chenrui 4 vuotta sitten
vanhempi
commit
dd20f6c765

+ 34 - 0
src/api/promoRule.js

@@ -0,0 +1,34 @@
+import { axios } from '@/utils/request'
+
+//  优惠活动 规则 列表  无分页
+export const promoRuleQueryList = (params) => {
+  return axios({
+    url: '/promoRule/queryList',
+    data: params,
+    method: 'post'
+  })
+}
+//  优惠活动 保存
+export const promoRuleSave = (params) => {
+  return axios({
+    url: '/promoRule/save',
+    data: params,
+    method: 'post'
+  })
+}
+//  优惠活动 删除
+export const promoRuleDel = (params) => {
+  const url = `/promoRule/delete/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get'
+  })
+}
+//  优惠活动 详情
+export const promoRuleDetail = (params) => {
+  const url = `/promoRule/findBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get'
+  })
+}

+ 12 - 1
src/config/router.config.js

@@ -441,7 +441,7 @@ export const asyncRouterMap = [
                 }
               }
             ]
-          },
+          }
           // {
           //   path: '/dealerManagement/dealerRelationshipBinding',
           //   redirect: '/dealerManagement/dealerRelationshipBinding/list',
@@ -1257,6 +1257,17 @@ export const asyncRouterMap = [
                   hidden: true
                   // permission: 'B_goodsManage_edit'
                 }
+              },
+              {
+                path: 'rule/:id/:sn',
+                name: 'promotionRulesManagementRule',
+                component: () => import(/* webpackChunkName: "shop" */ '@/views/promotionRulesManagement/promotionRules/rule.vue'),
+                meta: {
+                  title: '促销规则设置',
+                  icon: 'pull-request',
+                  hidden: true
+                  // permission: 'B_goodsManage_edit'
+                }
               }
             ]
           },

+ 67 - 93
src/views/promotionRulesManagement/promotionRules/basicInfoModal.vue

@@ -30,16 +30,16 @@
             <a-select
               id="promotionRules-basicInfo-activeDateEnable"
               placeholder="请选择"
+              @change="handleChange('activeDateEnable')"
               v-model="form.activeDateEnable"
               style="width: 100%;">
               <a-select-option v-for="item in rangeList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12">
+        <a-col span="12" v-if="form.activeDateEnable==1">
           <a-form-model-item prop="activeDate">
             <a-range-picker
-              v-if="form.activeDateEnable==1"
               style="width:100%"
               id="promotionRules-basicInfo-activeDate"
               :disabledDate="disabledDate"
@@ -51,19 +51,21 @@
       </a-row>
       <a-row :gutter="15">
         <a-col span="12">
-          <a-form-model-item label="参与客户" prop="promoBuyerEnable">
+          <a-form-model-item label="参与客户" prop="buyerLimitEnable">
             <a-select
-              id="promotionRules-basicInfo-promoBuyerEnable"
+              id="promotionRules-basicInfo-buyerLimitEnable"
               placeholder="请选择"
-              v-model="form.promoBuyerEnable"
+              @change="handleChange('buyerLimitEnable')"
+              v-model="form.buyerLimitEnable"
               style="width: 100%;">
               <a-select-option v-for="item in rangeCList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12">
-          <a-form-model-item prop="promoBuyerEnable">
-            <a-button v-if="form.promoBuyerEnable==1" id="promotionRules-basicInfo-choose" type="primary" class="button-success" @click="openModal=true">选择</a-button>
+        <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>
           </a-form-model-item>
         </a-col>
       </a-row>
@@ -80,16 +82,16 @@
             <a-select
               id="promotionRules-basicInfo-activeAmountEnable"
               placeholder="请选择"
+              @change="handleChange('activeAmountEnable')"
               v-model="form.activeAmountEnable"
               style="width: 100%;">
               <a-select-option v-for="item in rangeList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12">
+        <a-col span="12" v-if="form.activeAmountEnable==1">
           <a-form-model-item prop="activeAmount">
             <a-input-number
-              v-if="form.activeAmountEnable==1"
               id="promotionRules-basicInfo-activeAmount"
               v-model="form.activeAmount"
               :min="1"
@@ -115,16 +117,16 @@
             <a-select
               id="promotionRules-basicInfo-orderAmountEnable"
               placeholder="请选择"
+              @change="handleChange('orderAmountEnable')"
               v-model="form.orderAmountEnable"
               style="width: 100%;">
               <a-select-option v-for="item in rangeList" :key="item.val" :value="item.val">{{ item.name }}</a-select-option>
             </a-select>
           </a-form-model-item>
         </a-col>
-        <a-col span="12">
+        <a-col span="12" v-if="form.orderAmountEnable==1">
           <a-form-model-item prop="orderAmount">
             <a-input-number
-              v-if="form.orderAmountEnable==1"
               id="promotionRules-basicInfo-orderAmount"
               v-model="form.orderAmount"
               :min="1"
@@ -133,12 +135,12 @@
               style="width: 85%;margin-right: 5px;"
               placeholder="请输入订单起订金额(1~999999)"
               allowClear />
-            <span v-if="form.orderAmountEnable==1">万元</span>
+            <span>万元</span>
           </a-form-model-item>
         </a-col>
       </a-row>
       <a-form-model-item label="备注" prop="remark" :label-col="{span: 4}">
-        <a-input
+        <a-textarea
           id="promotionRules-basicInfo-remark"
           :maxLength="100"
           v-model.trim="form.remark"
@@ -150,19 +152,19 @@
       <a-button type="primary" id="promotionRules-basicInfo-modal-save" @click="handleSave">保存</a-button>
       <a-button id="promotionRules-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
     </div>
+    <!-- 选择参与客户 -->
+    <choose-customer-modal :openModal="openCustomerModal" :chooseCust="chooseCust" @close="openCustomerModal=false" @ok="handleOk" />
   </a-modal>
 </template>
 
 <script>
 import moment from 'moment'
 import { VSelect } from '@/components'
-// import { storeCallOutSave } from '@/api/storeCallOut'
-// import { custAllList } from '@/api/customer'
-// import { getLookUpData } from '@/api/data'
-// import { storeCallOutTypeAllList } from '@/api/storeCallOutType'
+import chooseCustomerModal from './chooseCustomerModal'
+import { promoActiveSave } from '@/api/promoActive'
 export default {
   name: 'StoreTransferOutBasicInfoModal',
-  components: { VSelect },
+  components: { VSelect, chooseCustomerModal },
   props: {
     openModal: {
       //  弹框显示状态
@@ -179,26 +181,29 @@ export default {
       },
       form: {
         name: '',
-        activeDateEnable: undefined,  //  活动时间启用标记
+        activeDateEnable: 0, //  活动时间启用标记
         activeDate: [],
-        activeDateStart: '',  // 活动时间-开始
-        activeDateEnd: '',  // 活动时间-结束
-        promoBuyerEnable: undefined,  //  参与客户启用标记
-        activeAmountEnable: undefined,  //  活动经费启用标记
-        activeAmount: '',  // 活动经费上限
-        orderAmountEnable: undefined,  //  起订金额启用标记
-        orderAmount: '',  // 订单起订金额
+        activeDateStart: '', // 活动时间-开始
+        activeDateEnd: '', // 活动时间-结束
+        buyerLimitEnable: 0, //  参与客户启用标记
+        buyerSns: '', //  部分客户
+        activeAmountEnable: 0, //  活动经费启用标记
+        activeAmount: '', // 活动经费上限
+        orderAmountEnable: 0, //  起订金额启用标记
+        orderAmount: '', // 订单起订金额
         remark: ''
       },
       rules: {
         name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
-        activeDateEnable: [{ required: true, message: '请选择调往对象名称', trigger: 'change' }],
-        putPersonName: [{ required: true, message: '请输入调往对象名称', trigger: 'blur' }],
-        callOutType: [{ required: true, message: '请选择调拨类型', trigger: 'change' }]
+        activeDateEnable: [{ required: true, message: '请选择是否限制活动时间', trigger: 'change' }],
+        activeDate: [{ required: true, message: '请选择限制的活动时间', trigger: 'change' }],
+        buyerLimitEnable: [{ required: true, message: '请选择是否限制参与客户', trigger: 'change' }],
+        buyerSns: [{ required: true, message: '请选择参与客户', trigger: 'blur' }],
+        activeAmountEnable: [{ required: true, message: '请选择是否限制活动经费', trigger: 'change' }],
+        activeAmount: [{ required: true, message: '请输入活动经费上限', trigger: 'blur' }],
+        orderAmountEnable: [{ required: true, message: '请选择是否限制起订金额', trigger: 'change' }],
+        orderAmount: [{ required: true, message: '请输入订单起订金额', trigger: 'blur' }]
       },
-      custData: [], //  调往对象  下拉数据
-      putPersonTypeList: [], //  调往对象类型
-      storeCallOutTypeList: [], //  调拨类型
       dateFormat: 'YYYY-MM-DD',
       rangeList: [ //  是否限制
         { name: '不限', val: 0 },
@@ -208,12 +213,8 @@ export default {
         { name: '全部客户', val: 0 },
         { name: '部分客户', val: 1 }
       ],
-    }
-  },
-  computed: {
-    // 当前所选调往对象是否为客户
-    isCustomer () {
-      return this.form.putPersonType == 'CUSTOMER'
+      openCustomerModal: false,
+      chooseCust: [] //  当前已选客户
     }
   },
   methods: {
@@ -223,7 +224,15 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
-          storeCallOutSave(form).then(res => {
+          if (form.activeDate && form.activeDate.length > 0) {
+            form.activeDateStart = moment(form.activeDate[0]).format(this.dateFormat)
+            form.activeDateEnd = moment(form.activeDate[1]).format(this.dateFormat)
+          } else {
+            form.activeDateStart = undefined
+            form.activeDateEnd = undefined
+          }
+          delete form.activeDate
+          promoActiveSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
@@ -238,60 +247,29 @@ export default {
         }
       })
     },
-    // 调往对象  change
-    putPersonTypeChange (e) {
-      this.$refs.ruleForm.resetFields()
-      this.form.putPersonSn = undefined
-      this.form.putPersonName = ''
-      this.form.putPersonType = e.target.value
-    },
-    // 调往对象名称  change
-    putPersonChange (val) {
-      const ind = this.custData.findIndex(item => item.customerSn == val)
-      this.form.putPersonName = this.custData[ind].customerName
-    },
-    // 调往对象列表
-    getCustAllList () {
-      custAllList().then(res => {
-        if (res.status == 200) {
-          this.custData = res.data
-        } else {
-          this.custData = []
-        }
-      })
-    },
-    // 调往对象类型
-    getPutPersonTypeList () {
-      const _this = this
-      getLookUpData({
-        pageNo: 1,
-        pageSize: 1000,
-        lookupCode: 'PUT_PERSON_TYPE'
-      }).then(res => {
-        if (res.status == 200) {
-          _this.putPersonTypeList = res.data.list
-        } else {
-          _this.putPersonTypeList = []
-        }
-      })
-    },
-    //  调拨类型
-    getStoreCallOutTypeAllList () {
-      storeCallOutTypeAllList().then(res => {
-        if (res.status == 200) {
-          this.storeCallOutTypeList = res.data
-        } else {
-          this.storeCallOutTypeList = []
-        }
-      })
+    handleOk (obj) {
+      this.chooseCust = obj
+      this.form.buyerSns = this.chooseCust.join(',')
     },
-    filterOption (input, option) {
-      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+    // select   change
+    handleChange (val) {
+      // 数据更改为不限时需重置之前所选数据
+      if (val == 'activeDateEnable' && this.form.activeDateEnable == 0) { //  活动时间
+        this.form.activeDate = []
+        this.form.activeDateStart = ''
+        this.form.activeDateEnd = ''
+      } else if (val == 'buyerLimitEnable' && this.form.buyerLimitEnable == 0) { //  参与客户
+        this.chooseCust = []
+      } else if (val == 'activeAmountEnable' && this.form.activeAmountEnable == 0) { //  活动经费
+        this.form.activeAmount = ''
+      } else if (val == 'orderAmountEnable' && this.form.orderAmountEnable == 0) { //  起订金额
+        this.form.orderAmount = ''
+      }
     },
     // 不可选日期
     disabledDate (date, dateStrings) {
       return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
-    },
+    }
   },
   watch: {
     //  父页面传过来的弹框状态
@@ -303,10 +281,6 @@ export default {
       if (!newValue) {
         this.$emit('close')
         this.$refs.ruleForm.resetFields()
-      } else {
-        // this.getCustAllList()
-        // this.getPutPersonTypeList()
-        // this.getStoreCallOutTypeAllList()
       }
     }
   }

+ 237 - 0
src/views/promotionRulesManagement/promotionRules/chooseCustomerModal.vue

@@ -0,0 +1,237 @@
+<template>
+  <a-modal
+    centered
+    class="chooseCustomer-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="选择客户"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="900">
+    <div class="chooseCustomer-con">
+      <!-- 搜索条件 -->
+      <div class="table-page-search-wrapper">
+        <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
+            <a-col :md="6" :sm="24">
+              <a-form-item label="客户名称">
+                <a-input id="chooseCustomer-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
+              </a-form-item>
+            </a-col>
+            <a-col :md="12" :sm="24">
+              <a-row>
+                <a-form-item label="地区">
+                  <a-col span="7">
+                    <a-form-item prop="provinceSn" style="margin: 0;">
+                      <a-select v-model="queryParam.provinceSn" @change="getCityList" placeholder="请选择省">
+                        <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
+                      </a-select>
+                    </a-form-item>
+                  </a-col>
+                  <a-col span="7" offset="1">
+                    <a-form-item prop="citySn" style="margin: 0;">
+                      <a-select v-model="queryParam.citySn" @change="getAreaList" placeholder="请选择市">
+                        <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
+                      </a-select>
+                    </a-form-item>
+                  </a-col>
+                  <a-col span="7" offset="1">
+                    <a-form-item prop="countySn" style="margin: 0;">
+                      <a-select v-model="queryParam.countySn" placeholder="请选择区/县">
+                        <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
+                      </a-select>
+                    </a-form-item>
+                  </a-col>
+                </a-form-item>
+              </a-row>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="promotionRulesList-refresh">查询</a-button>
+              <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="promotionRulesList-reset">重置</a-button>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+      <p style="font-weight: bold;">当前已选:{{ selectedRowKeys.length }}个</p>
+      <!-- 列表 -->
+      <s-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data="loadData"
+        bordered>
+      </s-table>
+      <!-- 按钮 -->
+      <div class="btn-con">
+        <a-button
+          type="primary"
+          id="chooseCustomer-submit"
+          size="large"
+          class="button-primary"
+          style="padding: 0 60px;"
+          @click="handleSubmit">确定</a-button>
+        <a-button
+          id="chooseCustomer-cancel"
+          size="large"
+          class="button-cancel"
+          @click="isShow=false"
+          style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { STable } from '@/components'
+import { getArea } from '@/api/data'
+import { dealerQueryList } from '@/api/dealer'
+export default {
+  name: 'ChooseCustomerModal',
+  components: { STable },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    chooseCust: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      disabled: false, //  查询、重置按钮是否可操作
+      queryParam: {
+        dealerName: '',
+        provinceSn: undefined,
+        citySn: undefined,
+        districtSn: undefined
+      },
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
+          const 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
+          return data
+        })
+      },
+      selectedRowKeys: [],
+      addrProvinceList: [], //  省下拉
+      addrCityList: [], //  市下拉
+      addrDistrictList: [] //  区下拉
+    }
+  },
+  methods: {
+    //  重置
+    resetSearchForm () {
+      this.queryParam.dealerName = ''
+      this.queryParam.provinceSn = undefined
+      this.queryParam.citySn = undefined
+      this.queryParam.districtSn = undefined
+      this.$refs.table.refresh(true)
+    },
+    //  确定
+    handleSubmit () {
+      if (this.selectedRowKeys.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      this.$emit('ok', this.selectedRowKeys)
+      this.isShow = false
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      console.log('selectedRowKeys changed: ', selectedRowKeys, selectedRows)
+      this.selectedRowKeys = selectedRowKeys
+    },
+    // 获取城市列表
+    getCityList (val) {
+      this.addrCityList = []
+      this.addrDistrictList = []
+      this.queryParam.citySn = undefined
+      this.queryParam.districtSn = undefined
+      this.getArea('city', val)
+    },
+    // 获取区县列表
+    getAreaList (val) {
+      this.addrDistrictList = []
+      this.queryParam.districtSn = undefined
+      this.getArea('district', val)
+    },
+    //  省/市/区
+    getArea (type, sn) {
+      let params
+      if (type == 'province') {
+        params = { level: '1' }
+      } else {
+        params = { psn: sn }
+      }
+      getArea(params).then(res => {
+        if (res.status == 200) {
+          if (type == 'province') {
+            this.addrProvinceList = res.data || []
+          } else if (type == 'city') {
+            this.addrCityList = res.data || []
+          } else if (type == 'district') {
+            this.addrDistrictList = res.data || []
+          }
+        } else {
+          if (type == 'province') {
+            this.addrProvinceList = []
+          } else if (type == 'city') {
+            this.addrCityList = []
+          } else if (type == 'district') {
+            this.addrDistrictList = []
+          }
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+      } else {
+        console.log(this.selectedRowKeys, '++++', this.chooseCust)
+        this.selectedRowKeys = this.chooseCust
+        if (this.addrProvinceList.length == 0) {
+          // this.getArea('province')
+        }
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .chooseCustomer-modal{
+    .chooseCustomer-con{
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 304 - 0
src/views/promotionRulesManagement/promotionRules/editRuleModal.vue

@@ -0,0 +1,304 @@
+<template>
+  <a-modal
+    centered
+    class="promotionRules-rule-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="新增"
+    v-model="isShow"
+    @cancle="isShow = false"
+    width="80%">
+    <a-form-model
+      id="promotionRules-rule-form"
+      ref="ruleForm"
+      :model="form"
+      :rules="rules"
+      :label-col="formItemLayout.labelCol"
+      :wrapper-col="formItemLayout.wrapperCol"
+    >
+      <a-form-model-item label="促销类型" prop="promoRuleType" :extra="extra">
+        <v-select
+          code="PROMO_RULE_TYPE"
+          id="promotionRules-rule-promoRuleType"
+          v-model="form.promoRuleType"
+          allowClear
+          placeholder="请选择促销类型"
+        ></v-select>
+      </a-form-model-item>
+      <!-- 买产品送产品 -->
+      <div v-if="form.promoRuleType == 'BUY_PROD_GIVE_PROD'">
+        <a-form-model-item label="促销设置" prop="buyerLimitEnable">
+          购买满
+          <a-input-number
+            id="promotionRules-rule-outQty"
+            v-model="form.orderGoodsQty"
+            :precision="0"
+            :min="1"
+            :max="999999"
+            placeholder="请输入数量"
+            style="width: 30%;" />
+          正价产品,送
+          <a-input-number
+            id="promotionRules-rule-outQty"
+            v-model="form.promoQty"
+            :precision="0"
+            :min="1"
+            :max="999999"
+            placeholder="请输入数量"
+            style="width: 30%;" />
+          促销品
+        </a-form-model-item>
+        <a-form-model-item label="正价产品" prop="normalGoodsList">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+        <a-form-model-item label="促销品" prop="promoGoodsList">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+      </div>
+      <!-- 买产品送采购额 -->
+      <div v-if="form.promoRuleType == 'BUY_PROD_GIVE_MONEY'">
+        <a-form-model-item label="促销设置" prop="buyerLimitEnable">
+          <a-radio-group v-model="form.orderRuleType" @change="radioChange">
+            <a-radio value="prod_qty" style="margin-bottom: 10px;">
+              购买满
+              <a-input-number
+                id="promotionRules-rule-orderGoodsQty"
+                v-model="form.orderGoodsQty"
+                :precision="0"
+                :min="1"
+                :max="999999"
+                placeholder="请输入数量"
+                style="width: 30%;" />
+              元正价产品,送
+              <a-input-number
+                id="promotionRules-rule-promoAmount"
+                v-model="form.promoAmount"
+                :precision="2"
+                :min="1"
+                :max="999999"
+                placeholder="请输入金额"
+                style="width: 30%;" />
+              元采购额可用于购买促销品
+            </a-radio>
+            <a-radio value="order_amount">
+              购买满
+              <a-input-number
+                id="promotionRules-rule-orderGoodsQty"
+                v-model="form.orderGoodsQty"
+                :precision="0"
+                :min="1"
+                :max="999999"
+                placeholder="请输入数量"
+                style="width: 30%;" />
+              元正价产品可以返正价产品采购额的
+              <a-input-number
+                id="promotionRules-rule-promoAmountPer"
+                v-model="form.promoAmountPer"
+                :precision="0"
+                :min="1"
+                :max="999999"
+                placeholder="请输入数量"
+                style="width: 30%;" />
+              %用于购买促销品
+            </a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+        <a-form-model-item label="正价产品" prop="buyerLimitEnable">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+        <a-form-model-item label="促销品" prop="buyerLimitEnable">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+      </div>
+      <!-- 特价产品销售 -->
+      <div v-if="form.promoRuleType == 'PROMO_PROD'">
+        <a-form-model-item label="特价产品" prop="promoGoodsList">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+      </div>
+      <!-- 加价换购 -->
+      <div v-if="form.promoRuleType == 'ADD_PRICE_PURCH'">
+        <a-form-model-item label="加价规则" prop="buyerLimitEnable">
+          购买满
+          <a-input-number
+            id="promotionRules-rule-outQty"
+            v-model="form.outQty"
+            :precision="0"
+            :min="1"
+            :max="999999"
+            placeholder="请输入数量"
+            style="width: 30%;" />
+          个正价产品  可以以换购价购买任意1个换购产品
+        </a-form-model-item>
+        <a-form-model-item label="正价产品" prop="buyerLimitEnable">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+        <a-form-model-item label="换购产品" prop="buyerLimitEnable">
+          <a-button id="promotionRules-rule-choose" type="primary" class="button-success" @click="openCustomerModal=true">选择</a-button>
+          <span style="font-weight: bold;margin-left: 30px;">当前已选:{{ chooseCust.length }}个</span>
+        </a-form-model-item>
+      </div>
+    </a-form-model>
+    <div class="btn-cont">
+      <a-button type="primary" id="promotionRules-rule-modal-save" @click="handleSave">保存</a-button>
+      <a-button id="promotionRules-rule-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
+    </div>
+    <!-- 选择参与客户 -->
+    <choose-customer-modal :openModal="openCustomerModal" :chooseCust="chooseCust" @close="openCustomerModal=false" @ok="handleOk" />
+  </a-modal>
+</template>
+
+<script>
+import moment from 'moment'
+import { VSelect } from '@/components'
+import chooseCustomerModal from './chooseCustomerModal'
+import { promoActiveSave } from '@/api/promoActive'
+export default {
+  name: 'StoreTransferOutBasicInfoModal',
+  components: { VSelect, chooseCustomerModal },
+  props: {
+    openModal: {
+      //  弹框显示状态
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        promoRuleType: undefined
+      },
+      rules: {
+        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
+        activeDateEnable: [{ required: true, message: '请选择是否限制活动时间', trigger: 'change' }],
+        activeDate: [{ required: true, message: '请选择限制的活动时间', trigger: 'change' }],
+        buyerLimitEnable: [{ required: true, message: '请选择是否限制参与客户', trigger: 'change' }],
+        buyerSns: [{ required: true, message: '请选择参与客户', trigger: 'blur' }],
+        activeAmountEnable: [{ required: true, message: '请选择是否限制活动经费', trigger: 'change' }],
+        activeAmount: [{ required: true, message: '请输入活动经费上限', trigger: 'blur' }],
+        orderAmountEnable: [{ required: true, message: '请选择是否限制起订金额', trigger: 'change' }],
+        orderAmount: [{ required: true, message: '请输入订单起订金额', trigger: 'blur' }]
+      },
+      dateFormat: 'YYYY-MM-DD',
+      rangeList: [ //  是否限制
+        { name: '不限', val: 0 },
+        { name: '限制', val: 1 }
+      ],
+      rangeCList: [ //  是否全部
+        { name: '全部客户', val: 0 },
+        { name: '部分客户', val: 1 }
+      ],
+      openCustomerModal: false,
+      chooseCust: [] //  当前已选客户
+    }
+  },
+  computed: {
+    extra () {
+      let str = ''
+      if (this.form.promoRuleType == 'BUY_PROD_GIVE_PROD') { //  买产品送产品
+        str = '(即买正价产品送促销品,例如买刹车片送滤芯)'
+      } else if (this.form.promoRuleType == 'BUY_PROD_GIVE_MONEY') { //  买产品送采购额
+        str = '(即买正价产品送对应促销品的采购额,例如买1000元刹车片送200元滤清器采购额)'
+      } else if (this.form.promoRuleType == 'PROMO_PROD') { //  特价产品销售
+        str = '(即将产品按设置的特惠价格进行促销)'
+      } else if (this.form.promoRuleType == 'ADD_PRICE_PURCH') { //  加价换购
+        str = '(即购买其它产品时,以设置的金额可购买换购产品)'
+      }
+      return str
+    }
+  },
+  methods: {
+    //  保存
+    handleSave () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = JSON.parse(JSON.stringify(_this.form))
+          if (form.activeDate && form.activeDate.length > 0) {
+            form.activeDateStart = moment(form.activeDate[0]).format(this.dateFormat)
+            form.activeDateEnd = moment(form.activeDate[1]).format(this.dateFormat)
+          } else {
+            form.activeDateStart = undefined
+            form.activeDateEnd = undefined
+          }
+          delete form.activeDate
+          promoActiveSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              setTimeout(() => {
+                _this.isShow = false
+                _this.$emit('ok', res.data)
+              }, 1000)
+            }
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    handleOk (obj) {
+      this.chooseCust = obj
+      this.form.buyerSns = this.chooseCust.join(',')
+    },
+    // select   change
+    handleChange (val) {
+      // 数据更改为不限时需重置之前所选数据
+      if (val == 'activeDateEnable' && this.form.activeDateEnable == 0) { //  活动时间
+        this.form.activeDate = []
+        this.form.activeDateStart = ''
+        this.form.activeDateEnd = ''
+      } else if (val == 'buyerLimitEnable' && this.form.buyerLimitEnable == 0) { //  参与客户
+        this.chooseCust = []
+      } else if (val == 'activeAmountEnable' && this.form.activeAmountEnable == 0) { //  活动经费
+        this.form.activeAmount = ''
+      } else if (val == 'orderAmountEnable' && this.form.orderAmountEnable == 0) { //  起订金额
+        this.form.orderAmount = ''
+      }
+    },
+    radioChange (val) {
+
+    },
+    // 不可选日期
+    disabledDate (date, dateStrings) {
+      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+.promotionRules-rule-modal {
+	.ant-modal-body {
+		padding: 40px 40px 24px;
+	}
+	.btn-cont {
+		text-align: center;
+		margin: 35px 0 10px;
+	}
+}
+</style>

+ 54 - 45
src/views/promotionRulesManagement/promotionRules/list.vue

@@ -38,7 +38,7 @@
     </div>
     <!-- 总计 -->
     <a-alert type="info" showIcon style="margin-bottom:15px">
-      <div slot="message">合计: <strong>222</strong>条</div>
+      <div slot="message">合计: <strong>{{ total }}</strong>条</div>
     </a-alert>
     <!-- 列表 -->
     <s-table
@@ -48,11 +48,11 @@
       :rowKey="(record) => record.id"
       :columns="columns"
       :data="loadData"
-      :scroll="{ x: 1350, y: tableHeight }"
+      :scroll="{ x: 1440, y: tableHeight }"
       bordered>
-      <!-- 产品分类 -->
-      <template slot="productType" slot-scope="text, record">
-        <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
+      <!-- 促销时间 -->
+      <template slot="activeDate" slot-scope="text, record">
+        <span v-if="record.activeDateStart || record.activeDateEnd">{{ record.activeDateStart }} 至 {{ record.activeDateEnd }}</span>
         <span v-else>--</span>
       </template>
       <!-- 状态 -->
@@ -61,13 +61,18 @@
           id="promotionRulesList-enable"
           checkedChildren="启用"
           unCheckedChildren="禁用"
-          v-if="$hasPermissions('B_product_dealerProduct_enable')"
           @change="changeStatus(record)"
           :checked="record.enabledFlag == 1 ? true : false" />
-        <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span>
+        <!-- <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span> -->
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-primary"
+          @click="handleRule(record)"
+          id="promotionRulesList-rule-btn">规则设置</a-button>
         <a-button
           size="small"
           type="link"
@@ -82,18 +87,16 @@
           id="promotionRulesList-detail-btn">详情</a-button>
       </template>
     </s-table>
-    <!-- 新增/编辑 -->
+    <!-- 新增 -->
     <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
   </a-card>
 </template>
 
 <script>
 import moment from 'moment'
-// import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
-// import { dealerProductTypeList } from '@/api/dealerProductType'
 import { STable, VSelect } from '@/components'
 import basicInfoModal from './basicInfoModal.vue'
-import { promoActiveList } from '@/api/promoActive'
+import { promoActiveList, promoActiveEnable } from '@/api/promoActive'
 export default {
   components: { STable, VSelect, basicInfoModal },
   data () {
@@ -102,27 +105,19 @@ export default {
       dateFormat: 'YYYY-MM-DD',
       tableHeight: 0,
       queryParam: { //  查询条件
-        code: '', //  产品编码
-        name: '', //  产品名称
-        origCode: '', //  原厂编码
-        sysFlag: '0',
-        productBrandSn: undefined, //  产品品牌
-        productTypeSn1: '', //  产品一级分类
-        productTypeSn2: '', //  产品二级分类
-        productTypeSn3: '', //  产品三级分类
+        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: '促销时间', dataIndex: 'createsDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '参与客户', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '备注', dataIndex: 'origCode', width: 220, 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: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -130,20 +125,34 @@ export default {
         if (this.tableHeight == 0) {
           this.tableHeight = window.innerHeight - 502
         }
+        // 创建时间
+        if (this.createDate && this.createDate.length > 0) {
+          this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
+          this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
+        } else {
+          this.queryParam.beginDate = undefined
+          this.queryParam.endDate = undefined
+        }
         return promoActiveList(Object.assign(parameter, this.queryParam)).then(res => {
           const 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
+            let str = ''
+            const promoBuyerList = data.list[i].promoBuyerList ? data.list[i].promoBuyerList : []
+            promoBuyerList.map(item => {
+              str += item.buyerName
+            })
+            data.list[i].promoBuyerName = str
           }
+          this.total = data.count
           this.disabled = false
           return data
         })
       },
-      openModal: false, //  查看客户详情  弹框
-      itemId: '', //  当前产品id
-      productBrandList: [], //  品牌下拉数据
-      productTypeList: [] //  分类下拉数据
+      total: 0, //  总条数
+      openModal: false, //  弹框
+      itemId: '' //  当前产品id
     }
   },
   methods: {
@@ -160,17 +169,22 @@ export default {
     },
     //  编辑
     handleEdit (row) {
-      this.$router.push({ path: `/promotionRulesManagement/promotionRules/edit/${row.id}` })
+      this.$router.push({ path: `/promotionRulesManagement/promotionRules/edit/${row.promoActiveSn}` })
     },
     //  基本信息  保存
     handleOk (data) {
-      this.$router.push({ path: `/promotionRulesManagement/promotionRules/add/${data.id}/${data.storeCallOutSn}` })
+      this.$refs.table.refresh(true)
+      // this.$router.push({ path: `/promotionRulesManagement/promotionRules/rule/${data.id}/${data.storeCallOutSn}` })
     },
     //  详情
     handleDetail (row) {
       this.itemId = row.id
       this.openModal = true
     },
+    // 规则设置
+    handleRule (row) {
+      this.$router.push({ path: `/promotionRulesManagement/promotionRules/rule/${row.id}/${row.promoActiveSn}` })
+    },
     // 启用 禁用
     changeStatus (record) {
       if (record.enabledFlag == '1') {
@@ -189,23 +203,18 @@ export default {
     // 启用 禁用
     setEnable (record) {
       const params = {
-        id: record.id,
-        enabledFlag: record.enabledFlag == 1 ? '0' : '1'
+        sn: record.promoActiveSn,
+        flag: record.enabledFlag == 1 ? '0' : '1'
       }
-      // dealerProductUpdate(params).then(res => {
-      //   if (res.status == 200) {
-      //     this.$message.success(res.message)
-      //     this.$refs.table.refresh()
-      //   } else {
-      //     this.$refs.table.refresh()
-      //   }
-      // })
+      promoActiveEnable(params).then(res => {
+        if (res.status == 200) {
+          this.$message.success(res.message)
+          this.$refs.table.refresh()
+        } else {
+          this.$refs.table.refresh()
+        }
+      })
     }
-  },
-  beforeRouteEnter (to, from, next) {
-    next(vm => {
-
-    })
   }
 }
 </script>

+ 103 - 0
src/views/promotionRulesManagement/promotionRules/rule.vue

@@ -0,0 +1,103 @@
+<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>
+      </template>
+    </s-table>
+    <!-- 新增/编辑 -->
+    <edit-rule-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
+  </a-card>
+</template>
+
+<script>
+import { STable, VSelect } from '@/components'
+import editRuleModal from './editRuleModal.vue'
+import { promoRuleQueryList } from '@/api/promoRule'
+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: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        if (this.tableHeight == 0) {
+          this.tableHeight = window.innerHeight - 502
+        }
+        return promoRuleQueryList({ promoActiveSn: this.$route.params.sn }).then(res => {
+          const data = res.data
+          this.disabled = false
+          return data
+        })
+      },
+      openModal: false // 弹框
+    }
+  },
+  methods: {
+    //  编辑
+    handleEdit (row) {
+      this.$router.push({ path: `/promotionRulesManagement/promotionRules/edit/${row.id}` })
+    },
+    handleOk (data) {
+      this.$refs.table.refresh(true)
+      // this.$router.push({ path: `/promotionRulesManagement/promotionRules/add/${data.id}/${data.storeCallOutSn}` })
+    },
+    //  详情
+    handleDetail (row) {
+      this.itemId = row.id
+      this.openModal = true
+    }
+  }
+}
+</script>