<!--
  @description:集约化评标-屏蔽单位
  @Modifier: 肖文龙
  @routerPath:
  @date: 2020年3月9日15:15:12
-->
<template>
  <div class="mb10">
    <div class="page-title">
      3. 屏蔽单位
      <el-button v-if="isEdit && judgesStatus!=='02'" type="primary" @click="addRow()">
        添加屏蔽单位
      </el-button>
    </div>
    <div>
      <el-table :data="tableData">
        <el-table-column type="index" label="序号" width="45" align="center" />
        <el-table-column header-align="center" label="屏蔽单位名称" min-width="250px" prop="avoidCompany" />
        <el-table-column header-align="center" label="屏蔽单位编码" min-width="140px" prop="avoidOrgcode" />
        <el-table-column header-align="center" min-width="300px" label="屏蔽原因" prop="reason" />
        <el-table-column align="center" width="100px" label="屏蔽类型" prop="avoidType">
          <template slot-scope="scope">
            <span
              v-for="(item,index) in shieldingTypeList"
              v-if="item.typecode===scope.row.avoidType"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          v-if="isEdit && judgesStatus!=='02'"
          header-align="center"
          label="操作"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click="editRow(scope.row,scope.$index)"
            >
              [编辑]
            </el-link>
            <el-link
              type="primary"
              @click="deleteRow(scope.row,scope.$index)"
            >
              [删除]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="initData" />
    </div>
    <!--添加/编辑屏蔽单位-->
    <shieldingUnitDalog :dialog-data="dialogData" :data="formData" @shieldingUnitInfo="shieldingUnitInfo" />
  </div>
</template>

<script>
/* api*/
import { queryExtractCompanyListByJuryId, deleteExtractCompanyInfo } from '@/api/intensiveeval/intensiveeval'
/* 混合开发*/
import { groupMixin } from '@/views/intensiveeval/mixins/intensiveevalGroupMixin'// 字典信息
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import shieldingUnitDalog from './shieldingUnit-dialog'// 添加/编辑屏蔽单位-弹框
export default {
  name: 'ShieldingUnitEditView',
  components: {
    shieldingUnitDalog,
    pagination
  },
  mixins: [groupMixin, ListMixin],
  data() {
    return {
      judgesStatus: this.$route.query.judgesStatus, // 评委会状态02为抽取失败 禁用添加评标单位按钮
      isEdit: this.$route.meta.isEdit, // 是否可编辑 布尔值
      formData: { },
      tableData: [], // 列表信息
      // 弹窗展示状态
      dialogData: {
        dialog: false, // 是否展开 布尔值
        dialogType: '00' // 编辑状态 00 新增 01 编辑
      }
    }
  },
  created() {
    this.initData()// 初始化屏蔽专家列表
  },
  methods: {
    // 初始化屏蔽专家列表
    initData() {
      const stageId = this.$route.query.juryId ? '' : this.$store.getters.groupId.stageId
      const data = {
        juryId: this.$route.query.juryId, // 评委会Id-组建评标委员会时用的
        stageId: stageId, // 阶段Id>在项目驱动里用的
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      queryExtractCompanyListByJuryId(data).then(res => {
        this.tableData = res.data.records
        this.paginationData.total = res.data.total
      })
    },
    // 新增
    addRow() {
      this.dialogData = {
        dialog: true,
        dialogType: '00'
      }
    },
    // 编辑
    editRow(row) {
      this.dialogData = {
        dialog: true,
        dialogType: '01'
      }
      this.formData = row
    },
    // 新增/编辑返回的信息
    shieldingUnitInfo() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.initData()// 初始化屏蔽专家列表
    },
    //  删除
    deleteRow(row) {
      this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        deleteExtractCompanyInfo(row.id).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.paginationData.pageNo = 1
          this.paginationData.pageSize = 10
          this.initData()// 初始化屏蔽专家列表
        })
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>
