소스 검색

Merge branch 'develop_yh50' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into develop_yh50

lilei 7 달 전
부모
커밋
fef6513001

+ 0 - 9
src/views/promotionRulesManagement/dealerPromotions/list.vue

@@ -52,15 +52,6 @@
               <span class="table-page-search-submitButtons">
                 <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionList-refresh">查询</a-button>
                 <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="promotionList-reset">重置</a-button>
-                <!-- <a-button
-                  style="margin-left: 10px"
-                  type="primary"
-                  class="button-warning"
-                  @click="handleExport"
-                  :disabled="disabled"
-                  :loading="exportLoading"
-                >导出</a-button> -->
-                <!-- v-if="$hasPermissions('B_promotionListExport')" -->
               </span>
             </a-col>
           </a-row>

+ 29 - 84
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -429,66 +429,33 @@ export default {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          // 验证必填
+          // 验证规则门槛必填
           if (_this.form.gateFlag == '1') {
             if (!_this.form.gateType) {
               _this.$message.warning('请选择规则门槛设置类型!')
               return
             }
-            if (!_this.form.gateValue) {
+            if (!_this.form.gateValue || (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount)) {
               _this.$message.warning('规则门槛条件不能为空!')
               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
           }
-          if (_this.form.giveRuleType == 'SUM_MONEY') {
-            if (!_this.fullGiftRuleList[0].regularValue || _this.fullGiftRuleList[0].regularValue <= 0) {
-              _this.$message.warning('满赠规则条件不能为空!')
-              return
-            }
-            if (!_this.fullGiftRuleList[0].promotionValue || _this.fullGiftRuleList[0].promotionValue <= 0) {
-              _this.$message.warning('满赠规则条件不能为空!')
-              return
-            }
-          } else {
-            const hasNullVal = _this.fullGiftRuleList.some(itemVal => {
-              if (itemVal.regularValue && itemVal.promotionValue) {
-                return (itemVal.regularValue <= 0 || itemVal.promotionValue <= 0)
-              } else {
-                return true
-              }
-            })
-            if (hasNullVal) {
-              _this.$message.warning('满赠规则条件不能为空!')
-              return
-            }
+          // 验证满赠规则必填项
+          const hasNullVal = _this.fullGiftRuleList.some(itemVal => !itemVal.regularValue || !itemVal.promotionValue)
+          if (hasNullVal) {
+            _this.$message.warning('满赠规则条件不能为空!')
+            return
           }
+          // 验证表格必填项
           const form = JSON.parse(JSON.stringify(_this.form))
-          let rowFlag1, rowFlag2, rowFlag3
           if (form.gateFlag == '1') {
-            form.gateProductList = this.$refs.cillProduct.getResultVal() // 规则门槛
             form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
-            if (form.gateProductList.length == 0) {
-              _this.$message.warning('请添加门槛产品!')
+            // 门槛产品数据
+            form.gateProductList = this.$refs.cillProduct.getResultVal()
+            if (_this.isJudge(form.gateProductList, '门槛')) {
               return
-            } else {
-              const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
-              if (qtyFlag) {
-                _this.$message.warning('订单起订量设置不能为空!')
-                return
-              }
-              rowFlag1 = _this.isJudge(form.gateProductList)
             }
           } else {
             form.gateProductList = []
@@ -498,33 +465,19 @@ export default {
           }
           // 正价产品判断表格必填
           form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
-          if (form.regularProductList.length == 0) {
-            _this.$message.warning('请添加正价产品!')
+          if (_this.isJudge(form.regularProductList, '正价')) {
             return
-          } else {
-            const qtyFlag = form.regularProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
-            if (qtyFlag) {
-              _this.$message.warning('订单起订量设置不能为空!')
-              return
-            }
-            rowFlag2 = _this.isJudge(form.regularProductList)
           }
           // 促销产品
           if (form.scopeFlag == '0') {
             form.giftProductList = this.$refs.offerProduct.getResultVal()
-            if (form.giftProductList.length == 0) {
-              _this.$message.warning('请添加促销产品!')
+            if (_this.isJudge(form.giftProductList, '促销')) {
               return
             }
-            rowFlag3 = _this.isJudge(form.giftProductList)
           } else {
             form.giftProductList = []
           }
 
-          if (rowFlag1 || rowFlag2 || rowFlag3) {
-            _this.$message.warning('请选择产品分类、品牌或产品!')
-            return
-          }
           // 组传给后台所需数据
           _this.fullGiftRuleList.map((val, i) => {
             val.scopeLevel = i * 1 + 1
@@ -576,28 +529,20 @@ export default {
       })
     },
     // 判断品牌,分类,产品其中一个必填
-    isJudge (list) {
-      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
+    isJudge (list, typeName) {
+      let flag, flag1, flag2
+      flag = !(list && list.length)
+      flag1 = list.some(con => !(con.productThisList && con.productThisList.length) && !(con.productTypeList && con.productTypeList.length) && !(con.productBrandList && con.productBrandList.length))
+      flag2 = list.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
+      if (flag) {
+        const tipInfo = '请添加' + typeName + '产品!'
+        this.$message.warning(tipInfo)
+      } else if (flag1) {
+        this.$message.warning('请选择产品分类、品牌或产品!')
+      } else if (flag2) {
+        this.$message.warning('订单起订量设置不能为空!')
+      }
+      return flag || flag1 || flag2
     },
     // 重置表格
     resetSearchForm () {

+ 37 - 68
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

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

+ 27 - 65
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -440,46 +440,32 @@ export default {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          // 验证必填
+          // 验证门槛产品必填
           if (_this.form.gateFlag === '1') {
             if (!_this.form.gateType) {
               _this.$message.warning('请选择规则门槛设置类型!')
               return
             }
-            if (!_this.form.gateValue) {
-              _this.$message.warning('规则门槛条件不能为空!')
-              return
-            }
-            if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
+            if (!_this.form.gateValue || (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount)) {
               _this.$message.warning('规则门槛条件不能为空!')
               return
             }
           }
-          // 判断特价规则必填
+          // 验证特价规则条件必填
           if (_this.form.discountType != '0' && _this.setTableData) {
             if (_this.setTableData[0].provinceValue == undefined || _this.setTableData[0].cityValue == undefined || _this.setTableData[0].specialValue == undefined) {
               _this.$message.warning('特价规则条件不能为空!')
               return
             }
           }
+          // 验证表格必填项
           const form = JSON.parse(JSON.stringify(_this.form))
           if (form.gateFlag === '1') {
-            form.gateProductList = _this.$refs.cillProduct.getResultVal()
             form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
-            if (form.gateProductList.length == 0) {
-              _this.$message.warning('请添加门槛产品!')
+            // 门槛产品
+            form.gateProductList = this.$refs.cillProduct.getResultVal()
+            if (_this.isJudge(form.gateProductList, '门槛')) {
               return
-            } else {
-              const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
-              if (qtyFlag) {
-                _this.$message.warning('订单起订量设置不能为空!')
-                return
-              }
-              const rowFlag = _this.isJudge(form.gateProductList)
-              if (rowFlag) {
-                _this.$message.warning('请选择产品分类、品牌或产品!')
-                return
-              }
             }
             form.gateUnit = form.gateType == 'RATIO_AMOUNT' ? 'RATIO' : form.gateType == 'MIN_AMOUNT' ? 'YUAN' : form.gateUnit
             form.quotaUnit = 'GE'
@@ -493,24 +479,13 @@ export default {
             form.borrowTimeLimtType = undefined
             form.borrowedShowFlag = undefined
           }
+          // 特价产品
           form.specialProductList = _this.$refs.specialProduct.getResultVal()
-          if (form.specialProductList.length == 0) {
-            _this.$message.warning('请添加特价产品!')
+          if (_this.isJudge(form.specialProductList, '特价')) {
             return
-          } else {
-            // 为空判断
-            const isTypeEmpty = form.specialProductList.some(item => (item.productTypeList && item.productTypeList.length == 0) && (item.productBrandList && item.productBrandList.length == 0))
-            if (isTypeEmpty) {
-              _this.$message.warning('产品分类或品牌不能为空!')
-              return
-            }
-            const isNumEmpty = form.specialProductList.some(item => (!item.unitType || !item.unitQty))
-            if (isNumEmpty) {
-              _this.$message.warning('订单起订量设置不能为空!')
-              return
-            }
           }
-          if (form.discountType === '0') { // 手动输入
+          // 手动输入必填项
+          if (form.discountType === '0') {
             const isCountEmpty = _this.isNumEmpty(form.specialProductList)
             if (isCountEmpty.flag) {
               _this.$message.warning('折扣不能为空!')
@@ -521,17 +496,11 @@ export default {
               return
             }
           } else {
-            // if (form.discountType === '2') { // 直降价格为负判断
-            //   const hasNegativePrice = form.specialProductList.some((item) => (item.provinceDiscountPrice < 0 || item.cityDiscountPrice < 0 || item.specialDiscountPrice < 0))
-            //   if (hasNegativePrice) {
-            //     _this.$message.warning('直降后价格不能为负值!')
-            //     return
-            //   }
-            // }
             form.provinceValue = _this.setTableData[0].provinceValue
             form.cityValue = _this.setTableData[0].cityValue
             form.specialValue = _this.setTableData[0].specialValue
           }
+          // 组后端所需数据
           form.promotionSn = _this.promotionSn
           if (form.gateFlag == '1') {
             if (form.gateType === 'RATIO_AMOUNT') {
@@ -587,28 +556,21 @@ export default {
       })
       return { flag: arr.length > 0, flag1: arr1.length > 0 }
     },
-    // 判断门槛产品中品牌,分类,产品其中一个必填
-    isJudge (list) {
-      const flag = list.some(con => {
-        if (con.productThisList) {
-          if (con.productThisList.length > 0) {
-            return false
-          } else {
-            if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
-              return false
-            } else {
-              return true
-            }
-          }
-        } else {
-          if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
-            return false
-          } else {
-            return true
-          }
-        }
-      })
-      return flag
+    // 判断品牌,分类,产品其中一个必填
+    isJudge (list, typeName) {
+      let flag, flag1, flag2
+      flag = !(list && list.length)
+      flag1 = list.some(con => !(con.productThisList && con.productThisList.length) && !(con.productTypeList && con.productTypeList.length) && !(con.productBrandList && con.productBrandList.length))
+      flag2 = list.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
+      if (flag) {
+        const tipInfo = '请添加' + typeName + '产品!'
+        this.$message.warning(tipInfo)
+      } else if (flag1) {
+        this.$message.warning('请选择产品分类、品牌或产品!')
+      } else if (flag2) {
+        this.$message.warning('订单起订量设置不能为空!')
+      }
+      return flag || flag1 || flag2
     },
     // 重置表格
     resetSearchForm () {

+ 26 - 18
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -617,16 +617,20 @@ export default {
       this.dataSource.forEach(item => {
         if (item.productBrandList && item.productBrandList.length > 0) {
           item.productBrandList.forEach((con) => {
-            row.productBrandList.forEach(newCon => {
-              if (newCon.productBrandSn == con.productBrandSn) {
-                flag = true
-                if (item.productTypeList && item.productTypeList.length == 0) {
-                  noTypeFlag = true
-                } else {
-                  c_typeArr = c_typeArr.concat(item.productTypeList)
+            if (row.productBrandList && row.productBrandList.length > 0) {
+              row.productBrandList.forEach(newCon => {
+                if (newCon.productBrandSn == con.productBrandSn) {
+                  flag = true
+                  if (item.productTypeList && item.productTypeList.length == 0) {
+                    noTypeFlag = true
+                  } else {
+                    c_typeArr = c_typeArr.concat(item.productTypeList)
+                  }
                 }
-              }
-            })
+              })
+            } else {
+              flag = false
+            }
           })
         }
       })
@@ -640,16 +644,20 @@ export default {
       this.dataSource.forEach(item => {
         if (item.productTypeArr && item.productTypeArr.length > 0) {
           item.productTypeArr.forEach((con) => {
-            row.productTypeArr.forEach(newCon => {
-              if (newCon.id == con.id) {
-                flag = true
-                if (item.productBrandList && item.productBrandList.length == 0) {
-                  noTypeFlag = true
-                } else {
-                  c_brandArr = c_brandArr.concat(item.productBrandList)
+            if (row.productTypeArr && row.productTypeArr.length > 0) {
+              row.productTypeArr.forEach(newCon => {
+                if (newCon.id == con.id) {
+                  flag = true
+                  if (item.productBrandList && item.productBrandList.length == 0) {
+                    noTypeFlag = true
+                  } else {
+                    c_brandArr = c_brandArr.concat(item.productBrandList)
+                  }
                 }
-              }
-            })
+              })
+            } else {
+              flag = false
+            }
           })
         }
       })