前端修改
This commit is contained in:
@@ -167,18 +167,19 @@
|
||||
<el-form-item label="班组" prop="team">
|
||||
<el-input v-model="form.team" placeholder="请输入班组" />
|
||||
</el-form-item>
|
||||
<el-form-item label="物料类型" prop="itemType">
|
||||
<el-select v-model="form.itemType" placeholder="请选择物料类型" @change="form.itemId = undefined">
|
||||
<el-option label="成品" value="product" />
|
||||
<el-option label="原料" value="raw_material" />
|
||||
<el-form-item label="材料类型" prop="materialType">
|
||||
<el-select v-model="form.materialType" placeholder="请选择材料类型" @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">
|
||||
<product-select v-if="form.itemType == 'product'" v-model="form.itemId" placeholder="请选择成品ID"
|
||||
<el-form-item :label="getItemLabel" prop="itemId">
|
||||
<product-select v-if="form.itemType == 'product'" v-model="form.itemId" placeholder="请选择成品"
|
||||
style="width: 100%;" clearable />
|
||||
<raw-material-select v-else-if="form.itemType == 'raw_material'" v-model="form.itemId" placeholder="请选择原料ID"
|
||||
<raw-material-select v-else-if="form.itemType == 'raw_material'" v-model="form.itemId" placeholder="请选择原料"
|
||||
style="width: 100%;" clearable />
|
||||
<div v-else>请先选择物料类型</div>
|
||||
<div v-else>请先选择材料类型</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="毛重" prop="grossWeight">
|
||||
<el-input v-model="form.grossWeight" placeholder="请输入毛重" />
|
||||
@@ -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 = "修改钢卷物料";
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ export default {
|
||||
querys: {
|
||||
// itemType: 'product',
|
||||
dataType: 1,
|
||||
materialType: '产品'
|
||||
materialType: '成品'
|
||||
},
|
||||
labelType: '3',
|
||||
showStatus: true,
|
||||
|
||||
Reference in New Issue
Block a user