<!--
  @description: 运维-资审合格通知书审核/资审结果通知书审核
  @author: 肖文龙
  @routerPath:/projectManagement/confirmQualifiedAudit
              /projectManagement/confirmQualifiedResultAudit
  @date：  2020年2月7日13:48:19
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    :tabs="auditStatusList"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      {{ noticeTitle }}审核列表
    </template>
    <template v-slot:search="">
      <el-form-item :label="noticeTitle" prop="noticeTitle">
        <el-input v-model.trim="searchForm.noticeTitle" :placeholder="noticeTitle" 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="noticeTitle"
          header-align="center"
          prop="noticeTitle"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          label="包编号"
          prop="packNo"
          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="audit(scope.row)"
            >
              [审核]
            </el-link>
            <el-link
              v-if="auditStatus === '01'"
              type="primary"
              @click="audit(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* api*/
import { getAuditZsNoticeList } from '@api/bidding/bidCalibration'
import { ListMixin } from '@/mixins/ListMixin'
import { initGroupMixin } from '@/mixins/initGroupMixin' // 公共tabs切换页数据list
import pagination from '@comp/common/pagination/pagination'
export default {
  name: 'ConfirmQualifiedResultAuditList',
  components: {
    pagination
  },
  mixins: [ListMixin, initGroupMixin],
  data() {
    return {
      loading: false,
      noticeTitle: '', // 资审合格通知书  资审结果通知书审核
      // 搜索
      searchForm: {
        noticeTitle: '',
        noticeType: '',
        tenderName: ''
      },
      tableData: [], // 列表
      auditStatus: '' // 00待审核 01已审核
    }
  },
  watch: {
    $route() {
      this.initBulletinType()// 初始化
      this.$refs.tableCrud.onSearchChange()
    }
  },
  created() {
    this.initBulletinType()// 初始化
  },
  methods: {
    /* 初始化*/
    initBulletinType() {
      if (this.$route.meta.noticeType === '01') {
        this.noticeTitle = '资审合格通知书'
        this.searchForm.noticeType = '01'
      } else if (this.$route.meta.noticeType === '00') {
        this.noticeTitle = '资审结果通知书'
        this.searchForm.noticeType = '00'
      }
    },
    // 获取数据
    loadData(params, callback, tabData) {
      this.auditStatus = tabData.typecode // 审核状态
      params.auditStatus = tabData.typecode
      getAuditZsNoticeList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
        this.$forceUpdate()
      }).catch(() => {
        this.loading = false
      })
    },
    // 审核
    audit(row) {
      // 00 否 结果通知书 01 是合格通知书
      if (this.searchForm.noticeType === '00') {
        this.$router.push({
          path: '/projectManagement/zsNotificationResultsAuditPdfDetail',
          query: {
            noticeId: row.id,
            auditStatus: this.auditStatus // 00待审核 01已审核
          }
        })
      } else {
        // 01 是合格通知书
        this.$router.push({
          path: '/projectManagement/zsNotificationConformityAuditPdfDetail',
          query: {
            noticeId: row.id,
            auditStatus: this.auditStatus // 00待审核 01已审核
          }
        })
      }
    }
  }
}
</script>

<style lang="less">

</style>
