<!--
  @description: 规则配置标段信息列表
  @Modifier: haofengxian
  @routerPath: /serviceConfig/bidBulletinTenderStageRule
  @date: 2020-11-4-15:47
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="110px"
    @on-load="loadData"
  >
    <template v-slot:header>
      规则配置标段信息列表
    </template>
    <template v-slot:search="search">
      <el-form-item ref="packNo" label="标段（包）编号" prop="packNo">
        <el-input
          v-model.trim="searchForm.packNo"
          placeholder="标段（包）编号"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="packName" label="标段（包）名称" prop="packName">
        <el-input
          v-model.trim="searchForm.packName"
          style="width:220px"
          placeholder="标段（包）名称"
          @keyup.enter.native="search.onSearch"
        />
      </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="packNo"
          label="标段（包）编号"
          min-width="180"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="标段（包）名称"
          min-width="230"
        />
        <el-table-column
          :formatter="formatIsTwoBidOpening"
          header-align="center"
          prop="isTwoBidOpening"
          label="开标方式"
          width="110"
          align="center"
        />
        <el-table-column
          :formatter="formatBidDocumentDecryptionMethod"
          header-align="center"
          prop="bidDocumentDecryptionMethod"
          label="投标文件解密方式"
          width="120"
        />
        <el-table-column
          label="投标截止时间"
          prop="submitEndTime"
          align="center"
          width="140"
        >
          <template slot-scope="scope">
            {{ scope.row.submitEndTime && $Moment(scope.row.submitEndTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="开标时间"
          prop="openBidStartTime"
          align="center"
          min-width="200"
        >
          <template slot-scope="scope">
            {{ scope.row.openBidStartTime && $Moment(scope.row.openBidStartTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="技术标开标时间（两步开标）"
          prop="technicalOpenBidStartTime"
          align="center"
          min-width="200"
        >
          <template slot-scope="scope">
            {{ scope.row.technicalOpenBidStartTime && $Moment(scope.row.technicalOpenBidStartTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="经济标开标时间（两步开标）"
          prop="economicOpenBidStartTime"
          align="center"
          min-width="200"
        >
          <template slot-scope="scope">
            {{ scope.row.economicOpenBidStartTime && $Moment(scope.row.economicOpenBidStartTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          label="操作"
          width="90"
          align="center"
        >
          <template slot-scope="scope">
            <el-link type="primary" @click.stop="modifyRule(scope.row)">
              [修改规则]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>

<script>
/* 接口*/
import { listTenderStageRulePages } from '@api/bidding/bidBulletin'
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
import { tenderBulletinInitGroupMixin } from '../mixins/tenderBulletinInitGroupMixin'

export default {
  name: 'TenderStageRuleExpand',
  mixins: [tenderBulletinInitGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        packName: '', // 标段名称
        packNo: '' // 标段编号
      },
      tableData: []
    }
  },
  created() {
    // 获取开标方式字典初始化信息
    this.getBulletinOpenInitInfo()
  },
  methods: {
    // 获取数据
    loadData(params, callback) {
      listTenderStageRulePages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 表格字典值替换文本-解密方式
    formatBidDocumentDecryptionMethod(row, column, cellValue) {
      return filterDictText(this.decryptionMethodList, cellValue)
    },
    // 表格字典值替换文本-开标方式
    formatIsTwoBidOpening(row, column, cellValue) {
      return filterDictText(this.openingMethodList, cellValue)
    },
    // 修改规则
    modifyRule(row) {
      this.$router.push({
        name: 'BidBulletinTenderStageRuleUpdate',
        params: {
          stageId: row.stageId
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
