Explorar el Código

促销规则预览

chenrui hace 1 año
padre
commit
8ba3e484f9

+ 25 - 11
src/views/promotionRulesManagement/dealerPromotions/detailModal.vue

@@ -77,7 +77,7 @@
       </a-form-model>
       <a-card size="small" :bordered="false" class="pages-wrap">
         <div class="flex">
-          <a-radio-group v-model="chooseVal" button-style="solid">
+          <a-radio-group v-model="chooseVal" button-style="solid" @change="onChange">
             <a-radio-button value="a" v-show="form.gateFlag==='1'">
               门槛产品
             </a-radio-button>
@@ -94,7 +94,7 @@
               特价产品
             </a-radio-button>
           </a-radio-group>
-          <a-button type="primary" v-show="isShowPreview" class="button-info" @click="handlePreview">预览</a-button>
+          <a-button type="link" v-show="isShowPreview" class="button-info" @click="handlePreview">预览</a-button>
         </div>
         <!-- 列表 -->
         <div v-show="chooseVal==='a'||chooseVal==='b'||chooseVal==='c'">
@@ -276,7 +276,7 @@ export default {
         productBrandList: [],
         productThisList: []
       },
-      isShowPreview: false,
+
       chooseVal: 'a',
       columns: [
         { title: '产品分类', width: '30%', scopedSlots: { customRender: 'productType' }, align: 'center' },
@@ -284,8 +284,9 @@ export default {
         { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '设置起订量', width: '20%', scopedSlots: { customRender: 'setNum' }, align: 'center' }
       ],
-      previewList: [],
-      openProductModal: false // 产品预览弹窗
+      isShowPreview: false, // 是否显示预览按钮
+      openProductModal: false, // 预览弹窗
+      previewList: []// 预览值
     }
   },
   computed: {
@@ -380,7 +381,7 @@ export default {
               this.isShowPreview = this.judgeBtnShow(res.data.regularProductList)
             } else {
               this.chooseVal = 'd'
-              // this.isShowPreview = this.judgeBtnShow(res.data.giftProductList)
+              this.isShowPreview = this.judgeBtnShow(res.data.specialProductList)
             }
           }
           this.form = { ...this.form, ...resultObj }
@@ -394,7 +395,7 @@ export default {
     },
     // 判断预览按钮是否显示
     judgeBtnShow (conData) {
-      const hasData = conData.some(item => item.productTypeList)
+      const hasData = conData.some(item => item.productThisList)
       return hasData
     },
     getPreviewList (dataList) {
@@ -403,7 +404,6 @@ export default {
         if (con.productThisList) {
           con.productThisList.forEach((item, i) => {
             item.unitTypeInfo = con.unitTypeDictValue + con.unitQty
-            item.no = i * 1 + 1
             item.productTypeInfo = con.promotionProductType
           })
           newList = [ ...newList, ...con.productThisList ]
@@ -414,12 +414,13 @@ export default {
     // 预览
     handlePreview () {
       const dataName = this.chooseVal === 'a' ? 'gate' : this.chooseVal === 'b' ? 'regular' : this.chooseVal === 'c' ? 'gift' : this.chooseVal === 'd' ? 'special' : 'giftGroup'
+      const titName = this.chooseVal === 'a' ? '门槛产品' : this.chooseVal === 'b' ? '正价产品' : this.chooseVal === 'd' ? '特价产品' : '促销产品'
       if (dataName != 'giftGroup') {
         const newPreviewList = this.getPreviewList(this.form[dataName + 'ProductList'])
         if (newPreviewList && newPreviewList.length > 0) {
           this.previewList = newPreviewList
           const resuleObj = {
-            tit: '门槛产品',
+            tit: titName,
             promotionRuleSn: this.itemSn,
             promotionProductType: newPreviewList[0].productTypeInfo
           }
@@ -432,9 +433,10 @@ export default {
           const stepPreviewList = this.getPreviewList(this.form.giftProductMap['GIFT' + (stepIndex * 1 + 1)])
           this.previewList = stepPreviewList
           const resuleObj = {
-            tit: '促销产品(阶梯' + stepIndex * 1 + 1 + ')',
+            tit: '促销产品(阶梯' + (stepIndex * 1 + 1) + ')',
             promotionRuleSn: this.itemSn,
-            promotionProductType: stepPreviewList[0].productTypeInfo
+            promotionProductType: stepPreviewList[0].productTypeInfo,
+            scopeLevel: (stepIndex * 1 + 1)
           }
           this.$refs.previewModal.pageInit(resuleObj)
         }
@@ -444,6 +446,18 @@ export default {
     closeProductModal () {
       this.previewList = []
       this.openProductModal = false
+    },
+    onChange (e) {
+      const dataName = this.chooseVal === 'a' ? 'gate' : this.chooseVal === 'b' ? 'regular' : this.chooseVal === 'c' ? 'gift' : this.chooseVal === 'd' ? 'special' : 'giftGroup'
+      if (dataName != 'giftGroup') {
+        this.isShowPreview = this.judgeBtnShow(this.form[dataName + 'ProductList'])
+      } else {
+        // 阶梯数据处理
+        const pos = e.split('')[1]
+        if (this.form.giftProductMap && Object.keys(this.form.giftProductMap).length > 0) {
+          this.isShowPreview = this.judgeBtnShow(this.form.giftProductMap['GIFT' + (pos * 1 + 1)])
+        }
+      }
     }
   },
   watch: {

+ 18 - 8
src/views/promotionRulesManagement/dealerPromotions/productPreviewModal.vue

@@ -13,15 +13,15 @@
         <ve-table
           :max-height="500"
           :columns="columns"
-          :table-data="dataList"
+          :table-data="newDataList"
           :border-around="true"
           :border-y="true"
         />
-        <div v-show="dataList&&dataList.length==0" class="empty-data" style="height:'300px'"><a-empty description="暂无数据" :image="simpleImage"/></div>
+        <div v-show="newDataList&&newDataList.length==0" class="empty-data" style="height:'300px'"><a-empty description="暂无数据" :image="simpleImage"/></div>
       </div>
       <div class="btn-cont">
-        <a-button @click="handleExport" :loading="exportLoading">导出</a-button>
-        <a-button type="primary" class="button-info" style="margin-left:20px;" id="productPreview-back" @click="isShow = false">关闭</a-button>
+        <a-button type="primary" v-if="resObj&&resObj.promotionRuleSn" style="margin-right:20px;"  @click="handleExport" :loading="exportLoading">导出</a-button>
+        <a-button  id="productPreview-back" @click="isShow = false">关闭</a-button>
       </div>
     </a-spin>
   </a-modal>
@@ -58,13 +58,16 @@ export default {
         { title: '序号', field: 'no', key: 'a', width: 40, align: 'center', operationColumn: false },
         { title: '产品编码', field: 'productCode', key: 'b', width: '40%', align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
         { title: '起订量', field: 'unitTypeInfo', key: 'c', width: '40%', align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } }
-      ]
+      ],
+      newDataList:this.dataList
     }
   },
   methods: {
     pageInit (obj) {
       this.resObj = obj
-      this.title = obj.tit + '(已选' + this.dataList.length + '项)'
+      this.$nextTick(()=>{
+        this.title = obj.tit + '(已选' + this.dataList.length + '项)'
+      })
     },
     //  导出
     handleExport () {
@@ -73,7 +76,8 @@ export default {
       _this.spinning = true
       const ajaxData = {
         promotionRuleSn: _this.resObj.promotionRuleSn,
-        promotionProductType: _this.resObj.promotionProductType
+        promotionProductType: _this.resObj.promotionProductType,
+        scopeLevel: _this.resObj.scopeLevel || undefined
       }
       hdExportExcel(excelProductExcel, ajaxData, '促销活动' + this.resObj.tit, function () {
         _this.exportLoading = false
@@ -90,7 +94,13 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.$refs.table.clearTable()
+      }else{
+        if(this.dataList&&this.dataList.length>0){
+          this.newDataList = this.dataList.map((item,i)=>{
+            item.no = i*1+1
+            return item
+          })
+        }
       }
     }
   }

+ 56 - 9
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -178,12 +178,15 @@
               促销产品
             </a-radio-button>
           </a-radio-group>
-          <a-button
-            size="small"
-            type="link"
-            class="button-info"
-            @click="openGuideModal=true"
-            id="promotionList-edit-btn">+导入产品</a-button>
+          <div>
+            <a-button
+              size="small"
+              type="link"
+              class="button-info"
+              @click="openGuideModal=true"
+              id="promotionList-edit-btn">+导入产品</a-button>
+            <a-button type="link" class="button-error" @click="handlePreview">预览</a-button>
+          </div>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 :unitTypeList="unitTypeDataList" ref="cillProduct"></tableType1></div>
         <div v-show="chooseVal=='b'"><tableType1 :unitTypeList="unitTypeDataList" ref="normalPriceProduct"></tableType1></div>
@@ -196,6 +199,8 @@
     </a-spin>
     <!-- 导入产品 -->
     <importGuideModal goodFlag="1" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
+    <!-- 预览弹窗 -->
+    <productPreviewModal ref="previewModal" :openModal="openProductModal" :dataList="previewList" @close="closeProductModal"></productPreviewModal>
   </a-modal>
 </template>
 
@@ -206,10 +211,11 @@ import tableType1 from './tableType1.vue'
 import { promotionSave, getRuleDetail } from '@/api/promotion'
 import ImportGuideModal from './importGuideModal.vue'
 import { getLookUpData } from '@/api/data'
+import productPreviewModal from './productPreviewModal'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, ImportGuideModal },
+  components: { VSelect, tableType1, ImportGuideModal, productPreviewModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -262,7 +268,9 @@ export default {
         promotionValue: undefined
       }],
       code: 'SCOPE_UNIT_TYPE', // 起订类型数据字典
-      unitTypeDataList: []
+      unitTypeDataList: [],
+      openProductModal: false, // 预览弹窗
+      previewList: []// 预览值
     }
   },
   methods: {
@@ -548,8 +556,8 @@ export default {
       const _this = this
       getRuleDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
-          this.chooseVal = res.data.gateFlag == '0' ? 'b' : 'a'
           const resultObj = res.data
+          _this.chooseVal = resultObj.gateFlag == '0' ? 'b' : 'a'
           if (resultObj.gateFlag === '1') {
             resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
           }
@@ -643,6 +651,45 @@ export default {
           _this.unitTypeDataList = res.data.list
         }
       })
+    },
+    // 获取预览数据
+    getPreviewList (dataList) {
+      if (dataList && dataList.length > 0) {
+        let newList = []
+        dataList.forEach(con => {
+          if (con.productThisList) {
+            con.productThisList.forEach((item, i) => {
+              item.unitTypeInfo = con.unitTypeDictValue + con.unitQty
+              item.no = i * 1 + 1
+              item.productTypeInfo = con.promotionProductType
+            })
+            newList = [ ...newList, ...con.productThisList ]
+          }
+        })
+        return newList
+      } else {
+        return []
+      }
+    },
+    // 预览  删除标签,添加标签  预览按钮显示不显示
+    handlePreview () {
+      const dataName = this.chooseVal === 'a' ? 'gate' : this.chooseVal === 'b' ? 'regular' : 'gift'
+      const titName = this.chooseVal === 'a' ? '门槛产品' : this.chooseVal === 'b' ? '正价产品' : '促销产品'
+      const newPreviewList = this.getPreviewList(this.form[dataName + 'ProductList'])
+      if (newPreviewList && newPreviewList.length === 0) {
+        this.$message.warning('暂时没有可预览的产品')
+        return
+      }
+      this.previewList = newPreviewList
+      const resuleObj = {
+        tit: titName
+      }
+      this.$refs.previewModal.pageInit(resuleObj)
+      this.openProductModal = true
+    },
+    closeProductModal () {
+      this.previewList = []
+      this.openProductModal = false
     }
   },
   watch: {

+ 76 - 11
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

@@ -173,12 +173,15 @@
               {{ fullGiftRuleList.length>1?'促销产品('+'阶梯'+(i*1+1)+')':'促销产品' }}
             </a-radio-button>
           </a-radio-group>
-          <a-button
-            size="small"
-            type="link"
-            class="button-info"
-            @click="openGuideModal=true"
-            id="promotionList-edit-btn">+导入产品</a-button>
+          <div>
+            <a-button
+              size="small"
+              type="link"
+              class="button-info"
+              @click="openGuideModal=true"
+              id="promotionList-edit-btn">+导入产品</a-button>
+            <a-button type="link" class="button-error" @click="handlePreview">预览</a-button>
+          </div>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 :unitTypeList="unitTypeDataList" ref="cillProduct"></tableType1></div>
         <div v-show="chooseVal=='b'"><tableType1 :unitTypeList="unitTypeDataList" ref="normalPriceProduct"></tableType1></div>
@@ -191,6 +194,8 @@
     </a-spin>
     <!-- 导入产品 -->
     <importGuideModal goodFlag="1" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
+    <!-- 预览弹窗 -->
+    <productPreviewModal ref="previewModal" :openModal="openProductModal" :dataList="previewList" @close="closeProductModal"></productPreviewModal>
   </a-modal>
 </template>
 
@@ -201,10 +206,11 @@ import tableType1 from './tableType1.vue'
 import { promotionSave, getRuleDetail, getNewScopeSn } from '@/api/promotion'
 import ImportGuideModal from './importGuideModal.vue'
 import { getLookUpData } from '@/api/data'
+import productPreviewModal from './productPreviewModal'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, ImportGuideModal },
+  components: { VSelect, tableType1, ImportGuideModal, productPreviewModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -266,7 +272,9 @@ export default {
       id: null,
       code: 'SCOPE_UNIT_TYPE', // 起订类型数据字典
       unitTypeDataList: [],
-      loadingSave: false
+      loadingSave: false,
+      openProductModal: false, // 预览弹窗
+      previewList: []// 预览值
     }
   },
   methods: {
@@ -277,9 +285,6 @@ export default {
         item.regularValue = undefined
       })
     },
-    onChooseVal (e) {
-      this.chooseVal = e.target.value
-    },
     // 新增  满减规则  最多能添加五个
     async addFullGiftRule () {
       const result = await getNewScopeSn({})
@@ -679,6 +684,66 @@ export default {
           _this.unitTypeDataList = res.data.list
         }
       })
+    },
+    // 获取预览产品数据
+    getPreviewList (dataList) {
+      if (dataList && dataList.length > 0) {
+        let newList = []
+        dataList.forEach(con => {
+          if (con.productThisList) {
+            con.productThisList.forEach((item, i) => {
+              item.unitTypeInfo = con.unitTypeDictValue + con.unitQty
+              item.productTypeInfo = con.promotionProductType
+            })
+            newList = [ ...newList, ...con.productThisList ]
+          }
+        })
+        return newList
+      } else {
+        return []
+      }
+    },
+    // 预览
+    handlePreview () {
+      const dataName = this.chooseVal === 'a' ? 'gate' : this.chooseVal === 'b' ? 'regular' : this.chooseVal === 'c' ? 'gift' : 'giftGroup'
+      const titName = this.chooseVal === 'a' ? '门槛产品' : this.chooseVal === 'b' ? '正价产品' : '促销产品'
+      if (dataName != 'giftGroup') {
+        const newPreviewList = this.getPreviewList(this.form[dataName + 'ProductList'])
+        if (newPreviewList && newPreviewList.length > 0) {
+          this.previewList = newPreviewList
+          const resuleObj = {
+            tit: titName
+          }
+          this.$refs.previewModal.pageInit(resuleObj)
+        } else {
+          this.$message.warning('暂时没有可预览的产品')
+          return
+        }
+      } else {
+        // 阶梯数据处理
+        const stepIndex = this.chooseVal.split('')[1]
+        if (this.form.giftProductMap && Object.keys(this.form.giftProductMap).length > 0) {
+          const stepPreviewList = this.getPreviewList(this.form.giftProductMap['GIFT' + (stepIndex * 1 + 1)])
+          if (stepPreviewList && stepPreviewList.length > 0) {
+            this.previewList = stepPreviewList
+            const resuleObj = {
+              tit: '促销产品(阶梯' + (stepIndex * 1 + 1) + ')'
+            }
+            this.$refs.previewModal.pageInit(resuleObj)
+          } else {
+            this.$message.warning('暂时没有可预览的产品')
+            return
+          }
+        }
+      }
+      this.openProductModal = true
+    },
+    closeProductModal () {
+      this.previewList = []
+      this.openProductModal = false
+    },
+    onChooseVal (e) {
+      this.chooseVal = e.target.value
     }
   },
   watch: {

+ 48 - 3
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -191,9 +191,10 @@
               style="margin-left:10px;"
               size="small"
               type="link"
-              class="button-error"
+              class="button-info"
               id="promotionList-edit-btn"
               @click="addProducts">+新增产品</a-button>
+            <a-button type="link" class="button-error" @click="handlePreview">预览</a-button>
           </div>
         </div>
         <div v-show="chooseVal=='a'"><tableType1 :unitTypeList="unitTypeDataList" ref="cillProduct"></tableType1></div>
@@ -214,6 +215,8 @@
       @ok="handleProductsAdd" />
     <!-- 导入产品 -->
     <importGuideModal :goodFlag="chooseVal=='a'?'1':'0'" :rulesType="form.discountType" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
+    <!-- 预览弹窗 -->
+    <productPreviewModal ref="previewModal" :openModal="openProductModal" :dataList="previewList" @close="closeProductModal"></productPreviewModal>
   </a-modal>
 </template>
 
@@ -226,10 +229,11 @@ import { promotionSave, getRuleDetail } from '@/api/promotion'
 import chooseProductsModal from './chooseProductsModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import { getLookUpData } from '@/api/data'
+import productPreviewModal from './productPreviewModal'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType3, chooseProductsModal, ImportGuideModal },
+  components: { VSelect, tableType1, tableType3, chooseProductsModal, ImportGuideModal, productPreviewModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -276,7 +280,9 @@ export default {
       chooseProducts: [],
       openGuideModal: false, // 导入弹窗
       code: 'SCOPE_UNIT_TYPE', // 起订类型数据字典
-      unitTypeDataList: []
+      unitTypeDataList: [],
+      openProductModal: false, // 预览弹窗
+      previewList: []// 预览值
     }
   },
   computed: {
@@ -812,6 +818,45 @@ export default {
           _this.unitTypeDataList = res.data.list
         }
       })
+    },
+    // 获取预览数据
+    getPreviewList (dataList) {
+      if (dataList && dataList.length > 0) {
+        let newList = []
+        dataList.forEach(con => {
+          if (con.productThisList) {
+            con.productThisList.forEach((item, i) => {
+              item.unitTypeInfo = con.unitTypeDictValue + con.unitQty
+              item.no = i * 1 + 1
+              item.productTypeInfo = con.promotionProductType
+            })
+            newList = [ ...newList, ...con.productThisList ]
+          }
+        })
+        return newList
+      } else {
+        return []
+      }
+    },
+    // 预览  删除标签,添加标签  预览按钮显示不显示
+    handlePreview () {
+      const dataName = this.chooseVal === 'a' ? 'gate' : 'special'
+      const titName = this.chooseVal === 'a' ? '门槛产品' : '特价产品'
+      const newPreviewList = this.getPreviewList(this.form[dataName + 'ProductList'])
+      if (newPreviewList.length === 0) {
+        this.$message.warning('暂时没有可预览的产品')
+        return
+      }
+      this.previewList = newPreviewList
+      const resuleObj = {
+        tit: titName
+      }
+      this.$refs.previewModal.pageInit(resuleObj)
+      this.openProductModal = true
+    },
+    closeProductModal () {
+      this.previewList = []
+      this.openProductModal = false
     }
   },
   watch: {