<!--
  @description:招标失败列表
  @Modifier: haofengxian/肖文龙
  @routerPath: bidding/projectDrive/biddingFailure/biddingFailure-list
  @date: 2020-12-17
  isCanOperate: true可以操作 false不可以查看只有查看权限
-->
<template>
  <section class="main">
    <el-button v-if="tenderBase.isCanOperate" type="primary" class="mb10" @click="addBidFailure">
      新增
    </el-button>
    <div>
      <el-table
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          label="招标失败"
          header-align="center"
          prop="stopBiddingBulletinName"
          min-width="230"
        />
        <el-table-column
          label="标段（包）编号"
          prop="stopBiddingPackNo"
          align="center"
          min-width="200"
        />
        <el-table-column
          prop="submitDate"
          align="center"
          label="提交时间"
          width="160"
        />
        <el-table-column
          :formatter="formatterUnusualReasonType"
          align="center"
          label="异常原因"
          prop="unusualReasonType"
          min-width="200"
        />
        <el-table-column
          prop="megFeedbackText"
          align="center"
          label="失败处置提醒"
          width="160"
        />
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
  </section>
</template>

<script>
/* 接口*/
import { biddingFailPages } from '@api/huanengwuzids/index'
/* 组件*/
import pagination from '@comp/common/pagination/pagination' // 分页
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin' // 分页
import { filterDictText } from '@/assets/js/utils'// 常用方法
export default {
  name: 'BiddingFailureList',
  components: {
    pagination // 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      /* 字典信息-start */
      unusualReasonTypeList: [], // 异常原因
      /* 字典信息-end */
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      tenderId: this.$route.query.id,
      loading: true,
      tableData: []
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
    this.initGroup()// 获取字典方法
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 表格字典值替换文本-异常原因
    formatterUnusualReasonType(row, column, cellValue) {
      return filterDictText(this.unusualReasonTypeList, cellValue)
    },
    // 获取字典方法
    initGroup() {
      const data = [
        'unusualReasonType' // 异常原因
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取数据
    loadData() {
      const params = {
        tenderId: this.tenderId,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      biddingFailPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 新增招标失败
    addBidFailure() {
      this.$router.push({
        path: '/bidding/projectDrive/biddingFailure/biddingFailureAdd',
        query: {
          ...this.$route.query
        }
      })
    }
  }
}
</script>

<style scoped></style>
