|
@@ -59,6 +59,7 @@
|
|
|
<!-- @update:selection="handleSelectionChange" -->
|
|
<!-- @update:selection="handleSelectionChange" -->
|
|
|
<ele-pro-table
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
ref="table"
|
|
|
|
|
+ row-key="rowKey"
|
|
|
:needPage="false"
|
|
:needPage="false"
|
|
|
:columns="columns"
|
|
:columns="columns"
|
|
|
:datasource="bomList"
|
|
:datasource="bomList"
|
|
@@ -174,7 +175,7 @@
|
|
|
<script>
|
|
<script>
|
|
|
import { deepClone } from '@/utils';
|
|
import { deepClone } from '@/utils';
|
|
|
import { getBom, batchSave } from '@/api/productionPlan/index.js';
|
|
import { getBom, batchSave } from '@/api/productionPlan/index.js';
|
|
|
- import { routeList } from '@/api/saleOrder';
|
|
|
|
|
|
|
+ import { routeList, bomRoutingList } from '@/api/saleOrder';
|
|
|
import EquipmentDialog from './EquipmentDialog.vue';
|
|
import EquipmentDialog from './EquipmentDialog.vue';
|
|
|
import { start } from 'nprogress';
|
|
import { start } from 'nprogress';
|
|
|
|
|
|
|
@@ -390,14 +391,14 @@
|
|
|
// 说明是全选
|
|
// 说明是全选
|
|
|
if (selection.length > 0) {
|
|
if (selection.length > 0) {
|
|
|
this.bomList.forEach((el) => {
|
|
this.bomList.forEach((el) => {
|
|
|
- this.bomListMap[el.id] = true;
|
|
|
|
|
|
|
+ this.bomListMap[el.rowKey] = true;
|
|
|
this.handleSelectionChange(el);
|
|
this.handleSelectionChange(el);
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
// 取消全选
|
|
// 取消全选
|
|
|
this.bomList.forEach((el) => {
|
|
this.bomList.forEach((el) => {
|
|
|
- delete this.bomListMap[el.id];
|
|
|
|
|
- this.deleteJhData(el.id);
|
|
|
|
|
|
|
+ delete this.bomListMap[el.rowKey];
|
|
|
|
|
+ this.deleteJhData(el.rowKey);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -405,26 +406,27 @@
|
|
|
// 勾选 取消勾选
|
|
// 勾选 取消勾选
|
|
|
select(selection, row) {
|
|
select(selection, row) {
|
|
|
// 存在说明已勾选
|
|
// 存在说明已勾选
|
|
|
- if (this.bomListMap[row.id]) {
|
|
|
|
|
- delete this.bomListMap[row.id];
|
|
|
|
|
- this.deleteJhData(row.id);
|
|
|
|
|
|
|
+ if (this.bomListMap[row.rowKey]) {
|
|
|
|
|
+ delete this.bomListMap[row.rowKey];
|
|
|
|
|
+ this.deleteJhData(row.rowKey);
|
|
|
} else {
|
|
} else {
|
|
|
- this.bomListMap[row.id] = true;
|
|
|
|
|
|
|
+ this.bomListMap[row.rowKey] = true;
|
|
|
this.handleSelectionChange(row);
|
|
this.handleSelectionChange(row);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 计划列表数据 BOM信息删除
|
|
// 计划列表数据 BOM信息删除
|
|
|
- deleteJhData(id) {
|
|
|
|
|
- let index = this.jhList.findIndex((el) => el.id === id);
|
|
|
|
|
|
|
+ deleteJhData(rowKey) {
|
|
|
|
|
+ let index = this.jhList.findIndex((el) => el.rowKey === rowKey);
|
|
|
if (index != -1) {
|
|
if (index != -1) {
|
|
|
this.jhList.splice(index, 1);
|
|
this.jhList.splice(index, 1);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 计划列表数据 BOM信息添加
|
|
// 计划列表数据 BOM信息添加
|
|
|
handleSelectionChange(m) {
|
|
handleSelectionChange(m) {
|
|
|
|
|
+ // 后端 id 可能重复/为空,勾选联动统一用前端生成的 rowKey 去重
|
|
|
for (let i = 0; i < this.jhList.length; i++) {
|
|
for (let i = 0; i < this.jhList.length; i++) {
|
|
|
let item = this.jhList[i];
|
|
let item = this.jhList[i];
|
|
|
- if (item.id == m.id) {
|
|
|
|
|
|
|
+ if (m.rowKey != null && item.rowKey === m.rowKey) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -438,6 +440,7 @@
|
|
|
}
|
|
}
|
|
|
let _num = this.getRequiredFormingNum(m);
|
|
let _num = this.getRequiredFormingNum(m);
|
|
|
let data = {
|
|
let data = {
|
|
|
|
|
+ rowKey: m.rowKey,
|
|
|
id: m.id,
|
|
id: m.id,
|
|
|
categoryId: m.categoryId,
|
|
categoryId: m.categoryId,
|
|
|
productCode: m.productCode,
|
|
productCode: m.productCode,
|
|
@@ -456,6 +459,16 @@
|
|
|
};
|
|
};
|
|
|
this.jhList.push(data);
|
|
this.jhList.push(data);
|
|
|
// this.jhList = _arr;
|
|
// this.jhList = _arr;
|
|
|
|
|
+ // 回填 BOM 绑定的工艺路线(默认取第一条,与临时计划选择BOM后的逻辑一致)
|
|
|
|
|
+ if (m.id != null) {
|
|
|
|
|
+ bomRoutingList(m.id).then((res) => {
|
|
|
|
|
+ const arr = res || [];
|
|
|
|
|
+ if (arr.length > 0 && !data.produceRoutingId) {
|
|
|
|
|
+ this.$set(data, 'produceRoutingId', arr[0].id);
|
|
|
|
|
+ this.$set(data, 'produceRoutingName', arr[0].name);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
// 数量正则
|
|
// 数量正则
|
|
|
handleQuantityInput(e, row) {
|
|
handleQuantityInput(e, row) {
|
|
@@ -506,14 +519,14 @@
|
|
|
// 删除计划信息
|
|
// 删除计划信息
|
|
|
removeRow(row, index) {
|
|
removeRow(row, index) {
|
|
|
// 如果删除的是当前列表BOM信息的数据 就将它的勾选去掉
|
|
// 如果删除的是当前列表BOM信息的数据 就将它的勾选去掉
|
|
|
- let data = this.bomList.find((el) => el.id == row.id);
|
|
|
|
|
- if (data && data.id) {
|
|
|
|
|
|
|
+ let data = this.bomList.find((el) => el.rowKey == row.rowKey);
|
|
|
|
|
+ if (data) {
|
|
|
this.$refs.table.toggleRowSelection(data);
|
|
this.$refs.table.toggleRowSelection(data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 删除对应的存储数据
|
|
// 删除对应的存储数据
|
|
|
- if (this.bomListMap[row.id]) {
|
|
|
|
|
- delete this.bomListMap[row.id];
|
|
|
|
|
|
|
+ if (this.bomListMap[row.rowKey]) {
|
|
|
|
|
+ delete this.bomListMap[row.rowKey];
|
|
|
}
|
|
}
|
|
|
this.jhList.splice(index, 1);
|
|
this.jhList.splice(index, 1);
|
|
|
},
|
|
},
|
|
@@ -545,7 +558,11 @@
|
|
|
size: -1
|
|
size: -1
|
|
|
};
|
|
};
|
|
|
getBom(params).then((res) => {
|
|
getBom(params).then((res) => {
|
|
|
- this.bomList = res?.bomList || [];
|
|
|
|
|
|
|
+ // 后端返回的 id 可能重复/为空,前端生成唯一 rowKey 供勾选联动使用
|
|
|
|
|
+ this.bomList = (res?.bomList || []).map((el, index) => ({
|
|
|
|
|
+ ...el,
|
|
|
|
|
+ rowKey: `${this.formData.produceType || ''}_${el.id || ''}_${index}`
|
|
|
|
|
+ }));
|
|
|
let ids = Object.keys(this.bomListMap);
|
|
let ids = Object.keys(this.bomListMap);
|
|
|
if (ids.length > 0) {
|
|
if (ids.length > 0) {
|
|
|
this.checkBoxData();
|
|
this.checkBoxData();
|
|
@@ -565,7 +582,7 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.bomList.forEach((row) => {
|
|
this.bomList.forEach((row) => {
|
|
|
- if (this.bomListMap[row.id]) {
|
|
|
|
|
|
|
+ if (this.bomListMap[row.rowKey]) {
|
|
|
this.$refs.table.toggleRowSelection(row);
|
|
this.$refs.table.toggleRowSelection(row);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -654,8 +671,10 @@
|
|
|
return this.$message.warning('请填写正确的生产数量');
|
|
return this.$message.warning('请填写正确的生产数量');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // rowKey 仅用于前端勾选联动,提交给后端前去掉
|
|
|
|
|
+ const addPOList = this.jhList.map(({ rowKey, ...rest }) => rest);
|
|
|
let param = {
|
|
let param = {
|
|
|
- addPOList: this.jhList,
|
|
|
|
|
|
|
+ addPOList: addPOList,
|
|
|
produceType: this.formData.produceType,
|
|
produceType: this.formData.produceType,
|
|
|
id: this.formData.id
|
|
id: this.formData.id
|
|
|
};
|
|
};
|