<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-anjuan"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="form-content" v-loading="loading">
      <el-steps :active="activeName" simple style="margin-bottom: 20px">
        <el-step
          title="立项信息"
          icon="el-icon-info"
          @click.native="changeTab('1')"
        >
        </el-step>
        <el-step
          title="物料信息"
          icon="el-icon-info"
          @click.native="changeTab('2')"
        >
        </el-step>
        <el-step
          title="招标信息"
          icon="el-icon-info"
          @click.native="changeTab('3')"
        >
        </el-step>
        <el-step
          title="评标信息"
          icon="el-icon-info"
          @click.native="changeTab('4')"
          v-if="parameter.evaluationMethod == 2"
        >
        </el-step>
      </el-steps>
      <div v-if="activeName == 1" class="div-content">
        <el-form
          ref="formInfo1"
          :model="parameter"
          label-width="auto"
          label-position="left"
          :rules="rules"
        >
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="组织单位" prop="affiliatedOrgName">
                <el-input
                  disabled
                  v-model="parameter.affiliatedOrgName"
                  placeholder="请输入组织单位"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="明细来源" prop="detailSourceType">
                <dict-select
                  dictCode="cglx-mxly"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.detailSourceType"
                  placeholder="请选择明细来源"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购单位" prop="procureOrgName">
                <el-input
                  :readonly="parameter.matIfPlat == 0 ? false : true"
                  v-model="parameter.procureOrgName"
                  placeholder="请选择采购单位"
                  clearable
                  prefix-icon="el-icon-search"
                  @focus="
                    parameter.detailSourceType == 1
                      ? purchasingUnitsBtn()
                      : clickOrg()
                  "
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="公告标题" prop="noticeTitle">
                <el-input
                  clearable
                  v-model="parameter.noticeTitle"
                  placeholder="请输入公告标题"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购类型" prop="procureType">
                <dict-select
                  dictCode="cglx-cglx"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  @select="changeType"
                  v-model="parameter.procureType"
                  placeholder="请选择采购类型"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.procureType == 4">
              <el-form-item label="份额分配数量(份)" prop="allocationOfShares">
                <dict-select
                  dictCode="fefpsl"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  @select="changeShares"
                  v-model="parameter.allocationOfShares"
                  placeholder="请选择份额分配数量"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.procureType == 4">
              <el-form-item label="第一分配率(%)" prop="allocationRate1">
                <el-input
                  type="Number"
                  clearable
                  v-model="parameter.allocationRate1"
                  :min="0"
                  placeholder="请输入第一分配率(%)"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col
              :span="8"
              v-if="
                ((parameter.allocationOfShares <= 2 &&
                  parameter.allocationOfShares != 1) ||
                  parameter.allocationOfShares == 3 ||
                  parameter.allocationOfShares == 4 ||
                  parameter.allocationOfShares == 5) &&
                parameter.procureType == 4
              "
            >
              <el-form-item label="第二分配率(%)" prop="allocationRate2">
                <el-input
                  type="Number"
                  clearable
                  v-model="parameter.allocationRate2"
                  :min="0"
                  placeholder="请输入第二分配率(%)"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col
              :span="8"
              v-if="
                ((parameter.allocationOfShares <= 3 &&
                  parameter.allocationOfShares != 1 &&
                  parameter.allocationOfShares != 2) ||
                  parameter.allocationOfShares == 4 ||
                  parameter.allocationOfShares == 5) &&
                parameter.procureType == 4
              "
            >
              <el-form-item label="第三分配率(%)" prop="allocationRate3">
                <el-input
                  type="Number"
                  clearable
                  v-model="parameter.allocationRate3"
                  :min="0"
                  placeholder="请输入第三分配率(%)"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col
              :span="8"
              v-if="
                ((parameter.allocationOfShares <= 4 &&
                  parameter.allocationOfShares != 1 &&
                  parameter.allocationOfShares != 2 &&
                  parameter.allocationOfShares != 3) ||
                  parameter.allocationOfShares == 5) &&
                parameter.procureType == 4
              "
            >
              <el-form-item label="第四分配率(%)" prop="allocationRate4">
                <el-input
                  type="Number"
                  clearable
                  v-model="parameter.allocationRate4"
                  :min="0"
                  placeholder="请输入第四分配率(%)"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col
              :span="8"
              v-if="
                parameter.allocationOfShares <= 5 &&
                parameter.allocationOfShares != 1 &&
                parameter.allocationOfShares != 2 &&
                parameter.allocationOfShares != 3 &&
                parameter.allocationOfShares != 4 &&
                parameter.procureType == 4
              "
            >
              <el-form-item label="第五分配率(%)" prop="allocationRate5">
                <el-input
                  type="Number"
                  clearable
                  v-model="parameter.allocationRate5"
                  :min="0"
                  placeholder="请输入第五分配率(%)"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="发布方式" prop="releaseMethod">
                <dict-select
                  dictCode="cglx-fbfs"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  :disabled="
                    parameter.procureType == 7 || parameter.procureType == 1
                  "
                  v-model="parameter.releaseMethod"
                  placeholder="请选择发布方式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="是否含税价" prop="isTax">
                <dict-select
                  dictCode="cgsq-bjfs"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.isTax"
                  placeholder="请选择是否含税价"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" key="2" v-if="parameter.releaseMethod == 2">
              <el-form-item
                label="供应商"
                :rules="[
                  {required: true, message: '请选择供应商', trigger: 'blur'},
                ]"
                prop="vendorName"
                class="input-select-item"
              >
                <el-tooltip
                  width="250"
                  placement="bottom"
                  effect="light"
                  :content="parameter.vendorName"
                >
                  <el-input
                    clearable
                    @focus="openVendor"
                    v-model="parameter.vendorName"
                    placeholder="请选择供应商"
                    prefix-icon="el-icon-search"
                  >
                  </el-input>
                </el-tooltip>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="付款方式" prop="quotationMethod">
                <dict-select
                  dictCode="cglx-fkfs"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  @select="selectMethod"
                  v-model="parameter.quotationMethod"
                  placeholder="请选择付款方式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.quotationMethod == 2">
              <el-form-item
                class="form-flex"
                label="承兑时间"
                prop="acceptanceTime"
              >
                <dict-select
                  dictCode="cdsj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.acceptanceTime"
                  placeholder="请选择承兑时间"
                />
                <div class="append">月</div>
              </el-form-item>
            </el-col>

            <!-- <el-col :span="8">
              <el-form-item label="资质要求" prop="hasQualification">
                <dict-select
                  dictCode="cglx-zzyq"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.hasQualification"
                  placeholder="请选择资质要求"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.hasQualification == 2">
              <el-form-item label="资质标签" prop="qualificationsCoutentName">
                <el-select
                  style="width: 100%"
                  @change="changeQualifications"
                  multiple
                  v-model="parameter.qualificationsCoutentName"
                  placeholder="请选择资质标签"
                >
                  <el-option
                    v-for="item in qualificationsList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                    @click.native="clickQua(item)"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col :span="8">
              <el-form-item label="有无保证金" prop="hasBond">
                <dict-select
                  dictCode="cglx-ywbzj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.hasBond"
                  placeholder="请选择有无保证金"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.hasBond == 1">
              <el-form-item label="保证金（元）" prop="bond">
                <el-input
                  clearable
                  v-model="parameter.bond"
                  placeholder="请输入保证金"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="投标文件是否必传"
                prop="isBidDocumentsUpload"
              >
                <dict-select
                  dictCode="sfsctbwj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.isBidDocumentsUpload"
                  placeholder="请选择投标文件是否必传"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报价轮次" prop="quotationRounds">
                <el-input
                  clearable
                  v-model="parameter.quotationRounds"
                  placeholder="请输入报价轮次"
                  :disabled="parameter.procureType != 4"
                  @input="changeRounds"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报价模板" prop="quotationTemplateName">
                <el-input
                  clearable
                  @focus="handleTemplate"
                  prefix-icon="el-icon-search"
                  v-model="parameter.quotationTemplateName"
                  placeholder="请选择报价模板"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col
              :span="8"
              v-if="getMethodauth('daicai') && parameter.isAgencyProcure == 1"
            >
              <el-form-item label="是否代采" prop="isAgencyProcure">
                <dict-select
                  dictCode="cgsq-sfdc"
                  :hasDefaultOption="true"
                  disabled
                  style="width: 100%"
                  v-model="parameter.isAgencyProcure"
                  placeholder="请选择是否代采"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                class="form-flex"
                label="挂账时间"
                prop="pendingTime"
              >
                <dict-select
                  dictCode="cdsj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.pendingTime"
                  placeholder="请选择挂账时间"
                />
                <div class="append">月</div>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="立项联系人" prop="affiliatedUserName">
                <el-input
                  clearable
                  v-model="parameter.affiliatedUserName"
                  placeholder="请输入联系人"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="联系方式" prop="contactsPhone">
                <el-input
                  clearable
                  v-model="parameter.contactsPhone"
                  placeholder="请输入联系方式"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="预算类型" prop="fundType">
                <dict-select
                  dictCode="xmyslx"
                  :hasDefaultOption="true"
                  style="width: 100%"
                  v-model="parameter.fundType"
                  placeholder="请选择预算类型"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购包或标段预算/规模(元)" prop="fundScale">
                <el-input
                  disabled
                  v-model="parameter.fundScale"
                  placeholder="自动计算明细最高限价总和"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="24">
              <el-form-item label="公告内容" prop="establishmentName">
                <quill-editor
                  v-model="parameter.establishmentName"
                  style="height: 120px"
                  ref="myQuillEditor"
                  :options="editorOption"
                  :editorOption="editorOption"
                >
                </quill-editor>
                <el-upload
                  :show-upload-list="false"
                  :on-success="handleFileSuccess"
                  type="drag"
                  :headers="headers"
                  :show-file-list="false"
                  :action="action"
                  class="uploadFile"
                >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div v-if="activeName == 2" class="div-content">
        <el-form
          ref="formInfo2"
          :model="parameter"
          label-width="auto"
          label-position="left"
          :rules="rules"
        >
          <div style="display: flex" v-if="parameter.detailSourceType == 2">
            <!-- <el-button
              @click="addTable"
              type="primary"
              style="margin-left: 10px"
              size="small"
              icon="el-icon-plus"
              >添加</el-button
            > -->
            <import-file :importData="importData" @load="load"></import-file>
          </div>
          <el-table
            ref="singleTable"
            :data="parameter.detailsList"
            style="width: 100%"
            highlight-current-row
            :cell-style="{'text-align': 'center'}"
            :header-cell-style="{'text-align': 'center'}"
          >
            <el-table-column fixed type="index" width="55" label="序号" />
            <el-table-column
              label="需求企业"
              min-width="140"
              prop="matCompanyName"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matCompanyName"
                  placeholder="需求企业"
                  disabled
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="物料名称" min-width="140" prop="matName">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matName"
                  placeholder="物料名称"
                  disabled
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="企业物料编号"
              min-width="120"
              prop="matCode"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matCode"
                  disabled
                  placeholder="企业物料编号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="平台物料编号"
              min-width="120"
              prop="matPlatcode"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matPlatcode"
                  disabled
                  placeholder="平台物料编号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="物料牌号"
              min-width="120"
              prop="matMaterial"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matMaterial"
                  disabled
                  placeholder="物料牌号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="规格型号" min-width="120" prop="matSpec">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matSpec"
                  disabled
                  placeholder="规格型号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="数量" min-width="110" prop="matNum">
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-if="parameter.applicationType == 2"
                  v-model="scope.row.matNum"
                  placeholder="数量"
                ></el-input>
                <el-input
                  v-else
                  clearable
                  disabled
                  type="Number"
                  v-model="scope.row.matNum"
                  placeholder="数量"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="最高限价(元)"
              min-width="110"
              prop="maximumPriceLimit"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.maximumPriceLimit"
                  placeholder="最高限价"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="税率" min-width="80" prop="taxRate">
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.taxRate"
                  placeholder="税率"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="计量单位" min-width="80" prop="matUnit">
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.matUnit"
                  placeholder="计量单位"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="品牌" min-width="80" prop="matBrand">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matBrand"
                  placeholder="品牌"
                  disabled
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="计划编号" min-width="140" prop="planCode">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.planCode"
                  placeholder="计划编号"
                  disabled
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="需求日期" min-width="140" prop="demandDate">
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.demandDate"
                  type="date"
                  disabled
                  value-format="yyyy-MM-dd"
                  placeholder="请选择需求日期"
                  style="width: 100%"
                />
              </template>
            </el-table-column>
            <el-table-column label="基础扩展" min-width="140" prop="matBaseExt">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matBaseExt"
                  disabled
                  placeholder=""
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="其他扩展"
              min-width="140"
              prop="matOtherExt"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.matOtherExt"
                  disabled
                  placeholder=""
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="送货地址"
              min-width="180"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.unloadAddress"
                  disabled
                  placeholder=""
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="企业补充说明"
              min-width="180"
              prop="remarks"
            >
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.remarks"
                  disabled
                  placeholder=""
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              align="right"
              width="90px"
              :index="999"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="danger"
                  circle
                  icon="el-icon-close"
                  @click="delTable(scope.$index, scope.row)"
                />
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
      <div v-if="activeName == 3" class="div-content">
        <el-form
          ref="formInfo3"
          :model="parameter"
          label-width="auto"
          label-position="left"
          :rules="rules"
        >
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="响应截止时间" prop="responseTimeDeadline">
                <el-date-picker
                  clearable
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%"
                  :picker-options="pickerOptions"
                  v-model="parameter.responseTimeDeadline"
                  placeholder="请选择响应截止时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="投标开始时间" prop="biddingStartTime">
                <el-date-picker
                  clearable
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  :picker-options="pickerOptionsStart"
                  style="width: 100%"
                  v-model="parameter.biddingStartTime"
                  placeholder="请选择投标开始时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="投标结束时间" prop="biddingEndTime">
                <el-date-picker
                  clearable
                  type="datetime"
                  :picker-options="pickerOptionsEnd"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%"
                  v-model="parameter.biddingEndTime"
                  placeholder="请选择投标结束时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="this.parameter.procureType != 3">
              <el-form-item label="评标方式" prop="evaluationMode">
                <dict-select
                  dictCode="cglx-pbfs"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.evaluationMode"
                  placeholder="请选择评标方式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="评标方法" prop="evaluationMethod">
                <!-- <el-input
                clearable
                type="areatext"
                v-model="parameter.evaluationMethod"
                placeholder="请选择评标方法"
              >
              <el-button
                    slot="append"
                    @click="evaluationBid"
                    icon="el-icon-search"
                  ></el-button>
              </el-input> -->
                <dict-select
                  dictCode="cglx-pbff"
                  :hasDefaultOption="true"
                  clearable
                  :disabled="this.parameter.procureType == 3"
                  style="width: 100%"
                  v-model="parameter.evaluationMethod"
                  placeholder="请选择评标方法"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" key="0" v-show="parameter.evaluationMethod == 2">
              <el-form-item prop="expertList">
                <span slot="label" style="display: inline-block">
                  评标人
                  <el-tooltip
                    effect="dark"
                    content="请选择至少三位评标人并且为奇数个数"
                    placement="bottom"
                  >
                    <i style="font-size: 18px" class="el-icon-question" />
                  </el-tooltip>
                </span>
                <el-input
                  clearable
                  type="areatext"
                  @focus="openExpert"
                  key="0"
                  v-model="parameter.expertList"
                  placeholder="请选择评标人"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="澄清补遗截止时间"
                prop="clarificationSupplementDeadlineTime"
              >
                <el-date-picker
                  clearable
                  type="datetime"
                  :picker-options="pickerOptions"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%"
                  v-model="parameter.clarificationSupplementDeadlineTime"
                  placeholder="请选择澄清补遗截止时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="供货商提出问题的截止时间"
                prop="raisingQuestionsDeadlineTime"
              >
                <el-date-picker
                  clearable
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%"
                  :picker-options="pickerOptions"
                  v-model="parameter.raisingQuestionsDeadlineTime"
                  placeholder="请选择供货商提出问题的截止时间"
                ></el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="中标结果有效期（天）" prop="winBidValidity">
                <el-input
                  clearable
                  type="number"
                  v-model="parameter.winBidValidity"
                  placeholder="请输入中标结果有效期（天）"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="rows-title">
            <div class="text-overflow">
              <el-tabs v-model="active" @tab-click="handleClick">
                <el-tab-pane name="1" label="招标文件">
                  <div>
                    <el-upload
                      class="upload-demo"
                      ref="upload"
                      :headers="headers"
                      :action="action"
                      :file-list="dataList"
                      :multiple="false"
                      accept=".png,.jpg,.jpeg,.xlsx,.xls,.pdf,.docx,.doc,.zip,.rar"
                      :show-file-list="false"
                      :before-upload="beforeUpload"
                      :on-progress="handleProgress"
                      :on-success="handleSuccess"
                      :on-error="onError"
                    >
                      <el-button slot="trigger" size="small" type="primary"
                        >上传文件</el-button
                      >
                    </el-upload>
                    <el-table
                      class="down"
                      :data="dataList"
                      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>
                </el-tab-pane>
              </el-tabs>
            </div>
          </div>
        </el-form>
      </div>
      <div v-if="activeName == 4" class="div-content">
        <el-form
          ref="formInfo3"
          :model="parameter"
          label-width="auto"
          label-position="left"
          :rules="rules"
        >
          <el-table
            :border="true"
            stripe
            fit
            size="mini"
            row-key="id"
            ref="multipleSelection"
            default-expand-all
            :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
            >
              <template slot-scope="scope">
                <div v-if="scope.row.children">
                  {{ scope.row.evaluationItemPname }}
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="评分细项"
              min-width="180"
              align="center"
              prop="evaluationItemCode"
            >
              <template slot="header">
                <span class="required">*</span>评分细项
              </template>
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-if="!scope.row.children"
                  type="textarea"
                  :disabled="
                    scope.row.evaluationItemCode == '价格得分' ? true : false
                  "
                  v-model="scope.row.evaluationItemCode"
                  placeholder="请输入评分细项"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="评分标准"
              min-width="180"
              align="center"
              prop="evaluationStandard"
            >
              <template slot="header">
                <span class="required">*</span>评分标准
              </template>
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-if="!scope.row.children"
                  type="textarea"
                  v-model="scope.row.evaluationStandard"
                  placeholder="请输入评分标准"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="分值"
              min-width="140"
              prop="evaluationScore"
            >
              <template slot="header">
                <span class="required">*</span>分值
              </template>
              <template slot-scope="scope">
                <el-input-number
                  v-model="scope.row.evaluationScore"
                  controls-position="right"
                  :min="0"
                  v-if="!scope.row.children"
                  :precision="0"
                  @change="handleInput(scope.row)"
                  :max="100"
                ></el-input-number>
                <div v-else>
                  {{ scope.row.score }}
                </div>
              </template>
            </el-table-column>
            <el-table-column min-width="120px" align="center" label="操作">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  plain
                  size="small"
                  v-if="scope.row.children"
                  @click="LowerBtn(scope.row)"
                  >添加下级</el-button
                >
                <el-button
                  type="text"
                  plain
                  size="small"
                  v-if="
                    !scope.row.children &&
                    scope.row.evaluationItemCode != '价格得分'
                  "
                  @click="deleteLevel(scope.row, scope.$index)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
    </div>
    <div slot="footer" class="footer">
      <el-button @click="handleClose">{{ $t('domestic.cancel') }}</el-button>
      <el-button type="primary" v-if="activeName == 2" @click="up"
        >上一步</el-button
      >
      <el-button type="primary" v-if="activeName == 3" @click="up1"
        >上一步</el-button
      >
      <el-button type="primary" v-if="activeName == 4" @click="up2"
        >上一步</el-button
      >
      <el-button
        type="primary"
        :loading="saveing"
        v-if="activeName == 1"
        @click="next"
        >下一步</el-button
      >
      <el-button type="primary" v-if="activeName == 2" @click="next1"
        >下一步</el-button
      >
      <el-button
        type="primary"
        v-if="activeName == 3 && parameter.evaluationMethod == 2"
        :loading="saveing"
        @click="next2"
        >下一步</el-button
      >
      <el-button
        type="primary"
        v-if="activeName == 3 && parameter.evaluationMethod != 2"
        :loading="saveing"
        @click="handleSave"
        >{{ $t('domestic.save') }}</el-button
      >
      <el-button
        type="primary"
        v-if="activeName == 4 && parameter.evaluationMethod == 2"
        :loading="saveing"
        @click="handleSave"
        >{{ $t('domestic.save') }}</el-button
      >
    </div>
    <!-- 选择采购组织 -->
    <purchasingUnits
      @addDetail="addDetail"
      :useOrgList="methodUnitsList"
      ref="troubleshooting"
    />
    <!-- 选择评标人 -->
    <expertUesrs @addexpert="handleAdd" :useOrgList="expertData" ref="expert" />
    <!-- 选择评标方法 -->
    <evaluationBid
      @addDetail="open"
      :useOrgList="bidList"
      ref="evaluationBid"
    />
    <!-- 选择报价模板 -->
    <quotationTemplateDialog @template="openTemplate" ref="template" />
    <supplierDialog
      @vendor="getSupplierList"
      :useOrgList="supplierList"
      ref="poolUnits"
    />
    <!-- 企业及下级单位 -->
    <subordinateOrgDialog
      ref="orgDialog"
      @org="getCompany"
    ></subordinateOrgDialog>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import {quillEditor} from 'vue-quill-editor' //调用编辑器
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import {mapState} from 'vuex'
import 'quill/dist/quill.bubble.css'
import purchasingUnits from './purchasingUnits.vue'
import basicData from '@/api/basicData'
import expertUesrs from './expertUesrs.vue'
import evaluationBid from './evaluationBid.vue'
import quotationTemplateDialog from './quotationTemplateDialog.vue'
import procurementManagement from '@/api/procurementManagement'
import supplierDialog from '@/components/dialog/supplierDialog.vue'
import subordinateOrgDialog from '@/components/dialog/subordinateOrgDialog.vue'

const toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'], // toggled buttons
  ['blockquote', 'code-block'],

  [{header: 1}, {header: 2}], // custom button values
  [{list: 'ordered'}, {list: 'bullet'}],
  [{script: 'sub'}, {script: 'super'}], // superscript/subscript
  [{indent: '-1'}, {indent: '+1'}], // outdent/indent
  [{direction: 'rtl'}], // text direction

  [{size: ['small', false, 'large', 'huge']}], // custom dropdown
  [{header: [1, 2, 3, 4, 5, 6, false]}],

  [{color: []}, {background: []}], // dropdown with defaults from theme
  [{font: []}],
  [{align: []}],
  ['link', 'image', 'upload'],
  ['clean'], // remove formatting button
]
import {Quill} from 'vue-quill-editor'
import moment from 'moment'
import {del} from '@vue/composition-api'
// 自定义插入a链接
var Link = Quill.import('formats/link')
class FileBlot extends Link {
  // 继承Link Blot
  static create(value) {
    let node = undefined
    if (value && !value.href) {
      // 适应原本的Link Blot
      node = super.create(value)
    } else {
      // 自定义Link Blot
      node = super.create(value.href)
      // node.setAttribute('download', value.innerText);  // 左键点击即下载
      node.innerText = value.innerText
      node.download = value.innerText
    }
    return node
  }
}
FileBlot.blotName = 'link'
FileBlot.tagName = 'A'
Quill.register(FileBlot)
export default {
  name: 'domesticDialog',
  components: {
    Breadcrumb,
    purchasingUnits,
    expertUesrs,
    quillEditor,
    quotationTemplateDialog,
    supplierDialog,
    evaluationBid,
    subordinateOrgDialog,
  },
  props: {
    editData: Object,
  },
  data() {
    return {
      importData: {
        title: '明细导入',
        templateName: '明细导入模板.xls',
        downloadUrl: '/../fvue/static/excel/明细导入模板.xls',
        importUrl: window.context.portal + '/matApprovalDetails/v1/excelToData',
        showProject: true,
        header: '明细导入',
      },
      activeName: '1',
      loading: false,
      supplierList: [],
      treeData: [],
      scoreData: [],
      editorOption: {
        // 改变提示文字内容
        placeholder: '请输入内容......',
        modules: {
          toolbar: {
            container: toolbarOptions, // 工具栏
            handlers: {
              upload: (value) => {
                if (value) {
                  document.querySelector('.uploadFile input').click()
                }
              },
            },
          },
        },
      },
      saveing: false,
      bidList: [],
      // qualificationsList: [],
      active: '1',
      centralizedData: [
        {name: '是', id: 1},
        {name: '否', id: 0},
      ],
      breadcrumbOpt: [{breadcrumbName: '采购立项'}, {breadcrumbName: '新增'}],
      expertData: [],
      rules: {
        fundType: [
          {
            required: true,
            message: '请选择预算类型',
            trigger: 'blur',
          },
        ],
        detailSourceType: [
          {
            required: true,
            message: '请选择明细来源',
            trigger: 'blur',
          },
        ],
        noticeTitle: [
          {
            required: true,
            message: '请输入公告标题',
            trigger: 'blur',
          },
        ],
        allocationOfShares: [
          {
            required: true,
            message: '请选择份额分配数量',
            trigger: 'blur',
          },
        ],
        expertList: [
          {required: true, message: '请选择评标人', trigger: 'blur'},
        ],
        matNum: [
          {
            required: true,
            message: '请输入数量',
            trigger: 'blur',
          },
        ],
        establishmentName: [
          {
            required: true,
            message: '请输入公告内容',
            trigger: 'blur',
          },
        ],
        procureOrgName: [
          {
            required: true,
            message: '请选择采购单位',
            trigger: 'blur',
          },
        ],
        applicationType: [
          {
            required: true,
            message: '请选择项目类型',
            trigger: 'blur',
          },
        ],
        matIfPlat: [
          {
            required: true,
            message: '请选择是否集中采购',
            trigger: 'blur',
          },
        ],
        procureType: [
          {
            required: true,
            message: '请选择采购类型',
            trigger: 'blur',
          },
        ],
        isTax: [
          {
            required: true,
            message: '请选择是否含税价',
            trigger: 'blur',
          },
        ],
        releaseMethod: [
          {
            required: true,
            message: '请选择发布方式',
            trigger: 'blur',
          },
        ],
        quotationMethod: [
          {
            required: true,
            message: '请选择付款方式',
            trigger: 'blur',
          },
        ],
        acceptanceTime: [
          {
            required: true,
            message: '请选择承兑时间',
            trigger: 'blur',
          },
        ],
        evaluationMethod: [
          {
            required: true,
            message: '请选择评标方法',
            trigger: 'blur',
          },
        ],
        // pendingTime: [
        //   {
        //     required: true,
        //     message: '请选择挂账时间',
        //     trigger: 'blur',
        //   },
        // ],
        // hasQualification: [
        //   {
        //     required: true,
        //     message: '请选择资质要求',
        //     trigger: 'blur',
        //   },
        // ],
        // qualificationsCoutentName: [
        //   {
        //     required: true,
        //     message: '请选择资质标签',
        //     trigger: 'blur',
        //   },
        // ],
        hasBond: [
          {
            required: true,
            message: '请选择有无保证金',
            trigger: 'blur',
          },
        ],
        bond: [
          {
            required: true,
            message: '请输入保证金',
            trigger: 'blur',
          },
        ],
        quotationRounds: [
          {
            required: true,
            message: '请输入报价轮数',
            trigger: 'blur',
          },
        ],
        quotationTemplateName: [
          {
            required: true,
            message: '请选择报价模板',
            trigger: 'blur',
          },
        ],
        evaluationMethodName: [
          {
            required: true,
            message: '请选择评标方法',
            trigger: 'blur',
          },
        ],
        biddingStartTime: [
          {
            required: true,
            message: '请选择投标开始时间',
            trigger: 'blur',
          },
        ],
        biddingEndTime: [
          {
            required: true,
            message: '请选择投标结束时间',
            trigger: 'blur',
          },
        ],
        clarificationSupplementDeadlineTime: [
          {
            required: true,
            message: '请选择澄清补遗时间',
            trigger: 'blur',
          },
        ],
        raisingQuestionsDeadlineTime: [
          {
            required: true,
            message: '请选择供货商提出问题的截止时间',
            trigger: 'blur',
          },
        ],
        responseTimeDeadline: [
          {
            required: true,
            message: '请选择响应截止时间',
            trigger: 'blur',
          },
        ],
        winBidValidity: [
          {
            required: true,
            message: '请输入中标结果有效期',
            trigger: 'blur',
          },
        ],
        evaluationMode: [
          {
            required: true,
            message: '请选择评标方式',
            trigger: 'blur',
          },
        ],
        allocationRate1: [
          {
            required: true,
            message: '请输入第一分配率(%)',
            trigger: 'blur',
          },
        ],
        allocationRate2: [
          {
            required: true,
            message: '请输入第二分配率(%)',
            trigger: 'blur',
          },
        ],
        allocationRate3: [
          {
            required: true,
            message: '请输入第三分配率(%)',
            trigger: 'blur',
          },
        ],
        allocationRate4: [
          {
            required: true,
            message: '请输入第四分配率(%)',
            trigger: 'blur',
          },
        ],
        allocationRate5: [
          {
            required: true,
            message: '请输入第五分配率(%)',
            trigger: 'blur',
          },
        ],
        isBidDocumentsUpload: [
          {
            required: true,
            message: '请选择投标文件是否必传',
            trigger: 'blur',
          },
        ],
      },
      addressList: [],
      useOrgListValue: '',
      dataList: [],
      uoLoading: false,
      fileList: [],
      methodUnitsList: [],
      parameter: {
        projectNumber: '',
        noticeTitle: '',
        establishmentName: '',
        projectApprovalType: '1',
        detailSourceType: 1,
        detailsList: [],
        bidStatus: '0',
        evaTemplate: {
          descriptionList: [],
        },
        procureOrgName: '',
        applicationType: '',
        allocationOfShares: 1,
        evaluationMode: 1,
        evaluationMethodName: '',
        quotationRounds: 1,
        quotationRoundsNum: 1,
        allocationRate1: 100,
        allocationRate2: '',
        allocationRate3: '',
        allocationRate4: '',
        winBidValidity: 90,
        allocationRate5: '',
        acceptanceTime: 6,
        isBidDocumentsUpload: 0,
        matIfPlat: '',
        // hasQualification: '1',
        pendingTime: 1,
        vendorName: '',
        isTax: '',
        fundType: 4,
        templateDetails: [],
        expertList: '',
        fundScale: 0,
        technicalWeight: 0,
        noticeType:1,
        businessWeight: 0,
        procureType: '1',
        tenderDocumentList: [],
        quotationTemplate: '',
        approvalInviteVendorList: [],
        quotationTemplateName: '',
        releaseMethod: '1',
        evaluationMethod: '1',
        biddingStartTime: '',
        projectEvaluationExpertList: [],
        biddingEndTime: '',
        raisingQuestionsDeadlineTime: '',
        clarificationSupplementDeadlineTime: '',
        matApprovalQualificationList: [],
        quotationMethod: '',
        hasBond: '0',
        purchasingApplicationId: '',
        bond: 0,
        releaseStatus: 0,
        responseTimeDeadline: '',
        quotationTemplateDetailApprovalList: [],
        zbDocument: {
          type: 1,
          accessoryList: [],
        },
      },
      pickerOptionsStart: {
        disabledDate: (time) => {
          if (this.parameter.biddingEndTime) {
            // eslint-disable-next-line max-len
            return (
              time.getTime() >
                new Date(this.parameter.biddingEndTime).getTime() ||
              time.getTime() <=
                new Date(this.basicInfo.createDate).getTime() - 86400000
            )
          }
          return (
            time.getTime() <=
            new Date(this.basicInfo.createDate).getTime() - 86400000
          )
        },
      },
      // 结束时间限制
      pickerOptionsEnd: {
        disabledDate: (time) => {
          if (this.parameter.biddingStartTime) {
            return (
              time.getTime() <
              new Date(this.parameter.biddingStartTime).getTime()
            )
          }
          return (
            time.getTime() <=
            new Date(this.basicInfo.createDate).getTime() - 86400000
          )
        },
      },
      basicInfo: {
        // 创建时间 此时间可以通过后端接口取服务器时间 或者 用 new Date().getTime()
        createDate: new Date().getTime(),
      },
      pickerOptions: {
        disabledDate: (time) => {
          if (this.parameter.responseTimeDeadline) {
            return (
              time.getTime() >
                new Date(this.parameter.biddingEndTime).getTime() ||
              time.getTime() <=
                new Date(this.basicInfo.createDate).getTime() - 86400000
            )
          }
          return (
            time.getTime() <=
            new Date(this.basicInfo.createDate).getTime() - 86400000
          )
        },
      },
    }
  },
  created() {
    this.getAddress()
    this.selectTree()
    this.addModifyBtn()
    this.parameter.matIfPlat = this.$route.query.type
    this.currentUser = JSON.parse(sessionStorage.getItem('currentUserDetail'))
    // this.parameter.procureOrgCode = this.currentUser.org[0].orgCode
    // this.parameter.procureOrgId = this.currentUser.org[0].orgId
    // this.parameter.procureOrgName = this.currentUser.org[0].orgName
    this.parameter.affiliatedOrgCode = this.currentUser.org[0].orgCode
    this.parameter.affiliatedOrgId = this.currentUser.org[0].orgId
    this.parameter.affiliatedOrgName = this.currentUser.org[0].orgName

    // this.getQualifications()
    let moment = require('moment')
    this.parameter.biddingStartTime = moment().format('YYYY-MM-DD HH:mm:ss')
    this.parameter.biddingEndTime = moment()
      .add(3, 'day')
      .format('YYYY-MM-DD HH:mm:ss')
    this.parameter.clarificationSupplementDeadlineTime = moment()
      .add(3, 'day')
      .format('YYYY-MM-DD HH:mm:ss')
    this.parameter.raisingQuestionsDeadlineTime = moment()
      .add(3, 'day')
      .format('YYYY-MM-DD HH:mm:ss')
    this.parameter.responseTimeDeadline = this.parameter.biddingStartTime
    this.parameter.affiliatedUserName = this.currentUser.user.fullname
    this.parameter.contactsPhone = this.currentUser.user.mobile
  },
  computed: {
    ...mapState({
      headers: (state) => {
        return {Authorization: `Bearer ${state.login.currentUser.token}`}
      },
      action: function () {
        return window.context.portal + '/biz/universal/v1/minioUpload'
      },
      actionBz: function () {
        return window.context.portal + '/matApproval/v1/uploadTenderDoc'
      },
    }),
  },
  mounted() {},
  watch: {
    scoreData: {
      handler: function (newVal, oldVal) {
        console.log('Address changed:', newVal, oldVal)
        // let sum = 0
        // newVal.forEach(item=>{
        //   console.log(item);
        //   item.evaluationScore += item.evaluationScore ==100
        // })
      },
      deep: true,
    },
  },
  methods: {
    // 获取送货地址分页
    getAddress() {
      let params = {
        pageBean: {
          pageSize: -1,
          page: -1,
        },
      }
      this.$http
        .post('${portal}/bizDeliveryAddress/v1/queryByPageOrg', params)
        .then((res) => {
          this.addressList = res.data.rows
        })
    },
    changeShares(val) {
      this.parameter.allocationOfShares = val
      if (val == 1) {
        this.parameter.allocationRate1 = 100
      }
      if (val == 2) {
        this.parameter.allocationRate1 = 50
        this.parameter.allocationRate2 = 50
      }
      if (val == 3) {
        this.parameter.allocationRate1 = 30
        this.parameter.allocationRate2 = 30
        this.parameter.allocationRate3 = 40
      }
      if (val == 4) {
        this.parameter.allocationRate1 = 25
        this.parameter.allocationRate2 = 25
        this.parameter.allocationRate3 = 25
        this.parameter.allocationRate4 = 25
      }
      if (val == 5) {
        this.parameter.allocationRate1 = 20
        this.parameter.allocationRate2 = 20
        this.parameter.allocationRate3 = 20
        this.parameter.allocationRate4 = 20
        this.parameter.allocationRate5 = 20
      }
    },
    //查询评标分类树结构
    selectTree() {
      basicData.bizEvaluationItemSelectTree().then((res) => {
        this.scoreData = res.value[0].children
        this.scoreData.forEach((item) => {
          item.evaluationItemPname = item.subjectName
          item.evaluationScore = 0
        })
      })
    },
    // 综合评标法添加子级
    LowerBtn(row) {
      row.children.push({
        evaluationItemCode: '',
        evaluationStandard: '',
        evaluationScore: 0,
        evaluationItemPid: row.id,
        id: Math.random() + '',
      })
      if (row.subjectName == '商务部分') {
        row.children[0].evaluationItemCode = '价格得分'
      }
    },
    deleteLevel(row, index) {
      this.scoreData = this.delFlatten(this.scoreData, row.id)
    },
    // 子节点删除
    delFlatten(arr, id) {
      arr.map((item) => {
        if (item.children !== undefined) {
          for (let i = 0; i < item.children.length; i++) {
            if (item.children[i].id === id) {
              item.children = item.children.filter((items) => {
                return items.id !== id
              })
            }
          }
        }
        if (Array.isArray(item.children)) {
          this.delFlatten(item.children, id)
        }
      })
      return arr
    },
    handleInput(val) {
      console.log(val)
      let sum = 0
      // this.scoreData.forEach((item) => {
      //   item.children.forEach((e, index) => {
      //     if (
      //       e.evaluationItemPid == item.id &&
      //       item.subjectName == '技术部分' &&
      //       item.subjectName != '商务部分'
      //     ) {
      //       sum += e.evaluationScore
      //       item.score = sum
      //     }
      //     if (
      //       e.evaluationItemPid == item.id &&
      //       item.subjectName == '商务部分'
      //     ) {
      //       item.score = 100 - sum
      //       if (val.id != e.id) {
      //         e.evaluationScore = item.score - val.evaluationScore
      //       }
      //     }
      //   })
      // })
    },
    // 切换tab
    handleClick(tab, e) {},
    // 上传文件成功回调
    handleSuccess(res, fileList) {
      this.loading = false
      if (this.active == 1) {
        if (res.state) {
          this.dataList.push(res.value)
          this.dataList.forEach((item) => {
            item['type'] = 1
          })
        }
        this.parameter.zbDocument.type = 1
        this.parameter.zbDocument.accessoryList = this.dataList
      }
    },
    beforeUpload(file) {
      let acceptList = ['xlsx', 'xls','png','jpg','jpeg','xlsx','xls','pdf','docx','doc','zip','rar']
      // 根据文件名获取文件的后缀名
      let fileType = file.name.split('.').pop().toLowerCase()
      // 判断文件格式是否符合要求
      if (acceptList.indexOf(fileType) === -1) {
        this.$message.error('请上传 .png,.jpg,.jpeg,.xlsx,.xls,pdf,.docx,.doc,.zip,.rar 格式的文件 !')
        return false
      }
    },
    handleProgress() {
      this.loading = true
    },
    onError(err, file, fileList) {
      this.loading = false
    },
    evaluationBid() {
      this.$refs.evaluationBid.add(this.currentUser.org[0].orgId)
    },
    //下载按钮回调
    downloadFile(name, url) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      a.download = name
      a.target = '_blank'
      a.href = url
      a.dispatchEvent(event)
    },
    // 删除
    deleteHandle(index) {
      this.$confirm('是否确认删除该附件', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        if (this.active == 1) {
          this.dataList.splice(index, 1)
        }
        if (this.active == 2) {
          this.fileList.splice(index, 1)
        }
      })
    },
    //采购单位
    purchasingUnitsBtn() {
      this.$refs.troubleshooting.add(this.parameter.matIfPlat)
    },
    clickOrg() {
      this.$refs.orgDialog.add(this.parameter.matIfPlat)
    },
    // 选择供应商
    openVendor() {
      this.$refs.poolUnits.add(this.parameter)
    },
    // 获取供应商数据
    getSupplierList(list) {
      list.forEach((item) => {
        this.parameter.approvalInviteVendorList.push({
          vendorId: item.id,
          vendorCode: item.code,
          vendorName: item.name,
          projectApprovalType: 1,
        })
      })
      this.supplierList = list
      this.parameter.vendorName = list
        .map((item) => {
          return item.name
        })
        .join(',')
      this.$nextTick(() => {
        this.$refs.formInfo1.clearValidate('vendorName')
      })
    },
    getCompany(data) {
      this.parameter.procureOrgCode = data[0].code
      this.parameter.procureOrgId = data[0].id
      this.parameter.procureOrgName = data[0].name
      this.parameter.detailsList = []
    },
    openExpert() {
      this.$refs.expert.add()
    },
    // 选择评标模板
    handleTemplate() {
      this.$refs.template.add(this.parameter)
    },
    // 获取评标模板数据
    openTemplate(data) {
      console.log(data, 'data')
      this.parameter.quotationTemplateDetailApprovalList = data
      this.parameter.quotationTemplate = data[0].id
      this.parameter.quotationTemplateName = data[0].name
      this.$nextTick(() => {
        this.$refs.formInfo1.clearValidate('quotationTemplateName')
      })
      this.$forceUpdate()
    },
    open(list) {
      console.log(list)
      this.bidList = list
      this.parameter.evaluationTemplateId = list.id
      this.parameter.evaluationMethodName = list.name
      if (list.evaluatingMethods == 1) {
        this.parameter.evaluationMethod = 2
      }
      if (list.evaluatingMethods == 2) {
        this.parameter.evaluationMethod = 1
      }
    },
    addDetail(list) {
      console.log(list)
      this.methodUnitsList = list
      let ids = list.map((item) => {
        return item.id
      })
      this.parameter.purchasingApplicationId = ids.join(',')
      this.parameter.procureOrgCode = list[0].preparedOrgCode
      this.parameter.procureOrgId = list[0].preparedOrgId
      this.parameter.procureOrgName = list[0].preparedOrgName
      this.parameter.applicationType = list[0].applicationType
      this.parameter.isAgencyProcure = list[0].isAgencyProcure
      if (this.parameter.isAgencyProcure == 1) {
        this.parameter.procureOrgCode = list[0].agencyProcureOrgCode
        this.parameter.procureOrgId = list[0].agencyProcureOrgId
        this.parameter.procureOrgName = list[0].agencyProcureOrgName
      }
      this.parameter.matIfPlat = list[0].matIfPlat
      this.parameter.isTax = list[0].isTax
      this.parameter.quotationMethod = list[0].payMethod
      this.parameter.pendingTime = list[0].pendingTime
      this.parameter.acceptanceTime = list[0].acceptanceTime
      this.parameter.procureType = list[0].procurementMethod
      if (this.parameter.procureType == 7) {
        this.parameter.releaseMethod = 2
      } else {
        this.parameter.releaseMethod = 1
      }
      if (
        list[0].accessoryList.length != 0 &&
        list[0].accessoryList != undefined
      ) {
        this.dataList = list[0].accessoryList
        this.dataList.forEach((item) => {
          delete item.id
        })
      }
      let params = {
        querys: [
          {
            group: 'main',
            operation: 'IN',
            parentGroup: '',
            property: 'purchasingApplicationId',
            relation: 'AND',
            value: ids,
          },
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'status',
            relation: 'AND',
            value: '1',
          },
        ],
        pageBean: {
          pageSize: -1,
          page: -1,
        },
      }
      this.$http
        .post('${portal}/bizPurchasingApplicationDetails/v1/page', params)
        .then((res) => {
          if (res.data.state) {
            if (this.parameter.detailsList.length == 0) {
              this.parameter.detailsList = res.data.value.rows
            } else {
              res.data.value.rows.forEach((item) => {
                this.parameter.detailsList.push(item)
              })
            }
            let sum = 0
            this.parameter.detailsList.forEach((item) => {
              sum += item.maximumPriceLimit
              item['matCompanyName'] = this.parameter.procureOrgName
              item['purchasingApplicationDetailId'] = item.id
              item['purchasingApplicationId'] = list[0].id
            })
            this.parameter.fundScale = sum
          }
        })
      this.useOrgListValue = list
        .map((item) => {
          return item.preparedOrgName
        })
        .join(',')
      this.$nextTick(() => {
        this.$refs.formInfo1.clearValidate('procureOrgName')
      })
    },
    // 公告文件上传
    handleFileSuccess(res, file) {
      this.quillUrl = res.value.url
      let quill = this.$refs.myQuillEditor.quill
      // 插入链接
      let length = quill.getSelection().index
      quill.insertEmbed(
        length,
        'link',
        {href: this.quillUrl, innerText: file.name},
        'api'
      )
      quill.setSelection(length + 1)
    },
    handleAdd(list) {
      this.expertData = []
      this.expertData = list
      this.parameter.projectEvaluationExpertList = list
      this.parameter.expertList = list
        .map((item) => {
          return item.fullname
        })
        .join(',')
      this.$nextTick(() => {
        if (this.parameter.expertList == undefined) {
          this.parameter.expertList = ''
        }
        let field = 'expertList' // 替换为要清除校验的字段名
        const rules = this.$refs['formInfo3'].rules

        if (rules && rules[field]) {
          this.$refs['formInfo3'].clearValidate(field)
        }
        delete rules.expertList
      })
      this.$forceUpdate()
    },
    //列表删除行
    delTable(index, row) {
      this.parameter.detailsList.splice(index, 1)
      if (row.id) {
        this.parameter.deleteDetailsId.push(row.id)
      }
    },
    //编辑
    addModifyBtn() {
      if (this.$route.query.editRows) {
        console.log()
        this.breadcrumbOpt[1].breadcrumbName = '编辑'
        this.modifychoData(this.$route.query.editRows)
      } else {
        this.breadcrumbOpt[1].breadcrumbName = '新增'
      }
    },
    //获取修改回显数据
    modifychoData(val) {
      this.loading = true
      procurementManagement.bizProjectApprovalSelectOne(val.id).then((res) => {
        this.loading = false
        this.parameter = res.value
        if (this.parameter.evaluationMethod == 2) {
          this.parameter.evaluationMethodName = '综合评标法'
        }
        if (this.parameter.evaluationMethod == 1) {
          this.parameter.evaluationMethodName = '最低评标法'
        }
        if (this.parameter.zbDocument != undefined) {
          delete this.parameter.zbDocument.id
          this.dataList = this.parameter.zbDocument.accessoryList
        }
        if (this.parameter.projectEvaluationExpertList) {
          this.parameter.expertList = this.parameter.projectEvaluationExpertList
            .map((item) => {
              return item.fullname
            })
            .join(',')
        }
        this.scoreData.forEach((item) => {
          item.evaluationItemPname = item.subjectName
          this.parameter.evaTemplate.descriptionList.forEach((val) => {
            if (item.id == val.evaluationItemPid) {
              item.children.push(val)
            }
          })
        })
        this.parameter.vendorName = this.parameter.approvalInviteVendorList
          .map((item) => {
            return item.vendorName
          })
          .join(',')
        this.supplierList = this.parameter.approvalInviteVendorList
        this.methodUnitsList = []
        let arr = this.parameter.purchasingApplicationId.split(',')
        arr.forEach((item) => {
          this.methodUnitsList.push({
            id: item,
          })
        })
      })
    },
    changeType(val) {
      this.parameter.quotationTemplateName = ''
      if (val == 4) {
        this.parameter.allocationOfShares = 2
        this.parameter.allocationRate1 = 50
        this.parameter.allocationRate2 = 50
      }
      if (val == 7) {
        this.parameter.releaseMethod = 2
      } else {
        this.parameter.releaseMethod = 1
      }
      if (val == 3) {
        this.parameter.isBidDocumentsUpload = 0
      } else {
        this.parameter.isBidDocumentsUpload = 1
      }
    },
    load(data) {
      console.log(data)
      if (this.parameter.detailsList.length == 0) {
        this.parameter.detailsList = data
        this.parameter.detailsList.forEach((item) => {
          item.acceptanceTime = this.parameter.acceptanceTime
          item.pendingTime = this.parameter.pendingTime
          item.matIfPlat = this.parameter.matIfPlat
        })
      } else {
        data.forEach((item) => {
          this.parameter.detailsList.push({
            matName: item.matName,
            matCode: item.matCode,
            matCode: item.matCode,
            matMaterial: item.matMaterial,
            matSpec: item.matSpec,
            matNum: item.matNum,
            matUnit: item.matUnit,
            procurementMethod: item.procurementMethod,
            matBrand: item.matBrand,
            preparedDate: item.demandDateValue,
            demandDate: item.demandDate,
            matBaseExt: item.matBaseExt,
            matOtherExt: item.matOtherExt,
            id: item.id,
            matCompanyName: item.matCompanyName,
            matPlatcode: item.matPlatcode,
            remarks: item.remarks,
            acceptanceTime: this.parameter.acceptanceTime,
            taxRate: item.taxRate,
            matId: item.matId,
            planCode: item.planCode,
            matIfPlat: this.parameter.matIfPlat,
            maximumPriceLimit: item.maximumPriceLimit,
            unloadAddress: item.unloadAddress,
            pendingTime: this.parameter.pendingTime,
            key: new Date(),
          })
        })
      }
      this.addressList.forEach((item) => {
        this.parameter.detailsList.forEach((val) => {
          if (item.code == val.unloadAddress) {
            val.unloadAddress = item.enterpriseContactAddress
          }
        })
      })
    },
    changeRounds(val) {},
    selectMethod() {
      this.parameter.quotationTemplateName = ''
    },
    // 关闭//面包屑点击
    handleClose() {
      if (this.$route.query.type == 1) {
        this.$router.push({
          name: 'approvalProcurement',
          params: {
            tabsActiveName: 'collectiveApprovalProcurement',
          },
        })
      }
      if (this.$route.query.type == 0) {
        this.$router.push({
          name: 'approvalProcurement',
          params: {
            tabsActiveName: 'selfApprovalProcurement',
          },
        })
      }
      this.parameter = {}
    },
    // 保存
    handleSave() {
      if (this.dataList.length == 0) {
        this.$message.warning('请上传招标文件')
        return
      }
      this.parameter.evaTemplate.descriptionList = []
      let sum = 0
      let arr = []
      this.scoreData.forEach((item) => {
        console.log(item)
        if (item.children) {
          item.evaluationItemPname = item.subjectName
          item.children.forEach((val) => {
            val.evaluationItemPname = item.subjectName
            sum += val.evaluationScore
            arr.push(val)
            this.parameter.evaTemplate.descriptionList = arr
          })
        }
        if (
          this.parameter.procureType == 1 ||
          this.parameter.procureType == 7
        ) {
          this.parameter.technicalWeight = 0
          this.parameter.businessWeight = 0
        } else {
          if (item.subjectName == '技术部分') {
            this.parameter.technicalWeight = item.score
          }
          if (item.subjectName == '商务部分') {
            this.parameter.businessWeight = item.score
          }
        }
      })
      if (this.parameter.evaluationMethod == 1) {
        sum = 0
      }
      if (this.parameter.evaluationMethod == 2 && sum != 100) {
        this.$message.warning('评标信息总分值需为100分，请重新输入')
        return false
      }
      this.scoreData.forEach((item) => {
        if (item.id) {
          delete item.id
        }
        if (item.children) {
          item.children.forEach((val) => {
            if (val.id) {
              delete val.id
            }
          })
        }
      })
      this.parameter.quotationTemplateDetailApprovalList.forEach((item) => {
        delete item.id
      })
      this.parameter.detailsList.forEach((item) => {
        delete item.id
      })
      if (
        this.parameter.projectEvaluationExpertList &&
        this.parameter.projectEvaluationExpertList.length != 0
      ) {
        this.parameter.projectEvaluationExpertList.forEach((item) => {
          item['expertId'] = item.id
          delete item.id
        })
      }
      if (this.parameter.matApprovalQualificationList.length != 0) {
        this.parameter.matApprovalQualificationList.forEach((item) => {
          item['qualificationTypeName'] = item.name
          item['qualificationTypeValue'] = item.code
          if (item.id) {
            delete item.id
          }
        })
      }
      delete this.parameter.zbDocument.id
      delete this.$refs['formInfo3'].rules.expertList
      this.parameter.zbDocument.accessoryList = this.dataList
      console.log(this.parameter)
      this.$refs.formInfo3.validate((valid) => {
        if (valid) {
          this.saveing = true
          procurementManagement
            .bizProjectApprovalSaveOrUpdate(this.parameter)
            .then((res) => {
              this.saveing = false
              if (res.state) {
                this.$message.success(res.message)
                this.handleClose()
              }
            })
        }
      })
    },
    changTap(val) {
      this.activeName = val
    },
    next() {
      if (this.activeName == 1) {
        this.$refs.formInfo1.validate((valid) => {
          if (valid) {
            this.parameter.detailsList.forEach((item) => {
              delete item.id
            })
            this.saveing = true
            procurementManagement
              .bizProjectApprovalSaveOrUpdate(this.parameter)
              .then((res) => {
                this.saveing = false
                if (res.state) {
                  this.activeName = 2
                  this.$message.success('暂存成功')
                  this.parameter = res.value
                  delete this.parameter.zbDocument.id
                  if (
                    this.parameter.projectEvaluationExpertList &&
                    this.parameter.projectEvaluationExpertList.length != 0
                  ) {
                    if (this.parameter.expertList == undefined) {
                      this.parameter.expertList = ''
                    }
                    this.parameter.expertList =
                      this.parameter.projectEvaluationExpertList
                        .map((item) => {
                          return item.fullname
                        })
                        .join(',')
                  }
                }
              })
          }
        })
      }
    },
    next1() {
      this.$refs.formInfo2.validate((valid) => {
        if (valid) {
          this.activeName = 3
        }
      })
    },
    next2() {
      // this.selectTree()
      if (this.dataList.length == 0) {
        this.$message.warning('请上传招标文件')
        return
      }
      this.$refs.formInfo3.validate((valid) => {
        if (valid) {
          this.parameter.detailsList.forEach((item) => {
            delete item.id
          })
          this.parameter.projectEvaluationExpertList.forEach((item) => {
            delete item.id
          })
          this.parameter.quotationTemplateDetailApprovalList.forEach((item) => {
            delete item.id
          })
          delete this.parameter.evaTemplate.id
          delete this.parameter.zbDocument.id
          this.saveing = true
          procurementManagement
            .bizProjectApprovalSaveOrUpdate(this.parameter)
            .then((res) => {
              this.saveing = false
              if (res.state) {
                this.activeName = 4
                this.$message.success('暂存成功')
              }
            })
        }
      })
    },
    up() {
      if (this.activeName == 2) {
        this.activeName = 1
      }
    },
    up1() {
      if (this.activeName == 3) {
        this.activeName = 2
      }
    },
    up2() {
      if (this.activeName == 4) {
        this.activeName = 3
      }
    },
    changeTab(val) {
      this.activeName = val
    },
    getMethodauth(elAuth) {
      let allMethod = window.sessionStorage.allMethod
      let methodAuth = window.sessionStorage.methodAuth
      let allMethodArray = allMethod && allMethod.split(',')
      let methodAuthArray = methodAuth && methodAuth.split(',')
      // 无权限则隐藏按钮
      if (
        methodAuthArray &&
        methodAuthArray.includes(elAuth) &&
        allMethodArray &&
        allMethodArray.includes(elAuth)
      ) {
        return true
      } else {
        return false
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.form-content {
  overflow: hidden;
}
/deep/.el-tabs {
  height: 100%;
}
/deep/.el-table-lable-box .cell {
  display: flex;
  justify-content: center;
}
/deep/.el-tabs__content {
  height: calc(100% - 50px);
  overflow-y: auto;
}
.div-content {
  height: calc(100% - 70px);
  overflow-y: auto;
  overflow-x: hidden;
}
.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-tabs__item {
  font-size: 16px;
}
/deep/.el-tabs__header {
  padding: 0;
}
/deep/.el-row {
  display: flex;
  flex-wrap: wrap;
}
.form-flex {
  /deep/.el-form-item__content {
    display: flex;
    align-items: center;
  }
}
.append {
  width: 10%;
  background-color: #f5f7fa;
  color: #909399;
  vertical-align: middle;
  display: table-cell;
  position: relative;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 0 10px;
  white-space: nowrap;
  text-align: center;
}
/deep/.el-step.is-simple:not(:last-of-type) .el-step__title {
  cursor: pointer;
}
/deep/.el-step.is-simple .el-step__title {
  cursor: pointer;
}
.required {
  color: red;
  font-size: 14px;
  margin-right: 3px;
}
</style>
<style lang="scss">
.ql-snow.ql-toolbar .ql-upload {
  background: url('../../../../../assets/img/icon_upload.svg');
  background-size: 18px 18px;
  background-position: center center;
  background-repeat: no-repeat;
  /*background: red;*/
}
</style>
