<!--
  @description: 新增招标计划--评标办法信息
  @author: sunxinman/haofengxian
  @routerPath: /tenderPlan/tenderPlanAdd/methodInfo
  @date: 2019-12-23 22:35:58
  说明：
  1.招标计划流程信息资格审查方式选择年度资格预审，则在评标办法tab页只显示资格预审评审办法信息，无评标办法信息。因为年度资格预审项目不走后审流程
  2.若资格审查办法为资格后审，本页面只有评标办法信息 则隐藏资格预审评审办法信息
-->
<template>
  <div>
    <el-form ref="form" :model="prequalificationInfo">
      <!--===================资格预审评审办法信息====================================-->
      <!--若资格审查办法为资格后审，本页面只有评标办法信息 则隐藏资格预审评审办法信息-->
      <section v-if="isShowZSPage">
        <div class="page-title">
          <span v-if="isShowPage">1. </span>资格预审评审办法信息
        </div>
        <table class="from_table">
          <tr>
            <td>
              <el-form-item label="资格预审审查办法" />
            </td>
            <td>
              {{ prequalificationInfo.prequalificationEvaluationMethod==='00'?'合格制':'有限数量制' }}
            </td>
            <td />
            <td />
          </tr>
          <tr>
            <td><el-form-item label="商务、技术得分高于" /></td>
            <td>
              <el-input v-model="prequalificationInfo.businessTechScoreHigher" />
            </td>
            <template v-if="prequalificationInfo.prequalificationEvaluationMethod==='01'">
              <td><el-form-item label="数量" prop="biddingAmount" /></td>
              <td><el-input v-model="prequalificationInfo.biddingAmount" disabled /></td>
            </template>
            <template v-if="prequalificationInfo.prequalificationEvaluationMethod==='00'">
              <td />
              <td />
            </template>
          </tr>
          <tr>
            <td><el-form-item label="商务权重" /></td>
            <td><el-input v-model="prequalificationInfo.businessWeight" /></td>
            <td><el-form-item label="技术权重" /></td>
            <td><el-input v-model="prequalificationInfo.techWeight" /></td>
          </tr>
          <tr>
            <td><el-form-item label="资质要求" /></td>
            <td><el-input v-model="prequalificationInfo.qualificationRequirement" /></td>
            <td><el-form-item label="同类业绩要求" /></td>
            <td><el-input v-model="prequalificationInfo.similarAchievementRequirement" /></td>
          </tr>
          <tr>
            <td><el-form-item label="是否委托预审委员会决议" /></td>
            <td>
              <el-radio-group v-model="prequalificationInfo.ifEntrustCommitteeDecision">
                <el-radio label="00">
                  是
                </el-radio>
                <el-radio label="01">
                  否
                </el-radio>
              </el-radio-group>
            </td>
            <td><el-form-item label="其他" /></td>
            <td><el-input v-model="prequalificationInfo.otherInfo" /></td>
          </tr>
        </table>
      </section>
      <!--=========================评标办法信息==========================================-->
      <!--若资格审查办法选择年度资格预审，则在评标办法tab页只显示资格预审评审办法信息，无评标办法信息-->
      <section v-if="isShowPage">
        <div class="page-title">
          <span v-if="isShowZSPage">2. </span>评标办法信息
        </div>
        <!--2.1.综合评估法 评标办法部分根据第一步招标计划信息-流程控制中“评标办法”字段区分综合评估法和经评审的最低投标价法两种展现页面-->
        <table v-if="!bidEvaluationMethodShow" class="from_table">
          <tr>
            <td><el-form-item label="评标办法" /></td>
            <td colspan="3">
              <el-radio-group v-model="bidEvaluationInfo.biddingEvaluation">
                <el-radio label="00">
                  综合评估法
                </el-radio>
                <el-radio label="01">
                  最低评标价法
                </el-radio>
                <el-radio label="02">
                  全寿命周期成本计算法
                </el-radio>
              </el-radio-group>
            </td>
          </tr>
          <!--评标办法为 选择综合评估法显示-->
          <template v-if="bidEvaluationInfo.biddingEvaluation==='00'">
            <tr>
              <td>
                <el-form-item label="价格权重" />
              </td>
              <td>
                <el-input v-model="bidEvaluationInfo.priceWeight" />
              </td>
              <td><el-form-item label="商务权重" /></td>
              <td>
                <el-input v-model="bidEvaluationInfo.businessWeight" />
              </td>
            </tr>
            <tr>
              <td>
                <el-form-item label="技术权重" />
              </td>
              <td>
                <el-input v-model="bidEvaluationInfo.techWeight" />
              </td>
              <td><el-form-item label="推荐原则" /></td>
              <td>
                <el-input v-model="bidEvaluationInfo.recommendPrinciple" />
              </td>
            </tr>
            <tr>
              <td>
                <el-form-item label="其他" />
              </td>
              <td>
                <el-input v-model="bidEvaluationInfo.othersInfo" />
              </td>
              <td />
              <td />
            </tr>
          </template>
          <!--评标办法为 选择最低评标价法、全寿命周期成本计算法显示-->
          <tr v-if="bidEvaluationInfo.biddingEvaluation!=='00'">
            <td><el-form-item label="推荐原则" /></td>
            <td>
              <el-input v-model="bidEvaluationInfo.recommendPrinciple" />
            </td>
            <td>
              <el-form-item label="其他" />
            </td>
            <td>
              <el-input v-model="bidEvaluationInfo.othersInfo" />
            </td>
          </tr>
        </table>
        <!--2.2.经评审的最低投标价法-->
        <table v-if="bidEvaluationMethodShow" class="from_table">
          <tr>
            <td><el-form-item label="评标办法" /></td>
            <td colspan="3">
              <el-radio-group v-model="bidEvaluationInfo.biddingEvaluation">
                <el-radio label="03">
                  经评审的最低投标价法
                </el-radio>
                <el-radio label="04">
                  经评审的合理低价法
                </el-radio>
              </el-radio-group>
            </td>
          </tr>
          <tr>
            <!--选择经评审的最低投标价法 显示-->
            <template v-if="bidEvaluationInfo.biddingEvaluation==='03'">
              <td>
                <el-form-item label="经评审的最低投标价法文本" />
              </td>
              <td>
                <el-input v-model="bidEvaluationInfo.lowestEvaluatedBiddingPriceText" />
              </td>
            </template>
            <!--选择经评审的合理低价法文本 显示-->
            <template v-if="bidEvaluationInfo.biddingEvaluation==='04'">
              <td>
                <el-form-item label="经评审的合理低价法文本" />
              </td>
              <td>
                <el-input v-model="bidEvaluationInfo.reasonableEvaluatedBiddingPriceText" />
              </td>
            </template>
            <td>
              <el-form-item label="商务、技术得分均不低于" />
            </td>
            <td>
              <el-input v-model="bidEvaluationInfo.businessTechScoreNotLower" />
            </td>
          </tr>
          <tr>
            <td><el-form-item label="推荐原则" /></td>
            <td>
              <el-input v-model="bidEvaluationInfo.recommendPrinciple" />
            </td>
            <td>
              <el-form-item label="其他" />
            </td>
            <td colspan="3">
              <el-input v-model="bidEvaluationInfo.othersInfo" />
            </td>
          </tr>
        </table>
      </section>
      <!-- 保存按钮 -->
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <el-button @click="prevForm">
              上一步
            </el-button>
            <el-button :loading="confirmLoading" @click="submitForm('form', '01')">
              保存
            </el-button>
            <el-button :loading="confirmLoading" type="primary" @click="submitForm('form', '00')">
              下一步
            </el-button>
          </div>
        </div>
      </div>
    </el-form>
  </div>
</template>
<script>
/* api*/
import { savePretenderingPurchasesEvaluation, getPretenderingPurchasesEvaluationBySchemeId } from '@/api/purchasePlan/pretcloudPurchasescheme'
export default {
  name: 'MethodInfo',
  props: {
    // 接收步骤条父页面信息
    tenderPlanData: {
      type: Object,
      default: function() {
        return {
          id: ''
        }
      }
    }
  },
  data() {
    return {
      confirmLoading: false, // 暂存Loding
      isShowZSPage: true, // 根据资格审查方式 qualificationCheckWay控制评审办法是否显示资审模块
      isShowPage: true, // 根据资格审查方式 qualificationCheckWay控制评审办法是否显示后审模块
      bidEvaluationMethodShow: false, // 控制评标办法信息模块显示隐藏
      // 资格预审办法信息
      prequalificationInfo: {
        biddingAmount: '', // 数量
        businessTechScoreHigher: '', // 商务、技术得分高于
        businessWeight: '', // 商务权重
        id: '', // 主键id
        ifEntrustCommitteeDecision: '01', // 是否委托预审委员会决议,00是，01否
        schemeId: '',
        otherInfo: '', // 其他
        prequalificationEvaluationMethod: '', // 资格预审评审办法,00合格制,01有限数量制
        prequalificationMethodT: '', // 资格预审审查办法
        qualificationRequirement: '', // 资质要求
        similarAchievementRequirement: '', // 同类业绩要求
        techWeight: '' // 技术权重
      },
      // 评标办法信息
      bidEvaluationInfo: {
        biddingEvaluation: '00', // 评标办法评标办法，00综合评估法，01最低评标价法，02全寿命周期成本计算法，03经评审的最低投标价法，04经评审的合理低价法
        lowestEvaluatedBiddingPriceText: '', // 经评审的最低投标价法文本
        reasonableEvaluatedBiddingPriceText: '', // 经评审的合理低价法文本
        businessTechScoreNotLower: '', // 商务、技术得分均不低于
        techWeight: '', // 技术权重
        businessWeight: '', // 商务权重
        priceWeight: '', // 价格权重
        othersInfo: '', // 其他
        recommendPrinciple: '', // 推荐原则
        schemeId: '',
        createUser: this.$store.getters.info.userName,
        updateUser: this.$store.getters.info.userName,
        useStatus: '00'
      }
    }
  },
  created() {
    const process = JSON.parse(sessionStorage.getItem('process')) // 取出招标计划信息
    this.handlePageShow(process)
    this.getPretenderingPurchasesEvaluation(process)
  },
  methods: {
    //  根据id获取评标办法信息
    getPretenderingPurchasesEvaluation(process) {
      getPretenderingPurchasesEvaluationBySchemeId(this.tenderPlanData.id).then(res => {
        const {
          pretPurchaseschemePretenderingPurchasesPrequalificationVo, // 资格预审办法信息实体Dto
          pretPurchaseschemePretenderingPurchasesEvaluationVo // 评标办法信息实体Dto
        } = res.data
        this.prequalificationInfo = pretPurchaseschemePretenderingPurchasesPrequalificationVo || this.prequalificationInfo
        this.bidEvaluationInfo = pretPurchaseschemePretenderingPurchasesEvaluationVo || this.bidEvaluationInfo
        // 带出资格预审评审办法,00合格制,01有限数量制
        this.prequalificationInfo.prequalificationEvaluationMethod = process.prequalificationEvaluationMethod
        this.prequalificationInfo.biddingAmount = process.quantitativeRestriction // 从流程信息带出数量
      })
    },
    // 处理页面显示隐藏
    handlePageShow(process) {
      if (process) {
        /* 资格审查方式 qualificationCheckWay  00:单次资格预审 01:年度资格预审 02:资格后审
          若资格审查办法为资格后审，本页面只有评标办法信息，一个模块 隐藏资格预审评审办法信息模块
        * */
        if (process && process.qualificationCheckWay === '02') {
          this.isShowZSPage = false
          this.isShowPage = true
        }
        /*
          若资格审查办法为年度资格预审，本页面只显示资格预审评审办法信息，无评标办法信息
        * */
        if (process && process.qualificationCheckWay === '01') {
          this.isShowZSPage = true
          this.isShowPage = false
        }
        /* 评标办法部分根据第一步招标计划信息-流程控制中“评标办法”字段区分综合评估法和经评审的最低投标价法两种展现页面
        *  评标办法 00:综合评价法 01:经评审的最低投标价法
        * */
        if (process.bidEvaluationMethod === '01') {
          this.bidEvaluationInfo.biddingEvaluation = '03' // 03经评审的最低投标价法
          this.bidEvaluationMethodShow = true // 显示经评审的最低投标价法 则隐藏 综合评估法
        }
      }
    },
    // 上一步
    prevForm() {
      this.$emit('stepPage', 'prev')
    },
    // 暂存，进入下一步
    submitForm(form, type) {
      this.bidEvaluationInfo.schemeId = this.tenderPlanData.id
      this.prequalificationInfo.schemeId = this.tenderPlanData.id
      const obj = {
        pretPurchaseschemePretenderingPurchasesPrequalificationDto: this.prequalificationInfo, // 资格预审办法信息实体Dto
        pretPurchaseschemePretenderingPurchasesEvaluationDto: this.bidEvaluationInfo // 评标办法信息实体Dto
      }
      this.confirmLoading = true// btnLoding
      savePretenderingPurchasesEvaluation(obj).then(() => {
        if (type === '00') {
          this.$emit('stepPage', 'next')
        } else {
          this.$message({
            type: 'success',
            message: '保存成功'
          })
        }
        this.confirmLoading = false// btnLoding
      }).catch(() => {
        this.confirmLoading = false// btnLoding
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>
