瀏覽代碼

修改bug

chenrui 10 月之前
父節點
當前提交
b2ebd4b589

+ 55 - 5
src/api/promoActive.js

@@ -2,7 +2,7 @@ import { axios } from '@/utils/request'
 
 
 //  促销活动 列表  有分页
 //  促销活动 列表  有分页
 export const promoActiveList = (params) => {
 export const promoActiveList = (params) => {
-  const url = `/promoActive/ueryPage/${params.pageNo}/${params.pageSize}`
+  const url = `/promoActive/queryPage/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
   delete params.pageNo
   delete params.pageSize
   delete params.pageSize
   return axios({
   return axios({
@@ -11,12 +11,62 @@ export const promoActiveList = (params) => {
     method: 'post'
     method: 'post'
   })
   })
 }
 }
+// 促销活动 关闭
+export const closeActive = (params) => {
+  return axios({
+    url: `/promoActive/closeActive/${params.sn}`,
+    method: 'get'
+  })
+}
+// 促销活动 开启
+export const publishActive = (params) => {
+  return axios({
+    url: `/promoActive/publishActive/${params.sn}`,
+    method: 'get'
+  })
+}
 
 
-// 促销活动
-export const ticketCheckTicket = (params) => {
+//  促销活动 详情
+export const promoActiveDetail = (params) => {
+  const url = `/promoActive/findBySn/${params.sn}`
   return axios({
   return axios({
-    url: '/ticket/checkTicket',
+    url: url,
+    method: 'get'
+  })
+}
+
+// 促销活动 发布修改
+export const promoActivePublish = (params) => {
+  return axios({
+    url: '/promoRuleDetail/updateList',
     data: params,
     data: params,
-    method: 'post'
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('发布修改')
+    }
+  })
+}
+
+// 促销活动 选择产品列表
+export const queryWaitingProductPage = (params) => {
+  const url = `/promoRuleProduct/queryWaitingProductPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 新增一行
+export const getNewScopeSn = (params) => {
+  return axios({
+    url: '/promoActive/getNewSn',
+    data: params,
+    method: 'get'
   })
   })
 }
 }

+ 3 - 3
src/components/Select/index.js

@@ -33,9 +33,9 @@ export default {
     const data = allLookup.find(item => item.code == _this.code)
     const data = allLookup.find(item => item.code == _this.code)
     // 判断是否是省仓用户
     // 判断是否是省仓用户
     _this.dataList = _this.$store.state.user.dealerSupplierFlag == '1' ? data.itemList : data.itemList.filter(item => item.dispName != '省级批发价')
     _this.dataList = _this.$store.state.user.dealerSupplierFlag == '1' ? data.itemList : data.itemList.filter(item => item.dispName != '省级批发价')
-    setTimeout(()=>{
+    setTimeout(() => {
       _this.$emit('loadDataFinish', _this.dataList)
       _this.$emit('loadDataFinish', _this.dataList)
-    },100)
+    }, 100)
   },
   },
   methods: {
   methods: {
     // 根据code 获取名称
     // 根据code 获取名称
@@ -74,7 +74,7 @@ export default {
     }
     }
     if (this.showType === 'radio') {
     if (this.showType === 'radio') {
       return (
       return (
-        <a-radio-group vModel={props.value} {...{ props, on: radioOn }} >,
+        <a-radio-group vModel={props.value} {...{ props, on: radioOn }} >
           {
           {
             this.dataList.map(item => {
             this.dataList.map(item => {
               return (<a-radio value={item.code} key={item.code}>{item['dispName']}</a-radio>)
               return (<a-radio value={item.code} key={item.code}>{item['dispName']}</a-radio>)

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

@@ -3336,11 +3336,11 @@ export const asyncRouterMap = [
                 }
                 }
               },
               },
               {
               {
-                path: 'detail/:sn/:pageType',
+                path: 'edit/:sn/:pageType',
                 name: 'promotionInfoEdit',
                 name: 'promotionInfoEdit',
                 component: () => import(/* webpackChunkName: "productManagement" */ '@/views/promotionManagement/promotionInfo/edit.vue'),
                 component: () => import(/* webpackChunkName: "productManagement" */ '@/views/promotionManagement/promotionInfo/edit.vue'),
                 meta: {
                 meta: {
-                  title: '编辑促销活动',
+                  title: '编辑促销',
                   icon: 'contacts',
                   icon: 'contacts',
                   hidden: true
                   hidden: true
                   // permission: 'M_promotionInfoEdit'
                   // permission: 'M_promotionInfoEdit'
@@ -3351,7 +3351,7 @@ export const asyncRouterMap = [
                 name: 'promotionInfoDetail',
                 name: 'promotionInfoDetail',
                 component: () => import(/* webpackChunkName: "productManagement" */ '@/views/promotionManagement/promotionInfo/edit.vue'),
                 component: () => import(/* webpackChunkName: "productManagement" */ '@/views/promotionManagement/promotionInfo/edit.vue'),
                 meta: {
                 meta: {
-                  title: '查看促销活动',
+                  title: '查看促销',
                   icon: 'contacts',
                   icon: 'contacts',
                   hidden: true
                   hidden: true
                   // permission: 'M_promotionInfoDetail'
                   // permission: 'M_promotionInfoDetail'

+ 1 - 0
src/views/promotionManagement/couponDetails/list.vue

@@ -100,6 +100,7 @@ export default {
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
         { title: '销售单号', dataIndex: 'usedBizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '销售单号', dataIndex: 'usedBizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '客户名称', dataIndex: 'customerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '客户名称', dataIndex: 'customerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '货架名称', dataIndex: 'customerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '券名称', dataIndex: 'ruleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '券名称', dataIndex: 'ruleName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '券副标题', dataIndex: 'ruleTitle', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '券副标题', dataIndex: 'ruleTitle', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '券金额', dataIndex: 'ticketValue', width: '10%', align: 'right', customRender: text => { return text || text == 0 ? this.toThousands(text, 2) : '--' } },
         { title: '券金额', dataIndex: 'ticketValue', width: '10%', align: 'right', customRender: text => { return text || text == 0 ? this.toThousands(text, 2) : '--' } },

+ 28 - 31
src/views/promotionManagement/promotionInfo/chooseProductsModal.vue

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

+ 210 - 146
src/views/promotionManagement/promotionInfo/edit.vue

@@ -4,7 +4,7 @@
       <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
       <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
         <!-- 自定义的二级文字标题 -->
         <!-- 自定义的二级文字标题 -->
         <template slot="subTitle">
         <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>
         </template>
       </a-page-header>
       </a-page-header>
       <!-- 表单 -->
       <!-- 表单 -->
@@ -43,18 +43,8 @@
               </a-form-model-item>
               </a-form-model-item>
             </a-col>
             </a-col>
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <a-form-model-item label="封面图片" prop="imageSet" :label-col="{span:2}" :wrapper-col="{span:20}">
-                <Upload
-                  v-if="pageType==='add'||(pageType==='edit'&&!isDisabled)"
-                  class="upload"
-                  id="promotionEdit-imageSet"
-                  v-model="form.imageSet"
-                  ref="imageSet"
-                  :fileSize="10"
-                  :maxNums="10"
-                  @change="changeImage"
-                  listType="picture-card"></Upload>
-                <div v-else>
+              <a-form-model-item label="封面图片" prop="images" :label-col="{span:2}" :wrapper-col="{span:20}">
+                <div>
                   <img
                   <img
                     :src="con"
                     :src="con"
                     alt="图片走丢了"
                     alt="图片走丢了"
@@ -82,28 +72,10 @@
             </a-col>
             </a-col>
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
               <a-form-model-item label="内容" prop="content" v-show="form.contentType =='IMAGE_CONTENT'" :label-col="{span:2}" :wrapper-col="{span:20}">
               <a-form-model-item label="内容" prop="content" v-show="form.contentType =='IMAGE_CONTENT'" :label-col="{span:2}" :wrapper-col="{span:20}">
-                <editor
-                  v-show="pageType === 'add'||(pageType === 'edit'&&!isDisabled)"
-                  id="promotionEdit-editor"
-                  ref="editor"
-                  class="promotionEdit-editor"
-                  @on-change="editorChange"
-                  :cache="false"></editor>
-                <div v-show="(pageType === 'edit'||pageType === 'see')&&isDisabled" class="box" v-html="form.content"></div>
+                <div class="box" v-html="form.content"></div>
               </a-form-model-item>
               </a-form-model-item>
               <a-form-model-item label="上传视频" prop="content" v-show="form.contentType =='VIDEO'" :label-col="{span:2}" :wrapper-col="{span:20}">
               <a-form-model-item label="上传视频" prop="content" v-show="form.contentType =='VIDEO'" :label-col="{span:2}" :wrapper-col="{span:20}">
-                <Upload
-                  v-if="pageType==='add'||(pageType==='edit'&&!isDisabled)"
-                  class="upload"
-                  id="promotionEdit-imageSet"
-                  v-model="form.content"
-                  fileType="video/mp4"
-                  ref="videoSet"
-                  :fileSize="100"
-                  :maxNums="1"
-                  @change="changeVideo"
-                ></Upload>
-                <div v-else>
+                <div>
                   <video width="230" height="150" controls loop controlsList="nodownload">
                   <video width="230" height="150" controls loop controlsList="nodownload">
                     <source :src="form.content" type="video/mp4">
                     <source :src="form.content" type="video/mp4">
                   </video>
                   </video>
@@ -120,7 +92,13 @@
                   placeholder="请输入跳转链接"
                   placeholder="请输入跳转链接"
                   @blur="handleLink"
                   @blur="handleLink"
                   allowClear />
                   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 value="1">
                     货架促销
                     货架促销
                   </a-select-option>
                   </a-select-option>
@@ -134,7 +112,7 @@
           <!-- 参数配置 -->
           <!-- 参数配置 -->
           <a-row style="width:83%;margin:0 auto 24px;" v-if="form.contentType =='LINK'&&form.linkType!='2'">
           <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-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>
             <a-col
             <a-col
               :xs="24"
               :xs="24"
@@ -144,11 +122,19 @@
               :xl="24"
               :xl="24"
               v-show="isShowParams">
               v-show="isShowParams">
               <!-- 参数配置内容 -->
               <!-- 参数配置内容 -->
-              <setPromotion style="margin-top:20px;" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
+              <setPromotion ref="setContent" :pageType="pageType" style="margin-top:20px;" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
             </a-col>
             </a-col>
           </a-row>
           </a-row>
         </a-card>
         </a-card>
       </a-form-model>
       </a-form-model>
+      <!-- <div class="btn-cont">
+        <a-button id="product-brand-edit-modal-back" @click="isShow = false" style="margin-right:15px;">取消</a-button>
+        <a-button
+          style="margin-right:15px;color: #fff;background-color: #39f;border-color: #39f;"
+          @click="handleSee"
+          v-if="form.contentType !='LINK'">预览</a-button>
+        <a-button type="primary" id="product-brand-edit-modal-save" @click="handleSave">确定</a-button>
+      </div> -->
     </a-spin>
     </a-spin>
     <div class="affix-cont">
     <div class="affix-cont">
       <a-button
       <a-button
@@ -157,28 +143,34 @@
         :disabled="spinning"
         :disabled="spinning"
         id="productInfoEdit-submit-btn"
         id="productInfoEdit-submit-btn"
         size="large"
         size="large"
+        v-if="pageType!='see'"
         @click="handleSave"
         @click="handleSave"
         style="padding: 0 60px;">保存</a-button>
         style="padding: 0 60px;">保存</a-button>
     </div>
     </div>
     <!-- 预览 -->
     <!-- 预览 -->
     <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
     <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>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, Upload } from '@/components'
-import Editor from '@/components/WEeditor'
-// import { saveActive, promoTerminalDetail } from '@/api/promoTerminal'
+import { VSelect } from '@/components'
+import { promoActivePublish, promoActiveDetail } from '@/api/promoActive'
 import promotionShowModal from './promotionShowModal'
 import promotionShowModal from './promotionShowModal'
 import setPromotion from './setPromotion'
 import setPromotion from './setPromotion'
 import chooseProduct from './chooseProductsModal.vue'
 import chooseProduct from './chooseProductsModal.vue'
 export default {
 export default {
   name: 'ProductBrandEditModal',
   name: 'ProductBrandEditModal',
   mixins: [commonMixin],
   mixins: [commonMixin],
-  components: { VSelect, Upload, Editor, promotionShowModal, setPromotion, chooseProduct },
+  components: { VSelect, promotionShowModal, setPromotion, chooseProduct },
   data () {
   data () {
     return {
     return {
       isShow: this.openModal, //  是否打开弹框
       isShow: this.openModal, //  是否打开弹框
@@ -188,28 +180,45 @@ export default {
         wrapperCol: { span: 16 }
         wrapperCol: { span: 16 }
       },
       },
       form: {
       form: {
-        promoActiveSn: undefined,
-        title: '',
-        contentType: 'IMAGE_CONTENT',
-        imageSet: '',
-        showFlag: '0',
-        content: '',
-        enabledFlag: '0',
-        sort: undefined,
-        contentLink: '',
-        linkType: undefined
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        images: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
+        publishState: 'UNPUBLISH',
+        promoRuleSn: undefined, // 券内容sn
+        // 参数配置数据
+        promoRule: {
+          ruleType: undefined, // 基本规则类型
+          productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+          productRangeList: [], // 产品范围列表
+          ruleName: '', // 券名称
+          ruleTitle: '', // 副标题
+          ruleBaseType: undefined, // 券生成方式
+          ruleExplain: '', // 使用说明
+          validType: undefined, // 券有效期类型
+          validStartDate: undefined, // 券生效时间
+          validEndDate: undefined, // 券失效时间
+          validDays: undefined, // 券有效期天数
+          ruleDetailList: [] // 券内容
+        }
       },
       },
       pageType: undefined, // 页面类型
       pageType: undefined, // 页面类型
       showProModal: false,
       showProModal: false,
-      images: [],
       isShowParams: false, // 是否显示参数配置内容
       isShowParams: false, // 是否显示参数配置内容
       openShowModal: false,
       openShowModal: false,
       isDisabled: false, // 控制是否能编辑
       isDisabled: false, // 控制是否能编辑
+      chooseTypeList: [],
+      chooseDataList: [],
+      images: [], // 回显显示图片数据
       rules: {
       rules: {
         title: [
         title: [
           { required: true, message: '请输入标题名称', trigger: 'blur' }
           { required: true, message: '请输入标题名称', trigger: 'blur' }
         ],
         ],
-        imageSet: [
+        images: [
           { required: true, message: '请选择要上传的封面图片', trigger: 'change' }
           { required: true, message: '请选择要上传的封面图片', trigger: 'change' }
         ],
         ],
         sort: [
         sort: [
@@ -224,11 +233,8 @@ export default {
         contentLink: [
         contentLink: [
           { required: true, message: '请输入对应内容', trigger: 'blur' }
           { required: true, message: '请输入对应内容', trigger: 'blur' }
         ],
         ],
-        enabledFlag: [
+        publishState: [
           { required: true, message: '请选择是否发布', trigger: 'change' }
           { required: true, message: '请选择是否发布', trigger: 'change' }
-        ],
-        showFlag: [
-          { required: true, message: '请选择是否显示', trigger: 'change' }
         ]
         ]
       }
       }
     }
     }
@@ -236,84 +242,139 @@ export default {
   methods: {
   methods: {
     // 设置参数
     // 设置参数
     onChangeParams (e) {
     onChangeParams (e) {
-      this.isShowParams = e.target.checked
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '改变参数配置,参数配置内容将清空,确认改变吗?',
+        centered: true,
+        onOk () {
+          _this.isShowParams = e.target.checked
+          _this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
+          if (!e.target.checked) {
+            _this.$refs.setContent.clearContent()
+            _this.$nextTick(() => {
+              _this.$refs.setContent.addCouponCon()
+            })
+          }
+        },
+        onCancel () {
+          _this.isShowParams = e.target.checked
+          _this.form.ruleEnableFlag = e.target.checked ? '1' : '0'
+        }
+      })
     },
     },
-    // 打开弹窗
-    insterProduct (flag) {
+    // 打开产品弹窗
+    insterProduct (obj) {
+      if (obj && Object.keys(obj).length > 0) {
+        this.chooseTypeList = obj.typeArr
+        this.chooseDataList = obj.productArr
+      }
       this.showProModal = true
       this.showProModal = true
     },
     },
+    // 添加产品成功
+    addProductSuccess (list) {
+      const productArr = list.map(item => {
+        return { productCode: item.code,
+          productSn: item.productSn }
+      })
+      this.$refs.setContent.setProductSn(productArr)
+    },
+    closeProductModal () {
+      this.showProModal = false
+    },
     // 返回列表
     // 返回列表
     handleBack () {
     handleBack () {
-      this.resetSearchForm()
       this.$router.push({ name: 'promotionInfoList', query: { closeLastOldTab: true } })
       this.$router.push({ name: 'promotionInfoList', 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 () {
     getDetail () {
-      // 查看按钮时,所有按钮不能编辑    编辑按钮时,state 已发布,只能编辑是否发布;state已关闭,都可以编辑
-      promoTerminalDetail({ sn: this.$route.params.sn }).then(res => {
+      // 查看按钮时,所有按钮不能编辑    编辑按钮时,只可编辑券内容
+      const _this = this
+      promoActiveDetail({ sn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {
         if (res.status == 200) {
-          if (this.pageType === 'edit') {
-            this.isDisabled = res.data.state === 'PUBLISH'
-          } else {
-            this.isDisabled = true
+          if (_this.pageType === 'edit' || _this.pageType === 'see') {
+            _this.isDisabled = true
+          }
+          _this.form.promoActiveSn = res.data.promoActiveSn
+          _this.form.promoRuleSn = (res.data.promoRule && res.data.promoRule.promoRuleSn) ? res.data.promoRule.promoRuleSn : undefined // 规则sn
+          _this.form.title = res.data.title
+          _this.form.contentType = res.data.contentType
+          _this.form.sort = res.data.sort
+          _this.form.images = res.data.images
+          if (res.data.images) {
+            const imageSet = res.data.images.split(',')
+            _this.images = imageSet
           }
           }
-          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)
-          if (res.data.contentType == 'IMAGE_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)
+          _this.form.content = res.data.content
+          _this.form.publishState = res.data.publishState
+          if (res.data.contentType == 'LINK') {
+            _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
+              res.data.promoRule.ruleDetailList.map(val => {
+                val.unit = 'GE'
+                return val
+              })
+              _this.$nextTick(() => {
+                _this.$refs.setContent.setDetailData(res.data.promoRule, res.data.promoRule.ruleDetailList)
+              })
             }
             }
-          } else if (res.data.contentType == 'LINK') {
-            this.form.contentLink = res.data.content
           }
           }
         }
         }
       })
       })
     },
     },
-    closeProductModal () {
-
-    },
-
-    //  确定
+    //  确定保存
     handleSave () {
     handleSave () {
       const _this = this
       const _this = this
       if (_this.form.contentType == 'LINK') {
       if (_this.form.contentType == 'LINK') {
         _this.form.content = _this.form.contentLink
         _this.form.content = _this.form.contentLink
+        if (_this.form.ruleEnableFlag === '1') {
+          _this.form.promoRule.ruleDetailList = _this.$refs.setContent.couponList
+        }
+        // 验证组件必填项
+        _this.$refs.setContent.testAndVerify(function (res) {
+          if (res) {
+            _this.saveInfo()
+          }
+        })
       }
       }
+    },
+    saveInfo () {
+      const _this = this
+      _this.$refs.ruleForm.validateField('ruleDetailList')
       _this.$refs.ruleForm.validate(valid => {
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
         if (valid) {
-          _this.form.promoActiveSn = this.itemId
-          const formData = JSON.parse(JSON.stringify(_this.form))
-          formData.imageSet = formData.imageSet ? formData.imageSet.split(',') : []
-          formData.showFlag = formData.enabledFlag == 0 ? '0' : formData.showFlag
+          _this.form.promoActiveSn = this.$route.params.sn
+          var formData = JSON.parse(JSON.stringify(_this.form))
+          var ajaxData = {}
           if (formData.contentType == 'LINK') {
           if (formData.contentType == 'LINK') {
             delete formData.contentLink
             delete formData.contentLink
+            formData.promoRule = _this.$refs.setContent.getPromotionVal()
+            ajaxData.promoRuleSn = formData.promoRuleSn
+            ajaxData.ruleDetailList = formData.promoRule.ruleDetailList
           }
           }
+          ajaxData.promoActiveSn = formData.promoActiveSn
           _this.spinning = true
           _this.spinning = true
-          saveActive(formData).then(res => {
+          promoActivePublish(ajaxData).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
+              _this.$nextTick(() => {
+                _this.handleBack()
+                _this.resetSearchForm()
+              })
               _this.spinning = false
               _this.spinning = false
-              _this.isShow = false
-              _this.$emit('ok')
             } else {
             } else {
               _this.spinning = false
               _this.spinning = false
             }
             }
@@ -323,41 +384,37 @@ export default {
         }
         }
       })
       })
     },
     },
-    //  图片上传
-    changeImage (file) {
-      this.form.imageSet = file
-    },
-    // 视频上传
-    changeVideo (file) {
-      this.form.content = file
-    },
-    //  文本编辑器
-    editorChange (html, text) {
-      this.form.content = html
-    },
     // 重置
     // 重置
     resetSearchForm () {
     resetSearchForm () {
-      if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
-        this.$refs.imageSet.setFileList('')
-        this.$refs.videoSet.setFileList('')
-      }
-      if (this.$refs.editor) {
-        this.$refs.editor.setHtml('')
-      }
       this.form = {
       this.form = {
-        promoActiveSn: undefined,
-        title: '',
-        contentType: 'IMAGE_CONTENT',
-        imageSet: '',
-        showFlag: '0',
-        content: '',
-        enabledFlag: '0',
-        sort: undefined,
-        contentLink: '',
-        linkType: undefined
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        images: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
+        publishState: 'UNPUBLISH',
+        promoRuleSn: undefined, // 券内容sn
+        // 参数配置数据
+        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.isDisabled = false
+      // this.$refs.setContent.clearContent()
       this.$refs.ruleForm.resetFields()
       this.$refs.ruleForm.resetFields()
     },
     },
     // 选择内容类型
     // 选择内容类型
@@ -385,17 +442,24 @@ export default {
       this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
       this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
     },
     },
     pageInit () {
     pageInit () {
-      this.pageType = this.$route.params.pageType ? this.$route.params.pageType : 'add'
-      if (this.pageType === 'edit' || this.pageType === 'see') {
-        this.getDetail()
-      }
+      this.pageType = this.$route.params.pageType
+      this.getDetail()
     }
     }
   },
   },
   mounted () {
   mounted () {
-    this.pageInit()
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+    }
   },
   },
   activated () {
   activated () {
-    this.pageInit()
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+    }
   },
   },
   beforeRouteEnter (to, from, next) {
   beforeRouteEnter (to, from, next) {
     next(vm => {})
     next(vm => {})
@@ -420,12 +484,12 @@ export default {
       width: 100%!important;
       width: 100%!important;
     }
     }
     //  文本编辑器  工具栏样式换行
     //  文本编辑器  工具栏样式换行
-    .promotionEdit-editor{
-      .w-e-toolbar{
-        flex-wrap: wrap;
-        z-index: 0;
-      }
-    }
+    // .promotionEdit-editor{
+    //   .w-e-toolbar{
+    //     flex-wrap: wrap;
+    //     z-index: 0;
+    //   }
+    // }
     // /deep/.upload-file .ant-upload-list-item-info{
     // /deep/.upload-file .ant-upload-list-item-info{
     //   padding:2px !important;
     //   padding:2px !important;
     // }
     // }

+ 40 - 33
src/views/promotionManagement/promotionInfo/list.vue

@@ -15,7 +15,7 @@
                 <a-input id="promotionInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入促销名称"/>
                 <a-input id="promotionInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入促销名称"/>
               </a-form-item>
               </a-form-item>
             </a-col>
             </a-col>
-            <a-col :md="4" :sm="24">
+            <!-- <a-col :md="4" :sm="24">
               <a-form-item label="显示状态">
               <a-form-item label="显示状态">
                 <a-select
                 <a-select
                   v-model="queryParam.showFlag"
                   v-model="queryParam.showFlag"
@@ -25,19 +25,19 @@
                   <a-select-option :value="0">未显示</a-select-option>
                   <a-select-option :value="0">未显示</a-select-option>
                 </a-select>
                 </a-select>
               </a-form-item>
               </a-form-item>
-            </a-col>
-            <a-col :md="4" :sm="24">
+            </a-col> -->
+            <a-col :md="6" :sm="24">
               <a-form-item label="促销状态">
               <a-form-item label="促销状态">
                 <v-select
                 <v-select
-                  v-model="queryParam.state"
+                  v-model="queryParam.dealerPublishState"
                   ref="sourceType"
                   ref="sourceType"
-                  id="promotionInfoList-sourceType"
+                  id="promotionInfoList-dealerPublishState"
                   code="PROMO_STATE"
                   code="PROMO_STATE"
                   placeholder="请选择促销状态"
                   placeholder="请选择促销状态"
                   allowClear></v-select>
                   allowClear></v-select>
               </a-form-item>
               </a-form-item>
             </a-col>
             </a-col>
-            <a-col :md="4" :sm="24">
+            <a-col :md="6" :sm="24">
               <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionInfoList-refresh">查询</a-button>
               <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionInfoList-refresh">查询</a-button>
               <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="promotionInfoList-reset">重置</a-button>
               <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="promotionInfoList-reset">重置</a-button>
             </a-col>
             </a-col>
@@ -71,8 +71,11 @@
           <div v-else class="desc font1" @click="handleDescModal(record)">{{ record.description }}</div>
           <div v-else class="desc font1" @click="handleDescModal(record)">{{ record.description }}</div>
         </template>
         </template>
         <!-- 状态 -->
         <!-- 状态 -->
-        <template slot="showStatus" slot-scope="text, record">
-          {{ record.showFlag == '1'?'已显示':'未显示' }}
+        <template slot="dealerPublishState" slot-scope="text, record">
+          <span v-if="record.dealerPublishState">
+            {{ record.dealerPublishState == 'PUBLISH'?'已开启':record.dealerPublishState == 'END'?'已结束':record.dealerPublishState == 'CLOSE'?'已关闭' :'未开启' }}
+          </span>
+          <span v-else>--</span>
         </template>
         </template>
         <!-- 促销展示 -->
         <!-- 促销展示 -->
         <template slot="salesShow" slot-scope="text, record">
         <template slot="salesShow" slot-scope="text, record">
@@ -92,42 +95,44 @@
             type="link"
             type="link"
             class="button-primary"
             class="button-primary"
             @click="handleOpen(record)"
             @click="handleOpen(record)"
-            v-if="(record.state=='UNPUBLISH'||record.state=='CLOSE')"
+            v-if="record.dealerEditFlag==='1'&&(record.dealerPublishState=='UNPUBLISH'||record.dealerPublishState=='CLOSE')"
             id="productOnlineInfoList-detail-btn">开启</a-button>
             id="productOnlineInfoList-detail-btn">开启</a-button>
           <a-button
           <a-button
             size="small"
             size="small"
             type="link"
             type="link"
             class="button-primary"
             class="button-primary"
-            v-if="record.state=='PUBLISH'"
+            v-if="record.dealerEditFlag==='1'&&record.dealerPublishState=='PUBLISH'"
             @click="handleClose(record)"
             @click="handleClose(record)"
             id="productOnlineInfoList-detail-btn">关闭</a-button>
             id="productOnlineInfoList-detail-btn">关闭</a-button>
           <a-button
           <a-button
             size="small"
             size="small"
             type="link"
             type="link"
             class="button-primary"
             class="button-primary"
-            v-if="record.state!='END'"
-            @click="handleEdit(record)">编辑</a-button>
+            v-if="record.dealerEditFlag==='1'&&record.dealerPublishState!='END'"
+            @click="handleEdit(record,'edit')">编辑</a-button>
           <a-button
           <a-button
             size="small"
             size="small"
             type="link"
             type="link"
             class="button-success"
             class="button-success"
-            v-if="record.state!='END'"
-            @click="handleEdit(record)">查看</a-button>
+            v-if="record.dealerPublishState!='END'"
+            @click="handleEdit(record,'see')">查看</a-button>
         </template>
         </template>
       </s-table>
       </s-table>
     </a-spin>
     </a-spin>
+    <!-- 促销描述 -->
     <promotion-desc-modal :con="descInfo" :openModal="openDescModal" @close="openDescModal = false"/>
     <promotion-desc-modal :con="descInfo" :openModal="openDescModal" @close="openDescModal = false"/>
+    <!-- 促销展示 -->
     <promotion-show-modal ref="promotionShow" :openModal="openShowModal" @close="openShowModal = false"/>
     <promotion-show-modal ref="promotionShow" :openModal="openShowModal" @close="openShowModal = false"/>
   </a-card>
   </a-card>
 </template>
 </template>
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import { promoActiveList } from '@/api/promoActive'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
 import rangeDate from '@/views/common/rangeDate.vue'
 import promotionDescModal from './promotionDescModal'
 import promotionDescModal from './promotionDescModal'
 import promotionShowModal from './promotionShowModal'
 import promotionShowModal from './promotionShowModal'
+import { promoActiveList, closeActive, publishActive } from '@/api/promoActive'
 
 
 export default {
 export default {
   name: 'UrgentOffsetList',
   name: 'UrgentOffsetList',
@@ -144,20 +149,20 @@ export default {
         beginDate: undefined,
         beginDate: undefined,
         endDate: undefined,
         endDate: undefined,
         name: '', //  促销名称
         name: '', //  促销名称
-        showFlag: undefined, // 显示状态
-        state: undefined// 促销状态
+        dealerPublishState: undefined// 促销状态
       },
       },
       descInfo: '', // 促销描述
       descInfo: '', // 促销描述
       disabled: false, //  查询、重置按钮是否可操作
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
       columns: [
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
         { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
         { title: '发布时间', dataIndex: 'createDate', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '发布时间', dataIndex: 'createDate', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '促销名称', dataIndex: 'name', width: '24%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '促销名称', dataIndex: 'name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '标题', dataIndex: 'title', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '20%', align: 'center' },
         { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '20%', align: 'center' },
         { title: '促销描述', scopedSlots: { customRender: 'desc' }, width: '20%', align: 'center' },
         { title: '促销描述', scopedSlots: { customRender: 'desc' }, width: '20%', align: 'center' },
         { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '10%', align: 'center' },
         { title: '促销展示', scopedSlots: { customRender: 'salesShow' }, width: '10%', align: 'center' },
         // { title: '显示状态', scopedSlots: { customRender: 'showStatus' }, width: '10%', align: 'center' },
         // { title: '显示状态', scopedSlots: { customRender: 'showStatus' }, width: '10%', align: 'center' },
-        { title: '状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '状态', scopedSlots: { customRender: 'dealerPublishState' }, width: '10%', align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
       ],
       // 加载数据方法 必须为 Promise 对象
       // 加载数据方法 必须为 Promise 对象
@@ -171,7 +176,7 @@ export default {
             const no = (data.pageNo - 1) * data.pageSize
             const no = (data.pageNo - 1) * data.pageSize
             for (var i = 0; i < data.list.length; i++) {
             for (var i = 0; i < data.list.length; i++) {
               data.list[i].no = no + i + 1
               data.list[i].no = no + i + 1
-              // data.list[i].images = data.list[i].images ? data.list[i].images.split(',') : []
+              data.list[i].images = data.list[i].images ? data.list[i].images.split(',') : []
             }
             }
             this.disabled = false
             this.disabled = false
           }
           }
@@ -204,7 +209,7 @@ export default {
       })
       })
     },
     },
     // 开启
     // 开启
-    handleOpen () {
+    handleOpen (row) {
       const _this = this
       const _this = this
       this.$confirm({
       this.$confirm({
         title: '提示',
         title: '提示',
@@ -212,7 +217,7 @@ export default {
         centered: true,
         centered: true,
         onOk () {
         onOk () {
           _this.spinning = true
           _this.spinning = true
-          allocLinkageOutDel({ sn: row.allocationLinkageOutSn }).then(res => {
+          publishActive({ sn: row.promoActiveSn }).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
               _this.$refs.table.refresh()
@@ -225,7 +230,7 @@ export default {
       })
       })
     },
     },
     // 关闭
     // 关闭
-    handleClose () {
+    handleClose (row) {
       const _this = this
       const _this = this
       this.$confirm({
       this.$confirm({
         title: '提示',
         title: '提示',
@@ -233,7 +238,7 @@ export default {
         centered: true,
         centered: true,
         onOk () {
         onOk () {
           _this.spinning = true
           _this.spinning = true
-          allocLinkageOutDel({ sn: row.allocationLinkageOutSn }).then(res => {
+          closeActive({ sn: row.promoActiveSn }).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
               _this.$refs.table.refresh()
@@ -246,14 +251,17 @@ export default {
       })
       })
     },
     },
     // 编辑
     // 编辑
-    handleEdit (row) {
+    handleEdit (row, type) {
       const _this = this
       const _this = this
-      // _this.$warning({
-      //   title: '提示',
-      //   content: '请先关闭活动,活动关闭后可编辑活动'
-      // })
-      _this.$router.push({ name: 'promotionInfoEdit', params: { sn: row.promoActiveSn } })
-      // _this.$router.push({ name: 'promotionInfoDetail', params: { sn: row.promoActiveSn } })
+      if (row.dealerPublishState === 'PUBLISH' && type === 'edit') {
+        _this.$warning({
+          title: '提示',
+          content: '请先关闭活动,活动关闭后可编辑活动'
+        })
+      } else {
+        const nameInfo = type === 'edit' ? 'promotionInfoEdit' : 'promotionInfoDetail'
+        _this.$router.push({ name: nameInfo, params: { sn: row.promoActiveSn, pageType: type } })
+      }
     },
     },
     //  重置
     //  重置
     resetSearchForm () {
     resetSearchForm () {
@@ -261,8 +269,7 @@ export default {
       this.queryParam.beginDate = undefined
       this.queryParam.beginDate = undefined
       this.queryParam.endDate = undefined
       this.queryParam.endDate = undefined
       this.queryParam.name = ''
       this.queryParam.name = ''
-      this.queryParam.showFlag = undefined
-      this.queryParam.state = undefined
+      this.queryParam.dealerPublishState = undefined
       this.$refs.table.refresh(true)
       this.$refs.table.refresh(true)
     },
     },
     pageInit () {
     pageInit () {

+ 282 - 202
src/views/promotionManagement/promotionInfo/setPromotion.vue

@@ -5,95 +5,97 @@
       ref="sellRuleForm"
       ref="sellRuleForm"
       :model="sellForm"
       :model="sellForm"
       :rules="sellRules"
       :rules="sellRules"
+      class="setPromotion-form"
       :label-col="sellFormItemLayout.labelCol"
       :label-col="sellFormItemLayout.labelCol"
       :wrapper-col="sellFormItemLayout.wrapperCol">
       :wrapper-col="sellFormItemLayout.wrapperCol">
       <a-row>
       <a-row>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
         <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-select
-              v-model="sellForm.contentType"
+              v-model="sellForm.ruleType"
               placeholder="请选择基本规则"
               placeholder="请选择基本规则"
-              ref="saleStatus"
-              id="promotion-saleStatus"
-              code="PROMO_CONTENT_TYPE"
+              id="setPromotion-ruleType"
+              code="PROMO_ACTIVE_RULE_TYPE"
               :disabled="disabledVal"
               :disabled="disabledVal"
               allowClear></v-select>
               allowClear></v-select>
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
         <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
             <a-input
               :disabled="disabledVal"
               :disabled="disabledVal"
-              id="setPromotion-title"
+              id="setPromotion-ruleName"
               :maxLength="20"
               :maxLength="20"
-              v-model.trim="sellForm.title"
+              v-model.trim="sellForm.ruleName"
               placeholder="请输入券名称(最多20个字符)"
               placeholder="请输入券名称(最多20个字符)"
               allowClear />
               allowClear />
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
         <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
             <a-input
               :disabled="disabledVal"
               :disabled="disabledVal"
-              id="setPromotion-title"
+              id="setPromotion-ruleTitle"
               :maxLength="20"
               :maxLength="20"
-              v-model.trim="sellForm.title"
+              v-model.trim="sellForm.ruleTitle"
               placeholder="请输入券副标题(最多20个字符)"
               placeholder="请输入券副标题(最多20个字符)"
               allowClear />
               allowClear />
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
           <a-form-model-item label="产品范围">
           <a-form-model-item label="产品范围">
-            <div id="setPromotionRange" style="position:relative;">
+            <div id="setPromotion-productRange" style="position:relative;">
               <a-tree-select
               <a-tree-select
-                v-model="con"
+                v-model="sellForm.productRangeList"
                 style="width: 100%"
                 style="width: 100%"
-                :tree-data="treeData"
+                :maxTagCount="12"
+                :tree-data="productTypeList"
                 tree-checkable
                 tree-checkable
                 :disabled="disabledVal"
                 :disabled="disabledVal"
-                :show-checked-strategy="SHOW_ALL"
                 :getPopupContainer="triggerNode => triggerNode.parentNode"
                 :getPopupContainer="triggerNode => triggerNode.parentNode"
+                :replaceFields="{children:'children',title: 'productTypeName',key: 'productTypeSn',value: 'productTypeSn'}"
+                @blur="onChangeTree"
                 placeholder="请选择产品范围" />
                 placeholder="请选择产品范围" />
-                <!-- @change="onChangeTree" -->
             </div>
             </div>
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
         <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"
+              @change="handleRuleBaseType"
+              allowClear></v-select>
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
         <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">
                 <a-col :md="22" :sm="24">
                   <div class="couponList">
                   <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 :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
                         购买<a-input-number
                           style="margin:0 5px;"
                           style="margin:0 5px;"
-                          v-model="couponForm.regularValue"
+                          v-model="item.productQty"
                           :step="1"
                           :step="1"
                           :max="99999999"
                           :max="99999999"
                           :precision="0"
                           :precision="0"
-                          :disabled="disabledVal"
+                          :disabled="true"
                           size="small"/>
                           size="small"/>
                         <a-select
                         <a-select
                           default-value="GE"
                           default-value="GE"
-                          :disabled="disabledVal"
-                          v-model="couponForm.regularUnit"
+                          v-model="item.unit"
                           style="width: 60px;"
                           style="width: 60px;"
                           size="small"
                           size="small"
-                          @change="handleChangeUnit">
+                          :disabled="true">
                           <a-select-option value="GE">
                           <a-select-option value="GE">
                           </a-select-option>
                           </a-select-option>
@@ -102,104 +104,41 @@
                           </a-select-option>
                           </a-select-option>
                         </a-select>
                         </a-select>
                         活动产品,送<a-input-number
                         活动产品,送<a-input-number
-                          v-model="couponForm.promotionValue"
-                          :disabled="disabledVal"
+                          v-model="item.ruleValue"
                           style="margin:0 5px;"
                           style="margin:0 5px;"
                           :min="0"
                           :min="0"
                           :step="1"
                           :step="1"
                           :precision="2"
                           :precision="2"
                           :max="99999999"
                           :max="99999999"
+                          :disabled="pageType==='see'?disabledVal:!disabledVal"
                           size="small"/> 元
                           size="small"/> 元
                       </a-form-model-item>
                       </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-form-model-item class="productName" label="活动产品" prop="ruleProductList">
+                        <a-button type="primary" :disabled="pageType==='see'?disabledVal:!disabledVal" @click="handleAddProduct(item)" size="small">添加产品</a-button>
+                        <div class="productCon" v-if="item.ruleProductList && item.ruleProductList.length>0">
+                          <a-tag :closable="pageType==='see'?!disabledVal:disabledVal" @close="delBuyerName(item,con)" v-for="con in item.ruleProductList" :key="con.productSn">
+                            {{ con.productCode }}
                           </a-tag>
                           </a-tag>
                         </div>
                         </div>
                       </a-form-model-item>
                       </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>
-                    </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"
-                          style="margin:0 5px;"
-                          :min="0"
-                          :step="1"
-                          :precision="2"
-                          :max="99999999"
-                          :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-tag>
-                        </div>
-                      </a-form-model-item>
-                      <a-form-model-item label="券适用范围" prop="desc">
-                        全部产品
-                      </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
                         <a-input
-                          v-model="couponForm.desc"
-                          :disabled="disabledVal"
+                          v-model="item.detailExplain"
+                          :disabled="pageType==='see'?disabledVal:!disabledVal"
                           style="width:80%;"
                           style="width:80%;"
                           type="textarea"
                           type="textarea"
                           placeholder="请输入使用说明"
                           placeholder="请输入使用说明"
-                          :maxLength="200" />
+                          :maxLength="50" />
                       </a-form-model-item>
                       </a-form-model-item>
                     </a-form-model>
                     </a-form-model>
                   </div>
                   </div>
                 </a-col>
                 </a-col>
                 <a-col :md="2" :sm="24">
                 <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="pageType==='see'?disabledVal:!disabledVal">+新增</a-button>
+                  <a-button type="link" v-show="i!=0" @click="delCouponCon(item.id)" :disabled="pageType==='see'?disabledVal:!disabledVal">删除</a-button>
                 </a-col>
                 </a-col>
               </a-row>
               </a-row>
             </div>
             </div>
@@ -211,30 +150,31 @@
           :md="12"
           :md="12"
           :lg="24"
           :lg="24"
           :xl="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" />
+          v-if="sellForm.ruleBaseType!='category'">
+          <a-form-model-item label="使用说明" prop="ruleExplain">
+            <a-input v-model="sellForm.ruleExplain" type="textarea" placeholder="请输入使用说明" :disabled="disabledVal" :maxLength="50" />
           </a-form-model-item>
           </a-form-model-item>
         </a-col>
         </a-col>
         <a-col :xs="24" :sm="24" :md="12" :lg="24" :xl="24">
         <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" @change="handleValidType">
+              <a-radio :style="radioStyle" value="FIXED">
                 <span>固定日期</span>
                 <span>固定日期</span>
                 <a-range-picker
                 <a-range-picker
                   style="width:100%;margin-left:5px;"
                   style="width:100%;margin-left:5px;"
-                  v-model="sellForm.time"
+                  v-model="time"
                   :format="dateFormat"
                   :format="dateFormat"
                   @change="dateChange"
                   @change="dateChange"
                   :disabled="disabledVal"
                   :disabled="disabledVal"
+                  :disabled-date="disabledDate"
                   :placeholder="['开始时间', '结束时间']" />
                   :placeholder="['开始时间', '结束时间']" />
-                  <!-- :disabled-date="disabledDate" -->
               </a-radio>
               </a-radio>
-              <a-radio :style="radioStyle" :value="2">
+              <a-radio :style="radioStyle" value="LIMIT">
                 <span>领取后,当天生效,有效期至</span><a-input-number
                 <span>领取后,当天生效,有效期至</span><a-input-number
                   style="margin:0 5px;"
                   style="margin:0 5px;"
-                  v-model="sellForm.regularValue"
+                  v-model="sellForm.validDays"
                   :step="1"
                   :step="1"
+                  :min="1"
                   :max="99999999"
                   :max="99999999"
                   :disabled="disabledVal"
                   :disabled="disabledVal"
                   :precision="0"/>天
                   :precision="0"/>天
@@ -249,9 +189,10 @@
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
+import moment from 'moment'
 import { VSelect } from '@/components'
 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/promoActive'
 export default {
 export default {
   name: 'PromotionAddModal',
   name: 'PromotionAddModal',
   mixins: [commonMixin],
   mixins: [commonMixin],
@@ -260,17 +201,21 @@ export default {
     disabledVal: {
     disabledVal: {
       type: Boolean,
       type: Boolean,
       default: false
       default: false
+    },
+    pageType: {
+      type: String,
+      default: 'edit'
     }
     }
   },
   },
   data () {
   data () {
     return {
     return {
       spinning: false,
       spinning: false,
-      SHOW_ALL,
       // form 表单label布局设置
       // form 表单label布局设置
       sellFormItemLayout: {
       sellFormItemLayout: {
         labelCol: { span: 2 }, // 文字前距离设置
         labelCol: { span: 2 }, // 文字前距离设置
         wrapperCol: { span: 20 }// 表单后距离设置  数字越大距离越小
         wrapperCol: { span: 20 }// 表单后距离设置  数字越大距离越小
       },
       },
+      // 卷内容 form 表单label布局设置
       couponFormLayout: {
       couponFormLayout: {
         labelCol: { span: 3 },
         labelCol: { span: 3 },
         wrapperCol: { span: 18 }
         wrapperCol: { span: 18 }
@@ -281,111 +226,246 @@ export default {
         height: '50px',
         height: '50px',
         lineHeight: '40px'
         lineHeight: '40px'
       },
       },
+      // 主要内容 提交数据
       sellForm: {
       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, // 券有效期天数
+        // ruleDetailName:undefined,
+        // 券内容
+        ruleDetailList: []
       },
       },
-      dateFormat: 'YYYY-MM',
-      con: [],
-      couponList: [{
-        val1: '',
-        unit: ''
-      }], // 按产品款数生成券 数据
-      treeData: [],
-      showProModal: false,
-      couponForm: {},
-      couponRules: {},
-
+      editFlag: true, // 编辑页面 可编辑内容
+      // 券内容 提交数据
+      couponList: [],
+      // 按产品款数生成券 数据
+      dateFormat: 'YYYY-MM-DD',
+      posNum: null, // 选择产品位置
       sellRules: {
       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' }],
+        ruleExplain: [{ required: true, message: '请输入使用说明', trigger: ['change', 'blur'] }],
+        validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
+        ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'change' }]
+      },
+      productTypeList: [],
+      time: []
     }
     }
   },
   },
   methods: {
   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 typeArr = this.sellForm.productRangeList || []
+      let productArr = []
+      this.couponList.forEach(item => {
+        if (item.ruleProductList && item.ruleProductList.length > 0) {
+          const arr = item.ruleProductList.map(con => { return con.productSn })
+          productArr = productArr.concat(arr)
+        }
+      })
+      this.$emit('addProduct', { typeArr, productArr })
     },
     },
-    // 生成方式 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) {
       if (this.couponList.length >= 10) {
         this.$message.warning('最多只能新增10个!')
         this.$message.warning('最多只能新增10个!')
         return
         return
       }
       }
+      const result = await getNewScopeSn({})
+      const obj = {
+        id: result.data,
+        productQty: 1, // 产品数量
+        ruleValue: undefined, // 返利金额
+        detailExplain: undefined, // 使用说明
+        unit: 'GE',
+        range: '1',
+        ruleProductList: []
+      }
       this.couponList.push(obj)
       this.couponList.push(obj)
     },
     },
     // 删除券内容
     // 删除券内容
     delCouponCon (id) {
     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 = []
+        }
+      })
     },
     },
-    onChangeTree (e) {
-      debugger
+    // 券生成方式 change
+    handleRuleBaseType () {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '改变生成方式,券内容也会改变,确认改变吗?',
+        centered: true,
+        onOk () {
+          _this.couponList.map(item => {
+            item.detailExplain = undefined
+            return item
+          })
+        }
+      })
+    },
+    // 券有效期 change
+    handleValidType (con) {
+      this.sellForm.validType = con.target.value
+      if (con.target.value === 'FIXED') {
+        this.sellForm.validDays = undefined
+      } else {
+        this.time = []
+        this.sellForm.validStartDate = undefined
+        this.sellForm.validEndDate = undefined
+      }
+    },
+    setProductSn (list) {
+      this.couponList[this.posNum].ruleProductList = list
+    },
+    // 验证必填项
+    testAndVerify (callBack) {
+      if (this.couponList && this.couponList.length > 0) {
+       let moneyFlag = this.couponList.some( con => !con.ruleValue)
+       let productFlag = this.couponList.some( con => con.ruleProductList && con.ruleProductList.length == 0)
+       if(moneyFlag){
+         this.$message.warning('请输入返利金额!')
+         return false
+       }
+       if(productFlag){
+         this.$message.warning('请选择活动产品!')
+        return false
+       }
+      }
+      this.$refs.sellRuleForm.validate(valid => {
+        if (valid){
+          callBack(valid)
+        } else {
+          return false
+        }
+      })
+    },
+    // 返回组件值
+    getPromotionVal () {
+      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>
 </script>
 
 
 <style lang="less" scoped>
 <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>
 </style>

+ 1 - 1
src/views/salesManagement/salesQuery/detail.vue

@@ -66,7 +66,7 @@
               折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
               折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
               折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
               折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
               折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
               折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
-              已发放券金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
+              已发放券金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;
             </div>
             </div>
             <div>
             <div>
               <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
               <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>

+ 5 - 4
src/views/salesManagement/salesQueryNew/detail.vue

@@ -71,6 +71,7 @@
               折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
               折后总售价:<strong>{{ detailData&&(detailData.discountedAmount || detailData.discountedAmount==0) ? toThousands(detailData.discountedAmount) : '--' }}</strong>;
               折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
               折扣:<strong>{{ detailData&&(detailData.discountRate || detailData.discountRate==0) ? detailData.discountRate+'%' : '--' }}</strong>;
               折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
               折扣金额:<strong>{{ detailData&&(detailData.discountAmount || detailData.discountAmount==0) ? toThousands(detailData.discountAmount) : '--' }}</strong>;
+              已发放券金额:<strong>{{ detailData&&(detailData.totalGiveAmount || detailData.totalGiveAmount==0) ? toThousands(detailData.totalGiveAmount) : '--' }}</strong>;
             </div>
             </div>
             <div>
             <div>
               <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
               <a-checkbox v-model="showCost" v-if="$hasPermissions('M_ShowAllCost')" id="salesQuery-cost">成本价</a-checkbox>
@@ -242,10 +243,10 @@ export default {
       const _this = this
       const _this = this
       _this.spinning = true
       _this.spinning = true
       let url = salesDetailPrint
       let url = salesDetailPrint
-      const params = { 
-        sn: this.outBizSn || this.$route.params.sn, 
-        printOrgCode: this.printOrgCode ? 1 : 0, 
-        printAllName: this.printAllName ? 1 : 0, 
+      const params = {
+        sn: this.outBizSn || this.$route.params.sn,
+        printOrgCode: this.printOrgCode ? 1 : 0,
+        printAllName: this.printAllName ? 1 : 0,
         remarksShowFlag: this.printRemarks ? 1 : 0,
         remarksShowFlag: this.printRemarks ? 1 : 0,
         priceFlag: this.printPrice ? 1 : 0
         priceFlag: this.printPrice ? 1 : 0
       }
       }