fix(wms): 修复原材料选择和表单字段禁用状态问题

修复原材料选择组件中ID比较类型不一致导致的选择问题,移除表单中成品相关字段的禁用状态限制,并初始化表单默认值
This commit is contained in:
砂糖
2025-11-20 15:53:45 +08:00
parent 5bfa264021
commit dcf33da35c
2 changed files with 26 additions and 19 deletions

View File

@@ -129,6 +129,7 @@ export default {
// 如果为选中任何原材料,显示选择原材料
// 如果为选中多个原材料,显示已选 X 项
// 如果为选中单个原材料,显示原材料名称
console.log(this.selectedIds);
if (this.selectedIds.length === 0) {
return '请选择原材料';
}
@@ -146,12 +147,14 @@ export default {
} else {
return this.selectedRows[0]?.rawMaterialName || '未选择';
}
}
},
},
watch: {
value: {
immediate: true,
handler(val) {
console.log('watch触发val', val);
this.selectedIds = val ? val.split(',').filter(id => id) : [];
// this.syncSelectedRows();
this.$forceUpdate(); // 新增:强制刷新视图
@@ -169,22 +172,13 @@ export default {
return this.selectedIds.includes(rawMaterialId);
},
// 同步选中行数据
// syncSelectedRows() {
// if (this.rawMaterialList.length === 0) return;
// this.selectedRows = this.rawMaterialList.filter(item =>
// this.selectedIds.includes(item.rawMaterialId)
// );
// },
// 卡片选择事件(多选)
handleCardSelection(checked, item) {
if (checked) {
!this.selectedIds.includes(item.rawMaterialId) && this.selectedIds.push(item.rawMaterialId);
} else {
this.selectedIds = this.selectedIds.filter(id => id !== item.rawMaterialId);
this.selectedIds = this.selectedIds.filter(id => id != item.rawMaterialId);
}
// this.syncSelectedRows();
},
// 原有方法保持不变(仅修改同步选中状态逻辑)
@@ -194,9 +188,11 @@ export default {
const params = { ...this.queryParams, ...this.filters };
const response = await listRawMaterial(params);
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
this.rawMaterialList = response.rows.map(item => ({
...item,
rawMaterialId: item.rawMaterialId.toString()
})) || [];
this.total = response.total || 0;
// this.syncSelectedRows(); // 加载数据后同步选中状态
}
return this.rawMaterialList;
} catch (error) {
@@ -252,7 +248,6 @@ export default {
const emitValue = this.selectedIds.join(',');
this.$emit('input', emitValue);
this.$emit('change', emitValue, this.selectedRows);
this.$forceUpdate(); // 新增:强制刷新视图
this.dialogVisible = false;
},