
<!--
  @description: 评标大厅-综合评估法经济评审页面
  @Modifier：wxy/yf
  @routerPath: /procurement/evaluationLobbyDrive/priceReview
  @date：  2020-08-5 14:12:28
-->
<template>
  <div class="main">
    <div>
      <!-- 表格组件 -->
      <priceReviewTable ref="priceReviewTable" :get-tender-base="getTenderBase" />
      <!-- 底部按钮 isEdit 布尔值根据驱动节点状态判断 （00未开启 02已完成）return false 01正在进行  true isEvalLeader当前评委是否是组长 00 否 01是 isCommerceLeader是否商务组长 00否 01是 -->
      <div v-if="getTenderBase.isEdit && getTenderBase.isEvalLeader==='01' && getTenderBase.isCommerceLeader === '01'" class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <el-button :loading="confirmLoding" type="primary" size="medium" @click="submit">
              提交评审结果
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api接口*/
import {
  savePriceReview,
  dealPriceReviewDriver
} from '@api/procurement/procurementEvaluation'
// import driveStepRight from '../procurementEvaluationLobbyDrive/components/procurementDriveStepRight'
import priceReviewTable from './procurementPriceReviewTableComp' // 表格组件
export default {
  name: 'PriceReview',
  inject: ['getTenderBase', 'getDriveTask', 'driveReload'],
  components: {
    priceReviewTable: priceReviewTable // 表格组件
    // 'drive-step-right': driveStepRight
  },
  mixins: [],
  data() {
    return {
      confirmLoding: false,
      getTenderBase: this.getTenderBase() // getTenderBase参数
    }
  },
  watch: {
  },
  mounted() {
    // 当前登录人非组长 isEvalLeader是否为组长 00否01是
    if (this.getTenderBase.isEvalLeader === '00') {
      this.nonLeader()
    }
  },
  methods: {
    // 提交评审结果
    submit() {
      this.$confirm(`提交之后将不可修改，确认提交评审结果吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.confirmLoding = true
        if (this.$refs.priceReviewTable.scoreChecks()) {
          const data = this.$refs.priceReviewTable.assemblyData()
          savePriceReview(data).then(res => {
            this.getTenderBase.isEdit = false
            this.confirmLoding = false
            // 刷新驱动
            this.driveReload()
            this.getDriveTask()
          }).catch(() => {
            this.confirmLoding = false
          })
        } else {
          this.confirmLoding = false
        }
      }).catch(() => {
        this.confirmLoding = false
      })
    },
    // 非组长更新驱动
    nonLeader() {
      const data = {
        evalExpertId: this.getTenderBase.evalExpertId, // 专家评审表ID
        driverId: this.getTenderBase.driverId, // 驱动id
        packId: this.getTenderBase.packId, // 标段id
        evalRule: this.getTenderBase.evalRule // 评审规则 【00–整体步骤 01-单个评委步骤】
      }
      dealPriceReviewDriver(data).then(res => {
        // 刷新驱动
        // this.driveReload()
        // this.getDriveTask()
      })
    }
  }
}
</script>

<style lang="less" scoped>
  @import '~@assets/style/common/public.less';
.driveStep{
  background: #ffffff;
  height: 40px;
  line-height: 40px;
  border-bottom: 1px solid #E4E7ED;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.imgBg{
  width: 16px;
  height: 16px;
  margin: 0 2px;
  color: @hyacinthine;
}
.content-right_scrollbar .el-scrollbar{
  height: calc(100vh - 70px) !important;
}
</style>
