<template>
    <div>
        <h3 style="margin-left: 15px">{{ publishInfo.name }}</h3>
        <el-card shadow="hover" style="width: 95%; margin-left: 20px">
            <div slot="header" class="clearfix">
                <el-row>
                    <el-col :span="24" style="color: #111111">
                        服务类型：
                        <span v-if="publishInfo.parentCategoryName != null">
                            {{ publishInfo.parentCategoryName }}-
                        </span>
                        {{ publishInfo.categoryName }}
                    </el-col>
                    <el-col :span="12" style="color: #111111; margin-top: 5px">
                        <i class="el-icon-location-outline"></i>
                        {{
                            publishInfo.publishAddress == null
                                ? ""
                                : publishInfo.publishAddress.address + publishInfo.publishAddress.detailed
                        }}
                    </el-col>
                    <el-col :span="6" style="color: #222222">
                        {{ publishInfo.createTime | dateFormat('YYYY-MM-DD HH:mm') }}
                    </el-col>
                    <el-col :span="6">
                        有<span style="color: #fc6035">{{
                            publishInfo.quoteCount
                        }}</span
                        >人报价
                    </el-col>
                </el-row>
            </div>
            <div>
                <el-row>
                    <el-col
                        :span="24"
                        style="
                            font-size: 20px;
                            font-weight: 400;
                            color: #111111;
                            margin-bottom: 30px;
                        "
                    >
                        {{ publishInfo.publishDesc }}
                    </el-col>
                    <el-col :span="24" style="margin-top: 10px">
                        <div class="out">
                            <div>
                                <video
                                    controls
                                    v-for="(
                                        item, index
                                    ) in publishInfo.publishImageList"
                                    :key="index"
                                    v-if="item.type == '002'"
                                    width="240"
                                    height="240"
                                    style="margin: 10px"
                                >
                                    <source :src="item.url" type="video/mp4" />
                                </video>
                                <el-image
                                    :src="item.url"
                                    style="
                                        width: 240px;
                                        height: 240px;
                                        margin: 10px;
                                    "
                                    v-for="(
                                        item, index
                                    ) in publishInfo.publishImageList"
                                    :key="index"
                                    :preview-src-list="publishImageList"
                                    v-if="item.type == '001'"
                                >
                                </el-image>
                            </div>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col
                        :span="24"
                        style="
                            font-size: 20px;
                            font-weight: 400;
                            color: #111111;
                            margin-bottom: 30px;
                        "
                    >
                    </el-col>
                </el-row>
            </div>
        </el-card>
        <div style="padding: 20px 30px">
            <el-row>
                <el-col :span="12">
                    <div
                        style="
                            font-size: 20px;
                            font-weight: bold;
                            color: #111111;
                            line-height: 40px;
                        "
                    >
                        服务人员报价
                    </div>
                </el-col>
                <el-col :span="2" :offset="10" v-if="publishInfo.status == 0">
                    <el-button
                        v-if="this.userRole === 'merchant'"
                        type="primary"
                        size="normal"
                        @click="clickQuote()"
                        >报价</el-button
                    >
                </el-col>
            </el-row>
        </div>
        <div
            v-if="publishQuoteList != null && publishQuoteList.length > 0"
            style="margin: 5px 20px 30px 20px"
        >
            <el-card
                v-for="item in publishQuoteList"
                :key="item.quoteId"
                style="margin-bottom: 10px"
            >
                <div slot="header" class="clearfix">
                    <el-row>
                        <el-image
                            style="
                                width: 80px;
                                height: 80px;
                                border-radius: 80px;
                                float: left;
                                margin-right: 10px;
                            "
                            fit="cover"
                            :src="item.serverUser.avatar"
                        >
                            <div slot="error">
                                <img
                                    src="../../../assets/images/def-header.png"
                                    alt=""
                                    style="
                                        width: 80px;
                                        height: 80px;
                                        border-radius: 80px;
                                        float: left;
                                        margin-right: 10px;
                                    "
                                />
                            </div>
                        </el-image>

                        <div class="fontFamily quote-left-container">
                            <el-row>
                                <el-col
                                    :span="6"
                                    style="
                                        font-size: 15px;
                                        font-weight: bold;
                                        color: #111111;
                                        margin-bottom: 3px;
                                    "
                                >
                                    {{ item.serverUser.realName }}
                                    <span
                                        style="
                                            font-size: 16px;
                                            color: #d99864;
                                            padding-left: 0px;
                                            margin-left: 10px;
                                        "
                                    >
                                        {{ item.serverUser.serverLevelName }}
                                    </span>
                                </el-col>

                                <el-col
                                    :span="6"
                                    :offset="12"
                                    style="
                                        font-weight: 400;
                                        color: #999999;
                                        text-align: right;
                                    "
                                >
                                    {{ item.createTime | dateFormat('YYYY-MM-DD HH:mm') }}
                                </el-col>
                                <br />

                                <el-col :span="24">
                                    <span
                                        class="server-age"
                                        style="margin-bottom: 3px"
                                        >{{
                                            item.serverUser.serverAge
                                        }}年工龄</span
                                    >
                                </el-col>
                                <br />
                                <el-col
                                    :span="8"
                                    style="
                                        font-weight: 400;
                                        color: #111111;
                                        margin: 4px 0;
                                        font-size: 14px;
                                    "
                                >
                                    综合评分:
                                    {{
                                        item.serverUser.score === null ? 0 : item.serverUser.score
                                    }}
                                    <span
                                        style="
                                            background: #ffffff;
                                            font-weight: 400;
                                            color: #111111;
                                            margin-left: 20px;
                                        "
                                    >
                                        好评率:
                                        {{
                                            item.serverUser.rate === null ? 0 : item.serverUser.rate
                                        }}%
                                    </span>
                                </el-col>

                                <el-col
                                    style="
                                        font-size: 14px;
                                        font-weight: 400;
                                        color: #999999;
                                    "
                                    v-if="item.merchant.merchantType === 0"
                                >
                                    {{ item.serverUser.merchantName }}
                                </el-col>
                            </el-row>
                        </div>
                    </el-row>
                </div>
                <div>
                    <div>
                        <div
                            style="
                                width: 100%;
                                background-color: #f7f8f9;
                                border-radius: 10px;
                            "
                        >
                            <div
                                style="
                                    font-size: 15px;
                                    font-weight: 400;
                                    color: #111111;
                                    padding: 12px;
                                    word-wrap: break-word
                                "
                            >
                                {{ item.quoteDesc }}
                            </div>
                        </div>
                        <el-row style="margin: 10px">
                            <el-col :span="6">
                                <span
                                    style="
                                        border-radius: 8px;
                                        font-size: 15px;
                                        width: 64px;
                                        height: 40px;
                                        line-height: 40px;
                                    "
                                    >报价：</span
                                >
                                <span style="color: #ff0000">{{
                                    item.totalPrice
                                }}</span
                                >元
                            </el-col>
                            <el-col
                                :span="6"
                                :offset="12"
                                v-if="item.merchantId == merchantId"
                            >
                                <el-button
                                    style="float: right; margin: 0 2px"
                                    size="mini"
                                    @click="delQuote(item.quoteId)"
                                    v-if="publishInfo.publishState === '001'"
                                    >删除</el-button
                                >
                                <el-button
                                    style="float: right; margin: 0 2px"
                                    size="mini"
                                    @click="addReply(item)"
                                    v-if="publishInfo.publishState === '001'"
                                    >留言</el-button
                                >
                                <el-button
                                    style="float: right; margin: 0 2px"
                                    size="mini"
                                    type="primary"
                                    @click="editQuote(item)"
                                    v-if="publishInfo.publishState === '001'"
                                    >编辑</el-button
                                >
                            </el-col>
                        </el-row>
                    </div>
                    <el-divider></el-divider>
                    <div
                        v-for="(re, index1) in item.quoteReplyVoList"
                        style="margin-left: 50px"
                        v-show="flag"
                        :key="index1"
                    >
                        <el-row
                            v-if="
                                re.serverUserId == item.serverUserId &&
                                re.quoteId == item.quoteId
                            "
                        >
                            <el-image
                                style="
                                    width: 40px;
                                    height: 40px;
                                    border-radius: 40px;
                                    margin-top: 10px;
                                    float: left;
                                    margin-right: 10px;
                                "
                                fit="cover"
                                :src="re.avatar"
                                v-if="re.replyType == '0'"
                            >
                              <div slot="error">
                                <img
                                  src="../../../assets/images/avatar_icon.png"
                                  alt=""
                                  style="
                                        width: 40px;
                                        height: 40px;
                                        border-radius: 40px;
                                        float: left;
                                        margin-right: 10px;
                                    "
                                />
                              </div>
                            </el-image>
                            <el-image
                                style="
                                    width: 40px;
                                    height: 40px;
                                    border-radius: 40px;
                                    margin-top: 10px;
                                    float: left;
                                    margin-right: 10px;
                                "
                                fit="cover"
                                :src="re.serverAvatar"
                                v-if="re.replyType == '1'"
                            >
                              <div slot="error">
                                <img
                                  src="../../../assets/images/def-header.png"
                                  alt=""
                                  style="
                                        width: 40px;
                                        height: 40px;
                                        border-radius: 40px;
                                        float: left;
                                        margin-right: 10px;
                                    "
                                />
                              </div>
                            </el-image>
                            <el-col
                                :span="23"
                                class="quote-reply-left-container"
                            >
                                <el-row
                                    style="
                                        margin-bottom: 10px;
                                        margin-top: 10px;
                                    "
                                >
                                    <el-col
                                        :span="6"
                                        v-if="re.replyType == '0'"
                                    >
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #111111;
                                            "
                                            >{{ re.name }}</span
                                        >
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #999999;
                                                margin: 0 8px;
                                            "
                                            v-if="re.serverName"
                                            >回复</span
                                        >
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #111111;
                                            "
                                            >{{ re.serverName }}</span
                                        >：
                                    </el-col>
                                    <el-col
                                        :span="6"
                                        v-if="re.replyType == '1'"
                                    >
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #111111;
                                            "
                                            >{{ re.serverName }}</span
                                        >
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #999999;
                                                margin: 0 8px;
                                            "
                                            v-if="re.name"
                                            >回复
                                        </span>
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #111111;
                                            "
                                            >{{ re.name }}</span
                                        >：
                                    </el-col>
                                    <el-col
                                        :span="6"
                                        :offset="12"
                                        style="
                                            font-size: 15px;
                                            color: #999999;
                                            text-align: right;
                                        "
                                    >
                                        {{ re.createTime | dateFormat('YYYY-MM-DD HH:mm') }}
                                    </el-col>
                                    <br />
                                    <el-col style="margin-top: 2px">
                                        <span
                                            style="
                                                font-size: 15px;
                                                color: #111111;
                                            "
                                            >{{ re.replyDesc }}</span
                                        >
                                        <el-button
                                            v-if="
                                                re.replyType == '1' &&
                                                item.merchantId == merchantId
                                            "
                                            size="mini"
                                            style="float: right"
                                            type="danger"
                                            @click="deleteReply(re)"
                                            >删除</el-button
                                        >
                                    </el-col>
                                </el-row>
                            </el-col>
                        </el-row>
                    </div>
                </div>
            </el-card>
            <pagination
                style="margin: 10px"
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                :page-sizes="[1, 5, 10, 20]"
                @pagination="getQuoteList"
            />
        </div>
        <div v-else>
            <div
                style="
                    text-align: center;
                    font-size: 30px;
                    color: #666666;
                    padding: 20px;
                "
            >
                暂无报价
            </div>
        </div>

        <!-- 报价对话框 -->
        <el-dialog
            title="我要报价"
            :visible.sync="quoteOpen"
            width="500px"
            append-to-body
        >
            <el-form
                ref="quoteForm"
                :model="quoteParams"
                label-width="120px"
                :rules="quoteRules"
            >
                <el-form-item label="报价描述">
                    <el-input
                        type="textarea"
                        :rows="4"
                        maxlength="500"
                        show-word-limit
                        placeholder="请输入内容"
                        v-model="quoteParams.quoteDesc"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="单价" prop="singlePrice">
                    <el-input-number
						placeholder="请输入单价"
                        v-model="quoteParams.singlePrice"
                        :controls="false"
                        :min="0"
                        :max="99999999.99"
                        :precision="2"
                        @blur="countTotalPrice()"
                    >
                        <template slot="append">元</template>
                    </el-input-number>
                </el-form-item>
                <el-form-item label="单位" prop="quoteUnit">
                    <el-select
						placeholder="请选择单位"
                        v-model="quoteParams.quoteUnit"
                        @change="justifyOther"
                        style="width: 100%"
                    >
                        <el-option
                            v-for="item in unitsOption"
                            :label="item.dictLabel"
                            :value="item.dictSort"
                            :key="item.dictSort"
                        ></el-option>
                    </el-select>
                    <el-input
                        v-if="otherUnitFlag"
                        v-model="quoteParams.otherUnit"
                        style="margin-top: 20px"
                        placeholder="其他单位:如“平方米”"
                    ></el-input>
                </el-form-item>
                <el-form-item label="单位时长" prop="singleTime">
                    <el-select
                        v-model="quoteParams.singleTime"
                        style="width: 100%"
                    >
                        <el-option
                            v-for="item in timeList"
                            :label="item + '小时'"
                            :value="item"
                            :key="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="数量" prop="quoteCounts">
                    <el-input-number
                        placeholder="请输入数量"
                        v-model.trim="quoteParams.quoteCounts"
                        :controls="false"
                        :min="0"
                        :max="99999"
                        :precision="0"
                        @blur="countTotalPrice()"
                    >
                    </el-input-number>
                </el-form-item>
                <el-form-item label="服务人员" prop="serverUserId">
                    <el-select
						placeholder="请选择服务人员"
                        v-model="quoteParams.serverUserId"
                        style="width: 100%"
                    >
                        <el-option
                            v-for="item in serverUserOption"
                            :label="item.realName"
                            :value="item.serverId"
                            :key="item.serverId"
                        ></el-option>
                    </el-select>
					<span style="color: red">注:如被选中则由此人来服务。</span>
                </el-form-item>
                <div style="float: right; margin-left: 0px">
                    总计：<span style="color: #ff0000">{{
                        (isNaN(quoteParams.quoteCounts) ? 0 : quoteParams.quoteCounts) * (isNaN(quoteParams.singlePrice) ? 0 : quoteParams.singlePrice)
                    }}</span
                    >元 /
                    <span style="color: #ff0000">{{
                        (isNaN(quoteParams.quoteCounts) ? 0 : quoteParams.quoteCounts) * (isNaN(quoteParams.singleTime) ? 0 : quoteParams.singleTime)
                    }}</span
                    >小时
                </div>
                <el-form-item style="">
                    <el-button type="primary" @click="save()">保存</el-button>
                    <el-button @click="qteCancel()">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
        <!-- 留言对话框 -->
        <el-dialog title="留言" :visible.sync="replyOpen">
            <el-form
                ref="replyForm"
                :model="replyParams"
                label-width="120px"
                style="height: 100px"
                :rules="quoteRules"
            >
                <el-form-item label="留言内容" prop="replyDesc">
                    <el-input
                        type="textarea"
                        rows="2"
                        v-model="replyParams.replyDesc"
                        maxlength="100"
                        show-word-limit
                        style="margin-bottom: 15px;"
                    ></el-input>
                    <el-button size="small" @click="add()" type="primary"
                        >保存</el-button
                    >
                    <el-button size="small" @click="replyCancel()"
                        >取消</el-button
                    >
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>

<script>
import { detail } from "@/api/merchant/merchant";
import {
    listPublishReply,
    addReply,
    listPublish,
    delPublishReply,
    listQuote,
} from "@/api/publish/publish";
import { addQuote, updateQuote, delQuote } from "@/api/publish/quote";
import { getPublishDetail } from "@/api/publish/adminPublish";
import { getInfo } from "@/api/login";
import { listCode } from "@/api/system/dict/code";
import { getDicts } from "@/api/system/dict/data";
import { listDownSelectUser } from "@/api/system/ServiceUserService";
export default {
    name: "publishDetails",
    data() {
        return {
            // 角色
            userRole: "",
            // 需求详情
            publishInfo: {},
            publishImageList: [],
            publishQuoteList: [],
            // 回复列表
            replyList: [],
            // 留言对话框
            replyOpen: false,
            // 编辑对话框
            quoteOpen: false,
            timeList: [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6],
            // 报价参数
            quoteParams: {
                quoteDesc: null,
                quoteUnit: null,
                otherUnit: null,
                serverUserId: null,
                merchantId: null,
                quoteCounts: undefined,
                singlePrice: undefined,
                singleTime: 0.5,
                totalPrice: null,
                totalTime: null,
                status: 0,
                publishId: null,
                quoteId: null,
            },
            //报价服务人员选项
            serverUserOption: [],
            //单价选项
            unitsOption: [],
            otherUnitFlag: false,
            //报价 表单校验
            quoteRules: {
                singlePrice: [
                    {
                        required: true,
                        message: "单价不能为空",
                        trigger: "blur",
                    },
                ],
                otherUnit: [
                    {
                        required: true,
                        message: "单位不能为空",
                        trigger: "blur",
                    },
                ],
                quoteCounts: [
                    {
                        required: true,
                        message: "数量不能为空",
                        trigger: "blur",

                    },
                ],
                quoteUnit: [
                    {
                        required: true,
                        message: "单位不能为空",
                        trigger: "blur",
                    },
                ],
                serverUserId: [
                    {
                        required: true,
                        message: "服务人员不能为空",
                        trigger: "blur",
                    },
                ],
            },
            replyParams: {
                quoteId: null, //quoteId
                memberId: null, //memberId
                replyDesc: null, //回复内容
                reReplyId: null, //回复回复ID
                serverUserId: null,
            },
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                publishId: null,
            },
            flag: true,
            merchantId: "",
            pageList: [],
            total: 0,
            disabled: false,
        };
    },

    created() {},

    mounted() {
        // this.listPublishReplyQuery();
        this.listUser();
        this.listUnit();
        this.getPublishDetail();
        this.queryParams.publishId = this.$route.query.publishId;
        this.getQuoteList();
    },

    methods: {
        // 查询需求详情信息
        getPublishDetail() {
            getPublishDetail(this.$route.query.publishId).then((res) => {
                this.publishInfo = res.data;
                this.publishImageList = []
                if (res.data.publishImageList != null && res.data.publishImageList.length > 0) {
                  for(let i = 0; i < res.data.publishImageList.length; i ++) {
                    if (res.data.publishImageList[i].type == '001') {
                      this.publishImageList.push(res.data.publishImageList[i].url)
                    }
                  }
                }
            });
        },

        // 点击【留言】按钮添加回复
        addReply(row) {
            this.replyParams.quoteId = row.quoteId;
            this.replyParams.memberId = this.publishInfo.memberId;
            this.replyParams.serverUserId = row.serverUserId;
            this.replyOpen = true;
        },

        // 添加留言
        add() {
            addReply(this.replyParams).then((res) => {
                this.replyParams.replyDesc = null;
                // 关闭留言框
                this.replyOpen = false;
                // 刷新报价列表
                this.getQuoteList();
                // this.listPublishReplyQuery();
            });
        },

        // 取消回复，关闭留言回复框
        replyCancel() {
            this.replyParams.replyDesc = null;
            // 关闭留言框
            this.replyOpen = false;
            // 刷新报价列表
            this.getQuoteList();
        },

        // listPublishReplyQuery() {
        //     listPublishReply().then((res) => {
        //         this.replyList = res.rows;
        //     });
        // },
        justifyOther(value) {
               console.log(value);
            if (value == 999) {
                this.otherUnitFlag = true;
            } else {
                this.otherUnitFlag = false;
            }
        },
        // firstQuote() {
        //     let param = {
        //         merchantId: this.merchantId,
        //     };
        //     listDownSelectUser(param).then((res) => {
        //         this.quoteServerUserOption = res.rows;
        //         this.quoteOpen = true;

        //     });
        // },

        // 点击【编辑】按钮编辑报价信息
        editQuote(item) {
            // 打开报价框
            this.disabled = true;
            this.quoteOpen = true;
            // 组装参数
            this.quoteParams.merchantId = item.merchantId;
            this.quoteParams.publishId = this.publishInfo.publishId;
            this.quoteParams.quoteId = item.quoteId;
            this.quoteParams.singlePrice = item.singlePrice;
            this.quoteParams.quoteDesc = item.quoteDesc;
            this.quoteParams.quoteCounts = item.quoteCounts;

            for (let i in this.serverUserOption) {
                if (item.serverUserId == this.serverUserOption[i].serverId) {
                    this.quoteParams.serverUserId =
                        this.serverUserOption[i].serverId;
                }
            }
            for (let j in this.unitsOption) {
                if (
                    item.quoteUnit == this.unitsOption[j].dictSort &&
                    item.quoteUnit !== 999
                ) {
                    this.quoteParams.quoteUnit = this.unitsOption[j].dictSort;
                } else if (
                    this.unitsOption[j].dictSort == 999 &&
                    item.quoteUnit == 999
                ) {
                    this.quoteParams.quoteUnit = this.unitsOption[j].dictSort;
                    this.quoteParams.otherUnit = item.otherUnit;
                    this.otherUnitFlag = true;
                }
            }
        },

        // 删除报价
        delQuote(quoteId) {
            this.$modal
                .confirm("是否确认删除此条报价？")
                .then(function () {
                    return delQuote(quoteId);
                })
                .then(() => {
                    this.$modal.msgSuccess("删除成功");
                    // 刷新详情信息
                    this.getPublishDetail();
                    // 刷新报价列表
                    this.getQuoteList();
                })
                .catch(() => {});
        },

        // 报价参数重置
        resetQuoteParams() {
            this.quoteParams = {
                quoteDesc: null,
                quoteUnit: null,
                otherUnit: null,
                serverUserId: null,
                merchantId: null,
                quoteCounts: undefined,
                singlePrice: undefined,
                singleTime: 0.5,
                totalPrice: 0,
                totalTime: 0,
                status: 0,
                publishId: null,
                quoteId: null,
            };
            // 清空表单
            if (this.$refs.quoteForm) {
                this.$refs.quoteForm.clearValidate()
            }
        },

        // 报价对话框计算总价
        countTotalPrice() {
            if (
                this.quoteParams.singlePrice &&
                this.quoteParams.singlePrice < 0.01
            ) {
                return this.$modal.msgError("单价不能小于0.01");
            }
            if (
                this.quoteParams.singlePrice &&
                this.quoteParams.quoteCounts
            ) {
                this.queryParams.totalPrice =
                    this.quoteParams.singlePrice * this.quoteParams.quoteCounts;
            }
        },

        // 点击报价框里【保存】按钮
        save() {
            // 校验参数
            if (!this.quoteParams.singlePrice) {
                return this.$modal.msgError("请输入单价");
            }
            if (!this.quoteParams.quoteUnit) {
                return this.$modal.msgError("请选择单位");
            }
            if (!this.quoteParams.quoteCounts) {
                return this.$modal.msgError("请输入数量");
            }
            if (!this.quoteParams.serverUserId) {
                return this.$modal.msgError("请选择服务人员");
            }
            if (this.quoteParams.quoteDesc && this.quoteParams.quoteDesc.length > 500) {
                return this.$modal.msgError("报价描述字数不得超过500")
            }
            if (this.quoteParams.otherUnit && this.quoteParams.otherUnit.length > 10) {
                return this.$modal.msgError("其他单位长度不得超过10")
            }
            // 编辑后选择的不是其他单位时,将之前的其他单位值清空
            if (this.quoteParams.quoteId !== null
                && this.quoteParams.quoteUnit !==  999
                && this.quoteParams.otherUnit
                && this.quoteParams.otherUnit.length > 0) {
                this.quoteParams.otherUnit = "";
            }
            if (this.quoteParams.quoteId !== null) {
                // 编辑报价
                updateQuote(this.quoteParams).then((res) => {
                    if (res.code === 200) {
                        // 关闭报价框
                        this.quoteOpen = false;
                        // 刷新报价列表
                        this.getQuoteList();
                        // 刷新详情
                        this.getPublishDetail();
                    }
                });
            } else {
                // 添加报价
                addQuote(this.quoteParams).then((res) => {
                    if (res.code === 200) {
                        // 关闭报价框
                        this.quoteOpen = false;
                        // 刷新报价列表
                        this.getQuoteList();
                        // 刷新详情
                        this.getPublishDetail();
                    }
                });
            }
        },

        // 点击【报价】按钮
        clickQuote() {
            // 打开报价框
            this.quoteOpen = true;
            // 组装报价参数
            this.quoteParams.publishId = this.$route.query.publishId;
            this.quoteParams.merchantId = this.merchantId;
            this.quoteParams.totalPrice =
                this.quoteParams.singlePrice * this.quoteParams.quoteCounts;
            this.quoteParams.totalTime =
                this.quoteParams.singleTime * this.quoteParams.quoteCounts;
            // 查询服务人员下拉选
            let param = {
                merchantId: this.merchantId,
            };
            listDownSelectUser(param).then((res) => {
                this.quoteServerUserOption = res.rows;
            });
        },

        // 取消报价，关闭报价弹框
        qteCancel() {
            // 关闭报价框
            this.quoteOpen = false;
            // 重置报价参数
            this.resetQuoteParams();
            // 刷新报价列表
            this.getQuoteList();
        },

        // 加载服务人员下拉选列表
        listUser() {
            getInfo().then((r) => {
                if (r.roles[0] === "merchant") {
                    if (r.merchant.merchantId !== null) {
                        this.merchantId = r.merchant.merchantId;
                    }
                    this.userRole = r.roles[0]
                }
                let param = {
                    merchantId: this.merchantId,
                };
                //报价列表服务人员信息
                listDownSelectUser(param).then((res) => {
                    this.serverUserOption = res.rows;
                    console.log(
                        "serverUserOption--------------",
                        this.serverUserOption
                    );
                });
            });
        },

        // 加载报价单位
        listUnit() {
            // let param = {
            //     codeValue: "报价单位",
            // };
            // listCode(param).then((res) => {
            //     this.unitsOption = res.rows;
            // });

            //查询报检单位集合
            let param = "goods_unit";
             getDicts(param).then((res) => {
                 if(res.code==200){
                    this.unitsOption = res.data;
                 }
            });
        },

        // 商家删除留言
        deleteReply(row) {
            console.log(row);
            this.$modal
                .confirm("是否确认删除此条评论？")
                .then(function () {
                    return delPublishReply(row.replyId);
                })
                .then(() => {
                    // this.listPublishReplyQuery();
                    // 刷新报价信息列表
                    this.getQuoteList();
                    this.$modal.msgSuccess("删除成功");
                })
                .catch(() => {});
        },

        // 报价列表
        getQuoteList() {
            this.queryParams.publishId = this.$route.query.publishId;
            listQuote(this.queryParams).then((res) => {
                this.publishQuoteList = res.rows;
                this.total = res.rows.length;
                console.log("listQuote--------------", this.publishQuoteList);
            });
        }
    }
};
</script>

<style scoped="scoped">
.out {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}
.in {
    height: 25%;
    width: 25%;
    box-sizing: border-box;
    margin-left: 5px;
}
.fontFamily {
    font-family: "微软雅黑";
}
.server-age {
    background: linear-gradient(
        269deg,
        rgb(231, 194, 161) 0%,
        rgb(231, 194, 161) 0%,
        rgb(244, 235, 225) 100%,
        rgb(244, 235, 225) 100%
    );
    padding: 3px 5px;
    font-size: 11px;
    font-weight: 500;
    color: rgb(136, 92, 75);
    border-radius: 4px;
}
.quote-left-container {
    width: -webkit-calc(100% - 130px);
    width: -moz-calc(100% - 130px);
    width: calc(100% - 130px);
    float: left;
}

.quote-reply-left-container {
    width: -webkit-calc(100% - 90px);
    width: -moz-calc(100% - 90px);
    width: calc(100% - 90px);
}
</style>
