<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-roleEdit"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="common-page-shadow" v-loading="loading">
      <div class="common-table-container flex searchPanel">
        <div class="common-table-wrapper">
          <div
            class="common-btn-group"
            style="display: flex; align-items: center; margin-top: 10px"
          >
            <el-button
              type="primary"
              icon="el-icon-download"
              :loading="exporting"
              size="small"
              plain
              :disabled="show"
              @click="handleDown"
              >下载报价模板</el-button
            >
            <import-file :importData="importData" @load="load"></import-file>
          </div>
          <!-- LJ：表格高度自适应需配合样式  btn-pagenation 有按钮有分页  btngroup只有按钮  pagenation只有分页 -->
          <div class="common-table-content btn-pagenation">
            <!-- 服务 -->
            <el-table
              :border="true"
              stripe
              fit
              size="mini"
              row-key="id"
              v-loading="tableLoading"
              ref="multipleSelection"
              highlight-current-row
              highlight-selection-row
              @cell-click="cellClick"
              v-if="$route.query.rows.applicationType == 1"
              :data="tableData"
              height="100%"
            >
              <!-- <el-table-column type="expand" width="55" align="center" label="">
                <template slot-scope="scope">
                  <el-table
                    border
                    label-position="left"
                    stripe
                    fit
                    style="width: 100%;"
                    size="mini"
                    :row-key="scope.row.id"
                    :data="detailsData"
                    v-loading="tableLoading"
                    ref="multipleSelection"
                  >
                  <el-table-column
                      label="费用名称"
                      show-overflow-tooltip
                      align="center"
                      width="130px"
                      prop="matName"
                    ></el-table-column>
                    <el-table-column
                      label="付款次数"
                      show-overflow-tooltip
                      align="center"
                      width="110px"
                      prop="payFrequency"
                    ></el-table-column>
                    <el-table-column
                      label="付款比例(%)"
                      show-overflow-tooltip
                      align="center"
                      width="110px"
                      prop="payRatio"
                    ></el-table-column>
                    <el-table-column
                      label="付款金额(万元)"
                      show-overflow-tooltip
                      align="center"
                      width="110px"
                      prop="payAmount"
                    ></el-table-column>
                  </el-table>
                </template>
              </el-table-column> -->
              <el-table-column
                width="90"
                align="center"
                label="类型"
                prop="detailType"
              >
                <template slot-scope="scope">
                  <div v-if="scope.row.detailType == 1">服务</div>
                  <div v-if="scope.row.detailType == 2">工程</div>
                  <div v-if="scope.row.detailType == 3">设备或物资</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="noticeCode"
                min-width="120px"
                show-overflow-tooltip
                label="项目编号"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="matName"
                min-width="120px"
                show-overflow-tooltip
                label="项目名称"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                label="服务内容"
                min-width="130px"
                show-overflow-tooltip
                align="center"
                prop="matOtherExt"
              ></el-table-column>
              <el-table-column
                label="服务范围"
                show-overflow-tooltip
                align="center"
                min-width="130px"
                prop="matBaseExt"
              ></el-table-column>
              <el-table-column
                label="服务开始时间"
                show-overflow-tooltip
                align="center"
                min-width="110px"
                prop="serviceStartTime"
              ></el-table-column>
              <el-table-column
                label="服务结束时间"
                show-overflow-tooltip
                align="center"
                min-width="110px"
                prop="serviceEndTime"
              ></el-table-column>
              <el-table-column
                :prop="
                  'quoValue' + `${(params.quotationRoundsNum - 1).toString()}`
                "
                show-overflow-tooltip
                min-width="80px"
                align="center"
                :label="'第' + `${params.quotationRoundsNum - 1}` + '轮报价'"
                v-if="params.quotationRoundsNum > 1"
                resizable
              >
                <template slot-scope="scope">
                  <div>{{ scope.row.quoValue1 }}</div>
                </template>
              </el-table-column>
              <el-table-column
                :prop="
                  'quoValue' + `${(params.quotationRoundsNum - 1).toString()}`
                "
                show-overflow-tooltip
                min-width="80px"
                align="center"
                :label="
                  '第' + `${params.quotationRoundsNum - 1}` + '轮报价总额'
                "
                v-if="params.quotationRoundsNum > 1"
                resizable
              >
                <template slot-scope="scope">
                  <div>
                    {{ (scope.row.quoValue1 * scope.row.matNum).toFixed(2) }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                header-align="center"
                align="center"
                v-for="(item, index) in tableHeadData"
                :key="index"
                :prop="item.prop"
                min-width="120"
                :label="item.quoArrange"
              >
                <template slot-scope="scope">
                  <el-input
                    size="small"
                    :min="0"
                    v-if="item.priceEntry == 1"
                    v-model="scope.row.quotationTemplateDetailList[index].value"
                    onkeyup="this.value=this.value.match(/\d+\.?\d{0,4}/);this.dispatchEvent(new Event('input'))"
                    @input="changeQuoArrange(scope.row, index)"
                  ></el-input>
                  <div v-if="item.priceEntry == '2'">
                    <div
                      v-if="
                        scope.row.quotationTemplateDetailList[index].value ==
                          undefined ||
                        scope.row.quotationTemplateDetailList[index].value ==
                          0 ||
                        scope.row.quotationTemplateDetailList[index].value == ''
                      "
                    >
                      0
                    </div>
                    <div v-else>
                      {{ (scope.row.quoArrange * scope.row.matNum).toFixed(2) }}
                    </div>
                  </div>
                  <div v-if="item.priceEntry == '0'">
                    <el-tooltip
                      width="250"
                      placement="top-start"
                      effect="light"
                      :content="
                        scope.row.quotationTemplateDetailList[index].value
                      "
                    >
                      <el-input
                        v-model="
                          scope.row.quotationTemplateDetailList[index].value
                        "
                        @input="changeQuoArrange(scope.row, index)"
                      ></el-input>
                    </el-tooltip>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="预算总金额(万元)"
                align="center"
                min-width="140"
                prop="payAmount"
              >
              </el-table-column>
              <el-table-column
                prop="tenderExplain"
                show-overflow-tooltip
                min-width="100px"
                align="center"
                label="投标补充说明"
                resizable
              >
                <template slot-scope="scope">
                  <el-tooltip
                    width="250"
                    placement="top-start"
                    effect="light"
                    :content="scope.row.tenderExplain"
                  >
                    <el-input
                      @input="changeQuoArrange(scope.row, index)"
                      v-model="scope.row.tenderExplain"
                      placeholder="投标补充说明"
                    ></el-input>
                  </el-tooltip>
                </template>
              </el-table-column>
            </el-table>
            <!-- 工程 -->
            <el-table
              :border="true"
              stripe
              fit
              size="mini"
              v-loading="tableLoading"
              ref="multipleSelection"
              v-if="$route.query.rows.applicationType == 2"
              :data="tableData"
              @cell-mouse-enter="handleCellEnter"
              @cell-mouse-leave="handleCellLeave"
              height="100%"
            >
              <el-table-column
                type="index"
                width="55"
                align="center"
                label="序号"
              >
              </el-table-column>

              <el-table-column
                width="90"
                align="center"
                label="类型"
                prop="detailType"
              >
                <template slot-scope="scope">
                  <div v-if="scope.row.detailType == 1">服务</div>
                  <div v-if="scope.row.detailType == 2">工程</div>
                  <div v-if="scope.row.detailType == 3">设备或物资</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="noticeCode"
                min-width="90px"
                show-overflow-tooltip
                label="项目编号"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="matName"
                min-width="90px"
                show-overflow-tooltip
                label="项目名称"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="matOtherExt"
                min-width="120px"
                label="服务内容"
                align="center"
                resizable
              >
              </el-table-column>

              <el-table-column
                prop="matBaseExt"
                min-width="120px"
                show-overflow-tooltip
                label="服务范围"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                label="开始时间"
                align="center"
                min-width="120"
                prop="serviceStartTime"
              >
              </el-table-column>
              <el-table-column
                label="结束时间"
                align="center"
                min-width="120"
                prop="serviceEndTime"
              >
              </el-table-column>
              <el-table-column
                prop="matUnit"
                show-overflow-tooltip
                min-width="80px"
                align="center"
                label="计量单位"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="matNum"
                show-overflow-tooltip
                min-width="80px"
                align="center"
                label="数量"
                resizable
              >
              </el-table-column>
              <el-table-column
                :prop="
                  'quoValue' + `${(params.quotationRoundsNum - 1).toString()}`
                "
                show-overflow-tooltip
                min-width="80px"
                align="center"
                :label="'第' + `${params.quotationRoundsNum - 1}` + '轮报价'"
                v-if="params.quotationRoundsNum > 1"
                resizable
              >
                <template slot-scope="scope">
                  <div>{{ scope.row.quoValue1 }}</div>
                </template>
              </el-table-column>
              <el-table-column
                :prop="
                  'quoValue' + `${(params.quotationRoundsNum - 1).toString()}`
                "
                show-overflow-tooltip
                min-width="80px"
                align="center"
                :label="
                  '第' + `${params.quotationRoundsNum - 1}` + '轮报价总额'
                "
                v-if="params.quotationRoundsNum > 1"
                resizable
              >
                <template slot-scope="scope">
                  <div>
                    {{ (scope.row.quoValue1 * scope.row.matNum).toFixed(2) }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                header-align="center"
                align="center"
                v-for="(item, index) in tableHeadData"
                :key="index"
                :prop="item.prop"
                min-width="120"
                :label="item.quoArrange"
              >
                <template slot-scope="scope">
                  <el-input
                    size="small"
                    :min="0"
                    v-if="item.priceEntry == 1"
                    v-model="scope.row.quotationTemplateDetailList[index].value"
                    onkeyup="this.value=this.value.match(/\d+\.?\d{0,4}/);this.dispatchEvent(new Event('input'))"
                    @input="changeQuoArrange(scope.row, index)"
                  ></el-input>
                  <div v-if="item.priceEntry == '2'">
                    <div
                      v-if="
                        scope.row.quotationTemplateDetailList[index].value ==
                          undefined ||
                        scope.row.quotationTemplateDetailList[index].value ==
                          0 ||
                        scope.row.quotationTemplateDetailList[index].value == ''
                      "
                    >
                      0
                    </div>
                    <div v-else>
                      {{ (scope.row.quoArrange * scope.row.matNum).toFixed(2) }}
                    </div>
                  </div>
                  <div v-if="item.priceEntry == '0'">
                    <el-tooltip
                      width="250"
                      placement="top-start"
                      effect="light"
                      :content="
                        scope.row.quotationTemplateDetailList[index].value
                      "
                    >
                      <el-input
                        v-model="
                          scope.row.quotationTemplateDetailList[index].value
                        "
                        @input="changeQuoArrange(scope.row, index)"
                      ></el-input>
                    </el-tooltip>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="图号/规格型号"
                min-width="170"
                align="center"
                prop="matSpec"
              >
              </el-table-column>
              <el-table-column
                align="center"
                label="项目描述"
                min-width="170"
                prop="projectDescript"
              >
              </el-table-column>
              <el-table-column
                label="备注"
                align="center"
                min-width="170"
                prop="remark"
              >
              </el-table-column>
              <el-table-column
                prop="tenderExplain"
                show-overflow-tooltip
                min-width="100px"
                align="center"
                label="投标补充说明"
                resizable
              >
                <template slot-scope="scope">
                  <el-tooltip
                    width="250"
                    placement="top-start"
                    effect="light"
                    :content="scope.row.tenderExplain"
                  >
                    <el-input
                      @input="changeQuoArrange(scope.row, index)"
                      v-model="scope.row.tenderExplain"
                      placeholder="投标补充说明"
                    ></el-input>
                  </el-tooltip>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div class="common-pagenation">
            <div class="common-total">
              <div class="text">
                报价总额: <span>￥{{ totalValue }}</span>
              </div>
              <div class="btn">
                <el-button
                  type="primary"
                  size="small"
                  :disabled="show"
                  :loading="saveing"
                  @click="open"
                  >提交报价</el-button
                >
              </div>
            </div>
          </div>
        </div>
        <div class="common-table-quote">
          <div class="quote-content">
            <div class="rows">
              <div class="rows-left">
                <div class="rows-hr"></div>
              </div>
              <div class="rows-title">
                <div class="text-overflow">报价截止时间</div>
              </div>
            </div>
            <div class="auction">
              <div id="box">
                <div id="time">
                  <div
                    id="time"
                    style="text-align: center"
                    v-if="
                      time > 0 &&
                      Date.now() -
                        new Date(this.params.biddingStartTime).getTime() >
                        0
                    "
                  >
                    <strong>
                      <span id="day"> {{ dateTime.days }}天 </span>
                    </strong>
                    <strong>
                      <span id="hour"> {{ dateTime.hours }}时 </span>
                    </strong>
                    <strong>
                      <span id="minute"> {{ dateTime.minutes }}分 </span>
                    </strong>
                    <strong>
                      <span id="second"> {{ dateTime.seconds }}秒 </span>
                    </strong>
                  </div>
                  <div style="text-align: center; color: red" v-else>
                    {{ countDown }}
                  </div>
                </div>
              </div>
            </div>
            <div class="rows" style="margin-bottom: 0">
              <div class="rows-left">
                <div class="rows-hr"></div>
              </div>
              <div class="rows-title">
                <div class="text-overflow">
                  <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane name="0" label="招标文件"></el-tab-pane>
                    <el-tab-pane name="1" label="澄清提问"></el-tab-pane>
                    <el-tab-pane name="2" label="投标文件"></el-tab-pane>
                    <el-tab-pane name="3" label="补遗文件"></el-tab-pane>
                    <el-tab-pane
                      name="4"
                      label="评分标准"
                      v-if="method != 1"
                    ></el-tab-pane>
                  </el-tabs>
                </div>
              </div>
            </div>
            <div class="content" v-if="activeName == 0">
              <el-table
                class="down"
                :data="dataList"
                size="mini"
                border
                stripe
                style="width: 100%; margin-top: 20px"
              >
                <el-table-column prop="name" label="文件名称"></el-table-column>
                <el-table-column width="150px" label="操作">
                  <template slot-scope="scope">
                    <el-button size="small" type="text">
                      <a @click="downloadFile(scope.row.name, scope.row.url)"
                        >下载</a
                      >
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="content" v-if="activeName == 1">
              <el-table
                class="down"
                :data="clarifyList"
                size="mini"
                border
                :key="activeName == 1"
                stripe
                style="width: 100%; margin-top: 20px"
              >
                <el-table-column type="expand">
                  <template slot-scope="props">
                    <el-table
                      :key="'childTable' + props.row.id"
                      header-cell-class-name="selectAllbtnDis"
                      :ref="'childTable' + props.row.id"
                      :data="props.row.answerList"
                      style="width: 100%; margin-left: 25px"
                    >
                      <el-table-column label="澄清企业" prop="operateOrgName">
                      </el-table-column>
                      <el-table-column label="澄清描述" prop="describe">
                      </el-table-column>
                      <el-table-column label="澄清时间" prop="operateTime">
                      </el-table-column>
                      <el-table-column
                        prop="name"
                        label="附件"
                      ></el-table-column>
                      <el-table-column width="120px" label="操作">
                        <template slot-scope="scope">
                          <el-button
                            size="small"
                            v-if="scope.row.accessoryList.length != 0"
                            type="text"
                          >
                            <a
                              @click="
                                downloadFile(scope.row.name, scope.row.url)
                              "
                              >下载</a
                            >
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="operateOrgName"
                  label="提问企业"
                  min-width="100px"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  prop="describe"
                  min-width="100px"
                  label="描述"
                  show-overflow-tooltip
                ></el-table-column>

                <el-table-column
                  prop="operateTime"
                  min-width="100px"
                  label="提出时间"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  prop="name"
                  min-width="100px"
                  label="文件名称"
                ></el-table-column>
                <el-table-column min-width="80px" label="操作">
                  <template slot-scope="scope">
                    <el-button
                      size="small"
                      v-if="scope.row.accessoryList.length != 0"
                      type="text"
                    >
                      <a @click="downloadFile(scope.row.name, scope.row.url)"
                        >下载</a
                      >
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <!-- 投标文件 -->
            <div class="content" v-if="activeName == 2">
              <el-checkbox-group
                v-model="checkboxData"
                @change="changeCheck"
                style="margin: 10px 0px"
                size="medium"
              >
                <el-checkbox
                  label="线上投标"
                  false-label="null"
                  size="medium"
                  :true-label="1"
                ></el-checkbox>
                <el-checkbox
                  label="线下投标"
                  false-label="null"
                  size="medium"
                  :true-label="2"
                ></el-checkbox>
              </el-checkbox-group>
              <!-- 线上投标 -->
              <el-table
                class="down"
                :data="tenderList"
                size="mini"
                border
                v-if="checkboxData =='1'"
                stripe
                style="width: 100%"
              >
                <el-table-column prop="name" label="文件名称"></el-table-column>
                <el-table-column width="150px" label="操作">
                  <template slot-scope="scope">
                    <el-button size="small" type="text">
                      <a @click="downloadFile(scope.row.name, scope.row.url)"
                        >下载</a
                      >
                    </el-button>
                    <el-button
                      size="small"
                      type="text"
                      v-if="params.quotationRoundsNum == params.quotationRounds"
                      @click="deleteHandle(scope.row.id, scope.$index)"
                      >删除</el-button
                    >
                    <el-button
                      size="small"
                      type="text"
                      v-if="scope.row.bidSignStatus==1"
                      @click="handleSign(scope.row, scope.$index)"
                      >签署</el-button
                    >
                    <el-button
                      size="small"
                      type="text" @click="handleQuery(scope.row, scope.$index)" v-if="scope.row.bidSignStatus==2">签署中</el-button>
                    <el-button
                      size="small"
                      type="text" @click="handleQuery(scope.row, scope.$index)" v-if="scope.row.bidSignStatus==3">已签署</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 线下投标 -->
              <el-table
                class="down"
                :data="tenderList"
                size="mini"
                border
                v-if="checkboxData =='2'"
                stripe
                style="width: 100%"
              >
                <el-table-column prop="name" label="文件名称"></el-table-column>
                <el-table-column width="150px" label="操作">
                  <template slot-scope="scope">
                    <el-button size="small" type="text">
                      <a @click="downloadFile(scope.row.name, scope.row.url)"
                        >下载</a
                      >
                    </el-button>
                    <el-button
                      size="small"
                      type="text"
                      v-if="params.quotationRoundsNum == params.quotationRounds"
                      @click="deleteHandle(scope.row.id, scope.$index)"
                      >删除</el-button
                    >
                    
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <!-- 补遗文件 -->
            <div class="content" v-if="activeName == 3">
              <el-table
                class="down"
                :data="addendumList"
                size="mini"
                border
                v-loading="dataing"
                stripe
                style="width: 100%; margin-top: 20px"
              >
                <el-table-column
                  prop="describe"
                  show-overflow-tooltip
                  label="描述"
                ></el-table-column>
                <el-table-column prop="isVendorConfirm" label="是否需要确认">
                  <template slot-scope="scope">
                    <div v-if="scope.row.isVendorConfirm == '2'">是</div>
                    <div v-if="scope.row.isVendorConfirm == '1'">否</div>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="name"
                  label="文件名称"
                  :key="activeName == 3"
                ></el-table-column>
                <el-table-column width="100px" label="操作">
                  <template slot-scope="scope">
                    <el-button size="small" type="text">
                      <a @click="downloadFile(scope.row.name, scope.row.url)"
                        >下载</a
                      >
                    </el-button>
                    <el-button
                      size="small"
                      type="text"
                      v-if="
                        scope.row.isVendorConfirm == 2 &&
                        scope.row.confirmStatus == 0
                      "
                    >
                      <a @click="byReluat(scope.row)">确认</a>
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            <div class="content" v-if="activeName == 4">
              <el-table
                :border="true"
                stripe
                fit
                size="mini"
                :key="params.evaluationMethod"
                row-key="id"
                ref="multipleSelection"
                v-loading="dataing"
                default-expand-all
                style="width: calc(100% - 20px)"
                :data="scoreData"
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
              >
                <el-table-column
                  prop="evaluationItemPname"
                  min-width="100px"
                  class-name="el-table-lable-box"
                  label="评分大项"
                  align="center"
                  resizable
                >
                </el-table-column>
                <el-table-column
                  label="评分细项"
                  min-width="130px"
                  prop="evaluationItemCode"
                >
                  <template slot-scope="scope">
                    <div>
                      {{ scope.row.evaluationItemCode }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="评分标准"
                  min-width="130px"
                  prop="evaluationStandard"
                >
                  <template slot-scope="scope">
                    <div>
                      {{ scope.row.evaluationStandard }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="分值"
                  min-width="100px"
                  prop="evaluationScore"
                >
                </el-table-column>
              </el-table>
            </div>
            <div class="btn">
              <el-button
                icon="el-icon-upload"
                @click="openBid"
                v-if="this.activeName == 2"
                size="small"
                :disabled="show"
                type="primary"
                >添加文件</el-button
              >
              <el-button
                icon="el-icon-upload"
                @click="openQuestion"
                v-if="this.activeName == 1"
                size="small"
                :disabled="show"
                type="primary"
                >添加提问</el-button
              >
            </div>
            <div class="rows" style="margin-bottom: 0">
              <div class="rows-left">
                <div class="rows-hr"></div>
              </div>
              <div class="rows-title">
                <div class="text-overflow">付款信息</div>
              </div>
            </div>
            <el-table
              :data="form.payInfoList"
              style="width: 100%"
              border
              height="140px"
              size="mini"
            >
              <el-table-column
                min-width="150"
                show-overflow-tooltip
                prop="matName"
                label="费用名称"
              >
              </el-table-column>
              <el-table-column
                min-width="150"
                prop="payTerm"
                label="付款条件"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                min-width="120"
                prop="payFrequency"
                label="付款次数"
                show-overflow-tooltip
              >
                <template slot-scope="scope">
                  <div>第{{ scope.row.payFrequency }}次</div>
                </template>
              </el-table-column>
              <el-table-column
                min-width="110"
                prop="payRatio"
                label="付款比例(%)"
                show-overflow-tooltip
              >
              </el-table-column>
              <el-table-column
                min-width="130"
                prop="payAmount"
                show-overflow-tooltip
                label="付款金额(万元)"
              >
              </el-table-column>
              <el-table-column
                min-width="180"
                prop="remarks"
                show-overflow-tooltip
                label="备注"
              >
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
    </div>
    <!-- 投标文件上传 -->
    <el-dialog
      title="投标文件上传"
      :visible.sync="dialogVisible"
      width="60%"
      v-loading="loading"
      :before-close="dialogBeforeClose"
    >
      <div>
        <el-form label-width="80px">
          <el-form-item label="投标文件">
            <el-upload
              class="upload-demo"
              ref="upload"
              :headers="headers"
              :action="action"
              :file-list="bidFileList"
              style="text-align: left"
              :multiple="false"
              accept=".docx,.doc"
              :on-progress="handleProgress"
              :show-file-list="false"
              :before-upload="beforeUpload"
              :on-success="handleSuccess"
            >
              <el-button
                icon="el-icon-upload"
                slot="trigger"
                style="width: 100% !important"
                size="small"
                type="primary"
                >上传文件</el-button
              >
            </el-upload>
          </el-form-item>
        </el-form>
        <el-table
          class="down"
          :data="bidFileList"
          border
          stripe
          style="width: 100%; margin-top: 20px"
        >
          <el-table-column prop="name" label="文件名称"></el-table-column>
          <el-table-column prop="size" label="文件大小">
            <template slot-scope="scope">
              <span>{{ scope.row.fileSize }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="上传时间">
            <template slot-scope="scope">
              <div>
                {{ scope.row.createTime }}
              </div>
            </template>
          </el-table-column>
          <el-table-column width="150px" label="操作">
            <template slot-scope="scope">
              <el-button size="small" type="text">
                <a
                  target="_blank"
                  @click="downloadFile(scope.row.name, scope.row.url)"
                  >下载</a
                >
              </el-button>
              <el-button
                size="small"
                type="text"
                @click="deleteFile(scope.$index)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" :loading="biding" @click="saveBid"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <!-- 提问 -->
    <el-dialog
      title="澄清提问"
      :visible.sync="visible"
      width="width"
      :before-close="dialogBeforeClose"
    >
      <el-form :model="form">
        <el-form-item label="问题描述" label-width="90px" prop="describe">
          <el-input
            type="textarea"
            autosize
            placeholder="请输入问题描述"
            v-model="form.describe"
          ></el-input>
        </el-form-item>
        <el-form-item label="附件上传" label-width="90px">
          <el-upload
            class="upload-demo"
            ref="upload"
            :headers="headers"
            :action="action"
            :file-list="form.accessoryList"
            :multiple="false"
            style="text-align: left"
            accept=".png,.jpg,.jpeg,.xlsx,.xls,.pdf,.docx,.doc,.zip,.rar"
            :show-file-list="false"
            :before-upload="beforeUpload"
            :on-success="handleSuccess"
          >
            <el-button slot="trigger" size="small" type="primary"
              >上传文件</el-button
            >
          </el-upload>
        </el-form-item>
      </el-form>
      <el-table
        class="down"
        :data="form.accessoryList"
        border
        stripe
        style="width: 100%; margin-top: 20px"
      >
        <el-table-column prop="name" label="文件名称"></el-table-column>
        <el-table-column prop="size" label="文件大小">
          <template slot-scope="scope">
            <span>{{ scope.row.fileSize }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="上传时间">
          <template slot-scope="scope">
            <div>
              {{ scope.row.createTime }}
            </div>
          </template>
        </el-table-column>
        <el-table-column width="150px" label="操作">
          <template slot-scope="scope">
            <el-button size="small" type="text">
              <a
                target="_blank"
                @click="downloadFile(scope.row.name, scope.row.url)"
                >下载</a
              >
            </el-button>
            <el-button
              size="small"
              type="text"
              @click="deleteHandle(scope.$index)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer">
        <el-button @click="visible = false">取 消</el-button>
        <el-button type="primary" :loading="quesing" @click="handleQuestion"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import {mapState} from 'vuex'
import basicData from '@/api/basicData'
import utils from '@/utils.js'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  props: {
    editData: Object,
  },

  data() {
    return {
      form: {
        accessoryList: [],
        describe: '',
      },
      totalValue: 0,
      importData: {
        title: '导入报价',
        templateName: '导入报价导入模板.xls',
        downloadUrl:
          window.context.portal +
          '/projectApprovalDetails/v1/exportTemplateToExcel',
        importUrl:
          window.context.portal +
          '/projectApprovalDetails/v1/excelTemplateToData',
        show: true,
        disabled: false,
        header: '报价导入',
      },
      dialogVisible: false,
      breadcrumbOpt: [{breadcrumbName: '项目采购'}, {breadcrumbName: '报价'}],
      tableData: [],
      dataList: [],
      loading: false,
      checkboxData: 1,
      time: null,
      biding: false,
      addendumList: [], //补遗文件
      tenderList: [], //投标文件
      exporting: false,
      show: false,
      clarifyList: [], //澄清文件
      form: {},
      activeName: '0',
      tableLoading: false,
      quesing: false,
      id: '',
      params: {},
      fileList: [],
      saveing: false,
      startTime: null,
      bidFileList: [],
      detailsData: [],
      templateId: '',
      templateDetailId: '',
      endTime: null,
      visible: false,
      countDown: null,
      dataing: false,
      checkTrue: 1,
      dateTime: {
        days: '',
        hours: '',
        minutes: '',
        seconds: '',
      },
      currentUser: {},
      tableHeadData: [{label: '我的报价', width: 130, prop: 'quoArrange'}],
    }
  },
  created() {
    ;(this.tableHeadData = [
      {label: '我的报价', width: 130, prop: 'quoArrange'},
      {label: '合计金额', width: 120, prop: 'amount'},
    ]),
      (this.currentUser = JSON.parse(
        sessionStorage.getItem('currentUserDetail')
      ))
    this.id = this.$route.params.id
    this.method = this.$route.params.method
    if (this.$route.query.rows.applicationType == 1) {
      this.getDetail()
    }
    this.loadData()
    this.getZbfile()
    this.selectTree()
    this.getByfile()
  },
  watch: {
    tableData: {
      handler: function (newVal, oldVal) {
        let sum = 0
        newVal.forEach((item) => {
          if (item.quoArrange != undefined && item.matNum != undefined) {
            sum += item.quoArrange * item.matNum
            this.totalValue = sum.toFixed(2)
          }
        })
      },
      deep: true,
    },
  },
  mounted() {
    this.getBidFiles()
  },
  computed: {
    uploadHeaders: function () {
      return {
        Authorization:
          this.$store.state.login.currentUser &&
          'Bearer ' + this.$store.state.login.currentUser.token,
      }
    },
    ...mapState({
      headers: (state) => {
        return {Authorization: `Bearer ${state.login.currentUser.token}`}
      },
      action: function () {
        return window.context.portal + '/biz/universal/v1/minioUpload'
      },
    }),
  },
  methods: {
    handleClick() {
      if (this.activeName == 0) {
        this.getZbfile()
      }
      if (this.activeName == 2) {
        this.getBidFiles()
      }
      if (this.activeName == 1) {
        this.getQuestion()
      }
      if (this.activeName == 3) {
        this.getByfile()
      }
      if (this.activeName == 4) {
        this.dataing = true
        this.selectTree()
        let parmas = {
          pageBean: {
            pageSize: -1,
            page: -1,
          },
          querys: [],
        }
        parmas.querys.push(
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeId',
            relation: 'AND',
            value: this.id,
          },
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeType',
            relation: 'AND',
            value: 2,
          }
        )
        this.$http
          .post('${portal}/bizEvaluationSystem/v1/pageDetail', parmas)
          .then((res) => {
            let data = res.data.value.rows
            this.dataing = false
            this.scoreData.forEach((item) => {
              data.forEach((val) => {
                val.descriptionList.forEach((e) => {
                  if (e.evaluationItemPid == item.id) {
                    delete e.evaluationItemPname
                    item.evaluationItemPname = item.subjectName
                    item.evaluationScore += e.evaluationScore
                    item.children.push(e)
                  }
                })
              })
            })
          })
      }
    },
    // 获取提问文件
    getQuestion() {
      let parmas = {
        pageBean: {
          pageSize: -1,
          page: -1,
        },
        querys: [],
      }
      parmas.querys.push({
        group: 'main',
        operation: 'EQUAL',
        parentGroup: '',
        property: 'projectApprovalId',
        relation: 'AND',
        value: this.id,
      })
      this.tendering = true
      this.$http
        .post('${portal}/clarifyQuestions/v1/pageAndAnswer', parmas)
        .then((res) => {
          this.tendering = false
          this.clarifyList = []
          if (res.data.state) {
            this.clarifyList = res.data.value.rows
            this.clarifyList.forEach((item) => {
              if (item.accessoryList && item.accessoryList.length) {
                item.accessoryList.forEach((val) => {
                  item.name = val.name
                  item.url = val.url
                })
              }
              if (item.answerList.length != 0) {
                item.answerList.forEach((e) => {
                  if (e.accessoryList && e.accessoryList.length) {
                    e.accessoryList.forEach((key) => {
                      e.name = key.name
                      e.url = key.url
                    })
                  }
                })
              }
            })
          }
        })
    },
    // 获取招标文件
    getZbfile() {
      let parmas = {
        pageBean: {
          pageSize: -1,
          page: -1,
        },
        querys: [],
      }
      parmas.querys.push(
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'projectApprovalId',
          relation: 'AND',
          value: this.id,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'type',
          relation: 'AND',
          value: 1,
        }
      )
      this.dataing = true
      this.$http
        .post('${portal}/tenderDocument/v1/pageAccessory', parmas)
        .then((res) => {
          this.dataing = false
          this.dataList = []
          let data = res.data.value.rows
          data.forEach((item) => {
            if (item.accessoryList && item.accessoryList.length != 0) {
              item.accessoryList.forEach((val) => {
                if (item.id == val.sourceId) {
                  val.describe = item.describe
                  this.dataList.push(val)
                  this.$forceUpdate()
                }
              })
            }
          })
        })
    },
    // 获取补遗文件
    getByfile() {
      let parmas = {
        pageBean: {
          pageSize: -1,
          page: -1,
        },
        querys: [],
      }
      parmas.querys.push(
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'projectApprovalId',
          relation: 'AND',
          value: this.id,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'releaseStatus',
          relation: 'AND',
          value: 2,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'type',
          relation: 'AND',
          value: 2,
        }
      )
      this.dataing = true
      this.$http
        .post('${portal}/tenderDocument/v1/pageAccessory', parmas)
        .then((res) => {
          this.dataing = false
          this.addendumList = []
          let data = res.data.value.rows
          data.forEach((item) => {
            if (item.accessoryList && item.accessoryList.length != 0) {
              item.accessoryList.forEach((val) => {
                if (item.id == val.sourceId) {
                  item.name = val.name
                  item.url = val.url
                  this.addendumList.push(item)
                }
              })
            }
          })
        })
    },
    handleProgress() {
      this.loading = true
    },
    changeCheck(val) {
      if (val == 2) {
        this.$confirm('请将投标文件在开标前送达，否则废标！', '提示', {
          confirmButtonText: '确定',
          showClose: false,
          showCancelButton: false,
          closeOnClickModal: false,
          closeOnPressEscape: false,
          type: 'error',
        })
      }
      this.getBidFiles()
    },
    //查询评标分类树结构
    selectTree() {
      this.scoreData = []
      basicData.bizEvaluationItemSelectTree().then((res) => {
        this.scoreData = res.value[0].children
        this.scoreData.forEach((item) => {
          this.$set(item, 'evaluationScore', 0)
        })
      })
    },
    //报价总额
    totalChange() {
      this.totalValue = 0
      let sum = 0
      this.tableData.forEach((item) => {
        if (item.quoArrange != undefined) {
          sum += item.quoArrange * item.matNum
          this.totalValue = sum.toFixed(2)
        }
      })
    },
    handleDown() {
      this.exporting = true
      let data = {
        querys: [],
      }
      data.querys.push({
        group: 'main',
        operation: 'EQUAL',
        parentGroup: '',
        property: 'noticeId',
        relation: 'AND',
        value: this.params.id,
      })
      let portal = window.context.portal
      let query = {
        url: `${portal}/projectApprovalDetails/v1/exportTemplateToExcel`,
        method: 'post',
        data: data,
        headers: {
          'Content-type': 'application/json',
        },
        responseType: 'blob', //将文件流转成blob对象
        noErrorMsg: true,
      }
      this.$http.request(query).then((res) => {
        if (res.status == 200) {
          this.$message.success('导出成功')
          this.exporting = false
        } else {
          this.$message.error('导出失败')
          this.exporting = false
        }
      })
    },
    //下载文件
    downloadFile(name, url) {
      console.log(name, 'name')
      const link = document.createElement('a')
      link.style.display = 'none'
      link.target = '_blank'
      // 设置下载地址
      link.setAttribute('href', url)
      // 设置文件名
      link.setAttribute('download', name)
      link.download = name
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
    },
    /** 鼠标移入cell */
    handleCellEnter(row, column, cell, event) {
      row.isEdit = true
    },
    /** 鼠标移出cell */
    handleCellLeave(row, column, cell, event) {
      row.isEdit = false
    },
    load(data) {
      console.log(data, 'ress')
      this.checkTrue = 2
      let sum = 0
      let arr = []
      arr = data.map((obj) => Object.keys(obj))
      let list = arr[0]
      this.tableData.forEach((item) => {
        data.forEach((val, index) => {
          if (item.id == val['标的ID']) {
            item.quoArrange =
              Number(val['含税单价(元)']) ||
              Number(val['不含税单价(元)']) ||
              Number(val['含税单价万(元)']) ||
              Number(val['不含税单价(万元)'])
            item.tenderExplain = val['投标补充说明'] || val['投标人补充说明']
            item.quotationTemplateDetailList.forEach((i) => {
              list.forEach((e) => {
                if (e == i.quoArrange) {
                  i.value = val[e]
                }
              })
              if (item.matNum == undefined) {
                item.matNum = 1
              }
              if (i.quoArrange == '合计金额(元)') {
                i.value = item.quoArrange * item.matNum
              }
              if (item.quotationTemplateDetailDataList) {
                item.quotationTemplateDetailDataList.push({
                  noticeDetailedId: item.id,
                  noticeId: this.id,
                  noticeType: 1,
                  templateId: i.templateId,
                  templateDetailId: i.id,
                  value: i.value,
                  quoArrange: i.quoArrange,
                })
                item.quotationTemplateDetailDataList.forEach((val) => {
                  if (
                    val.quoArrange == '合计金额(元)' ||
                    val.quoArrange == '合计金额(万元)'
                  ) {
                    val.priceEntry = 2
                    val['value'] = item.quoArrange * item.matNum
                  } else if (
                    val.quoArrange == '含税单价(元)' ||
                    val.quoArrange == '不含税单价(元)' ||
                    val.quoArrange == '含税单价(万元)' ||
                    val.quoArrange == '不含税单价(万元)'
                  ) {
                    val.priceEntry = 1
                  } else {
                    val.priceEntry = 0
                  }
                  if (val.priceEntry == 0) {
                    item.tenderExplain = val.value
                  }
                })
              }
            })
            sum += item.quoArrange * item.matNum
          }
        })
      })
    },
    loadData() {
      this.tableLoading = true
      let params = {
        pageBean: {
          page: -1,
          pageSize: -1,
        },
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeId',
            relation: 'AND',
            value: this.id,
          },
        ],
      }
      this.$http
        .post('${portal}/projectApprovalDetails/v1/quoData', params)
        .then((res) => {
          console.log(res, 'res')
          if (res.data.state) {
            this.params = res.data.value
            console.log(this.params, 'this.params')
            this.time =
              new Date(this.params.biddingEndTime).getTime() - Date.now()
            if (new Date(this.params.biddingStartTime).getTime() > Date.now()) {
              this.show = false
            }
            this.tableData = res.data.value.detailsList
            this.countDownMethod(this.params)
          }
          this.tableData.forEach((item, index) => {
            item.payAmount = item.amount
            if (item.matNum == undefined) {
              item.matNum = 1
            }
            this.tableHeadData = []
            this.$set(
              item,
              'quotationMethod',
              this.$route.query.rows.quotationMethod
            )
            if (item.quotationTemplateDetailDataList == undefined) {
              item.quotationTemplateDetailDataList = []
            }
            if (item.quoArrange == undefined) {
              this.$set(item, 'quoArrange', 0)
            }
            if (
              item.quotationTemplateDetailList &&
              item.quotationTemplateDetailList.length != 0
            ) {
              if (
                item.quotationTemplateDetailList[0].value == undefined &&
                this.params.quotationRoundsNum == 1
              ) {
                item.quoArrange = 0
              } else {
                item.quoArrange = item.quotationTemplateDetailList[0].value
              }
              if (
                this.params.quotationRoundsNum != 1 &&
                item.quotationTemplateDetailList[0].value == undefined
              ) {
                item.quoArrange = 0
                item[
                  'quoValue' + (this.params.quotationRoundsNum - 1).toString()
                ] =
                  item.quotationTemplateDetailList[0][
                    'quoValue' + (this.params.quotationRoundsNum - 1).toString()
                  ]
              } else {
                item.quoArrange = item.quotationTemplateDetailList[0].value
                item[
                  'quoValue' + (this.params.quotationRoundsNum - 1).toString()
                ] =
                  item.quotationTemplateDetailList[0][
                    'quoValue' + (this.params.quotationRoundsNum - 1).toString()
                  ]
              }
              this.tableHeadData = item.quotationTemplateDetailList
              this.tableHeadData.forEach((val, o) => {
                if (val.value == undefined) {
                  this.$set(val, 'value', '')
                }
                if (this.params.quotationRoundsNum > 1 && val.priceEntry == 1) {
                  val.value =
                    val[
                      'quoValue' +
                        (this.params.quotationRoundsNum - 1).toString()
                    ]
                }
              })
              if (item.amount == undefined) {
                item.amount = 0
              }
            }
            this.$set(item, 'isEdit', true)
          })
          console.log(this.tableData, 'tableData')
          this.tableLoading = false
        })
    },
    getDetail() {
      let parmas = {
        querys: [],
        pageBean: {
          page: -1,
          pageSize: -1,
        },
      }
      parmas.querys.push({
        group: 'main',
        operation: 'EQUAL',
        parentGroup: '',
        property: 'noticeId',
        relation: 'AND',
        value: this.id,
      })
      this.$http
        .post('${portal}/projectApprovalPay/v1/pageAll', parmas)
        .then((res) => {
          this.detailsData = res.data.value.rows
        })
    },
    // 倒计时定时器
    countDownMethod(row) {
      this.countDown = setInterval(() => {
        const date =
          Date.parse(new Date(row.biddingEndTime)) - Date.parse(new Date())
        this.time = date
        if (
          Date.parse(new Date(row.biddingStartTime)) - Date.parse(new Date()) >
          0
        ) {
          this.countDown = '未开始'
          this.show = true
          this.importData.disabled = true
        } else if (date > 0) {
          this.show = false
          this.importData.disabled = false
          this.dateTime = this.formatDate(date)
        } else {
          this.countDown = '已结束'
          this.show = true
          // this.handleClose()
          this.importData.disabled = true
          this.tableData = []
          this.totalValue = 0
          clearInterval(this.countDown)
        }
      }, 1000)
    },
    formatDate(time) {
      let days = this.addZero(Math.floor(time / 1000 / 60 / 60 / 24)) //天
      let hours = this.addZero(Math.floor((time / 1000 / 60 / 60) % 24)) //时
      let minutes = this.addZero(Math.floor((time / 1000 / 60) % 60)) //分
      let seconds = this.addZero(Math.floor((time / 1000) % 60)) //秒
      return {
        days,
        hours,
        minutes,
        seconds,
      }
    },
    addZero(d) {
      return parseInt(d) < 10 ? '0' + d : d
    },
    // 获取投标文件
    getBidFiles() {
      let parmas = {
        pageBean: {
          pageSize: -1,
          page: -1,
        },
        querys: [],
      }
      parmas.querys.push(
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'projectApprovalId',
          relation: 'AND',
          value: this.id,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'projectApprovalType',
          relation: 'AND',
          value: 2,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'supplierId',
          relation: 'AND',
          value: this.currentUser.org[0].orgId,
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'bidType',
          relation: 'AND',
          value: this.checkboxData,
        }
      )
      this.tenderList = []
      this.$http.post('${portal}/bidDocuments/v1/page', parmas).then((res) => {
        let data = res.data.value.rows
        data.forEach((item) => {
          if (item.accessoryList && item.accessoryList.length != 0) {
            item.accessoryList.forEach((val) => {
              this.tenderList.push(val)
            })
          }
        })
      })
    },
    cellClick(row) {
      this.form = row
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'quotesMy',
        params: {
          tabsActiveName: 'CompetitiveNegotiation',
        },
      })
    },
    // 删除
    deleteFile(index) {
      this.$confirm('是否确认删除该附件', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        this.bidFileList.splice(index, 1)
      })
    },
    changeQuoArrange(row) {
      this.checkTrue = 1
      if (row.maximumPriceLimit != undefined) {
        if (
          row.quoArrange > row.maximumPriceLimit &&
          row.maximumPriceLimit != 0
        ) {
          this.$message.error('当前项报价已超过最高限价，请重新报价！')
          return
        }
      }
      row.quotationTemplateDetailDataList = []
      this.tableData.forEach((e) => {
        if (row.id == e.id) {
          row.quotationTemplateDetailList.forEach((item) => {
            if (
              (item.quoArrange == '含税单价(元)' ||
                item.quoArrange == '不含税单价(元)' ||
                item.quoArrange == '含税单价(万元)' ||
                item.quoArrange == '不含税单价(万元)') &&
              item.matNum != undefined
            ) {
              e.quoArrange = item.value
              row.amount = item.value * row.matNum
            }
            if (
              (item.quoArrange == '含税单价(元)' ||
                item.quoArrange == '不含税单价(元)' ||
                item.quoArrange == '含税单价(万元)' ||
                item.quoArrange == '不含税单价(万元)') &&
              item.matNum == undefined
            ) {
              row.matNum = 1
              e.quoArrange = item.value
              row.amount = item.value
            }
            if (
              item.quoArrange == '合计金额(元)' ||
              item.quoArrange == '合计金额(万元)'
            ) {
              item.value = row.amount
            }
            e.quotationTemplateDetailDataList.push({
              noticeDetailedId: e.id,
              noticeId: this.id,
              noticeType: 1,
              templateId: item.templateId,
              templateDetailId: item.id,
              value: item.value,
              priceEntry: item.priceEntry,
              quoArrange: item.quoArrange,
            })
          })
        }
      })
    },
    // 报价
    open() {
      for (let index = 0; index < this.addendumList.length; index++) {
        if (
          this.addendumList[index].isVendorConfirm == 2 &&
          this.addendumList[index].confirmStatus == 0
        ) {
          this.$message.error('请确认补遗文件')
          break
        }
      }
      if (
        this.tenderList.length == 0 &&
        this.params.isBidDocumentsUpload == 1
      ) {
        this.$message.warning('请上传投标文件')
        this.show = true
        return
      } else {
        this.show = false
      }
      for (let index = 0; index < this.tenderList.length; index++) {
        if (
          this.tenderList[index].bidSignStatus != 3 &&
          this.tenderList[index].bidType == 1
        ) {
          
          this.$message.error('请确认所有投标文件是否已签署完毕')
          break
        }
      }
      let quoVo = {
        projectApproval: {
          detailsList: [],
        },
      }
      this.tableData.forEach((item) => {
        if (item.quoArrange > 0) {
          quoVo.projectApproval.detailsList.push(item)
        }
      })
      if (this.checkTrue == 1) {
        this.tableData.forEach((e) => {
          e.amount = e.quoArrange * e.matNum
          if (e.quotationTemplateDetailDataList.length != 0) {
            e.quotationTemplateDetailDataList.forEach((val) => {
              if (
                e.id == val.noticeDetailedId &&
                val.quoArrange == '合计金额(元)'
              ) {
                val.priceEntry = 2
                val['value'] = Number(e.quoArrange * e.matNum)
              } else {
                val.priceEntry = 1
              }
            })
          } else {
            e.quotationTemplateDetailList.forEach((i) => {
              if (i.quoArrange == '合计金额(元)') {
                e.quotationTemplateDetailDataList.push({
                  noticeDetailedId: e.id,
                  noticeId: this.id,
                  noticeType: 1,
                  templateId: i.templateId,
                  templateDetailId: i.id,
                  value: e.quoArrange * e.matNum,
                  priceEntry: 2,
                  quoArrange: i.quoArrange,
                })
              } else {
                e.quotationTemplateDetailDataList.push({
                  noticeDetailedId: e.id,
                  noticeId: this.id,
                  noticeType: 1,
                  templateId: i.templateId,
                  templateDetailId: i.id,
                  value: i.value,
                  priceEntry: i.priceEntry,
                  quoArrange: i.quoArrange,
                })
              }
            })
          }
        })
      }
      quoVo.projectApproval = {...quoVo.projectApproval, ...this.params}
      console.log(quoVo, 'quoVo')
      this.saveing = true
      this.$http
        .post('${portal}/bizBiddingQuotation/v1/quotationProject', quoVo)
        .then((res) => {
          this.saveing = false
          if (res.data.state) {
            this.$message.success(res.data.message)
            this.loadData()
          }
        })
    },
    // 确认补遗
    byReluat(row) {
      let arr = []
      arr.push({
        tenderDocumentId: row.id,
        projectApprovalId: row.projectApprovalId,
      })
      this.$http
        .post('${portal}/purchasing/bizTenderDocumentConfirm/v1/saveList', arr)
        .then((res) => {
          if (res.data.state) {
            this.getByfile()
          }
        })
    },
    // 文件状态改变时的钩子，添加文件、上传成功和上传失败时都会被调用,function(file, fileList)
    handleSuccess(res, file, fileList) {
      this.loading = false
      this.bidFileList.push(res.value)
      if (this.bidFileList.length != 0) {
        this.show = false
      }
      if (this.activeName == 1) {
        this.form.accessoryList.push(res.value)
      }
    },
    beforeUpload(file) {
      let acceptList = ['docx', 'doc']
      // 根据文件名获取文件的后缀名
      let fileType = file.name.split('.').pop().toLowerCase()
      // 判断文件格式是否符合要求
      if (acceptList.indexOf(fileType) === -1) {
        this.$message.error('请上传 docx,doc 等格式的文件 !')
        return false
      }
    },
    //下载按钮回调
    downloadFile(name, url) {
      console.log(name, 'name')
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      a.download = name
      a.target = '_blank'
      a.href = url
      a.dispatchEvent(event)
    },
    // 删除
    deleteHandle(id, index) {
      this.$confirm('是否确认删除该附件', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        if (this.activeName == 2 && id) {
          this.$http
            .post('${portal}/biz/universal/v1/delete?ids=' + id)
            .then((res) => {
              if (res.data.state) {
                this.$message.success('删除成功')
                this.getBidFiles()
              }
            })
        } else {
          this.form.accessoryList.splice(index, 1)
        }
        this.$forceUpdate()
      })
    },
    // 签署投标文件
    handleSign(row){
      this.$http.post('${portal}/bidDocuments/v1/sendDocSign?fileId='+row.id).then(res=>{
        console.log(res,'resssssssssss');
        if(res.data.state){
          window.open(res.data.value,'_blank')
          this.getBidFiles()
        }
      })
    },
    handleQuery(row){
      window.open(row.bidContractUrl,'_blank')
    },
    dialogBeforeClose() {
      this.dialogVisible = false
      this.form.accessoryList = []
    },
    // 打开投标文件
    openBid() {
      this.dialogVisible = true
    },
    // 保存投标文件
    saveBid() {
      let data = {
        accessoryList: [],
        projectApprovalId: this.params.id,
        projectApprovalType: 2,
        quotationRounds: this.params.quotationRoundsNum,
        supplierId: '',
        bidType:'',
      }
      if(this.checkboxData==1){
        data.bidType = 1
      }
      if(this.checkboxData==2){
        data.bidType = 2
      }
      data.supplierId = this.currentUser.org[0].orgId
      data.accessoryList = this.bidFileList
      this.biding = true
      this.$http
        .post('${portal}/bidDocuments/v1/saveOrUpdateEntity', data)
        .then((res) => {
          this.biding = false
          if (res.data.state) {
            this.handleClick()
            this.dialogBeforeClose()
            this.bidFileList = []
          }
        })
    },
    // 打开提问弹窗
    openQuestion() {
      this.visible = true
    },
    // 提交提问
    handleQuestion() {
      let data = {
        projectApprovalId: this.id,
        describe: this.form.describe,
        accessoryList: this.form.accessoryList,
        projectApprovalType: 2,
      }
      this.quesing = true
      this.$http
        .post('${portal}/clarifyQuestions/v1/saveOrUpdate', data)
        .then((res) => {
          if (res.data.state) {
            this.getQuestion()
            this.visible = false
            this.form = {
              describe: '',
              accessoryList: [],
            }
          }
          this.quesing = false
        })
    },
    // 获取字典值翻译
    getDictName(code, value) {
      return utils.getDictName(code, value)
    },
  },
}
</script>

<style lang="scss" scoped>
.common-page-shadow {
  width: 100%;
  height: calc(100% - 50px);
  box-sizing: border-box;
  .flex {
    display: flex;
    flex-wrap: nowrap;
  }
  .common-search-container {
    height: 80px;
    div {
      display: flex;
      align-items: center;
    }
  }
  .common-table-container {
    height: calc(100% - 20px);
    .common-table-content.btn-pagenation {
      height: calc(100% - 130px);
    }
    .common-table-wrapper {
      width: 65%;
    }
    .common-table-quote {
      height: 100%;
      width: 35%;
      padding: 26px 20px 30px 20px;
      .quote-content {
        border: 1px solid #eee;
        border-radius: 10px;
        height: 100%;
        padding: 0 20px;
        position: relative;
        width: calc(100% - 60px);
        .content {
          height: calc(100% - 450px);
          overflow: auto;
        }
        .btn {
          width: 100%;
          bottom: 16px;
          display: flex;
          justify-content: center;
        }
      }
    }
  }
}
/deep/.el-table-lable-box .cell {
  display: flex;
  justify-content: center;
}
.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 16px;
  padding: 10px 0;
  .rows-left {
    margin-right: 10px;
    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e6eff;
      border-radius: 2px;
    }
  }
  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 16px;
    }
  }
}
/deep/.el-checkbox__label {
  font-size: 16px !important;
}
</style>
