<!--
  @description:采购单归档，已归档表格
  @Modifier: lxl
  @date: 2021-4-9-14:06
-->
<template>
  <div>
    <el-table
      ref="smallTable"
      v-loading="loading"
      :data="tableData"
    >
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60"
        fixed="left"
      />
      <el-table-column
        prop="tenderNo"
        label="采购单编号/采购单名称"
        header-align="center"
        width="200"
      >
        <template slot-scope="scope">
          <p>{{ scope.row.tenderNo }}</p>
          <p>{{ scope.row.tenderName }}</p>
        </template>
      </el-table-column>
      <el-table-column
        prop="tenderMethod"
        label="采购方式"
        header-align="center"
        align="left"
        width="180"
      >
        <template slot-scope="scope">
          {{ scope.row.tenderMethod && filterDictText(tender_methodList,scope.row.tenderMethod) }}
        </template>
      </el-table-column>
      <el-table-column
        label="是否框架"
        prop="planType"
        width="160"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.planType && filterDictText(isFrameList,scope.row.planType) }}
        </template>
      </el-table-column>
      <el-table-column
        prop="sourcingUserRealName"
        label="采购员"
        width="80"
        header-align="center"
        align="center"
      />
      <el-table-column
        prop="purchaseProjectStatus"
        label="采购单状态"
        width="100"
        header-align="center"
        align="left"
      >
        <template slot-scope="scope">
          {{ scope.row.purchaseProjectStatus && filterDictText(protprojectPurchaseProjectStatusList,scope.row.purchaseProjectStatus) }}
        </template>
      </el-table-column>
      <el-table-column
        label="采购结束时间"
        width="180"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.resultPublishTime && $Moment(scope.row.resultPublishTime).format(momentDateTime) }}
        </template>
      </el-table-column>
      <el-table-column
        label="归档时间"
        width="160"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.archiveTime && $Moment(scope.row.archiveTime).format(momentDateTime) }}
        </template>
      </el-table-column>
      <el-table-column
        label="下载状态"
        width="160"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.isDownloadArchive && filterDictText(isDownloadArchiveFileList,scope.row.isDownloadArchive) }}
        </template>
      </el-table-column>
      <el-table-column
        label="下载时间"
        width="160"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.archiveDownloadTime && $Moment(scope.row.archiveDownloadTime).format(momentDateTime) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="80">
        <template slot-scope="scope">
          <slot name="method" :scope="scope" />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
/* 公共参数方法*/
import { filterDictText } from '@/assets/js/utils'// 常用方法
/* mixins*/
import { archivedDic } from '.././mixins/dicMixins.js'
export default {
  mixins: [archivedDic],
  props: {
    // 列表数据
    tableData: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      orderStateList: [], // 采购单状态
      purchaseProjectStatusList: [], // 采购状态
      tender_methodList: [], // 采购方式
      protprojectPurchaseProjectStatusList: [], // 采购单状态
      isDownloadArchiveFileList: [] // 下载状态
    }
  },
  created() {
    this.initGroup()
  },
  methods: {
    filterDictText,
    // 获取字典方法
    initGroup() {
      const data = [
        'tender_method',
        'protprojectPurchaseProjectStatus',
        'isDownloadArchiveFile'
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取row的key值优化表格的渲染
    getRowKeys(row) {
      return new Date().getTime() + Math.random() * 100
    },
    // 选择事件
    handleSelectionChange(row) {
      this.$emit('handleSelectionChange', row)
    }
  }
}
</script>
