<!--
  @description: 开评标计划
  @author:肖文龙
  @date: 2020年3月11日15:15:13
-->
<template>
  <div>
    <el-table
      ref="smallTable"
      v-loading="loading"
      :data="tableData"
    >
      <el-table-column
        type="index"
        label="序号"
        width="45px"
        align="center"
      />
      <el-table-column
        header-align="center"
        prop="tenderName"
        label="招标项目名称"
        min-width="300"
      />
      <el-table-column
        header-align="center"
        prop="packNo"
        label="标段（包）编号"
        min-width="200"
      />
      <el-table-column
        prop="judgesGroupedStatus"
        align="center"
        label="分组情况"
        min-width="200"
      >
        <template slot-scope="scope">
          <span
            v-for="(item,index) in judgingPanelTypeList"
            v-if="scope.row.judgesGroupedStatus===item.typecode"
            :key="index"
          >{{ item
            .typename }}</span>
        </template>
      </el-table-column>
      <!--
        商务技术组人数
        分组信息为不分组时
      -->
      <el-table-column
        v-if="judgesGroupedStatus==='00'"
        prop="expertsSelectedNumber"
        header-align="center"
        align="right"
        label="商务技术组人数"
        min-width="100"
      />
      <!--
        商务组人数
        分组信息为分组时
      -->
      <el-table-column
        v-if="judgesGroupedStatus==='01'"
        prop="businessExpertsSelectedNumber"
        header-align="center"
        align="right"
        label="商务组人数"
        min-width="100"
      />
      <!--
        技术组人数
        分组信息为分组时
      -->
      <el-table-column
        v-if="judgesGroupedStatus==='01'"
        prop="technicalExpertsSelectedNumber"
        header-align="center"
        align="right"
        label="技术组人数"
        min-width="100"
      />
      <el-table-column
        header-align="center"
        label="操作"
        align="center"
        width="120"
      >
        <template slot-scope="scope">
          <el-link
            type="primary"
            @click="see(scope.row)"
          >
            [查看]
          </el-link>
          <el-link
            v-if="isEdit&&functionType==='00'"
            type="primary"
            @click="deleteRow(scope.row)"
          >
            [删除]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination :pagination-data="paginationData" />
    <bidEvaluationPlanDetailDialog :dialog-data="dialogData" @change="loadData" />
  </div>
</template>

<script>
/* api*/
import { queryPlanListByBatchNumberPages, deletePlanInfoById } from '@/api/intensiveeval/intensiveeval'
/* 混合开发*/
import { groupMixin } from '@/views/intensiveeval/mixins/intensiveevalGroupMixin'// 字典信息
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import bidEvaluationPlanDetailDialog from './bidEvaluationPlanDetail-dialog'// 查看详情
export default {
  name: 'BidEvaluationPlanDetail',
  components: {
    pagination,
    bidEvaluationPlanDetailDialog
  },
  mixins: [groupMixin, ListMixin],
  data() {
    return {
      flowStatus: this.$route.query.flowStatus, // true 工作流进入
      loading: false, // 刷新loading
      isEdit: this.$route.meta.isEdit, // 是否可以编辑 布尔值
      functionType: this.$route.meta.functionType, // 当前页面所处功能 00 计划管理员-集约化评标分组-编辑分组 01 部门主任设置牵头人
      judgesGroupedStatus: '', // 评标委员会是否分组 01 分组 00 不分组
      /* 查看详情弹框-是否打开*/
      dialogData: {
        dialog: false,
        planId: ''// 评标计划Id
      },
      searchForm: {
        groupId: '', // 分组Id
        batchNumber: this.$route.query.batchNumber, // 批次号
        pageNo: 1,
        pageSize: 10
      },
      // 评标委员会列表
      tableData: [{ tenderNo: '1' }]
    }
  },
  created() {
    this.loadData()// 获取数据
  },
  methods: {
    // 获取数据
    loadData() {
      this.loading = true
      const params = this.getQueryParams()// 查询条件
      queryPlanListByBatchNumberPages(params).then(response => {
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        this.tableData.map(item => {
          this.judgesGroupedStatus = item.judgesGroupedStatus// 评标委员会是否分组
        })
        this.loading = false
      }).catch(() => {

      })
    },
    // 查看
    see(row) {
      this.dialogData.dialog = true
      this.dialogData.planId = row.planId// 评标计划Id
    },
    // 删除
    deleteRow(row) {
      this.$confirm('删除本条记录后，请前往“集约化评标计划”页面对本条记录重新设置集约化评标分组名称，确认删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        deletePlanInfoById(row.planId).then(res => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          /* 集约化评标计划*/
          // this.$router.push({ path: '/intensiveEvaluation/evaluationPlanManagementTabs' })
        })
      }).catch(() => {
      })
    },
    // 查询条件
    getQueryParams() {
      // 工作流进入bizId  否则取groupId
      this.searchForm.groupId = this.flowStatus ? this.$route.query.bizId : this.$route.query.groupId // 分组Id
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return param
    }
  }
}
</script>

<style lang="less" scoped>

</style>
