<!--
  @description: 审核招标公告列表，审核资审公告列表
  @Modifier:haoFx
  @routerPath: /projectManagement/auditInformationBulletin
               /projectManagement/auditBulletin
  @date:2019/11/18-10:47
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    :tabs="auditStatusList"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      {{ bulletinTitle }}审核列表
    </template>
    <template v-slot:search="">
      <el-form-item :label="bulletinTitle" prop="title">
        <el-input v-model.trim="searchForm.title" :placeholder="bulletinTitle" style="width:268px" />
      </el-form-item>
      <el-form-item label="招标项目名称" prop="tenderName">
        <el-input v-model.trim="searchForm.tenderName" placeholder="招标项目名称" style="width:268px" />
      </el-form-item>
    </template>
    <template v-slot:GXTable>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column
          :label="bulletinTitle"
          header-align="center"
          prop="title"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          label="包编号"
          prop="packNos"
          align="left"
          min-width="200"
        />
        <el-table-column label="操作" align="center" width="80">
          <template slot-scope="scope">
            <el-link
              v-if="auditStatus === '00'"
              type="primary"
              @click="auditBulletin(scope.row)"
            >
              [审核]
            </el-link>
            <el-link
              v-if="auditStatus === '01'"
              type="primary"
              @click="auditBulletin(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
import { listWaitAuditTenderBulletinPages } from '@/api/bidding/bidBulletin'
/* 混合开发方法-参数字段*/
import { tenderBulletinInitGroupMixin } from './../mixins/tenderBulletinInitGroupMixin'// 字典信息
import { ListMixin } from '@/mixins/ListMixin'
import { initGroupMixin } from '@/mixins/initGroupMixin' // 公共tabs切换页数据list
import pagination from '@comp/common/pagination/pagination'

export default {
  name: 'AuditBulletiNoticeList',
  components: {
    pagination
  },
  mixins: [ListMixin, tenderBulletinInitGroupMixin, initGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        bulletinType: '', // 公告类型 招标公告 01, 资审公告 21
        tenderName: '', // 项目名称
        title: '' // 公告标题
      },
      tableData: [], // 列表
      auditStatus: '' // 00待审核 02已审核
    }
  },
  watch: {
    $route() {
      this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
      this.$refs.tableCrud.onSearchChange()
    }
  },
  created() {
    this.initBulletinType()// 字典信息区分-招标公告/资审公告方法
  },
  methods: {
    // 获取招标公告列表数据
    loadData(params, callback, tabData) {
      this.auditStatus = tabData.typecode // 审核状态
      params.auditStatus = tabData.typecode
      params.bulletinType = this.bulletinType
      listWaitAuditTenderBulletinPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
        this.$forceUpdate()
      }).catch(() => {
        this.loading = false
      })
    },
    // 审核
    auditBulletin(row) {
      // 同一个页面不同路由
      let path = ''
      if (this.bulletinType === '01') { // 招标公告
        path = '/projectManagement/auditBulletinContent'
      } else if (this.bulletinType === '21') {
        path = '/projectManagement/auditInformationBulletinContent'// 资审公告
      }
      this.$router.push({
        path: path,
        query: {
          // auditStatus: this.auditStatus, // 审核状态 00待审核 01已审核
          // bulletinId: row.bulletinId
          auditStatus: this.auditStatus, // 审核状态 00待审核 01已审核
          bulletinId: row.bulletinId,
          tenderId: row.tenderId
        }
      })
    }
  }
}
</script>

<style lang="less">

</style>
