Commit 17f3f7db authored by dragondean@qq.com's avatar dragondean@qq.com

完善阶梯价组件的错误提示

parent b1a8a0e0
......@@ -98,32 +98,34 @@ export default {
},
// 校验
validate(){
let valid = true
const index = this.index
const errors = []
// 区间设置检查
if(index > 0 && !this.value.startNum){
valid = false
this.$message.error(`请设置第${index+1}阶段的起始值`)
errors.push(`请设置${this.priceName}${index+1}阶段的起始值`)
}
if(!this.value.endNum){
valid = false
this.$message.error(`请设置第${index+1}阶段的结束值`)
errors.push(`请设置${this.priceName}${index+1}阶段的结束值`)
}
// 价格检查
if(!this.validatePrice(this.value[`${this.fieldPrefix}Price`])){
valid = false
this.$message.error(`请设置第${index+1}阶段的${this.priceName}`)
errors.push(`请设置第${index+1}阶段的${this.priceName}`)
}
// 包装价格检查
if(this.value.packagingList?.length){
this.value.packagingList.forEach((item, i) => {
if(item.packagingTypes?.length && !this.validatePrice(item.packagingPrice)){
valid = false
this.$message.error(`请设置第${index+1}阶段的包装类型${i+1}${this.priceName}`)
errors.push(`请设置第${index+1}阶段的包装类型${i+1}${this.priceName}`)
}
})
}
return valid
if(errors.length){
this.$notify.error({
title: this.$t("表单错误"),
message: errors.join(';\n')
});
}
return !errors.length
},
// 校验价格是否为空,可以是0
validatePrice(value){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment