<template>
  <ele-pro-table
    ref="equiTable"
    :columns="columns"
    :datasource="datasource"
    :selection.sync="selection"
    :current.sync="current"
    highlight-current-row
    row-key="id"
    height="20vh"
  >
  </ele-pro-table>
</template>

<script>
import { getList } from '@/api/bpm/components/exceptionManagement';


export default {
  components: {},
  props: {
    selectList: Array,
    type: {
      default: 1 //1多选 2单选
    }
  },
  data() {
    return {
      equipmentdialog: false,
      current: null,
      planType: [
        { label: '所有计划类型', value: null },
        { label: '内销计划', value: '1' },
        { label: '外销计划', value: '2' },
        { label: '预制计划', value: '3' }
      ],
      columns: [
        {
          width: 45,
          type: 'selection',
          columnKey: 'selection',
          align: 'center',
          reserveSelection: true,
          show: this.type == 1
        },
        {
          columnKey: 'index',
          label: '序号',
          type: 'index',
          width: 55,
          align: 'center',
          showOverflowTooltip: true,
          fixed: 'left'
        },
        {
          prop: 'code',
          label: '计划编号',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 180,
          fixed: 'left'
        },
        {
          prop: 'productCode',
          label: '产品编码',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 180
        },
        {
          prop: 'productName',
          label: '产品名称',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 150
        },

        {
          prop: 'brandNo',
          label: '牌号',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 80
        },
        {
          prop: 'batchNo',
          label: '批号',
          align: 'center',
          minWidth: 100,
          showOverflowTooltip: true
        },
        {
          prop: 'model',
          label: '型号',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },

        {
          prop: 'priority',
          label: '优先级',
          align: 'center',
          minWidth: 90,
          showOverflowTooltip: true,
          sortable: 'custom'
        },

        {
          prop: 'productNum',
          label: '计划数量',
          showOverflowTooltip: true,
          align: 'center',
          minWidth: 90
        },
        {
          prop: 'productWeight',
          label: '计划重量',
          minWidth: 90,

          align: 'center',
          showOverflowTooltip: true
        },
        {
          prop: 'requiredFormingNum',
          label: '要求生产数量',
          minWidth: 120,

          align: 'center',
          showOverflowTooltip: true
        },

        {
          prop: 'newSumOrderWeight',
          label: '要求生产重量',
          minWidth: 120,

          align: 'center',
          showOverflowTooltip: true
        },

        {
          prop: 'reqMoldTime',
          label: '要求生产日期',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 120
        },

        {
          prop: 'orderType',
          label: '计划类型',
          align: 'center',
          minWidth: 80,
          showOverflowTooltip: true,
          formatter: (row) => {
            const obj = this.planType.find((i) => i.value == row.planType);
            return obj && obj.label;
          }
        },
        {
          prop: 'createTime',
          label: '创建时间',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        }
      ],
      categoryLevelId: null,
      code: null,
      selection: [],
      ids: []
    };
  },

  watch: {},
  methods: {
    datasource({ page, where, limit }) {
      return getList({
        ...where,
        pageNum: page,
        size: limit
      });
    },
    /* 刷新表格 */
    reload(where) {
      this.$nextTick(() =>
        this.$refs.equiTable.reload({ page: 1, limit: 10, where })
      );
    },
    // 选择
    getValue() {
      this.selection.forEach((item) => {
        item['objType'] = 1;
      });
      return JSON.parse(JSON.stringify(this.selection));
    }
  }
};
</script>

