lilei há 2 dias atrás
pai
commit
55651b44d3

+ 11 - 6
src/views/reportData/promotionSalesRealTimeReport/index.vue

@@ -258,23 +258,28 @@ export default {
       exportLoading: false, // 导出按钮加载状态
       showExport: false, // 导出弹窗
       columns: [
-        { title: '促销名称', dataIndex: 'promotion.title', width: '160px', align: 'left', customRender: function (text) { return text || '--' }, fixed: 'left', ellipsis: true },
-        { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '130px', align: 'center', fixed: 'left' },
-        { title: '费用所属部门', dataIndex: 'departmentName', width: '160px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true, fixed: 'left' },
-        { title: '促销类型', dataIndex: 'promotionRule.promotionRuleTypeDictValue', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '规则', dataIndex: 'promotionRule.ruleInfo', width: '180px', align: 'left', scopedSlots: { customRender: 'promotionDesc' }, fixed: 'left' },
-        { title: '销售单号', dataIndex: 'salesBillNo', width: '120px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
+        { title: '销售单号', dataIndex: 'salesBillNo', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '地区', dataIndex: 'provinceName', width: '160px', align: 'center', scopedSlots: { customRender: 'addressInfo' } },
         { title: '客户名称', dataIndex: 'buyerName', width: '140px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '客户级别', dataIndex: 'buyerLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '销售审核时间', dataIndex: 'auditDate', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销名称', dataIndex: 'promotion.title', width: '160px', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '130px', align: 'center' },
+        { title: '费用所属部门', dataIndex: 'departmentName', width: '160px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '促销类型', dataIndex: 'promotionRule.promotionRuleTypeDictValue', width: '100px', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '规则', dataIndex: 'promotionRule.ruleInfo', width: '180px', align: 'left', scopedSlots: { customRender: 'promotionDesc' } },
         { title: '数量(非促)', dataIndex: 'notGiftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '数量(促)', dataIndex: 'giftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '实售金额', dataIndex: 'totalRealAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '开单金额', dataIndex: 'totalAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '成本金额', dataIndex: 'totalRealCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '规则数量(非促)', dataIndex: 'notGiftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '规则数量(促)', dataIndex: 'giftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '规则实售金额', dataIndex: 'totalRealAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '规则开单金额', dataIndex: 'totalAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '规则成本金额', dataIndex: 'totalRealCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '损失成本', dataIndex: 'lossCost', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '损失费用', dataIndex: 'lossAmount', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: <a-tooltip placement='top' title='即在下推时促销产品已转采购额的数量'>转采购额数量&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'convertPromoGiftsQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },

+ 284 - 182
src/views/reportData/promotionSalesRealTimeReport/list.vue

@@ -140,7 +140,7 @@
           :data="loadData"
           :pageSize="30"
           :style="{ height: tableHeight+84.5+'px' }"
-          :scroll="{ y: tableHeight-20,x:1890}"
+          :scroll="{ x:1890,y: tableHeight-34}"
           :defaultLoadData="false"
           bordered>
           <!-- 促销时间 -->
@@ -150,12 +150,7 @@
           </template>
           <!-- 规则 -->
           <template slot="promotionDesc" slot-scope="text, record">
-            <div v-if="record.promotionRule.ruleInfo" v-html="record.promotionRule.ruleInfo"></div>
-            <span v-else>--</span>
-          </template>
-          <!-- 地区 -->
-          <template slot="addressInfo" slot-scope="text, record">
-            <span v-if="record.provinceName">{{ record.provinceName }}{{ record.cityName?'/'+record.cityName:'' }}{{ record.districtName?'/'+record.districtName :'' }}</span>
+            <div v-if="record.promotionRule&&record.promotionRule.ruleInfo" v-html="record.promotionRule.ruleInfo"></div>
             <span v-else>--</span>
           </template>
           <template slot="footer">
@@ -206,7 +201,6 @@ export default {
   mixins: [commonMixin],
   components: { STable, VSelect, reportModal, AreaList, rangeDate, subarea, customerService },
   data () {
-    const _this = this
     return {
       spinning: false,
       advanced: true, // 高级搜索 展开/关闭
@@ -249,175 +243,6 @@ export default {
       },
       dateFormat: 'YYYY-MM-DD', // 时间格式
       totalData: null, //  统计合计
-      // 表格列
-      columns: [{
-        title: '促销名称',
-        dataIndex: 'promotion.title',
-        width: '160px',
-        align: 'left',
-        customRender: function (text) {
-          return text || '--'
-        },
-        fixed: 'left',
-        ellipsis: true
-      },
-      {
-        title: '促销时间',
-        scopedSlots: {
-          customRender: 'promotionTime'
-        },
-        width: '130px',
-        align: 'center',
-        fixed: 'left'
-      },
-      {
-        title: '费用所属部门',
-        dataIndex: 'departmentName',
-        width: '160px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        },
-        ellipsis: true,
-        fixed: 'left'
-      },
-      {
-        title: '促销类型',
-        dataIndex: 'promotionRule.promotionRuleTypeDictValue',
-        width: '100px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        },
-        fixed: 'left'
-      }, { title: '规则', dataIndex: 'promotionRule.ruleInfo', width: '180px', align: 'left', scopedSlots: { customRender: 'promotionDesc' }, fixed: 'left' },
-      {
-        title: '销售单号',
-        dataIndex: 'salesBillNo',
-        width: '120px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        },
-        fixed: 'left'
-      },
-      {
-        title: '区域',
-        dataIndex: 'subareaArea.subareaName',
-        width: '80px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        }
-      },
-      {
-        title: '分区',
-        dataIndex: 'subareaArea.subareaAreaName',
-        width: '80px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        }
-      },
-      {
-        title: '地区',
-        dataIndex: 'provinceName',
-        width: '160px',
-        align: 'center',
-        scopedSlots: { customRender: 'addressInfo' }
-      },
-      {
-        title: '客户名称',
-        dataIndex: 'buyerName',
-        width: '140px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        },
-        ellipsis: true
-      },
-      {
-        title: '客户级别',
-        dataIndex: 'buyerLevelDictValue',
-        width: '80px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        }
-      },
-      {
-        title: '销售审核时间',
-        dataIndex: 'auditDate',
-        width: '120px',
-        align: 'center',
-        customRender: function (text) {
-          return text || '--'
-        }
-      },
-      {
-        title: '实时数量(非促)',
-        dataIndex: 'notGiftQty',
-        width: '100px',
-        align: 'center',
-        customRender: function (text) {
-          return ((text || text == 0) ? text : '--')
-        }
-      },
-      {
-        title: '实时数量(促)',
-        dataIndex: 'giftQty',
-        width: '100px',
-        align: 'center',
-        customRender: function (text) {
-          return ((text || text == 0) ? text : '--')
-        }
-      },
-      {
-        title: '实时实售金额',
-        dataIndex: 'totalRealAmount',
-        width: '100px',
-        align: 'right',
-        customRender: function (text) {
-          return ((text || text == 0) ? _this.toThousands(text) : '--')
-        }
-      },
-      {
-        title: '实时开单金额',
-        dataIndex: 'totalAmount',
-        width: '100px',
-        align: 'right',
-        customRender: function (text) {
-          return ((text || text == 0) ? _this.toThousands(text) : '--')
-        }
-      },
-      {
-        title: '实时成本金额',
-        dataIndex: 'totalRealCost',
-        width: '100px',
-        align: 'right',
-        customRender: function (text) {
-          return ((text || text == 0) ? _this.toThousands(text) : '--')
-        }
-      },
-      {
-        title: '实时损失成本',
-        dataIndex: 'lossCost',
-        width: '100px',
-        align: 'right',
-        customRender: function (text) {
-          return ((text || text == 0) ? _this.toThousands(text) : '--')
-        }
-      },
-      {
-        title: '实时损失费用',
-        dataIndex: 'lossAmount',
-        width: '100px',
-        align: 'right',
-        customRender: function (text) {
-          return ((text || text == 0) ? _this.toThousands(text) : '--')
-        }
-      }
-      ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.spinning = true
@@ -428,18 +253,234 @@ export default {
           let data
           if (res.status == 200) {
             data = res.data
-            // 计算列表序号
-            for (var i = 0; i < data.length; i++) {
-              data[i].no = i + 1
+            // 序号计算
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+              data.list[i].addressInfo = data.list[i].provinceName + '/' + data.list[i].cityName + '/' + data.list[i].districtName
             }
-            this.disabled = false
+            data.list = this.getMixData(data.list)
           }
           this.spinning = false
+          this.disabled = false
           return data
         })
       }
     }
   },
+  computed: {
+    columns () {
+      const _this = this
+      const rowspanMix = function (value, row, index) {
+        const obj = {
+          children: value || '--',
+          attrs: {}
+        }
+        if (row.rowspan != undefined) {
+          obj.attrs.rowSpan = row.rowspan
+        }
+        return obj
+      }
+      const rowspanMix1 = function (value, row, index) {
+        const obj = {
+          children: (value || value == 0) ? value : '--',
+          attrs: {}
+        }
+        if (row.rowspan1 != undefined) {
+          obj.attrs.rowSpan = row.rowspan1
+        }
+        return obj
+      }
+      return [
+        {
+          title: '销售单号',
+          dataIndex: 'salesBillNo',
+          width: '120px',
+          align: 'center',
+          customRender: (value, row, index) => rowspanMix(value, row, index)
+        },
+        {
+          title: '区域',
+          dataIndex: 'subareaArea.subareaName',
+          width: '80px',
+          align: 'center',
+          customRender: rowspanMix
+        },
+        {
+          title: '分区',
+          dataIndex: 'subareaArea.subareaAreaName',
+          width: '80px',
+          align: 'center',
+          customRender: rowspanMix
+        },
+        {
+          title: '地区',
+          dataIndex: 'addressInfo',
+          width: '160px',
+          align: 'center',
+          customRender: rowspanMix
+        },
+        {
+          title: '客户名称',
+          dataIndex: 'buyerName',
+          width: '140px',
+          align: 'center',
+          customRender: rowspanMix,
+          ellipsis: true
+        },
+        {
+          title: '客户级别',
+          dataIndex: 'buyerLevelDictValue',
+          width: '80px',
+          align: 'center',
+          customRender: rowspanMix
+        },
+        {
+          title: '销售审核时间',
+          dataIndex: 'auditDate',
+          width: '120px',
+          align: 'center',
+          customRender: rowspanMix
+        },
+        {
+          title: '促销名称',
+          dataIndex: 'promotion.title',
+          width: '160px',
+          align: 'left',
+          customRender: function (text) {
+            return text || '--'
+          },
+          ellipsis: true
+        },
+        {
+          title: '促销时间',
+          scopedSlots: {
+            customRender: 'promotionTime'
+          },
+          width: '130px',
+          align: 'center'
+        },
+        {
+          title: '费用所属部门',
+          dataIndex: 'departmentName',
+          width: '160px',
+          align: 'center',
+          customRender: function (text) {
+            return text || '--'
+          },
+          ellipsis: true
+        },
+        {
+          title: '促销类型',
+          dataIndex: 'promotionRule.promotionRuleTypeDictValue',
+          width: '100px',
+          align: 'center',
+          customRender: function (text) {
+            return text || '--'
+          }
+        },
+        { title: '规则', dataIndex: 'promotionRule.ruleInfo', width: '180px', align: 'left', scopedSlots: { customRender: 'promotionDesc' } },
+        {
+          title: '数量(非促)',
+          dataIndex: 'notGiftQtySum',
+          width: '100px',
+          align: 'center',
+          customRender: rowspanMix1
+        },
+        {
+          title: '数量(促)',
+          dataIndex: 'giftQtySum',
+          width: '100px',
+          align: 'center',
+          customRender: rowspanMix1
+        },
+        {
+          title: '实售金额',
+          dataIndex: 'totalRealAmountSum',
+          width: '100px',
+          align: 'right',
+          customRender: rowspanMix1
+        },
+        {
+          title: '开单金额',
+          dataIndex: 'totalAmountSum',
+          width: '100px',
+          align: 'right',
+          customRender: rowspanMix1
+        },
+        {
+          title: '成本金额',
+          dataIndex: 'totalRealCostSum',
+          width: '100px',
+          align: 'right',
+          customRender: rowspanMix1
+        },
+        {
+          title: '规则数量(非促)',
+          dataIndex: 'notGiftQty',
+          width: '100px',
+          align: 'center',
+          customRender: function (text) {
+            return ((text || text == 0) ? text : '--')
+          }
+        },
+        {
+          title: '规则数量(促)',
+          dataIndex: 'giftQty',
+          width: '100px',
+          align: 'center',
+          customRender: function (text) {
+            return ((text || text == 0) ? text : '--')
+          }
+        },
+        {
+          title: '规则实售金额',
+          dataIndex: 'totalRealAmount',
+          width: '100px',
+          align: 'right',
+          customRender: function (text) {
+            return ((text || text == 0) ? _this.toThousands(text) : '--')
+          }
+        },
+        {
+          title: '规则开单金额',
+          dataIndex: 'totalAmount',
+          width: '100px',
+          align: 'right',
+          customRender: function (text) {
+            return ((text || text == 0) ? _this.toThousands(text) : '--')
+          }
+        },
+        {
+          title: '规则成本金额',
+          dataIndex: 'totalRealCost',
+          width: '100px',
+          align: 'right',
+          customRender: function (text) {
+            return ((text || text == 0) ? _this.toThousands(text) : '--')
+          }
+        },
+        {
+          title: '损失成本',
+          dataIndex: 'lossCost',
+          width: '100px',
+          align: 'right',
+          customRender: function (text) {
+            return ((text || text == 0) ? _this.toThousands(text) : '--')
+          }
+        },
+        {
+          title: '损失费用',
+          dataIndex: 'lossAmount',
+          width: '100px',
+          align: 'right',
+          customRender: function (text) {
+            return ((text || text == 0) ? _this.toThousands(text) : '--')
+          }
+        }
+      ]
+    }
+  },
   watch: {
     // 展开关闭
     advanced (newValue, oldValue) {
@@ -453,6 +494,67 @@ export default {
     }
   },
   methods: {
+    // 标记rowspan
+    getMixData (data) {
+      let ret = []
+      ret = this.markRowspan(data, 'salesBillNo')
+      ret = this.markMutiRowspan(ret, 'salesBillNo', 'stackFlag')
+      return ret
+    },
+    markRowspan (array, key = 'no') {
+      // 统计每个key值的出现次数
+      const countMap = {}
+      array.forEach(item => {
+        const value = item[key]
+        countMap[value] = (countMap[value] || 0) + 1
+      })
+
+      // 标记rowspan
+      const result = []
+      const processedKeys = {}
+
+      array.forEach(item => {
+        const value = item[key]
+        const newItem = { ...item, rowspan: 0 }
+
+        if (!processedKeys[value]) {
+          // 每组第一项标记总数
+          newItem.rowspan = countMap[value]
+          processedKeys[value] = true
+        }
+
+        result.push(newItem)
+      })
+
+      return result
+    },
+    markMutiRowspan (array, key = 'no', flagKey = 'stackFlag') {
+      // 统计每个key值的出现次数
+      const countMap = {}
+      array.forEach(item => {
+        const value = item[key] + '-' + item[flagKey]
+        countMap[value] = (countMap[value] || 0) + 1
+      })
+
+      // 标记rowspan
+      const result = []
+      const processedKeys = {}
+
+      array.forEach(item => {
+        const value = item[key] + '-' + item[flagKey]
+        const newItem = { ...item, rowspan1: 0 }
+
+        if (!processedKeys[value]) {
+          // 每组第一项标记总数
+          newItem.rowspan1 = countMap[value]
+          processedKeys[value] = true
+        }
+
+        result.push(newItem)
+      })
+
+      return result
+    },
     // 下推时间 change
     salesDateChange (date) {
       if (date[0] && date[1]) {
@@ -521,7 +623,7 @@ export default {
       delete params.salesDate
       this.$nextTick(() => {
         this.getCount(params)
-        this.$refs.table.refresh()
+        this.$refs.table.refresh(true)
       })
     },
     // 导出