<!--
  @description: 采购员-采购方式维护-物料采购方式维护 执行中 表格
  @author: hdk
  @date： 2020-10-29
-->
<template>
  <div>
    <el-table ref="smallTable" v-loading="loading" :data="tableData" @sort-change="sortChange">
      <el-table-column key="1010" fixed type="index" label="序号" align="center" min-width="60" />
      <el-table-column
        key="1012"
        fixed
        prop="purchaseCode"
        sortable="custom"
        label="物资编号"
        header-align="center"
        align="left"
        min-width="140"
      />
      <el-table-column
        key="1013"
        fixed
        prop="purchaseName"
        sortable="custom"
        label="物资信息"
        min-width="140"
        header-align="center"
        align="center"
      />
      <el-table-column
        key="1015"
        prop="purchaseBrand"
        sortable="custom"
        label="品牌"
        min-width="180"
        header-align="center"
        align="center"
      />
      <el-table-column
        key="1016"
        prop="suppliersName"
        sortable="custom"
        label="供货供应商"
        min-width="180"
        header-align="center"
        align="center"
      />
      <el-table-column
        key="1017"
        prop="purchaseMethodValue"
        sortable="custom"
        label="采购方式"
        min-width="200"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(tenderMethodList, scope.row.purchaseMethodValue) }}
        </template>
      </el-table-column>
      <el-table-column
        key="1018"
        label="创建人"
        min-width="180"
        sortable="custom"
        prop="createUserName"
        header-align="center"
        align="left"
      />
      <el-table-column
        key="1019"
        label="创建日期"
        sortable="custom"
        prop="createTime"
        min-width="110"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ scope.row.createTime && $Moment(scope.row.createTime).format(momentDate) }}
        </template>
      </el-table-column>
      <el-table-column
        key="1020"
        prop="auditStatus"
        sortable="custom"
        label="状态"
        min-width="100"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          {{ filterDictText(planAuditStatusList, scope.row.auditStatus) }}
        </template>
      </el-table-column>
      <el-table-column
        key="1025"
        label="操作"
        width="160"
        header-align="center"
        align="center"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-link type="primary" @click="materielAdd('02', scope.row)">
            [变更]
          </el-link>
          <el-link
            v-if="purchasplanMethodSubmitAuditConfig"
            type="primary"
            @click.stop="onFlowTrace(scope.row)"
          >
            [流程追踪]
          </el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { filterDictText } from '@/assets/js/utils'// 常用方法
import { materielMixins } from './mixins/materielMixins'

export default {
  name: 'ExecuteTable',
  mixins: [materielMixins],
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
    }
  },
  methods: {
    filterDictText,
    // 变更
    materielAdd(editMode, row) {
      const params = {
        editMode,
        row
      }
      this.$emit('materielAdd', params)
    },
    // 流程追踪
    onFlowTrace(row) {
      this.$emit('onFlowTrace', row)
    },
    // 排序
    sortChange: function(column, prop, order) {
      let orderType = ''
      switch (column.order) {
        case 'ascending':
          orderType = 'ASC'
          break
        case 'descending':
          orderType = 'DESC'
          break
      }
      this.$emit('orderData', { column: column.prop, orderSort: orderType })
    }
  }
}
</script>
