chenrui преди 10 месеца
родител
ревизия
a38739baa9

+ 0 - 23
src/api/promoActive.js

@@ -82,26 +82,3 @@ export const queryWaitingProductPage = (params) => {
     }
   })
 }
-
-// promoActive/findBySn/{sn}
-// export const promoActiveFindBySn = (params) => {
-//   const url = `/promoActive/findBySn/${params.sn}`
-//   return axios({
-//     url: url,
-//     method: 'get',
-//     headers: {
-//       'module': encodeURIComponent('促销活动明细')
-//     }
-//   })
-// }
-//  优惠活动 详情
-export const promoActiveDetailD = (params) => {
-  const url = `/promoActive/findDetailBySn/${params.sn}`
-  return axios({
-    url: url,
-    method: 'get',
-    headers: {
-      'module': encodeURIComponent('优惠活动明细')
-    }
-  })
-}

+ 53 - 19
src/views/promotionRulesManagement/promotionManagement/edit.vue

@@ -19,7 +19,7 @@
         <a-card :bordered="false" class="promotionEdit-cont">
           <a-row>
             <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-              <a-form-model-item label="标题名称" prop="title">
+              <a-form-model-item label="标题" prop="title">
                 <a-input
                   id="promotionEdit-title"
                   :maxLength="30"
@@ -89,7 +89,7 @@
                   class="promotionEdit-editor"
                   @on-change="editorChange"
                   :cache="false"></editor>
-                <div v-show="(pageType === 'edit'||pageType === 'see')&&isDisabled" class="box" v-html="form.content"></div>
+                <div v-if="(pageType === 'edit'||pageType === 'see')&&isDisabled" class="box" v-html="form.content"></div>
               </a-form-model-item>
               <a-form-model-item label="上传视频" prop="content" v-show="form.contentType =='VIDEO'" :label-col="{span:2}" :wrapper-col="{span:20}">
                 <Upload
@@ -208,6 +208,7 @@
       :chooseType="chooseTypeList"
       :chooseData="chooseDataList"
       :openModal="showProModal"
+      v-if="pageType!='see'"
       @ok="addProductSuccess"
       @close="closeProductModal"></chooseProduct>
   </div>
@@ -241,7 +242,7 @@ export default {
         content: '', // 内容
         contentLink: '', // 链接内容
         sort: undefined, // 排序
-        ruleEnableFlag: undefined, // 参数配置 1勾选配置  0不能配置
+        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
         publishState: 'UNPUBLISH',
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
         // 参数配置数据
@@ -292,9 +293,6 @@ export default {
         ],
         dealerEditFlag: [
           { required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }
-        ],
-        showFlag: [
-          { required: true, message: '请选择是否显示', trigger: 'change' }
         ]
       }
     }
@@ -302,15 +300,39 @@ export default {
   methods: {
     // 设置参数
     onChangeParams (e) {
-      this.isShowParams = e.target.checked
-      this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
-      this.$nextTick(() => {
-        this.$refs.setContent.addCouponCon()
-      })
+      const _this = this
+      _this.isShowParams = e.target.checked
+      _this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
+      if (_this.pageType === 'add') {
+        _this.$nextTick(() => {
+          _this.$refs.setContent.addCouponCon()
+        })
+      } else {
+        if (!e.target.checked) {
+          _this.$refs.setContent.clearContent()
+          _this.$nextTick(() => {
+            _this.$refs.setContent.addCouponCon()
+          })
+        }
+      }
+      // _this.$confirm({
+      //   title: '提示',
+      //   content: '改变参数配置,参数配置内容将清空,确认改变吗?',
+      //   centered: true,
+      //   onOk () {
+      //   },
+      //   onCancel () {
+      //     _this.isShowParams = !e.target.checked
+      //     _this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
+      //   }
+      // })
     },
     // 打开产品弹窗
-    insterProduct (typeList) {
-      this.chooseTypeList = typeList
+    insterProduct (obj) {
+      if (obj && Object.keys(obj).length > 0) {
+        this.chooseTypeList = obj.typeArr
+        this.chooseDataList = obj.productArr
+      }
       this.showProModal = true
     },
     // 添加产品成功
@@ -319,7 +341,6 @@ export default {
         return { productCode: item.code,
           productSn: item.productSn }
       })
-      this.chooseDataList = list.map(item => item.productSn)
       this.$refs.setContent.setProductSn(productArr)
     },
     closeProductModal () {
@@ -352,13 +373,14 @@ export default {
           _this.form.promoActiveSn = res.data.promoActiveSn
           _this.form.title = res.data.title
           _this.form.contentType = res.data.contentType
-          _this.form.showFlag = res.data.showFlag
           _this.form.sort = res.data.sort
           _this.imageSet = res.data.imageSet
           if (res.data.imageSet) {
             const images = res.data.imageSet.join(',')
             _this.form.imageSet = images
-            _this.$refs.imageSet.setFileList(images)
+            if (this.pageType != 'see') {
+              _this.$refs.imageSet.setFileList(images)
+            }
           }
           _this.form.content = res.data.content
           _this.form.dealerEditFlag = res.data.dealerEditFlag
@@ -376,6 +398,10 @@ export default {
             _this.form.ruleEnableFlag = res.data.ruleEnableFlag
             if (res.data.promoRule && res.data.promoRule.ruleDetailList && res.data.ruleEnableFlag === '1') {
               _this.form.promoRule = res.data.promoRule
+              res.data.promoRule.ruleDetailList.map(val => {
+                val.unit = 'GE'
+                return val
+              })
               _this.$nextTick(() => {
                 _this.$refs.setContent.setDetailData(res.data.promoRule, res.data.promoRule.ruleDetailList)
               })
@@ -392,8 +418,16 @@ export default {
         if (_this.form.ruleEnableFlag === '1') {
           _this.form.promoRule.ruleDetailList = _this.$refs.setContent.couponList
         }
+        // 验证组件必填项
+        _this.$refs.setContent.testAndVerify(function (res) {
+          if (res) {
+            _this.saveInfo()
+          }
+        })
       }
-      _this.$refs.ruleForm.validateField('ruleDetailList')
+    },
+    saveInfo () {
+      const _this = this
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
           _this.form.promoActiveSn = this.$route.params.sn
@@ -450,8 +484,8 @@ export default {
         content: '', // 内容
         contentLink: '', // 链接内容
         sort: undefined, // 排序
-        ruleEnableFlag: undefined, // 参数配置 1勾选配置  0不能配置
-        publishState: 'UNPUBLISH',
+        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
+        publishState: 'UNPUBLISH', // 是否发布
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
         // 参数配置数据
         promoRule: {

+ 1 - 0
src/views/promotionRulesManagement/promotionManagement/list.vue

@@ -228,6 +228,7 @@ export default {
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '促销名称', dataIndex: 'name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '标题', dataIndex: 'title', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '8%', align: 'center' },
         { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center' },
         { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },

+ 70 - 12
src/views/promotionRulesManagement/promotionManagement/setPromotion.vue

@@ -15,7 +15,7 @@
               v-model="sellForm.ruleType"
               placeholder="请选择基本规则"
               id="setPromotion-ruleType"
-              code="PROMO_RULE_TYPE"
+              code="PROMO_ACTIVE_RULE_TYPE"
               :disabled="disabledVal"
               allowClear></v-select>
           </a-form-model-item>
@@ -68,6 +68,7 @@
               code="PROMO_RULE_BASE_TYPE"
               showType="radio"
               :disabled="disabledVal"
+              @change="handleRuleBaseType"
               allowClear></v-select>
           </a-form-model-item>
         </a-col>
@@ -87,7 +88,7 @@
                           :step="1"
                           :max="99999999"
                           :precision="0"
-                          :disabled="disabledVal"
+                          :disabled="true"
                           size="small"/>
                         <a-select
                           default-value="GE"
@@ -149,14 +150,14 @@
           :md="12"
           :lg="24"
           :xl="24"
-          v-show="sellForm.value===1">
+          v-if="sellForm.ruleBaseType!='category'">
           <a-form-model-item label="使用说明" prop="ruleExplain">
             <a-input v-model="sellForm.ruleExplain" type="textarea" placeholder="请输入使用说明" :disabled="disabledVal" :maxLength="200" />
           </a-form-model-item>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="24" :xl="24">
           <a-form-model-item label="券有效期" prop="validType">
-            <a-radio-group v-model="sellForm.validType" :disabled="disabledVal">
+            <a-radio-group v-model="sellForm.validType" :disabled="disabledVal" @change="handleValidType">
               <a-radio :style="radioStyle" value="FIXED">
                 <span>固定日期</span>
                 <a-range-picker
@@ -174,6 +175,7 @@
                   v-model="sellForm.validDays"
                   :step="1"
                   :max="99999999"
+                  :min="1"
                   :disabled="disabledVal"
                   :precision="0"/>天
               </a-radio>
@@ -245,9 +247,9 @@ export default {
         ruleType: [{ required: true, message: '请选择基本规则', trigger: 'change' }],
         ruleName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
         ruleBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
-        ruleDetailList: [{ required: true, message: '请添加券内容', trigger: ['change', 'blur'] }],
         ruleExplain: [{ required: true, message: '请输入使用说明', trigger: ['change', 'blur'] }],
-        validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }]
+        validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
+        ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'change' }]
       },
       productTypeList: [],
       time: []
@@ -296,14 +298,23 @@ export default {
     handleAddProduct (row) {
       const pos = this.couponList.findIndex(item => item.id === row.id)
       this.posNum = pos
-      const typeSrr = this.sellForm.productRangeList || []
-
-      this.$emit('addProduct', typeSrr)
+      const typeArr = this.sellForm.productRangeList || []
+      let productArr = []
+      this.couponList.forEach(item => {
+        if (item.ruleProductList && item.ruleProductList.length > 0) {
+          const arr = item.ruleProductList.map(con => { return con.productSn })
+          productArr = productArr.concat(arr)
+        }
+      })
+      this.$emit('addProduct', { typeArr, productArr })
     },
     onChangeTree () {
       this.couponList = []
       this.addCouponCon()
     },
+    handleDropdownVisibleChange () {
+      debugger
+    },
     // 新增券内容
     async addCouponCon () {
       if (this.couponList.length >= 10) {
@@ -313,7 +324,7 @@ export default {
       const result = await getNewScopeSn({})
       const obj = {
         id: result.data,
-        productQty: undefined, // 产品数量
+        productQty: 1, // 产品数量
         ruleValue: undefined, // 返利金额
         detailExplain: undefined, // 使用说明
         unit: 'GE',
@@ -337,14 +348,61 @@ export default {
         }
       })
     },
+    // 券生成方式 change
+    handleRuleBaseType () {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '改变生成方式,券内容也会改变,确认改变吗?',
+        centered: true,
+        onOk () {
+          _this.couponList.map(item => {
+            item.detailExplain = undefined
+            return item
+          })
+        }
+      })
+    },
+    // 券有效期 change
+    handleValidType (con) {
+      this.sellForm.validType = con.target.value
+      if (con.target.value === 'FIXED') {
+        this.sellForm.validDays = undefined
+      } else {
+        this.time = []
+        this.sellForm.validStartDate = undefined
+        this.sellForm.validEndDate = undefined
+      }
+    },
     setProductSn (list) {
       this.couponList[this.posNum].ruleProductList = list
     },
-    // 返回组件值
-    getPromotionVal () {
+    // 验证必填项
+    testAndVerify (callBack) {
       if (this.couponList && this.couponList.length > 0) {
         this.sellForm.ruleDetailList = this.couponList
+        this.$refs.sellRuleForm.validateField('ruleDetailList')
+        const moneyFlag = this.couponList.some(con => !con.ruleValue)
+        const productFlag = this.couponList.some(con => con.ruleProductList && con.ruleProductList.length == 0)
+        if (moneyFlag) {
+          this.$message.warning('请输入返利金额!')
+          return false
+        }
+        if (productFlag) {
+          this.$message.warning('请选择活动产品!')
+          return false
+        }
       }
+      this.$refs.sellRuleForm.validate(valid => {
+        if (valid) {
+          callBack(valid)
+        } else {
+          return false
+        }
+      })
+    },
+    // 返回组件值
+    getPromotionVal () {
       this.sellForm.productRangeFlag = (this.sellForm.productRangeList && this.sellForm.productRangeList.length > 0) ? '1' : '0'
       const newData = JSON.parse(JSON.stringify(this.sellForm))
       newData.productRangeList = newData.productRangeList.map(item => {