<!--
 * @description: 老平台归档信息列表
 * @author: tangQing
 * @date: 2022-11-30
!-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      老平台归档信息列表
    </template>
    <template v-slot:search="search">
      <el-form-item label="招标项目编号">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="招标项目编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="招标项目名称">
        <el-input
          v-model.trim="searchForm.tenderName"
          placeholder="招标项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--招标方式-->
      <el-form-item
        label="招标方式"
      >
        <el-select v-model="searchForm.tenderMethod" placeholder="请选择">
          <el-option
            v-for="(item,index) in ProcurementMethod"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        label="资格审查方式"
        prop="qualificationMethod"
      >
        <el-select v-model="searchForm.qualificationMethod" placeholder="请选择">
          <el-option
            v-for="item in QualificationExaminationMethod"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
    </template>
    <template v-slot:GXTable>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          prop="tenderNo"
          align="center"
          label="招标项目编号"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          :formatter="formatTenderMethod"
          header-align="center"
          prop="tenderMethod"
          label="招标方式"
          width="80"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="agentLinkerName"
          label="项目经理"
          width="90"
        />
        <el-table-column
          header-align="center"
          label="标段（包）名称"
          prop="packName"
          align="left"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          label="标段（包）编号"
          prop="packNo"
          align="left"
          min-width="160"
        />
        <el-table-column
          align="center"
          label="操作"
          width="100"
        >
          <template slot-scope="scope">
            <!-- isArchive 01 已归档 -->
            <el-link
              type="primary"
              @click.stop="archived(scope.row)"
            >
              [查看归档]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { listTenderProjectArchiveOldPages } from '@/api/bidding/biddingProject'// 招标项目-归档列表
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* 混入-字典信息 */
import { tenderArchivedGroup } from './../mixins/bidArchivedGroupMixin'// 字典信息
export default {
  name: 'TenderProjectList',
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      QualificationExaminationMethod: [
        {
          typecode: '00',
          typename: '资审项目'
        }, {
          typecode: '01',
          typename: '后审项目'
        }
      ], // 资格审查方式
      ...tenderArchivedGroup,
      /* 字典信息-end */
      loading: true,
      // 搜索
      createTime: [], // 创建时间 不传给后端只做回显
      searchForm: {
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        qualificationMethod: '', // 00资格预审,01 资格后审
        tenderMethod: '', // 招标方式 : 公开招标 00 邀请招标 01
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: [],
      // 招标/采购方式
      ProcurementMethod: [{
        typecode: '00',
        typename: '公开招标'
      }, {
        typecode: '01',
        typename: '邀请招标'
      }, {
        typecode: '02',
        typename: '竞争性谈判'
      }, {
        typecode: '03',
        typename: '询价'
      }, {
        typecode: '04',
        typename: '单一来源采购'
      }, {
        typecode: '05',
        typename: '其他'
      }, {
        typecode: '06',
        typename: '竞争性磋商'
      }]
    }
  },
  created() {
    // 字典信息
    this.initGroup()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'phaseType' // 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 表格字典值替换文本-招标方式
    formatTenderMethod(row, column, cellValue) {
      return filterDictText(this.ProcurementMethod, cellValue)
    },
    // 获取数据
    loadData(params, callback) {
      listTenderProjectArchiveOldPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 归档
    archived(row) {
      this.$router.push({
        name: 'tenderArchivedOld-detail',
        params: {
          packId: row.packId,
          row: row
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
