<template>
    <div>
      <el-table
        v-loading="loading"
        :data="itemList"
      >
        <!-- <el-table-column type="selection" width="55" align="center"/> -->

        <el-table-column :label="$t('生产工单')" width="180" prop="workorderCode"/>
        <el-table-column :label="$t('产品编号')" width="180" prop="productCode"/>
        <el-table-column :label="$t('产品名称')" prop="productName"/>
        <el-table-column :label="$t('生产订单数量')" v-if="isOrder" prop="quantity"/>
        <el-table-column :label="$t('规格')" width="140" prop="productSpc"/>
        <el-table-column :label="$t('需求日期')" width="140" prop="requestDate"/>
      </el-table>
    </div>
</template>

<script>


import {
  taskWorkunitList
} from "@/api/mes/pro/scheduleList";

export default {
  props: ['isOrder'],
  name: "arrangCodeList",
  components: { },
  data() {
    return {
      showFlag: false,
      // 选中数组
      ids: [],
      selectedRows: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 物料产品表格数据
      itemList: null,
      loading: false,
    };
  },
  created() {

  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 查询物料编码列表 */
    getList() {
      this.loading = true;
      const params = {}
      if (this.isOrder) {
        params['arrangeCode'] = this.$attrs.arrangeCode
      } else {
        params['taskWorkunitId'] = this.$attrs.taskWorkunitId
      }
      taskWorkunitList(params).then((response) => {
        this.itemList = response;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.statusArr = ["ORCHESTRATED"]
      this.handleQuery();
    },
     // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.workorderId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
      this.selectedRows = selection;
    },
  },
};
</script>
