app三级后端修改
This commit is contained in:
@@ -93,20 +93,37 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="物品类型" prop="itemType">
|
||||
<el-select v-model="updateForm.itemType" placeholder="请选择物品类型" style="width: 100%" :disabled="readonly">
|
||||
<el-option label="原材料" value="raw_material" />
|
||||
<el-option label="产品" value="product" />
|
||||
<el-form-item label="材料类型" prop="materialType">
|
||||
<el-select
|
||||
v-model="updateForm.materialType"
|
||||
placeholder="请选择材料类型"
|
||||
style="width: 100%"
|
||||
:disabled="readonly"
|
||||
@change="handleMaterialTypeChange">
|
||||
<el-option label="原料" value="原料" />
|
||||
<el-option label="成品" value="成品" />
|
||||
<el-option label="废品" value="废品" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="物品" prop="itemId">
|
||||
<el-select v-model="updateForm.itemId" placeholder="请选择物品" filterable remote :remote-method="searchItems"
|
||||
:loading="itemSearchLoading" style="width: 100%" :disabled="readonly">
|
||||
<!-- 物品类型由材料类型自动决定,不显示选择框 -->
|
||||
|
||||
<el-form-item
|
||||
:label="getItemLabel"
|
||||
:prop="updateForm.materialType === '废品' ? '' : 'itemId'"
|
||||
:rules="updateForm.materialType === '废品' ? [] : rules.itemId">
|
||||
<el-select
|
||||
v-model="updateForm.itemId"
|
||||
:placeholder="getItemPlaceholder"
|
||||
filterable
|
||||
remote
|
||||
:remote-method="searchItems"
|
||||
:loading="itemSearchLoading"
|
||||
style="width: 100%"
|
||||
:disabled="readonly || !updateForm.materialType">
|
||||
<el-option v-for="item in currentItemList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<MaterialSelect :hideType="hideType" :itemId.sync="updateForm.itemId" :itemType.sync="updateForm.itemType" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="毛重(t)" prop="grossWeight">
|
||||
<el-input v-model.number="updateForm.grossWeight" placeholder="请输入毛重" type="number" step="0.01"
|
||||
@@ -192,13 +209,11 @@ import { listWarehouse } from '@/api/wms/warehouse';
|
||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
||||
import { listProduct } from '@/api/wms/product';
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
import MaterialSelect from "@/components/KLPService/MaterialSelect";
|
||||
|
||||
export default {
|
||||
name: 'TypingCoil',
|
||||
components: {
|
||||
ActualWarehouseSelect,
|
||||
MaterialSelect
|
||||
ActualWarehouseSelect
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -226,6 +241,7 @@ export default {
|
||||
updateForm: {
|
||||
currentCoilNo: '',
|
||||
team: '',
|
||||
materialType: null,
|
||||
itemType: null,
|
||||
itemId: null,
|
||||
grossWeight: null,
|
||||
@@ -241,6 +257,9 @@ export default {
|
||||
team: [
|
||||
{ required: true, message: '请输入班组', trigger: 'blur' }
|
||||
],
|
||||
materialType: [
|
||||
{ required: true, message: '请选择材料类型', trigger: 'change' }
|
||||
],
|
||||
itemType: [
|
||||
{ required: true, message: '请选择物品类型', trigger: 'change' }
|
||||
],
|
||||
@@ -274,6 +293,26 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 动态显示标签
|
||||
getItemLabel() {
|
||||
if (this.updateForm.materialType === '成品') {
|
||||
return '产品类型';
|
||||
} else if (this.updateForm.materialType === '原料' || this.updateForm.materialType === '废品') {
|
||||
return '原料类型';
|
||||
}
|
||||
return '物品';
|
||||
},
|
||||
// 动态显示占位符
|
||||
getItemPlaceholder() {
|
||||
if (this.updateForm.materialType === '成品') {
|
||||
return '请选择产品类型';
|
||||
} else if (this.updateForm.materialType === '原料') {
|
||||
return '请选择原料类型';
|
||||
} else if (this.updateForm.materialType === '废品') {
|
||||
return '请选择原料类型(非必填)';
|
||||
}
|
||||
return '请先选择材料类型';
|
||||
},
|
||||
// 当前物品列表(根据物品类型动态切换)
|
||||
currentItemList() {
|
||||
if (this.updateForm.itemType === 'raw_material') {
|
||||
@@ -291,18 +330,50 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 监听材料类型变化,自动设置物料类型
|
||||
'updateForm.materialType'(newVal, oldVal) {
|
||||
console.log('🔥 typing.vue watch 触发! materialType 变化:', oldVal, '->', newVal);
|
||||
|
||||
// 先清空物品选择
|
||||
this.$set(this.updateForm, 'itemId', null);
|
||||
|
||||
// 设置物料类型
|
||||
if (newVal === '成品') {
|
||||
this.$set(this.updateForm, 'itemType', 'product');
|
||||
console.log('✅ 设置 itemType = product');
|
||||
} else if (newVal === '原料' || newVal === '废品') {
|
||||
this.$set(this.updateForm, 'itemType', 'raw_material');
|
||||
console.log('✅ 设置 itemType = raw_material');
|
||||
}
|
||||
|
||||
console.log('📊 当前 updateForm:', {
|
||||
materialType: this.updateForm.materialType,
|
||||
itemType: this.updateForm.itemType,
|
||||
itemId: this.updateForm.itemId
|
||||
});
|
||||
|
||||
console.log('📦 数据列表:', {
|
||||
rawMaterialList: this.rawMaterialList.length,
|
||||
productList: this.productList.length
|
||||
});
|
||||
},
|
||||
// 监听物品类型变化,加载对应的列表
|
||||
'updateForm.itemType'(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
if (newVal !== oldVal && newVal) {
|
||||
this.updateForm.itemId = null;
|
||||
this.loadItemList(newVal);
|
||||
}
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
console.log('🚀 typing.vue created 钩子执行');
|
||||
|
||||
// 先加载库区列表
|
||||
await this.loadWarehouses();
|
||||
|
||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
||||
await this.loadAllItems();
|
||||
|
||||
// 从路由参数获取coilId和actionId
|
||||
const coilId = this.$route.query.coilId;
|
||||
const actionId = this.$route.query.actionId;
|
||||
@@ -451,9 +522,38 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 页面加载时一次性加载所有原料和产品列表
|
||||
async loadAllItems() {
|
||||
console.log('🔥 开始加载所有物品列表');
|
||||
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('✅ 原材料列表加载成功,数量:', this.rawMaterialList.length);
|
||||
}
|
||||
|
||||
if (productRes.code === 200) {
|
||||
this.productList = productRes.rows || [];
|
||||
console.log('✅ 产品列表加载成功,数量:', this.productList.length);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 加载物品列表失败', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载物品列表(根据类型)
|
||||
async loadItemList(itemType) {
|
||||
if (!itemType) return;
|
||||
if (!itemType) {
|
||||
console.log('loadItemList: itemType 为空');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('开始加载物品列表,类型:', itemType);
|
||||
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
@@ -464,8 +564,10 @@ export default {
|
||||
pageSize: 100,
|
||||
withBom: true // 请求包含BOM信息
|
||||
});
|
||||
console.log('原材料列表响应:', response);
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
console.log('原材料列表加载成功,数量:', this.rawMaterialList.length);
|
||||
}
|
||||
} else if (itemType === 'product') {
|
||||
// 使用带BOM的接口
|
||||
@@ -474,8 +576,10 @@ export default {
|
||||
pageSize: 100,
|
||||
withBom: true // 请求包含BOM信息
|
||||
});
|
||||
console.log('产品列表响应:', response);
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
console.log('产品列表加载成功,数量:', this.productList.length);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -488,7 +592,7 @@ export default {
|
||||
// 搜索物品(支持名称和规格搜索)
|
||||
async searchItems(query) {
|
||||
if (!this.updateForm.itemType) {
|
||||
this.$message.warning('请先选择物品类型');
|
||||
this.$message.warning('请先选择材料类型');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -561,8 +665,10 @@ export default {
|
||||
this.updateForm = {
|
||||
currentCoilNo: this.currentInfo.currentCoilNo,
|
||||
team: this.currentInfo.team,
|
||||
itemType: this.currentInfo.itemType,
|
||||
itemId: this.currentInfo.itemId,
|
||||
materialType: this.currentInfo.materialType,
|
||||
// 不复制 itemType 和 itemId,让它们由 materialType 自动决定
|
||||
itemType: null,
|
||||
itemId: null,
|
||||
grossWeight: parseFloat(this.currentInfo.grossWeight) || null,
|
||||
netWeight: parseFloat(this.currentInfo.netWeight) || null,
|
||||
warehouseId: this.currentInfo.warehouseId,
|
||||
@@ -571,11 +677,7 @@ export default {
|
||||
|
||||
console.log('复制的表单数据:', this.updateForm);
|
||||
|
||||
// 加载对应的物品列表
|
||||
if (this.updateForm.itemType) {
|
||||
this.loadItemList(this.updateForm.itemType);
|
||||
}
|
||||
|
||||
// materialType 会触发 watch,自动设置 itemType 并加载物品列表
|
||||
this.$message.success('已复制当前信息');
|
||||
},
|
||||
|
||||
@@ -602,6 +704,7 @@ export default {
|
||||
supplierCoilNo: this.currentInfo.supplierCoilNo,
|
||||
currentCoilNo: this.updateForm.currentCoilNo,
|
||||
team: this.updateForm.team,
|
||||
materialType: this.updateForm.materialType,
|
||||
itemType: this.updateForm.itemType,
|
||||
itemId: this.updateForm.itemId,
|
||||
grossWeight: this.updateForm.grossWeight,
|
||||
|
||||
Reference in New Issue
Block a user