Browse Source

经销商促销

chenrui 10 months ago
parent
commit
f3b973c083

+ 70 - 0
src/api/promoActive.js

@@ -82,3 +82,73 @@ export const queryWaitingProductPage = (params) => {
     }
   })
 }
+
+// 修理厂促销   保存产品范围
+export const saveBatchEntity = (params) => {
+  return axios({
+    url: '/promoRuleProductRange/saveBatchEntity',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('保存产品范围')
+    }
+  })
+}
+// 批量创建产品
+export const promoCreateBatch = (params) => {
+  return axios({
+    url: '/promoRuleProduct/createBatch',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('批量创建产品')
+    }
+  })
+}
+export const promoUpdateBatch = (params) => {
+  return axios({
+    url: '/promoRuleProduct/updateBatch',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('批量创建产品')
+    }
+  })
+}
+// 获取已选产品列表数据  有分页
+export const promoRuleProductList = (params) => {
+  const url = `/promoRuleProduct/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 批量删除
+export const deleteBatch = (params) => {
+  return axios({
+    url: '/promoRuleProduct/deleteBatch',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('批量删除')
+    }
+  })
+}
+// 删除产品范围  数据变化 promoActiveSn  productTypeSnList
+export const deleteByProductType = (params) => {
+  return axios({
+    url: '/promoRuleProduct/deleteByProductType',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('批量删除')
+    }
+  })
+}

+ 296 - 0
src/views/promotionRulesManagement/promotionManagement/detailModal.vue

@@ -0,0 +1,296 @@
+<template>
+  <a-modal
+    centered
+    class="promotion-basicInfo-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="详情"
+    v-model="isShow"
+    @cancel="isShow=false"
+    width="80%">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="promotion-basicInfo-form"
+        ref="ruleForm"
+        :model="form"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol" >
+        <a-form-model-item label="标题" v-if="form.description">
+          {{ form.title }}
+        </a-form-model-item>
+        <a-form-model-item label="排序" v-if="form.gateFlag">
+          {{ form.sort }}
+        </a-form-model-item>
+        <!-- 买产品送产品 -->
+        <a-form-model-item label="封面图片" prop="regularSameFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_PROD'">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <!-- 买产品送采购额 -->
+        <a-form-model-item label="内容类型" prop="regularSameFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_MONEY'">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <!-- 特价产品 -->
+        <a-form-model-item label="基本规则" prop="regularSameFlag" v-if="form.promotionRuleType ==='PROMO_PROD'">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <a-form-model-item label="券名称" prop="accrualFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_PROD'&&form.accrualFlag">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <a-form-model-item label="券副标题" prop="regularPromotionSameFlag">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <a-form-model-item label="生成方式" prop="regularPromotionSameFlag">
+          {{ form.regularPromotionSameFlag }}
+        </a-form-model-item>
+        <a-form-model-item label="券有效期" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+        <a-form-model-item label="券适用范围" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+        <a-form-model-item label="使用说明" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+        <a-form-model-item label="产品范围" prop="scopeFlag" >
+          <a-tree-select
+            v-model="form.productRangeList"
+            :maxTagCount="12"
+            :tree-data="productTypeList"
+            tree-checkable
+            :disabled="true"
+            :getPopupContainer="triggerNode => triggerNode.parentNode"
+            :replaceFields="{children:'children',title: 'productTypeName',key: 'productTypeSn',value: 'productTypeSn'}"
+            placeholder="请选择产品范围" />
+        </a-form-model-item>
+        <a-form-model-item label="加盟商编辑" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+        <a-form-model-item label="是否发布" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+        <a-form-model-item label="返券产品" prop="scopeFlag" >
+          {{ form.scopeFlag==='1'?'全部产品':'部分产品' }}
+        </a-form-model-item>
+      </a-form-model>
+      <a-card size="small" :bordered="false" class="pages-wrap">
+        <div>
+          <s-table
+            class="sTable"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.id"
+            :columns="columns"
+            :data="loadData"
+            :row-selection="{ columnWidth: 40 }"
+            @rowSelection="rowSelectionFun"
+            :defaultLoadData="false"
+            bordered>
+          </s-table>
+        </div>
+      </a-card>
+      <div class="btn-cont">
+        <a-button id="promotion-basicInfo-modal-back" @click="isShow = false">关闭</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { promoActiveDetail, promoRuleProductList } from '@/api/promoActive'
+import { productTypeQuery } from '@/api/productType'
+import { STable } from '@/components'
+export default {
+  name: 'DetailModal',
+  mixins: [commonMixin],
+  components: { STable },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      spinning: false,
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 20 }
+      },
+      productTypeList: [],
+      form: {
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: '1', // 参数配置 1勾选配置  0不能配置
+        publishFlag: '0',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        promoRule: {},
+        publishState: 'UNPUBLISH'
+      },
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '原厂编码', dataIndex: 'origCode', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '活动价', dataIndex: 'price', width: '12%', align: 'center', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
+        { title: '返券金额', dataIndex: 'ruleValue', width: '12%', align: 'center', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
+        { title: '参考终端价', dataIndex: 'terminalPrice', width: '12%', align: 'center', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        const params = Object.assign(parameter, this.queryParam)
+        console.log('11111111111111', this.promoActiveSn)
+        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
+            }
+            this.disabled = false
+          }
+          this.spinning = false
+          return data
+        })
+      }
+    }
+  },
+  methods: {
+    // 重置
+    resetSearchForm () {
+      this.form = {
+        promoActiveSn: undefined, // 促销活动sn
+        title: '', // 标题
+        imageSet: '', // 图片
+        contentType: 'IMAGE_CONTENT', // 内容类型
+        content: '', // 内容
+        contentLink: '', // 链接内容
+        sort: undefined, // 排序
+        ruleEnableFlag: '1', // 参数配置 1勾选配置  0不能配置
+        publishFlag: '0',
+        dealerEditFlag: '0', // 加盟商编辑 1是 0否
+        promoRule: {},
+        publishState: 'UNPUBLISH'
+      }
+    },
+    // 获取列表详情
+    getDetail () {
+      promoActiveDetail({ sn: this.itemSn }).then(res => {
+        if (res.status == 200) {
+          this.form = res.data
+          if (res.data.contentType === 'LINK') {
+            console.log('加载产品范围')
+            this.$nextTick(() => {
+              this.getTreeData()
+            })
+          }
+        }
+      })
+    },
+    // 获取产品范围数据
+    getTreeData () {
+      productTypeQuery({}).then(res => {
+        if (res.status == 200) {
+          this.productTypeList = res.data
+        } else {
+          this.productTypeList = []
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.resetSearchForm()
+      } else {
+        this.getDetail()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .promotion-basicInfo-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .promotion-basicInfo-con{
+      margin-top:10px;
+    }
+    .ant-form-item{
+      margin-bottom:0 !important;
+    }
+    .buyerBox{
+      border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+    //处理滚动条不显示
+    .tabBox{
+       max-height:100px;
+       overflow-y:scroll;
+    }
+   .tabBox::-webkit-scrollbar {
+       width: 0px;
+    }
+    .tabBox::-webkit-scrollbar-track {
+      background: transparent;
+    }
+
+    .tabBox::-webkit-scrollbar-thumb {
+      background: transparent;
+    }
+
+    .tabBox::-webkit-scrollbar-button {
+      display: none;
+    }
+    // 设置input  禁用颜色
+    .ant-form-item-control .ant-input[disabled]{
+      color:#333333;
+      background:#ffffff;
+    }
+   .ant-radio-button-wrapper-disabled{
+     color:#333333;
+     padding:0 16px;
+   }
+   .ant-radio-button-wrapper-disabled.ant-radio-button-wrapper-checked{
+   background-color: #ed1c24 !important;
+   color:#ffffff;
+    padding:0 16px;
+   }
+   /deep/.ant-select-disabled .ant-select-selection, .ant-cascader-picker-disabled{
+      color:#333 !important;
+      background:#fff;
+   }
+   .flex{
+     display:flex;
+     align-items:center;
+     justify-content:space-between;
+   }
+  }
+
+</style>

+ 415 - 162
src/views/promotionRulesManagement/promotionManagement/edit.vue

@@ -1,25 +1,26 @@
 <template>
-  <div class="promotionEdit-wrap" :style="{paddingBottom: pageType!='see'?'51px':'10px'}">
+  <div class="promotionEdit-wrap" :style="{paddingBottom: (form.contentType ==='LINK'&&form.linkType==='1')?'10px':'51px'}">
     <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-form-model
-        id="promotionEdit-form"
-        ref="ruleForm"
-        :model="form"
-        :rules="rules"
-        :label-col="formItemLayout.labelCol"
-        :wrapper-col="formItemLayout.wrapperCol"
-      >
-        <a-card :bordered="false" class="promotionEdit-cont">
+      <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="24" :sm="24" :md="12" :lg="12" :xl="12">
-              <a-form-model-item label="标题" prop="title">
+              <a-form-model-item label="标题" prop="title" :label-col="{span:4}" :wrapper-col="{span:16}">
                 <a-input
                   id="promotionEdit-title"
                   :maxLength="30"
@@ -30,7 +31,7 @@
               </a-form-model-item>
             </a-col>
             <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
-              <a-form-model-item label="排序" prop="sort">
+              <a-form-model-item label="排序" prop="sort" :label-col="{span:4}" :wrapper-col="{span:16}">
                 <a-input-number
                   style="width:100%"
                   id="promotionEdit-sort"
@@ -43,7 +44,7 @@
               </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" :label-col="{span:2}" :wrapper-col="{span:20}">
+              <a-form-model-item label="封面图片" prop="imageSet">
                 <Upload
                   v-if="pageType==='add'||(pageType==='edit'&&!isDisabled)"
                   class="upload"
@@ -68,10 +69,9 @@
               </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" :label-col="{span:2}" :wrapper-col="{span:18}">
+              <a-form-model-item label="内容类型" prop="contentType">
                 <v-select
                   v-model="form.contentType"
-                  ref="saleStatus"
                   id="promotion-saleStatus"
                   code="PROMO_CONTENT_TYPE"
                   showType="radio"
@@ -81,7 +81,7 @@
               </a-form-model-item>
             </a-col>
             <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'">
                 <editor
                   v-show="pageType === 'add'||(pageType === 'edit'&&!isDisabled)"
                   id="promotionEdit-editor"
@@ -89,9 +89,9 @@
                   class="promotionEdit-editor"
                   @on-change="editorChange"
                   :cache="false"></editor>
-                <div v-if="(pageType === 'edit'||pageType === 'see')&&isDisabled" class="box" v-html="form.content"></div>
+                <div v-if="(pageType === 'edit')&&isDisabled" class="box" v-html="form.content"></div>
               </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'">
                 <Upload
                   v-if="pageType==='add'||(pageType==='edit'&&!isDisabled)"
                   class="upload"
@@ -116,10 +116,10 @@
                 </div>
                 <span class="upload-desc">说明:文件最大100M;视频:mp4.avi.flv</span>
               </a-form-model-item>
-              <a-form-model-item label="跳转链接" prop="contentLink" v-if="form.contentType =='LINK'" :label-col="{span:2}" :wrapper-col="{span:20}">
+              <a-form-model-item label="跳转链接" prop="contentLink" v-if="form.contentType =='LINK'">
                 <a-input
                   style="width:50%;"
-                  :disabled="isDisabled"
+                  :disabled="form.linkType==='1'||(pageType==='edit'&&isDisabled)"
                   id="promotionEdit-title"
                   :maxLength="100"
                   v-model.trim="form.contentLink"
@@ -140,35 +140,165 @@
                     其他
                   </a-select-option>
                 </a-select>
+                <span class="tip upload-desc">
+                  选择【货架促销】,促销内容会同步显示在促销模块内
+                </span>
               </a-form-model-item>
             </a-col>
           </a-row>
-          <!-- 参数配置 -->
-          <a-row style="width:83%;margin:0 auto 24px;" v-if="form.contentType =='LINK'&&form.linkType!='2'">
+        </a-form-model>
+        <a-form-model
+          id="setPromotion-form"
+          ref="sellRuleForm"
+          :model="sellForm"
+          :rules="sellRules"
+          class="setPromotion-form"
+          :label-col="sellFormItemLayout.labelCol"
+          :wrapper-col="sellFormItemLayout.wrapperCol">
+          <a-row v-if="form.contentType ==='LINK'&&form.linkType==='1'">
             <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <a-checkbox :disabled="true" v-model="isShowParams">参数配置</a-checkbox>
+              <a-form-model-item label="基本规则" prop="ruleType">
+                <v-select
+                  style="width:40%;"
+                  v-model="sellForm.ruleType"
+                  placeholder="请选择基本规则"
+                  id="promotionEdit-ruleType"
+                  code="PROMO_ACTIVE_RULE_TYPE"
+                  :disabled="isDisabled"
+                  allowClear></v-select>
+              </a-form-model-item>
             </a-col>
-            <a-col
-              :xs="24"
-              :sm="24"
-              :md="24"
-              :lg="24"
-              :xl="24"
-              v-show="isShowParams">
-              <!-- 参数配置内容 -->
-              <setPromotion ref="setContent" style="margin-top:20px;" :pageType="pageType" :disabledVal="isDisabled" @addProduct="insterProduct"></setPromotion>
+            <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
+              <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="ruleName">
+                <a-input
+                  :disabled="isDisabled"
+                  id="promotionEdit-ruleName"
+                  :maxLength="20"
+                  v-model.trim="sellForm.ruleName"
+                  placeholder="请输入券名称(最多20个字符)"
+                  allowClear />
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
+              <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
+                <a-input
+                  :disabled="isDisabled"
+                  id="promotionEdit-ruleTitle"
+                  :maxLength="20"
+                  v-model.trim="sellForm.ruleTitle"
+                  placeholder="请输入券副标题(最多20个字符)"
+                  allowClear />
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="生成方式" prop="ruleBaseType">
+                <!-- showType="radio" -->
+                <v-select
+                  style="width:40%;"
+                  v-model="sellForm.ruleBaseType"
+                  id="promotionEdit-ruleBaseType"
+                  code="PROMO_RULE_BASE_TYPE"
+                  :disabled="isDisabled"
+                  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
+                  style="width:40%;"
+                  v-model="sellForm.validType"
+                  placeholder="请选择券有效期"
+                  id="promotionEdit-validType"
+                  code="PROMO_RULE_TICKET_TYPE"
+                  :disabled="isDisabled"
+                  allowClear></v-select>
+                <a-range-picker
+                  v-show="sellForm.validType==='FIXED'"
+                  style="width:40%;margin-left:10px;"
+                  v-model="time"
+                  :format="dateFormat"
+                  @change="dateChange"
+                  :disabled="isDisabled"
+                  :disabled-date="disabledDate"
+                  :placeholder="['开始时间', '结束时间']" />
+                <span style="width:40%;margin-left:10px;" v-show="sellForm.validType==='LIMIT'">
+                  领取后,立即生效,有效期<a-input-number
+                    style="margin:0 5px;"
+                    v-model="sellForm.validDays"
+                    :step="1"
+                    :max="99999999"
+                    :min="1"
+                    :disabled="isDisabled"
+                    :precision="0"/>天
+                </span>
+              </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="range">
+                全部产品
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="使用说明" prop="ruleExplain">
+                <a-input
+                  v-model="sellForm.ruleExplain"
+                  :disabled="isDisabled"
+                  type="textarea"
+                  placeholder="请输入使用说明(最多50个字符)"
+                  :maxLength="200" />
+              </a-form-model-item>
             </a-col>
+            <div style="text-align:center;" v-if="!isShowNextStep"><a-button type="primary" size="large" :disabled="isDisabled" @click="handleSave('part')" >保存后设置产品</a-button></div>
           </a-row>
-          <a-row>
+          <a-row v-if="form.contentType =='LINK'&&isShowNextStep">
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="产品范围">
+                <div id="setPromotion-productRange" style="position:relative;">
+                  <a-tree-select
+                    v-model="sellForm.productRangeList"
+                    :maxTagCount="12"
+                    :tree-data="productTypeList"
+                    tree-checkable
+                    :disabled="isDisabled"
+                    :getPopupContainer="triggerNode => triggerNode.parentNode"
+                    :replaceFields="{children:'children',title: 'productTypeName',key: 'productTypeSn',value: 'productTypeSn'}"
+                    @blur="onChangeTree"
+                    placeholder="请选择产品范围" />
+                </div>
+              </a-form-model-item>
+            </a-col>
+            <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
+              <a-form-model-item label="返券产品">
+                <div class="productInfo flex-center">
+                  <div>
+                    返券金额<a-input-number
+                      v-model="sellForm.ruleValue"
+                      style="margin:0 5px;"
+                      :min="0"
+                      :step="1"
+                      :precision="2"
+                      :max="99999999"
+                      :disabled="isDisabled"
+                      size="small"/> 元
+                    <a-button type="primary" :disabled="isDisabled" class="button-primary" size="small" @click="handleBatchAdd">批量添加</a-button>
+                  </div>
+                  <a-button type="primary" :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="chooseProduct" :promoActiveSn="$route.params.sn" :disabledVal="isDisabled"></productTable>
+              </div>
+            </a-col>
             <a-col
               :xs="24"
               :sm="24"
               :md="24"
               :lg="16"
-              :xl="16"
-              v-if="form.contentType =='LINK'&&form.linkType==='1'">
+              :xl="16">
               <a-form-model-item label="加盟商编辑" prop="dealerEditFlag" :label-col="{span:3}" :wrapper-col="{span:18}">
-                <a-radio-group button-style="solid" :disabled="(form.contentType !='LINK'||!isShowParams||isDisabled)" v-model="form.dealerEditFlag">
+                <a-radio-group button-style="solid" :disabled="isDisabled" v-model="form.dealerEditFlag">
                   <a-radio-button value="1">
                   </a-radio-button>
@@ -180,28 +310,36 @@
             </a-col>
             <a-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
               <a-form-model-item label="是否发布" prop="publishState" :label-col="{span:3}" :wrapper-col="{span:18}">
-                <a-radio-group button-style="solid" v-model="form.publishState" :disabled="pageType==='see'">
-                  <a-radio-button value="PUBLISH">
+                <a-radio-group button-style="solid" v-model="form.publishState">
+                  <a-radio-button value="1">
                   </a-radio-button>
-                  <a-radio-button value="UNPUBLISH">
+                  <a-radio-button value="0">
                   </a-radio-button>
                 </a-radio-group>
               </a-form-model-item>
             </a-col>
           </a-row>
-        </a-card>
-      </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-row v-if="form.contentType !='LINK' ||(form.contentType ==='LINK'&&form.linkType==='2') ">
+            <a-col :xs="24" :sm="24" :md="24" :lg="16" :xl="16">
+              <a-form-model-item label="是否发布" prop="publishFlag" :label-col="{span:3}" :wrapper-col="{span:18}">
+                <a-radio-group button-style="solid" v-model="form.publishFlag">
+                  <a-radio-button value="1">
+                    是
+                  </a-radio-button>
+                  <a-radio-button value="0">
+                    否
+                  </a-radio-button>
+                </a-radio-group>
+              </a-form-model-item>
+            </a-col>
+          </a-row>
+        </a-form-model>
+        </a-form-model>
+      </a-card>
     </a-spin>
+    <!-- v-if="form.contentType !='LINK'||isShowNextStep" -->
     <div class="affix-cont">
       <a-button
         type="primary"
@@ -209,8 +347,8 @@
         :disabled="spinning"
         id="productInfoEdit-submit-btn"
         size="large"
-        v-if="pageType!='see'"
-        @click="handleSave"
+        @click="handleSave('all')"
+        v-if="form.contentType !='LINK'||isShowNextStep"
         style="padding: 0 60px;">保存</a-button>
     </div>
     <!-- 预览 -->
@@ -219,8 +357,6 @@
     <chooseProduct
       ref="chooseProduct"
       :chooseType="chooseTypeList"
-      :chooseData="chooseDataList"
-      :chooseProduct="chooseProductList"
       :openModal="showProModal"
       @ok="addProductSuccess"
       @close="closeProductModal"></chooseProduct>
@@ -229,23 +365,28 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
+import moment from 'moment'
 import { VSelect, Upload } from '@/components'
 import Editor from '@/components/WEeditor'
-import { promoActivePublish, promoActiveDetail } from '@/api/promoActive'
+import { promoActivePublish, promoActiveDetail, saveBatchEntity, promoCreateBatch, deleteByProductType } from '@/api/promoActive'
 import promotionShowModal from './promotionShowModal'
-import setPromotion from './setPromotion'
+import productTable from './productTable'
 import chooseProduct from './chooseProductsModal.vue'
+import { productTypeQuery } from '@/api/productType'
 export default {
   name: 'ProductBrandEditModal',
   mixins: [commonMixin],
-  components: { VSelect, Upload, Editor, promotionShowModal, setPromotion, chooseProduct },
+  components: { VSelect, Upload, Editor, promotionShowModal, chooseProduct, productTable },
   data () {
     return {
-      isShow: this.openModal, //  是否打开弹框
       spinning: false,
       formItemLayout: {
-        labelCol: { span: 4 },
-        wrapperCol: { span: 16 }
+        labelCol: { span: 2 },
+        wrapperCol: { span: 20 }
+      },
+      sellFormItemLayout: {
+        labelCol: { span: 2 }, // 文字前距离设置
+        wrapperCol: { span: 20 }// 表单后距离设置  数字越大距离越小
       },
       form: {
         promoActiveSn: undefined, // 促销活动sn
@@ -256,31 +397,37 @@ export default {
         contentLink: '', // 链接内容
         sort: undefined, // 排序
         ruleEnableFlag: '1', // 参数配置 1勾选配置  0不能配置
-        publishState: 'UNPUBLISH',
+        publishFlag: '0',
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
-        // 参数配置数据
-        promoRule: {
-          ruleType: undefined, // 基本规则类型
-          productRangeFlag: '', // 产品范围标记 0无  1有产品范围
-          productRangeList: [], // 产品范围列表
-          ruleName: '', // 券名称
-          ruleTitle: '', // 副标题
-          ruleBaseType: undefined, // 券生成方式
-          ruleExplain: '', // 使用说明
-          validType: undefined, // 券有效期类型
-          validStartDate: undefined, // 券生效时间
-          validEndDate: undefined, // 券失效时间
-          validDays: undefined, // 券有效期天数
-          ruleDetailList: []// 券内容
-        }
+        promoRule: {},
+        publishState: 'UNPUBLISH'
+      },
+      // 参数配置数据
+      sellForm: {
+        ruleType: 'ticket', // 基本规则类型
+        productRangeFlag: '', // 产品范围标记 0无  1有产品范围
+        productRangeList: [], // 产品范围列表
+        ruleName: '', // 券名称
+        ruleTitle: '', // 副标题
+        ruleBaseType: 'category', // 券生成方式
+        ruleExplain: '', // 使用说明
+        validType: undefined, // 券有效期类型
+        validStartDate: undefined, // 券生效时间
+        validEndDate: undefined, // 券失效时间
+        validDays: undefined, // 券有效期天数
+        range: '1',
+        // 券内容
+        ruleDetailList: []
       },
+      time: [], // 有效期
+      promotionName: '',
+      dateFormat: 'YYYY-MM-DD',
       pageType: undefined, // 页面类型
       showProModal: false,
-      isShowParams: true, // 是否显示参数配置内容
+      isShowNextStep: false, // 是否显示下一步 配置产品
       openShowModal: false,
       isDisabled: false, // 控制是否能编辑
       chooseTypeList: [],
-      chooseDataList: [],
       chooseProductList: [],
       imageSet: [], // 回显显示图片数据
       rules: {
@@ -302,16 +449,35 @@ export default {
         contentLink: [
           { required: true, message: '请输入对应内容', trigger: 'blur' }
         ],
-        publishState: [
+        publishFlag: [
           { required: true, message: '请选择是否发布', trigger: 'change' }
         ],
-        dealerEditFlag: [
-          { required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }
+        range: [
+          { required: true, message: '请选择券适用范围', trigger: 'change' }
         ]
+      },
+      sellRules: {
+        ruleType: [{ required: true, message: '请选择基本规则', trigger: 'change' }],
+        ruleName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
+        ruleBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
+        validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
+        ruleDetailList: [{ type: 'array', required: true, message: '请选择券内容', trigger: 'blur' }]
+        // dealerEditFlag: [{ required: true, message: '请选择加盟商是否可编辑', trigger: 'change' }]
       }
     }
   },
   methods: {
+    // 禁用日期时间
+    disabledDate (current) {
+      return current && current < moment().startOf('day')
+    },
+    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'
+      }
+    },
     // 打开产品弹窗
     insterProduct (obj) {
       if (obj && Object.keys(obj).length > 0) {
@@ -321,14 +487,7 @@ export default {
       }
       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
     },
@@ -336,25 +495,15 @@ export default {
     handleBack () {
       this.$router.push({ name: 'promotionManagementList', query: { closeLastOldTab: true } })
     },
-    // 预览
-    // handleSee () {
-    //   if (this.form.content) {
-    //     this.openShowModal = true
-    //     this.$refs.showModal.pageInit({ type: this.form.contentType, con: this.form.content })
-    //   } else {
-    //     this.$message.error('请输入预览内容!')
-    //   }
-    // },
-    //  详情
+    //  详情  挨个赋值原因:该接口和修理厂促销列表详情用的同一个接口,给后端传值过滤多余参数
     getDetail () {
-      // 查看按钮时,所有按钮不能编辑    编辑按钮时,publishState 已发布,只能编辑是否发布;publishState已关闭,都可以编辑
       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'
-          } else if (_this.pageType === 'see') {
-            _this.isDisabled = true
+            _this.form.publishFlag = res.data.publishFlag // 未返值
           }
           _this.form.promoActiveSn = res.data.promoActiveSn
           _this.form.title = res.data.title
@@ -364,13 +513,13 @@ export default {
           if (res.data.imageSet) {
             const images = res.data.imageSet.join(',')
             _this.form.imageSet = images
-            if (this.pageType != 'see') {
+            if (this.pageType === 'add') {
               _this.$refs.imageSet.setFileList(images)
             }
           }
           _this.form.content = res.data.content
+          _this.promotionName = res.data.name || ''
           _this.form.dealerEditFlag = res.data.dealerEditFlag
-          _this.form.publishState = res.data.publishState
           if (res.data.contentType == 'IMAGE_CONTENT') {
             _this.$refs.editor.setHtml(res.data.content)
           } else if (res.data.contentType == 'VIDEO') {
@@ -380,69 +529,104 @@ export default {
           } else 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)
-              })
+            if (res.data.promoRule) {
+              _this.isShowNextStep = true
+              _this.sellForm = res.data.promoRule
+              _this.sellForm.range = '1'
+              _this.time = [res.data.promoRule.validStartDate, res.data.promoRule.validEndDate]
             }
           }
         }
       })
     },
     //  确定保存
-    handleSave () {
+    handleSave (type) {
       const _this = this
       if (_this.form.contentType === 'LINK') {
         _this.form.content = _this.form.contentLink
-        if (_this.form.ruleEnableFlag === '1') {
-          _this.form.promoRule.ruleDetailList = _this.$refs.setContent.couponList
-        }
         // 验证组件必填项
-        _this.$refs.setContent.testAndVerify(function (res) {
-          if (res) {
-            _this.saveInfo()
+        _this.$refs.ruleForm.validate(valid => {
+          if (valid) {
+            // 验证设置参数必填项
+            _this.testAndVerify(function (res) {
+              console.log('2222222:', res)
+              if (res) {
+                _this.savePartInfo(type)
+              }
+            })
           }
         })
       } else {
-        _this.saveInfo()
+        _this.$refs.ruleForm.validate(valid => {
+          if (valid) {
+            _this.savePartInfo(type)
+          }
+        })
       }
     },
-    saveInfo () {
-      const _this = this
-      _this.$refs.ruleForm.validate(valid => {
+    testAndVerify (callBack) {
+      if (this.sellForm.validType === 'FIXED') {
+        if (!this.sellForm.validStartDate || this.sellForm.validStartDate.validEndDate) {
+          this.$message.warning('请选择固定日期!')
+          return false
+        }
+      } else {
+        if (!this.sellForm.validDays) {
+          this.$message.warning('请输入有效天数!')
+          return false
+        }
+      }
+      this.$refs.sellRuleForm.validate(valid => {
         if (valid) {
-          _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
-            formData.promoRule = _this.$refs.setContent.getPromotionVal()
-          }
-          _this.spinning = true
-          promoActivePublish(formData).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$nextTick(() => {
-                _this.handleBack()
-                _this.resetSearchForm()
-              })
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
+          callBack(valid)
         } else {
           return false
         }
       })
     },
+    // 保存部分参数
+    // handlePartSave () {
+    //   const _this = this
+    //   _this.$refs.ruleForm.validate(valid => {
+    //     if (valid) {
+    //       // 验证设置参数必填项
+    //       _this.testAndVerify(function (res) {
+    //         console.log('2222222:', res)
+    //         if (res) {
+    //           _this.savePartInfo()
+    //         }
+    //       })
+    //     }
+    //   })
+    // },
+    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
+      }
+      formData.promoRule = _this.sellForm
+      _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
@@ -481,20 +665,22 @@ export default {
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
         // 参数配置数据
         promoRule: {
-          ruleType: undefined, // 基本规则类型
+          ruleType: 'ticket', // 基本规则类型
           productRangeFlag: '', // 产品范围标记 0无  1有产品范围
           productRangeList: [], // 产品范围列表
           ruleName: '', // 券名称
           ruleTitle: '', // 副标题
-          ruleBaseType: undefined, // 券生成方式
+          ruleBaseType: 'category', // 券生成方式
           ruleExplain: '', // 使用说明
           validType: undefined, // 券有效期类型
           validStartDate: undefined, // 券生效时间
           validEndDate: undefined, // 券失效时间
           validDays: undefined, // 券有效期天数
-          ruleDetailList: []// 券内容
+          // 券内容
+          ruleDetailList: []
         }
       }
+      this.isShowNextStep = false
       this.isDisabled = false
       if (this.$refs.setContent) {
         this.$refs.setContent.clearContent()
@@ -503,14 +689,26 @@ export default {
         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
     },
@@ -527,20 +725,61 @@ export default {
     handleLinkType (val) {
       this.form.contentLink = val === '2' ? '' : '/pagesB/promoDetail'
     },
+    // 添加产品
+    handleAddProduct () {
+      this.chooseTypeList = this.sellForm.productRangeList
+      // 保存产品范围
+      saveBatchEntity({ list: this.productRangeList, promoActiveSn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          this.showProModal = true
+        }
+      })
+    },
+    // 批量添加
+    handleBatchAdd () {
+      if (!this.sellForm.ruleValue) {
+        this.$message.warning('请输入返券金额!')
+        return
+      }
+      this.$refs.chooseProduct.editMorePrice(this.sellForm.ruleValue)
+    },
+    // 添加产品成功
+    addProductSuccess (list) {
+      const productArr = list.map(item => {
+        return {
+          promoActiveSn: this.$route.params.sn,
+          promoRuleSn: this.sellForm.promoRuleSn,
+          productCode: item.code,
+          productSn: item.productSn,
+          ruleValue: this.sellForm.ruleValue
+        }
+      })
+      promoCreateBatch(productArr).then(res => {
+        if (res.status == 200) {
+          this.showProModal = false
+          // 获取产品列表 有分页
+          this.$refs.chooseProduct.pageInit()
+        }
+      })
+
+      this.$refs.setContent.setProductSn(productArr)
+    },
+    onChangeTree () {
+      deleteByProductType({ promoActiveSn: this.$route.params.sn, productTypeSnList: this.sellForm.productRangeList || [] }).then(res => {
+        if (res.status == 200) {
+          this.$refs.chooseProduct.pageInit()
+        }
+      })
+    },
     pageInit () {
       this.pageType = this.$route.params.pageType
-      if (this.pageType === 'edit' || this.pageType === 'see') {
-        this.destroyVideo()
+      if (this.pageType === 'edit') {
         this.getDetail()
       }
-    },
-    // 重新加载视频
-    destroyVideo () {
-      const video = this.$refs.videoPlayer
-      if (video) {
-        video.pause() // 暂停视频
-        video.load() // 重新加载视频,以清除播放状态
-      }
+      console.log('加载产品范围')
+      this.$nextTick(() => {
+        this.getTreeData()
+      })
     }
   },
   mounted () {
@@ -573,6 +812,9 @@ export default {
       overflow-y: scroll;
       height: 100%;
     }
+    /deep/.ant-form-item{
+      margin-bottom:8px;
+    }
     .promotionEdit-cont{
       margin-bottom: 10px;
     }
@@ -605,13 +847,24 @@ export default {
     .affix{
       .ant-affix{
         z-index: 101;
+        display:inline-block
       }
     }
-    /deep/.ant-radio-disabled{
-     span{
-        color:rgb(0,0,0) !important;
-      }
+    /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>

+ 16 - 22
src/views/promotionRulesManagement/promotionManagement/list.vue

@@ -122,7 +122,7 @@
                 size="small"
                 type="link"
                 class="button-success"
-                @click="handleRelease(record,'see')"
+                @click="handleSee(record)"
                 v-if="(record.publishState=='PUBLISH')&&$hasPermissions('B_promotionManagementContent')"
                 id="promotion-modify-btn">查看</a-button>
               <a-button
@@ -152,8 +152,9 @@
       <promotion-show-modal ref="showModal" :openModal="openShowModal" @close="openShowModal = false"></promotion-show-modal>
       <!-- 新增 -->
       <addModal :openModal="openAddModal" :itemId="itemId" @close="closeAddModal" @ok="$refs.table.refresh()"></addModal>
-      <!-- 促销发布 -->
-      <!-- <promotion-edit-modal :pageType="pageType" :openModal="openPromotionEditModal" :itemId="itemId" @close="closePromotionEditModal" @ok="$refs.table.refresh()" /> -->
+      <!-- 查看 -->
+      <detail-Modal :openModal="openDetailModal" :itemId="itemId" @close="closeDetailModal" @ok="$refs.table.refresh()" />
+
     </a-card>
   </div>
 </template>
@@ -162,25 +163,17 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
-
 import lookUpCustomersModal from './lookUpCustomersModal'
 import promotionDescModal from './promotionDescModal'
 import promotionShowModal from './promotionShowModal'
 import addModal from './addModal'
+import detailModal from './detailModal'
 import { updateShowFlag } from '@/api/promoTerminal'
 import { promoActiveList, promoActiveDel } from '@/api/promoActive'
 export default {
   name: 'PromotionList',
   mixins: [commonMixin],
-  components: {
-    STable,
-    VSelect,
-    rangeDate,
-    lookUpCustomersModal,
-    promotionShowModal,
-    promotionDescModal,
-    addModal
-  },
+  components: { STable, VSelect, rangeDate, lookUpCustomersModal, promotionShowModal, promotionDescModal, addModal, detailModal },
   data () {
     return {
       spinning: false,
@@ -190,7 +183,7 @@ export default {
       openDescModal: false,
       openShowModal: false,
       openAddModal: false,
-      openPromotionEditModal: false,
+      openDetailModal: false,
       createDate: [], //  创建时间
       itemId: '',
       descCon: '', // 描述内容
@@ -327,16 +320,17 @@ export default {
     },
     // 促销发布
     handleRelease (row, type) {
-      if (type === 'add') {
-        const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
-        this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
-      } else { // 查看 、编辑跳转
-        this.$router.push({ name: 'promotionManagementEdit', params: { sn: row.promoActiveSn, pageType: type } })
-      }
+      const newType = row.imageSet && row.imageSet.length > 0 ? 'edit' : type
+      this.$router.push({ name: 'promotionManagementAdd', params: { sn: row.promoActiveSn, pageType: newType } })
+    },
+    // 打开详情
+    handleSee (row) {
+      this.openDetailModal = true
+      this.itemId = row.promoActiveSn
     },
     // 关闭促销发布
-    closePromotionEditModal () {
-      this.openPromotionEditModal = false
+    closeDetailModal () {
+      this.openDetailModal = false
       this.itemId = ''
     },
     pageInit () {

+ 148 - 212
src/views/promotionRulesManagement/promotionManagement/productTable.vue

@@ -1,245 +1,181 @@
 <template>
   <div class="veTableCon">
-    <ve-table
-      border-y
-      v-show="!showEmpty"
-      :scroll-width="0"
-      :max-height="(tableHeight)"
-      :show-header="showTableHead"
-      :row-style-option="{clickHighlight: true}"
-      :cellSelectionOption="{enable: false}"
-      :virtual-scroll-option="{enable: true}"
-      :columns="columns"
-      :table-data="dataSource"
-    />
-    <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
+    <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"
+        bordered>
+        <template slot="price" slot-scope="text,record">
+          <a-input-number
+            :min="0"
+            :step="1"
+            :precision="2"
+            :max="99999999"
+            @blur="editAllPrice(record,'price')"
+            placeholder="请输入"
+            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"
+            @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"
+            :disabled="disabledVal"
+            :id="'productTable-del-btn'+record.id "
+            @click="handleDel(record)"
+          >删除</a-button>
+        </template>
+      </s-table>
+    </a-spin>
   </div>
 </template>
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { Empty } from 'ant-design-vue'
+import { STable } from '@/components'
+import { promoRuleProductList, deleteBatch, promoUpdateBatch } from '@/api/promoActive'
 export default {
-  name: 'DetailProductList',
+  name: 'ProductTable',
   mixins: [commonMixin],
+  components: { STable },
   props: {
-    newLoading: Boolean, // loadin
-    // 最大高度
-    maxHeight: {
-      type: [String, Number],
-      default: '300'
-    },
-    // 是否显示表格头部
-    showHeader: {
+    disabledVal: {
       type: Boolean,
-      default: true
+      default: false
+    },
+    promoActiveSn: {
+      type: String,
+      default: ''
     }
   },
   data () {
     return {
       spinning: false,
-      openDetailModal: false, // 活动规则详情弹框
-      detailSn: null, // 活动规则详情sn
-      activeList: [], // 活动列表
-      dataSource: [], // 列表原始数据
-      tableHeight: this.maxHeight, // 表格高度
-      // 自定义单元格样式
-      cellStyleOption: {
-        bodyCellClass: ({ row, column, rowIndex }) => {
-          if (row.id.indexOf('promo-') >= 0 && column.field === 'no') {
-            return 'table-body-cell-no'
+      rowSelectionInfo: null,
+      queryParam: {},
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '原厂编码', dataIndex: 'origCode', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '活动价', scopedSlots: { customRender: 'price' }, width: '12%', align: 'center' },
+        { title: '返券金额', scopedSlots: { customRender: 'ruleValue' }, width: '12%', align: 'center' },
+        { title: '参考终端价', dataIndex: 'terminalPrice', width: '12%', align: 'center', customRender: text => { return ((text || text == 0) ? this.toThousands(text) : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        const params = Object.assign(parameter, this.queryParam)
+        console.log('11111111111111', this.promoActiveSn)
+        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
+              data.list[i].price = data.list[i].terminalPrice
+            }
+            this.disabled = false
           }
-        }
-      },
-      // 表格列可拖曳
-      columnWidthResizeOption: {
-        // default false
-        enable: true,
-        // column resize min width
-        minWidth: 50
-      },
-      // 自定义单元格内容
-      cellSpanOption: {
-        bodyCellSpan: this.bodyCellSpan
-      },
-      isCityPrice: false, // 是否显示市级价
-      outStockStr: '', // 产品库存不足提示信息
-      showEmpty: true, // 是否显示空数据图片
-      showTableHead: true, // 是否显示表格头部
-      colspanNums: 13, // 单元格合并列数
-      hasOutStockOfActive: false,
-      simpleImage: Empty.PRESENTED_IMAGE_SIMPLE // 空图片
-    }
-  },
-  computed: {
-    columns () {
-      const _this = this
-      // 终端价格变价
-      const priceEdit = function (record, data) {
-        return (
-          <a-input placeholder="请输入"/>
-        )
-      }
-      // 操作按钮
-      const actionFormat = function (record, data) {
-        return (
-          <div>
-            <a-button size="small" type="link" class="button-info" onClick={() => _this.handleDel(record)}>删除</a-button>
-          </div>
-        )
+          this.spinning = false
+          return data
+        })
       }
-      const arr = [
-        { title: '序号', field: 'no', key: 'a', width: 40, align: 'center' },
-        { title: '产品编码', field: 'productBrandName', key: 'a', align: 'center', width: 80, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '全品类' } },
-        { title: '产品名称', field: 'productTypeName1', key: 'b', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '原厂编码', field: 'productTypeName2', key: 'c', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '活动价', field: 'productTypeName3', key: 'd', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return priceEdit(row, row[column.field]) } },
-        { title: '参考终端价', field: 'priceLevelDictValue', key: 'e', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '操作', field: 'action', width: 80, key: 'f', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column }) => { return actionFormat(row, row[column.field]) } }
-      ]
-      return arr
     }
   },
   methods: {
-    // 关闭详情弹窗
-    closeDetailModal () {
-      this.detailSn = null
-      this.openDetailModal = false
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
     },
-    // 合并活动分类单元格
-    bodyCellSpan ({ row, column, rowIndex }) {
-      if (row.id.indexOf('promo-') >= 0) {
-        if (column.field == 'no') {
-          return {
-            rowspan: 1,
-            colspan: this.colspanNums
-          }
-        } else {
-          return {
-            rowspan: 0,
-            colspan: 0
-          }
-        }
+    // 批量修改价格
+    editAllPrice (row, typeName) {
+      let ajaxData = []
+      if (typeName != 'all') {
+        ajaxData.push({
+          id: row.id,
+          ruleValue: typeName === 'ruleValue' ? row.ruleValue : row.price
+        })
+      } else {
+        ajaxData = row || []
       }
-    },
-    // 查看活动详情
-    showDesc (row) {
-      this.detailSn = row.promoRuleSn
-      this.openDetailModal = true
-    },
-    // 获取销售单参与的活动列表
-    pageInit () {
-      salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
+      promoUpdateBatch(ajaxData).then(res => {
         if (res.status == 200) {
-          this.activeList = res.data || []
+          this.$refs.table.refresh(true)
+          this.$refs.table.clearSelected() // 清空表格选中项
         }
-        this.$nextTick(() => {
-          this.searchTable()
-        })
       })
     },
-    // 查询表格数据
-    async searchTable () {
-      this.dataSource = []
-      this.disabled = true
-      this.spinning = true
-      // 参数
-      const params = {
-        salesBillSn: this.salesBillSn,
-        showStock: this.showStock,
-        warehouseSn: this.warehouseSn,
-        promotionFlag: this.promoFlag == '' ? undefined : this.promoFlag
+    editMorePrice (numInfo) {
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows && this.rowSelectionInfo.selectedRows.length === 0)) {
+        this.$message.warning('请选择要修改的产品!')
+        return
       }
-      // 参与活动数据
-      const active = this.activeList.filter(item => item.enabledFlag == 1)
-
-      // 正常产品
-      const hasSearchNormal = !params.promotionFlag || params.promotionFlag == 0
-      const proList = hasSearchNormal ? await salesDetailAllList(params).then(res => res.data) : []
-      const norTotal = hasSearchNormal ? await salesDetaiCount(params).then(res => res.data) : null
-
-      // 没有活动时,表格不显示统计数据
-      let listData = active.length ? (proList.length ? [{
-        id: 'promo-normal',
-        total: norTotal
-      }, ...proList] : []) : proList
-
-      // 有促销活动产品
-      if (params.promotionFlag != 0) {
-        // 循环获取活动产品
-        for (let i = 0; i < active.length; i++) {
-          const promo = active[i]
-          const activeParams = {
-            promoRuleSn: promo.promoRuleSn,
-            promoSn: promo.promoSn,
-            salesPromoSn: promo.salesPromoSn,
-            ...params
-          }
-
-          // 获取活动产品统计
-          const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
-          if (acTotal) {
-            // 采购额结余
-            acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
-            // 采购额超出
-            acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
-          }
-          // 有数据时才调用接口,避免做无用的调用
-          if (acTotal && acTotal.totalQty) {
-            // 获取活动产品列表
-            const aclist = await salesDetailAllList(activeParams).then(res => res.data)
-            // 合并结果数据
-            const retList = aclist.length ? [{
-              id: 'promo-' + i,
-              promo: promo,
-              total: acTotal
-            }, ...aclist] : []
-            // 将活动产品数据拼接
-            listData = aclist && aclist.length ? listData.concat(retList) : listData
-          }
-        }
-        // 如果活动没有任何产品,不显示统计一行
-        if (active.length) {
-          const hasAcp = listData.filter(item => item.id != 'promo-normal').filter(item => item.id.indexOf('promo-') >= 0)
-          if (hasAcp && hasAcp.length == 0) {
-            listData = listData.filter(item => item.id.indexOf('promo-') < 0) || []
-          }
-        }
-      }
-      // 赋值
-      this.dataSource = listData
-      // 格式化数据
-      let f = 0
-      let str = ''
-      this.outStockStr = ''
-      this.dataSource.map((item, i) => {
-        if (item.id.indexOf('promo-') >= 0) { f = f - 1 }
-        item.no = i + 1 + f
-        // 格式化数据
-        const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
-        const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
-        const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
-        const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
-        item.productCode = productCode || '--'
-        item.productName = productName || '--'
-        item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
-        item.productOrigUnit = productOrigUnit || '--'
-        item.epushedQty = Number(item.pushedQty) - Number(item.pushQty)
-        if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
-          str += item.productCode + '、'
-          if (item.promotionFlag != 0) {
-            this.hasOutStockOfActive = true
-          }
+      const ajaxArr = this.rowSelectionInfo.selectedRows.map(item => { return { id: item.id, ruleValue: numInfo } })
+      this.editAllPrice(ajaxArr, 'all')
+    },
+    // 删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '点击确定,该内容将会被删除,不可再恢复!',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          // let ids=[]
+          // ids.push(row.id)
+          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
+            }
+          })
         }
       })
-      if (str.length > 0) {
-        str = str.substr(0, str.length - 1)
-        this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
-      }
-      this.showEmpty = this.dataSource.length <= 0
-      this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
-      this.spinning = false
-      this.disabled = false
+    },
+    pageInit () {
+      this.$nextTick(() => {
+        this.$refs.table.refresh(true)
+      })
     }
+  },
+  mounted () {
+    this.pageInit()
+  },
+  activated () {
+    this.pageInit()
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
   }
 }
 </script>