增加商品校验
This commit is contained in:
@@ -125,7 +125,7 @@ const queryMaterialCategoryById = (params)=>getAction("/materialCategory/findByI
|
|||||||
//商品管理
|
//商品管理
|
||||||
const addMaterial = (params)=>postAction("/material/add",params);
|
const addMaterial = (params)=>postAction("/material/add",params);
|
||||||
const editMaterial = (params)=>putAction("/material/update",params);
|
const editMaterial = (params)=>putAction("/material/update",params);
|
||||||
const checkMaterial = (params)=>getAction("/material/checkIsNameExist",params);
|
const checkMaterial = (params)=>getAction("/material/checkIsExist",params);
|
||||||
const getMaterialBySelect = (params)=>getAction("/material/findBySelect",params);
|
const getMaterialBySelect = (params)=>getAction("/material/findBySelect",params);
|
||||||
const getSerialMaterialBySelect = (params)=>getAction("/material/getMaterialEnableSerialNumberList",params);
|
const getSerialMaterialBySelect = (params)=>getAction("/material/getMaterialEnableSerialNumberList",params);
|
||||||
const getMaterialByBarCode = (params)=>getAction("/material/getMaterialByBarCode",params);
|
const getMaterialByBarCode = (params)=>getAction("/material/getMaterialByBarCode",params);
|
||||||
|
|||||||
@@ -230,8 +230,7 @@
|
|||||||
name:{
|
name:{
|
||||||
rules: [
|
rules: [
|
||||||
{ required: true, message: '请输入名称!' },
|
{ required: true, message: '请输入名称!' },
|
||||||
{ min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
|
{ min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' }
|
||||||
{ validator: this.validateMaterialName}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
unit:{
|
unit:{
|
||||||
@@ -362,6 +361,7 @@
|
|||||||
stock: allValues.tablesValue[1].values,
|
stock: allValues.tablesValue[1].values,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 发起新增或修改的请求 */
|
/** 发起新增或修改的请求 */
|
||||||
requestAddOrEdit(formData) {
|
requestAddOrEdit(formData) {
|
||||||
if(formData.unit === '' && formData.unitId === '') {
|
if(formData.unit === '' && formData.unitId === '') {
|
||||||
@@ -372,6 +372,26 @@
|
|||||||
this.$message.warning('抱歉,请输入条码信息!');
|
this.$message.warning('抱歉,请输入条码信息!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//校验商品是否存在,通过校验商品的名称、型号、规格、颜色、单位、制造商等
|
||||||
|
let param = {
|
||||||
|
id: this.model.id?this.model.id:0,
|
||||||
|
name: this.model.name,
|
||||||
|
model: this.parseParam(this.model.model),
|
||||||
|
color: this.parseParam(this.model.color),
|
||||||
|
standard: this.parseParam(this.model.standard),
|
||||||
|
mfrs: this.parseParam(this.model.mfrs),
|
||||||
|
otherField1: this.parseParam(this.model.otherField1),
|
||||||
|
otherField2: this.parseParam(this.model.otherField2),
|
||||||
|
otherField3: this.parseParam(this.model.otherField3),
|
||||||
|
unit: this.parseParam(this.model.unit),
|
||||||
|
unitId: this.parseParam(this.model.unitId)
|
||||||
|
}
|
||||||
|
checkMaterial(param).then((res)=>{
|
||||||
|
if(res && res.code===200) {
|
||||||
|
if(res.data.status){
|
||||||
|
this.$message.warning('抱歉,该商品已存在!');
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
//进一步校验单位
|
//进一步校验单位
|
||||||
let manyUnitselected = ''
|
let manyUnitselected = ''
|
||||||
if(formData.unitId) {
|
if(formData.unitId) {
|
||||||
@@ -435,23 +455,12 @@
|
|||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
validateMaterialName(rule, value, callback){
|
parseParam(param) {
|
||||||
let params = {
|
return param ? param: ""
|
||||||
name: value,
|
|
||||||
id: this.model.id?this.model.id:0
|
|
||||||
};
|
|
||||||
checkMaterial(params).then((res)=>{
|
|
||||||
if(res && res.code===200) {
|
|
||||||
if(!res.data.status){
|
|
||||||
callback();
|
|
||||||
} else {
|
|
||||||
callback("名称已经存在");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
callback(res.data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
validateBarCode(type, value, row, column, callback, target) {
|
validateBarCode(type, value, row, column, callback, target) {
|
||||||
let params = {
|
let params = {
|
||||||
|
|||||||
Reference in New Issue
Block a user