Browse Source

对接促销规则

chenrui 4 years ago
parent
commit
5bde4d9660

+ 8 - 0
src/api/promoRule.js

@@ -32,3 +32,11 @@ export const promoRuleDetail = (params) => {
     method: 'get'
   })
 }
+//  优惠活动 详情  包含规则
+export const promoRuleDetailD = (params) => {
+  const url = `/promoRule/findDetailBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get'
+  })
+}

+ 55 - 15
src/views/promotionRulesManagement/promotionRules/basicInfoModal.vue

@@ -37,7 +37,7 @@
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12" v-if="form.activeDateEnable==1">
+        <a-col span="12" v-if="form.activeDateEnable=='1'">
           <a-form-model-item prop="activeDate">
             <a-range-picker
               style="width:100%"
@@ -62,7 +62,7 @@
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12" v-if="form.buyerLimitEnable==1">
+        <a-col span="12" v-if="form.buyerLimitEnable=='1'">
           <a-form-model-item prop="buyerSns">
             <a-button id="promotionRules-basicInfo-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
             <span style="font-weight: bold;">当前已选:{{ chooseCust.length }}个</span>
@@ -89,7 +89,7 @@
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12" v-if="form.activeAmountEnable==1">
+        <a-col span="12" v-if="form.activeAmountEnable=='1'">
           <a-form-model-item prop="activeAmount">
             <a-input-number
               id="promotionRules-basicInfo-activeAmount"
@@ -100,7 +100,7 @@
               style="width: 85%;margin-right: 5px;"
               placeholder="请输入活动经费上限(1~999999)"
               allowClear />
-            <span v-if="form.activeAmountEnable==1">万元</span>
+            <span>万元</span>
           </a-form-model-item>
         </a-col>
       </a-row>
@@ -124,7 +124,7 @@
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12" v-if="form.orderAmountEnable==1">
+        <a-col span="12" v-if="form.orderAmountEnable=='1'">
           <a-form-model-item prop="orderAmount">
             <a-input-number
               id="promotionRules-basicInfo-orderAmount"
@@ -161,7 +161,7 @@
 import moment from 'moment'
 import { VSelect } from '@/components'
 import chooseCustomerModal from './chooseCustomerModal'
-import { promoActiveSave } from '@/api/promoActive'
+import { promoActiveSave, promoActiveDetail } from '@/api/promoActive'
 export default {
   name: 'StoreTransferOutBasicInfoModal',
   components: { VSelect, chooseCustomerModal },
@@ -170,6 +170,10 @@ export default {
       //  弹框显示状态
       type: Boolean,
       default: false
+    },
+    itemSn: {
+      type: String || Number,
+      default: ''
     }
   },
   data () {
@@ -181,15 +185,15 @@ export default {
       },
       form: {
         name: '',
-        activeDateEnable: 0, //  活动时间启用标记
+        activeDateEnable: '0', //  活动时间启用标记
         activeDate: [],
         activeDateStart: '', // 活动时间-开始
         activeDateEnd: '', // 活动时间-结束
-        buyerLimitEnable: 0, //  参与客户启用标记
+        buyerLimitEnable: '0', //  参与客户启用标记
         buyerSns: '', //  部分客户
-        activeAmountEnable: 0, //  活动经费启用标记
+        activeAmountEnable: '0', //  活动经费启用标记
         activeAmount: '', // 活动经费上限
-        orderAmountEnable: 0, //  起订金额启用标记
+        orderAmountEnable: '0', //  起订金额启用标记
         orderAmount: '', // 订单起订金额
         remark: ''
       },
@@ -206,18 +210,40 @@ export default {
       },
       dateFormat: 'YYYY-MM-DD',
       rangeList: [ //  是否限制
-        { name: '不限', val: 0 },
-        { name: '限制', val: 1 }
+        { name: '不限', val: '0' },
+        { name: '限制', val: '1' }
       ],
       rangeCList: [ //  是否全部
-        { name: '全部客户', val: 0 },
-        { name: '部分客户', val: 1 }
+        { name: '全部客户', val: '0' },
+        { name: '部分客户', val: '1' }
       ],
       openCustomerModal: false,
       chooseCust: [] //  当前已选客户
     }
   },
   methods: {
+    // 详情
+    getDetail () {
+      const _this = this
+      promoActiveDetail({ sn: this.itemSn }).then(res => {
+        if (res.status == 200) {
+          const data = res.data
+          this.form = Object.assign(this.form, data)
+          if (data.activeDateStart) {
+            this.form.activeDate[0] = moment(data.activeDateStart).format(this.dateFormat)
+          }
+          if (data.activeDateEnd) {
+            this.form.activeDate[1] = moment(data.activeDateEnd).format(this.dateFormat)
+          }
+          this.chooseCust = []
+          if (data.promoBuyerList && data.promoBuyerList.length > 0) {
+            data.promoBuyerList.map(item => {
+              _this.chooseCust.push(item.buyerSn)
+            })
+          }
+        }
+      })
+    },
     //  保存
     handleSave () {
       const _this = this
@@ -249,7 +275,7 @@ export default {
     },
     handleOk (obj) {
       this.chooseCust = obj
-      this.form.buyerSns = this.chooseCust.join(',')
+      // this.form.buyerSns = this.chooseCust.join(',')
     },
     // select   change
     handleChange (val) {
@@ -260,6 +286,7 @@ export default {
         this.form.activeDateEnd = ''
       } else if (val == 'buyerLimitEnable' && this.form.buyerLimitEnable == 0) { //  参与客户
         this.chooseCust = []
+        this.form.buyerSns = ''
       } else if (val == 'activeAmountEnable' && this.form.activeAmountEnable == 0) { //  活动经费
         this.form.activeAmount = ''
       } else if (val == 'orderAmountEnable' && this.form.orderAmountEnable == 0) { //  起订金额
@@ -282,6 +309,19 @@ export default {
         this.$emit('close')
         this.$refs.ruleForm.resetFields()
       }
+    },
+    itemSn (newValue, oldValue) {
+      if (this.isShow && newValue) {
+        this.getDetail()
+      }
+    },
+    chooseCust: {
+      handler (newValue, oldValue) {
+        if (this.isShow && newValue) {
+          this.form.buyerSns = newValue.join(',')
+        }
+      },
+      deep: true
     }
   }
 }

+ 143 - 61
src/views/promotionRulesManagement/promotionRules/choosePriceProductsModal.vue

@@ -4,51 +4,54 @@
     class="choosePosPriceProducts-modal"
     :footer="null"
     :maskClosable="false"
-    title="选择正价产品"
+    title="选择产品"
     v-model="isShow"
     @cancle="isShow=false"
     width="80%">
     <div class="table-operator">
-      <a-button id="choosePosPriceProducts-brand" type="primary" class="button-error" @click="choosePModal('brand')">选择产品品牌</a-button>
-      <a-button id="choosePosPriceProducts-type" type="primary" class="button-info" @click="choosePModal('type')">选择产品分类</a-button>
+      <a-button v-if="!(ruleType=='PROMO_PROD') && !((ruleType=='ADD_PRICE_PURCH') && (goodsType == 'promo'))" id="choosePosPriceProducts-brand" type="primary" class="button-error" @click="choosePModal('brand')">选择产品品牌</a-button>
+      <a-button v-if="!(ruleType=='PROMO_PROD') && !((ruleType=='ADD_PRICE_PURCH') && (goodsType == 'promo'))" id="choosePosPriceProducts-type" type="primary" class="button-info" @click="choosePModal('type')">选择产品分类</a-button>
       <a-button id="choosePosPriceProducts-product" type="primary" class="button-success" @click="choosePModal('product')">选择产品</a-button>
     </div>
     <!-- 参与产品 -->
     <div class="products-con">
       <!-- 标题栏 -->
       <div class="products-header">
-        <div class="products-tit">
-          参与产品:<a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="openGuideModal=true">导入产品</a-button>
-        </div>
-        <div class="products-operation">
-          <a-row :gutter="15">
-            <a-col :span="9">
-              <v-select
-                code="ORDER_GOODS_UNIT"
-                id="choosePosPriceProducts-orderGoodsUnit"
-                v-model="orderGoodsUnit"
-                allowClear
-                placeholder="请选择"
-                style="width: 100%;"
-              ></v-select>
-            </a-col>
-            <a-col :span="10">
-              <a-input-number
-                v-if="orderGoodsUnit=='PROD_UNIT'"
-                id="choosePosPriceProducts-orderGoodsQty"
-                v-model="orderGoodsQty"
-                :min="1"
-                :max="999999"
-                :precision="0"
-                style="width: 85%;margin-right: 5px;"
-                placeholder="请输入限制数量(1~999999)"
-                allowClear />
-            </a-col>
-            <a-col :span="5">
-              <a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="handlerBulkCopy">批量复制</a-button>
-            </a-col>
-          </a-row>
+        <div class="header-con">
+          <div class="products-tit">
+            参与产品:<a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="openGuideModal=true">导入产品</a-button>
+          </div>
+          <div class="products-operation" v-if="goodsType=='normal'">
+            <a-row :gutter="15">
+              <a-col :span="9">
+                <v-select
+                  code="ORDER_GOODS_UNIT"
+                  id="choosePosPriceProducts-orderGoodsUnit"
+                  v-model="orderGoodsUnit"
+                  allowClear
+                  placeholder="请选择"
+                  style="width: 100%;"
+                ></v-select>
+              </a-col>
+              <a-col :span="10">
+                <a-input-number
+                  v-if="orderGoodsUnit=='PROD_UNIT'"
+                  id="choosePosPriceProducts-orderGoodsQty"
+                  v-model="orderGoodsQty"
+                  :min="1"
+                  :max="999999"
+                  :precision="0"
+                  style="width: 85%;margin-right: 5px;"
+                  placeholder="请输入限制数量(1~999999)"
+                  allowClear />
+              </a-col>
+              <a-col :span="5">
+                <a-button id="choosePosPriceProducts-import" type="primary" class="button-info" @click="handlerBulkCopy">批量复制</a-button>
+              </a-col>
+            </a-row>
+          </div>
         </div>
+        <p><a-icon type="exclamation-circle" style="color: #f90;margin-right: 5px;" />提示:导入时会清空下方已选内容,只展示导出成功的产品,请谨慎使用。</p>
       </div>
       <!-- 表格 -->
       <a-table
@@ -56,9 +59,9 @@
         ref="table"
         size="small"
         :rowKey="(record, index) => index"
-        :columns="columns"
+        :columns="nowColumns"
         :dataSource="loadData"
-        :scroll="{ x: 1380, y: 500 }"
+        :scroll="{ x: goodsType == 'normal' ? 1380 : null, y: 500 }"
         :pagination="false"
         bordered>
         <!-- 序号 -->
@@ -85,6 +88,17 @@
             placeholder="请输入限制数量(1~999999)"
             style="width: 50%;margin-left: 5px;" />
         </template>
+        <!-- 特惠单价 / 换购单价 -->
+        <template slot="goodsPrice" slot-scope="text, record">
+          <a-input-number
+            id="choosePosPriceProducts-goodsPrice"
+            v-model="record.goodsPrice"
+            :precision="2"
+            :min="0.1"
+            :max="999999"
+            placeholder="请输入限制数量(0.1~999999)"
+            style="width: 100%;" />
+        </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="text, record, index">
           <a-button size="small" type="primary" class="button-error" @click="handleDel(record, index)" id="choosePosPriceProducts-del-btn">删除</a-button>
@@ -153,15 +167,30 @@ export default {
       orderGoodsUnit: undefined, //  起订量限制 批量
       orderGoodsQty: '', //  限制数量
       // 表头
-      columns: [
+      columns: [ //  正品
         { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
         { title: '类型', dataIndex: 'goodsTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '类型名称', dataIndex: 'typeName', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'goodsCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '起订量限制', scopedSlots: { customRender: 'orderGoodsUnit' }, width: 400, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
+      promoColumns: [ //  促销品
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
+        { title: '类型', dataIndex: 'goodsTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'typeName', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'goodsCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+      ],
+      promoSpecialColumns: [ //  特价产品/加价促销品
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
+        { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'goodsCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: this.ruleType == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)', scopedSlots: { customRender: 'goodsPrice' }, width: 200, align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+      ],
       loadData: [],
       openBrandModal: false, //  选择产品品牌
       openTypeModal: false, //  选择产品分类
@@ -172,6 +201,29 @@ export default {
       chooseType: [] //  所选分类
     }
   },
+  computed: {
+    nowColumns () {
+      let columns = this.columns
+      if ((this.ruleType == 'BUY_PROD_GIVE_PROD') || (this.ruleType == 'BUY_PROD_GIVE_MONEY')) { //  买产品送产品/买产品送采购额
+        if (this.goodsType == 'normal') { //  正品
+          columns = this.columns
+        } else if (this.goodsType == 'promo') { //  促销
+          columns = this.promoColumns
+        }
+      } else if (this.ruleType == 'PROMO_PROD') { //  特价产品
+        if (this.goodsType == 'promo') { //  促销
+          columns = this.promoSpecialColumns
+        }
+      } else if (this.ruleType == 'ADD_PRICE_PURCH') { //  加价换购
+        if (this.goodsType == 'normal') { //  正品
+          columns = this.columns
+        } else if (this.goodsType == 'promo') { //  促销
+          columns = this.promoSpecialColumns
+        }
+      }
+      return columns
+    }
+  },
   methods: {
     // 选择产品
     choosePModal (type) {
@@ -200,19 +252,16 @@ export default {
     },
     // 品牌
     handleBrandOk (obj) {
-      console.log('接收----品牌----', obj)
       this.chooseBrand = obj
       this.changeData()
     },
     // 产品
     handleProductsOk (obj) {
-      console.log('接收----产品----', obj)
       this.chooseProducts = obj
       this.changeData()
     },
     // 分类
     handleTypeOk (obj) {
-      console.log('接收----分类----', obj)
       this.chooseType = obj
       this.changeData()
     },
@@ -220,16 +269,30 @@ export default {
     handleSave () {
       const _this = this
       const arr = []
-      _this.loadData.map((item, index) => {
-        if ((item.orderGoodsUnit == 'PROD_UNIT') && (!item.orderGoodsQty)) {
-          arr.push(index)
+      if (this.goodsType == 'normal') { //  正品
+        _this.loadData.map((item, index) => {
+          if ((item.orderGoodsUnit == 'PROD_UNIT') && (!item.orderGoodsQty)) {
+            arr.push(index)
+          }
+        })
+        if (arr.length > 0) {
+          this.$message.warning('请完善起订量限制后再保存!')
+          return
+        }
+      } else if (this.goodsType == 'promo') { //  促销
+        let num = 0
+        if ((this.ruleType == 'PROMO_PROD') || (this.ruleType == 'ADD_PRICE_PURCH')) { //  特价产品 / 加价换购
+          _this.loadData.map((item, index) => {
+            if (!item.goodsPrice) {
+              num++
+            }
+          })
+          if (num > 0) {
+            this.$message.warning('存在未填写的内容,请填写完整后再提交!')
+            return
+          }
         }
-      })
-      if (arr.length > 0) {
-        this.$message.warning('请完善起订量限制后再保存!')
-        return
       }
-      console.log('liebiao', this.loadData)
       this.$emit('ok', this.loadData)
       this.isShow = false
     },
@@ -238,40 +301,46 @@ export default {
       _this.loadData = []
       if (_this.chooseBrand.length > 0) {
         _this.chooseBrand.map(item => {
-          _this.loadData.push({
+          const obj = {
             goodsType: 'brand',
             goodsTypeName: '品牌',
             typeName: item.brandName,
             goodsSn: item.brandSn,
             orderGoodsUnit: undefined,
             orderGoodsQty: ''
-          })
+          }
+          delete item.id
+          _this.loadData.push(Object.assign(obj, item))
         })
       }
       if (_this.chooseType.length > 0) {
         _this.chooseType.map(item => {
-          _this.loadData.push({
-            goodsType: 'type',
+          const obj = {
+            goodsType: 'type_' + item.productTypeLevel,
             goodsTypeName: (item.productTypeLevel == 1 ? '一级' : item.productTypeLevel == 2 ? '二级' : item.productTypeLevel == 3 ? '三级' : '') + '分类',
             typeName: item.productTypeName,
             goodsSn: item.productTypeSn,
             orderGoodsUnit: undefined,
             orderGoodsQty: ''
-          })
+          }
+          delete item.id
+          _this.loadData.push(Object.assign(obj, item))
         })
       }
       if (_this.chooseProducts.length > 0) {
         _this.chooseProducts.map(item => {
-          _this.loadData.push({
+          const obj = {
             goodsType: 'product',
             goodsTypeName: '产品',
             typeName: item.name,
             name: item.name,
-            code: item.code,
+            goodsCode: item.code,
             goodsSn: item.productSn,
             orderGoodsUnit: undefined,
             orderGoodsQty: ''
-          })
+          }
+          delete item.id
+          _this.loadData.push(Object.assign(obj, item))
         })
       }
     },
@@ -282,6 +351,10 @@ export default {
         this.$message.warning('请选择需要批量复制的选项值后再操作!')
         return
       }
+      if (this.loadData.length == 0) {
+        this.$message.warning('请选择需要批量复制的产品后再操作!')
+        return
+      }
       this.$confirm({
         title: '提示',
         content: '批量复制会覆盖原单独设置的规则,确定要批量复制吗?',
@@ -310,6 +383,8 @@ export default {
         this.chooseBrand = []
         this.chooseProducts = []
         this.chooseType = []
+        this.orderGoodsUnit = undefined //  起订量限制 批量
+        this.orderGoodsQty = '' //  限制数量
         this.$emit('close')
       }
     },
@@ -335,10 +410,17 @@ export default {
         background-color: #fafafa;
         border-radius: 6px;
         margin: 10px 0;
-        display: flex;
-        justify-content: space-between;
-        .products-operation{
-          width: 50%;
+        .header-con{
+          display: flex;
+          justify-content: space-between;
+          .products-operation{
+            width: 50%;
+          }
+        }
+        p{
+          margin: 8px 0 0;
+          color: #909399;
+          font-size: 12px;
         }
       }
       .btn-con{

+ 67 - 1
src/views/promotionRulesManagement/promotionRules/detail.vue

@@ -1,8 +1,74 @@
 <template>
+  <div class="promotionRulesDetail-wrap">
+    <a-page-header :ghost="false" :backIcon="false" class="promotionRulesDetail-back" >
+      <!-- 自定义的二级文字标题 -->
+      <template slot="subTitle">
+        <a id="promotionRulesDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
+      </template>
+    </a-page-header>
+    <a-card size="small" :bordered="false" class="promotionRulesDetail-wrap">
+      <a-descriptions bordered :column="2" v-if="detailsData">
+        <a-descriptions-item label="活动名称:">{{ detailsData.name || '--' }}</a-descriptions-item>
+        <a-descriptions-item label="活动时间:">
+          <span v-if="detailsData.activeDateEnable=='0'">不限</span>
+          <span v-else>{{ detailsData.activeDateStart }} ~ {{ detailsData.activeDateEnd }}</span>
+        </a-descriptions-item>
+        <a-descriptions-item label="参与客户:">
+          <span v-if="detailsData.buyerLimitEnable=='0'">全部客户</span>
+          <p v-else style="margin: 0;">部分客户,共{{ detailsData.promoBuyerList.length }}个  <a-button id="promotionRules-rule-normalGoodsList" type="primary" size="small" class="button-success" @click="handleLook">查看</a-button></p>
+        </a-descriptions-item>
+        <a-descriptions-item label="活动经费上限:">
+          <span v-if="detailsData.activeAmountEnable=='0'">不限</span>
+          <span v-else>{{ detailsData.activeAmount }} 万元</span>
+        </a-descriptions-item>
+        <a-descriptions-item label="订单起订金额:">
+          <span v-if="detailsData.orderAmountEnable=='0'">不限</span>
+          <span v-else>{{ detailsData.orderAmount }} 万元</span>
+        </a-descriptions-item>
+        <a-descriptions-item label="备注:">{{ detailsData.remark || '--' }}</a-descriptions-item>
+      </a-descriptions>
+      <a-divider />
+    </a-card>
+  </div>
 </template>
 
 <script>
+import { promoActiveDetailD } from '@/api/promoActive'
+export default {
+  data () {
+    return {
+      detailsData: null
+    }
+  },
+  methods: {
+    //  详情
+    getDetail () {
+      const _this = this
+      promoActiveDetailD({ sn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          _this.detailsData = res.data
+        }
+      })
+    },
+    // 查看客户
+    handleLook () {},
+    //  返回列表
+    handleBack () {
+      this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {
+      vm.getDetail()
+    })
+  }
+}
 </script>
 
-<style>
+<style lang="less" scoped>
+  .promotionRulesDetail-wrap{
+    .promotionRulesDetail-back{
+      margin-bottom: 15px;
+    }
+  }
 </style>

+ 50 - 6
src/views/promotionRulesManagement/promotionRules/editRuleModal.vue

@@ -4,7 +4,7 @@
     class="promotionRules-rule-modal"
     :footer="null"
     :maskClosable="false"
-    title="新增"
+    :title="itemSn ? '编辑':'新增'"
     v-model="isShow"
     @cancle="isShow = false"
     width="80%">
@@ -176,15 +176,19 @@
 <script>
 import { VSelect } from '@/components'
 import ChoosePriceProductsModal from './choosePriceProductsModal.vue'
-import { promoRuleSave } from '@/api/promoRule'
+import { promoRuleSave, promoRuleDetailD } from '@/api/promoRule'
 export default {
-  name: 'StoreTransferOutBasicInfoModal',
+  name: 'EditRuleModalModal',
   components: { VSelect, ChoosePriceProductsModal },
   props: {
     openModal: {
       //  弹框显示状态
       type: Boolean,
       default: false
+    },
+    itemSn: {
+      type: String || Number,
+      default: ''
     }
   },
   data () {
@@ -211,8 +215,14 @@ export default {
         promoQty: [{ required: true, message: '请输入促销品数量', trigger: 'blur' }],
         orderRuleType: [{ required: true, message: '请选择促销方式', trigger: 'change' }],
         orderAmount: [{ required: true, message: '请输入正价品金额', trigger: 'blur' }],
-        promoAmount: [{ required: true, message: '请输入采购额', trigger: 'blur' }],
-        promoAmountPer: [{ required: true, message: '请输入百分比', trigger: 'blur' }],
+        promoAmount: [
+          // { required: true, message: '请输入采购额', trigger: 'blur' },
+          { validator: this.promoAmountValidator }
+        ],
+        promoAmountPer: [
+          // { required: true, message: '请输入百分比', trigger: 'blur' }
+          { validator: this.promoAmountPerValidator }
+        ],
         normalGoodsList: [{ required: true, message: '请选择正价品', trigger: 'change' }],
         promoGoodsList: [{ required: true, message: '请选择促销品', trigger: 'change' }]
       },
@@ -239,17 +249,47 @@ export default {
     }
   },
   methods: {
+    // 详情
+    getDetail () {
+      promoRuleDetailD({ sn: this.itemSn }).then(res => {
+        if (res.status == 200) {
+          const data = res.data
+          this.form = Object.assign(this.form, data)
+        }
+      })
+    },
+    //  采购额百分比自定义校验
+    promoAmountValidator (rule, value, callback) {
+      if (this.form.orderRuleType == 'prod_qty' && !value) {
+        callback(new Error('请输入采购额'))
+      } else {
+        callback()
+      }
+    },
+    //  采购额百分比自定义校验
+    promoAmountPerValidator (rule, value, callback) {
+      if (this.form.orderRuleType == 'order_amount' && !value) {
+        callback(new Error('请输入百分比'))
+      } else {
+        callback()
+      }
+    },
     //  保存
     handleSave () {
       const _this = this
       //  处理表单校验
       _this.form.normalGoodsList = this.normalGoodsList.length > 0 ? 'a' : ''
       _this.form.promoGoodsList = this.promoGoodsList.length > 0 ? 'a' : ''
+      console.log(this.form)
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           form.normalGoodsList = this.normalGoodsList
           form.promoGoodsList = this.promoGoodsList
+          form.promoActiveSn = this.$route.params.sn
+          if (form.promoRuleType == 'BUY_PROD_GIVE_MONEY' && form.orderRuleType == 'order_amount') { //  买产品送采购额  百分比
+            form.promoAmountPer = Number(form.promoAmountPer) / 100
+          }
           promoRuleSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
@@ -266,7 +306,6 @@ export default {
       })
     },
     handleOk (obj) {
-      console.log('已选产品-----', obj)
       if (this.nowChooseGoodsType == 'normal') { // 正价品
         this.normalGoodsList = obj
       } else if (this.nowChooseGoodsType == 'promo') { // 促销品
@@ -309,6 +348,11 @@ export default {
         this.$emit('close')
         this.$refs.ruleForm.resetFields()
       }
+    },
+    itemSn (newValue, oldValue) {
+	  if (this.isShow && newValue) {
+	    this.getDetail()
+	  }
     }
   }
 }

+ 10 - 6
src/views/promotionRulesManagement/promotionRules/list.vue

@@ -88,7 +88,7 @@
       </template>
     </s-table>
     <!-- 新增 -->
-    <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
+    <basic-info-modal :openModal="openModal" :itemSn="itemSn" @ok="handleOk" @close="closeModal" />
   </a-card>
 </template>
 
@@ -152,7 +152,7 @@ export default {
       },
       total: 0, //  总条数
       openModal: false, //  弹框
-      itemId: '' //  当前产品id
+      itemSn: '' //  当前sn
     }
   },
   methods: {
@@ -169,17 +169,21 @@ export default {
     },
     //  编辑
     handleEdit (row) {
-      this.$router.push({ path: `/promotionRulesManagement/promotionRules/edit/${row.promoActiveSn}` })
+      this.itemSn = row.promoActiveSn
+      this.openModal = true
     },
     //  基本信息  保存
     handleOk (data) {
       this.$refs.table.refresh(true)
-      // this.$router.push({ path: `/promotionRulesManagement/promotionRules/rule/${data.id}/${data.storeCallOutSn}` })
+    },
+    // 关闭弹框
+    closeModal () {
+      this.itemSn = ''
+      this.openModal = false
     },
     //  详情
     handleDetail (row) {
-      this.itemId = row.id
-      this.openModal = true
+      this.$router.push({ path: `/promotionRulesManagement/promotionRules/detail/${row.id}/${row.promoActiveSn}` })
     },
     // 规则设置
     handleRule (row) {

+ 79 - 54
src/views/promotionRulesManagement/promotionRules/rule.vue

@@ -1,45 +1,53 @@
 <template>
-  <a-card size="small" :bordered="false" class="promotionRulesList-rule-wrap">
-    <!-- 操作按钮 -->
-    <div class="table-operator">
-      <a-button id="promotionRulesList-rule-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
-    </div>
-    <!-- 列表 -->
-    <s-table
-      class="sTable"
-      ref="table"
-      size="default"
-      :rowKey="(record) => record.id"
-      :columns="columns"
-      :data="loadData"
-      :showPagination="false"
-      :scroll="{ x: 1440, y: tableHeight }"
-      bordered>
-      <!-- 操作 -->
-      <template slot="action" slot-scope="text, record">
-        <a-button
-          size="small"
-          type="link"
-          class="button-info"
-          @click="handleEdit(record)"
-          id="promotionRulesList-rule-edit-btn">编辑</a-button>
-        <a-button
-          size="small"
-          type="link"
-          class="button-success"
-          @click="handleDetail(record)"
-          id="promotionRulesList-rule-detail-btn">详情</a-button>
-        <a-button
-          size="small"
-          type="link"
-          class="button-error"
-          @click="handleDel(record)"
-          id="promotionRulesList-rule-del-btn">删除</a-button>
+  <div class="promotionRulesList-rule-wrap">
+    <a-page-header :ghost="false" :backIcon="false" class="promotionRulesList-rule-back" >
+      <!-- 自定义的二级文字标题 -->
+      <template slot="subTitle">
+        <a id="promotionRulesList-rule-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
       </template>
-    </s-table>
-    <!-- 新增/编辑 -->
-    <edit-rule-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
-  </a-card>
+    </a-page-header>
+    <a-card size="small" :bordered="false" class="promotionRulesList-rule-wrap">
+      <!-- 操作按钮 -->
+      <div class="table-operator">
+        <a-button id="promotionRulesList-rule-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
+      </div>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="default"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        :showPagination="false"
+        :scroll="{ y: tableHeight }"
+        bordered>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record">
+          <a-button
+            size="small"
+            type="link"
+            class="button-info"
+            @click="handleEdit(record)"
+            id="promotionRulesList-rule-edit-btn">编辑</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-success"
+            @click="handleDetail(record)"
+            id="promotionRulesList-rule-detail-btn">详情</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-error"
+            @click="handleDel(record)"
+            id="promotionRulesList-rule-del-btn">删除</a-button>
+        </template>
+      </s-table>
+      <!-- 新增/编辑 -->
+      <edit-rule-modal :openModal="openModal" :itemSn="itemSn" @ok="handleOk" @close="openModal=false" />
+    </a-card>
+  </div>
 </template>
 
 <script>
@@ -50,23 +58,13 @@ export default {
   components: { STable, VSelect, editRuleModal },
   data () {
     return {
-      createDate: [], //  创建时间
-      dateFormat: 'YYYY-MM-DD',
       tableHeight: 0,
-      queryParam: { //  查询条件
-        name: '', //  名称
-        enabledFlag: undefined //  状态
-      },
       disabled: false, //  查询、重置按钮是否可操作
-      exportLoading: false, // 导出loading
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
-        { title: '促销名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '促销时间', scopedSlots: { customRender: 'activeDate' }, width: 200, align: 'center' },
-        { title: '参与客户', dataIndex: 'promoBuyerName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '备注', dataIndex: 'remark', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '状态', scopedSlots: { customRender: 'enabledFlag' }, width: 140, align: 'center', fixed: 'right' },
+        { title: '促销类型', dataIndex: 'promoRuleTypeDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销规则', dataIndex: 'promoRule', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
@@ -77,17 +75,33 @@ export default {
         }
         return promoRuleQueryList({ promoActiveSn: this.$route.params.sn }).then(res => {
           const data = res.data
+          for (var i = 0; i < data.length; i++) {
+            data[i].no = i + 1
+            if (data[i].promoRuleType == 'BUY_PROD_GIVE_PROD') { //  买产品送产品
+              data[i].promoRule = '购买满' + data[i].orderGoodsQty + '正价产品,送' + data[i].promoQty + '促销品'
+            } else if (data[i].promoRuleType == 'BUY_PROD_GIVE_MONEY') { //  买产品送采购额
+              if (data[i].orderRuleType == 'prod_qty') {
+                data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品,送' + data[i].promoAmount + '元采购额可用于购买促销品'
+              } else if (data[i].orderRuleType == 'order_amount') {
+                data[i].promoRule = '购买满' + data[i].orderAmount + '元正价产品可以返正价产品采购额的' + data[i].promoAmountPer * 100 + '%用于购买促销品'
+              }
+            } else if (data[i].promoRuleType == 'ADD_PRICE_PURCH') { //  加价换购
+              data[i].promoRule = '购买满' + data[i].orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
+            }
+          }
           this.disabled = false
           return data
         })
       },
-      openModal: false // 弹框
+      openModal: false, // 弹框
+      itemSn: '' //  当前sn
     }
   },
   methods: {
     //  编辑
     handleEdit (row) {
-      this.$router.push({ path: `/promotionRulesManagement/promotionRules/edit/${row.id}` })
+      this.itemSn = row.promoRuleSn
+      this.openModal = true
     },
     handleOk (data) {
       this.$refs.table.refresh(true)
@@ -96,7 +110,18 @@ export default {
     handleDetail (row) {
       this.itemId = row.id
       this.openModal = true
+    },
+    //  返回列表
+    handleBack () {
+      this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })
     }
   }
 }
 </script>
+<style lang="less" scoped>
+  .promotionRulesList-rule-wrap{
+    .promotionRulesList-rule-back{
+      margin-bottom: 15px;
+    }
+  }
+</style>