chenrui 1 éve
szülő
commit
b158e7db3a

+ 36 - 24
src/api/promotion.js

@@ -9,7 +9,7 @@ export const dealerPromotionList = (params) => {
     url: url,
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('列表查询')
     }
   })
@@ -20,7 +20,7 @@ export const dealerPromotionSave = params => {
     url: '/promotion/create',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('新增')
     }
   })
@@ -39,7 +39,7 @@ export const dealerPromotionEdit = params => {
     url: '/promotion/modify',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('编辑')
     }
   })
@@ -51,7 +51,7 @@ export const dealerPromotionDel = params => {
     url: `/promotion/delete/${params.sn}`,
     data: {},
     method: 'get',
-    headers:{
+    headers: {
       'module': encodeURIComponent('删除')
     }
   })
@@ -62,7 +62,7 @@ export const getRuleDetail = (params) => {
     url: `/promotion/rule/findBySn/${params.sn}`,
     data: {},
     method: 'get'
-    
+
   })
 }
 // 规则设置 列表
@@ -71,7 +71,7 @@ export const getRuleQueryList = (params) => {
     url: '/promotion/rule/queryList',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('明细列表查询')
     }
   })
@@ -91,7 +91,7 @@ export const promotionSave = (params) => {
     url: '/promotion/rule/save',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('新增/编辑')
     }
   })
@@ -102,7 +102,7 @@ export const promotionRulesDel = (params) => {
     url: '/promotion/rule/delete',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('删除')
     }
   })
@@ -113,7 +113,7 @@ export const promotionSubmit = (params) => {
     url: `/promotion/submit/${params.sn}`,
     data: {},
     method: 'get',
-    headers:{
+    headers: {
       'module': encodeURIComponent('提交')
     }
   })
@@ -125,7 +125,7 @@ export const modifyEnabledFlag = (params) => {
     url: '/promotion/modifyEnabledFlag',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('发布')
     }
   })
@@ -136,7 +136,7 @@ export const promotionAudit = (params) => {
     url: '/promotion/audit',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('审核')
     }
   })
@@ -147,7 +147,7 @@ export const promotionDateModify = (params) => {
     url: '/promotion/promotionDateModify',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('变更促销时间')
     }
   })
@@ -158,7 +158,7 @@ export const promotionIsOver = (params) => {
     url: `/promotion/isOver/${params.sn}`,
     data: {},
     method: 'get',
-    headers:{
+    headers: {
       'module': encodeURIComponent('终止')
     }
   })
@@ -172,7 +172,7 @@ export const downNormalFail = (params) => {
     method: 'post',
     data: paramsNew,
     responseType: 'blob',
-    headers:{
+    headers: {
       'module': encodeURIComponent('导出门槛产品错误项')
     }
   })
@@ -187,7 +187,7 @@ export const downSpecialFail = (params) => {
     method: 'post',
     data: paramsNew,
     responseType: 'blob',
-    headers:{
+    headers: {
       'module': encodeURIComponent('导出促销产品错误项')
     }
   })
@@ -201,7 +201,7 @@ export const downDealerFail = (params) => {
     method: 'post',
     data: params,
     responseType: 'blob',
-    headers:{
+    headers: {
       'module': encodeURIComponent('导出参与客户 (经销商)错误项')
     }
   })
@@ -212,7 +212,7 @@ export const queryCreatorList = (params) => {
   return axios({
     url: '/promotion/queryCreatorList',
     data: params,
-    method: 'post',
+    method: 'post'
   })
 }
 
@@ -222,7 +222,7 @@ export const handleCopyData = (params) => {
     url: '/promotion/copyData',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('复制')
     }
   })
@@ -237,7 +237,7 @@ export const queryAuditPageList = (params) => {
     url: url,
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('已选参与客户列表查询')
     }
   })
@@ -251,7 +251,7 @@ export const queryDealerPage = (params) => {
     url: url,
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('经销商列表查询')
     }
   })
@@ -262,7 +262,7 @@ export const midwaySubmit = (params) => {
     url: '/promotion/dealer/midwaySubmit',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('提交审核')
     }
   })
@@ -273,7 +273,7 @@ export const dealerMidwayUpdate = (params) => {
     url: '/promotion/dealer/midwayUpdate',
     data: params,
     method: 'post',
-    headers:{
+    headers: {
       'module': encodeURIComponent('添加经销商并更新列表显示状态')
     }
   })
@@ -284,8 +284,8 @@ export const dealerMidwayAudit = (params) => {
     url: '/promotion/dealer/midwayAudit',
     data: params,
     method: 'post',
-    headers:{
-      'module': encodeURIComponent(params.dealerAuditStatus=='AUDIT_PASS'?'审核通过':'审核不通过')
+    headers: {
+      'module': encodeURIComponent(params.dealerAuditStatus == 'AUDIT_PASS' ? '审核通过' : '审核不通过')
     }
   })
 }
@@ -306,3 +306,15 @@ export const updateDealerSnList = (params) => {
     method: 'post'
   })
 }
+// 导出规则产品明细列表
+export const excelProductExcel = (params) => {
+  return axios({
+    url: '/promotion/rule/excelProductExcel',
+    data: params,
+    method: 'post',
+    responseType: 'blob',
+    headers: {
+      'module': encodeURIComponent('导出')
+    }
+  })
+}

+ 21 - 14
src/views/allocationManagement/transferReturn/editGrp.vue

@@ -115,6 +115,19 @@
                     style="width: 100%;" />
                 </div>
               </template> -->
+          <!-- 本次可退数量 -->
+          <template slot="returnNumber" slot-scope="text, record,index">
+            <a-input-number
+              v-if="record.refundableQty!=0"
+              size="small"
+              v-model="record.returnableQty"
+              :precision="0"
+              :min="0"
+              :max="record.refundableQty"
+              placeholder="请输入"
+              style="width: 100%;" />
+            <span v-else>0</span>
+          </template>
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
             <a-button
@@ -192,18 +205,6 @@
               placeholder="请输入"
               style="width: 100%;" />
           </template> -->
-          <!-- 退货数量 -->
-          <template slot="returnQty" slot-scope="text, record,index">
-            <a-input-number
-              size="small"
-              v-model="record.returnQty"
-              @blur="e => returnQtyChange(e.target.value, record,index)"
-              :precision="0"
-              :min="0"
-              :max="record.returnQty"
-              placeholder="请输入"
-              style="width: 100%;" />
-          </template>
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
             <a-button size="small" type="link" class="button-error" @click="handleDel(record)" id="editGrap-del-btn">删除</a-button>
@@ -304,6 +305,7 @@ export default {
             data.list[i].no = no + i + 1
             data.list[i].returnPrice = data.list[i].price
             data.list[i].oldPrice = data.list[i].price
+            data.list[i].returnableQty = undefined
           }
           this.loadDataSource = data.list || []
           this.disabled = false
@@ -350,6 +352,7 @@ export default {
         { title: '剩余可退数量', dataIndex: 'refundableQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '退货单价', dataIndex: 'returnPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '退货数量', dataIndex: 'returnQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '本次可退数量', scopedSlots: { customRender: 'returnNumber' }, width: '8%', align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
       arr.splice(5, 0, { title: '调拨单价', dataIndex: 'price', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
@@ -364,7 +367,7 @@ export default {
         { title: '产品名称', dataIndex: 'product.name', align: 'center', width: '29%', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '单位', dataIndex: 'product.unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '退货单价', dataIndex: 'price', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '退货数量', scopedSlots: { customRender: 'returnQty' }, width: '10%', align: 'center' },
+        { title: '退货数量', dataIndex: 'returnQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
       arr.splice(7, 0, { title: '退货金额', dataIndex: 'totalReturnPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
@@ -508,13 +511,17 @@ export default {
     },
     //  添加/编辑
     handleAdd (row, isEdit, isRefresh) {
+      if (!row.returnableQty) {
+        this.$message.error('本次可退数量不能为空!')
+        return
+      }
       const params = {
         allocateReturnSn: this.allocateReturnSn,
         productSn: row.productSn,
         price: isEdit ? row.price : row.returnPrice,
         allocateNo: row.allocateNo,
         allocateSn: row.allocateSn,
-        returnableQty: row.returnQty
+        returnableQty: row.returnableQty
       }
       const fun = isEdit ? allocReturnDetailUpdate : allocReturnDetailInsert
       if (isEdit) { // 编辑

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

@@ -76,23 +76,26 @@
         </a-form-model-item>
       </a-form-model>
       <a-card size="small" :bordered="false" class="pages-wrap">
-        <a-radio-group v-model="chooseVal" button-style="solid">
-          <a-radio-button value="a" v-show="form.gateFlag==='1'">
-            门槛产品
-          </a-radio-button>
-          <a-radio-button value="b" v-show="form.promotionRuleType!='PROMO_PROD'">
-            正价产品
-          </a-radio-button>
-          <a-radio-button value="c" v-show="(form.regularPromotionSameFlag==='0'||form.scopeFlag==='0')&&form.promotionRuleType!='BUY_PROD_GIVE_PROD'">
-            促销产品
-          </a-radio-button>
-          <a-radio-button :value="'c'+i" v-for="(item,i) in form.giveRuleList" :key="i" v-show="(form.regularPromotionSameFlag==='0'||form.scopeFlag==='0')&&form.promotionRuleType=='BUY_PROD_GIVE_PROD'&&form.giveRuleList">
-            {{ form.giveRuleList.length>1? '促销产品'+'(阶梯'+(i*1+1) +')' :'促销产品' }}
-          </a-radio-button>
-          <a-radio-button value="d" v-show="form.promotionRuleType=='PROMO_PROD'">
-            特价产品
-          </a-radio-button>
-        </a-radio-group>
+        <div class="flex">
+          <a-radio-group v-model="chooseVal" button-style="solid">
+            <a-radio-button value="a" v-show="form.gateFlag==='1'">
+              门槛产品
+            </a-radio-button>
+            <a-radio-button value="b" v-show="form.promotionRuleType!='PROMO_PROD'">
+              正价产品
+            </a-radio-button>
+            <a-radio-button value="c" v-show="(form.regularPromotionSameFlag==='0'||form.scopeFlag==='0')&&form.promotionRuleType!='BUY_PROD_GIVE_PROD'">
+              促销产品
+            </a-radio-button>
+            <a-radio-button :value="'c'+i" v-for="(item,i) in form.giveRuleList" :key="i" v-show="(form.regularPromotionSameFlag==='0'||form.scopeFlag==='0')&&form.promotionRuleType=='BUY_PROD_GIVE_PROD'&&form.giveRuleList">
+              {{ form.giveRuleList.length>1? '促销产品'+'(阶梯'+(i*1+1) +')' :'促销产品' }}
+            </a-radio-button>
+            <a-radio-button value="d" v-show="form.promotionRuleType=='PROMO_PROD'">
+              特价产品
+            </a-radio-button>
+          </a-radio-group>
+          <a-button type="primary" v-show="isShowPreview" class="button-info" @click="handlePreview">预览</a-button>
+        </div>
         <!-- 列表 -->
         <div v-show="chooseVal==='a'||chooseVal==='b'||chooseVal==='c'">
           <a-table
@@ -218,15 +221,19 @@
         <a-button id="dealerPromotions-basicInfo-modal-back" @click="isShow = false">关闭</a-button>
       </div>
     </a-spin>
+    <!-- 预览弹窗 -->
+    <productPreviewModal ref="previewModal" :openModal="openProductModal" :dataList="previewList" @close="closeProductModal"></productPreviewModal>
   </a-modal>
 </template>
 
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { getRuleDetail } from '@/api/promotion'
+import productPreviewModal from './productPreviewModal'
 export default {
   name: 'DetailModal',
   mixins: [commonMixin],
+  components: { productPreviewModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -269,13 +276,16 @@ export default {
         productBrandList: [],
         productThisList: []
       },
+      isShowPreview: false,
       chooseVal: 'a',
       columns: [
         { title: '产品分类', width: '30%', scopedSlots: { customRender: 'productType' }, align: 'center' },
         { title: '品牌', width: '35%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
         { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '设置起订量', width: '20%', scopedSlots: { customRender: 'setNum' }, align: 'center' }
-      ]
+      ],
+      previewList: [],
+      openProductModal: false // 产品预览弹窗
     }
   },
   computed: {
@@ -360,19 +370,18 @@ export default {
           const resultObj = res.data
           if (resultObj.gateFlag == '1') {
             this.chooseVal = 'a'
+            this.isShowPreview = this.judgeBtnShow(res.data.gateProductList)
           } else {
             if (resultObj.promotionRuleType == 'BUY_PROD_GIVE_PROD') {
               this.chooseVal = 'b'
+              this.isShowPreview = this.judgeBtnShow(res.data.regularProductList)
             } else if (resultObj.promotionRuleType == 'BUY_PROD_GIVE_MONEY') {
               this.chooseVal = 'b'
+              this.isShowPreview = this.judgeBtnShow(res.data.regularProductList)
             } else {
               this.chooseVal = 'd'
+              // this.isShowPreview = this.judgeBtnShow(res.data.giftProductList)
             }
-            // if (resultObj.giveRuleList && resultObj.giveRuleList.length > 0) {
-            //   this.chooseVal = 'c0'
-            // } else {
-            //   this.chooseVal = resultObj.promotionRuleType == 'PROMO_PROD' ? 'd' : 'b'
-            // }
           }
           this.form = { ...this.form, ...resultObj }
           this.setTableData = [{
@@ -382,6 +391,59 @@ export default {
           }]
         }
       })
+    },
+    // 判断预览按钮是否显示
+    judgeBtnShow (conData) {
+      const hasData = conData.some(item => item.productTypeList)
+      return hasData
+    },
+    getPreviewList (dataList) {
+      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
+    },
+    // 预览
+    handlePreview () {
+      const dataName = this.chooseVal === 'a' ? 'gate' : this.chooseVal === 'b' ? 'regular' : this.chooseVal === 'c' ? 'gift' : this.chooseVal === 'd' ? 'special' : 'giftGroup'
+      if (dataName != 'giftGroup') {
+        const newPreviewList = this.getPreviewList(this.form[dataName + 'ProductList'])
+        if (newPreviewList && newPreviewList.length > 0) {
+          this.previewList = newPreviewList
+          const resuleObj = {
+            tit: '门槛产品',
+            promotionRuleSn: this.itemSn,
+            promotionProductType: newPreviewList[0].productTypeInfo
+          }
+          this.$refs.previewModal.pageInit(resuleObj)
+        }
+      } 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)])
+          this.previewList = stepPreviewList
+          const resuleObj = {
+            tit: '促销产品(阶梯' + stepIndex * 1 + 1 + ')',
+            promotionRuleSn: this.itemSn,
+            promotionProductType: stepPreviewList[0].productTypeInfo
+          }
+          this.$refs.previewModal.pageInit(resuleObj)
+        }
+      }
+      this.openProductModal = true
+    },
+    closeProductModal () {
+      this.previewList = []
+      this.openProductModal = false
     }
   },
   watch: {
@@ -431,11 +493,11 @@ export default {
     .tabBox::-webkit-scrollbar-track {
       background: transparent;
     }
-     
+
     .tabBox::-webkit-scrollbar-thumb {
       background: transparent;
     }
-     
+
     .tabBox::-webkit-scrollbar-button {
       display: none;
     }
@@ -457,6 +519,11 @@ export default {
       color:#333 !important;
       background:#fff;
    }
+   .flex{
+     display:flex;
+     align-items:center;
+     justify-content:space-between;
+   }
   }
 
 </style>

+ 110 - 0
src/views/promotionRulesManagement/dealerPromotions/productPreviewModal.vue

@@ -0,0 +1,110 @@
+<template>
+  <a-modal
+    centered
+    class="productPreview-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="title"
+    v-model="isShow"
+    @cancel="isShow=false"
+    width="80%">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div style="height:540px;">
+        <ve-table
+          :max-height="500"
+          :columns="columns"
+          :table-data="dataList"
+          :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>
+      <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>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { Empty } from 'ant-design-vue'
+import { hdExportExcel } from '@/libs/exportExcel'
+import { excelProductExcel } from '@/api/promotion'
+export default {
+  name: 'ProductPreviewModal',
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    dataList: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
+      title: '预览弹窗',
+      titName: '',
+      resObj: {},
+      exportLoading: false,
+      spinning: false,
+      columns: [
+        { 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] || '--' } }
+      ]
+    }
+  },
+  methods: {
+    pageInit (obj) {
+      this.resObj = obj
+      this.title = obj.tit + '(已选' + this.dataList.length + '项)'
+    },
+    //  导出
+    handleExport () {
+      const _this = this
+      _this.exportLoading = true
+      _this.spinning = true
+      const ajaxData = {
+        promotionRuleSn: _this.resObj.promotionRuleSn,
+        promotionProductType: _this.resObj.promotionProductType
+      }
+      hdExportExcel(excelProductExcel, ajaxData, '促销活动' + this.resObj.tit, function () {
+        _this.exportLoading = false
+        _this.spinning = false
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.table.clearTable()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .productPreview-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 5px 0 10px;
+    }
+  }
+</style>