Browse Source

促销活动

chenrui 9 months ago
parent
commit
8cdbf6b6e9

+ 62 - 61
src/views/easyPassManagement/promotionalActivities/detailModal.vue

@@ -18,67 +18,68 @@
           :label-col="formItemLayout.labelCol"
           :wrapper-col="formItemLayout.wrapperCol" >
           <a-row>
-             <a-col :xs="12" :sm="24">
-               <a-form-model-item label="促销名称" prop="title">
-                 {{ form.title }}
-               </a-form-model-item>
-             </a-col>
-              <a-col :xs="12" :sm="24">
-                <a-form-model-item label="促销时间" prop="sort">
-                  {{ form.sort }}
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="12" :sm="24">
-                <a-form-model-item label="排序" prop="sort">
-                  {{ form.sort }}
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="24" :sm="24">
-                <a-form-model-item label="封面图片" prop="imageSet">
-                  <img
-                    :src="con"
-                    alt="图片走丢了"
-                    width="80"
-                    height="80"
-                    v-for="(con,i) in imageSet"
-                    style="margin-right:10px;object-fit: cover;"
-                    :key="i"/>
-                  <div class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</div>
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="24" :sm="24">
-                <a-form-model-item label="参与经销商" prop="sort">
-                  {{ form.sort }}
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="24" :sm="24">
-                <a-form-model-item label="促销描述" prop="ruleExplain" >
-                  {{ form.promoRule&&form.promoRule.ruleExplain?form.promoRule.ruleExplain:'--' }}
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="24" :sm="24">
-                <a-form-model-item label="加盟商编辑" prop="dealerEditFlag" >
-                  {{ form.dealerEditFlag?form.dealerEditFlag==='1'?'是':'否':'--' }}
-                </a-form-model-item>
-              </a-col>
-              <a-col :xs="24" :sm="24">
-                 <a-form-model-item label="返券产品" prop="publishFlag" >
-                   <div class="productTable">
-                     <s-table
-                       class="sTable"
-                       ref="table"
-                       size="small"
-                       :rowKey="(record) => record.id"
-                       :columns="columns"
-                       :data="loadData"
-                       :defaultLoadData="false"
-                       :style="{ maxHeight: 300+'px' }"
-                       :scroll="{ y:230 }"
-                       bordered>
-                     </s-table>
-                   </div>
-                 </a-form-model-item>        
-              </a-col>
+            <a-col :xs="12" :sm="24">
+              <a-form-model-item label="促销名称" prop="title">
+                {{ form.title }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="12" :sm="24">
+              <a-form-model-item label="促销时间" prop="sort">
+                {{ form.sort }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="12" :sm="24">
+              <a-form-model-item label="排序" prop="sort">
+                {{ form.sort }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24">
+              <a-form-model-item label="参与经销商" prop="sort">
+                {{ form.sort }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24">
+              <a-form-model-item label="封面图片" prop="imageSet">
+                <img
+                  :src="con"
+                  alt="图片走丢了"
+                  width="80"
+                  height="80"
+                  v-for="(con,i) in imageSet"
+                  style="margin-right:10px;object-fit: cover;"
+                  :key="i"/>
+                <div class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</div>
+              </a-form-model-item>
+            </a-col>
+
+            <a-col :xs="24" :sm="24">
+              <a-form-model-item label="促销描述" prop="ruleExplain" >
+                {{ form.promoRule&&form.promoRule.ruleExplain?form.promoRule.ruleExplain:'--' }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24">
+              <a-form-model-item label="加盟商编辑" prop="dealerEditFlag" >
+                {{ form.dealerEditFlag?form.dealerEditFlag==='1'?'是':'否':'--' }}
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24">
+              <a-form-model-item label="返券产品" prop="publishFlag" >
+                <div class="productTable">
+                  <s-table
+                    class="sTable"
+                    ref="table"
+                    size="small"
+                    :rowKey="(record) => record.id"
+                    :columns="columns"
+                    :data="loadData"
+                    :defaultLoadData="false"
+                    :style="{ maxHeight: 300+'px' }"
+                    :scroll="{ y:230 }"
+                    bordered>
+                  </s-table>
+                </div>
+              </a-form-model-item>
+            </a-col>
           </a-row>
         </a-form-model>
         <div class="btn-cont">

+ 703 - 0
src/views/easyPassManagement/promotionalActivities/edit.vue

@@ -0,0 +1,703 @@
+<template>
+  <div class="promotionEdit-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <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>
+          <span v-if="pageType==='edit'" style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">促销名称:{{ promotionName||'--' }}</span>
+        </template>
+      </a-page-header>
+      <!-- 表单 -->
+      <a-card :bordered="false" class="promotionEdit-cont">
+        <a-form-model
+          id="promotionEdit-form"
+          ref="ruleForm"
+          :model="form"
+          :rules="rules"
+          :label-col="formItemLayout.labelCol"
+          :wrapper-col="formItemLayout.wrapperCol"
+        >
+          <a-row>
+            <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
+              <a-form-model-item label="促销名称" prop="title" :label-col="{span:4}" :wrapper-col="{span:16}">
+                <a-input
+                  id="promotionEdit-title"
+                  :maxLength="20"
+                  v-model.trim="form.title"
+                  placeholder="请输入促销名称(最多20个字符)"
+                  :disabled="isDisabled"
+                  allowClear/>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
+              <a-form-model-item label="促销时间" prop="time" :label-col="{span:4}" :wrapper-col="{span:16}">
+                <a-range-picker
+                  style="width:100%"
+                  id="promotionAdd-time"
+                  v-model="form.time"
+                  :format="dateFormat"
+                  :disabled-date="disabledDate"
+                  @change="dateChange"
+                  :placeholder="['开始时间', '结束时间']" />
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
+              <a-form-model-item label="排序" prop="sort" :label-col="{span:4}" :wrapper-col="{span:16}">
+                <a-input-number
+                  style="width:100%"
+                  id="promotionEdit-sort"
+                  :disabled="isDisabled"
+                  allowClear
+                  placeholder="请输入排序数字(数字越大越靠后)"
+                  v-model="form.sort"
+                  :min="0"
+                  :max="99999999"/>
+              </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-row :gutter="15">
+                  <a-col :md="10" :sm="24">
+                    <a-select id="promotionList-dealerScope" v-model="form.dealerScope" placeholder="请选择参与经销商" @change="changeDealerScope" allowClear>
+                      <a-select-option id="promotionList-dealerScope-all" value="ALL_DEALER">全部经销商</a-select-option>
+                      <a-select-option id="promotionList-dealerScope-some" value="SOME_DEALER">部分经销商</a-select-option>
+                    </a-select>
+                  </a-col>
+                  <a-col :md="3" :sm="24" v-show="form.dealerScope && form.dealerScope!='ALL_DEALER' ">
+                    <a-button id="promotionList-basicInfo-dealerScope" type="primary" :loading="spinning" @click="handleDealerModal">选择</a-button>
+                  </a-col>
+                  <a-col :md="5" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
+                    已{{ chooseDealerList.length }}选项
+                  </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" id="promotionList-dealerSn" :key="con.dealerSn" @close="delBuyerName(con)">
+                        {{ con.dealerName }}
+                      </a-tag>
+                    </div>
+                  </a-col>
+                </a-row>
+              </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">
+                <Upload
+                  class="upload"
+                  id="promotionEdit-imageSet"
+                  v-model="form.imageSet"
+                  ref="imageSet"
+                  :fileSize="10"
+                  :maxNums="1"
+                  @change="changeImage"
+                  listType="picture-card"></Upload>
+                <!-- <div v-else>
+                  <img
+                    :src="con"
+                    alt="图片走丢了"
+                    width="80"
+                    height="80"
+                    v-for="(con,i) in imageSet"
+                    style="margin-right:10px;object-fit: cover;"
+                    :key="i" />
+                </div> -->
+                <span class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</span>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="促销描述" prop="promoRule.ruleExplain">
+                <a-input
+                  v-model="form.promoRule.ruleExplain"
+                  :disabled="isDisabled"
+                  type="textarea"
+                  id="promotionEdit-ruleExplain"
+                  placeholder="请输入促销描述(最多500个字符)"
+                  :maxLength="500" />
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="加盟商编辑" prop="promoRule.dealerEditFlag">
+                <v-select
+                  v-model="form.contentType"
+                  id="promotion-contentType"
+                  code="FLAG"
+                  showType="radio"
+                  :disabled="isDisabled"
+                  @change="changeContentType"
+                  allowClear></v-select>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="促销规则" prop="promoRule.range">
+                <div class="productInfo flex-center">
+                  <div>
+                    同款产品买<a-input-number
+                      v-model="form.promoRule.ruleValue"
+                      style="margin:0 5px;"
+                      :min="0"
+                      :step="1"
+                      :precision="2"
+                      :max="99999999"
+                      id="promotionEdit-ruleValue"
+                      :disabled="isDisabled"
+                      size="small"/>赠
+                    <a-input-number
+                      v-model="form.promoRule.ruleValue"
+                      style="margin:0 5px;"
+                      :min="0"
+                      :step="1"
+                      :precision="2"
+                      :max="99999999"
+                      id="promotionEdit-ruleValue"
+                      :disabled="isDisabled"
+                      size="small"/>个(数量叠加)
+                    <a-button
+                      type="primary"
+                      id="promotionEdit-addSet-btn"
+                      :disabled="isDisabled"
+                      class="button-primary"
+                      size="small"
+                      @click="handleBatchAdd">批量设置</a-button>
+                  </div>
+                  <a-button type="primary" id="promotionEdit-add-btn" :disabled="isDisabled" @click="handleAddProduct" size="small">选择产品</a-button>
+                </div>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <div style="width: 83%;margin:0 auto 10px;">
+                <productTable ref="chooseProductList" :promoActiveSn="$route.params.sn" :disabledVal="isDisabled"></productTable>
+              </div>
+            </a-col>
+          </a-row>
+        </a-form-model>
+      </a-card>
+    </a-spin>
+    <div class="affix-cont">
+      <a-button
+        type="primary"
+        class="button-primary"
+        :disabled="spinning"
+        id="productInfoEdit-submit-btn"
+        size="large"
+        @click="handleSave('all')"
+        v-if="form.contentType !='LINK'|| isShowNextStep ||(form.contentType ==='LINK'&&form.linkType ==='2')"
+        style="padding: 0 60px;">保存</a-button>
+    </div>
+    <!-- 添加产品 -->
+    <chooseProduct
+      ref="chooseProduct"
+      :chooseType="chooseTypeList"
+      :itemSn="$route.params.sn"
+      :openModal="showProModal"
+      @ok="addProductSuccess"
+      @close="closeProductModal"></chooseProduct>
+  </div>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import moment from 'moment'
+// 组件
+import { VSelect, Upload } from '@/components'
+import Editor from '@/components/WEeditor'
+// import promotionShowModal from './promotionShowModal'
+import productTable from './productTable'
+// import chooseProduct from './chooseProductsModal.vue'
+// 接口
+import { productTypeQuery } from '@/api/productType'
+import { promoActivePublish, promoActiveDetail, saveBatchEntity, promoCreateBatch, deleteByProductType } from '@/api/promoActive'
+export default {
+  name: 'ProductBrandEditModal',
+  mixins: [commonMixin],
+  components: { VSelect, Upload, Editor, productTable },
+  data () {
+    return {
+      spinning: false,
+      // 表单 label 设置
+      formItemLayout: {
+        labelCol: { span: 2 },
+        wrapperCol: { span: 20 }
+      },
+      productRangeList: [], // 产品范围列表
+      dateFormat: 'YYYY-MM-DD', // 促销时间显示格式
+      // 链接配置内容
+      form: {
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        publishFlag: '0', // 是否发布
+        linkType: '1',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        promoRule: {
+          ruleType: 'ticket', // 基本规则类型
+          ruleName: '', // 券名称
+          ruleTitle: '', // 副标题
+          ruleBaseType: 'category', // 券生成方式
+          ruleExplain: '', // 使用说明
+          validType: undefined, // 券有效期类型
+          validStartDate: undefined, // 券生效时间
+          validEndDate: undefined, // 券失效时间
+          validDays: undefined, // 券有效期天数
+          dealerEditFlag: '0', // 加盟商编辑 1是 0否
+          publishFlag: '0', // 是否发布
+          range: '1'
+        }
+      },
+      chooseDealerList: [], // 所选经销商数据
+      time: [], // 有效期
+      promotionName: '', // 促销名称
+      pageType: undefined, // 页面类型
+      showProModal: false, // 打开产品弹窗
+      isShowNextStep: false, // 是否显示下一步 并提交一半配置产品
+      isDisabled: false, // 控制页面是否能编辑
+      chooseTypeList: [], // 已选中产品范围
+      imageSet: [], // 回显显示图片数据
+      productTypeList: [], // 产品范围    列表数据
+      // 表单验证规则
+      rules: {
+        title: [{ required: true, message: '请输入标题名称', trigger: 'blur' }],
+        imageSet: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
+        sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
+        contentType: [{ required: true, message: '请选择内容类型', trigger: 'change' }],
+        content: [{ required: true, message: '请输入对应内容', trigger: ['blur', 'change'] }],
+        contentLink: [{ required: true, message: '请输入对应内容', trigger: 'blur' }],
+        publishFlag: [{ required: true, message: '请选择是否发布', trigger: 'change' }],
+        'promoRule.ruleType': [{ required: true, message: '请选择基本规则', trigger: 'change' }],
+        'promoRule.ruleName': [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
+        'promoRule.ruleBaseType': [{ required: true, message: '请选择生成方式', trigger: 'change' }],
+        'promoRule.validType': [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
+        'promoRule.publishFlag': [{ required: true, message: '请选择是否发布', trigger: 'change' }],
+        'promoRule.dealerEditFlag': [{ required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }],
+        'promoRule.range': [{ required: true, message: '请选择', trigger: 'blur' }],
+        dealerEditFlag: [{ required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }]
+      }
+    }
+  },
+  methods: {
+    // 禁用日期时间
+    disabledDate (current) {
+      return current && current < moment().startOf('day')
+    },
+    // 日期  change
+    dateChange (date, dateStrings) {
+      if (dateStrings && dateStrings[0]) {
+        this.form.time = dateStrings
+        this.form.activeDateStart = date.length ? dateStrings[0] + ' 00:00:00' : ''
+        this.form.activeDateEnd = date.length ? dateStrings[1] + ' 23:59:59' : ''
+      } else {
+        this.form.time = []
+      }
+    },
+    // 打开产品弹窗
+    insterProduct (obj) {
+      if (obj && Object.keys(obj).length > 0) {
+        this.chooseTypeList = obj.typeArr
+      }
+      this.showProModal = true
+    },
+    // 关闭产品弹窗
+    closeProductModal () {
+      this.showProModal = false
+    },
+    // 返回列表
+    handleBack () {
+      this.$router.push({ name: 'promotionalActivities', query: { closeLastOldTab: true } })
+    },
+    //  详情  挨个赋值原因:该接口和修理厂促销列表详情用的同一个接口,给后端传值过滤多余参数
+    getDetail () {
+      const _this = this
+      promoActiveDetail({ sn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          // 编辑按钮时,publishState 已发布,只能编辑是否发布;publishState已关闭,都可以编辑
+          if (_this.pageType === 'edit') {
+            _this.isDisabled = res.data.publishState === 'PUBLISH'
+            _this.form.promoRule.publishFlag = res.data.publishFlag
+            _this.form.promoRule.dealerEditFlag = res.data.dealerEditFlag
+          }
+          _this.form.publishFlag = res.data.publishFlag
+          _this.form.dealerEditFlag = res.data.dealerEditFlag
+          _this.form.promoActiveSn = res.data.promoActiveSn
+          _this.form.title = res.data.title
+          _this.form.contentType = res.data.contentType
+          _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
+            if (this.pageType === 'add' || (this.pageType === 'edit' && res.data.publishState != 'PUBLISH')) {
+              _this.$refs.imageSet.setFileList(images)
+            }
+          }
+          _this.form.content = res.data.content
+          _this.promotionName = res.data.name || ''
+          _this.form.dealerEditFlag = res.data.dealerEditFlag
+          if (res.data.contentType == 'IMAGE_CONTENT') {
+            _this.$refs.editor.setHtml(res.data.content)
+          } else if (res.data.contentType == 'VIDEO') {
+            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.linkType = res.data.content != '/pagesB/promoDetail' ? '2' : '1'
+            if (res.data.promoRule) {
+              _this.isShowNextStep = true
+              _this.form.promoRule.range = '1'
+              _this.time = [res.data.promoRule.validStartDate, res.data.promoRule.validEndDate]
+              if (res.data.promoRule.productRangeList && res.data.promoRule.productRangeList.length > 0) {
+                _this.productRangeList = res.data.promoRule.productRangeList.map(item => { return item.productTypeSn })
+              }
+            }
+            _this.form.promoRule = { ..._this.form.promoRule, ...res.data.promoRule }
+          }
+        }
+      })
+    },
+    // 券有效期 change
+    handleValidType (con) {
+      this.form.promoRule.validType = con
+      if (con === 'FIXED') {
+        this.form.promoRule.validDays = undefined
+      } else {
+        this.time = []
+        this.form.promoRule.validStartDate = undefined
+        this.form.promoRule.validEndDate = undefined
+      }
+    },
+    //  确定保存  验证必填
+    handleSave (type) {
+      const _this = this
+      if (_this.form.contentType === 'LINK') {
+        _this.form.content = _this.form.contentLink
+      }
+      // 验证组件必填项
+      _this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.savePartInfo(type)
+        }
+      })
+    },
+    // 保存
+    savePartInfo (type) {
+      const _this = this
+      _this.form.promoActiveSn = this.$route.params.sn
+      var formData = JSON.parse(JSON.stringify(_this.form))
+      formData.imageSet = formData.imageSet ? formData.imageSet.split(',') : []
+      // 跳转链接
+      if (formData.contentType == 'LINK') {
+        delete formData.contentLink
+        if (_this.productRangeList && _this.productRangeList.length > 0) {
+          formData.promoRule.productRangeList = _this.productRangeList.map(item => { return { productTypeSn: item } })
+        }
+        // 促销活动
+        if (_this.form.linkType === '1') {
+          if (_this.form.promoRule.validType === 'FIXED') {
+            if (!_this.form.promoRule.validStartDate || _this.form.promoRule.validStartDate.validEndDate) {
+              _this.$message.warning('请输入券有效期!')
+              return false
+            }
+          } else {
+            if (!_this.form.promoRule.validDays) {
+              _this.$message.warning('请输入券有效期!')
+              return false
+            }
+          }
+          formData.publishFlag = _this.form.promoRule.publishFlag
+          formData.dealerEditFlag = _this.form.promoRule.dealerEditFlag
+        } else {
+          formData.promoRule = undefined
+        }
+        if (_this.$refs.chooseProductList) {
+          const numInfo = _this.$refs.chooseProductList.getDataNum()
+          if (numInfo == 0) {
+            _this.$message.warning('请选择返券产品!')
+            return
+          }
+        }
+      } else {
+        formData.promoRule = undefined
+      }
+      _this.spinning = true
+
+      promoActivePublish(formData).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          if (type === 'all') {
+            _this.$nextTick(() => {
+              _this.handleBack()
+              _this.resetSearchForm()
+            })
+          } else {
+            _this.isShowNextStep = true
+            _this.getDetail()
+          }
+          _this.spinning = false
+        } else {
+          _this.spinning = false
+        }
+      })
+    },
+    //  图片上传
+    changeImage (file) {
+      this.form.imageSet = file
+    },
+    // 视频上传
+    changeVideo (file) {
+      this.form.content = file
+    },
+    //  文本编辑器
+    editorChange (html, text) {
+      this.form.content = html
+    },
+    // 重置
+    resetSearchForm () {
+      if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
+        if (this.$refs.imageSet) {
+          this.$refs.imageSet.setFileList('')
+        }
+        if (this.$refs.videoSet) {
+          this.$refs.videoSet.setFileList('')
+        }
+      }
+      if (this.$refs.editor) {
+        this.$refs.editor.setHtml('')
+      }
+      this.form = {
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        publishFlag: '0', // 是否发布
+        linkType: '1',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        productRangeList: [], // 产品范围列表
+        promoRule: {
+          ruleType: 'ticket', // 基本规则类型
+          ruleName: '', // 券名称
+          ruleTitle: '', // 副标题
+          ruleBaseType: 'category', // 券生成方式
+          ruleExplain: '', // 使用说明
+          validType: undefined, // 券有效期类型
+          validStartDate: undefined, // 券生效时间
+          validEndDate: undefined, // 券失效时间
+          validDays: undefined, // 券有效期天数
+          dealerEditFlag: '0', // 加盟商编辑 1是 0否
+          publishFlag: '0', // 是否发布
+          range: '1'
+        } // 链接配置内容
+      }
+      this.isShowNextStep = false
+      this.isDisabled = false
+      if (this.$refs.ruleForm) {
+        this.$refs.ruleForm.resetFields()
+      }
+      if (this.$refs.ruleForm) {
+        this.$refs.ruleForm.resetFields()
+      }
+    },
+    // 获取产品范围数据
+    getTreeData () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    },
+    // 选择内容类型
+    changeContentType (e) {
+      if (e === 'LINK') {
+        this.form.linkType = '1'
+        this.form.contentLink = '/pagesB/promoDetail'
+        this.form.content = '/pagesB/promoDetail'
+      } else {
+        this.form.linkType = undefined
+        this.form.contentLink = ''
+        this.form.content = ''
+      }
+      this.form.contentType = e
+    },
+    // 填入link内容
+    handleLink (con) {
+      if (!con.target.value || con.target.value != '/pagesB/promoDetail') {
+        this.form.linkType = '2'
+      } else {
+        this.form.linkType = '1'
+      }
+      this.form.contentLink = con.target.value
+    },
+    // 选择货架促销填入默认值
+    handleLinkType (val) {
+      this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
+    },
+    // 添加产品
+    handleAddProduct () {
+      this.chooseTypeList = this.productRangeList
+      this.showProModal = true
+    },
+    // 批量添加
+    handleBatchAdd () {
+      if (!this.form.promoRule.ruleValue) {
+        this.$message.warning('请输入返券金额(需大于0)!')
+        return
+      }
+      this.$refs.chooseProductList.editMorePrice(this.form.promoRule.ruleValue)
+    },
+    // 添加产品成功
+    addProductSuccess (list) {
+      const productArr = list.map(item => {
+        return {
+          promoActiveSn: this.$route.params.sn,
+          promoRuleSn: this.form.promoRule.promoRuleSn,
+          productCode: item.code,
+          productSn: item.productSn,
+          ruleValue: this.form.promoRule.ruleValue,
+          price: item.terminalPrice
+        }
+      })
+      promoCreateBatch(productArr).then(res => {
+        if (res.status == 200) {
+          this.showProModal = false
+          // 获取产品列表 有分页
+          this.$refs.chooseProductList.pageInit()
+        }
+      })
+    },
+    // 选择产品范围
+    onChangeTree (e) {
+      deleteByProductType({ promoActiveSn: this.$route.params.sn, productTypeSnList: this.productRangeList || [] }).then(res => {
+        if (res.status == 200) {
+          this.$refs.chooseProductList.pageInit()
+        }
+      })
+      // 保存产品范围
+      const newArr = this.productRangeList.map(item => {
+        return {
+          promoActiveSn: this.$route.params.sn,
+          promoRuleSn: this.form.promoRule.promoRuleSn,
+          productTypeSn: item
+        }
+      })
+      saveBatchEntity({ list: newArr, promoActiveSn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          console.log('保存产品范围成功')
+        }
+      })
+    },
+    // 初始化
+    pageInit () {
+      this.pageType = this.$route.params.pageType
+      if (this.pageType === 'edit') {
+        this.getDetail()
+      }
+      console.log('加载产品范围')
+      this.$nextTick(() => {
+        this.getTreeData()
+      })
+    }
+  },
+  mounted () {
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+    }
+  },
+  activated () {
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+
+<style lang="less" scoped>
+.promotionEdit-wrap{
+    position: relative;
+    height: 100%;
+    box-sizing: border-box;
+    padding-bottom:51px;
+    .buyerBox{
+      border:1px solid #d9d9d9;
+      margin-top:10px;
+      border-radius:4px;
+      padding:4px 10px;
+      background:#f2f2f2;
+      max-height:130px;
+      overflow-y:scroll;
+      scrollbar-width: none;
+    }
+    >.ant-spin-nested-loading{
+      overflow-y: scroll;
+      height: 100%;
+    }
+    /deep/.ant-form-item{
+      margin-bottom:8px;
+    }
+    .promotionEdit-cont{
+      margin-bottom: 10px;
+    }
+    .upload{
+      width: 100%!important;
+    }
+    //  文本编辑器  工具栏样式换行
+    .promotionEdit-editor{
+      .w-e-toolbar{
+        flex-wrap: wrap;
+        z-index: 0;
+      }
+    }
+    //  商品图片描述
+    .upload-desc{
+      font-size: 12px;
+      color: #808695;
+    }
+    #promotionEdit-attachList{
+      height: auto;
+    }
+    .box{
+      border:1px solid #d9d9d9;
+      border-radius:4px;
+      padding:4px 11px;
+      color:rgba(0, 0, 0, 0.25);
+      cursor: not-allowed;
+      background:#fdfdfd;
+    }
+    .affix{
+      .ant-affix{
+        z-index: 101;
+        display:inline-block
+      }
+    }
+    /deep/.ant-radio-disabled + span{
+     color:#000!important;
+    }
+    .tip{
+      margin-left:10px;
+    }
+
+    .productInfo{
+      display:flex;
+      justify-content: space-between;
+    }
+    #setPromotion-productRange{
+      /deep/.ant-select-dropdown{
+        max-height:30vh !important;
+      }
+    }
+  }
+</style>

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

@@ -116,7 +116,7 @@
                 type="link"
                 class="button-warning"
                 :id="'promotion-edit-btn-'+record.id"
-                @click="promotionEdit(record)"
+                @click="handleRelease(record)"
                 v-if="(record.publishState=='UNPUBLISH' || record.publishState=='CLOSE') && $hasPermissions('B_promotionManagementEdit')">编辑</a-button>
               <a-button
                 size="small"
@@ -300,8 +300,8 @@ export default {
     },
     // 促销发布
     handleRelease (row, type) {
-      const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
-      this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
+      // const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
+      this.$router.push({ name: 'promotionalAddActivity', params: { sn: row.promoActiveSn, pageType: '' } })
     },
     // 打开详情
     handleDetail (row) {

+ 198 - 0
src/views/easyPassManagement/promotionalActivities/productTable.vue

@@ -0,0 +1,198 @@
+<template>
+  <div class="veTableCon">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :row-selection="{ columnWidth: 40 }"
+        @rowSelection="rowSelectionFun"
+        :defaultLoadData="false"
+        :style="{ maxHeight: 300+'px' }"
+        :scroll="{ y:230 }"
+        bordered>
+        <template slot="price" slot-scope="text,record">
+          <a-input-number
+            :min="0"
+            :step="1"
+            :precision="2"
+            :max="99999999"
+            @blur="editAllPrice(record,'price')"
+            placeholder="请输入"
+            :disabled="disabledVal"
+            v-model="record.price"
+            :id="'productTable-price'+record.id "
+            size="small"/>
+        </template>
+        <template slot="ruleValue" slot-scope="text,record">
+          <a-input-number
+            :min="0"
+            :step="1"
+            :precision="2"
+            :max="99999999"
+            :disabled="disabledVal"
+            @blur="editAllPrice(record,'ruleValue')"
+            placeholder="请输入"
+            v-model="record.ruleValue"
+            :id="'productTable-ruleValue'+record.id "
+            size="small"/>
+        </template>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text,record">
+          <a-button
+            size="small"
+            type="link"
+            class="button-error"
+            :id="'productTable-del-btn'+record.id "
+            :disabled="disabledVal"
+            @click="handleDel(record)"
+          >删除</a-button>
+        </template>
+      </s-table>
+    </a-spin>
+  </div>
+</template>
+<script>
+import { commonMixin } from '@/utils/mixin'
+// 组件
+import { STable } from '@/components'
+// 接口
+import { promoRuleProductList, deleteBatch, promoUpdateBatch } from '@/api/promoActive'
+export default {
+  name: 'ProductTable',
+  mixins: [commonMixin],
+  components: { STable },
+  props: {
+    promoActiveSn: {// 活动sn
+      type: String,
+      default: ''
+    },
+    disabledVal: {// 修改编辑时,禁用标志
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      spinning: false,
+      rowSelectionInfo: null, // 已选数据
+      queryParam: {}, // 查询条件
+      dataListQty: '0', // 表格数据总条数
+      columns: [// 表头
+        { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '原厂编码', dataIndex: 'origCode', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '买', scopedSlots: { customRender: 'price' }, width: '10%', align: 'right' },
+        { title: '赠', scopedSlots: { customRender: 'ruleValue' }, width: '10%', align: 'right' },
+        { title: '商城售价', dataIndex: 'terminalPrice', width: '10%', align: 'right', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        const params = Object.assign(parameter, this.queryParam)
+        params.promoActiveSn = this.promoActiveSn
+        return promoRuleProductList(params).then(res => {
+          let data
+          if (res.status == 200) {
+            data = res.data
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+              // 活动价初始值,活动价=参考终端价
+              if (!data.list[i].price) {
+                data.list[i].price = data.list[i].terminalPrice
+              } else {
+                data.list[i].price = data.list[i].price
+              }
+            }
+            this.disabled = false
+            this.dataListQty = res.data.count
+          }
+          this.spinning = false
+          return data
+        })
+      }
+    }
+  },
+  methods: {
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 批量修改价格
+    editAllPrice (row, typeName) {
+      let ajaxData = []
+      if (typeName != 'all') {
+        ajaxData.push({
+          id: row.id,
+          price: typeName === 'price' ? row.price : undefined,
+          ruleValue: typeName === 'ruleValue' ? row.ruleValue : undefined
+        })
+      } else {
+        ajaxData = row || []
+      }
+      promoUpdateBatch(ajaxData).then(res => {
+        if (res.status == 200) {
+          this.$refs.table.refresh(true)
+          this.$refs.table.clearSelected() // 清空表格选中项
+        }
+      })
+    },
+    // 修改产品活动价、返券金额
+    editMorePrice (numInfo) {
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows && this.rowSelectionInfo.selectedRows.length === 0)) {
+        this.$message.warning('请选择要修改的产品!')
+        return
+      }
+      const ajaxArr = this.rowSelectionInfo.selectedRows.map(item => { return { id: item.id, ruleValue: numInfo } })
+      this.editAllPrice(ajaxArr, 'all')
+    },
+    // 删除
+    handleDel (row) {
+      const _this = this
+      _this.spinning = true
+      deleteBatch([row.id]).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          _this.$refs.table.refresh()
+          _this.spinning = false
+        } else {
+          _this.spinning = false
+        }
+      })
+    },
+    // 获取表格总条数
+    getDataNum () {
+      return this.dataListQty
+    },
+    // 初始化
+    pageInit () {
+      this.$nextTick(() => {
+        this.$refs.table.refresh(true)
+      })
+    }
+  },
+  mounted () {
+    this.pageInit()
+  },
+  activated () {
+    this.pageInit()
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+
+<style>
+ /* form input[type='radio'], form input[type='checkbox'] {
+      width: 15px;
+      height: 14px;
+  } */
+</style>