chenrui hace 10 meses
padre
commit
c4a341daaa

+ 25 - 3
src/views/promotionRulesManagement/promotionManagement/chooseProductsModal.vue

@@ -109,13 +109,19 @@ export default {
       type: Boolean,
       default: false
     },
-    chooseData: {
+    chooseData: {// 隐藏选择的产品
       type: Array,
       default: () => {
         return []
       }
     },
-    chooseType: {
+    chooseType: {// 选中的分类
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    chooseProduct: {// 当前行选中的数据
       type: Array,
       default: () => {
         return []
@@ -179,8 +185,24 @@ export default {
               data.list[i].no = no + i + 1
             }
             this.disabled = false
+            const _this = this
+            // 选中回显
+            if (_this.chooseProduct && _this.chooseProduct.length > 0) {
+              const selectedRows = []
+              let selectedRowKeys = []
+              data.list.forEach(item => {
+                const flag = _this.chooseProduct.includes(item.productSn)
+                if (flag) {
+                  selectedRows.push(item)
+                }
+              })
+              selectedRowKeys = _this.chooseProduct
+              _this.$nextTick(() => { // 页面渲染完成后的回调
+                _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
+              })
+            }
           }
-          this.spinning = false
+          _this.spinning = false
           return data
         })
       },

+ 28 - 38
src/views/promotionRulesManagement/promotionManagement/edit.vue

@@ -140,7 +140,7 @@
           <!-- 参数配置 -->
           <a-row style="width:83%;margin:0 auto 24px;" v-if="form.contentType =='LINK'&&form.linkType!='2'">
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <a-checkbox @change="onChangeParams" :disabled="isDisabled" v-model="isShowParams">参数配置</a-checkbox>
+              <a-checkbox :disabled="true" v-model="isShowParams">参数配置</a-checkbox>
             </a-col>
             <a-col
               :xs="24"
@@ -150,11 +150,17 @@
               :xl="24"
               v-show="isShowParams">
               <!-- 参数配置内容 -->
-              <setPromotion ref="setContent" style="margin-top:20px;" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
+              <setPromotion ref="setContent" style="margin-top:20px;" :pageType="pageType" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
             </a-col>
           </a-row>
           <a-row>
-            <a-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
+            <a-col
+              :xs="24"
+              :sm="24"
+              :md="24"
+              :lg="16"
+              :xl="16"
+              v-if="form.contentType =='LINK'&&form.linkType==='1'">
               <a-form-model-item label="加盟商编辑" prop="dealerEditFlag" :label-col="{span:3}" :wrapper-col="{span:18}">
                 <a-radio-group button-style="solid" :disabled="(form.contentType !='LINK'||!isShowParams||isDisabled)" v-model="form.dealerEditFlag">
                   <a-radio-button value="1">
@@ -207,6 +213,7 @@
       ref="chooseProduct"
       :chooseType="chooseTypeList"
       :chooseData="chooseDataList"
+      :chooseProduct="chooseProductList"
       :openModal="showProModal"
       v-if="pageType!='see'"
       @ok="addProductSuccess"
@@ -263,11 +270,12 @@ export default {
       },
       pageType: undefined, // 页面类型
       showProModal: false,
-      isShowParams: false, // 是否显示参数配置内容
+      isShowParams: true, // 是否显示参数配置内容
       openShowModal: false,
       isDisabled: false, // 控制是否能编辑
       chooseTypeList: [],
       chooseDataList: [],
+      chooseProductList: [],
       imageSet: [], // 回显显示图片数据
       rules: {
         title: [
@@ -298,40 +306,12 @@ export default {
     }
   },
   methods: {
-    // 设置参数
-    onChangeParams (e) {
-      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 (obj) {
       if (obj && Object.keys(obj).length > 0) {
         this.chooseTypeList = obj.typeArr
         this.chooseDataList = obj.productArr
+        this.chooseProductList = obj.chooseProductArr
       }
       this.showProModal = true
     },
@@ -424,6 +404,8 @@ export default {
             _this.saveInfo()
           }
         })
+      } else {
+        _this.saveInfo()
       }
     },
     saveInfo () {
@@ -470,8 +452,12 @@ export default {
     // 重置
     resetSearchForm () {
       if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
-        this.$refs.imageSet.setFileList('')
-        this.$refs.videoSet.setFileList('')
+        if (this.$refs.imageSet) {
+          this.$refs.imageSet.setFileList('')
+        }
+        if (this.$refs.videoSet) {
+          this.$refs.videoSet.setFileList('')
+        }
       }
       if (this.$refs.editor) {
         this.$refs.editor.setHtml('')
@@ -484,7 +470,7 @@ export default {
         content: '', // 内容
         contentLink: '', // 链接内容
         sort: undefined, // 排序
-        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
+        ruleEnableFlag: '1', // 参数配置 1勾选配置  0不能配置
         publishState: 'UNPUBLISH', // 是否发布
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
         // 参数配置数据
@@ -504,8 +490,12 @@ export default {
         }
       }
       this.isDisabled = false
-      this.$refs.setContent.clearContent()
-      this.$refs.ruleForm.resetFields()
+      if (this.$refs.setContent) {
+        this.$refs.setContent.clearContent()
+      }
+      if (this.$refs.ruleForm) {
+        this.$refs.ruleForm.resetFields()
+      }
     },
     // 选择内容类型
     changeContentType (e) {

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

@@ -116,7 +116,7 @@
                 type="link"
                 class="button-warning"
                 @click="handleRelease(record,'edit')"
-                v-if="(record.publishState=='PUBLISH' || record.publishState=='CLOSE')&&$hasPermissions('B_promotionManagementContent')"
+                v-if="((record.publishState=='PUBLISH'&&record.content!='/pagesB/promoDetail') || record.publishState=='CLOSE')&&$hasPermissions('B_promotionManagementContent')"
                 id="promotion-modify-btn">发布修改</a-button>
               <a-button
                 size="small"

+ 27 - 10
src/views/promotionRulesManagement/promotionManagement/setPromotion.vue

@@ -170,7 +170,7 @@
                   :placeholder="['开始时间', '结束时间']" />
               </a-radio>
               <a-radio :style="radioStyle" value="LIMIT">
-                <span>领取后,当天生效,有效期</span><a-input-number
+                <span>领取后,当天生效,有效期</span><a-input-number
                   style="margin:0 5px;"
                   v-model="sellForm.validDays"
                   :step="1"
@@ -201,6 +201,10 @@ export default {
     disabledVal: {
       type: Boolean,
       default: false
+    },
+    pageType: {
+      type: String,
+      default: 'edit'
     }
   },
   data () {
@@ -249,7 +253,7 @@ export default {
         ruleBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
         ruleExplain: [{ required: true, message: '请输入使用说明', trigger: ['change', 'blur'] }],
         validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
-        ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'change' }]
+        ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'blur' }]
       },
       productTypeList: [],
       time: []
@@ -300,21 +304,24 @@ export default {
       this.posNum = pos
       const typeArr = this.sellForm.productRangeList || []
       let productArr = []
+      let chooseProductArr = []
       this.couponList.forEach(item => {
         if (item.ruleProductList && item.ruleProductList.length > 0) {
-          const arr = item.ruleProductList.map(con => { return con.productSn })
-          productArr = productArr.concat(arr)
+          if (item.id != row.id) {
+            const arr = item.ruleProductList.map(con => { return con.productSn })
+            productArr = productArr.concat(arr)
+          } else {
+            const arr = item.ruleProductList.map(con => { return con.productSn })
+            chooseProductArr = chooseProductArr.concat(arr)
+          }
         }
       })
-      this.$emit('addProduct', { typeArr, productArr })
+      this.$emit('addProduct', { typeArr, productArr, chooseProductArr })
     },
     onChangeTree () {
       this.couponList = []
       this.addCouponCon()
     },
-    handleDropdownVisibleChange () {
-      debugger
-    },
     // 新增券内容
     async addCouponCon () {
       if (this.couponList.length >= 10) {
@@ -418,13 +425,23 @@ export default {
       }
       this.sellForm = { ...this.sellForm, ...info }
       this.couponList = arr
+    },
+    pageInit () {
+      const _this = this
+      _this.getTreeData()
+      if (_this.pageType === 'add') {
+        _this.addCouponCon()
+      }
     }
   },
   mounted () {
-    this.getTreeData()
+    this.pageInit()
   },
   activated () {
-    this.getTreeData()
+    this.pageInit()
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
   }
 }
 </script>