({
- id: item.rawMaterialId,
- name: this.formatItemName(item)
- }));
- } else if (this.updateForm.itemType === 'product') {
- return this.productList.map(item => ({
- id: item.productId,
- name: this.formatItemName(item)
- }));
- }
- return [];
- }
},
async created() {
- // 先加载库区列表
- await this.loadWarehouses();
-
// 从路由参数获取coilId和actionId
const coilId = this.$route.query.coilId;
const actionId = this.$route.query.actionId;
@@ -645,12 +628,9 @@ export default {
// 根据材料类型设置物品类型
if (value === '成品') {
this.$set(this.updateForm, 'itemType', 'product');
- // 清空列表,等待用户搜索
- this.productList = [];
+
} else if (value === '原料') {
this.$set(this.updateForm, 'itemType', 'raw_material');
- // 清空列表,等待用户搜索
- this.rawMaterialList = [];
}
},
@@ -675,8 +655,6 @@ export default {
// 填充当前信息(左侧)
this.currentInfo = {
...data,
- itemName: this.getItemName(data),
- nextWarehouseName: this.getWarehouseName(data.warehouseId),
};
// 填充时间相关字段
@@ -698,14 +676,6 @@ export default {
}
},
- // 获取物料名称
- getItemName(data) {
- if (data.itemName) {
- return data.itemName;
- }
- return '';
- },
-
// 获取物品类型文本
getItemTypeText(itemType) {
if (itemType === 'raw_material') return '原材料';
@@ -713,13 +683,6 @@ export default {
return '—';
},
- // 获取库区名称
- getWarehouseName(warehouseId) {
- if (!warehouseId) return '';
- const warehouse = this.warehouseList.find(w => w.warehouseId === warehouseId);
- return warehouse ? warehouse.warehouseName : '';
- },
-
// 格式化物品名称(添加规格和参数信息)
formatItemName(item) {
if (!item) return '';
@@ -754,41 +717,7 @@ export default {
return displayName;
},
-
- // 加载库区列表
- async loadWarehouses() {
- try {
- const response = await listWarehouse({ pageNum: 1, pageSize: 1000 });
- if (response.code === 200) {
- this.warehouseList = response.rows || response.data || [];
- }
- } catch (error) {
- console.error('加载库区列表失败', error);
- }
- },
-
- // 加载变更历史
- async loadHistory() {
- if (!this.currentInfo.enterCoilNo) {
- return;
- }
-
- try {
- this.historyLoading = true;
- const response = await getMaterialCoilTrace({
- enterCoilNo: this.currentInfo.enterCoilNo,
- currentCoilNo: this.currentInfo.currentCoilNo || undefined
- });
-
- if (response.code === 200 && response.data) {
- this.historySteps = response.data.steps || [];
- }
- } catch (error) {
- console.error('加载变更历史失败', error);
- } finally {
- this.historyLoading = false;
- }
- },
+
// 复制当前信息到更新表单
copyFromCurrent() {
@@ -872,6 +801,15 @@ export default {
const response = await updateMaterialCoil(updateData);
+ // 更新完成后如果选定了合同,需要增加与合同的绑定关系
+ const coilId = response.msg;
+ if (this.updateForm.contractId) {
+ await addCoilContractRel({
+ coilId: coilId,
+ contractId: this.updateForm.contractId,
+ });
+ }
+
if (response.code === 200) {
this.$message.success('钢卷信息更新成功');
@@ -880,6 +818,8 @@ export default {
await completeAction(this.actionId, response.msg);
}
+
+
// 延迟返回
setTimeout(() => {
this.$router.back();