Ver código fonte

对接促销规则

chenrui 4 anos atrás
pai
commit
120f0f49d2

+ 5 - 5
src/views/promotionRulesManagement/promotionRules/choosePriceProductsModal.vue

@@ -170,7 +170,7 @@ export default {
       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: 'goodsName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { 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: 'orderGoodsUnit' }, width: 400, align: 'center' },
@@ -179,7 +179,7 @@ export default {
       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: 'goodsName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { 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' }
@@ -304,7 +304,7 @@ export default {
           const obj = {
             goodsType: 'brand',
             goodsTypeName: '品牌',
-            typeName: item.brandName,
+            goodsName: item.brandName,
             goodsSn: item.brandSn,
             orderGoodsUnit: undefined,
             orderGoodsQty: ''
@@ -318,7 +318,7 @@ export default {
           const obj = {
             goodsType: 'type_' + item.productTypeLevel,
             goodsTypeName: (item.productTypeLevel == 1 ? '一级' : item.productTypeLevel == 2 ? '二级' : item.productTypeLevel == 3 ? '三级' : '') + '分类',
-            typeName: item.productTypeName,
+            goodsName: item.productTypeName,
             goodsSn: item.productTypeSn,
             orderGoodsUnit: undefined,
             orderGoodsQty: ''
@@ -332,7 +332,7 @@ export default {
           const obj = {
             goodsType: 'product',
             goodsTypeName: '产品',
-            typeName: item.name,
+            goodsName: item.name,
             name: item.name,
             goodsCode: item.code,
             goodsSn: item.productSn,

+ 162 - 3
src/views/promotionRulesManagement/promotionRules/detail.vue

@@ -15,7 +15,7 @@
         </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>
+          <p v-else style="margin: 0;">部分客户,共{{ detailsData.promoBuyerList.length }}个  <a-button id="promotionRules-rule-normalGoodsList" type="primary" size="small" class="button-success" @click="handleLook(detailsData.promoBuyerList)">查看</a-button></p>
         </a-descriptions-item>
         <a-descriptions-item label="活动经费上限:">
           <span v-if="detailsData.activeAmountEnable=='0'">不限</span>
@@ -28,7 +28,70 @@
         <a-descriptions-item label="备注:">{{ detailsData.remark || '--' }}</a-descriptions-item>
       </a-descriptions>
       <a-divider />
+      <!-- 列表 -->
+      <p style="font-weight: bold;">促销规则:</p>
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data-source="promoRuleList"
+        :pagination="false"
+        bordered>
+        <!-- 操作 -->
+        <template slot="action" slot-scope="text, record">
+          <a-button
+            v-if="record.promoRuleType!='PROMO_PROD'"
+            size="small"
+            type="link"
+            class="button-info"
+            @click="handleLookP(record.normalGoodsList, 'normal')"
+            id="promotionRulesDetail-edit-btn">查看正价品</a-button>
+          <a-button
+            size="small"
+            type="link"
+            class="button-warning"
+            @click="handleLookP(record.promoGoodsList, 'promo')"
+            id="promotionRulesDetail-del-btn">查看{{ record.promoRuleType=='PROMO_PROD' ? '特价品' : record.promoRuleType=='ADD_PRICE_PURCH' ? '换购品' : '促销品' }}</a-button>
+        </template>
+      </a-table>
     </a-card>
+    <!-- 查看客户/正价品/促销品 -->
+    <a-modal
+      centered
+      class="promotionRulesDetail-look-modal"
+      :footer="null"
+      :maskClosable="false"
+      title="查看"
+      v-model="openModal"
+      @cancle="openModal = false"
+      width="80%">
+      <a-table
+        ref="lookTable"
+        size="small"
+        :rowKey="(record) => record.id"
+        :columns="nowColumns"
+        :data-source="lookLoadData"
+        :pagination="false"
+        bordered>
+        <!-- 序号 -->
+        <template slot="no" slot-scope="text, record, index">{{ index+1 }}</template>
+        <!-- 起订量限制 -->
+        <template slot="orderGoodsUnit" slot-scope="text, record">
+          {{ record.orderGoodsUnit=='PROD_UNIT' ? '按设置数量':record.orderGoodsUnit=='FULL_BOX' ? '按整箱':'--' }}
+          <span v-if="record.orderGoodsUnit=='PROD_UNIT'">  --  {{ record.orderGoodsQty }}</span>
+        </template>
+        <!-- 自定义表头 -->
+        <template slot="goodsPriceTit" slot-scope="text, record">
+          {{ record.orderGoodsUnit == 'PROMO_PROD' ? '特惠单价(¥)' : '换购单价(¥)' }}
+        </template>
+        <template slot="goodsPrice" slot-scope="text, record">
+          <span v-if="record.arrowFalg">{{ record.arrowFalg == 1 ? '是' : '否' }}</span>
+          <span v-else>--</span>
+        </template>
+      </a-table>
+    </a-modal>
   </div>
 </template>
 
@@ -37,7 +100,44 @@ import { promoActiveDetailD } from '@/api/promoActive'
 export default {
   data () {
     return {
-      detailsData: null
+      detailsData: null,
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
+        { 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' }
+      ],
+      loadData: [],
+      openModal: false,
+      custColumns: [
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center' },
+        { title: '客户名称', dataIndex: 'buyerName', align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      pColumns: [ //  正品
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center', fixed: 'left' },
+        { title: '类型', dataIndex: 'goodsTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'goodsName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { 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: 'orderGoodsUnit' }, align: 'center' }
+      ],
+      promoColumns: [ //  促销品
+        { title: '序号', scopedSlots: { customRender: 'no' }, width: 80, align: 'center', fixed: 'left' },
+        { title: '类型', dataIndex: 'goodsTypeName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'goodsName', width: 220, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'goodsCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      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 || '--' } },
+        { slots: { title: 'goodsPriceTit' }, scopedSlots: { customRender: 'goodsPrice' }, width: 200, align: 'center' }
+      ],
+      lookLoadData: [],
+      promoRuleList: [],
+      nowColumns: []
     }
   },
   methods: {
@@ -47,16 +147,75 @@ export default {
       promoActiveDetailD({ sn: this.$route.params.sn }).then(res => {
         if (res.status == 200) {
           _this.detailsData = res.data
+          if (_this.detailsData.promoRuleList) {
+            _this.detailsData.promoRuleList.map((item, index) => {
+              item.no = index + 1
+              if (item.promoRuleType == 'BUY_PROD_GIVE_PROD') { //  买产品送产品
+                item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,送' + item.promoQty + '个促销品'
+              } else if (item.promoRuleType == 'BUY_PROD_GIVE_MONEY') { //  买产品送采购额
+                if (item.orderRuleType == 'prod_qty') {
+                  item.promoRule = '购买满' + item.orderAmount + '元正价产品,送' + item.promoAmount + '元采购额可用于购买促销品'
+                } else if (item.orderRuleType == 'order_amount') {
+                  item.promoRule = '购买满' + item.orderAmount + '元正价产品可以返正价产品采购额的' + item.promoAmountPer * 100 + '%用于购买促销品'
+                }
+              } else if (item.promoRuleType == 'ADD_PRICE_PURCH') { //  加价换购
+                item.promoRule = '购买满' + item.orderGoodsQty + '个正价产品,可以以换购价购买任意1个换购产品'
+              }
+            })
+          } else {
+            _this.detailsData.promoRuleList = []
+          }
         }
       })
     },
     // 查看客户
-    handleLook () {},
+    handleLook (record) {
+      this.nowColumns = this.custColumns
+      this.lookLoadData = record || []
+      this.openModal = true
+    },
+    // 查看正价品/促销品
+    handleLookP (record, goodsType) {
+      let columns = this.pColumns
+      if ((record.promoRuleType == 'BUY_PROD_GIVE_PROD') || (record.promoRuleType == 'BUY_PROD_GIVE_MONEY')) { //  买产品送产品/买产品送采购额
+        if (goodsType == 'normal') { //  正品
+          columns = this.columns
+        } else if (goodsType == 'promo') { //  促销
+          columns = this.promoColumns
+        }
+      } else if (record.promoRuleType == 'PROMO_PROD') { //  特价产品
+        if (goodsType == 'promo') { //  促销
+          columns = this.promoSpecialColumns
+        }
+      } else if (record.promoRuleType == 'ADD_PRICE_PURCH') { //  加价换购
+        if (goodsType == 'normal') { //  正品
+          columns = this.columns
+        } else if (goodsType == 'promo') { //  促销
+          columns = this.promoSpecialColumns
+        }
+      }
+      record.map(item => {
+        item.name = item.goodsName
+      })
+      this.nowColumns = columns
+      this.lookLoadData = record || []
+      this.openModal = true
+    },
     //  返回列表
     handleBack () {
       this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })
     }
   },
+  watch: {
+    detailsData: {
+      handler (newValue, oldValue) {
+        if (newValue.promoRuleList) {
+          this.promoRuleList = newValue.promoRuleList
+        }
+      },
+      deep: true
+    }
+  },
   beforeRouteEnter (to, from, next) {
     next(vm => {
       vm.getDetail()

+ 32 - 16
src/views/promotionRulesManagement/promotionRules/editRuleModal.vue

@@ -37,10 +37,10 @@
               :precision="0"
               :min="1"
               :max="999999"
-              placeholder="请输入"
+              placeholder="请输入数量"
               style="width: 100%;" />
           </a-form-model-item>
-          正价产品,送
+          正价产品,送
           <a-form-model-item prop="promoQty" :label-col="{span: 0}" style="display: inline-block;">
             <a-input-number
               id="promotionRules-rule-promoQty"
@@ -48,10 +48,10 @@
               :precision="0"
               :min="1"
               :max="999999"
-              placeholder="请输入"
+              placeholder="请输入数量"
               style="width: 100%;" />
           </a-form-model-item>
-          促销品
+          促销品
         </a-form-model-item>
         <a-form-model-item label="正价产品" prop="normalGoodsList">
           <a-button id="promotionRules-rule-normalGoodsList" type="primary" class="button-success" @click="chooseProduct('normal')">选择</a-button>
@@ -68,14 +68,14 @@
           <a-radio-group v-model="form.orderRuleType" @change="radioChange">
             <a-radio value="prod_qty" style="margin-bottom: 10px;">
               购买满
-              <a-form-model-item prop="orderAmount" :label-col="{span: 0}" style="display: inline-block;">
+              <a-form-model-item prop="orderAmounts" :label-col="{span: 0}" style="display: inline-block;">
                 <a-input-number
-                  id="promotionRules-rule-orderAmount"
-                  v-model="form.orderAmount"
+                  id="promotionRules-rule-orderAmounts"
+                  v-model="form.orderAmounts"
                   :precision="2"
                   :min="0.1"
                   :max="999999"
-                  placeholder="请输入"
+                  placeholder="请输入金额"
                   style="width: 100%;" />
               </a-form-model-item>
               元正价产品,送
@@ -86,7 +86,7 @@
                   :precision="2"
                   :min="0.1"
                   :max="999999"
-                  placeholder="请输入"
+                  placeholder="请输入金额"
                   style="width: 100%;" />
               </a-form-model-item>
               元采购额可用于购买促销品
@@ -100,7 +100,7 @@
                   :precision="2"
                   :min="0.1"
                   :max="999999"
-                  placeholder="请输入"
+                  placeholder="请输入金额"
                   style="width: 100%;" />
               </a-form-model-item>
               元正价产品可以返正价产品采购额的
@@ -111,7 +111,7 @@
                   :precision="2"
                   :min="0.1"
                   :max="100"
-                  placeholder="请输入"
+                  placeholder="请输入比例"
                   style="width: 100%;" />
               </a-form-model-item>
               %用于购买促销品
@@ -144,7 +144,7 @@
             :precision="0"
             :min="1"
             :max="999999"
-            placeholder="请输入"
+            placeholder="请输入数量"
             style="width: 30%;" />
           个正价产品,可以以换购价购买任意1个换购产品
         </a-form-model-item>
@@ -203,7 +203,8 @@ export default {
         orderGoodsQty: '', //  正价品数量
         promoQty: '', //  促销品数量
         orderRuleType: undefined, //  促销设置(买产品送采购额(定额)、买产品送采购额(定比例))
-        orderAmount: '', //  正价品金额
+        orderAmounts: '', //  正价品金额   金额
+        orderAmount: '', //  正价品金额  百分比
         promoAmount: '', // 采购额
         promoAmountPer: '', // 百分比
         normalGoodsList: '', //  已选正价品
@@ -214,6 +215,7 @@ export default {
         orderGoodsQty: [{ required: true, message: '请输入正价品数量', trigger: 'blur' }],
         promoQty: [{ required: true, message: '请输入促销品数量', trigger: 'blur' }],
         orderRuleType: [{ required: true, message: '请选择促销方式', trigger: 'change' }],
+        orderAmounts: [{ required: true, message: '请输入正价品金额', trigger: 'blur' }],
         orderAmount: [{ required: true, message: '请输入正价品金额', trigger: 'blur' }],
         promoAmount: [
           // { required: true, message: '请输入采购额', trigger: 'blur' },
@@ -255,6 +257,20 @@ export default {
         if (res.status == 200) {
           const data = res.data
           this.form = Object.assign(this.form, data)
+          if (data.normalGoodsList) {
+            data.normalGoodsList.map(item => {
+              delete item.id
+              item.name = item.goodsName
+            })
+          }
+          if (data.promoGoodsList) {
+            data.promoGoodsList.map(item => {
+              delete item.id
+              item.name = item.goodsName
+            })
+          }
+          this.normalGoodsList = data.normalGoodsList || []
+          this.promoGoodsList = data.promoGoodsList || []
         }
       })
     },
@@ -350,9 +366,9 @@ export default {
       }
     },
     itemSn (newValue, oldValue) {
-	  if (this.isShow && newValue) {
-	    this.getDetail()
-	  }
+      if (this.isShow && newValue) {
+        this.getDetail()
+      }
     }
   }
 }

+ 0 - 15
src/views/promotionRulesManagement/promotionRules/list.vue

@@ -191,21 +191,6 @@ export default {
     },
     // 启用 禁用
     changeStatus (record) {
-      if (record.enabledFlag == '1') {
-        this.$confirm({
-          title: '提示',
-          content: '产品被禁用后,不能再销售,确定禁用吗?',
-          centered: true,
-          onOk: () => {
-            this.setEnable(record)
-          }
-        })
-      } else {
-        this.setEnable(record)
-      }
-    },
-    // 启用 禁用
-    setEnable (record) {
       const params = {
         sn: record.promoActiveSn,
         flag: record.enabledFlag == 1 ? '0' : '1'

+ 19 - 8
src/views/promotionRulesManagement/promotionRules/rule.vue

@@ -30,12 +30,6 @@
             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"
@@ -53,7 +47,7 @@
 <script>
 import { STable, VSelect } from '@/components'
 import editRuleModal from './editRuleModal.vue'
-import { promoRuleQueryList } from '@/api/promoRule'
+import { promoRuleQueryList, promoRuleDel } from '@/api/promoRule'
 export default {
   components: { STable, VSelect, editRuleModal },
   data () {
@@ -78,7 +72,7 @@ export default {
           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 + '促销品'
+              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 + '元采购额可用于购买促销品'
@@ -111,6 +105,23 @@ export default {
       this.itemId = row.id
       this.openModal = true
     },
+    // 删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '确认要删除吗?',
+        centered: true,
+        onOk () {
+          promoRuleDel({ sn: row.promoRuleSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    },
     //  返回列表
     handleBack () {
       this.$router.push({ path: '/promotionRulesManagement/promotionRules/list' })