浏览代码

修改bug

chenrui 10 月之前
父节点
当前提交
64a7fdc690

+ 63 - 24
src/api/promoActive.js

@@ -1,6 +1,6 @@
 import { axios } from '@/utils/request'
 
-//  优惠活动 列表  有分页
+//  修理厂促销  列表  有分页
 export const promoActiveList = (params) => {
   const url = `/promoActive/queryPage/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
@@ -9,60 +9,99 @@ export const promoActiveList = (params) => {
     url: url,
     data: params,
     method: 'post',
-    headers:{
-        'module': encodeURIComponent('列表查询')
+    headers: {
+      'module': encodeURIComponent('列表查询')
     }
   })
 }
-//  优惠活动 保存
-export const promoActiveSave = (params) => {
+//  修理厂促销 新增
+export const promoActiveCreate = (params) => {
   return axios({
-    url: '/promoActive/save',
+    url: '/promoActive/create',
     data: params,
     method: 'post',
-    headers:{
-        'module': encodeURIComponent('新增')
+    headers: {
+      'module': encodeURIComponent('新增')
     }
   })
 }
-//  优惠活动 删除
+
+//  修理厂促销 详情
+export const promoActiveDetail = (params) => {
+  const url = `/promoActive/findBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get'
+  })
+}
+//  修理厂促销 编辑
+export const promoActiveUpdate = (params) => {
+  return axios({
+    url: '/promoActive/update',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('编辑')
+    }
+  })
+}
+
+//  修理厂促销 删除
 export const promoActiveDel = (params) => {
   const url = `/promoActive/delete/${params.sn}`
   return axios({
     url: url,
     method: 'get',
-    headers:{
-        'module': encodeURIComponent('删除')
+    headers: {
+      'module': encodeURIComponent('删除')
     }
   })
 }
-//  优惠活动 详情
-export const promoActiveDetail = (params) => {
-  const url = `/promoActive/findBySn/${params.sn}`
+// 修理厂促销 促销发布
+export const promoActivePublish = (params) => {
   return axios({
-    url: url,
-    method: 'get'
+    url: '/promoActive/updatePublish',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('促销发布')
+    }
   })
 }
-//  优惠活动 启禁用
-export const promoActiveEnable = (params) => {
-  const url = `/promoActive/enable/${params.sn}/${params.flag}`
+// 修理厂促销 选择产品列表
+export const queryWaitingProductPage = (params) => {
+  const url = `/promoRuleProduct/queryWaitingProductPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
   return axios({
     url: url,
-    method: 'get',
-    headers:{
-        'module': encodeURIComponent('启用禁用')
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
     }
   })
 }
+
+// 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('优惠活动明细')
+    headers: {
+      'module': encodeURIComponent('优惠活动明细')
     }
   })
 }

+ 1 - 1
src/config/router.config.js

@@ -3431,7 +3431,7 @@ export const asyncRouterMap = [
                 }
               },
               {
-                path: 'add',
+                path: 'add/:sn/:pageType',
                 name: 'promotionManagementAdd',
                 component: () => import(/* webpackChunkName: "promotionRulesManagement" */ '@/views/promotionRulesManagement/promotionManagement/edit.vue'),
                 meta: {

+ 81 - 47
src/views/promotionRulesManagement/promotionManagement/addModal.vue

@@ -29,7 +29,7 @@
             @change="dateChange"
             :placeholder="['开始时间', '结束时间']" />
         </a-form-model-item>
-        <a-form-model-item label="参与经销商" prop="promoBuyerList">
+        <a-form-model-item label="参与经销商" prop="dealerSnList">
           <a-row :gutter="15">
             <!-- <a-col :md="15" :sm="24">
               <a-select
@@ -48,8 +48,8 @@
             </a-col>
             <a-col :md="24" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
               <div class="buyerBox">
-                <a-tag closable v-for="con in chooseDealerList" :key="con.buyerSn" @close="delBuyerName(con)">
-                  {{ con.buyerName }}
+                <a-tag closable v-for="con in chooseDealerList" :key="con.dealerSn" @close="delBuyerName(con)">
+                  {{ con.dealerName }}
                 </a-tag>
               </div>
             </a-col>
@@ -67,7 +67,20 @@
       </a-form-model>
       <div class="btn-cont">
         <a-button id="promotion-modal-back" @click="isShow = false" >取消</a-button>
-        <a-button type="primary" style="margin-left: 15px;" :loading="spinning" id="promotion-modal-save" @click="handleSave">确定</a-button>
+        <a-button
+          v-if="!isEdit"
+          type="primary"
+          style="margin-left: 15px;"
+          :loading="spinning"
+          id="promotion-modal-save"
+          @click="handleSave">确定</a-button>
+        <a-button
+          v-else
+          type="primary"
+          style="margin-left: 15px;"
+          :loading="spinning"
+          id="promotion-modal-save"
+          @click="handleEdit">确定</a-button>
       </div>
     </a-spin>
     <!-- 选择经销商 -->
@@ -89,9 +102,12 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { promoTerminalSave, promoTerminalDetail } from '@/api/promoTerminal'
-import chooseDealer from './chooseDealer'
 import moment from 'moment'
+// 组件
+import chooseDealer from './chooseDealer'
+// 接口
+import { promoActiveCreate, promoActiveDetail, promoActiveUpdate } from '@/api/promoActive'
+
 export default {
   name: 'PromotionAddModal',
   mixins: [commonMixin],
@@ -126,10 +142,10 @@ export default {
         activeDateEnable: '1',
         buyerLimitEnable: '1',
         description: '',
-        promoBuyerList: []
+        dealerSnList: []
       },
       rules: {
-        promoBuyerList: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
+        dealerSnList: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
         time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
         name: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
         description: [{ required: true, message: '请输入促销描述', trigger: 'blur' }]
@@ -140,18 +156,18 @@ export default {
     }
   },
   methods: {
+    // 禁用日期时间
     disabledDate (current) {
       return current && current < moment().startOf('day')
     },
+    // 选择经销商
     handleDealerModal () {
       this.openDealerModal = true
       const _this = this
       if (_this.chooseDealerList.length == 0) {
-        _this.form.promoBuyerList = []
+        _this.form.dealerSnList = []
       }
-      const arr = _this.chooseDealerList.map(item => {
-        return item.buyerSn
-      })
+      const arr = _this.form.dealerSnList
       // 选择经销商回显
       _this.$nextTick(() => {
         _this.$refs.dealerChoose.pageInit(arr)
@@ -161,35 +177,25 @@ export default {
     dateChange (date, dateStrings) {
       if (dateStrings && dateStrings[0]) {
         this.form.time = dateStrings
-        this.form.activeDateStart = date.length ? dateStrings[0] : ''
-        this.form.activeDateEnd = date.length ? dateStrings[1] : ''
+        this.form.activeDateStart = date.length ? dateStrings[0] + ' 00:00:00' : ''
+        this.form.activeDateEnd = date.length ? dateStrings[1] + ' 23:59:59' : ''
       } else {
         this.form.time = []
       }
     },
     // 添加经销商
     handleAddDealer (list) {
-      this.chooseDealerList = list.map(con => {
-        return {
-          buyerSn: con.dealerSn,
-          buyerName: con.dealerName
-        }
-      })
+      this.chooseDealerList = list
       this.openDealerModal = false
       // 移除表单必填项
-      this.$refs.ruleForm.clearValidate('promoBuyerList')
+      this.$refs.ruleForm.clearValidate('dealerSnList')
     },
     // 获取编辑详情
     getEditInfo () {
-      promoTerminalDetail({ sn: this.itemId }).then(res => {
+      promoActiveDetail({ sn: this.itemId }).then(res => {
         if (res.status == 200) {
           const data = res.data
-          this.chooseDealerList = data.promoBuyerList
-          data.promoBuyerList = data.promoBuyerList.map(item => {
-            return {
-              buyerSn: item.buyerSn
-            }
-          })
+          this.chooseDealerList = data.promoDealerList
           data.time = [data.activeDateStart, data.activeDateEnd]
           this.form = data
         }
@@ -197,24 +203,48 @@ export default {
     },
     // 删除所选经销商
     delBuyerName (row) {
-      const pot = this.chooseDealerList.findIndex(con => { return con.buyerSn == row.buyerSn })
+      const pot = this.chooseDealerList.findIndex(con => { return con.dealerSn == row.dealerSn })
       this.chooseDealerList.splice(pot, 1)
     },
     //  保存促销
     handleSave () {
       const _this = this
       const newArr = this.chooseDealerList.map(item => {
-        return {
-          buyerSn: item.buyerSn
+        return item.dealerSn
+      })
+      this.form.dealerSnList = newArr
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = JSON.parse(JSON.stringify(_this.form))
+          delete form.time
+          _this.spinning = true
+          promoActiveCreate(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.isShow = false
+              _this.$emit('ok', res.data)
+            }
+            _this.spinning = false
+          })
+        } else {
+          _this.spinning = false
+          return false
         }
       })
-      this.form.promoBuyerList = newArr
+    },
+    // 修改促销
+    handleEdit () {
+      const _this = this
+      const newArr = this.chooseDealerList.map(item => {
+        return item.dealerSn
+      })
+      this.form.dealerSnList = newArr
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           delete form.time
           _this.spinning = true
-          promoTerminalSave(form).then(res => {
+          promoActiveUpdate(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.isShow = false
@@ -227,6 +257,23 @@ export default {
           return false
         }
       })
+    },
+    // 重置
+    reSetForm () {
+      this.$refs.ruleForm.resetFields()
+      this.form = {
+        promoActiveSn: undefined,
+        name: '',
+        time: [],
+        activeDateStart: undefined,
+        activeDateEnd: undefined,
+        activeDateEnable: '1',
+        buyerLimitEnable: '1',
+        description: '',
+        dealerSnList: []
+      }
+      this.isEdit = false
+      this.chooseDealerList = []
     }
   },
   watch: {
@@ -238,20 +285,7 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.$refs.ruleForm.resetFields()
-        this.form = {
-          promoActiveSn: undefined,
-          name: '',
-          time: [],
-          activeDateStart: undefined,
-          activeDateEnd: undefined,
-          activeDateEnable: '1',
-          buyerLimitEnable: '1',
-          description: '',
-          promoBuyerList: []
-        }
-        this.isEdit = false
-        this.chooseDealerList = []
+        this.reSetForm()
       } else {
         this.isEdit = !!this.itemId
         if (this.itemId) {

+ 24 - 27
src/views/promotionRulesManagement/promotionManagement/chooseProductsModal.vue

@@ -24,17 +24,17 @@
             <a-row :gutter="15">
               <a-col :md="8" :sm="24">
                 <a-form-model-item label="产品编码">
-                  <a-input id="chooseProducts-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
+                  <a-input id="chooseProducts-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
                 </a-form-model-item>
               </a-col>
               <a-col :md="8" :sm="24">
                 <a-form-model-item label="原厂编码">
-                  <a-input id="chooseProducts-code" v-model.trim="queryParam.code" allowClear placeholder="请输入原厂编码"/>
+                  <a-input id="chooseProducts-code" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
                 </a-form-model-item>
               </a-col>
               <a-col :md="8" :sm="24">
                 <a-form-model-item label="产品名称">
-                  <a-input id="chooseProducts-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
+                  <a-input id="chooseProducts-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
                 </a-form-model-item>
               </a-col>
               <a-col :md="8" :sm="24">
@@ -67,7 +67,7 @@
           size="small"
           :rowKey="(record) => record.productSn"
           rowKeyName="productSn"
-          :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseDataList && this.chooseDataList.indexOf(record.productSn) > -1 } })}"
+          :row-selection="{ columnWidth: 40}"
           @rowSelection="rowSelectionFun"
           :columns="columns"
           :pagination="{pageSizeOptions: ['20','50','100','200','500']}"
@@ -97,7 +97,7 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable } from '@/components'
-import { productList } from '@/api/product'
+import { queryWaitingProductPage } from '@/api/promoActive'
 import ProductBrand from '@/views/common/productBrand.js'
 import productTypeAll from '@/views/common/productTypeAll.js'
 export default {
@@ -115,6 +115,12 @@ export default {
         return []
       }
     },
+    chooseType: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
     zIndex: { // 层级
       type: [String, Number],
       default: 1000
@@ -130,13 +136,16 @@ export default {
         wrapperCol: { span: 20 }
       },
       queryParam: { //  查询条件
-        name: '', // 产品名称
-        code: '', //  产品编码
+        productName: '', // 产品名称
+        productCode: '', //  产品编码
+        origCode: '', // 原厂编码
         productBrandSn: undefined, //  产品品牌
         productType: [],
         productTypeSn1: '', //  产品一级分类
         productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '' //  产品三级分类
+        productTypeSn3: '', //  产品三级分类
+        hideProductSnList: [],
+        productTypeSnList: []
       },
       chooseDataList: [],
       disabled: false, //  查询、重置按钮是否可操作
@@ -159,7 +168,9 @@ export default {
         this.disabled = true
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
-        return productList(params).then(res => {
+        params.hideProductSnList = this.chooseData
+        params.productTypeSnList = this.chooseType
+        return queryWaitingProductPage(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -188,8 +199,9 @@ export default {
     },
     // 重置数据
     resetData () {
-      this.queryParam.code = ''
-      this.queryParam.name = ''
+      this.queryParam.productName = ''
+      this.queryParam.productCode = ''
+      this.queryParam.origCode = ''
       this.queryParam.productBrandSn = undefined
       this.queryParam.productTypeSn1 = ''
       this.queryParam.productTypeSn2 = ''
@@ -203,7 +215,7 @@ export default {
     resetSearchForm () {
       this.$refs.table.clearSelected()
     },
-    // 保存
+    // 批量添加
     handleSave () {
       if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
         this.$message.warning('请在列表勾选后再进行操作!')
@@ -223,10 +235,6 @@ export default {
       this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
-    },
-    // 禁用
-    handleDisabled (list) {
-      this.chooseDataList = list
     }
   },
   watch: {
@@ -243,17 +251,6 @@ export default {
       } else {
         const _this = this
         _this.resetData()
-        if (_this.chooseData && _this.chooseData.length > 0) {
-          let selectedRows = []
-          const selectedRowKeys = []
-          _this.chooseData.forEach(item => {
-            selectedRowKeys.push(item.goodsSn)
-          })
-          selectedRows = _this.chooseData
-          this.$nextTick(() => { // 页面渲染完成后的回调
-            _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
-          })
-        }
       }
     }
   }

+ 177 - 87
src/views/promotionRulesManagement/promotionManagement/edit.vue

@@ -4,7 +4,7 @@
       <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
         <!-- 自定义的二级文字标题 -->
         <template slot="subTitle">
-          <a id="promotionEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
+          <a id="promotionEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" />返回列表</a>
         </template>
       </a-page-header>
       <!-- 表单 -->
@@ -60,7 +60,7 @@
                     alt="图片走丢了"
                     width="80"
                     height="80"
-                    v-for="(con,i) in images"
+                    v-for="(con,i) in imageSet"
                     style="margin-right:10px;"
                     :key="i" />
                 </div>
@@ -120,7 +120,13 @@
                   placeholder="请输入跳转链接"
                   @blur="handleLink"
                   allowClear />
-                <a-select id="promotionEdit-title" default-value="货架促销" @change="handleLinkType" style="width: 120px;margin-left:10px;" v-model="form.linkType">
+                <a-select
+                  id="promotionEdit-title"
+                  :disabled="isDisabled"
+                  default-value="货架促销"
+                  @change="handleLinkType"
+                  style="width: 120px;margin-left:10px;"
+                  v-model="form.linkType">
                   <a-select-option value="1">
                     货架促销
                   </a-select-option>
@@ -134,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">参数配置</a-checkbox>
+              <a-checkbox @change="onChangeParams" :disabled="isDisabled" v-model="isShowParams">参数配置</a-checkbox>
             </a-col>
             <a-col
               :xs="24"
@@ -144,13 +150,13 @@
               :xl="24"
               v-show="isShowParams">
               <!-- 参数配置内容 -->
-              <setPromotion style="margin-top:20px;" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
+              <setPromotion ref="setContent" style="margin-top:20px;" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
             </a-col>
           </a-row>
           <a-row>
             <a-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
-              <a-form-model-item label="是否发布" prop="enabledFlag" :label-col="{span:3}" :wrapper-col="{span:18}">
-                <a-radio-group button-style="solid" v-model="form.enabledFlag" :disabled="pageType==='see'">
+              <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">
                   </a-radio-button>
@@ -160,17 +166,19 @@
                 </a-radio-group>
               </a-form-model-item>
             </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
+              <a-form-model-item label="是否发布" prop="publishState" :label-col="{span:3}" :wrapper-col="{span:18}">
+                <a-radio-group button-style="solid" v-model="form.publishState" :disabled="pageType==='see'">
+                  <a-radio-button value="PUBLISH">
+                    是
+                  </a-radio-button>
+                  <a-radio-button value="UNPUBLISH">
+                    否
+                  </a-radio-button>
+                </a-radio-group>
+              </a-form-model-item>
+            </a-col>
           </a-row>
-          <!-- <a-form-model-item label="是否显示" prop="showFlag" v-if="form.enabledFlag == 1">
-            <a-radio-group button-style="solid" v-model="form.showFlag">
-              <a-radio-button value="1">
-                显示
-              </a-radio-button>
-              <a-radio-button value="0">
-                隐藏
-              </a-radio-button>
-            </a-radio-group>
-          </a-form-model-item> -->
         </a-card>
       </a-form-model>
       <!-- <div class="btn-cont">
@@ -195,7 +203,13 @@
     <!-- 预览 -->
     <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
     <!-- 添加产品 -->
-    <chooseProduct ref="chooseProduct" :openModal="showProModal" @close="closeProductModal"></chooseProduct>
+    <chooseProduct
+      ref="chooseProduct"
+      :chooseType="chooseTypeList"
+      :chooseData="chooseDataList"
+      :openModal="showProModal"
+      @ok="addProductSuccess"
+      @close="closeProductModal"></chooseProduct>
   </div>
 </template>
 
@@ -203,7 +217,7 @@
 import { commonMixin } from '@/utils/mixin'
 import { VSelect, Upload } from '@/components'
 import Editor from '@/components/WEeditor'
-import { saveActive, promoTerminalDetail } from '@/api/promoTerminal'
+import { promoActivePublish, promoActiveDetail } from '@/api/promoActive'
 import promotionShowModal from './promotionShowModal'
 import setPromotion from './setPromotion'
 import chooseProduct from './chooseProductsModal.vue'
@@ -220,23 +234,40 @@ export default {
         wrapperCol: { span: 16 }
       },
       form: {
-        promoActiveSn: undefined,
-        title: '',
-        contentType: 'IMAGE_CONTENT',
-        imageSet: '',
-        showFlag: '0',
-        content: '',
-        enabledFlag: '0',
-        sort: undefined,
-        contentLink: '',
-        linkType: undefined
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: undefined, // 参数配置 1勾选配置  0不能配置
+        publishState: 'UNPUBLISH',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        // 参数配置数据
+        promoRule: {
+          ruleType: undefined, // 基本规则类型
+          productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+          productRangeList: [], // 产品范围列表
+          ruleName: '', // 券名称
+          ruleTitle: '', // 副标题
+          ruleBaseType: undefined, // 券生成方式
+          ruleExplain: '', // 使用说明
+          validType: undefined, // 券有效期类型
+          validStartDate: undefined, // 券生效时间
+          validEndDate: undefined, // 券失效时间
+          validDays: undefined, // 券有效期天数
+          ruleDetailList: []// 券内容
+        }
       },
       pageType: undefined, // 页面类型
       showProModal: false,
-      images: [],
       isShowParams: false, // 是否显示参数配置内容
       openShowModal: false,
       isDisabled: false, // 控制是否能编辑
+      chooseTypeList: [],
+      chooseDataList: [],
+      imageSet: [], // 回显显示图片数据
       rules: {
         title: [
           { required: true, message: '请输入标题名称', trigger: 'blur' }
@@ -256,9 +287,12 @@ export default {
         contentLink: [
           { required: true, message: '请输入对应内容', trigger: 'blur' }
         ],
-        enabledFlag: [
+        publishState: [
           { required: true, message: '请选择是否发布', trigger: 'change' }
         ],
+        dealerEditFlag: [
+          { required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }
+        ],
         showFlag: [
           { required: true, message: '请选择是否显示', trigger: 'change' }
         ]
@@ -269,83 +303,115 @@ export default {
     // 设置参数
     onChangeParams (e) {
       this.isShowParams = e.target.checked
+      this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
+      this.$nextTick(() => {
+        this.$refs.setContent.addCouponCon()
+      })
     },
-    // 打开弹窗
-    insterProduct (flag) {
+    // 打开产品弹窗
+    insterProduct (typeList) {
+      this.chooseTypeList = typeList
       this.showProModal = true
     },
+    // 添加产品成功
+    addProductSuccess (list) {
+      const productArr = list.map(item => {
+        return { productCode: item.code,
+          productSn: item.productSn }
+      })
+      this.chooseDataList = list.map(item => item.productSn)
+      this.$refs.setContent.setProductSn(productArr)
+    },
+    closeProductModal () {
+      this.showProModal = false
+    },
     // 返回列表
     handleBack () {
-      this.resetSearchForm()
       this.$router.push({ name: 'promotionManagementList', query: { closeLastOldTab: true } })
     },
     // 预览
-    handleSee () {
-      if (this.form.content) {
-        this.openShowModal = true
-        this.$refs.showModal.pageInit({ type: this.form.contentType, con: this.form.content })
-      } else {
-        this.$message.error('请输入预览内容!')
-      }
-    },
+    // handleSee () {
+    //   if (this.form.content) {
+    //     this.openShowModal = true
+    //     this.$refs.showModal.pageInit({ type: this.form.contentType, con: this.form.content })
+    //   } else {
+    //     this.$message.error('请输入预览内容!')
+    //   }
+    // },
     //  详情
     getDetail () {
-      // 查看按钮时,所有按钮不能编辑    编辑按钮时,state 已发布,只能编辑是否发布;state已关闭,都可以编辑
-      promoTerminalDetail({ sn: this.$route.params.sn }).then(res => {
+      // 查看按钮时,所有按钮不能编辑    编辑按钮时,publishState 已发布,只能编辑是否发布;publishState已关闭,都可以编辑
+      const _this = this
+      promoActiveDetail({ sn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {
-          if (this.pageType === 'edit') {
-            this.isDisabled = res.data.state === 'PUBLISH'
-          } else {
-            this.isDisabled = true
+          if (_this.pageType === 'edit') {
+            _this.isDisabled = res.data.publishState === 'PUBLISH'
+          } else if (_this.pageType === 'see') {
+            _this.isDisabled = true
+          }
+          _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)
           }
-          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.enabledFlag = res.data.enabledFlag
-          this.form.sort = res.data.sort
-          this.images = res.data.imageSet
-          this.form.imageSet = res.data.images
-          this.form.content = res.data.content
-          this.$refs.imageSet.setFileList(res.data.images)
+          _this.form.content = res.data.content
+          _this.form.dealerEditFlag = res.data.dealerEditFlag
+          _this.form.publishState = res.data.publishState
           if (res.data.contentType == 'IMAGE_CONTENT') {
-            this.$refs.editor.setHtml(res.data.content)
+            _this.$refs.editor.setHtml(res.data.content)
           } else if (res.data.contentType == 'VIDEO') {
-            if (res.data.state != 'PUBLISH') {
-              this.$refs.videoSet.setFileList(res.data.content)
+            if (res.data.publishState != 'PUBLISH') {
+              _this.$refs.videoSet.setFileList(res.data.content)
             }
           } else if (res.data.contentType == 'LINK') {
-            this.form.contentLink = res.data.content
+            _this.form.contentLink = res.data.content
+            _this.form.linkType = '1'
+            _this.isShowParams = res.data.ruleEnableFlag === '1'
+            _this.form.ruleEnableFlag = res.data.ruleEnableFlag
+            if (res.data.promoRule && res.data.promoRule.ruleDetailList && res.data.ruleEnableFlag === '1') {
+              _this.form.promoRule = res.data.promoRule
+              _this.$nextTick(() => {
+                _this.$refs.setContent.setDetailData(res.data.promoRule, res.data.promoRule.ruleDetailList)
+              })
+            }
           }
         }
       })
     },
-    closeProductModal () {
-
-    },
-
-    //  确定
+    //  确定保存
     handleSave () {
       const _this = this
       if (_this.form.contentType == 'LINK') {
         _this.form.content = _this.form.contentLink
+        if (_this.form.ruleEnableFlag === '1') {
+          _this.form.promoRule.ruleDetailList = _this.$refs.setContent.couponList
+        }
       }
+      _this.$refs.ruleForm.validateField('ruleDetailList')
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          _this.form.promoActiveSn = this.itemId
-          const formData = JSON.parse(JSON.stringify(_this.form))
+          _this.form.promoActiveSn = this.$route.params.sn
+          var formData = JSON.parse(JSON.stringify(_this.form))
           formData.imageSet = formData.imageSet ? formData.imageSet.split(',') : []
-          formData.showFlag = formData.enabledFlag == 0 ? '0' : formData.showFlag
           if (formData.contentType == 'LINK') {
             delete formData.contentLink
+            formData.promoRule = _this.$refs.setContent.getPromotionVal()
           }
           _this.spinning = true
-          saveActive(formData).then(res => {
+          promoActivePublish(formData).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
+              _this.$nextTick(() => {
+                _this.handleBack()
+                _this.resetSearchForm()
+              })
               _this.spinning = false
-              _this.isShow = false
-              _this.$emit('ok')
             } else {
               _this.spinning = false
             }
@@ -377,19 +443,34 @@ export default {
         this.$refs.editor.setHtml('')
       }
       this.form = {
-        promoActiveSn: undefined,
-        title: '',
-        contentType: 'IMAGE_CONTENT',
-        imageSet: '',
-        showFlag: '0',
-        content: '',
-        enabledFlag: '0',
-        sort: undefined,
-        contentLink: '',
-        linkType: undefined
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: undefined, // 参数配置 1勾选配置  0不能配置
+        publishState: 'UNPUBLISH',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        // 参数配置数据
+        promoRule: {
+          ruleType: undefined, // 基本规则类型
+          productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+          productRangeList: [], // 产品范围列表
+          ruleName: '', // 券名称
+          ruleTitle: '', // 副标题
+          ruleBaseType: undefined, // 券生成方式
+          ruleExplain: '', // 使用说明
+          validType: undefined, // 券有效期类型
+          validStartDate: undefined, // 券生效时间
+          validEndDate: undefined, // 券失效时间
+          validDays: undefined, // 券有效期天数
+          ruleDetailList: []// 券内容
+        }
       }
-      this.images = []
       this.isDisabled = false
+      this.$refs.setContent.clearContent()
       this.$refs.ruleForm.resetFields()
     },
     // 选择内容类型
@@ -417,17 +498,26 @@ export default {
       this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
     },
     pageInit () {
-      this.pageType = this.$route.params.pageType ? this.$route.params.pageType : 'add'
+      this.pageType = this.$route.params.pageType
       if (this.pageType === 'edit' || this.pageType === 'see') {
         this.getDetail()
       }
     }
   },
   mounted () {
-    this.pageInit()
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+    }
   },
   activated () {
-    this.pageInit()
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+    }
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {})

+ 19 - 32
src/views/promotionRulesManagement/promotionManagement/list.vue

@@ -66,24 +66,9 @@
           :scroll="{ y: tableHeight }"
           :defaultLoadData="false"
           bordered>
-          <!-- 自定义表头 -->
-          <template slot="arrowFalgTitle">
-            <a-tooltip placement="top">
-              <template slot="title">
-                <span>易码通轮播促销展示显示状态</span>
-              </template>
-              显示状态<a-icon type="question-circle" :style="{ marginLeft: '10px' }" />
-            </a-tooltip>
-          </template>
-          <!-- 显示状态 -->
-          <template slot="arrowFalg" slot-scope="text, record">
-            <a-switch
-              checkedChildren="显示"
-              unCheckedChildren="隐藏"
-              id="promotion-isEnable"
-              v-model="record.isEnable"
-              :disabled="record.state!='PUBLISH'"
-              @change="changeFlagHandle(record)" />
+          <!-- 促销状态 -->
+          <template slot="stateVal" slot-scope="text, record">
+            <span>{{ record.publishState==='UNPUBLISH'?'未发布':record.publishState==='PUBLISH'?'已发布':record.publishState==='CLOSE'?'已关闭':'已结束' }}</span>
           </template>
           <!-- 促销时间 -->
           <template slot="promotionTime" slot-scope="text, record">
@@ -91,7 +76,7 @@
           </template>
           <!-- 参与客户 -->
           <template slot="joinCustomers" slot-scope="text, record">
-            <span @click="handleCustomers(record)" v-if="record.promoBuyerSnSet&&record.promoBuyerSnSet.length>0">共有<span class="link-bule">{{ record.promoBuyerSnSet.length }}</span>个客户</span>
+            <span @click="handleCustomers(record)" v-if="record.dealerSnList&&record.dealerSnList.length>0">共有<span class="link-bule">{{ record.dealerSnList.length }}</span>个客户</span>
             <span v-else>共有0个客户</span>
           </template>
           <!-- 促销描述 -->
@@ -124,37 +109,37 @@
                 type="link"
                 class="button-warning"
                 @click="promotionEdit(record)"
-                v-if="(record.state=='UNPUBLISH' || record.state=='CLOSE') && $hasPermissions('B_promotionManagementAdd')"
+                v-if="(record.publishState=='UNPUBLISH' || record.publishState=='CLOSE') && $hasPermissions('B_promotionManagementAdd')"
                 id="promotion-edit-btn">编辑</a-button>
               <a-button
                 size="small"
                 type="link"
                 class="button-warning"
                 @click="handleRelease(record,'edit')"
-                v-if="(record.state=='PUBLISH' || record.state=='CLOSE')&&$hasPermissions('B_promotionManagementContent')"
+                v-if="(record.publishState=='PUBLISH' || record.publishState=='CLOSE')&&$hasPermissions('B_promotionManagementContent')"
                 id="promotion-modify-btn">发布修改</a-button>
               <a-button
                 size="small"
                 type="link"
                 class="button-success"
                 @click="handleRelease(record,'see')"
-                v-if="(record.state=='PUBLISH')&&$hasPermissions('B_promotionManagementContent')"
+                v-if="(record.publishState=='PUBLISH')&&$hasPermissions('B_promotionManagementContent')"
                 id="promotion-modify-btn">查看</a-button>
               <a-button
                 size="small"
                 type="link"
                 class="button-info"
                 @click="handleRelease(record,'add')"
-                v-if="record.state=='UNPUBLISH'&&$hasPermissions('B_promotionManagementContent')"
+                v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementContent')"
                 id="promotion-release-btn">发布</a-button>
               <a-button
                 size="small"
                 type="link"
                 class="button-error"
-                v-if="record.state=='UNPUBLISH'&&$hasPermissions('B_promotionManagementDel')"
+                v-if="record.publishState=='UNPUBLISH'&&$hasPermissions('B_promotionManagementDel')"
                 @click="handleDel(record)"
                 id="promotion-del-btn">删除</a-button>
-              <span v-if="record.state=='End'">--</span>
+              <span v-if="record.publishState=='End'">--</span>
             </div>
           </template>
         </s-table>
@@ -177,12 +162,13 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
-import { promoTerminalList, promoTerminalDel, updateShowFlag } from '@/api/promoTerminal'
+
 import lookUpCustomersModal from './lookUpCustomersModal'
 import promotionDescModal from './promotionDescModal'
 import promotionShowModal from './promotionShowModal'
 import addModal from './addModal'
-// import promotionEditModal from './editModal'
+import { updateShowFlag } from '@/api/promoTerminal'
+import { promoActiveList, promoActiveDel } from '@/api/promoActive'
 export default {
   name: 'PromotionList',
   mixins: [commonMixin],
@@ -223,7 +209,7 @@ export default {
         this.disabled = true
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
-        return promoTerminalList(params).then(res => {
+        return promoActiveList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -247,7 +233,7 @@ export default {
         { title: '促销描述', scopedSlots: { customRender: 'salesDesc' }, width: '12%', align: 'center' },
         { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '6%', align: 'center' },
         // { slots: { title: 'arrowFalgTitle' }, scopedSlots: { customRender: 'arrowFalg' }, width: '6%', align: 'center' },
-        { title: '促销状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销状态', scopedSlots: { customRender: 'stateVal' }, width: '6%', align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
     }
@@ -261,7 +247,7 @@ export default {
     handleCustomers (row) {
       this.openCustomerModal = true
       this.$nextTick(() => {
-        this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.promoBuyerSnSet ? row.promoBuyerSnSet : undefined, promoActiveSn: row.promoActiveSn })
+        this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoActiveSn: row.promoActiveSn })
       })
     },
     //  创建时间  change
@@ -317,7 +303,7 @@ export default {
         centered: true,
         onOk () {
           _this.spinning = true
-          promoTerminalDel({ sn: row.promoActiveSn }).then(res => {
+          promoActiveDel({ sn: row.promoActiveSn }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
@@ -341,7 +327,8 @@ export default {
     // 促销发布
     handleRelease (row, type) {
       if (type === 'add') {
-        this.$router.push({ name: 'promotionManagementAdd' })
+        const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
+        this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
       } else { // 查看 、编辑跳转
         this.$router.push({ name: 'promotionManagementEdit', params: { sn: row.promoActiveSn, pageType: type } })
       }

+ 217 - 209
src/views/promotionRulesManagement/promotionManagement/setPromotion.vue

@@ -5,83 +5,85 @@
       ref="sellRuleForm"
       :model="sellForm"
       :rules="sellRules"
+      class="setPromotion-form"
       :label-col="sellFormItemLayout.labelCol"
       :wrapper-col="sellFormItemLayout.wrapperCol">
       <a-row>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-          <a-form-model-item label="基本规则" prop="contentType">
+          <a-form-model-item label="基本规则" prop="ruleType">
             <v-select
-              v-model="sellForm.contentType"
+              v-model="sellForm.ruleType"
               placeholder="请选择基本规则"
-              ref="saleStatus"
-              id="promotion-saleStatus"
-              code="PROMO_CONTENT_TYPE"
+              id="setPromotion-ruleType"
+              code="PROMO_RULE_TYPE"
               :disabled="disabledVal"
               allowClear></v-select>
           </a-form-model-item>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-          <a-form-model-item label="券名称" prop="title" :label-col="{span:4}" :wrapper-col="{span:18}">
+          <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="ruleName">
             <a-input
               :disabled="disabledVal"
-              id="setPromotion-title"
+              id="setPromotion-ruleName"
               :maxLength="20"
-              v-model.trim="sellForm.title"
+              v-model.trim="sellForm.ruleName"
               placeholder="请输入券名称(最多20个字符)"
               allowClear />
           </a-form-model-item>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-          <a-form-model-item label="券副标题" :label-col="{span:2}" :wrapper-col="{span:18}">
+          <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
             <a-input
               :disabled="disabledVal"
-              id="setPromotion-title"
+              id="setPromotion-ruleTitle"
               :maxLength="20"
-              v-model.trim="sellForm.title"
+              v-model.trim="sellForm.ruleTitle"
               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="产品范围">
-            <div id="setPromotionRange" style="position:relative;">
+            <div id="setPromotion-productRange" style="position:relative;">
               <a-tree-select
-                v-model="con"
+                v-model="sellForm.productRangeList"
                 style="width: 100%"
-                :tree-data="treeData"
+                :maxTagCount="12"
+                :tree-data="productTypeList"
                 tree-checkable
                 :disabled="disabledVal"
-                :show-checked-strategy="SHOW_ALL"
                 :getPopupContainer="triggerNode => triggerNode.parentNode"
+                :replaceFields="{children:'children',title: 'productTypeName',key: 'productTypeSn',value: 'productTypeSn'}"
+                @blur="onChangeTree"
                 placeholder="请选择产品范围" />
-                <!-- @change="onChangeTree" -->
             </div>
           </a-form-model-item>
         </a-col>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-          <a-form-model-item label="生成方式" prop="contentType">
-            <a-radio-group v-model="sellForm.value" @change="onChangeType" :disabled="disabledVal">
-              <a-radio :value="1">
-                按订单生成券
-              </a-radio>
-              <a-radio :value="2">
-                按产品款数生成券
-              </a-radio>
-            </a-radio-group>
+          <a-form-model-item label="生成方式" prop="ruleBaseType">
+            <v-select
+              v-model="sellForm.ruleBaseType"
+              ref="ruleBaseType"
+              id="setPromotion-ruleBaseType"
+              code="PROMO_RULE_BASE_TYPE"
+              showType="radio"
+              :disabled="disabledVal"
+              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="imageSet">
-            <div class="couponCon">
-              <a-row v-show="sellForm.value===1">
+          <a-form-model-item label="券内容" prop="ruleDetailList">
+            <div class="couponCon" v-if="couponList&&couponList.length>0">
+              <a-row v-for="(item,i) in couponList" :key="item.id">
                 <a-col :md="22" :sm="24">
                   <div class="couponList">
                     <!-- 具体内容 -->
-                    <a-form-model ref="couponRuleForm" :model="couponForm" :rules="couponRules" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
-                      <a-form-model-item ref="name" prop="name" style="margin-left:26px;">
+                    <a-form-model ref="couponRuleForm" :model="item" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
+                      <a-form-model-item style="margin-left:26px;">
+                        <span style="color:#ed1c24;font-size:15px;">*</span>
                         购买<a-input-number
                           style="margin:0 5px;"
-                          v-model="couponForm.regularValue"
+                          v-model="item.productQty"
                           :step="1"
                           :max="99999999"
                           :precision="0"
@@ -89,11 +91,10 @@
                           size="small"/>
                         <a-select
                           default-value="GE"
-                          :disabled="disabledVal"
-                          v-model="couponForm.regularUnit"
+                          v-model="item.unit"
                           style="width: 60px;"
                           size="small"
-                          @change="handleChangeUnit">
+                          :disabled="true">
                           <a-select-option value="GE">
                           </a-select-option>
@@ -102,67 +103,7 @@
                           </a-select-option>
                         </a-select>
                         活动产品,送<a-input-number
-                          v-model="couponForm.promotionValue"
-                          :disabled="disabledVal"
-                          style="margin:0 5px;"
-                          :min="0"
-                          :step="1"
-                          :precision="2"
-                          :max="99999999"
-                          size="small"/> 元
-                      </a-form-model-item>
-                      <a-form-model-item label="活动产品" prop="region">
-                        <a-button type="primary" @click="handleAddProduct" :disabled="disabledVal" size="small">添加产品</a-button>
-                        <div class="productCon">
-                          <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
-                            产品编码
-                          </a-tag>
-                          <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
-                            产品编码
-                          </a-tag>
-                        </div>
-                      </a-form-model-item>
-                      <a-form-model-item label="券适用范围" prop="desc">
-                        全部产品
-                      </a-form-model-item>
-                    </a-form-model>
-                  </div>
-                </a-col>
-                <a-col :md="2" :sm="24">
-                  <a-button type="link" class="button-info" :disabled="disabledVal">+新增</a-button>
-                  <a-button type="link" :disabled="disabledVal">删除</a-button>
-                </a-col>
-              </a-row>
-              <a-row v-show="sellForm.value===2" v-for="item in couponList" :key="item.id">
-                <a-col :md="22" :sm="24">
-                  <div class="couponList">
-                    <!-- 具体内容 -->
-                    <a-form-model ref="couponRuleForm" :model="couponForm" :rules="couponRules" :label-col="couponFormLayout.labelCol" :wrapper-col="couponFormLayout.wrapperCol">
-                      <a-form-model-item ref="name" prop="name" style="margin-left:26px;">
-                        购买<a-input-number
-                          style="margin:0 5px;"
-                          v-model="couponForm.regularValue"
-                          :step="1"
-                          :max="99999999"
-                          :precision="0"
-                          :disabled="disabledVal"
-                          size="small"/>
-                        <a-select
-                          default-value="GE"
-                          v-model="couponForm.regularUnit"
-                          style="width: 60px;"
-                          size="small"
-                          :disabled="disabledVal"
-                          @change="handleChangeUnit">
-                          <a-select-option value="GE">
-                            个
-                          </a-select-option>
-                          <a-select-option value="YUAN">
-                            元
-                          </a-select-option>
-                        </a-select>
-                        活动产品,送<a-input-number
-                          v-model="couponForm.promotionValue"
+                          v-model="item.ruleValue"
                           style="margin:0 5px;"
                           :min="0"
                           :step="1"
@@ -171,23 +112,20 @@
                           :disabled="disabledVal"
                           size="small"/> 元
                       </a-form-model-item>
-                      <a-form-model-item label="活动产品" prop="region">
-                        <a-button type="primary" :disabled="disabledVal" @click="handleAddProduct" size="small">添加产品</a-button>
-                        <div class="productCon">
-                          <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
-                            产品编码
-                          </a-tag>
-                          <a-tag closable @close="delBuyerName(con)" :disabled="disabledVal">
-                            产品编码
+                      <a-form-model-item class="productName" label="活动产品" prop="ruleProductList">
+                        <a-button type="primary" :disabled="disabledVal" @click="handleAddProduct(item)" size="small">添加产品</a-button>
+                        <div class="productCon" v-if="item.ruleProductList && item.ruleProductList.length>0">
+                          <a-tag :closable="!disabledVal" @close="delBuyerName(item,con)" v-for="con in item.ruleProductList" :key="con.productSn">
+                            {{ con.productCode }}
                           </a-tag>
                         </div>
                       </a-form-model-item>
-                      <a-form-model-item label="券适用范围" prop="desc">
+                      <a-form-model-item class="productName" label="券适用范围" prop="range">
                         全部产品
                       </a-form-model-item>
-                      <a-form-model-item label="使用说明" prop="desc">
+                      <a-form-model-item label="使用说明" prop="detailExplain" v-show="sellForm.ruleBaseType==='category'">
                         <a-input
-                          v-model="couponForm.desc"
+                          v-model="item.detailExplain"
                           :disabled="disabledVal"
                           style="width:80%;"
                           type="textarea"
@@ -198,8 +136,8 @@
                   </div>
                 </a-col>
                 <a-col :md="2" :sm="24">
-                  <a-button type="link" v-if="i===0" class="button-info" @click="addCouponCon" :disabled="disabledVal">+新增</a-button>
-                  <a-button type="link" v-else @click="delCouponCon(item.id)" :disabled="disabledVal">删除</a-button>
+                  <a-button type="link" v-show="i===0&&couponList.length<10" class="button-info" @click="addCouponCon" :disabled="disabledVal">+新增</a-button>
+                  <a-button type="link" v-show="i!=0" @click="delCouponCon(item.id)" :disabled="disabledVal">删除</a-button>
                 </a-col>
               </a-row>
             </div>
@@ -212,28 +150,28 @@
           :lg="24"
           :xl="24"
           v-show="sellForm.value===1">
-          <a-form-model-item label="使用说明">
-            <a-input v-model="sellForm.desc" type="textarea" placeholder="请输入使用说明" :disabled="disabledVal" :maxLength="200" />
+          <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="券有效期">
-            <a-radio-group v-model="sellForm.termVal" :disabled="disabledVal">
-              <a-radio :style="radioStyle" :value="1">
+          <a-form-model-item label="券有效期" prop="validType">
+            <a-radio-group v-model="sellForm.validType" :disabled="disabledVal">
+              <a-radio :style="radioStyle" value="FIXED">
                 <span>固定日期</span>
                 <a-range-picker
                   style="width:100%;margin-left:5px;"
-                  v-model="sellForm.time"
+                  v-model="time"
                   :format="dateFormat"
                   @change="dateChange"
                   :disabled="disabledVal"
+                  :disabled-date="disabledDate"
                   :placeholder="['开始时间', '结束时间']" />
-                  <!-- :disabled-date="disabledDate" -->
               </a-radio>
-              <a-radio :style="radioStyle" :value="2">
+              <a-radio :style="radioStyle" value="LIMIT">
                 <span>领取后,当天生效,有效期至</span><a-input-number
                   style="margin:0 5px;"
-                  v-model="sellForm.regularValue"
+                  v-model="sellForm.validDays"
                   :step="1"
                   :max="99999999"
                   :disabled="disabledVal"
@@ -242,18 +180,6 @@
             </a-radio-group>
           </a-form-model-item>
         </a-col>
-        <a-col :xs="24" :sm="24" :md="12" :lg="24" :xl="24">
-          <a-form-model-item label="加盟商编辑" prop="enabledFlag">
-            <a-radio-group button-style="solid" :disabled="disabledVal" v-model="sellForm.enabledFlag">
-              <a-radio-button value="1">
-                是
-              </a-radio-button>
-              <a-radio-button value="0">
-                否
-              </a-radio-button>
-            </a-radio-group>
-          </a-form-model-item>
-        </a-col>
       </a-row>
     </a-form-model>
   </a-spin>
@@ -261,9 +187,10 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
+import moment from 'moment'
 import { VSelect } from '@/components'
-import { TreeSelect } from 'ant-design-vue'
-const SHOW_ALL = TreeSelect.SHOW_ALL
+import { productTypeQuery } from '@/api/productType'
+import { getNewScopeSn } from '@/api/promotion'
 export default {
   name: 'PromotionAddModal',
   mixins: [commonMixin],
@@ -277,12 +204,12 @@ export default {
   data () {
     return {
       spinning: false,
-      SHOW_ALL,
       // form 表单label布局设置
       sellFormItemLayout: {
         labelCol: { span: 2 }, // 文字前距离设置
         wrapperCol: { span: 20 }// 表单后距离设置  数字越大距离越小
       },
+      // 卷内容 form 表单label布局设置
       couponFormLayout: {
         labelCol: { span: 3 },
         wrapperCol: { span: 18 }
@@ -293,111 +220,192 @@ export default {
         height: '50px',
         lineHeight: '40px'
       },
+      // 主要内容 提交数据
       sellForm: {
-        value: 2,
-        termVal: undefined,
-        enabledFlag: '0',
-        con: []
+        ruleType: 'ticket', // 基本规则类型
+        productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+        productRangeList: [], // 产品范围列表
+        ruleName: '', // 券名称
+        ruleTitle: '', // 副标题
+        ruleBaseType: 'category', // 券生成方式
+        ruleExplain: '', // 使用说明
+        validType: undefined, // 券有效期类型
+        validStartDate: undefined, // 券生效时间
+        validEndDate: undefined, // 券失效时间
+        validDays: undefined, // 券有效期天数
+        // 券内容
+        ruleDetailList: []
       },
-      dateFormat: 'YYYY-MM',
-      con: [],
-      couponList: [{
-        val1: '',
-        unit: ''
-      }], // 按产品款数生成券 数据
-      treeData: [],
-      showProModal: false,
-      couponForm: {},
-      couponRules: {},
-
+      // 券内容 提交数据
+      couponList: [],
+      // 按产品款数生成券 数据
+      dateFormat: 'YYYY-MM-DD',
+      posNum: null, // 选择产品位置
       sellRules: {
-        promoBuyerList: [{
-          required: true,
-          message: '请选择参与经销商',
-          trigger: 'change'
-        }],
-        time: [{
-          required: true,
-          message: '请选择促销时间',
-          trigger: 'change'
-        }],
-        name: [{
-          required: true,
-          message: '请输入促销名称',
-          trigger: 'blur'
-        }],
-        description: [{
-          required: true,
-          message: '请输入促销描述',
-          trigger: 'blur'
-        }]
-      }
+        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' }]
+      },
+      productTypeList: [],
+      time: []
     }
   },
   methods: {
-    delBuyerName (row) {
-
+    // 禁用日期时间
+    disabledDate (current) {
+      return current && current < moment().startOf('day')
     },
-    onChange () {
-
+    // 删除产品
+    delBuyerName (row, conRow) {
+      const ind = this.couponList.findIndex(item => item.id === row.id)
+      const pos = this.couponList[ind].ruleProductList.findIndex(con => con.productSn === conRow.productSn)
+      this.couponList[ind].ruleProductList.splice(pos, 1)
     },
-    dateChange () {
-
+    dateChange (date, dateString) {
+      this.time = date
+      if (dateString[0] != '' && dateString[1] != '') {
+        this.sellForm.validStartDate = dateString[0] + ' 00:00:00'
+        this.sellForm.validEndDate = dateString[1] + ' 23:59:59'
+      }
+    },
+    // 重置
+    clearContent () {
+      this.couponList = []
+      this.productTypeList = []
+      this.time = []
+      this.sellForm = {
+        ruleType: 'ticket', // 基本规则类型
+        productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+        productRangeList: [], // 产品范围列表
+        ruleName: '', // 券名称
+        ruleTitle: '', // 副标题
+        ruleBaseType: 'category', // 券生成方式
+        ruleExplain: '', // 使用说明
+        validType: undefined, // 券有效期类型
+        validStartDate: undefined, // 券生效时间
+        validEndDate: undefined, // 券失效时间
+        validDays: undefined, // 券有效期天数
+        // 券内容
+        ruleDetailList: []
+      }
     },
-    handleChangeUnit () {},
     // 添加产品
-    handleAddProduct () {
-      this.$emit('addProduct', true)
+    handleAddProduct (row) {
+      const pos = this.couponList.findIndex(item => item.id === row.id)
+      this.posNum = pos
+      const typeSrr = this.sellForm.productRangeList || []
+
+      this.$emit('addProduct', typeSrr)
     },
-    // 生成方式 change
-    onChangeType (e) {
-      this.couponList = [{}]
-      this.sellForm.value = e.target.value
+    onChangeTree () {
+      this.couponList = []
+      this.addCouponCon()
     },
     // 新增券内容
-    addCouponCon () {
-      const obj = {
-        val1: '',
-        unit: ''
-      }
+    async addCouponCon () {
       if (this.couponList.length >= 10) {
         this.$message.warning('最多只能新增10个!')
         return
       }
+      const result = await getNewScopeSn({})
+      const obj = {
+        id: result.data,
+        productQty: undefined, // 产品数量
+        ruleValue: undefined, // 返利金额
+        detailExplain: undefined, // 使用说明
+        unit: 'GE',
+        range: '1',
+        ruleProductList: []
+      }
       this.couponList.push(obj)
     },
     // 删除券内容
     delCouponCon (id) {
-
+      const pos = this.couponList.findIndex(item => item.id === id)
+      this.couponList.splice(pos, 1)
+    },
+    // 获取产品范围数据
+    getTreeData () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    setProductSn (list) {
+      this.couponList[this.posNum].ruleProductList = list
     },
-    onChangeTree (e) {
-      debugger
+    // 返回组件值
+    getPromotionVal () {
+      if (this.couponList && this.couponList.length > 0) {
+        this.sellForm.ruleDetailList = this.couponList
+      }
+      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 => {
+        return { productTypeSn: item }
+      })
+      return newData
+    },
+    // 详情赋值
+    setDetailData (info, arr) {
+      info.productRangeList = info.productRangeList.map(item => item.productTypeSn)
+      if (info.validType === 'FIXED') {
+        this.time = [info.validStartDate, info.validEndDate]
+      }
+      this.sellForm = { ...this.sellForm, ...info }
+      this.couponList = arr
     }
-
+  },
+  mounted () {
+    this.getTreeData()
+  },
+  activated () {
+    this.getTreeData()
   }
 }
 </script>
 
 <style lang="less" scoped>
-  .couponList{
-    background: #EFEFEF;
-    border-radius:5px;
-    padding:15px 15px 2px;
-    margin-bottom:5px;
-    .ant-form-item{
-      margin-bottom:12px;
+  .setPromotion-form{
+    .couponList{
+      background: #EFEFEF;
+      border-radius:5px;
+      padding:15px 15px 2px;
+      margin-bottom:5px;
+      .ant-form-item{
+        margin-bottom:12px;
+      }
+    }
+    .productCon{
+      width: 80%;
+      margin-left:12.3%;
+      max-height: 150px;
+      overflow-y: scroll;
+      background: #fff;
+      border-radius: 5px;
+      padding: 10px 15px;
+    }
+    .productCon::-webkit-scrollbar {
+      display: none;
+    }
+    #setPromotion-productRange{
+      /deep/.ant-select-dropdown{
+        max-height:30vh !important;
+      }
+    }
+    .productName{
+      /deep/.ant-form-item-label > label::before {
+          content: '*';
+          color:#ed1c24;
+          font-size:15px;
+          margin-right:3px;
+      }
     }
-  }
-  .productCon{
-    width: 80%;
-    margin-left:12.3%;
-    max-height: 150px;
-    overflow-y: scroll;
-    background: #fff;
-    border-radius: 5px;
-    padding: 10px 15px;
-  }
-  .productCon::-webkit-scrollbar {
-    display: none;
   }
 </style>