<!--
  @description:集约化评标—填写分组名称-分组情况-编辑/查看
  @Modifier: 肖文龙
  @routerPath:intensiveeval/fillInGroupName-add
              intensiveeval/fillInGroupName-detail
  @date: 2020-3-14-19:04
-->
<template>
  <div>
    <div class="p0-16 mb10">
      <section class="title clearfix">
        <div class="title-back pointer" @click="back">
          <i class="iconfont icon-fanhui mr10" />{{
            isEdit?'填写分组名称':'查看分组名称' }}
        </div>
      </section>
      <el-form ref="formData" :inline-message="true" :model="formData" :rules="rules">
        <table class="tableData">
          <tr>
            <td>招标项目名称</td>
            <td>{{ formData.tenderName }}</td>
            <td>标段（包）编号</td>
            <td>{{ formData.packNo }}</td>
          </tr>
          <tr>
            <td>采购单位</td>
            <td>{{ formData.purchaseDepartment }}</td>
            <td>项目单位</td>
            <td>{{ formData.projectDepart }}</td>
          </tr>
          <tr>
            <td>评标委员会组建方式</td>
            <td>
              {{ filterDictText(juryOrganizeWayList, formData.juryBuildType) }}
            </td>
            <td>采购级别</td>
            <td>
              {{ filterDictText(purchaseLevelList, formData.purchaseLevel) }}
            </td>
          </tr>
          <tr>
            <td>招标项目类型</td>
            <td>
              {{ filterDictText(projectClassificationList, formData.projectClassification) }}
            </td>
            <td>概算（元）</td>
            <td>{{ formData.budgetEstimate }}</td>
          </tr>
          <tr>
            <td>超过法定限额</td>
            <td>
              {{ filterDictText(exceedingLegalLimitList, formData.beyondLegalLimit) }}
            </td>
            <td>入库专业</td>
            <td>{{ formData.libraryProfessional }}</td>
          </tr>
          <tr>
            <td>所属部门</td>
            <td>{{ formData.department }}</td>
            <td>
              项目经理
            </td>
            <td>{{ formData.tenderManager }}</td>
          </tr>
          <tr>
            <td>评标办法</td>
            <td>
              {{ filterDictText(evaluationTypeList, formData.reviewWay) }}
            </td>
            <td>开标日期</td>
            <td>
              {{ formData.openBidStartTime && $Moment(formData.openBidStartTime).format(momentDateTime) }}
            </td>
          </tr>
          <tr>
            <td>项目行业</td>
            <td>
              {{ filterDictText(projectIndustryList, formData.industryName) }}
            </td>
            <td>资格预审项目</td>
            <td>
              {{ filterDictText(prequalificationProgramList, formData.isQualificationProject) }}
            </td>
          </tr>
          <tr>
            <td>分组情况</td>
            <td>
              {{ filterDictText(judgingPanelTypeList, formData.judgesGroupedStatus) }}
            </td>
            <!--分组时-->
            <template v-if="formData.judgesGroupedStatus==='01'">
              <td>
                <span v-if="isEdit" class="red-star">*</span>
                商务组人数
              </td>
              <td>
                <el-form-item v-if="isEdit" ref="businessExpertsSelectedNumber" prop="businessExpertsSelectedNumber">
                  <el-input
                    v-model="formData.businessExpertsSelectedNumber"
                    type="text"
                    show-word-limit
                    style="width:200px"
                    maxlength="20"
                    placeholder="商务组人数"
                  />
                </el-form-item>
                <span v-else>{{ formData.businessExpertsSelectedNumber }}</span>
              </td>
            </template>
            <!--不分组时-->
            <template v-if="formData.judgesGroupedStatus==='00'">
              <td>
                <span v-if="isEdit" class="red-star">*</span>
                商务技术组人数
              </td>
              <td>
                <el-form-item v-if="isEdit" ref="expertsSelectedNumber" prop="expertsSelectedNumber">
                  <el-input
                    v-model="formData.expertsSelectedNumber"
                    type="number"
                    show-word-limit
                    maxlength="20"
                    style="width:200px"
                    placeholder="商务组人数"
                  />
                </el-form-item>
                <span v-else>{{ formData.expertsSelectedNumber }}</span>
              </td>
            </template>
          </tr>
          <tr>
            <!--分组时-->
            <template v-if="formData.judgesGroupedStatus==='01'">
              <td>
                <span v-if="isEdit" class="red-star">*</span>
                技术组人数
              </td>
              <td>
                <el-form-item v-if="isEdit" ref="technicalExpertsSelectedNumber" prop="technicalExpertsSelectedNumber">
                  <el-input
                    v-model="formData.technicalExpertsSelectedNumber"
                    type="number"
                    show-word-limit
                    maxlength="20"
                    style="width:200px"
                    placeholder="技术组人数"
                  />
                </el-form-item>
                <span v-else>{{ formData.technicalExpertsSelectedNumber }}</span>
              </td>
            </template>
            <td>
              <span v-if="isEdit" class="red-star">*</span>
              分组名称
            </td>
            <td>
              <el-form-item v-if="isEdit" ref="groupName" prop="groupName">
                <el-input
                  v-model="formData.groupName"
                  show-word-limit
                  maxlength="600"
                  style="width:200px"
                  placeholder="请选择"
                />
              </el-form-item>
              <span v-else>{{ formData.groupName }}</span>
            </td>
          </tr>
        </table>
      </el-form>
    </div>
    <!--可编辑状态时-->
    <div v-if="isEdit">
      <!--保存按钮-->
      <div class="but_footer">
        <div class="but_footer-h" />
        <div class="but_footer-but">
          <el-button type="primary" @click="submit()">
            确定
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
/* api*/
import { queryIntensiveevalPlanById, addGroupNameByPlan } from
  '@/api/intensiveeval/intensiveeval'
  /* 公共方法*/
import { checkRate, validateInput } from '@/assets/js/validate'// 校验
/* 混合开发*/
import { groupMixin } from '@/views/intensiveeval/mixins/intensiveevalGroupMixin'// 字典信息
export default {
  name: 'FillInGroupNameEditView',
  mixins: [groupMixin],
  props: {
  },
  data() {
    return {
      isEdit: false, // 是否可编辑 布尔值
      /* 参数*/
      formData: {
        purchaseDepartment: '', // 采购单位
        beyondLegalLimit: '', // 超过法定限额(00否 01是)
        budgetEstimate: '', // 概算
        department: '', // 所属部门
        groupName: '', // 集约化评标分组名称
        groupedStatus: '', // 分组状态(00未分组 01评标分组待编辑 02评标分组已保存 03评标分组待审批 04评标分组审批通过 05评标分组审批驳回 06已指定牵头人 07已创建评委会申请 08已抽取完成)
        id: '', // 主键id
        industryName: '', // 项目行业
        isQualificationProject: '', // 资格预审项目
        judgesGroupedStatus: '', // 评委会是否分组(00不分组 01分组)
        juryBuildType: '', // 评标委员会组建方式
        libraryProfessional: '', // 入库专业
        openBidPlanStatus: '', // 开评标计划状态（00减少 01正常 02增加）
        openBidStartTime: '', // 开标日期
        packId: '', // 标段(包)id
        packNo: '', // 标段（包）编号
        planId: '', // 计划id
        projectClassification: '', // 招标项目类型
        projectDepart: '', // 项目单位
        purchaseLevel: '', // 采购级别（01一级采购 02二级采购 03三级采购）
        reviewWay: '', // 评标方式 00: 有效最低价 01:综合评估法
        technicalExpertsSelectedNumber: 0, // 技术组人数
        businessExpertsSelectedNumber: 0, // 商务组人数
        expertsSelectedNumber: 0, // 商务技术组人数
        tenderManager: '', // 项目经理
        tenderName: '' // 招标项目名称
      },
      // 校验
      rules: {
        businessExpertsSelectedNumber: [{ required: true, validator: checkRate, trigger: 'blur' }], // 商务组人数
        expertsSelectedNumber: [{ required: true, validator: checkRate, trigger: 'blur' }], // 商务技术组人数
        technicalExpertsSelectedNumber: [{ required: true, validator: checkRate, trigger: 'blur' }], // 技术组人数
        groupName: [{ required: true, validator: validateInput, trigger: 'blur' }] // 分组名称
      }
    }
  },
  created() {
    // 是否可编辑 布尔值
    this.isEdit = this.$route.meta.isEdit
    this.initWebTypeGroup()// 集约化评标计划-集约化评标明细(立项-字典信息)
    this.getQueryAllDepartPage()// 查询集约化评标所有的部门
    this.loadData()// 初始化数据-回显
  },
  methods: {
    // 初始化数据-回显
    loadData() {
      const planId = this.$route.query.planId// 评标计划Id
      queryIntensiveevalPlanById(planId).then(res => {
        this.formData = res.data
      })
    },
    // 返回按钮
    back() {
      this.$router.push({ path: '/intensiveeval/intensiveevalPlanContent/intensiveevalDetail-list' })
    },
    // 确定
    submit() {
      this.$refs.formData.validate((valid, field) => {
        if (valid) {
          const data = {
            planId: this.formData.planId, // 集约化评标计划id
            businessExpertsSelectedNumber: Number(this.formData.businessExpertsSelectedNumber), // 集约化评标计划id
            technicalExpertsSelectedNumber: Number(this.formData.technicalExpertsSelectedNumber), // 集约化评标计划id
            expertsSelectedNumber: Number(this.formData.expertsSelectedNumber), // 商务技术组人数
            groupName: this.formData.groupName// 分组名称
          }
          this.$confirm('确定提交?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            confirmButtonClass: 'confirmBtn',
            cancelButtonClass: 'cancelBtn',
            type: 'warning'
          }).then(() => {
            addGroupNameByPlan(data).then(res => {
              this.$message({
                message: '提交成功',
                type: 'success'
              })
              this.$router.push({ path: '/intensiveeval/intensiveevalPlanContent/intensiveevalDetail-list' })
            })
          }).catch(() => {
          })
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
  /deep/.tableData{
    .el-form-item{
      margin: 0;
    }
  }

</style>
