<!--
  @description:采购单归档，未归档表格
  @Modifier: lxl
  @date: 2021-4-9-14:06
-->
<template>
  <div>
    <el-table
      ref="smallTable"
      v-loading="loading"
      :row-key="getRowKeys"
      :data="tableData"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        :reserve-selection="true"
        type="selection"
        width="60"
        align="center"
        fixed="left"
      />
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60"
        fixed="left"
      />
      <el-table-column
        prop="tenderNo"
        label="采购单编号/采购单名称"
        header-align="center"
        min-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="center"
        min-width="150"
      >
        <template slot-scope="scope">
          {{ scope.row.tenderMethod && filterDictText(tender_methodList,scope.row.tenderMethod) }}
        </template>
      </el-table-column>
      <el-table-column
        label="是否框架"
        prop="planType"
        width="100"
        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="采购员"
        min-width="150"
        header-align="center"
        align="center"
      />
      <el-table-column
        prop="purchaseProjectStatus"
        label="采购单状态"
        min-width="120"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.purchaseProjectStatus && filterDictText(protprojectPurchaseProjectStatusList,scope.row.purchaseProjectStatus) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" 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 {
      tender_methodList: [], // 采购方式
      protprojectPurchaseProjectStatusList: [] // 采购单状态
    }
  },
  created() {
    this.initGroup()
  },
  methods: {
    filterDictText,
    // 获取字典方法
    initGroup() {
      const data = [
        'tender_method',
        'protprojectPurchaseProjectStatus'
      ]
      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>
