app三级后端修改

This commit is contained in:
2025-11-11 12:21:16 +08:00
parent c78790919b
commit 86297ee681
7 changed files with 462 additions and 86 deletions

View File

@@ -147,22 +147,25 @@
<el-form-item label="班组">
<el-input v-model="targetCoil.team" placeholder="请输入班组名称" :disabled="readonly"></el-input>
</el-form-item>
<el-form-item label="物品类型">
<el-select v-model="targetCoil.itemType" placeholder="请选择物品类型" style="width: 100%" :disabled="readonly">
<el-option label="原料" value="raw_material" />
<el-option label="品" value="product" />
<el-form-item label="材料类型">
<el-select v-model="targetCoil.materialType" placeholder="请选择材料类型" style="width: 100%" :disabled="readonly">
<el-option label="原料" value="原料" />
<el-option label="品" value="成品" />
<el-option label="废品" value="废品" />
</el-select>
</el-form-item>
<el-form-item label="物品">
<!-- 物品类型由材料类型自动联动隐藏此选择框 -->
<el-form-item :label="getItemLabel">
<el-select
v-model="targetCoil.itemId"
placeholder="请选择物品"
:placeholder="getItemPlaceholder"
filterable
remote
:remote-method="searchItems"
:loading="itemSearchLoading"
style="width: 100%"
:disabled="readonly"
:disabled="readonly || !targetCoil.materialType"
>
<el-option
v-for="item in currentItemList"
@@ -264,6 +267,7 @@ export default {
targetCoil: {
currentCoilNo: '',
team: '',
materialType: null,
itemType: null,
itemId: null,
grossWeight: null,
@@ -290,6 +294,26 @@ export default {
};
},
computed: {
// 动态显示标签
getItemLabel() {
if (this.targetCoil.materialType === '成品') {
return '产品类型';
} else if (this.targetCoil.materialType === '原料' || this.targetCoil.materialType === '废品') {
return '原料类型';
}
return '物品';
},
// 动态显示占位符
getItemPlaceholder() {
if (this.targetCoil.materialType === '成品') {
return '请选择产品类型';
} else if (this.targetCoil.materialType === '原料') {
return '请选择原料类型';
} else if (this.targetCoil.materialType === '废品') {
return '请选择原料类型(非必填)';
}
return '请先选择材料类型';
},
// 当前物品列表(根据物品类型动态切换)
currentItemList() {
if (this.targetCoil.itemType === 'raw_material') {
@@ -307,18 +331,50 @@ export default {
}
},
watch: {
// 监听材料类型变化,自动设置物料类型
'targetCoil.materialType'(newVal, oldVal) {
console.log('🔥 merge.vue watch 触发! materialType 变化:', oldVal, '->', newVal);
// 先清空物品选择
this.$set(this.targetCoil, 'itemId', null);
// 设置物料类型
if (newVal === '成品') {
this.$set(this.targetCoil, 'itemType', 'product');
console.log('✅ 设置 itemType = product');
} else if (newVal === '原料' || newVal === '废品') {
this.$set(this.targetCoil, 'itemType', 'raw_material');
console.log('✅ 设置 itemType = raw_material');
}
console.log('📊 当前 targetCoil:', {
materialType: this.targetCoil.materialType,
itemType: this.targetCoil.itemType,
itemId: this.targetCoil.itemId
});
console.log('📦 数据列表:', {
rawMaterialList: this.rawMaterialList.length,
productList: this.productList.length
});
},
// 监听物品类型变化,加载对应的列表
'targetCoil.itemType'(newVal, oldVal) {
if (newVal !== oldVal) {
if (newVal !== oldVal && newVal) {
this.targetCoil.itemId = null; // 清空物品ID
this.loadItemList(newVal);
}
}
},
async created() {
console.log('🚀 merge.vue created 钩子执行');
// 加载库区列表
await this.loadWarehouses();
// 🔥 页面加载时直接加载所有原料和产品列表
await this.loadAllItems();
// 从路由参数获取coilId、actionId和readonly
const coilId = this.$route.query.coilId;
const actionId = this.$route.query.actionId;
@@ -567,9 +623,38 @@ export default {
}
},
// 页面加载时一次性加载所有原料和产品列表
async loadAllItems() {
console.log('🔥 merge.vue 开始加载所有物品列表');
try {
// 同时加载原料和产品
const [rawMaterialRes, productRes] = await Promise.all([
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
]);
if (rawMaterialRes.code === 200) {
this.rawMaterialList = rawMaterialRes.rows || [];
console.log('✅ merge.vue 原材料列表加载成功,数量:', this.rawMaterialList.length);
}
if (productRes.code === 200) {
this.productList = productRes.rows || [];
console.log('✅ merge.vue 产品列表加载成功,数量:', this.productList.length);
}
} catch (error) {
console.error('❌ merge.vue 加载物品列表失败', error);
}
},
// 加载物品列表(根据类型)
async loadItemList(itemType) {
if (!itemType) return;
if (!itemType) {
console.log('merge.vue loadItemList: itemType 为空');
return;
}
console.log('merge.vue 开始加载物品列表,类型:', itemType);
try {
this.itemSearchLoading = true;
@@ -579,8 +664,10 @@ export default {
pageSize: 100,
withBom: true
});
console.log('merge.vue 原材料列表响应:', response);
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
console.log('merge.vue 原材料列表加载成功,数量:', this.rawMaterialList.length);
}
} else if (itemType === 'product') {
const response = await listProduct({
@@ -588,12 +675,14 @@ export default {
pageSize: 100,
withBom: true
});
console.log('merge.vue 产品列表响应:', response);
if (response.code === 200) {
this.productList = response.rows || [];
console.log('merge.vue 产品列表加载成功,数量:', this.productList.length);
}
}
} catch (error) {
console.error('加载物品列表失败', error);
console.error('merge.vue 加载物品列表失败', error);
} finally {
this.itemSearchLoading = false;
}
@@ -602,7 +691,7 @@ export default {
// 搜索物品
async searchItems(query) {
if (!this.targetCoil.itemType) {
this.$message.warning('请先选择物品类型');
this.$message.warning('请先选择材料类型');
return;
}
@@ -745,6 +834,7 @@ export default {
enterCoilNo: enterCoilNos, // 拼接的入场钢卷号
currentCoilNo: this.targetCoil.currentCoilNo,
team: this.targetCoil.team,
materialType: this.targetCoil.materialType,
itemType: this.targetCoil.itemType,
itemId: this.targetCoil.itemId,
grossWeight: this.targetCoil.grossWeight,