|
@@ -443,64 +443,48 @@ export default {
|
|
const _this = this
|
|
const _this = this
|
|
this.$refs.ruleForm.validate(valid => {
|
|
this.$refs.ruleForm.validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
- // 验证必填
|
|
|
|
|
|
+ // 验证门槛必填
|
|
if (_this.form.gateFlag == '1') {
|
|
if (_this.form.gateFlag == '1') {
|
|
if (!_this.form.gateType) {
|
|
if (!_this.form.gateType) {
|
|
_this.$message.warning('请选择规则门槛设置类型!')
|
|
_this.$message.warning('请选择规则门槛设置类型!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if (!_this.form.gateValue) {
|
|
|
|
|
|
+ if (!_this.form.gateValue || (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount)) {
|
|
_this.$message.warning('规则门槛条件不能为空!')
|
|
_this.$message.warning('规则门槛条件不能为空!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
|
|
|
|
- _this.$message.warning('规则门槛条件不能为空!')
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if (_this.form.gateType == 'RATIO_AMOUNT') {
|
|
|
|
- _this.form.gateUnit = 'RATIO'
|
|
|
|
- } else if (_this.form.gateType == 'MIN_AMOUNT') {
|
|
|
|
- _this.form.gateUnit = 'YUAN'
|
|
|
|
- } else {
|
|
|
|
- _this.form.gateUnit = 'YUAN'
|
|
|
|
- _this.form.quotaUnit = 'YUAN'
|
|
|
|
- }
|
|
|
|
|
|
+ _this.form.gateUnit = _this.form.gateType === 'RATIO_AMOUNT' ? 'RATIO' : 'YUAN'
|
|
|
|
+ _this.form.quotaUnit = _this.form.gateType === 'FIXED_AMOUNT' ? 'YUAN' : undefined
|
|
}
|
|
}
|
|
- const hasNullVal = _this.fullGiftRuleList.some(itemVal => {
|
|
|
|
- if (itemVal.regularValue && itemVal.promotionValue) {
|
|
|
|
- return (itemVal.regularValue <= 0 || itemVal.promotionValue <= 0)
|
|
|
|
- } else {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ // 验证满赠必填
|
|
|
|
+ const hasNullVal = _this.fullGiftRuleList.some(itemVal => !itemVal.regularValue || !itemVal.promotionValue)
|
|
if (hasNullVal) {
|
|
if (hasNullVal) {
|
|
_this.$message.warning('满赠规则条件不能为空!')
|
|
_this.$message.warning('满赠规则条件不能为空!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 验证限制正价产品款数
|
|
if (_this.form.restrictFlag === '1' && !_this.form.restrictCategory) {
|
|
if (_this.form.restrictFlag === '1' && !_this.form.restrictCategory) {
|
|
- _this.$message.warning('请输入限制正价产品款数个数!')
|
|
|
|
|
|
+ _this.$message.warning('请输入限制正价产品款数!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 验证表格必填内容
|
|
var form = JSON.parse(JSON.stringify(_this.form))
|
|
var form = JSON.parse(JSON.stringify(_this.form))
|
|
- let rowFlag1, rowFlag2, rowFlag3
|
|
|
|
if (form.gateFlag == '1') { // 门槛产品
|
|
if (form.gateFlag == '1') { // 门槛产品
|
|
- form.gateProductList = this.$refs.cillProduct.getResultVal()
|
|
|
|
form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
|
|
form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
|
|
|
|
+ form.gateProductList = this.$refs.cillProduct.getResultVal()
|
|
if (form.gateProductList.length == 0) {
|
|
if (form.gateProductList.length == 0) {
|
|
_this.$message.warning('请添加门槛产品!')
|
|
_this.$message.warning('请添加门槛产品!')
|
|
return
|
|
return
|
|
} else {
|
|
} else {
|
|
- const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
|
|
|
|
- if (qtyFlag) {
|
|
|
|
- _this.$message.warning('订单起订量设置不能为空!')
|
|
|
|
|
|
+ if (_this.isJudge(form.gateProductList)) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- rowFlag1 = _this.isJudge(form.gateProductList)
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
form.gateProductList = []
|
|
form.gateProductList = []
|
|
form.gateType = undefined
|
|
form.gateType = undefined
|
|
}
|
|
}
|
|
|
|
+
|
|
// 正价产品
|
|
// 正价产品
|
|
form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
|
|
form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
|
|
// 判断表格必填
|
|
// 判断表格必填
|
|
@@ -508,52 +492,48 @@ export default {
|
|
_this.$message.warning('请添加正价产品!')
|
|
_this.$message.warning('请添加正价产品!')
|
|
return
|
|
return
|
|
} else {
|
|
} else {
|
|
- const qtyFlag = form.regularProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
|
|
|
|
- if (qtyFlag) {
|
|
|
|
- _this.$message.warning('订单起订量设置不能为空!')
|
|
|
|
|
|
+ if (_this.isJudge(form.regularProductList)) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- rowFlag2 = _this.isJudge(form.regularProductList)
|
|
|
|
}
|
|
}
|
|
- if (form.regularPromotionSameFlag === '0') { // 促销产品 阶梯促销产品
|
|
|
|
|
|
+
|
|
|
|
+ // 促销产品 阶梯促销产品
|
|
|
|
+ if (form.regularPromotionSameFlag === '0') {
|
|
const allGiftObj = {}
|
|
const allGiftObj = {}
|
|
_this.fullGiftRuleList.forEach((val, i) => {
|
|
_this.fullGiftRuleList.forEach((val, i) => {
|
|
allGiftObj['GIFT' + (i * 1 + 1)] = _this.$refs['offerProduct' + i][0].getResultVal()
|
|
allGiftObj['GIFT' + (i * 1 + 1)] = _this.$refs['offerProduct' + i][0].getResultVal()
|
|
})
|
|
})
|
|
|
|
+ // 促销产品 阶梯促销产品不为空
|
|
var lengthFlag = null
|
|
var lengthFlag = null
|
|
|
|
+ // 组数据,添加数组标识
|
|
|
|
+ let keyPos = 0
|
|
for (const key in allGiftObj) {
|
|
for (const key in allGiftObj) {
|
|
- if (allGiftObj[key].length === 0) {
|
|
|
|
- lengthFlag = true
|
|
|
|
- }
|
|
|
|
|
|
+ lengthFlag = !(allGiftObj[key] && allGiftObj[key].length)
|
|
|
|
+ keyPos += 1
|
|
|
|
+ allGiftObj[key].forEach((item, j) => {
|
|
|
|
+ item.scopeLevel = keyPos
|
|
|
|
+ })
|
|
}
|
|
}
|
|
if (lengthFlag) {
|
|
if (lengthFlag) {
|
|
_this.$message.warning('请添加促销产品!')
|
|
_this.$message.warning('请添加促销产品!')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 产品中分类、品牌或产品是否为空
|
|
const arrFlag = []
|
|
const arrFlag = []
|
|
for (const key in allGiftObj) {
|
|
for (const key in allGiftObj) {
|
|
if (allGiftObj[key] && allGiftObj[key].length > 0) {
|
|
if (allGiftObj[key] && allGiftObj[key].length > 0) {
|
|
arrFlag.push(_this.isJudge(allGiftObj[key]))
|
|
arrFlag.push(_this.isJudge(allGiftObj[key]))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- rowFlag3 = arrFlag.some(val => { return val })
|
|
|
|
- // 组数据,添加数组标识
|
|
|
|
- let keyPos = 0
|
|
|
|
- for (const key in allGiftObj) {
|
|
|
|
- keyPos += 1
|
|
|
|
- allGiftObj[key].forEach((item, j) => {
|
|
|
|
- item.scopeLevel = keyPos
|
|
|
|
- })
|
|
|
|
|
|
+ if (arrFlag.some(val => val)) {
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
+ // 赋值
|
|
form.giftProductMap = allGiftObj
|
|
form.giftProductMap = allGiftObj
|
|
} else {
|
|
} else {
|
|
form.giftProductMap = {}
|
|
form.giftProductMap = {}
|
|
}
|
|
}
|
|
|
|
|
|
- if (rowFlag1 || rowFlag2 || rowFlag3) {
|
|
|
|
- _this.$message.warning('请选择产品分类、品牌或产品!')
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
// 组传给后台所需数据
|
|
// 组传给后台所需数据
|
|
_this.fullGiftRuleList.map((val, i) => {
|
|
_this.fullGiftRuleList.map((val, i) => {
|
|
val.scopeLevel = i * 1 + 1
|
|
val.scopeLevel = i * 1 + 1
|
|
@@ -601,26 +581,15 @@ export default {
|
|
// 判断品牌,分类,产品其中一个必填
|
|
// 判断品牌,分类,产品其中一个必填
|
|
isJudge (list) {
|
|
isJudge (list) {
|
|
let flag = null
|
|
let flag = null
|
|
- list.forEach(con => {
|
|
|
|
- if (con.productThisList) {
|
|
|
|
- if (con.productThisList.length > 0) {
|
|
|
|
- flag = false
|
|
|
|
- } else {
|
|
|
|
- if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
|
|
|
|
- flag = false
|
|
|
|
- } else {
|
|
|
|
- flag = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
|
|
|
|
- flag = false
|
|
|
|
- } else {
|
|
|
|
- flag = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- return flag
|
|
|
|
|
|
+ let flag1 = null
|
|
|
|
+ flag = list.some(con => !(con.productThisList && con.productThisList.length) && !(con.productTypeList && con.productTypeList.length) && !(con.productBrandList && con.productBrandList.length))
|
|
|
|
+ flag1 = list.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
|
|
|
|
+ if (flag) {
|
|
|
|
+ this.$message.warning('请选择产品分类、品牌或产品!')
|
|
|
|
+ } else if (flag1) {
|
|
|
|
+ this.$message.warning('订单起订量设置不能为空!')
|
|
|
|
+ }
|
|
|
|
+ return flag || flag1
|
|
},
|
|
},
|
|
// 重置表格
|
|
// 重置表格
|
|
resetSearchForm () {
|
|
resetSearchForm () {
|