<template>
  <div class="common-page-shadow">
    <div class="common-search-container" ref="contentPanel">
      <el-form
        ref="form"
        :model="search"
        label-position="right "
        :inline="true"
        type="flex"
        justify="left"
      >
        <el-form-item label="项目编号">
          <el-input
            v-model="querys[1].value"
            clearable
            size="small"
            placeholder="项目编号"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否开标">
          <el-select
            v-model="search.code"
            clearable
            @change="changeCode"
            size="small"
            placeholder="请选择"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div class="container-btn">
        <el-button
          size="small"
          icon="el-icon-search"
          type="danger"
          class="btn btn-plus"
          @click="handleSearch"
        >
          搜索
        </el-button>
        <el-button
          size="small"
          icon="el-icon-refresh-right"
          class="btn btn-plus"
          @click="clearSearchForm"
        >
          重置
        </el-button>
      </div>
    </div>
    <el-row
      class="common-table-container flex searchPanel"
      :style="SearchPanel"
    >
      <el-col :span="24" class="common-table-wrapper">
        <div class="common-btn-group">
          <el-button
            size="small"
            icon="el-icon-thumb"
            type="primary"
            :disabled="!multipleSelection.length"
            class="btn btn-plus"
            :loading="viewing"
            @click="handleDetail"
          >
            查看报价情况
          </el-button>
          <el-button
            size="small"
            icon="el-icon-thumb"
            type="primary"
            :disabled="!multipleSelection.length"
            v-if="show"
            class="btn btn-plus"
            @click="handleView"
          >
            查看报价明细
          </el-button>
          <el-button
            size="small"
            icon="el-icon-thumb"
            type="primary"
            v-if="search.code == 0"
            :disabled="!multipleSelection.length"
            class="btn btn-plus"
            @click="handleUpdate"
          >
            修改时间
          </el-button>
        </div>
        <!-- LJ：表格高度自适应需配合样式  btn-pagenation 有按钮有分页  btngroup只有按钮  pagenation只有分页 -->
        <div class="common-table-content btn-pagenation">
          <el-table
            :border="true"
            stripe
            fit
            size="mini"
            v-loading="tableLoading"
            height="100%"
            ref="multipleSelection"
            :data="tableData"
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              min-width="50px"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="55"
              align="center"
              label="序号"
            >
            </el-table-column>
            <el-table-column
              prop="projectNumber"
              min-width="100px"
              label="项目编号"
              show-overflow-tooltip
              align="center"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="noticeTitle"
              show-overflow-tooltip
              min-width="120px"
              align="center"
              label="项目名称"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="procureOrgName"
              show-overflow-tooltip
              min-width="130px"
              align="center"
              label="需求企业"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="procureType"
              show-overflow-tooltip
              min-width="100px"
              align="center"
              label="采购类型"
              resizable
            >
              <template v-slot="{row}">
                <div v-if="row.procureType != 6">
                  {{ getDictName('cglx-cglx', row.procureType) }}
                </div>
                <div v-else>谈判采购（多轮）</div>
              </template>
            </el-table-column>
            <el-table-column
              prop="responseTimeDeadline"
              show-overflow-tooltip
              min-width="130px"
              align="center"
              label="响应截止时间"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="biddingStartTime"
              show-overflow-tooltip
              min-width="130px"
              align="center"
              label="投标开始时间"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="biddingEndTime"
              show-overflow-tooltip
              min-width="130px"
              align="center"
              label="投标结束时间"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="evaluationStartTime"
              show-overflow-tooltip
              min-width="120px"
              align="center"
              label="评标开始时间"
              resizable
            >
            </el-table-column>
            <el-table-column
              prop="quotationRoundsNum"
              show-overflow-tooltip
              min-width="100px"
              align="center"
              label="报价轮次"
              resizable
            >
            </el-table-column>
            <el-table-column
              show-overflow-tooltip
              min-width="120px"
              align="center"
              label="是否开标"
              resizable
            >
              <template v-slot="{row}">
                <span v-if="row.bidStatus == 5 || row.bidStatus > 5">是</span>
                <span v-else>否</span>
              </template>
            </el-table-column>
            <el-table-column
              min-width="180px"
              fixed="right"
              align="center"
              label="操作"
            >
              <template v-slot="{row}">
                <el-button
                  type="primary"
                  plain
                  v-if="row.bidStatus == 3 || row.bidStatus == 4"
                  size="small"
                  @click="bidsBtn(row)"
                  >开标</el-button
                >

                <el-button
                  type="primary"
                  plain
                  v-if="
                    (row.bidStatus == 3 ||
                      row.bidStatus == 4 ||
                      row.bidStatus == 5 ||
                      row.bidStatus == 6) &&
                    row.calibraStatus == 0
                  "
                  size="small"
                  @click="markerFlow(row)"
                  >流标</el-button
                >
                <el-tag type="danger" v-if="row.bidStatus == 8">已流标</el-tag>
                <el-button
                  type="primary"
                  plain
                  size="small"
                  v-if="
                    (row.bidStatus == 5 || row.bidStatus == 6) &&
                    (row.procureType == 6 || row.procureType == 4) &&
                    row.calibraStatus == 0 &&
                    row.quotationRoundsNum - row.quotationRounds != 0
                  "
                  @click="roundsTwo(row)"
                  >发起新一轮报价</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="common-pagenation">
          <el-pagination
            ref="paginationPanel"
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryParam.pageBean.page"
            :page-sizes="[20, 30, 40, 50]"
            :page-size="queryParam.pageBean.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="queryParam.pageBean.total"
          >
          </el-pagination>
        </div>
      </el-col>
    </el-row>
    <!-- 开标弹层 -->
    <el-dialog
      :close-on-click-modal="false"
      title="开标"
      :visible.sync="bidsLoading"
      width="70%"
      :before-close="handleClose"
      top="6vh"
    >
      <el-form
        ref="form"
        :model="bidsValue"
        label-width="auto"
        label-position="right "
        :inline="true"
        type="flex"
        justify="left"
        v-if="objData.evaluationMethod == 2"
      >
        <el-form-item label="评标人员">
          <el-input
            readonly
            clearable
            v-model="bidsValue.personnel"
            placeholder="请选择评标人员"
          >
            <el-button
              slot="append"
              @click="purchasingUnitsBtn"
              icon="el-icon-search"
            ></el-button>
          </el-input>
        </el-form-item>
      </el-form>
      <el-table
        :border="true"
        stripe
        fit
        size="mini"
        height="200px"
        v-loading="loading"
        ref="multipleSelection"
        :data="manageData"
      >
        <el-table-column
          prop="projectNumber"
          min-width="100px"
          label="项目编号"
          show-overflow-tooltip
          align="center"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="noticeTitle"
          min-width="120px"
          label="项目名称"
          align="center"
          show-overflow-tooltip
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="affiliatedOrgName"
          min-width="120px"
          show-overflow-tooltip
          label="需求企业"
          align="center"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="procureType"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="采购类型"
          resizable
        >
          <template v-slot="{row}">
            <div v-if="row.procureType != 6">
              {{ getDictName('cglx-cglx', row.procureType) }}
            </div>
            <div v-else>谈判采购</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="biddingStartTime"
          show-overflow-tooltip
          min-width="110px"
          align="center"
          label="投标开始时间"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="biddingEndTime"
          show-overflow-tooltip
          min-width="110px"
          align="center"
          label="投标结束时间"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="evaluationStartTime"
          show-overflow-tooltip
          min-width="110px"
          align="center"
          label="评标开始时间"
          resizable
        >
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
        <el-button
          size="small"
          type="primary"
          :loading="bidsSaveing"
          @click="bidsSave"
          >开 标</el-button
        >
      </span>
    </el-dialog>

    <!-- 报名情况 -->
    <el-dialog
      :close-on-click-modal="false"
      title="报名情况"
      :visible.sync="showDetals"
      width="60%"
      :before-close="close"
      top="10vh"
    >
      <el-table
        :border="true"
        stripe
        fit
        size="mini"
        v-loading="loading"
        ref="multipleSelection"
        :data="bidDataList"
      >
        <el-table-column type="index" width="55" align="center" label="序号">
        </el-table-column>
        <el-table-column
          prop="noticeTitle"
          show-overflow-tooltip
          min-width="120px"
          align="center"
          label="项目名称"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="companyName"
          show-overflow-tooltip
          min-width="120px"
          align="center"
          label="投标供应商"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="noticeType"
          show-overflow-tooltip
          min-width="120px"
          align="center"
          label="项目类型"
          resizable
        >
          <template slot-scope="scope">
            <div>
              {{ scope.row.noticeType == 1 ? '物资' : '项目' }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="isQuo"
          show-overflow-tooltip
          min-width="120px"
          align="center"
          label="是否投标"
          resizable
        >
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.isQuo == 1">已投标</el-tag>
            <el-tag type="danger" v-if="scope.row.isQuo == 0">未投标</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="close">取消</el-button>
      </span>
    </el-dialog>
    <bidOpeningUnits
      @addDetail="addDetail"
      :bidOpening="bidOpening"
      ref="troubleshooting"
    />
    <evaluationBid
      @addDetail="bidsDetail"
      :echoValue="echoValue"
      ref="troublebids"
    />
    <!-- 流标弹层 -->
    <el-dialog
      :close-on-click-modal="false"
      title="流标原因"
      :close-on-press-escape="false"
      :visible.sync="showTroubleshooting"
      width="50%"
      :before-close="close"
      top="10vh"
    >
      <el-form
        justify="left"
        label-width="auto"
        label-position="right"
        :model="markerFlowValue"
        class="demo-form-inline"
      >
        <el-form-item label="流标原因">
          <el-input
            type="textarea"
            size="small"
            v-model="markerFlowValue.failBidReason"
            placeholder="请输入流标原因"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
        <el-button
          size="small"
          type="primary"
          :loading="flowing"
          @click="handleSave"
          >保 存</el-button
        >
      </span>
    </el-dialog>
    <!-- 发起新一轮报价弹层 -->
    <el-dialog
      :close-on-click-modal="false"
      title="新一轮报价原因"
      :visible.sync="roundsTwoLoading"
      width="50%"
      :before-close="handleClose"
      top="10vh"
    >
      <el-form
        justify="left"
        label-width="auto"
        label-position="right"
        :model="roundsTwoValue"
        :rules="roundsRules"
        ref="roundsRules"
        class="demo-form-inline"
      >
        <el-form-item label="投标开始时间" prop="biddingStartTime">
          <el-date-picker
            clearable
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%"
            v-model="roundsTwoValue.biddingStartTime"
            placeholder="请选择投标开始时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="投标结束时间" prop="biddingEndTime">
          <el-date-picker
            clearable
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%"
            v-model="roundsTwoValue.biddingEndTime"
            placeholder="请选择投标结束时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="新一轮报价原因">
          <el-input
            type="textarea"
            size="small"
            v-model="roundsTwoValue.newQuoReason"
            placeholder="请输入新一轮报价原因"
            clearable
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
        <el-button
          size="small"
          type="primary"
          :loading="rounding"
          @click="roundsTwoSave"
          >保 存</el-button
        >
      </span>
    </el-dialog>
    <!-- 供应商报价总额 -->
    <el-dialog
      title="报价总额"
      :visible.sync="showVisible"
      width="60%"
      :modal-append-to-body="false"
      :before-close="beforeClose"
    >
      <el-table
        :border="true"
        stripe
        fit
        size="mini"
        v-loading="loading"
        height="400px"
        ref="multipleSelection"
        :data="manageData"
      >
        <el-table-column type="index" width="55" align="center" label="序号">
        </el-table-column>
        <el-table-column
          prop="quotationCompanyName"
          min-width="20%"
          label="报价供应商"
          align="center"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="quotationRoundsNum"
          min-width="20%"
          v-for="(item, index) in tableHeader"
          :key="index"
          :label="item"
          align="center"
          resizable
        >
          <template slot-scope="scope">
            <div v-if="scope.row.quoPriceMap[index]&&scope.row.quoPriceMap[index].quotationRounds == 1">
              {{ (scope.row.quoPriceMap[index].totalPrice).toFixed(2) }}
            </div>
            <div v-if="scope.row.quoPriceMap[index]&&scope.row.quoPriceMap[index].quotationRounds == 2">
              {{ (scope.row.quoPriceMap[index].totalPrice).toFixed(2) }}
            </div>
            <div v-if="scope.row.quoPriceMap[index]&&scope.row.quoPriceMap[index].quotationRounds == 3">
              {{ (scope.row.quoPriceMap[index].totalPrice).toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column min-width="20%" align="center" label="操作">
          <template v-slot="{row}">
            <template>
              <el-button
                type="primary"
                plain
                size="small"
                @click="handleQuerys(row)"
                >报价明细</el-button
              >
            </template>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer">
        <el-button @click="showVisible = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 报价明细详情 -->
    <el-dialog
      :close-on-click-modal="false"
      title="报价明细"
      :visible.sync="showView"
      width="80%"
      :before-close="close"
      top="6vh"
    >
      <el-table
        :border="true"
        stripe
        fit
        size="mini"
        v-loading="loading"
        height="500px"
        ref="multipleSelection"
        :data="detailsList"
      >
        <el-table-column type="index" width="55" align="center" label="序号">
        </el-table-column>
        <!-- <el-table-column
          prop="quotationCompanyName"
          show-overflow-tooltip
          min-width="140px"
          align="center"
          label="报价供应商"
          resizable
        >
        </el-table-column> -->
        <el-table-column
          prop="matCode"
          show-overflow-tooltip
          min-width="110px"
          align="center"
          label="企业物料编号"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matPlatcode"
          show-overflow-tooltip
          min-width="110px"
          align="center"
          label="平台物料编号"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matName"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="物料名称"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matMaterial"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="物料牌号"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matSpec"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="规格型号"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matUnit"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="计量单位"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="matNum"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="数量"
          resizable
        >
        </el-table-column>

        <el-table-column
          label="报价轮次"
          show-overflow-tooltip
          min-width="100"
          prop="quotationRounds"
        >
        </el-table-column>
        <el-table-column
          label="计划编号"
          show-overflow-tooltip
          min-width="100"
          prop="planCode"
        >
        </el-table-column>
        <el-table-column
          label="品牌/产地"
          show-overflow-tooltip
          min-width="100"
          prop="matBrand"
        >
        </el-table-column>
        <el-table-column
          label="基础扩展"
          show-overflow-tooltip
          min-width="140"
          prop="matBaseExt"
        >
        </el-table-column>
        <el-table-column
          label="其他扩展"
          min-width="140"
          prop="matOtherExt"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="quotationMethod"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="报价方式"
          resizable
        >
          <template slot-scope="scope">
            <span v-if="scope.row.quotationMethod == 1">现金</span>
            <span v-if="scope.row.quotationMethod == 2">承兑</span>
            <span v-if="scope.row.quotationMethod == 3">其他</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="isTax"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="是否含税"
          resizable
        >
          <template slot-scope="scope">
            <div>
              {{ scope.row.isTax == 1 ? '含税' : '不含税' }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="quotationPrice"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="报价金额(元)"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="quotationAmount"
          show-overflow-tooltip
          min-width="100px"
          align="center"
          label="总额(元)"
          resizable
        >
          <template slot-scope="scope">
            <div>
              {{ (scope.row.quotationPrice * scope.row.matNum).toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="送货地址" min-width="180" prop="unloadAddress">
        </el-table-column>
        <el-table-column label="企业补充说明" min-width="180" prop="purNote">
        </el-table-column>
        <el-table-column
          label="供应商补充说明"
          min-width="180"
          prop="tenderExplain"
        >
        </el-table-column>
        <el-table-column
          label="挂账日期(月)"
          min-width="100"
          prop="pendingTime"
        >
        </el-table-column>
        <el-table-column
          label="承兑日期(月)"
          min-width="100"
          v-if="form.quotationMethod == 2"
          prop="acceptanceTime"
        >
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="close">取消</el-button>
      </span>
    </el-dialog>
    <!-- 修改投标结束时间 -->
    <el-dialog
      :close-on-click-modal="false"
      title="修改时间"
      :visible.sync="endLoading"
      width="500px"
      :before-close="handleClose"
      top="7vh"
    >
      <el-form
        justify="left"
        label-width="auto"
        label-position="right"
        :model="params"
        :rules="roundsRules"
        ref="roundsRules"
        class="demo-form-inline"
      >
      <el-form-item label="响应截止时间" prop="responseTimeDeadline">
          <el-date-picker
            clearable
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%"
            v-model="params.responseTimeDeadline"
            placeholder="请选择响应截止时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="投标结束时间" prop="biddingEndTime">
          <el-date-picker
            clearable
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%"
            v-model="params.biddingEndTime"
            placeholder="请选择投标结束时间"
          ></el-date-picker>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="handleClose">取消</el-button>
        <el-button
          size="small"
          type="primary"
          :loading="rounding"
          @click="saveTime"
          >保 存</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import pagination from '@/components/pagination'
import bidOpeningUnits from './bidOpeningUnits.vue'
import evaluationBid from './evaluationBid.vue'
import {TableMixin} from '@/mixins/tableMixin'
import routerManagement from '@/api/BasicDataManagement/routerManagement.js'
export default {
  name: 'DemandEntry',
  components: {
    pagination,
    bidOpeningUnits,
    evaluationBid,
  },
  mixins: [TableMixin],
  data() {
    return {
      currentPage: 1,
      tableMaxHeight: 400,
      loading: false,
      objData: {},
      rounding: false,
      tableLoading: false,
      showTroubleshooting: false,
      markerFlowValue: {},
      roundsTwoLoading: false,
      roundsTwoValue: {
        biddingEndTime:'',
        biddingStartTime:''
      },
      bidsLoading: false,
      bidsValue: {personnel: '', way: ''},
      echoValue: {
        name: '',
      },
      viewing: false,
      show: true,
      manageData: [],
      bidOpening: [],
      params:{
        responseTimeDeadline:'',
        biddingEndTime:'',
      },
      form: {},
      options: [
        {
          value: 0,
          label: '否',
        },
        {
          value: 1,
          label: '是',
        },
      ],
      tableData: [],
      multipleSelection: [],
      queryParam: {
        pageBean: {
          page: 1,
          pageSize: 20,
          total: 0,
        },
      },
      querys: [
        {
          group: 'main',
          operation: 'IN',
          parentGroup: '',
          property: 'bidStatus',
          relation: 'AND',
          value: ['3', '4', '5'],
        },
        {
          group: 'main',
          operation: 'LIKE',
          parentGroup: '',
          property: 'bidStatus',
          relation: 'AND',
          value: '',
        },
      ],
      search: {
        code: 0,
      }, // 顶部搜索对象
      flowing: false,
      bidDataList: [],
      endLoading:false,
      showVisible: false,
      showView: false,
      detailsList: [],
      showDetals: false,
      bidsSaveing: false,
      deleteIds: '', // 是否选中列表解锁删除按钮
      activeCollapse1: ['1', '2'],
      fileList: [], // 文件上传
      edit: false, // 是否是修改功能
      currentDataDel: [], // 删除时排查是否有在审核的数据
      roundsRules: {
        biddingStartTime: [
          {
            required: true,
            message: '请选择报价开始时间',
            trigger: ['blur', 'change'],
          },
        ],
        biddingEndTime: [
          {
            required: true,
            message: '请选择报价结束时间',
            trigger: ['blur', 'change'],
          },
        ],
      },
      tableHeader: ['第一次报价总额(元)', '第二次报价总额(元)'],
      dateTime:''
    }
  },
  mounted() {},
  created() {
    let moment = require('moment')
    this.dateTime = moment().format('YYYY-MM-DD HH:ss:mm')
    this.loadData()
  },
  methods: {
    // 点击关闭按钮
    handleClose() {
      this.showTroubleshooting = false
      this.roundsTwoLoading = false
      this.endLoading = false
      this.bidsLoading = false
      this.bidOpening = []
      this.bidsValue.personnel = ''
      this.bidsValue.way = ''
      this.echoValue = {}
      this.params={
        biddingEndTime:'',
        responseTimeDeadline:''
      }
      this.roundsTwoValue = {}
    },
    close() {
      this.showDetals = false
      this.showView = false
    },
    //发起新一轮报价
    roundsTwo(row) {
      this.objData = row
      this.roundsTwoLoading = true
    },
    //发起新一轮报价保存
    roundsTwoSave() {
      let form = this.objData
      form.bidStatus = 3
      form.biddingStartTime = this.roundsTwoValue.biddingStartTime
      form.biddingEndTime = this.roundsTwoValue.biddingEndTime
      form.newQuoReason = this.roundsTwoValue.newQuoReason
      console.log(form)
      this.$refs.roundsRules.validate((valid) => {
        if (valid) {
          this.rounding = true
          this.$http
            .post('${portal}/matApproval/v1/newRoundQuo', form)
            .then((res) => {
              console.log(res, 'm;ress')
              // 表单验证通过
              if (res.data.state) {
                this.$message.success(res.data.message)
                this.roundsTwoValue = {}
                this.roundsTwoLoading = false
              }
              this.rounding = false
              this.loadData()
            })
        }
      })
    },
    //流标保存
    handleSave() {
      this.flowing = true
      this.showTroubleshooting = false
      let form = this.flowForm
      form.bidStatus = 8
      form.failBidReason = this.markerFlowValue.failBidReason
      this.$http
        .post('${portal}/matApproval/v1/newRoundQuo', form)
        .then((res) => {
          console.log(res, 'res')
          if (res.data.state) {
            this.$message.success(res.data.message)
            this.loadData()
            this.markerFlowValue = {}
            this.showTroubleshooting = false
            this.flowing = false
          } else {
            this.flowing = false
          }
        })
    },
    // 查看报名情况
    handleDetail() {
      if (this.multipleSelection.length > 1) {
        this.$message.warning('请选择单条数据进行查看')
        return
      }
      this.handleDetails()
    },
    handleView() {
      if (this.multipleSelection.length > 1) {
        this.$message.warning('请选择单条数据进行查看')
        return
      }
      let params = {
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeId',
            relation: 'AND',
            value: this.multipleSelection[0].id,
          },
        ],
      }
      this.$http
        .post('${portal}/bizBiddingQuotation/v1/matBidOpenOrgData', params)
        .then((res) => {
          if (res.data.state) {
            this.form = res.data.value
            this.manageData = res.data.value.quotationList
            this.showVisible = true
          }
        })
    },
    handleQuerys(row) {
      this.objData = row
      let params = {
        pageBean: {
          page: -1,
          pageSize: -1,
        },
        querys: [],
      }
      params.querys.push(
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'quo.NOTICE_ID_',
          relation: 'AND',
          value: row.noticeId,
        },
        // {
        //   group: 'main',
        //   operation: 'EQUAL',
        //   parentGroup: '',
        //   property: 'quo.QUOTATION_ROUNDS_',
        //   relation: 'AND',
        //   value: this.form.quotationRoundsNum,
        // },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'quo.QUOTATION_COMPANY_ID_',
          relation: 'AND',
          value: row.quotationCompanyId,
        }
      )
      this.$http
        .post('${portal}/bizBiddingQuotation/v1/pageQuoAndMatDetail', params)
        .then((res) => {
          if (res.data.state) {
            this.detailsList = res.data.value.rows
            this.showView = true
          }
        })
    },
    //流标
    markerFlow(row) {
      this.flowForm = row
      this.showTroubleshooting = true
    },
    //开标保存
    bidsSave() {
      this.$confirm('确认当前信息后请点击确定以进行开标？', '提示', {
        confirmButtonText: '确 定',
        cancelButtonText: '取 消',
        type: 'warning',
      })
        .then(() => {
          this.bidsSaveing = true
          let form = this.objData
          if (this.bidOpening.length != 0) {
            form.projectEvaluationExpertList = this.bidOpening
          }
          this.$http
            .post('${portal}/matApproval/v1/openingBid', form)
            .then((res) => {
              console.log(res, 'res')
              if (res.data.state) {
                this.$message.success(res.data.message)
                this.loadData()
                this.bidsValue = {}
                this.bidsLoading = false
                this.bidsSaveing = false
              } else {
                this.bidsSaveing = false
              }
            })
        })
        .catch(() => {
          this.$message.info('已取消')
        })
    },
    //开标
    bidsBtn(row) {
      this.manageData = []
      let params = {
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeId',
            relation: 'AND',
            value: row.id,
          },
        ],
      }
      this.$http
        .post('${portal}/bizBiddingQuotation/v1/matBidOpenOrgData', params)
        .then((res) => {
          console.log(res, 'res')
          if (res.data.state) {
            this.objData = res.data.value
            this.manageData.push(this.objData)
            this.bidsValue.personnel = this.objData.projectEvaluationExpertList
              .map((item) => {
                return item.fullname
              })
              .join(',')
            this.bidsLoading = true
          }
        })
    },
    //评标人员
    purchasingUnitsBtn() {
      this.$refs.troubleshooting.add()
    },
    addDetail(list) {
      this.bidOpening = list
      this.bidsValue.personnel = list
        .map((item) => {
          return item.fullname
        })
        .join(',')
      console.log(this.bidsValue.personnel)
    },
    //评标办法
    evaluationBid() {
      this.$refs.troublebids.add()
    },
    handleUpdate(){
      if(this.multipleSelection.length>1){
        this.$message.error('请选择一条数据')
        return
      }else{
        this.endLoading = true
        this.params.biddingEndTime = this.dateTime
        this.params.responseTimeDeadline = this.multipleSelection[0].responseTimeDeadline
      }
    },
    saveTime(){
      this.rounding = true
      let form = this.multipleSelection[0]
      form.biddingEndTime = this.params.biddingEndTime
      form.responseTimeDeadline = this.params.responseTimeDeadline
      this.$http.put('${portal}/matApproval/v1/',form).then(res=>{
        this.rounding = false
        if(res.data.state){
          this.endLoading = false
          this.loadData()
          this.$message.success('修改成功')
        }else{
          this.$message.error('修改失败')
          this.endLoading = false
        }
      })
    },
    bidsDetail(list) {
      this.bidsValue.way = list.name
      this.echoValue = list
      this.objData.evaluationTemplateId = this.echoValue.id
      this.objData.evaluationMethod = this.echoValue.evaluatingMethods
    },
    //获取数据
    loadData() {
      this.tableLoading = true
      this.queryParam.querys = []
      if (this.querys[0].value) {
        this.queryParam.querys.push(this.querys[0])
      }
      if (this.querys[1].value) {
        this.queryParam.querys.push(this.querys[1])
      }
      this.queryParam.sorter = [
        {
          direction: 'DESC',
          property: 'create_time_',
        },
      ]
      this.$http
        .post('${portal}/matApproval/v1/bidOpenData', this.queryParam)
        .then((res) => {
          console.log(res, 'res')
          this.tableLoading = false
          if (res.data.state) {
            this.tableData = res.data.value.rows
            console.log('返回的表格数据', this.tableData)
            this.queryParam.pageBean = {
              page: res.data.value.page,
              pageSize: res.data.value.pageSize,
              total: res.data.value.total,
            }
          }
        })
    },
    changeCode(val) {
      console.log(this.search.code)
      if (val == '' || val.length == 0) {
        console.log(val.length)
        this.querys[0].value = ['3', '4', '5', '6']
        this.querys[0].operation = 'IN'
      } else if (val == 0 && val.length == undefined) {
        this.querys[0].value = ['3', '4']
        this.querys[0].operation = 'IN'
      } else if (val == 1) {
        this.querys[0].value = 5
        this.querys[0].operation = 'GREAT'
      }
      this.$forceUpdate()
    },
    handleDetails() {
      let params = {
        pageBean: {
          page: -1,
          pageSize: -1,
        },
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'round',
            relation: 'AND',
            value: this.multipleSelection[0].quotationRoundsNum,
          },
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'noticeId',
            relation: 'AND',
            value: this.multipleSelection[0].id,
          },
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'status',
            relation: 'AND',
            value: 1,
          },
        ],
      }
      this.$http
        .post('${portal}/userParticipation/v1/pageRegistraAndBid', params)
        .then((res) => {
          console.log(res, 'res')
          if (res.data.state) {
            this.bidDataList = res.data.value.rows
            this.showDetals = true
          }
        })
    },
    // 顶部搜索
    handleSearch() {
      if (this.search.code == '' || this.search.code.length == 0) {
        this.querys[0].value = ['3', '4', '5', '6']
        this.querys[0].operation = 'IN'
      }
      if (this.search.code == '0' && this.search.code.length == undefined) {
        this.querys[0].value = ['3', '4']
        this.querys[0].operation = 'IN'
      }
      if (this.search.code == 1) {
        this.querys[0].value = 5
        this.querys[0].operation = 'GREAT'
      }
      this.loadData()
    },
    clearSearchForm() {
      this.querys[0].value = ['3', '4']
      this.querys[0].operation = 'IN'
      this.querys[1].value = ''
      this.search.code = 0
      this.loadData()
    },
    handleSelectionChange(currentData) {
      this.currentDataDel = currentData
      this.multipleSelection = currentData
      if (this.multipleSelection[0].bidStatus == 3) {
        this.show = false
      } else {
        this.show = true
      }
    },
    handleCurrentChange(page) {
      this.queryParam.pageBean = {...this.queryParam.pageBean, page}
      this.loadData(this.queryParam)
    },
    handleSizeChange(pageSize) {
      this.queryParam.pageBean = {...this.queryParam.pageBean, pageSize}
      this.loadData(this.queryParam)
    },
    beforeClose() {
      this.showVisible = false
    },
  },
  computed: {
    SearchPanel() {
      return {
        '--searchPanel': this.searchPanel + 'px',
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.common-table-content.btn-pagenation {
  height: calc(100% - 100px);
}
.cloumn-btn {
  border: 1px solid #2761ff;
  padding: 3px 10px;
  border-radius: 5px;
  &:nth-child(1) {
    margin-right: 5px;
  }
  &:nth-child(2) {
    margin-right: 5px;
  }
  &:nth-child(1):hover {
    background-color: #2761ff;
    color: #fff;
  }
  &:nth-child(2):hover {
    background-color: #2761ff;
    color: #fff;
  }
  /deep/ i,
  span {
    font-size: 16px;
  }
}

/deep/ .el-tree-node__content {
  padding: 5px 0;
}

/deep/ .el-table thead tr th {
  background-color: #eee !important;
  border-right: 1px solid #dfe2e8 !important;
}
/deep/ .el-table {
  border-collapse: collapse !important;
}
</style>
