给商品页面增加非空判断

This commit is contained in:
季圣华
2021-06-03 00:09:18 +08:00
parent faf5710133
commit 25b5680b80
2 changed files with 30 additions and 55 deletions

View File

@@ -187,7 +187,7 @@
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
align:"center", align:"center",
width: 100, width: 120,
fixed: 'right', fixed: 'right',
scopedSlots: { customRender: 'action' }, scopedSlots: { customRender: 'action' },
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<a-modal <a-modal
:title="title" :title="title"
:width="1000" :width="1200"
:visible="visible" :visible="visible"
:confirmLoading="confirmLoading" :confirmLoading="confirmLoading"
@ok="handleOk" @ok="handleOk"
@@ -188,53 +188,24 @@
dataSource: [], dataSource: [],
columns: [ columns: [
{ {
title: '条码', title: '条码', key: 'barCode', width: '30%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}',
key: 'barCode',
width: '30%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}',
validateRules: [{ required: true, message: '${title}不能为空' }] validateRules: [{ required: true, message: '${title}不能为空' }]
}, },
{ {
title: '单位', title: '单位', key: 'commodityUnit', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}',
key: 'commodityUnit', validateRules: [{ required: true, message: '${title}不能为空' }]
width: '12%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
}, },
{ {
title: '采购价', title: '采购价', key: 'purchaseDecimal', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}'
key: 'purchaseDecimal',
width: '12%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
}, },
{ {
title: '零售价', title: '零售价', key: 'commodityDecimal', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}'
key: 'commodityDecimal',
width: '12%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
}, },
{ {
title: '销售价', title: '销售价', key: 'wholesaleDecimal', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}'
key: 'wholesaleDecimal',
width: '12%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
}, },
{ {
title: '最低售价', title: '最低售价', key: 'lowDecimal', width: '12%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}'
key: 'lowDecimal',
width: '12%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
} }
] ]
}, },
@@ -243,18 +214,10 @@
dataSource: [], dataSource: [],
columns: [ columns: [
{ {
title: '仓库', title: '仓库', key: 'name', width: '15%', type: FormTypes.normal
key: 'name',
width: '15%',
type: FormTypes.normal
}, },
{ {
title: '库存数量', title: '库存数量', key: 'initStock', width: '15%', type: FormTypes.input, defaultValue: '', placeholder: '请输入${title}'
key: 'initStock',
width: '15%',
type: FormTypes.input,
defaultValue: '',
placeholder: '请输入${title}'
} }
] ]
}, },
@@ -267,6 +230,11 @@
{ min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' }, { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
{ validator: this.validateMaterialName} { validator: this.validateMaterialName}
] ]
},
unit:{
rules: [
{ required: true, message: '请输入单位!' }
]
} }
}, },
url: { url: {
@@ -368,11 +336,9 @@
}).then(allValues => { }).then(allValues => {
let formData = this.classifyIntoFormData(allValues) let formData = this.classifyIntoFormData(allValues)
formData.sortList = []; formData.sortList = [];
if(this.unitChecked){ if(formData.unit === undefined) {formData.unit = ''}
formData.unit = '' if(formData.unitId === undefined) {formData.unitId = ''}
} else { if(this.unitChecked) {formData.unit = ''} else {formData.unitId = ''}
formData.unitId = ''
}
// 发起请求 // 发起请求
return this.requestAddOrEdit(formData) return this.requestAddOrEdit(formData)
}).catch(e => { }).catch(e => {
@@ -395,6 +361,14 @@
}, },
/** 发起新增或修改的请求 */ /** 发起新增或修改的请求 */
requestAddOrEdit(formData) { requestAddOrEdit(formData) {
if(formData.unit === '' && formData.unitId === '') {
this.$message.warning('抱歉,单位为必填项!');
return;
}
if(formData.meList.length === 0) {
this.$message.warning('抱歉,请输入条码信息!');
return;
}
let url = this.url.add, method = 'post' let url = this.url.add, method = 'post'
if (this.model.id) { if (this.model.id) {
url = this.url.edit url = this.url.edit
@@ -405,12 +379,13 @@
httpAction(url, formData, method).then((res) => { httpAction(url, formData, method).then((res) => {
if(res.code === 200){ if(res.code === 200){
that.$emit('ok'); that.$emit('ok');
that.confirmLoading = false
that.close();
}else{ }else{
that.$message.warning(res.data.message); that.$message.warning(res.data.message);
that.confirmLoading = false
} }
}).finally(() => { }).finally(() => {
that.confirmLoading = false
that.close();
}) })
}, },
validateMaterialName(rule, value, callback){ validateMaterialName(rule, value, callback){