diff --git a/klp-ui/src/views/wms/coil/panels/base.vue b/klp-ui/src/views/wms/coil/panels/base.vue index a3727dcc..f2d34be9 100644 --- a/klp-ui/src/views/wms/coil/panels/base.vue +++ b/klp-ui/src/views/wms/coil/panels/base.vue @@ -167,18 +167,19 @@ - - - - + + + + + - - + - -
请先选择物料类型
+
请先选择材料类型
@@ -347,10 +348,33 @@ export default { } }; }, + computed: { + // 动态显示标签 + getItemLabel() { + if (this.form.materialType === '成品') { + return '产品类型'; + } else if (this.form.materialType === '原料' || this.form.materialType === '废品') { + return '原料类型'; + } + return '物品类型'; + } + }, created() { this.getList(); }, methods: { + // 处理材料类型变化 + handleMaterialTypeChange(value) { + // 清空物品选择 + this.form.itemId = null; + + // 根据材料类型设置物品类型 + if (value === '成品') { + this.form.itemType = 'product'; + } else if (value === '原料' || value === '废品') { + this.form.itemType = 'raw_material'; + } + }, /** 查询钢卷物料列表 */ getList() { this.loading = true; @@ -480,6 +504,18 @@ export default { handleAdd() { this.isCheck = false; this.reset(); + + // 如果父组件传入了 materialType,使用它作为默认值 + if (this.querys.materialType) { + this.form.materialType = this.querys.materialType; + // 同时设置对应的 itemType + if (this.querys.materialType === '成品') { + this.form.itemType = 'product'; + } else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') { + this.form.itemType = 'raw_material'; + } + } + this.open = true; this.title = "添加钢卷物料"; }, @@ -492,6 +528,28 @@ export default { getMaterialCoil(coilId).then(response => { this.loading = false; this.form = response.data; + + // 设置 materialType(优先级:后端返回 > itemType推断 > 父组件传入) + if (!this.form.materialType) { + if (this.form.itemType) { + // 根据 itemType 推断 + if (this.form.itemType === 'product') { + this.form.materialType = '成品'; + } else if (this.form.itemType === 'raw_material') { + this.form.materialType = '原料'; + } + } else if (this.querys.materialType) { + // 使用父组件传入的默认值 + this.form.materialType = this.querys.materialType; + // 同时设置对应的 itemType + if (this.querys.materialType === '成品') { + this.form.itemType = 'product'; + } else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') { + this.form.itemType = 'raw_material'; + } + } + } + this.open = true; this.title = "修改钢卷物料"; }); @@ -504,6 +562,28 @@ export default { getMaterialCoil(coilId).then(response => { this.loading = false; this.form = response.data; + + // 设置 materialType(优先级:后端返回 > itemType推断 > 父组件传入) + if (!this.form.materialType) { + if (this.form.itemType) { + // 根据 itemType 推断 + if (this.form.itemType === 'product') { + this.form.materialType = '成品'; + } else if (this.form.itemType === 'raw_material') { + this.form.materialType = '原料'; + } + } else if (this.querys.materialType) { + // 使用父组件传入的默认值 + this.form.materialType = this.querys.materialType; + // 同时设置对应的 itemType + if (this.querys.materialType === '成品') { + this.form.itemType = 'product'; + } else if (this.querys.materialType === '原料' || this.querys.materialType === '废品') { + this.form.itemType = 'raw_material'; + } + } + } + this.open = true; this.title = "修改钢卷物料"; }); diff --git a/klp-ui/src/views/wms/coil/product.vue b/klp-ui/src/views/wms/coil/product.vue index 1b0f8033..a1234828 100644 --- a/klp-ui/src/views/wms/coil/product.vue +++ b/klp-ui/src/views/wms/coil/product.vue @@ -15,7 +15,7 @@ export default { querys: { // itemType: 'product', dataType: 1, - materialType: '产品' + materialType: '成品' }, labelType: '3', showStatus: true,