chenrui 9 kuukautta sitten
vanhempi
commit
e5fd867864

+ 144 - 208
src/views/easyPassManagement/promotionalActivities/edit.vue

@@ -125,12 +125,11 @@
             <!-- 买产品送代金券 -->
             <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
               <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
-                <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="promoRule.ruleName">
+                <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="validName">
                   <a-input
-                    :disabled="isDisabled"
-                    id="promotionEdit-ruleName"
+                    id="promotionEdit-validName"
                     :maxLength="20"
-                    v-model.trim="form.promoRule.ruleName"
+                    v-model.trim="form.validName"
                     placeholder="请输入券名称(最多20个字符)"
                     allowClear />
                 </a-form-model-item>
@@ -138,71 +137,66 @@
               <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
                 <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
                   <a-input
-                    :disabled="isDisabled"
-                    id="promotionEdit-ruleTitle"
+                    id="promotionEdit-validTitle"
                     :maxLength="20"
-                    v-model.trim="form.promoRule.ruleTitle"
+                    v-model.trim="form.validTitle"
                     placeholder="请输入券副标题(最多20个字符)"
                     allowClear />
                 </a-form-model-item>
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item label="生成方式" prop="promoRule.ruleBaseType">
+                <a-form-model-item label="生成方式" prop="validBaseType">
                   <v-select
                     style="width:40%;"
-                    v-model="form.promoRule.ruleBaseType"
+                    v-model="form.validBaseType"
                     id="promotionEdit-ruleBaseType"
-                    code="PROMO_RULE_BASE_TYPE"
-                    :disabled="isDisabled"
+                    code="SHOP_PROMO_VALID_BASE_TYPE"
+                    placeholder="请选择生成方式"
                     allowClear></v-select>
                 </a-form-model-item>
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item label="券有效期" prop="promoRule.validType">
+                <a-form-model-item label="券有效期" prop="validType">
                   <v-select
                     style="width:40%;"
-                    v-model="form.promoRule.validType"
+                    v-model="form.validType"
                     placeholder="请选择券有效期"
                     id="promotionEdit-validType"
-                    code="PROMO_RULE_TICKET_TYPE"
-                    :disabled="isDisabled"
+                    code="SHOP_PROMO_VALID_TYPE"
                     @change="handleValidType"
                     allowClear></v-select>
                   <a-range-picker
-                    v-show="form.promoRule.validType==='FIXED'"
+                    v-show="form.validType==='FIXED'"
                     style="width:40%;margin-left:10px;"
-                    v-model="time"
+                    v-model="timeLimit"
                     :format="dateFormat"
                     id="promotionEdit-time"
-                    @change="dateChange"
-                    :disabled="isDisabled"
+                    @change="dateLimitChange"
                     :disabled-date="disabledDate"
                     :placeholder="['开始时间', '结束时间']" />
-                  <span style="width:40%;margin-left:10px;" v-show="form.promoRule.validType==='LIMIT'">
+                  <span style="width:40%;margin-left:10px;" v-show="form.validType==='LIMIT'">
                     有效期<a-input-number
                       style="margin:0 5px;"
-                      v-model="form.promoRule.validDays"
+                      v-model="form.validDays"
                       :step="1"
                       id="promotionEdit-validDays"
                       :max="99999999"
                       :min="1"
-                      :disabled="isDisabled"
                       :precision="0"/>天
                   </span>
                 </a-form-model-item>
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item class="productName" label="券适用范围" prop="promoRule.range">
+                <a-form-model-item class="productName" label="券适用范围" prop="validScope">
                   全部产品
                 </a-form-model-item>
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item label="使用说明" prop="promoRule.ruleExplain">
+                <a-form-model-item label="使用说明" prop="validInfo">
                   <a-input
-                    v-model="form.promoRule.ruleExplain"
-                    :disabled="isDisabled"
+                    v-model="form.validInfo"
                     type="textarea"
-                    id="promotionEdit-ruleExplain"
+                    id="promotionEdit-validInfo"
                     placeholder="请输入使用说明(最多50个字符)"
                     :maxLength="50" />
                 </a-form-model-item>
@@ -210,7 +204,7 @@
             </div>
             <div v-if="isShowNextStep">
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
+                <a-form-model-item prop="productNum" :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
                   <div class="productInfo flex-center">
                     <!-- 买产品送产品 -->
                     <div v-if="pageType==='BUY_PROD_GIVE_PROD'">
@@ -241,36 +235,29 @@
                     </div>
                     <!-- 特价产品 -->
                     <div v-if="pageType==='PROMO_PROD'" style="width:80%;">
-                      <a-select
-                        id="promotionList-discountType"
-                        default-value="0"
+                      <v-select
                         v-model="form.discountType"
-                        placeholder="请选择"
-                        style="width:20%;margin-right:5px;"
+                        ref="promoState"
+                        id="promotionList-discountType"
+                        code="SHOP_PROMO_DISCOUNT_TYPE"
                         size="small"
+                        style="width:15%;margin-right:5px;"
                         @change="handleDiscountType"
-                        allowClear>
-                        <a-select-option value="1" id="promotionList-discountType1">
-                          直降
-                        </a-select-option>
-                        <a-select-option value="2" id="promotionList-discountType2">
-                          打折
-                        </a-select-option>
-                      </a-select><span>{{ form.discountType==='1'? '直降':'折扣' }}</span>
+                        placeholder="请选择"
+                        allowClear></v-select>
+                      <span>{{ form.discountType==='STRAIGHT_DOWN'? '直降':'折扣' }}</span>
                       <a-input-number
-                        v-model="form.promoRule.ruleValue"
-                        style="width:20%;margin:0 5px;"
+                        v-model="resultValue"
+                        style="width:15%;margin:0 5px;"
                         :min="0"
                         :step="1"
                         :precision="2"
                         :max="99999999"
-                        id="promotionEdit-ruleValue"
-                        :disabled="isDisabled"
-                        size="small"/>{{ form.discountType==='1'? '元':'%' }}
+                        id="promotionEdit-resultValue"
+                        size="small"/>{{ form.discountType==='STRAIGHT_DOWN'? '元':'%' }}
                       <a-button
                         type="primary"
                         id="promotionEdit-addSet-btn"
-                        :disabled="isDisabled"
                         class="button-primary"
                         size="small"
                         @click="handleBatchAdd">批量设置</a-button>
@@ -279,14 +266,13 @@
                     <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
                       返券金额
                       <a-input-number
-                        v-model="form.promoRule.ruleValue"
+                        v-model="resultValue"
                         style="margin:0 5px;"
                         :min="0"
                         :step="1"
                         :precision="2"
                         :max="99999999"
-                        id="promotionEdit-ruleValue"
-                        :disabled="isDisabled"
+                        id="promotionEdit-resultValue"
                         size="small"/>元
                       <a-button
                         type="primary"
@@ -302,7 +288,7 @@
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                 <div style="width: 83%;margin:0 auto 10px;">
-                  <productTable ref="chooseProductList" :promoActiveSn="form.promoSn" :disabledVal="isDisabled"></productTable>
+                  <productTable ref="chooseProductList" :promoActiveSn="form.promoSn" :discountType="form.discountType" :activeType="pageType"></productTable>
                 </div>
               </a-col>
             </div>
@@ -351,8 +337,6 @@ import chooseDealer from '@/views/easyPassManagement/homepageCarouselImg/chooseD
 import productTable from './productTable'
 import chooseProduct from './chooseProductsModal.vue'
 // 接口
-import { productTypeQuery } from '@/api/productType'
-import { promoActivePublish, promoActiveDetail, saveBatchEntity, promoCreateBatch, deleteByProductType } from '@/api/promoActive'
 import { saveChooseProduct, saveShopPromo, shopPromoDetail } from '@/api/shopPromo'
 export default {
   name: 'ProductBrandEditModal',
@@ -385,23 +369,23 @@ export default {
         description: '', // '促销描述'
         dealerEditFlag: '0', // 加盟商编辑 0否 1是
         dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
-        rangeList: []// 选择产品列表
-        // 'discountType': '特价产品 - 优惠方式',
-        // 'validName': '券名称',
-        // 'validTitle': '券副标题',
-        // 'validBaseType': '券生成方式',
-        // 'validType': '券有效期类型',
-        // 'validStartDate': '券生效时间',
-        // 'validEndDate': '券失效时间',
-        // 'validDays': '券有效期天数',
-        // 'validScope': '券适用范围标记 1-全部 0-指定  死值 1'
-
+        rangeList: [], // 选择产品列表
+        discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
+        validName: '', // 券名称
+        validTitle: '', // 券副标题
+        validBaseType: undefined, // 券生成方式
+        validType: undefined, // 券有效期类型
+        validStartDate: undefined, // 券生效时间
+        validEndDate: undefined, // 券失效时间
+        validDays: undefined, // 券有效期天数
+        validScope: '1', // 券适用范围标记 1-全部 0-指定  死值 1
+        validInfo: '', // 使用说明
+        productNum: undefined
       },
       conditionValue: undefined, // 买产品送产品 买
-      resultValue: undefined, // 买产品送产品  赠
-
+      resultValue: undefined, // 买产品送产品  赠  返券金额
       chooseDealerList: [], // 所选经销商数据
-      time: [], // 有效期
+      timeLimit: [], // 有效期
       promotionName: '', // 促销名称
       showProModal: false, // 打开产品弹窗
       isShowNextStep: false, // 是否显示下一步 并提交一半配置产品
@@ -418,7 +402,12 @@ export default {
         imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
         description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
         dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }],
-        rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }]
+        rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }],
+        validName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
+        validBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
+        validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
+        validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }]
+        // productNum: [{ required: true, message: '选择产品不能为空', trigger: ['change', 'blur'] }]
       }
     }
   },
@@ -447,6 +436,16 @@ export default {
         this.form.time = []
       }
     },
+    // 有效期
+    dateLimitChange (date, dateStrings) {
+      if (dateStrings && dateStrings[0]) {
+        this.timeLimit = dateStrings
+        this.form.validStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
+        this.form.validEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
+      } else {
+        this.timeLimit = []
+      }
+    },
     // 打开产品弹窗
     insterProduct (obj) {
       if (obj && Object.keys(obj).length > 0) {
@@ -454,6 +453,10 @@ export default {
       }
       this.showProModal = true
     },
+    handleDiscountType (val) {
+      this.form.discountType = val
+      this.resultValue = undefined
+    },
     // 关闭产品弹窗
     closeProductModal () {
       this.showProModal = false
@@ -476,33 +479,53 @@ export default {
           _this.$refs.imageSet.setFileList(res.data.imageUrl)
         }
         _this.form = res.data
+        _this.isShowNextStep = true
         if (_this.$route.params.pageType === 'edit') {
           _this.pageType = res.data.promoType
           _this.promotionName = res.data.promoName
         }
-
-        _this.isShowNextStep = true
+        _this.$nextTick(() => {
+          _this.$refs.chooseProductList.pageInit()
+        })
       }
     },
     // 券有效期 change
     handleValidType (con) {
-      this.form.promoRule.validType = con
+      this.form.validType = con
       if (con === 'FIXED') {
-        this.form.promoRule.validDays = undefined
+        this.form.validDays = undefined
       } else {
-        this.time = []
-        this.form.promoRule.validStartDate = undefined
-        this.form.promoRule.validEndDate = undefined
+        this.timeLimit = []
+        this.form.validStartDate = undefined
+        this.form.validEndDate = undefined
       }
     },
     //  确定保存  验证必填
     handleSave (type) {
       const _this = this
-
       // 验证组件必填项
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          _this.$refs.ruleForm.clearValidate('rangeList')
+          _this.form.promoType = _this.pageType
+          _this.form.productNum = _this.$refs.chooseProductList.getChooseProductNum()
+
+          if (!_this.form.productNum) {
+            _this.$message.warning('请选择返券产品!')
+            return
+          }
+          if (_this.form.promoType === 'BUY_PROD_GIVE_VALID') {
+            if (_this.form.validType === 'FIXED') {
+              if (!_this.form.validStartDate || !_this.form.validEndDate) {
+                _this.$message.warning('请输入券有效期!')
+                return false
+              }
+            } else {
+              if (!_this.form.validDays) {
+                _this.$message.warning('请输入券有效期!')
+                return false
+              }
+            }
+          }
           _this.savePartInfo(type)
         }
       })
@@ -510,47 +533,31 @@ export default {
     // 保存
     savePartInfo (type) {
       const _this = this
-      _this.form.promoType = _this.pageType
       var formData = JSON.parse(JSON.stringify(_this.form))
       delete formData.time
-      // // 跳转链接
-      // if (formData.contentType == 'LINK') {
-      //   delete formData.contentLink
-      //   if (_this.productRangeList && _this.productRangeList.length > 0) {
-      //     formData.promoRule.productRangeList = _this.productRangeList.map(item => { return { productTypeSn: item } })
-      //   }
-      //   // 促销活动
-      //   if (_this.form.linkType === '1') {
-      //     if (_this.form.promoRule.validType === 'FIXED') {
-      //       if (!_this.form.promoRule.validStartDate || _this.form.promoRule.validStartDate.validEndDate) {
-      //         _this.$message.warning('请输入券有效期!')
-      //         return false
-      //       }
-      //     } else {
-      //       if (!_this.form.promoRule.validDays) {
-      //         _this.$message.warning('请输入券有效期!')
-      //         return false
-      //       }
-      //     }
-      //     formData.publishFlag = _this.form.promoRule.publishFlag
-      //     formData.dealerEditFlag = _this.form.promoRule.dealerEditFlag
-      //   } else {
-      //     formData.promoRule = undefined
-      //   }
-      //   if (_this.$refs.chooseProductList) {
-      //     const numInfo = _this.$refs.chooseProductList.getDataNum()
-      //     if (numInfo == 0) {
-      //       _this.$message.warning('请选择返券产品!')
-      //       return
-      //     }
-      //   }
-      // } else {
-      //   formData.promoRule = undefined
-      // }
+      delete formData.productNum
       _this.spinning = true
       saveShopPromo(formData).then(res => {
         if (res.status == 200) {
-          debugger
+          _this.spinning = false
+          if (res.data.errorMsg && res.data.errorMsg.length > 0) {
+            this.$confirm({
+              title: '提示',
+              content: res.data.errorMsg.map((item, i) => { return <p>{i * 1 + 1}、{item}</p> }),
+              centered: true,
+              okText: '知道了',
+              cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
+              cancelButtonProps: {
+                style: {
+                  display: 'none' // 通过设置样式隐藏取消按钮
+                }
+              },
+              onOk () {
+                console.log('知道了')
+              }
+            })
+            return
+          }
           _this.$message.success(res.message)
           if (type === 'all') {
             _this.$nextTick(() => {
@@ -561,24 +568,15 @@ export default {
             _this.isShowNextStep = true
             _this.getDetail({ sn: res.data.shopPromo.promoSn })
           }
-          _this.spinning = false
         } else {
           _this.spinning = false
         }
       })
     },
-    //  图片上传
+    //  封面图片上传
     changeImage (file) {
       this.form.imageUrl = file
     },
-    // 视频上传
-    changeVideo (file) {
-      this.form.content = file
-    },
-    //  文本编辑器
-    editorChange (html, text) {
-      this.form.content = html
-    },
     // 重置
     resetSearchForm () {
       if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
@@ -593,31 +591,29 @@ export default {
         this.$refs.editor.setHtml('')
       }
       this.form = {
-        promoActiveSn: undefined, // 促销活动sn
-        title: '', // 标题
-        imageSet: '', // 图片
-        contentType: 'IMAGE_CONTENT', // 内容类型
-        content: '', // 内容
-        contentLink: '', // 链接内容
+        promoType: undefined, // 促销类型
+        promoName: '', // '促销名称'
+        time: [], // 促销时间
+        promoStartDate: undefined, // 促销时间-开始
+        promoEndDate: undefined, // 促销时间-结束
         sort: undefined, // 排序
-        publishFlag: '0', // 是否发布
-        linkType: '1',
-        dealerEditFlag: '0', // 加盟商编辑 1是 0否
-        productRangeList: [], // 产品范围列表
-        promoRule: {
-          ruleType: 'ticket', // 基本规则类型
-          ruleName: '', // 券名称
-          ruleTitle: '', // 副标题
-          ruleBaseType: 'category', // 券生成方式
-          ruleExplain: '', // 使用说明
-          validType: undefined, // 券有效期类型
-          validStartDate: undefined, // 券生效时间
-          validEndDate: undefined, // 券失效时间
-          validDays: undefined, // 券有效期天数
-          dealerEditFlag: '0', // 加盟商编辑 1是 0否
-          publishFlag: '0', // 是否发布
-          range: '1'
-        } // 链接配置内容
+        allDealerFlag: '1', // 全部经销商 1   部分经销商0'
+        imageUrl: undefined, // 促销封面图
+        description: '', // '促销描述'
+        dealerEditFlag: '0', // 加盟商编辑 0否 1是
+        dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
+        rangeList: [], // 选择产品列表
+        discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
+        validName: '', // 券名称
+        validTitle: '', // 券副标题
+        validBaseType: undefined, // 券生成方式
+        validType: undefined, // 券有效期类型
+        validStartDate: undefined, // 券生效时间
+        validEndDate: undefined, // 券失效时间
+        validDays: undefined, // 券有效期天数
+        validScope: '1', // 券适用范围标记 1-全部 0-指定  死值 1
+        validInfo: '', // 使用说明
+        productNum: undefined
       }
       this.isShowNextStep = false
       this.isDisabled = false
@@ -628,42 +624,6 @@ export default {
         this.$refs.ruleForm.resetFields()
       }
     },
-    // 获取产品范围数据
-    // getTreeData () {
-    //   productTypeQuery({}).then(res => {
-    //     if (res.status == 200) {
-    //       this.productTypeList = res.data
-    //     } else {
-    //       this.productTypeList = []
-    //     }
-    //   })
-    // },
-    // 选择内容类型
-    changeContentType (e) {
-      if (e === 'LINK') {
-        this.form.linkType = '1'
-        this.form.contentLink = '/pagesB/promoDetail'
-        this.form.content = '/pagesB/promoDetail'
-      } else {
-        this.form.linkType = undefined
-        this.form.contentLink = ''
-        this.form.content = ''
-      }
-      this.form.contentType = e
-    },
-    // 填入link内容
-    handleLink (con) {
-      if (!con.target.value || con.target.value != '/pagesB/promoDetail') {
-        this.form.linkType = '2'
-      } else {
-        this.form.linkType = '1'
-      }
-      this.form.contentLink = con.target.value
-    },
-    // 选择货架促销填入默认值
-    handleLinkType (val) {
-      this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
-    },
     // 添加产品
     handleAddProduct () {
       this.chooseTypeList = this.productRangeList
@@ -690,31 +650,10 @@ export default {
       saveChooseProduct(productArr).then(res => {
         if (res.status == 200) {
           this.showProModal = false
-          // // 获取产品列表 有分页
-          this.$refs.chooseProductList.pageInit()
-        }
-      })
-    },
-    // 选择产品范围
-    onChangeTree (e) {
-      deleteByProductType({ promoActiveSn: this.$route.params.sn, productTypeSnList: this.productRangeList || [] }).then(res => {
-        if (res.status == 200) {
+          // 获取产品列表 有分页
           this.$refs.chooseProductList.pageInit()
         }
       })
-      // 保存产品范围
-      const newArr = this.productRangeList.map(item => {
-        return {
-          promoActiveSn: this.$route.params.sn,
-          promoRuleSn: this.form.promoRule.promoRuleSn,
-          productTypeSn: item
-        }
-      })
-      saveBatchEntity({ list: newArr, promoActiveSn: this.$route.params.sn }).then(res => {
-        if (res.status == 200) {
-          console.log('保存产品范围成功')
-        }
-      })
     },
     // 初始化
     pageInit () {
@@ -723,9 +662,6 @@ export default {
       } else {
         this.pageType = this.$route.params.pageType
       }
-      // this.$nextTick(() => {
-      //   this.getTreeData()
-      // })
     }
   },
   mounted () {

+ 17 - 17
src/views/easyPassManagement/promotionalActivities/list.vue

@@ -12,7 +12,7 @@
             </a-col>
             <a-col :md="5" :sm="24">
               <a-form-item label="促销名称">
-                <a-input id="promotion-promotionName" v-model.trim="queryParam.promoName" allowClear placeholder="请输入促销名称"/>
+                <a-input id="promotion-promoName" v-model.trim="queryParam.promoName" allowClear placeholder="请输入促销名称"/>
               </a-form-item>
             </a-col>
             <a-col :md="5" :sm="24">
@@ -21,7 +21,7 @@
                   v-model="queryParam.promotionType"
                   ref="promotionType"
                   id="promotion-promotionType"
-                  code="PROMO_STATE"
+                  code="SHOP_PROMO_PROMO_TYPE"
                   placeholder="请选择促销类型"
                   allowClear></v-select>
               </a-form-item>
@@ -29,10 +29,10 @@
             <a-col :md="5" :sm="24">
               <a-form-item label="促销状态">
                 <v-select
-                  v-model="queryParam.publishState"
-                  ref="publishState"
-                  id="promotion-publishState"
-                  code="PROMO_STATE"
+                  v-model="queryParam.promoState"
+                  ref="promoState"
+                  id="promotion-promoState"
+                  code="PROMOTION_STATE"
                   placeholder="请选择促销状态"
                   allowClear></v-select>
               </a-form-item>
@@ -195,19 +195,17 @@ export default {
       openCustomerModal: false, // 打开参与经销商弹窗
       openDetailModal: false, // 打开详情弹窗
       createDate: [], //  创建时间
-      itemId: '', // 当前活动sn
-      pageType: '', // 发布类型  add  促销发布  edit 发布修改
-      dealerSn: [], // 经销商sn
-      openSetImgModal: false, // 设置首页轮播图
+      openSetImgModal: false, // 设置首页轮播图弹窗
       // 查询参数
       queryParam: {
         beginDate: undefined, // 促销开始时间
         endDate: undefined, // 促销结束时间
-        name: '', // 促销名称
+        promoName: '', // 促销名称
         promotionType: '', // 促销类型
-        publishState: undefined// 是否发布
+        promoState: undefined// 是否发布
       },
-      itemObj: null,
+      itemId: '', // 当前活动sn
+      itemObj: null, // 促销活动当前行信息
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
@@ -227,7 +225,8 @@ export default {
           return data
         })
       },
-      columns: [// 表头
+      // 表头
+      columns: [
         { 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: '促销名称', scopedSlots: { customRender: 'promotionName' }, width: '15%', align: 'left' },
@@ -254,7 +253,7 @@ export default {
         this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
       })
     },
-    // 编辑
+    // 新增  编辑
     handleEdit (type, row) {
       if (type === 'edit') {
         this.$router.push({ name: 'promotionalEditActivity', params: { pageType: type, sn: row.promoSn } })
@@ -309,8 +308,9 @@ export default {
       this.$refs.rangeCreateDate.resetDate(this.createDate)
       this.queryParam.beginDate = undefined
       this.queryParam.endDate = undefined
-      this.queryParam.name = ''
-      this.queryParam.publishState = undefined
+      this.queryParam.promoName = ''
+      this.queryParam.promotionType = ''
+      this.queryParam.promoState = undefined
       this.$refs.table.refresh(true)
     },
     // 促销发布

+ 64 - 47
src/views/easyPassManagement/promotionalActivities/productTable.vue

@@ -23,7 +23,6 @@
             :max="99999999"
             @blur="editProductVal(record,'conditionValue')"
             placeholder="请输入"
-            :disabled="disabledVal"
             v-model="record.conditionValue"
             :id="'productTable-conditionValue'+record.id "
             size="small"/>
@@ -35,13 +34,36 @@
             :step="1"
             :precision="0"
             :max="99999999"
-            :disabled="disabledVal"
             @blur="editProductVal(record,'resultValue')"
             placeholder="请输入"
             v-model="record.resultValue"
             :id="'productTable-resultValue'+record.id "
             size="small"/>
         </template>
+        <!-- 特价产品 标题 -->
+        <template slot="titleType">
+          {{ activeType==='PROMO_PROD'?discountType==='STRAIGHT_DOWN'?'直降金额':'折扣(%)':activeType==='BUY_PROD_GIVE_VALID'?'返券金额':'--' }}
+        </template>
+        <!-- 直降  打折 ||   买产品送代金券 返券金额 -->
+        <template slot="priceValue" slot-scope="text,record">
+          <a-input-number
+            :min="0.01"
+            :step="1"
+            :precision="2"
+            :max="99999999"
+            @blur="editProductVal(record,'resultValue')"
+            placeholder="请输入"
+            v-model="record.resultValue"
+            :id="'productTable-resultValue'+record.id "
+            size="small"/>
+        </template>
+        <!-- 特价价格-->
+        <template slot="specialOffer" slot-scope="text,record">
+          <!-- 直降 -->
+          <span v-if="discountType==='STRAIGHT_DOWN'">{{ (record.shopProductPrice-record.resultValue).toFixed(2) }}</span>
+          <!-- 折扣 -->
+          <span v-else>{{ (record.shopProductPrice*record.resultValue/100).toFixed(2) }}</span>
+        </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="text,record">
           <a-button
@@ -49,7 +71,6 @@
             type="link"
             class="button-error"
             :id="'productTable-del-btn'+record.id "
-            :disabled="disabledVal"
             @click="handleDel(record)"
           >删除</a-button>
         </template>
@@ -72,9 +93,13 @@ export default {
       type: String,
       default: ''
     },
-    disabledVal: {// 修改编辑时,禁用标志
-      type: Boolean,
-      default: false
+    activeType: {// 促销活动类型
+      type: String,
+      default: ''
+    },
+    discountType: {// 特价产品时,优惠方式
+      type: String,
+      default: ''
     }
   },
   data () {
@@ -82,23 +107,13 @@ export default {
       spinning: false,
       rowSelectionInfo: null, // 已选数据
       queryParam: {}, // 查询条件
-      dataListQty: '0', // 表格数据总条数
-      columns: [// 表头
-        { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '原厂编码', dataIndex: 'productOrigCode', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '买', scopedSlots: { customRender: 'conditionValue' }, width: '10%', align: 'center' },
-        { title: '赠', scopedSlots: { customRender: 'resultValue' }, width: '10%', align: 'center' },
-        { title: '商城售价', dataIndex: 'shopProductPrice', width: '10%', align: 'right', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ],
+      chooseProductNum: 0, // 列表数据个数
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
-        params.promoActiveSn = this.promoActiveSn
+        params.promoSn = this.promoActiveSn
         return chooseProductList(params).then(res => {
           let data
           if (res.status == 200) {
@@ -106,15 +121,9 @@ export default {
             const no = (data.pageNo - 1) * data.pageSize
             for (var i = 0; i < data.list.length; i++) {
               data.list[i].no = no + i + 1
-              // // 活动价初始值,活动价=参考终端价
-              // if (!data.list[i].price) {
-              //   data.list[i].price = data.list[i].terminalPrice
-              // } else {
-              //   data.list[i].price = data.list[i].price
-              // }
             }
+            this.chooseProductNum = data.count
             this.disabled = false
-            // this.dataListQty = res.data.count
           }
           this.spinning = false
           return data
@@ -122,6 +131,33 @@ export default {
       }
     }
   },
+  computed: {
+    columns () {
+      const _this = this
+      const arr = [
+        { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '原厂编码', dataIndex: 'productOrigCode', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '商城售价', dataIndex: 'shopProductPrice', width: '10%', align: 'right', customRender: text => { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
+      ]
+      if (_this.activeType === 'BUY_PROD_GIVE_PROD') {
+        arr.splice(4, 0, { title: '买', scopedSlots: { customRender: 'conditionValue' }, width: '10%', align: 'center' })
+        arr.splice(5, 0, { title: '赠', scopedSlots: { customRender: 'resultValue' }, width: '10%', align: 'center' })
+      } else if (_this.activeType === 'PROMO_PROD') {
+        arr.splice(5, 0, { slots: { title: 'titleType' }, scopedSlots: { customRender: 'priceValue' }, width: '10%', align: 'center' })
+        arr.splice(6, 0, { title: '特价价格', width: '10%', align: 'right', scopedSlots: { customRender: 'specialOffer' } })
+      } else {
+        arr.splice(5, 0, { slots: { title: 'titleType' }, scopedSlots: { customRender: 'priceValue' }, width: '10%', align: 'center' })
+      }
+      return arr
+    },
+    // 计算列表选中数据条数
+    selectCount () {
+      return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length
+    }
+  },
   methods: {
     // 表格选中项
     rowSelectionFun (obj) {
@@ -171,32 +207,13 @@ export default {
         }
       })
     },
-    // 获取表格总条数
-    getDataNum () {
-      return this.dataListQty
+    getChooseProductNum () {
+      return this.chooseProductNum
     },
     // 初始化
     pageInit () {
-      this.$nextTick(() => {
-        this.$refs.table.refresh(true)
-      })
+      this.$refs.table.refresh(true)
     }
-  },
-  mounted () {
-    this.pageInit()
-  },
-  activated () {
-    this.pageInit()
-  },
-  beforeRouteEnter (to, from, next) {
-    next(vm => {})
   }
 }
 </script>
-
-<style>
- /* form input[type='radio'], form input[type='checkbox'] {
-      width: 15px;
-      height: 14px;
-  } */
-</style>