<!--
  @description: 审核供应商/风险控制部提交异议
  @Modifier: haoFx
  @routerPath:/objection/auditObjectionList
  @date: 2020/3/3-10:43
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    :tabs="auditStatusList"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      异议审核列表
    </template>
    <template v-slot:search="">
      <el-form-item ref="objectionMode" label="问题类型" prop="objectionMode">
        <el-select v-model="searchForm.objectionMode" placeholder="请选择">
          <el-option
            v-for="item in objectionModeList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item ref="supplierName" label="异议人" prop="supplierName">
        <el-input v-model="searchForm.supplierName" placeholder="异议人" width="228px" />
      </el-form-item>
      <el-form-item ref="tenderName" label="项目名称" prop="tenderName">
        <el-input v-model="searchForm.tenderName" placeholder="项目名称" width="228px" @keyup.enter.native="onSearch" />
      </el-form-item>
      <el-form-item ref="tenderNo" label="项目编号" prop="tenderNo">
        <el-input v-model="searchForm.tenderNo" placeholder="项目编号" width="228px" @keyup.enter.native="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
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          prop="tenderNo"
          align="center"
          label="招标项目编号"
          width="160"
        />
        <el-table-column
          header-align="center"
          label="标段（包）名称"
          prop="packNames"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="标段（包）编号"
          prop="packNos"
          align="center"
          min-width="110"
        />
        <!--          <el-table-column
            header-align="center"
            prop=""
            label="投诉方式"
            min-width="75"
            align="center"/>-->
        <el-table-column
          header-align="center"
          prop="supplierName"
          label="异议人"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          prop="objectionMode"
          label="问题类型"
          min-width="75"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.objectionMode==='00'">异议</span>
            <span v-if="scope.row.objectionMode==='01'">投诉</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="objectionType"
          label="异议类型"
          min-width="75"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in objectionTypeList"
              v-if="scope.row.objectionType===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="80">
          <template slot-scope="scope">
            <el-link
              v-if="auditStatus === '00'"
              type="primary"
              @click="handleAudit(scope.row)"
            >
              [审核]
            </el-link>
            <el-link
              v-if="auditStatus === '01'"
              type="primary"
              @click="handleAudit(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>

<script>
/* 接口*/
import { listWaitAuditObjectionPages } from '@api/bidding/tenderObjection'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { objectionConfigMixin } from '../mixins/objectionConfigMixin'// 澄清-字典信息
import { initGroupMixin } from '@/mixins/initGroupMixin' // 公共tabs切换页数据list
export default {
  name: 'ClarificationList',
  components: {
  },
  mixins: [ListMixin, objectionConfigMixin, initGroupMixin],
  data() {
    return {
      /* 字典信息-start */
      objectionTypeList: [], // 异议类型
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        supplierName: '', // 异议人
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        objectionMode: '' // 问题类型
      },
      tableData: [], // 列表
      auditStatus: '' // 00待审核 01已审核
    }
  },
  created() {
    // 获取字典方法
    this.initGroup()
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'objectionType' // 异议类型
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取数据
    loadData(params, callback, tabData) {
      this.auditStatus = tabData.typecode // 审核状态
      params.auditStatus = tabData.typecode
      listWaitAuditObjectionPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
      })
    },
    // 审核
    handleAudit(row) {
      this.$router.push({
        path: '/projectManagement/auditObjectionContent',
        name: 'AuditObjection',
        params: {
          objectionId: row.objectionId, // 异议id
          receiptStatus: row.receiptStatus, // 接受状态 01:受理 02:不受理
          auditStatus: this.auditStatus // 00待审核 01已审核
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>

