<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 { workOrder } 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'
        },
        {
          label: '生产订单号',
          align: 'center',
          minWidth: 180,
          prop: 'code',
          showOverflowTooltip: true,
          fixed: 'left'
        },
        {
          prop: 'productionPlanCode',
          label: '计划编号',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 180
        },
        {
          prop: 'produceRoutingName',
          label: '工艺路线',
          minWidth: 130,
          showOverflowTooltip: true,

          align: 'center'
        },
        {
          prop: 'productCode',
          label: '产品编码',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 180
        },
        {
          prop: 'productName',
          label: '产品名称',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 120
        },
        {
          prop: 'brandNo',
          label: '牌号',
          align: 'center',
          minWidth: 100,
          showOverflowTooltip: true
        },

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

          align: 'center'
        },

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

        {
          prop: 'formingNum',
          label: '要求生产数量',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'formingWeight',
          label: '要求生产重量',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        },
        {
          prop: 'planStartTime',
          label: '计划开始时间',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'planCompleteTime',
          label: '计划结束时间',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'createTime',
          label: '创建时间',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 110
        },

        {
          prop: 'serialNo',
          label: '客户代号',
          align: 'center',
          minWidth: 110,

          showOverflowTooltip: true
        },

        {
          prop: 'simpleName',
          label: '客户简称',
          align: 'center',
          minWidth: 120,

          showOverflowTooltip: true
        }
      ],
      categoryLevelId: null,
      code: null,
      selection: []
    };
  },

  watch: {},
  methods: {
    datasource({ page, where, limit }) {
      return workOrder({
        ...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'] = 2;
      });
      return JSON.parse(JSON.stringify(this.selection));
    }
  }
};
</script>

