Jelajahi Sumber

促销活动

chenrui 7 bulan lalu
induk
melakukan
7caabc6056

+ 442 - 0
src/views/easyPassManagement/promotionalActivities/addPromotionModal.vue

@@ -0,0 +1,442 @@
+<template>
+  <a-modal
+    centered
+    class="promotionAdd-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="itemSn?'编辑':'新增'"
+    v-model="isShow"
+    @cancel="isShow=false"
+    width="70%">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div class="promotionAdd-con">
+        <a-form-model
+          id="promotionAdd-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="promoName" :label-col="{span:6}" :wrapper-col="{span:14}">
+                <a-input
+                  id="promotionAdd-promoName"
+                  :maxLength="20"
+                  v-model.trim="form.promoName"
+                  placeholder="请输入促销名称(最多20个字符)"
+                  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:6}" :wrapper-col="{span:14}">
+                <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="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="排序" prop="sort">
+                <a-input-number
+                  style="width:37%"
+                  id="promotionAdd-sort"
+                  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="allDealerFlag">
+                <a-row :gutter="15">
+                  <a-col :md="10" :sm="24">
+                    <a-select
+                      style="width:90%;"
+                      id="promotionAdd-allDealerFlag"
+                      v-model="form.allDealerFlag"
+                      placeholder="请选择参与经销商"
+                      @change="changeDealerScope"
+                      allowClear>
+                      <a-select-option id="promotionAdd-dealerScope-all" value="1">全部经销商</a-select-option>
+                      <a-select-option id="promotionAdd-dealerScope-some" value="0">部分经销商</a-select-option>
+                    </a-select>
+                  </a-col>
+                  <a-col :md="3" :sm="24" v-show="form.allDealerFlag && form.allDealerFlag!='1' ">
+                    <a-button id="promotionAdd-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="promotionAdd-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"
+              class="imageUrl_box">
+              <a-form-model-item label="封面图片" prop="imageUrl">
+                <Upload
+                  class="upload"
+                  id="promotionAdd-imageUrl"
+                  v-model="form.imageUrl"
+                  ref="imageSet"
+                  :fileSize="10"
+                  :maxNums="1"
+                  @change="changeImage"
+                  listType="picture-card"></Upload>
+                <div class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</div>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="促销描述" prop="description">
+                <a-input
+                  v-model="form.description"
+                  type="textarea"
+                  id="promotionAdd-description"
+                  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="dealerOpenFlag">
+                <v-select
+                  v-model="form.dealerOpenFlag"
+                  id="promotionAdd-dealerOpenFlag"
+                  code="FLAG"
+                  showType="radio"
+                  allowClear></v-select>
+              </a-form-model-item>
+            </a-col>
+          </a-row>
+        </a-form-model>
+        <div class="btn-cont">
+          <a-button id="promotionAdd-close-btn" style="margin-right: 15px;" @click="isShow = false">取消</a-button>
+          <a-button
+            type="primary"
+            class="button-primary"
+            :disabled="spinning"
+            id="promotionAdd-submit-btn"
+            @click="handleSave()">保存</a-button>
+        </div>
+      </div>
+    </a-spin>
+    <!-- 选择经销商 -->
+    <chooseDealer ref="chooseDearler" :openModal="openDealerModal" :chooseInfo="chooseSnList" @close="closeDealerModal" @ok="addDealerOk"></chooseDealer>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import moment from 'moment'
+// 组件
+import { STable, VSelect, Upload } from '@/components'
+import chooseDealer from '@/views/easyPassManagement/homepageCarouselImg/chooseDealer'
+// 接口
+import { shopPromoDetail, saveShopPromo } from '@/api/shopPromo'
+
+export default {
+  name: 'AddPromotionModal',
+  mixins: [commonMixin],
+  components: { STable, VSelect, Upload, chooseDealer },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {// 活动sn
+      type: String,
+      default: ''
+    },
+    typeVal: {// 添加活动类型
+      type: String,
+      default: ''
+    },
+    chooseProductNum: {
+      type: String,
+      default: null
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      spinning: false, // 页面加载状态
+      // form表单label布局
+      formItemLayout: {
+        labelCol: { span: 3 },
+        wrapperCol: { span: 19 }
+      },
+      dateFormat: 'YYYY-MM-DD', // 促销时间显示格式
+      chooseDealerList: [], // 已选择的经销商列表
+      chooseSnList: [], // 已选经销商sn集合
+      openDealerModal: false, // 经销商弹窗
+      form: {
+        promoType: undefined, // 促销类型
+        promoName: '', // '促销名称'
+        time: [], // 促销时间
+        promoStartDate: undefined, // 促销时间-开始
+        promoEndDate: undefined, // 促销时间-结束
+        sort: undefined, // 排序
+        allDealerFlag: '1', // 全部经销商 1   部分经销商0'
+        imageUrl: undefined, // 促销封面图
+        description: '', // '促销描述'
+        dealerEditFlag: '0', // 加盟商编辑 0否 1是
+        dealerOpenFlag: '0' // 加盟商开关权限 0否 1是
+      },
+      // 表单验证规则
+      rules: {
+        promoName: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
+        time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
+        sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
+        allDealerFlag: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
+        imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
+        description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
+        dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }]
+      }
+    }
+  },
+  methods: {
+    //  封面图片上传
+    changeImage (file) {
+      this.form.imageUrl = file
+    },
+    // 参与经销商 change
+    changeDealerScope (val) {
+      const _this = this
+      if (_this.typeVal === 'edit') {
+        if (_this.chooseProductNum > 0) {
+          _this.$confirm({
+            title: '提示',
+            content: <div>变更【参与经销商】后将会【<span style="color:red">清空</span>】已选产品列表,确定变更吗?</div>,
+            centered: true,
+            onOk () {
+              _this.form.allDealerFlag = val
+              if (val == '1') {
+                _this.chooseDealerList = []
+              }
+            },
+            onCancel () {
+              _this.form.allDealerFlag = val == '1' ? '0' : '1'
+            }
+          })
+        }
+      }
+      _this.form.allDealerFlag = val
+      if (val == '1' || !val) {
+        _this.chooseDealerList = []
+      }
+    },
+    // 部分 打开选择经销商弹窗
+    handleDealerModal () {
+      this.chooseSnList = this.chooseDealerList.map(item => item.dealerSn)
+      this.openDealerModal = true
+    },
+    // 关闭 选择经销商弹窗
+    closeDealerModal () {
+      this.chooseSnList = []
+      this.openDealerModal = false
+    },
+    // 部分经销商  选择经销商成功
+    addDealerOk (list) {
+      const _this = this
+      if (_this.typeVal === 'edit') {
+        const hasEq = list.filter(item => !this.chooseDealerList.map(k => k.dealerSn).includes(item.dealerSn))
+        if (hasEq.length > 0 && _this.chooseProductNum > 0) {
+          _this.$confirm({
+            title: '提示',
+            content: <div>变更【参与经销商】后将会【<span style="color:red">清空</span>】已选产品列表,确定变更吗?</div>,
+            centered: true,
+            onOk () {
+              _this.chooseDealerList = list
+              _this.openDealerModal = false
+            },
+            onCancel () {
+              _this.$refs.chooseDearler.pageFlag = false
+              _this.$refs.chooseDearler.searchForm()
+            }
+          })
+        }
+      }
+      _this.chooseDealerList = list
+      _this.openDealerModal = false
+    },
+    // 部分经销商 删除
+    delBuyerName (row) {
+      const pos = this.chooseDealerList.findIndex(item => item.dealerSn == row.dealerSn)
+      if (pos >= 0) {
+        this.chooseDealerList.splice(pos, 1)
+      }
+    },
+    // 禁用日期时间
+    disabledDate (current) {
+      return current && current < moment().startOf('day')
+    },
+    // 促销时间  change
+    dateChange (date, dateStrings) {
+      if (dateStrings && dateStrings[0]) {
+        this.form.time = dateStrings
+        this.form.promoStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
+        this.form.promoEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
+      } else {
+        this.form.time = []
+      }
+    },
+    // 保存
+    handleSave () {
+      const _this = this
+      // 验证组件必填项
+      _this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.form.promoType = _this.typeVal
+          var formData = JSON.parse(JSON.stringify(_this.form))
+          // 部分经销商
+          if (formData.allDealerFlag == '0') {
+            if (_this.chooseDealerList && _this.chooseDealerList.length == 0) {
+              _this.$message.warning('请选择参与经销商!')
+              return
+            }
+            formData.dealerSnList = _this.chooseDealerList.map(con => con.dealerSn)
+          }
+          delete formData.time
+          delete formData.shopPromoDealerList
+          _this.spinning = true
+          saveShopPromo(formData).then(res => {
+            if (res.status == 200) {
+              _this.spinning = false
+              if (res.data.errorMsg && res.data.errorMsg.length > 0) {
+                this.$confirm({
+                  title: '提示',
+                  content: res.data.errorMsg.map((item, i) => { return <p>{i * 1 + 1}、{item}</p> }),
+                  centered: true,
+                  okText: '知道了',
+                  cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
+                  cancelButtonProps: {
+                    style: {
+                      display: 'none' // 通过设置样式隐藏取消按钮
+                    }
+                  },
+                  onOk () {
+                    console.log('知道了')
+                  }
+                })
+                return
+              }
+              _this.$message.success(res.message)
+              _this.$nextTick(() => {
+                _this.isShow = false
+                _this.$emit('ok')
+              })
+            } else {
+              _this.spinning = false
+            }
+          })
+        }
+      })
+    },
+    // 重置
+    resetSearchForm () {
+      this.form = {
+        promoType: undefined, // 促销类型
+        promoName: '', // '促销名称'
+        time: [], // 促销时间
+        promoStartDate: undefined, // 促销时间-开始
+        promoEndDate: undefined, // 促销时间-结束
+        sort: undefined, // 排序
+        allDealerFlag: '1', // 全部经销商 1   部分经销商0'
+        imageUrl: undefined, // 促销封面图
+        description: '', // '促销描述'
+        dealerEditFlag: '0', // 加盟商编辑 0否 1是
+        dealerOpenFlag: '0' // 加盟商开关权限 0否 1是
+      }
+      this.chooseDealerList = []
+      if (this.$refs.imageSet) {
+        this.$refs.imageSet.setFileList('')
+      }
+      if (this.$refs.ruleForm) {
+        this.$refs.ruleForm.resetFields()
+      }
+    },
+    //  详情
+    async getDetail () {
+      const _this = this
+      const res = await shopPromoDetail({ sn: _this.itemSn })
+      if (res.status == 200) {
+        if (res.data.promoStartDate && res.data.promoEndDate) {
+          const startTime = res.data.promoStartDate.split(' ')[0]
+          const endTime = res.data.promoEndDate.split(' ')[0]
+          res.data.time = [startTime, endTime]
+        }
+        if (res.data.imageUrl) {
+          _this.$refs.imageSet.setFileList(res.data.imageUrl)
+        }
+        _this.form = res.data
+        _this.isShowNextStep = true
+        if (_this.$route.params.pageType === 'edit') {
+          _this.pageType = res.data.promoType
+          _this.promotionName = res.data.promoName
+        }
+        // 部分经销商
+        if (_this.form.allDealerFlag == 0) {
+          _this.chooseDealerList = _this.form.shopPromoDealerList
+        }
+      }
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.resetSearchForm()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .promotionAdd-modal{
+    /deep/.imageUrl_box .ant-form-item-control{
+      line-height:0 !important;
+    }
+    .upload-desc{// 商品图片描述
+    padding-top:10px;
+      font-size: 12px;
+      color: #808695;
+    }
+    .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;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+
+</style>

+ 173 - 361
src/views/easyPassManagement/promotionalActivities/edit.vue

@@ -6,8 +6,42 @@
         <template slot="subTitle">
           <a id="promotionEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" />返回列表</a>
           <span v-if="$route.params.sn" style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">促销名称:{{ promotionName||'--' }}</span>
+          <a-button
+            type="link"
+            class="button-primary"
+            id="promotionEdit-edit-btn"
+            @click.stop="handleEdit">
+            <a-icon type="edit"/>编辑
+          </a-button>
+          <a-button type="link" size="small" class="button-default" @click="showDetail=!showDetail">
+            <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
+          </a-button>
         </template>
       </a-page-header>
+      <a-card size="small" :bordered="false" class="promotionEditInfo" v-show="showDetail">
+        <div slot="title">
+          <span>基础信息</span>
+        </div>
+        <div v-if="form">
+          <a-descriptions :column="{ xs: 2, sm: 3, md: 3}">
+            <a-descriptions-item label="促销名称">{{ form.promoName || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="促销时间">
+              {{ form.promoStartDate }}{{ form.promoStartDate?' ~ ':'' }}{{ form.promoEndDate }}
+            </a-descriptions-item>
+            <a-descriptions-item label="排序">{{ form.sort || '--' }}</a-descriptions-item>
+            <a-descriptions-item span="3" label="参与经销商" v-if="form.allDealerFlag=='1'">全部经销商</a-descriptions-item>
+            <a-descriptions-item span="3" label="参与经销商" v-else>
+              <span v-if="!form.shopPromoDealerList||(form.shopPromoDealerList&&form.shopPromoDealerList.length==0)">--</span>
+              <a-tag v-else v-for="con in form.shopPromoDealerList" :id="'promotionEdit-dealerSn'+con.dealerSn" :key="con.dealerSn">
+                {{ con.dealerName }}
+              </a-tag>
+            </a-descriptions-item>
+            <a-descriptions-item span="3" label="封面图片"><img :src="form.imageUrl" alt="图片走丢了" width="60" height="60" /></a-descriptions-item>
+            <a-descriptions-item span="3" label="促销描述">{{ form.description || '--' }}</a-descriptions-item>
+            <a-descriptions-item label="加盟商开关权限">{{ form.dealerOpenFlag=='0'?'否':'是' }}</a-descriptions-item>
+          </a-descriptions>
+        </div>
+      </a-card>
       <!-- 表单 -->
       <a-card :bordered="false" class="promotionEdit-cont">
         <a-form-model
@@ -19,107 +53,6 @@
           :wrapper-col="formItemLayout.wrapperCol"
         >
           <a-row>
-            <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
-              <a-form-model-item label="促销名称" prop="promoName" :label-col="{span:4}" :wrapper-col="{span:16}">
-                <a-input
-                  id="promotionEdit-promoName"
-                  :maxLength="20"
-                  v-model.trim="form.promoName"
-                  placeholder="请输入促销名称(最多20个字符)"
-                  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"
-                  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="allDealerFlag">
-                <a-row :gutter="15">
-                  <a-col :md="10" :sm="24">
-                    <a-select
-                      style="width:98%;"
-                      id="promotionList-allDealerFlag"
-                      v-model="form.allDealerFlag"
-                      placeholder="请选择参与经销商"
-                      @change="changeDealerScope"
-                      allowClear>
-                      <a-select-option id="promotionList-dealerScope-all" value="1">全部经销商</a-select-option>
-                      <a-select-option id="promotionList-dealerScope-some" value="0">部分经销商</a-select-option>
-                    </a-select>
-                  </a-col>
-                  <a-col :md="3" :sm="24" v-show="form.allDealerFlag && form.allDealerFlag!='1' ">
-                    <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="imageUrl">
-                <div style="display:flex;">
-                  <Upload
-                    class="upload"
-                    id="promotionEdit-imageUrl"
-                    v-model="form.imageUrl"
-                    ref="imageSet"
-                    :fileSize="10"
-                    :maxNums="1"
-                    @change="changeImage"
-                    listType="picture-card"></Upload>
-                  <span class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</span>
-                </div>
-              </a-form-model-item>
-            </a-col>
-            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <a-form-model-item label="促销描述" prop="description">
-                <a-input
-                  v-model="form.description"
-                  type="textarea"
-                  id="promotionEdit-description"
-                  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="dealerOpenFlag">
-                <v-select
-                  v-model="form.dealerOpenFlag"
-                  id="promotion-dealerOpenFlag"
-                  code="FLAG"
-                  showType="radio"
-                  allowClear></v-select>
-              </a-form-model-item>
-            </a-col>
             <!-- 买产品送代金券 -->
             <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
               <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
@@ -142,17 +75,6 @@
                     allowClear />
                 </a-form-model-item>
               </a-col>
-              <!-- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item label="生成方式" prop="validBaseType">
-                  <v-select
-                    style="width:40%;"
-                    v-model="form.validBaseType"
-                    id="promotionEdit-ruleBaseType"
-                    code="SHOP_PROMO_VALID_BASE_TYPE"
-                    placeholder="请选择生成方式"
-                    allowClear></v-select>
-                </a-form-model-item>
-              </a-col> -->
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
                 <a-form-model-item label="券有效期" prop="validType">
                   <v-select
@@ -185,7 +107,7 @@
                 </a-form-model-item>
               </a-col>
               <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item class="productName" label="券适用范围" prop="validScope">
+                <a-form-model-item class="productName" label="券适用范围">
                   全部产品
                 </a-form-model-item>
               </a-col>
@@ -200,99 +122,101 @@
                 </a-form-model-item>
               </a-col>
             </div>
-            <div v-if="isShowNextStep">
-              <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <a-form-model-item prop="productNum" :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
-                  <div class="productInfo flex-center">
-                    <div style="display:flex;">
-                      <!-- 买产品送产品 -->
-                      <div v-if="pageType==='BUY_PROD_GIVE_PROD'">
-                        同款产品买<a-input-number
-                          v-model="conditionValue"
-                          style="margin:0 5px;"
-                          :min="1"
-                          :step="1"
-                          :precision="0"
-                          :max="99999999"
-                          id="promotionEdit-conditionValue"
-                          size="small"/>赠
-                        <a-input-number
-                          v-model="resultValue"
-                          style="margin:0 5px;"
-                          :min="0"
-                          :step="1"
-                          :precision="0"
-                          :max="99999999"
-                          id="promotionEdit-resultValue"
-                          size="small"/>个(数量叠加)
-                        <a-button
-                          type="primary"
-                          id="promotionEdit-addSet-btn"
-                          class="button-primary"
-                          size="small"
-                          @click="handleBatchAdd">批量设置</a-button>
-                      </div>
-                      <!-- 特价产品 -->
-                      <div v-if="pageType==='PROMO_PROD'" style="width:80%;">
-                        <v-select
-                          v-model="form.discountType"
-                          ref="promoState"
-                          id="promotionList-discountType"
-                          code="SHOP_PROMO_DISCOUNT_TYPE"
-                          size="small"
-                          style="width:15%;margin-right:5px;"
-                          @change="handleDiscountType"
-                          placeholder="请选择"
-                          allowClear></v-select>
-                        <span v-show="form.discountType">{{ form.discountType==='STRAIGHT_DOWN'? '直降':'折扣' }}</span>
-                        <a-input-number
-                          v-model="resultValue"
-                          v-show="form.discountType"
-                          style="width:15%;margin:0 5px;"
-                          :min="0"
-                          :step="1"
-                          :precision="2"
-                          :max="99999999"
-                          id="promotionEdit-resultValue"
-                          size="small"/><span v-show="form.discountType">{{ form.discountType==='STRAIGHT_DOWN'? '元':'%' }}</span>
-                        <a-button
-                          type="primary"
-                          id="promotionEdit-addSet-btn"
-                          class="button-primary"
-                          size="small"
-                          @click="handleBatchAdd">批量设置</a-button>
-                      </div>
-                      <!-- 买产品返代金券 -->
-                      <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
-                        返券金额
-                        <a-input-number
-                          v-model="resultValue"
-                          style="margin:0 5px;"
-                          :min="0"
-                          :step="1"
-                          :precision="2"
-                          :max="99999999"
-                          id="promotionEdit-resultValue"
-                          size="small"/>元
-                        <a-button
-                          type="primary"
-                          id="promotionEdit-addSet-btn"
-                          class="button-primary"
-                          size="small"
-                          @click="handleBatchAdd">批量设置</a-button>
-                      </div>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item prop="productNum" :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
+                <div class="productInfo flex-center">
+                  <div style="width:80%;">
+                    <!-- 买产品送产品 -->
+                    <div v-if="pageType==='BUY_PROD_GIVE_PROD'">
+                      同款产品买<a-input-number
+                        v-model="conditionValue"
+                        style="margin:0 5px;"
+                        :min="1"
+                        :step="1"
+                        :precision="0"
+                        :max="99999999"
+                        id="promotionEdit-conditionValue"
+                        size="small"/>赠
+                      <a-input-number
+                        v-model="resultValue"
+                        style="margin:0 5px;"
+                        :min="0"
+                        :step="1"
+                        :precision="0"
+                        :max="99999999"
+                        id="promotionEdit-resultValue"
+                        size="small"/>个(数量叠加)
+                      <a-button
+                        type="primary"
+                        id="promotionEdit-addSet-btn"
+                        class="button-primary"
+                        size="small"
+                        @click="handleBatchAdd">批量设置</a-button>
+                      <span>已选 {{ porductChooseTotal || 0 }} 项</span>
+                    </div>
+                    <!-- 特价产品 -->
+                    <div v-if="pageType==='PROMO_PROD'">
+                      <v-select
+                        v-model="form.discountType"
+                        ref="promoState"
+                        id="promotionList-discountType"
+                        code="SHOP_PROMO_DISCOUNT_TYPE"
+                        size="small"
+                        style="width:20%;margin-right:5px;"
+                        @change="handleDiscountType"
+                        placeholder="请选择"
+                        allowClear></v-select>
+                      <span v-if="form.discountType">{{ form.discountType==='STRAIGHT_DOWN'? '直降':'折扣' }}</span>
+                      <a-input-number
+                        v-model="resultValue"
+                        v-if="form.discountType"
+                        style="width:20%;margin:0 5px;"
+                        :min="0"
+                        :step="1"
+                        :precision="2"
+                        :max="99999999"
+                        id="promotionEdit-resultValue"
+                        size="small"/><span v-show="form.discountType">{{ form.discountType==='STRAIGHT_DOWN'? '元':'%' }}</span>
+                      <a-button
+                        type="primary"
+                        id="promotionEdit-addSet-btn"
+                        class="button-primary"
+                        size="small"
+                        @click="handleBatchAdd">批量设置</a-button>
+                      <span>已选 {{ porductChooseTotal || 0 }} 项</span>
+                    </div>
+                    <!-- 买产品返代金券 -->
+                    <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
+                      返券金额
+                      <a-input-number
+                        v-model="resultValue"
+                        style="margin:0 5px;"
+                        :min="0"
+                        :step="1"
+                        :precision="2"
+                        :max="99999999"
+                        id="promotionEdit-resultValue"
+                        size="small"/>元
+                      <a-button
+                        type="primary"
+                        id="promotionEdit-addSet-btn"
+                        class="button-primary"
+                        size="small"
+                        @click="handleBatchAdd">批量设置</a-button>
                       <span>已选 {{ porductChooseTotal || 0 }} 项</span>
                     </div>
+                  </div>
+                  <div style="width:20%;text-align:right;" >
                     <a-button type="primary" id="promotionEdit-add-btn" @click="handleChooseProduct" 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" @changeSel="v=>porductChooseTotal=v" :promoActiveSn="form.promoSn" :discountType="form.discountType" :activeType="pageType"></productTable>
                 </div>
-              </a-col>
-            </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" @changeSel="v=>porductChooseTotal=v" :promoActiveSn="form.promoSn" :discountType="form.discountType" :activeType="pageType"></productTable>
+              </div>
+            </a-col>
           </a-row>
         </a-form-model>
       </a-card>
@@ -304,16 +228,8 @@
         :disabled="spinning"
         id="productInfoEdit-submit-btn"
         size="large"
-        @click="handleSave('all')"
-        v-if="isShowNextStep"
+        @click="handleSaveAll"
         style="padding: 0 60px;">保存</a-button>
-      <a-button
-        type="primary"
-        class="button-primary"
-        style="padding: 0 30px;"
-        size="large"
-        v-if="!isShowNextStep"
-        @click="handleSave('part')">保存后设置产品</a-button>
     </div>
     <!-- 添加产品 -->
     <chooseProduct
@@ -321,8 +237,15 @@
       :openModal="showProModal"
       @ok="addProductSuccess"
       @close="closeProductModal"></chooseProduct>
-    <!-- 选择经销商 -->
-    <chooseDealer ref="chooseDearler" :openModal="openDealerModal" :chooseInfo="chooseSnList" @close="closeDealerModal" @ok="addDealerOk"></chooseDealer>
+    <!--编辑  促销活动  基础信息    -->
+    <add-promotion-modal
+      ref="promotionAddModal"
+      :openModal="openAddModal"
+      typeVal="edit"
+      :chooseProductNum="form.productNum"
+      :itemSn="$route.params.sn"
+      @close="openAddModal=false"
+      @ok="promotionAddOk" ></add-promotion-modal>
   </div>
 </template>
 
@@ -332,15 +255,15 @@ import moment from 'moment'
 // 组件
 import { VSelect, Upload } from '@/components'
 import Editor from '@/components/WEeditor'
-import chooseDealer from '@/views/easyPassManagement/homepageCarouselImg/chooseDealer'
 import productTable from './productTable'
 import chooseProduct from './chooseProductsModal.vue'
+import addPromotionModal from './addPromotionModal'
 // 接口
 import { saveChooseProduct, saveShopPromo, shopPromoDetail } from '@/api/shopPromo'
 export default {
   name: 'ProductBrandEditModal',
   mixins: [commonMixin],
-  components: { VSelect, Upload, Editor, productTable, chooseDealer, chooseProduct },
+  components: { VSelect, Upload, Editor, productTable, chooseProduct, addPromotionModal },
   data () {
     return {
       spinning: false,
@@ -349,10 +272,11 @@ export default {
         labelCol: { span: 2 },
         wrapperCol: { span: 20 }
       },
-      productRangeList: [], // 产品范围列表
       dateFormat: 'YYYY-MM-DD', // 促销时间显示格式
       openDealerModal: false, // 打开选择经销商弹窗
       pageType: undefined, // 促销类型
+      showDetail: true, // 是否显示基础信息
+      openAddModal: false, // 基础信息编辑弹窗
       // 链接配置内容
       form: {
         promoType: undefined, // 促销类型
@@ -381,119 +305,37 @@ export default {
       },
       conditionValue: undefined, // 买产品送产品 买
       resultValue: undefined, // 买产品送产品  赠  返券金额
-      chooseDealerList: [], // 所选经销商数据
-      chooseSnList: [], // 已选经销商sn
       porductChooseTotal: 0, // 已选产品总数
       timeLimit: [], // 有效期
       promotionName: '', // 促销名称
       showProModal: false, // 打开产品弹窗
-      isShowNextStep: false, // 是否显示下一步 并提交一半配置产品
       // 表单验证规则
       rules: {
-        promoName: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
-        time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
-        sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
-        allDealerFlag: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
-        imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
-        description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
-        dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }],
         rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }],
         validName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
         validBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
         validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
-        validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }],
+        // validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }],
         productNum: [{ required: true, message: '选择产品不能为空', trigger: 'blur' }]
       }
     }
   },
   methods: {
-    // 部分经销商 删除
-    delBuyerName (row) {
-      const pos = this.chooseDealerList.findIndex(item => item.dealerSn == row.dealerSn)
-      if (pos >= 0) {
-        this.chooseDealerList.splice(pos, 1)
-      }
-    },
-    // 参与经销商 change
-    changeDealerScope (val) {
-      const _this = this
-      if (_this.$refs.chooseProductList) {
-        const hasProduct = _this.$refs.chooseProductList.getChooseProductNum()
-        if (hasProduct > 0) {
-          _this.$confirm({
-            title: '提示',
-            content: <div>变更【参与经销商】后将会【<span style="color:red">清空</span>】已选产品列表,确定变更吗?</div>,
-            centered: true,
-            onOk () {
-              _this.form.allDealerFlag = val
-              if (val == '1') {
-                _this.chooseDealerList = []
-              }
-              // 情况产品列表
-              _this.$refs.chooseProductList.clearTable()
-            },
-            onCancel () {
-              _this.form.allDealerFlag = val == '1' ? '0' : '1'
-            }
-          })
-        }
-      }
-      _this.form.allDealerFlag = val
-      if (val == '1' || !val) {
-        _this.chooseDealerList = []
-      }
-    },
-    // 部分 打开选择经销商弹窗
-    handleDealerModal () {
-      this.chooseSnList = this.chooseDealerList.map(item => item.dealerSn)
-      this.openDealerModal = true
-    },
-    // 关闭 选择经销商弹窗
-    closeDealerModal () {
-      this.chooseSnList = []
-      this.openDealerModal = false
+    // 编辑
+    handleEdit () {
+      this.openAddModal = true
+      this.form.productNum = this.$refs.chooseProductList.getChooseProductNum()
+      this.$refs.promotionAddModal.getDetail()
     },
-    // 部分经销商  选择经销商成功
-    addDealerOk (list) {
+    promotionAddOk () {
       const _this = this
-      if (_this.$refs.chooseProductList) {
-        const hasProduct = _this.$refs.chooseProductList.getChooseProductNum()
-        const hasEq = list.filter(item => !this.chooseDealerList.map(k => k.dealerSn).includes(item.dealerSn))
-        if (hasEq.length > 0 && hasProduct > 0) {
-          _this.$confirm({
-            title: '提示',
-            content: <div>变更【参与经销商】后将会【<span style="color:red">清空</span>】已选产品列表,确定变更吗?</div>,
-            centered: true,
-            onOk () {
-              _this.chooseDealerList = list
-              _this.openDealerModal = false
-              // 清空产品列表
-              _this.$refs.chooseProductList.clearTable()
-            },
-            onCancel () {
-              _this.$refs.chooseDearler.pageFlag = false
-              _this.$refs.chooseDearler.searchForm()
-            }
-          })
-        }
-      }
-      _this.chooseDealerList = list
-      _this.openDealerModal = false
+      // 情况产品列表
+      _this.$refs.chooseProductList.clearTable()
     },
     // 禁用日期时间
     disabledDate (current) {
       return current && current < moment().startOf('day')
     },
-    // 促销时间  change
-    dateChange (date, dateStrings) {
-      if (dateStrings && dateStrings[0]) {
-        this.form.time = dateStrings
-        this.form.promoStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
-        this.form.promoEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
-      } else {
-        this.form.time = []
-      }
-    },
     // 有效期
     dateLimitChange (date, dateStrings) {
       if (dateStrings && dateStrings[0]) {
@@ -571,25 +413,12 @@ export default {
       const _this = this
       const res = await shopPromoDetail(ajaxData)
       if (res.status == 200) {
-        if (res.data.promoStartDate && res.data.promoEndDate) {
-          const startTime = res.data.promoStartDate.split(' ')[0]
-          const endTime = res.data.promoEndDate.split(' ')[0]
-          res.data.time = [startTime, endTime]
-        }
-        if (res.data.imageUrl) {
-          _this.$refs.imageSet.setFileList(res.data.imageUrl)
-        }
         _this.form = res.data
         _this.form.productNum = 0
-        _this.isShowNextStep = true
         if (_this.$route.params.pageType === 'edit') {
           _this.pageType = res.data.promoType
           _this.promotionName = res.data.promoName
         }
-        // 部分经销商
-        if (_this.form.allDealerFlag == 0) {
-          _this.chooseDealerList = _this.form.shopPromoDealerList
-        }
         _this.$nextTick(() => {
           _this.$refs.chooseProductList.pageInit()
         })
@@ -607,12 +436,12 @@ export default {
       }
     },
     //  确定保存  验证必填
-    handleSave (type) {
+    handleSaveAll () {
       const _this = this
       // 验证组件必填项
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          _this.savePartInfo(type)
+          _this.savePartInfo()
         }
       })
     },
@@ -621,14 +450,6 @@ export default {
       const _this = this
       _this.form.promoType = _this.pageType
       var formData = JSON.parse(JSON.stringify(_this.form))
-      // 部分经销商
-      if (formData.allDealerFlag == '0') {
-        if (_this.chooseDealerList && _this.chooseDealerList.length == 0) {
-          _this.$message.warning('请选择参与经销商!')
-          return
-        }
-        formData.dealerSnList = _this.chooseDealerList.map(con => con.dealerSn)
-      }
       if (formData.promoType === 'BUY_PROD_GIVE_VALID') {
         if (formData.validType === 'FIXED') {
           if (!formData.validStartDate || !formData.validEndDate) {
@@ -642,16 +463,12 @@ export default {
           }
         }
       }
-      if (type === 'all') {
-        formData.productNum = _this.$refs.chooseProductList.getChooseProductNum()
-        if (formData.productNum && formData.productNum == 0) {
-          _this.$message.warning('请先选择产品!')
-          return
-        }
-        delete formData.productNum
+      formData.productNum = _this.$refs.chooseProductList.getChooseProductNum()
+      if (formData.productNum && formData.productNum == 0) {
+        _this.$message.warning('请先选择产品!')
+        return
       }
-      delete formData.time
-      delete formData.shopPromoDealerList
+      delete formData.productNum
       _this.spinning = true
       saveShopPromo(formData).then(res => {
         if (res.status == 200) {
@@ -675,24 +492,15 @@ export default {
             return
           }
           _this.$message.success(res.message)
-          if (type === 'all') {
-            _this.$nextTick(() => {
-              _this.handleBack()
-              _this.resetSearchForm()
-            })
-          } else {
-            _this.isShowNextStep = true
-            _this.getDetail({ sn: res.data.shopPromo.promoSn })
-          }
+          _this.$nextTick(() => {
+            _this.handleBack()
+            _this.resetSearchForm()
+          })
         } else {
           _this.spinning = false
         }
       })
     },
-    //  封面图片上传
-    changeImage (file) {
-      this.form.imageUrl = file
-    },
     // 重置
     resetSearchForm () {
       this.form = {
@@ -720,10 +528,6 @@ export default {
         validInfo: '', // 使用说明
         productNum: 0
       }
-      if (this.$refs.imageSet) {
-        this.$refs.imageSet.setFileList('')
-      }
-      this.isShowNextStep = false
       if (this.$refs.ruleForm) {
         this.$refs.ruleForm.resetFields()
       }
@@ -739,11 +543,7 @@ export default {
     // 初始化
     pageInit () {
       this.form.discountType = ''
-      if (this.$route.params.pageType === 'edit') {
-        this.getDetail({ sn: this.$route.params.sn })
-      } else {
-        this.pageType = this.$route.params.pageType
-      }
+      this.getDetail({ sn: this.$route.params.sn })
     }
   },
   mounted () {
@@ -773,6 +573,9 @@ export default {
     height: 100%;
     box-sizing: border-box;
     padding-bottom:51px;
+    .promotionEditInfo{
+      margin-bottom:10px;
+    }
     .buyerBox{
       border:1px solid #d9d9d9;
       margin-top:10px;
@@ -831,13 +634,22 @@ export default {
     }
 
     .productInfo{
+      width:100%;
       display:flex;
-      justify-content: space-between;
     }
     #setPromotion-productRange{
       /deep/.ant-select-dropdown{
         max-height:30vh !important;
       }
     }
+    /deep/.productName .ant-form-item-label::before{
+          display: inline-block;
+          margin-right: 4px;
+          color: #f5222d;
+          font-size: 12px;
+          font-family: SimSun, sans-serif;
+          line-height: 1;
+          content: '*';
+    }
   }
 </style>

+ 12 - 2
src/views/easyPassManagement/promotionalActivities/list.vue

@@ -140,6 +140,8 @@
           </template>
         </s-table>
       </a-spin>
+      <!-- 新增促销活动 -->
+      <add-promotion-modal :openModal="openAddModal" :typeVal="addPromotionType" @close="closeAddModal" @ok="$refs.table.refresh()" ></add-promotion-modal>
       <!-- 参与经销商 -->
       <lookUp-customers-modal ref="lookUpCustomers" :openModal="openCustomerModal" @close="openCustomerModal = false"></lookUp-customers-modal>
       <!-- 详情 -->
@@ -193,6 +195,7 @@ import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
 import lookUpCustomersModal from './lookUpCustomersModal'
 import detailModal from './detailModal'
+import addPromotionModal from './addPromotionModal'
 // 接口
 import { shopPromoActiveList, shopPromoDel, shopPromoRelease, shopPromoDiscard, updateShopBanner } from '@/api/shopPromo'
 import { updateSetShopBanner } from '@/api/shopBanner'
@@ -200,7 +203,7 @@ import { updateSetShopBanner } from '@/api/shopBanner'
 export default {
   name: 'PromotionalActivitiesList',
   mixins: [commonMixin],
-  components: { STable, VSelect, rangeDate, lookUpCustomersModal, detailModal },
+  components: { STable, VSelect, rangeDate, lookUpCustomersModal, detailModal, addPromotionModal },
   data () {
     return {
       spinning: false,
@@ -210,6 +213,8 @@ export default {
       openDetailModal: false, // 打开详情弹窗
       createDate: [], //  创建时间
       openSetImgModal: false, // 设置首页轮播图弹窗
+      openAddModal: false, // 新增促销活动
+      addPromotionType: null, // 新增促销活动类型   BUY_PROD_GIVE_PROD买产品送产品     BUY_PROD_GIVE_VALID买产品返代金券    PROMO_PROD特价产品
       // 查询参数
       queryParam: {
         beginDate: undefined, // 促销开始时间
@@ -268,12 +273,17 @@ export default {
         this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList ? row.dealerSnList : undefined, promoSn: row.promoSn })
       })
     },
+    //
+    closeAddModal () {
+      this.openAddModal = false
+    },
     // 新增  编辑
     handleEdit (type, row) {
       if (type === 'edit') {
         this.$router.push({ name: 'promotionalEditActivity', params: { pageType: type, sn: row.promoSn } })
       } else {
-        this.$router.push({ name: 'promotionalAddActivity', params: { pageType: type } })
+        this.addPromotionType = type
+        this.openAddModal = true
       }
     },
     // 删除促销活动