lilei 7 months ago
parent
commit
dd39cf7578
1 changed files with 113 additions and 102 deletions
  1. 113 102
      src/views/salesManagement/salesQueryNew/comps/activeStatisticsList.vue

+ 113 - 102
src/views/salesManagement/salesQueryNew/comps/activeStatisticsList.vue

@@ -39,7 +39,7 @@ import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detai
 import totalProductDetailModal from './totalProductDetailModal.vue'
 import normalProductDetailModal from './normalProductDetailModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
-import { salesPromoDetailCount, salesDisablePromo, salesEnablePromoPromo, salesBatchInsert, importBorrowTotalProduct } from '@/api/salesDetailNew'
+import { salesDisablePromo, salesEnablePromoPromo, salesBatchInsert, importBorrowTotalProduct } from '@/api/salesDetailNew'
 export default {
   mixins: [commonMixin],
   components: { detailModal, ImportGuideModal, totalProductDetailModal, normalProductDetailModal },
@@ -71,6 +71,10 @@ export default {
   },
   data () {
     const _this = this
+    // 格式化数字金额单元格
+    const formatTd = (row, column, rowIndex, uniKey, fun) => {
+      return (<div><span onClick={() => fun ? fun(row) : false}>{row[column.field]}</span><span style="font-size:10px;zoom:0.7;margin-left:3px;">{row[uniKey]}</span></div>)
+    }
     return {
       hasInit: false,
       spinning: false,
@@ -174,28 +178,31 @@ export default {
           }
         },
         {
-          title: '门槛产品(数量/金额)',
+          title: '门槛产品(数量金额)',
           children: [
             {
-              field: 'col2',
+              field: 'gateSelected',
               key: 'b',
               title: '已选',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
             },
             {
-              field: 'col3',
+              field: 'gateTotal',
               key: 'c',
               title: '累计',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
             },
             {
-              field: 'col4',
+              field: 'geteBalance',
               key: 'e',
               title: '差额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'gateUnit')
             }
           ]
         },
@@ -203,35 +210,36 @@ export default {
           title: '正价产品(数量/金额)',
           children: [
             {
-              field: 'col6',
+              field: 'regularSelected',
               key: 'f',
               title: '配额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
             },
             {
-              field: 'col7',
+              field: 'regularSelected',
               key: 'g',
               title: '已选',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
             },
             {
-              field: 'col8',
+              field: 'regularTotal',
               key: 'k',
               title: '累计',
               width: 50,
               align: 'center',
-              renderBodyCell: ({ row, column, rowIndex }, h) => {
-                return (<span onClick={() => _this.openTotalProduct(row)}>{row[column.field]}</span>)
-              }
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit', _this.openTotalProduct)
             },
             {
-              field: 'col9',
+              field: 'regularBalance',
               key: 'l',
               title: '差额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'regularUnit')
             }
           ]
         },
@@ -239,25 +247,28 @@ export default {
           title: '促销品(数量)',
           children: [
             {
-              field: 'col11',
+              field: 'promoLimit',
               key: 'z',
               title: '额度',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
             },
             {
-              field: 'col12',
+              field: 'promoSelected',
               key: 'x',
               title: '已选',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
             },
             {
-              field: 'col13',
+              field: 'promoBalance',
               key: 'v',
               title: '差额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'promoUnit')
             }
           ]
         },
@@ -265,32 +276,36 @@ export default {
           title: '采购额(金额)',
           children: [
             {
-              field: 'totalUsePromoGiftsAmount',
+              field: 'purchaseLimit',
               key: 'm',
               title: '额度',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
             },
             {
-              field: 'totalPromoGiftsAmount',
+              field: 'purchaseSelected',
               key: 'n',
               title: '已选',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
             },
             {
-              field: 'cgejyAmount',
+              field: 'purchaseSurplus',
               key: 'kq',
               title: '结余',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
             },
             {
-              field: 'cgeccAmount',
+              field: 'purchaseOverspend',
               key: 'jw',
               title: '超支',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'purchaseUnit')
             }
           ]
         },
@@ -298,25 +313,28 @@ export default {
           title: '特价产品(数量/金额)',
           children: [
             {
-              field: 'col18',
+              field: 'specialPriceQuota',
               key: 'mpe',
               title: '配额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'specialPriceUnit')
             },
             {
-              field: 'col19',
+              field: 'specialPriceSelected',
               key: 'nyx',
               title: '已选',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'specialPriceUnit')
             },
             {
-              field: 'col20',
+              field: 'specialPriceBalance',
               key: 'jce',
               title: '差额',
               width: 50,
-              align: 'center'
+              align: 'center',
+              renderBodyCell: ({ row, column, rowIndex }, h) => formatTd(row, column, rowIndex, 'specialPriceUnit')
             }
           ]
         },
@@ -412,38 +430,67 @@ export default {
       this.hasInit = true
       for (let i = 0; i < this.activeList.length; i++) {
         const item = this.activeList[i]
-        let acTotal = {}
-        // 启用的活动数据获取统计信息
-        if (item.enabledFlag == 1) {
-          // 参数
-          const activeParams = {
-            salesBillSn: this.salesBillSn,
-            warehouseSn: this.warehouseSn,
-            promotionFlag: undefined,
-            promoRuleSn: item.promoRuleSn,
-            promoSn: item.promoSn,
-            salesPromoSn: item.salesPromoSn
-          }
-          // 获取活动产品统计
-          acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
-          console.log(acTotal, 'acTotal')
-          if (acTotal) {
-            // 采购额结余
-            acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
-            // 采购额超出
-            acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
-          }
-        } else {
-          // 禁用活动不显示
-          delete item.totalPromoGiftsAmount
-          delete item.totalUsePromoGiftsAmount
-        }
+        // 门槛统计
+        const isYuan = item.gateRuleUnit == 'YUAN'
+        const gateUnit = isYuan ? '元' : '个' // 单位
+        const gateSelected = isYuan ? item.gateTotalAmount : item.gateTotalQty // 已选
+        const gateTotal = isYuan ? item.gateBorrowAmount : item.gateBorrowQty // 累计
+        const gateQuota = isYuan ? item.gateQuotaAmount : item.gateQuotaQty // 配额
+        const geteBalance = gateQuota ? gateQuota - (gateSelected + gateTotal) : '-' // 差额 = 配额 - 已选 - 累计
+        // 正价统计
+        const isYuan1 = item.regularRuleUnit == 'YUAN'
+        const regularUnit = isYuan1 ? '元' : '个' // 单位
+        const regularSelected = isYuan1 ? item.regularTotalAmount : item.regularTotalQty // 已选
+        const regularTotal = isYuan1 ? item.regularBorrowAmount : item.regularBorrowQty // 累计
+        const regularBalance = (isYuan1 ? item.regularQuotaAmount || 0 : item.regularQuotaQty || 0) - (regularSelected + regularTotal) // 差额 = 配额 - 已选 - 累计
+        // 促销品
+        const promoUnit = '个'
+        const promoLimit = 0 // 额度
+        const promoSelected = 0 // 已选
+        const promoBalance = promoLimit - promoSelected // 差额 = 额度 - 已选
+        // 采购额
+        const purchaseUnit = '元'
+        const purchaseLimit = item.totalPromoGiftsAmount // 额度
+        const purchaseSelected = item.totalUsePromoGiftsAmount // 已选
+        const purchaseSurplus = (purchaseLimit - purchaseSelected) || '-' // 结余
+        const purchaseOverspend = (purchaseSelected - purchaseLimit) || '-' // 超支
+        // 特价产品
+        const isYuan2 = item.specialPriceUnit == 'YUAN'
+        const specialPriceUnit = isYuan2 ? '元' : '个' // 单位
+        const specialPriceQuota = (isYuan2 ? item.specialPriceQuotaAmount : item.specialPriceQuotaQty) || 0 // 配额
+        const specialPriceSelected = isYuan2 ? item.specialPriceTotalAmount : item.specialPriceTotalQty || 0 // 已选
+        const specialPriceBalance = specialPriceQuota - specialPriceSelected || 0// 差额 = 配额 - 已选 - 累计
+
+        // 促销品
         this.tableData.push({
           ...item,
           promotionRuleType: item.promotionRule.promotionRuleTypeDictValue,
           promotionRuleDesc: item.promotionRule.description,
-          ...acTotal,
-          countData: acTotal
+          // 门槛
+          gateUnit, // 单位
+          gateSelected, // 已选
+          gateTotal, // 累计
+          geteBalance, // 差额 = 配额 - 已选 - 累计
+          // 正价
+          regularUnit, // 单位
+          regularSelected, // 已选
+          regularTotal, // 累计
+          regularBalance, // 差额 = 配额 - 已选 - 累计
+          // 促销品
+          promoUnit, // 单位
+          promoLimit, // 额度
+          promoSelected, // 已选
+          promoBalance, // 差额 = 额度 - 已选
+          // 采购额
+          purchaseLimit, // 额度
+          purchaseSelected, // 已选
+          purchaseSurplus, // 结余
+          purchaseOverspend, // 超支
+          // 特价产品
+          specialPriceUnit, // 单位
+          specialPriceQuota, // 配额
+          specialPriceSelected, // 已选
+          specialPriceBalance // 差额
         })
       }
     },
@@ -453,44 +500,8 @@ export default {
       // 刷新产品列表
       this.$emit('refash', '')
       const active = this.activeList.find(k => k.id == item.id)
-      const index = this.tableData.findIndex(k => k.id == item.id)
       active.enabledFlag = enable
       console.log(enable, 'enable')
-      // 如果是启用
-      if (enable == 1) {
-      // 参数
-        const activeParams = {
-          salesBillSn: this.salesBillSn,
-          warehouseSn: this.warehouseSn,
-          promotionFlag: undefined,
-          promoRuleSn: item.promoRuleSn,
-          promoSn: item.promoSn,
-          salesPromoSn: item.salesPromoSn
-        }
-        salesPromoDetailCount(activeParams).then(res => {
-          const acTotal = res.data
-          if (acTotal) {
-          // 采购额结余
-            acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
-            // 采购额超出
-            acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
-          }
-          this.tableData[index] = {
-            ...active,
-            promotionRuleType: active.promotionRule.promotionRuleTypeDictValue,
-            promotionRuleDesc: active.promotionRule.description,
-            ...acTotal,
-            countData: acTotal
-          }
-          this.tableData.splice()
-        })
-      } else {
-        // 禁用活动不显示
-        this.tableData[index] = active
-        this.tableData[index].totalPromoGiftsAmount = undefined
-        this.tableData[index].totalUsePromoGiftsAmount = undefined
-        this.tableData.splice()
-      }
     },
     // 启用规则
     enabledActive (item) {