feat(material): 添加物料大类变更监听和事务处理
- 在物料表单中为物料大类选择器添加 change 事件监听器 - 将原有的 watch 监听器转换为 handleMatCateChange 方法实
This commit is contained in:
parent
3bdd9ff957
commit
3a7ab2a130
@ -97,6 +97,7 @@ public class MaterialServiceImpl implements MaterialService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createMaterial(MaterialSaveReqVO createReqVO) {
|
public Long createMaterial(MaterialSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
MaterialDO material = BeanUtils.toBean(createReqVO, MaterialDO.class);
|
MaterialDO material = BeanUtils.toBean(createReqVO, MaterialDO.class);
|
||||||
@ -119,7 +120,8 @@ public class MaterialServiceImpl implements MaterialService {
|
|||||||
|
|
||||||
// 回写序列记录
|
// 回写序列记录
|
||||||
// serialNumberService.updateSerialNumber(serialNumberDO);
|
// serialNumberService.updateSerialNumber(serialNumberDO);
|
||||||
|
// 更新物料大类最大流水
|
||||||
|
matCodeService.updateCurMaxSeq(material.getMatCate(),material.getCode());
|
||||||
// 返回
|
// 返回
|
||||||
return material.getId();
|
return material.getId();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="物料大类" prop="matCate">
|
<el-form-item label="物料大类" prop="matCate">
|
||||||
<el-select v-model="formData.matCate" clearable placeholder="请选择物料大类" class="!w-250px">
|
<el-select v-model="formData.matCate" clearable placeholder="请选择物料大类" class="!w-250px" @change="handleMatCateChange">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getStrDictOptions(DICT_TYPE.HELI_MATERIAL_CODE)"
|
v-for="dict in getStrDictOptions(DICT_TYPE.HELI_MATERIAL_CODE)"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
@ -291,22 +291,14 @@ const handleSelectedSupplier = (newValue: any) => {
|
|||||||
formData.value.mainSupplierId = newValue?.id
|
formData.value.mainSupplierId = newValue?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听物料类型变化,查询matcode并更新code */
|
/** 物料大类改变事件,查询matcode并更新code */
|
||||||
watch(() => formData.value.matCate, async (newVal) => {
|
const handleMatCateChange = async (newVal: string) => {
|
||||||
// 如果未初始化完成,不处理
|
|
||||||
if (!isInitialized.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果新值为空,清空编码
|
// 如果新值为空,清空编码
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
formData.value.code = undefined
|
formData.value.code = undefined
|
||||||
originalMatCate.value = undefined
|
originalMatCate.value = undefined
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 如果值没有变化(用户选择的是同一个值),不更新编码
|
|
||||||
if (newVal === originalMatCate.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const allData = await getMatCatCode(newVal)
|
const allData = await getMatCatCode(newVal)
|
||||||
if (allData != null) {
|
if (allData != null) {
|
||||||
@ -319,10 +311,7 @@ watch(() => formData.value.matCate, async (newVal) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('查询matcode失败:', error)
|
console.error('查询matcode失败:', error)
|
||||||
formData.value.code = null
|
formData.value.code = null
|
||||||
|
|
||||||
// 提示该物料大类没有维护物料大类编码,请维护!
|
|
||||||
// message.error('该物料大类没有维护物料大类编码,请维护!')
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user