<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="procureOrgName">
                <el-input
                  readonly
                  v-model="parameter.procureOrgName"
                  placeholder="请选择采购单位"
                >
                  <!-- <el-button slot="append" @click="purchasingUnitsBtn" icon="el-icon-search"></el-button> -->
                </el-input>
              </el-form-item>
            </el-col>
            <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-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="项目名称" prop="projectLedgerName">
                <el-input
                  @focus="openProject"
                  prefix-icon="el-icon-search"
                  v-model="parameter.projectLedgerName"
                  placeholder="请选择项目"
                >
                  <!-- <el-button slot="append" @click="purchasingUnitsBtn" icon=""></el-button> -->
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目编号" prop="projectLedgerCode">
                <el-input
                  v-model="parameter.projectLedgerCode"
                  placeholder="项目编号"
                  disabled
                >
                  <!-- <el-button slot="append" @click="purchasingUnitsBtn" icon=""></el-button> -->
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目类型" prop="applicationType">
                <dict-select
                  dictCode="xmlx"
                  :hasDefaultOption="true"
                  @change="changeProjectType"
                  style="width: 100%"
                  disabled
                  v-model="parameter.applicationType"
                  placeholder="请选择项目类型"
                />
              </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%"
                  v-model="parameter.procureType"
                  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">
              <el-form-item label="发布方式" prop="releaseMethod">
                <dict-select
                  dictCode="cglx-fbfs"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.releaseMethod"
                  placeholder="请选择发布方式"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8" v-if="parameter.releaseMethod == 2">
              <el-form-item
                label="供应商"
                prop="vendorName"
                class="input-select-item"
              >
                <el-input
                  readonly
                  v-model="parameter.vendorName"
                  placeholder="请选择供应商"
                >
                  <el-button
                    slot="append"
                    @click="openVendor"
                    icon="el-icon-search"
                  ></el-button>
                </el-input>
              </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%"
                  @change="changeMethod"
                  v-model="parameter.quotationMethod"
                  placeholder="请选择付款方式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="parameter.quotationMethod == 2">
              <el-form-item label="承兑时间" prop="acceptanceTime">
                <dict-select
                  dictCode="cdsj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.acceptanceTime"
                  placeholder="请选择承兑时间"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="挂账时间" prop="pendingTime">
                <dict-select
                  dictCode="cdsj"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.pendingTime"
                  placeholder="请选择挂账时间"
                />
              </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="qualificationsCoutent">
                <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.qualificationName"
                    :value="item.qualificationName"
                  >
                  </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
                  type="number"
                  v-model="parameter.bond"
                  placeholder="请输入保证金"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8" >
              <el-form-item label="标书费（元）" prop="documentFee">
                <el-input
                  clearable
                  type="number"
                  v-model="parameter.documentFee"
                  placeholder="请输入标书费"
                ></el-input>
              </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
                  type="number"
                  v-model="parameter.contactsPhone"
                  placeholder="请输入联系方式"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报价轮次" prop="quotationRounds">
                <el-input
                  clearable
                  :disabled="parameter.procureType != 4"
                  v-model="parameter.quotationRounds"
                  placeholder="请输入报价轮次"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报价模板" prop="quotationTemplateName">
                <el-input
                  clearable
                  suffix-icon="el-icon-search"
                  @focus="handleTemplate"
                  v-model="parameter.quotationTemplateName"
                  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
                  v-model="parameter.fundScale"
                  placeholder="自动计算明细最高限价总和"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="付款条件" prop="payRatio">
                <span slot="label" style="display: inline-block">
                  付款条件
                  <el-tooltip
                    effect="dark"
                    content="请输入比例相加为10的付款条件"
                    placement="bottom"
                  >
                    <i style="font-size: 18px" class="el-icon-question" />
                  </el-tooltip>
                </span>
                <div style="display: flex;">
                  <el-input
                  v-model="parameter.payRatio1"
                  placeholder="付款比例"
                ></el-input>
                <span>：</span>
                <el-input
                  v-model="parameter.payRatio2"
                  placeholder="付款比例"
                ></el-input>
                <span>：</span>
                <el-input
                  v-model="parameter.payRatio3"
                  placeholder="付款比例"
                ></el-input>
                </div>
                
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
              <el-form-item label="第四次付款比例" prop="payRatio4">
                <el-input
                  v-model="parameter.payRatio4"
                  placeholder="第四次付款比例"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="第五次付款比例" prop="payRatio5">
                <el-input
                  v-model="parameter.payRatio5"
                  placeholder="第五次付款比例"
                ></el-input>
              </el-form-item>
            </el-col> -->
          </el-row>
          <el-row :gutter="24"> </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"
                  :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="right"
          :rules="rules"
        >
          <div>
            <el-button
              icon="el-icon-plus"
              type="primary"
              size="mini"
              style="margin-left: 10px"
              @click="addTableList"
              >添加</el-button
            >
          </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="150" prop="detailType">
              <template slot-scope="scope">
                <dict-select
                  dictCode="xmlx"
                  v-if="parameter.applicationType == 2"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="scope.row.detailType"
                  placeholder="请选择明细类型"
                />
                <div v-if="parameter.applicationType == 1">
                  {{ scope.row.detailType ? '服务' : '服务' }}
                </div>
              </template>
            </el-table-column>
            <!-- <el-table-column label="项目编号" min-width="150" prop="matName">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matName"
                  placeholder="请输入名称"
                ></el-input>
              </template>
            </el-table-column> -->
            <el-table-column label="项目名称" min-width="150" prop="matName">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matName"
                  placeholder="请输入名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="服务内容"
              min-width="150"
              prop="matOtherExt"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matOtherExt"
                  placeholder="请输入采购名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="服务范围" min-width="150" prop="matBaseExt">
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matBaseExt"
                  placeholder="请输入服务范围"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="开始时间"
              min-width="170"
              prop="serviceStartTime"
            >
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.serviceStartTime"
                  type="date"
                  placeholder="开始时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column
              label="结束时间"
              min-width="170"
              prop="serviceEndTime"
            >
              <template slot-scope="scope">
                <el-date-picker
                  v-model="scope.row.serviceEndTime"
                  type="date"
                  placeholder="结束时间"
                  value-format="yyyy-MM-dd"
                  format="yyyy-MM-dd"
                  style="width: 100%"
                >
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column
              label="图号/规格型号"
              min-width="170"
              prop="matSpec"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matSpec"
                  placeholder="请输入图号/规格型号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="项目描述"
              min-width="170"
              prop="projectDescript"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  type="textarea"
                  v-model="scope.row.projectDescript"
                  placeholder="请输入项目描述"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="计量单位"
              min-width="170"
              prop="matUnit"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  v-model="scope.row.matUnit"
                  placeholder="请输入计量单位"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="数量"
              min-width="140"
              show-overflow-tooltip
              prop="matNum"
            >
              <template slot-scope="scope">
                <el-form-item
                  :prop="`detailsList.${scope.$index}.matNum`"
                  :rules="rules.matNum"
                  label-width="0px"
                  style="margin-bottom: 0px"
                >
                  <el-input
                    v-model="scope.row.matNum"
                    placeholder="请输入数量"
                    clearable
                    prefix-icon="el-icon-search"
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              label="预估金额(万元)"
              min-width="180"
              show-overflow-tooltip
              prop="amount"
            >
              <template slot-scope="scope">
                  <el-input
                    clearable
                    v-model="scope.row.amount"
                    placeholder="请输入预估金额"
                  ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="备注"
              min-width="170"
              prop="remark"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  type="textarea"
                  v-model="scope.row.remark"
                  placeholder="请输入备注"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              fixed="right"
              align="right"
              width="90px"
              label="操作"
              :index="999"
            >
              <template slot-scope="scope" slot="header">
                <div>
                  <el-button
                    icon="el-icon-plus"
                    type="warning"
                    size="mini"
                    round
                    style="margin-left: 10px"
                    @click="addTable(scope.row)"
                  ></el-button>
                </div>
              </template>
              <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>
        <!--
        <el-tabs v-model="activeProject" type="card" @tab-click="handleClick">
          <el-tab-pane
            label="服务"
            name="first"
            v-if="parameter.applicationType == 1"
          ></el-tab-pane>
          <el-tab-pane
            label="服务"
            v-if="parameter.applicationType == 2"
            name="third"
          ></el-tab-pane>
          <el-tab-pane
            label="工程"
            v-if="parameter.applicationType == 2"
            name="second"
          ></el-tab-pane>
        </el-tabs>
        <el-button
          icon="el-icon-plus"
          type="primary"
          size="small"
          style="margin-left: 10px"
          @click="addTable(activeProject)"
          >添加</el-button
        >
        <el-table
          ref="singleTable"
          :data="parameter.serviceDetailList"
          style="width: 100%"
          v-if="activeName == 'first'"
          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="150" prop="matName">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matName"
                placeholder="服务名称"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="服务内容" min-width="150" prop="matOtherExt">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matOtherExt"
                placeholder="请输入服务内容"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="服务范围" min-width="170" prop="matBaseExt">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matBaseExt"
                placeholder="服务范围"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="服务开始时间"
            min-width="150"
            prop="serviceStartTime"
          >
            <template slot-scope="scope">
              <el-date-picker
                v-model="scope.row.serviceStartTime"
                type="date"
                placeholder="服务开始时间"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                style="width: 100%"
              >
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column
            label="服务结束时间"
            min-width="150"
            prop="serviceEndTime"
          >
            <template slot-scope="scope">
              <el-date-picker
                v-model="scope.row.serviceEndTime"
                type="date"
                placeholder="服务结束时间"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                style="width: 100%"
              >
              </el-date-picker>
            </template>
          </el-table-column>

          <el-table-column label="金额(万元)" min-width="150" prop="amount">
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                v-model="scope.row.amount"
                placeholder="金额(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            align="right"
            width="90px"
            label="操作"
            :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-table
          ref="singleTable"
          v-show="parameter.projectType == 2 && activeName == 'third'"
          :data="parameter.serviceDetailList"
          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="150" prop="matName">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matName"
                placeholder="服务名称"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="服务内容" min-width="150" prop="matOtherExt">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matOtherExt"
                placeholder="请输入服务内容"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="服务范围" min-width="170" prop="matBaseExt">
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matBaseExt"
                placeholder="服务范围"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="服务开始时间"
            min-width="150"
            prop="serviceStartTime"
          >
            <template slot-scope="scope">
              <el-date-picker
                v-model="scope.row.serviceStartTime"
                type="date"
                placeholder="服务开始时间"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                style="width: 100%"
              >
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column
            label="服务开始时间"
            min-width="150"
            prop="serviceEndTime"
          >
            <template slot-scope="scope">
              <el-date-picker
                v-model="scope.row.serviceEndTime"
                type="date"
                placeholder="服务结束时间"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                style="width: 100%"
              >
              </el-date-picker>
            </template>
          </el-table-column>

          <el-table-column label="金额(万元)" min-width="150" prop="amount">
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                v-model="scope.row.amount"
                placeholder="金额(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            align="right"
            width="90px"
            label="操作"
            :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-table
          ref="singleTable"
          v-show="parameter.projectType == 2 && activeName == 'second'"
          :data="parameter.engineeringDetailList"
          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="150"
            prop="matName"
          >
            <template slot-scope="scope">
              <el-input
                clearable
                v-model="scope.row.matName"
                placeholder="项目或费用名称"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="建筑面积(平方米)"
            min-width="150"
            prop="buildingArea"
          >
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                v-model="scope.row.buildingArea"
                placeholder="建筑面积(平方米)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="建筑工程及公用系统(万元)"
            min-width="150"
            prop="constructionEngineering"
          >
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                @input="changeAmount(scope.row)"
                v-model="scope.row.constructionEngineering"
                placeholder="建筑工程及公用系统(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="设备购置及安装(万元)"
            min-width="170"
            prop="equipmentProcurement"
          >
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                @input="changeAmount(scope.row)"
                v-model="scope.row.equipmentProcurement"
                placeholder="设备购置及安装(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            label="其他费用(万元)"
            min-width="120"
            prop="otherExpenses"
          >
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                @input="changeAmount(scope.row)"
                v-model="scope.row.otherExpenses"
                placeholder="其他费用(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="合计(万元)" min-width="150" prop="amount">
            <template slot-scope="scope">
              <el-input
                clearable
                type="Number"
                v-model="scope.row.amount"
                placeholder="合计(万元)"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            align="right"
            width="90px"
            label="操作"
            :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> -->
        <!-- <el-form
          ref="formInfo2"
          :model="parameter"
          label-width="auto"
          label-position="left"
          :rules="rules"
        >
          <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
              fixed
              label="物料名称"
              min-width="170"
              prop="matName"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  readonly
                  v-model="scope.row.matName"
                  placeholder="选择物料名称"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="企业物料编号"
              min-width="150"
              prop="matCompanyCode"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.matCompanyCode"
                  placeholder="企业物料编号"
                ></el-input>
              </template>
            </el-table-column>

            <el-table-column
              label="物料牌号"
              min-width="130"
              prop="matMaterial"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.matMaterial"
                  placeholder="物料牌号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="规格型号" min-width="130" prop="matSpec">
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.matSpec"
                  placeholder="规格型号"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="数量" min-width="110" prop="matNum">
              <template slot-scope="scope">
                <el-input
                  v-if="parameter.applicationType == 2"
                  readonly
                  disabled
                  v-model="scope.row.matNum"
                  placeholder="请输入数量"
                ></el-input>
                <el-input
                  clearable
                  disabled
                  v-else
                  v-model="scope.row.matNum"
                  placeholder="请输入数量"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              v-if="parameter.isTax == 2"
              label="不含税单价(元)"
              min-width="110"
              prop="purPrice"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.purPrice"
                  placeholder="不含税单价"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              v-if="parameter.isTax == 1"
              label="含税单价(元)"
              min-width="110"
              prop="taxInprice"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.taxInprice"
                  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
                  disabled
                  v-model="scope.row.matBrand"
                  placeholder="品牌"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column label="计划编号" min-width="80" prop="planCode">
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.planCode"
                  placeholder="计划编号"
                ></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
                  disabled
                  v-model="scope.row.matBaseExt"
                  placeholder="基础扩展"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="其他扩展"
              min-width="140"
              prop="matOtherExt"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.matOtherExt"
                  placeholder="其他扩展"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="送货地址"
              min-width="180"
              prop="unloadAddress"
            >
              <template slot-scope="scope">
                <el-input
                  clearable
                  disabled
                  v-model="scope.row.unloadAddress"
                  placeholder="请输入送货地址"
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="企业补充说明"
              min-width="180"
              prop="remarks"
            >
              <template slot-scope="scope">
                <el-input
                  disabled
                  v-model="scope.row.remarks"
                  placeholder="请输入企业补充说明"
                ></el-input>
              </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" 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">
                <dict-select
                  dictCode="cglx-pbff"
                  :hasDefaultOption="true"
                  clearable
                  style="width: 100%"
                  v-model="parameter.evaluationMethod"
                  placeholder="请选择评标方法"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="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="responseTimeDeadline">
                <el-date-picker
                  clearable
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%"
                  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"
                  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"
                  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">
              <el-form-item
                label="澄清补遗截止时间"
                prop="clarificationSupplementDeadlineTime"
              >
                <el-date-picker
                  clearable
                  type="datetime"
                  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%"
                  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
                  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"
                      :on-progress="handleProgress"
                      accept=".png,.jpg,.jpeg,.xlsx,.xls,.pdf,.docx,.doc,.zip,.rar"
                      :on-error="onError"
                      :show-file-list="false"
                      :on-success="handleSuccess"
                    >
                      <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-tab-pane
                  v-if="
                    parameter.bidStatus == 2 ||
                    parameter.bidStatus == 3 ||
                    parameter.bidStatus == 4 ||
                    parameter.bidStatus == 5
                  "
                  name="2"
                  label="补遗文件"
                >
                  <div>
                    <el-row :gutter="24">
                      <el-col :span="24">
                        <el-form-item label="描述" prop="describe">
                          <el-input
                            clearable
                            type="areatext"
                            v-model="parameter.byDocument.describe"
                            placeholder="请输入描述"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-upload
                      class="upload-demo"
                      ref="upload"
                      :headers="headers"
                      :action="actionBz"
                      :file-list="fileList"
                      :multiple="false"
                      accept=".png,.jpg,.jpeg,.xlsx,.xls,.pdf,.docx,.doc,.zip,.rar"
                      :show-file-list="false"
                      :on-success="handleSuccess"
                    >
                      <el-button slot="trigger" size="small" type="primary"
                        >上传文件</el-button
                      >
                    </el-upload>
                    <el-table
                      class="down"
                      :data="fileList"
                      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
      >
    </div>
    <!-- 选择采购组织 -->
    <!-- <purchasingUnits
      @addDetail="addDetail"
      :useOrgList="methodUnitsList"
      ref="troubleshooting"
    /> -->
    <!-- 选择评标人 -->
    <expertUesrs @handleAdd="handleAdd" :useOrgList="expertList" ref="expert" />
    <!-- 选择报价模板 -->
    <quotationTemplateDialog @template="openTemplate" ref="template" />
    <expertPoolUnits
      @vendor="getSupplierList"
      :useOrgList="supplierList"
      title="选择供应商"
      ref="poolUnits"
    />
    <!-- 选择新项目 -->
    <selectProjectDialog
      ref="project"
      @load="getProject"
      :useOrgList="projectList"
    ></selectProjectDialog>
    <!-- 地址弹窗 -->
    <addressDialog ref="address" @emit="getEmit"></addressDialog>
    <!-- 项目明细 -->
    <purchaseMaterial
      @addDetail="addDetail"
      :useOrgList="methodUnitsList"
      ref="troubleshooting"
    />
  </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 basicData from '@/api/basicData'
import {mapState} from 'vuex'
import 'quill/dist/quill.bubble.css'
import purchasingUnits from './purchasingUnits.vue'
import expertUesrs from './expertUesrs.vue'
import quotationTemplateDialog from './quotationTemplateDialog.vue'
import selectProjectDialog from './selectProjectDialog.vue'
import addressDialog from '@/components/dialog/addressDialog.vue'
import procurementManagement from '@/api/procurementManagement'
import expertPoolUnits from '@/components/dialog/expertPoolUnits.vue'
import purchaseMaterial from './purchaseMaterial.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, 8, false]}],

  [{color: []}, {background: []}], // dropdown with defaults from theme
  [{font: []}],
  [{align: []}],
  ['link', 'image', 'upload'],
  ['clean'], // remove formatting button
]
import {Quill} from 'vue-quill-editor'
// 自定义插入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,
    expertPoolUnits,
    selectProjectDialog,
    addressDialog,
    purchaseMaterial,
  },
  props: {
    editData: Object,
  },
  data() {
    return {
      importData: {
        title: '明细导入',
        templateName: '明细导入模板.xls',
        downloadUrl: '/../fvue/static/excel/material.xlsx',
        importUrl: window.context.portal + '/biz/Gs/v1/importExcelData',
        showProject: true,
        header: '明细导入',
      },
      editorOption: {
        // 改变提示文字内容
        placeholder: '请输入内容......',
        modules: {
          toolbar: {
            container: toolbarOptions, // 工具栏
            handlers: {
              upload: (value) => {
                if (value) {
                  document.querySelector('.uploadFile input').click()
                }
              },
            },
          },
        },
      },
      saveing: false,
      loading: false,
      bidList: [],
      supplierList: [],
      qualificationsList: [],
      active: '1',
      centralizedData: [
        {name: '是', id: 1},
        {name: '否', id: 0},
      ],
      breadcrumbOpt: [{breadcrumbName: '项目立项'}, {breadcrumbName: '新增'}],
      expertList: [],
      activeName: '1',
      activeProject: 'first',
      rules: {
        projectLedgerName: [
          {
            required: true,
            message: '请选择项目',
            trigger: 'blur',
          },
        ],
        documentFee: [
          {
            required: true,
            message: '请输入标书费',
            trigger: 'blur',
          },
        ],
        noticeTitle: [
          {
            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',
          },
        ],
        vendorName: [
          {
            required: true,
            message: '请选择供应商',
            trigger: 'blur',
          },
        ],
        establishmentName: [
          {
            required: true,
            message: '请输入项目内容',
            trigger: 'blur',
          },
        ],
        quotationMethod: [
          {
            required: true,
            message: '请选择付款方式',
            trigger: 'blur',
          },
        ],
        acceptanceTime: [
          {
            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',
          },
        ],
        evaluationMethod: [
          {
            required: true,
            message: '请选择评标方法',
            trigger: 'blur',
          },
        ],
        expertList: [
          {
            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',
          },
        ],
        payRatio: [
          {
            required: true,
            message: '请输入付款条件',
            trigger: 'blur',
          },
        ],
      },
      useOrgListValue: '',
      dataList: [],
      fileList: [],
      methodUnitsList: [],
      parameter: {
        projectNumber: '',
        noticeTitle: '',
        documentFee:0,
        establishmentName: '',
        projectApprovalType: '1',
        projectSourceType: 1,
        winBidValidity: 90,
        detailsList: [],
        expertList: '',
        projectLedgerName: '',
        bidStatus: '0',
        payFrequency:3,
        procureOrgName: '',
        pendingTime: 0,
        applicationType: '1',
        quotationRounds: 1,
        matIfPlat: '',
        hasQualification: '1',
        vendorName: '',
        quotationRoundsNum: 1,
        isTax: '',
        templateDetails: [],
        procureType: '1',
        affiliatedUserName:'',
        contactsPhone:'',
        tenderDocumentList: [],
        quotationTemplate: '',
        payRatio1:'',
        payRatio:'',
        payRatio2:'',
        payRatio3:'',
        approvalInviteVendorList: [],
        quotationTemplateName: '',
        releaseMethod: '1',
        evaluationMethod: '1',
        fundType: 4,
        fundScale: 0,
        technicalWeight: 0,
        businessWeight: 0,
        projectLedgerCode: '',
        acceptanceTime: '',
        noticeType: 2,
        biddingStartTime: '',
        biddingEndTime: '',
        raisingQuestionsDeadlineTime: '',
        clarificationSupplementDeadlineTime: '',
        quotationMethod: '',
        evaTemplate: {
          descriptionList: [],
        },
        hasBond: '0',
        bond: 0,
        releaseStatus: 0,
        responseTimeDeadline: '',
        evaluationMode: 1,
        biddingStartTime: '',
        biddingEndTime: '',
        quotationTemplateDetailApprovalList: [],
        zbDocument: {
          type: '',
          accessoryList: [],
        },
      },
      projectList: [],
      scoreData: [],
    }
  },
  created() {
    this.addModifyBtn()
    this.selectTree()
    this.getQualifications()
    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.affiliatedUserName = this.currentUser.user.fullname
    this.parameter.contactsPhone = this.currentUser.user.mobile
    this.parameter.affiliatedOrgCode = this.currentUser.org[0].orgCode
    this.parameter.affiliatedOrgId = this.currentUser.org[0].orgId
    this.parameter.affiliatedOrgName = this.currentUser.org[0].orgName
    let moment = require('moment')
    this.parameter.biddingStartTime = moment()
      .add(2, 'hours')
      .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 = moment()
      .add(2, 'hours')
      .format('YYYY-MM-DD HH:mm:ss')
  },
  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() {},
  methods: {
    //查询评标分类树结构
    selectTree() {
      basicData.bizEvaluationItemSelectTree().then((res) => {
        this.scoreData = res.value[0].children
        this.scoreData.forEach((item) => {
          item.evaluationItemPname = item.subjectName
          item.evaluationScore = 0
        })
      })
    },
    // 获取资质标签内容
    getQualifications() {
      let params = {
        querys: [],
        pageBean: {
          pageSize: -1,
          page: -1,
        },
      }
      this.$http
        .post('${portal}/bizQualificationLabel/v1/page', params)
        .then((res) => {
          if (res.data.state) {
            this.qualificationsList = res.data.value.rows
          }
        })
    },
    changeQualifications(val) {
      console.log(val, 'val')
      this.parameter.qualificationsCoutent = val.join(',')
    },
    // 切换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
      }
    },
    handleProgress() {
      this.loading = true
    },
    onError(err, file, fileList) {
      this.loading = false
    },
    //下载按钮回调
    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)
        }
      })
    },
    // 综合评标法添加子级
    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
            }
          }
        })
      })
    },
    changeProjectType(val) {
      if (val == 1) {
        this.activeProject = 'first'
      }
      if (val == 2) {
        this.activeProject = 'third'
      }
    },
    //采购单位
    purchasingUnitsBtn() {
      this.$refs.troubleshooting.add()
    },
    openExpert() {
      this.$refs.expert.add()
    },
    // 选择供应商
    openVendor() {
      this.$refs.poolUnits.add()
    },
    // 获取供应商数据
    getSupplierList(list) {
      list.forEach((item) => {
        this.parameter.approvalInviteVendorList.push({
          vendorCode: item.code,
          vendorName: item.name,
        })
      })

      this.supplierList = list
      this.parameter.vendorName = list
        .map((item) => {
          return item.name
        })
        .join(',')
    },
    // 选择评标模板
    handleTemplate() {
      this.$refs.template.add()
    },
    // 获取评标模板数据
    openTemplate(data) {
      this.parameter.quotationTemplateDetailApprovalList = data
      this.parameter.quotationTemplate = data[0].id
      this.parameter.quotationTemplateName = data[0].name
      this.parameter.templateDetails.forEach((item) => {
        delete item.id
      })
      this.$nextTick(() => {
        this.$refs.formInfo1.clearValidate('quotationTemplateName')
      })
      this.$forceUpdate()
    },
    addTableList() {
      this.$refs.troubleshooting.add(this.parameter)
    },
    addDetail(list) {
      console.log(list)
      this.methodUnitsList = list
      this.parameter.detailsList = list
      this.parameter.detailsList.forEach((item) => {
        item.plannedPrice = item.amount
        item.matId = item.id
      })
    },
    // 公告文件上传
    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)
    },
    // 打开资送货地址
    openAddress(index) {
      this.index = index
      this.$refs.address.open()
    },
    handleAdd(list) {
      console.log(list, 'list')
      if (this.parameter.projectEvaluationExpertList == undefined) {
        this.parameter.projectEvaluationExpertList = []
      }
      if (this.parameter.expertList == undefined) {
        this.parameter.expertList = ''
      }
      this.parameter.projectEvaluationExpertList = list
      this.parameter.projectEvaluationExpertList.forEach((item) => {
        item['expertId'] = item.id
        delete item.id
      })
      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()
    },
    openProject() {
      this.parameter.detailsList = []
      this.$refs.project.add(this.parameter)
    },
    //列表删除行
    addTable() {
      this.parameter.detailsList.push({})
    },
    //列表删除行
    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 = '新增'
      }
    },
    changeTab(val) {
      this.activeName = val
    },
    changeMethod(val) {
      if (val == 2) {
        this.parameter.acceptanceTime = 6
      } else {
        this.parameter.acceptanceTime = ''
      }
    },
    // 获取项目数据
    getProject(data) {
      console.log(data)
      this.projectList = data
      this.parameter.projectLedgerId = data[0].id
      this.parameter.projectLedgerName = data[0].projectName
      this.parameter.projectLedgerCode = data[0].projectCode
      this.parameter.projectUserName = data[0].projectUserName
      this.parameter.constructionStartTime = data[0].constructionStartTime
      this.parameter.constructionCompletionTime =
        data[0].constructionCompletionTime
      this.parameter.investment = data[0].investment
      this.parameter.projectUserMobile = data[0].projectUserMobile
      this.parameter.applicationType = data[0].projectType
      this.$nextTick(() => {
        this.$refs.formInfo1.clearValidate('projectLedgerName')
      })
    },
    getEmit(data) {
      console.log(data)
      if (data[0].sort == 1) {
        this.parameter.detailsList.forEach((item, index) => {
          if (this.index == index) {
            item.unloadAddress = data[0].enterpriseContactAddress
            return
          }
        })
      }
      if (data[0].sort == 2) {
        this.parameter.detailsList.forEach((item) => {
          item.unloadAddress = data[0].enterpriseContactAddress
        })
      }
      this.$forceUpdate()
    },
    //获取修改回显数据
    modifychoData(val) {
      procurementManagement.projectApprovalProDetails(val.id).then((res) => {
        this.parameter = res.value
        if (this.parameter.zbDocument != undefined) {
          delete this.parameter.zbDocument.id
          this.dataList = this.parameter.zbDocument.accessoryList
        }
        if (this.parameter.zbDocument == undefined) {
          this.parameter.zbDocument = {
            type: 1,
            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
      })
    },
    // 关闭//面包屑点击
    handleClose() {
      if (this.breadcrumbOpt[1].breadcrumbName === '编辑') {
        this.$router.push({
          name: 'projectProcurementApproval',
          params: {
            pageBean: this.$route.query.pageBean,
          },
        })
      } else {
        this.$router.push({
          name: 'projectProcurementApproval',
        })
      }
      this.parameter = {}
    },
    next2() {
      this.activeName = 4
    },
    next() {
      this.activeName = 2
    },
    next1() {
      this.activeName = 3
    },
    up() {
      this.activeName = 1
    },
    up1() {
      this.activeName = 2
    },
    up2() {
      if (this.activeName == 4) {
        this.activeName = 3
      }
    },
  },
}
</script>

<style lang="scss" scoped>
/deep/.el-step.is-simple:not(:last-of-type) .el-step__title {
  cursor: pointer;
}
/deep/.el-step.is-simple .el-step__title {
  cursor: pointer;
}
.div-content {
  height: calc(100% - 70px);
  overflow-y: auto;
  overflow-x: hidden;
}
.form-content {
  overflow: hidden;
}
/deep/.el-tabs {
  height: 100%;
}
/deep/.el-tabs__content {
  height: calc(100% - 50px);
  overflow-y: auto;
}
.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 18px;
  padding: 10px 0;
  .rows-left {
    margin-right: 10px;
    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e8eff;
      border-radius: 2px;
    }
  }
  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 18px;
    }
  }
}
/deep/.el-tabs__item {
  font-size: 18px;
}
/deep/.el-tabs__header {
  padding: 0;
}
/deep/.el-row {
  display: flex;
  flex-wrap: wrap;
}
/deep/.el-table-lable-box .cell {
  display: flex;
  justify-content: center;
}
</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>
