<!--
  @description:申报单位记录
  @Modifier: haofengxian
  @routerPath:
  @date: 2020-7-8-15:26
-->
<template>
  <div>
    <div>
      <el-table
        ref="smallTable"
        :data="tableData"
        width="100%"
      >
        <el-table-column
          label="序号"
          type="index"
          width="60px"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop="departName"
          align="center"
          label="申报单位"
          width="160"
        />
        <el-table-column
          header-align="center"
          prop="createTime"
          label="申报日期"
          align="center"
          min-width="260"
        />
        <el-table-column
          header-align="center"
          prop="supplyScope"
          label="供货范围"
          min-width="260"
        />
        <el-table-column
          header-align="center"
          prop="supplierName"
          label="经办人"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          prop="useStatus"
          label="申报状态"
          min-width="200"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in auditStatusList"
              v-if="scope.row.auditStatus===item.typecode"
              :key="index"
            >{{ item.typename }}
            </span>
          </template>
        </el-table-column>
        <el-table-column
          prop="isWinBiding"
          label="操作"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <el-link type="primary" @click="supplierDetail(scope.row.id)">
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </div>
    <!--申报单位记录查看-弹框-->
    <recordReportingDetail ref="recordReportingDetail" />
  </div>
</template>

<script>
/* api*/
import { listDeclarationPages } from '@/api/supplier/declaraTionrecord'
/* 公用方法*/
import { filterObj, filterDictText } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { supplierGroupMixin } from '../mixins/supplierGroupMixin'
/* 组件*/
import recordReportingDetail from '@/views/supplier/supplierRepository/recordReportingDetail-dialog' // 申报单位记录-查看详情
import pagination from '@comp/common/pagination/pagination'// 分页
import { mapGetters } from 'vuex'

export default {
  name: 'RecordReportingUnitList',
  components: {
    recordReportingDetail, // 查看页
    pagination // 分页
  },
  mixins: [ListMixin, supplierGroupMixin],
  props: {
    // 查看状态
    judgePageData: {
      type: Object,
      default: function() {
        return {
          detailType: 'dialog', // 查看形式 dialog 弹框
          departId: ''// 供应商主键id
        }
      }
    }
  },
  data() {
    return {
      tableData: [], // 列表信息
      searchForm: {
        supplierId: '', // 供应商id
        auditStatus: '' // 状态
      },
      recordReportingUnitListDto: {
        departId: '',
        tabType: '03' // 切换内容——企业资质
      },
      loading: true
    }
  },
  computed: {
    /* language 国际化*/
    ...mapGetters(['language'])
  },
  created() {
    this.recordReportingUnitListDto.departId = this.$route.params.supplierId || this.judgePageData.departId// 供应商id
    // 获取列表信息
    this.loadData()
  },
  methods: {
    filterDictText,
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listDeclarationPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.recordReportingUnitListDto)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 查看弹框
    supplierDetail(id) {
      this.$refs.recordReportingDetail.openDialog(id) // 获取详情
    }
  }
}
</script>

<style scoped>

</style>

