2 Commity 1520ee2859 ... ca7c1c716c

Autor SHA1 Wiadomość Data
  chenrui ca7c1c716c Merge branch 'develop_yh59' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into develop_yh59 1 miesiąc temu
  chenrui 461f32a70a 报表 1 miesiąc temu

+ 212 - 1
src/api/reportData.js

@@ -1580,4 +1580,215 @@ export const manageAnalysisReportExport = (params) => {
       'module': encodeURIComponent('各品类经营分析报表导出')
     }
   })
-}
+}
+
+/*
+***  促销费用报表
+*/
+
+// 促销费用报表   省份   有分页
+export const promoProvinceList = (params) => {
+  const url = `/report/promoExpenseProvince/reportList`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 促销费用报表 省份  表头
+export const promoProvinceTableTitle = (params) => {
+  return axios({
+    url: '/report/promoExpenseProvince/reportTitle',
+    data: params,
+    method: 'get',
+    headers: {
+      'module': encodeURIComponent('获取表头')
+    }
+  })
+}
+
+// 促销费用报表 省份  合计
+export const promoProvinceCount = (params) => {
+  return axios({
+    url: '/report/promoExpenseProvince/reportCount',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('合计')
+    }
+  })
+}
+
+// 促销费用报表 省份 导出
+export const promoProvinceExport = (params) => {
+  return axios({
+    url: '/report/promoExpenseProvince/reportExport',
+    data: params,
+    method: 'post',
+    responseType: 'blob',
+    headers: {
+      'module': encodeURIComponent('导出')
+    }
+  })
+}
+
+// 促销费用报表(客户) 、促销费用报表  有分页
+export const promoSalesExpenseList = (params) => {
+  const url = `/report/promoSalesExpense/reportPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 促销费用报表(客户) 、促销费用报表  表头
+export const promoSalesExpenseTitle = (params) => {
+  return axios({
+    url: '/report/promoSalesExpense/reportTitle',
+    data: params,
+    method: 'get',
+    headers: {
+      'module': encodeURIComponent('获取表头')
+    }
+  })
+}
+
+// 促销费用报表(客户) 、促销费用报表  合计
+export const promoSalesExpenseCount = (params) => {
+  return axios({
+    url: '/report/promoSalesExpense/reportCount',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('合计')
+    }
+  })
+}
+
+// 促销费用报表(客户) 、促销费用报表  导出
+export const promoSalesExpenseExport = (params) => {
+  return axios({
+    url: '/report/promoSalesExpense/reportExport',
+    data: params,
+    method: 'post',
+    responseType: 'blob',
+    headers: {
+      'module': encodeURIComponent('导出')
+    }
+  })
+}
+
+/*
+***** 开单统计报表
+*/
+
+// 开单统计报表(客户)   列表   有分页
+export const salesStatsDealerList = (params) => {
+  const url = `/report/salesStatsDealer/reportPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 开单统计报表(客户)  表头
+export const salesStatsDealerTitle = (params) => {
+  return axios({
+    url: '/report/salesStatsDealer/reportTitle',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('获取表头')
+    }
+  })
+}
+
+// 开单统计报表(客户)  合计
+export const salesStatsDealerCount = (params) => {
+  return axios({
+    url: '/report/salesStatsDealer/reportCount',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('合计')
+    }
+  })
+}
+
+// 开单统计报表(客户)  导出
+export const salesStatsDealerExport = (params) => {
+  return axios({
+    url: '/report/salesStatsDealer/reportExport',
+    data: params,
+    method: 'post',
+    responseType: 'blob',
+    headers: {
+      'module': encodeURIComponent('导出')
+    }
+  })
+}
+
+// 开单统计报表(省份)   列表   无分页
+export const salesStatsProvinceList = (params) => {
+  return axios({
+    url: '/report/salesStatsProvince/reportList',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+// 开单统计报表(省份)  表头
+export const salesStatsProvinceTit = (params) => {
+  return axios({
+    url: '/report/salesStatsProvince/reportTitle',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('获取表头')
+    }
+  })
+}
+
+// 开单统计报表(省份)  合计
+export const salesStatsProvinceCount = (params) => {
+  return axios({
+    url: '/report/salesStatsProvince/reportCount',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('合计')
+    }
+  })
+}
+
+// 开单统计报表(省份)  导出
+export const salesStatsProvinceExport = (params) => {
+  return axios({
+    url: '/report/salesStatsProvince/reportExport',
+    data: params,
+    method: 'post',
+    responseType: 'blob',
+    headers: {
+      'module': encodeURIComponent('导出')
+    }
+  })
+}

+ 16 - 16
src/views/dealerManagement/dealerZoneSearch/list.vue

@@ -5,17 +5,17 @@
       <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
         <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
           <a-row :gutter="15">
-            <a-col :md="6" :sm="24">
+            <a-col :md="4" :sm="24">
               <a-form-model-item label="地区">
-                <Area id="dealerZoneSearch-dealerProvinceSn" v-model="queryParam.dealerProvinceSn" placeholder="请选择省"></Area>
+                <Area id="dealerZoneSearch-dealerProvinceSn" v-model="queryParam.dealer.provinceSn" placeholder="请选择省"></Area>
               </a-form-model-item>
             </a-col>
-            <a-col :md="6" :sm="24">
+            <a-col :md="5" :sm="24">
               <a-form-item label="所属区域/分区">
                 <subarea id="dealerZoneSearch-subareaSn" ref="subarea" @change="subareaChange"></subarea>
               </a-form-item>
             </a-col>
-            <a-col :md="6" :sm="24">
+            <a-col :md="5" :sm="24">
               <a-form-item label="经销商">
                 <custList id="dealerZoneSearch-dealerName" placeholder="请输入经销商名称搜索" ref="indirectDealer" @change="dealerChange" />
               </a-form-item>
@@ -25,7 +25,7 @@
                 <a-input id="dealerZoneSearch-bizUserName" v-model.trim="queryParam.bizUserName" allowClear placeholder="请输入客服/品类经理/区域负责人/销售总监"/>
               </a-form-item>
             </a-col>
-            <a-col :md="24" :sm="24" style="text-align: center;margin-bottom: 10px;">
+            <a-col :md="4" :sm="24">
               <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="dealerZoneSearch-refresh">查询</a-button>
               <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="dealerZoneSearch-reset">重置</a-button>
               <a-button
@@ -114,20 +114,20 @@ export default {
         subareaAreaSn: undefined, // 分区
         dealer: {
           dealerSn: '', // 经销商sn
-          dealerName: ''// 经销商名称
+          dealerName: '', // 经销商名称
+          provinceSn: undefined// 地区
         },
-        bizUserName: '', // 客服/区域负责人/销售总监
-        dealerProvinceSn: undefined// 地区
+        bizUserName: '' // 客服/品类经理/区域负责人/销售总监
       },
       columns: [
-        { title: '经销商名称', dataIndex: 'dealer.dealerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '省份', dataIndex: 'dealerProvinceName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '所属区域', dataIndex: 'subareaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '所属分区', dataIndex: 'subareaAreaName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '经销商名称', dataIndex: 'dealer.dealerName', width: '12%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '省份', dataIndex: 'dealer.provinceName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '所属区域', dataIndex: 'subareaName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '所属分区', dataIndex: 'subareaAreaName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '客服', scopedSlots: { customRender: 'kf' }, dataIndex: 'userNameKfs', width: '30%', align: 'center' },
-        { title: '品类经理', dataIndex: 'subareaAreaName1', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '品类经理', dataIndex: 'userNamePljls', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '区域负责人', scopedSlots: { customRender: 'qyfzr' }, dataIndex: 'userNameQyfzrs', width: '11%', align: 'center' },
-        { title: '销售总监', scopedSlots: { customRender: 'xszj' }, dataIndex: 'userNameXszjs', width: '8%', align: 'center' }
+        { title: '销售总监', scopedSlots: { customRender: 'xszj' }, dataIndex: 'userNameXszjs', width: '7%', align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -169,8 +169,8 @@ export default {
       this.queryParam.subareaAreaSn = undefined
       this.queryParam.dealer.dealerSn = ''
       this.queryParam.dealer.dealerName = ''
+      this.queryParam.dealer.provinceSn = undefined
       this.queryParam.bizUserName = ''
-      this.queryParam.dealerProvinceSn = undefined
       this.$refs.indirectDealer.resetForm()
       this.$refs.subarea.clearData()
       this.$refs.table.refresh(true)
@@ -191,7 +191,7 @@ export default {
     // 计算表格高度
     setTableH () {
       const tableSearchH = this.$refs.tableSearch.offsetHeight
-      this.tableHeight = window.innerHeight - tableSearchH - 200
+      this.tableHeight = window.innerHeight - tableSearchH - 197
     }
   },
   watch: {

+ 64 - 105
src/views/reportData/billingStatistics/customerCountList.vue

@@ -12,7 +12,7 @@
           :model="queryParam">
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="月份" prop="queryDate">
+              <a-form-model-item label="月份" prop="beginDate">
                 <a-month-picker
                   id="customerCountList-monthBox"
                   class="monthBox"
@@ -104,44 +104,14 @@
           :scroll="{x:2200, y: tableHeight-120}"
           :defaultLoadData="false"
           bordered>
-          <template slot="footer">
+          <template slot="footer" v-if="totalData&&totalData.length">
             <a-row :gutter="15">
-              <a-col :md="24" :sm="24">合计:</a-col>
-              <a-col :md="4" :sm="24">箭牌滤清器:{{ (totalData && (totalData.increaseRewardAmount || totalData.increaseRewardAmount==0)) ? toThousands(totalData.increaseRewardAmount): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌变速箱滤清器:{{ (totalData && (totalData.increaseRewardShareFactory || totalData.increaseRewardShareFactory==0)) ? toThousands(totalData.increaseRewardShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌滤清器:{{ (totalData && (totalData.increaseRewardShareSys || totalData.increaseRewardShareSys==0)) ? toThousands(totalData.increaseRewardShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">滤清器合计:{{ (totalData && (totalData.transSubsidy || totalData.transSubsidy==0)) ? toThousands(totalData.transSubsidy): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨刮片:{{ (totalData && (totalData.totalPoint || totalData.totalPoint==0)) ? toThousands(totalData.totalPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨燕雨刮片:{{ (totalData && (totalData.currentPoint || totalData.currentPoint==0)) ? toThousands(totalData.currentPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌雨刮片:{{ (totalData && (totalData.currentPointShareFactory || totalData.currentPointShareFactory==0)) ? toThousands(totalData.currentPointShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">雨刮片合计:{{ (totalData && (totalData.currentPointShareSys || totalData.currentPointShareSys==0)) ?toThousands(totalData.currentPointShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌喇叭:{{ (totalData && (totalData.serviceAmountSys || totalData.serviceAmountSys==0)) ? toThousands(totalData.serviceAmountSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU+箭牌感应线:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU至惠刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU-P刹车盘:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">刹车片合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">汇箭蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">布瑞斯蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">蓄电池合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯变速箱油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯汽车养护产品:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">科润星机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升点火线圈:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升LED灯:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">合计品牌:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">轮胎:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">NGk火花塞:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">飞利浦:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">代理品牌合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">品牌+代理品牌合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
+              <a-col span="24">合计:</a-col>
+              <a-col span="24">
+                <a-col span="4" v-for="item in totalData" :key="item.key">
+                  {{ item.title }}:{{ item[item.key] ||item[item.key] ==0?toThousands(item[item.key]) :'--' }}
+                </a-col>
+              </a-col>
             </a-row>
           </template>
         </s-table>
@@ -162,7 +132,7 @@ import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
 import BizUser from '@/views/common/bizUser.js'
 import customerService from '@/views/common/customerService.vue'
 // 接口
-import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
+import { salesStatsDealerList, salesStatsDealerTitle, salesStatsDealerCount, salesStatsDealerExport } from '@/api/reportData'
 export default {
   name: 'CustomerCountList',
   mixins: [commonMixin],
@@ -177,8 +147,8 @@ export default {
       monthVal: moment().format('YYYY-MM'), // 初始化月份值
       //  查询条件
       queryParam: {
-        queryType: 'month', // 开单统计报表(客户)
-        queryDate: moment().format('YYYYMM'), // 选择月份
+        beginDate: moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00', // 月份开始时间
+        endDate: moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59', // 月份结束时间
         dealerLevel: undefined, // 客户等级
         customSn: undefined, // 客户sn
         dealerEntity: {
@@ -194,9 +164,10 @@ export default {
         },
         bizUserSn: undefined// 客服
       },
+      columns: [], // 表格  列数据
       totalData: null, // 合计
       rules: {
-        'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
+        'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
       },
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -204,7 +175,7 @@ export default {
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
         // 获取列表数据  有分页
-        return tireFeeReportList(params).then(res => {
+        return salesStatsDealerList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -233,57 +204,6 @@ export default {
       this.setTableH()
     }
   },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '40px', align: 'center', fixed: 'left' },
-        { title: '月份', dataIndex: 'monthData', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '省份', dataIndex: 'dealerEntity.provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true, fixed: 'left' },
-        { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '箭牌滤清器', dataIndex: 'serviceAmountProvince', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌变速箱滤清器', dataIndex: 'serviceAmountProvince1', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌滤清器', dataIndex: 'serviceAmountProvince2', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '滤清器合计', dataIndex: 'serviceAmountProvince3', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨刮片', dataIndex: 'serviceAmountProvince4', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨燕雨刮片', dataIndex: 'serviceAmountProvince5', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌雨刮片', dataIndex: 'serviceAmountProvince6', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '雨刮片合计', dataIndex: 'serviceAmountProvince7', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌喇叭', dataIndex: 'serviceAmountProvince8', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌刹车片', dataIndex: 'serviceAmountProvince9', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU+箭牌感应线', dataIndex: 'serviceAmountProvincea', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌刹车片', dataIndex: 'serviceAmountProvincec', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车片', dataIndex: 'serviceAmountProvinceb', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU至惠刹车片', dataIndex: 'serviceAmountProvinced', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车油', dataIndex: 'serviceAmountProvincee', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU-P刹车盘', dataIndex: 'serviceAmountProvincef', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '刹车片合计', dataIndex: 'serviceAmountProvinceg', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '汇箭蓄电池', dataIndex: 'serviceAmountProvinceh', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '布瑞斯蓄电池', dataIndex: 'serviceAmountProvincei', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '蓄电池合计', dataIndex: 'serviceAmountProvincej', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯变速箱油', dataIndex: 'serviceAmountProvincek', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯刹车油', dataIndex: 'serviceAmountProvincel', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯汽车养护产品', dataIndex: 'serviceAmountProvincem', width: '120px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '科润星机油', dataIndex: 'serviceAmountProvince12', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯合计', dataIndex: 'serviceAmountProvince13', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升点火线圈', dataIndex: 'serviceAmountProvince14', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升LED灯', dataIndex: 'serviceAmountProvince15', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升合计', dataIndex: 'serviceAmountProvince16', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '合计品牌', dataIndex: 'serviceAmountProvince17', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '轮胎', dataIndex: 'serviceAmountProvince18', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'NGk火花塞', dataIndex: 'serviceAmountProvince19', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '飞利浦', dataIndex: 'serviceAmountProvince20', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '代理品牌合计', dataIndex: 'serviceAmountProvince21', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '合计', dataIndex: 'serviceAmountProvince22', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
-      ]
-      return arr
-    }
-
-  },
   methods: {
     // 选择月份  禁用选择当月以后日期
     disabledDate (current) {
@@ -293,11 +213,43 @@ export default {
     onChangeMonth (date, dateString) {
       this.monthVal = dateString
       if (date && dateString != '') {
-        this.queryParam.queryDate = dateString.replace('-', '')
+        this.queryParam.beginDate = this.getMonthRange(dateString).firstDay
+        this.queryParam.endDate = this.getMonthRange(dateString).lastDay
       } else {
-        this.queryParam.queryDate = void 0
+        this.queryParam.beginDate = undefined
+        this.queryParam.endDate = undefined
       }
     },
+    // 获取指定月份   第一天和最后一天
+    getMonthRange (targetMonth) {
+      // 获取指定月第一天(格式化为 YYYY-MM-DD)
+      const firstDay = moment(targetMonth).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      // 获取指定月最后一天(格式化为 YYYY-MM-DD)
+      const lastDay = moment(targetMonth).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
+      return { firstDay, lastDay }
+    },
+    // 获取表头
+    async getTableTitle () {
+      const _this = this
+      const tableTitle = await salesStatsDealerTitle().then(res => res.data)
+      this.columns = tableTitle.list
+      this.columns.unshift({ title: '序号', dataIndex: 'no', fixed: 'left', align: 'center' })
+      this.countLabel = tableTitle.count
+      this.columns.map(item => {
+        let mw = 20
+        if (item.customRender == 'amount') {
+          mw = 15
+          item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
+        } else {
+          item.customRender = function (text) { return text || '--' }
+        }
+        const w = item.title.length * mw
+        const tw = w <= 80 ? mw * 5 : w
+        item.width = tw + 'px'
+        this.tableWidth = this.tableWidth + tw
+      })
+      this.resetSearchForm()
+    },
     // 查询
     handleSearch () {
       const _this = this
@@ -317,9 +269,15 @@ export default {
     },
     // 统计
     getCount (params) {
-      tireFeeReportCount(params).then(res => {
+      salesStatsDealerCount(params).then(res => {
         if (res.status == 200 && res.data) {
-          this.totalData = res.data
+          const mergedList = this.countLabel.map(item => {
+            const key = item.key
+            return key in res.data
+              ? { ...item, [key]: res.data[key] }
+              : item
+          })
+          this.totalData = mergedList
         } else {
           this.totalData = null
         }
@@ -338,9 +296,9 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.queryType = 'month'
+      this.queryParam.beginDate = moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      this.queryParam.endDate = moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
       this.monthVal = moment().format('YYYY-MM')
-      this.queryParam.queryDate = moment().format('YYYYMM')
       this.queryParam.dealerEntity.provinceSn = undefined
       this.queryParam.dealerEntity.citySn = undefined
       this.queryParam.dealerEntity.districtSn = undefined
@@ -351,13 +309,12 @@ export default {
       this.queryParam.subareaArea.subareaAreaSn = ''
       this.queryParam.subareaArea.bizUserSn = undefined
       this.queryParam.dealerLevel = undefined
-      this.queryParam.provinceFlag = undefined
-      this.$refs.subarea.clearData()
       if (this.advanced) {
+        this.$refs.subarea.clearData()
         this.$refs.dealerSubareaScopeList.resetForm()
+        this.$refs.areaList.clearData()
       }
       this.totalData = null
-      this.$refs.areaList.clearData()
       this.$refs.table.clearTable()
       this.$refs.ruleForm.resetFields()
     },
@@ -379,7 +336,7 @@ export default {
       const params = JSON.parse(JSON.stringify(_this.queryParam))
       _this.exportLoading = true
       _this.spinning = true
-      hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
+      hdExportExcel(salesStatsDealerExport, params, '开单统计报表(客户)', function () {
         _this.exportLoading = false
         _this.spinning = false
       })
@@ -388,8 +345,8 @@ export default {
     pageInit () {
       this.$nextTick(() => { // 页面渲染完成后的回调
         this.setTableH()
+        this.resetSearchForm()
       })
-      this.resetSearchForm()
     },
     // 计算表格高度
     setTableH () {
@@ -400,12 +357,14 @@ export default {
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
+      this.getTableTitle()
     }
   },
   activated () {
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
       this.pageInit()
+      this.getTableTitle()
     }
   }
 }

+ 75 - 139
src/views/reportData/billingStatistics/provinceCountList.vue

@@ -12,7 +12,7 @@
           :model="queryParam">
           <a-row :gutter="15">
             <a-col :md="5" :sm="24">
-              <a-form-model-item label="月份" prop="queryDate">
+              <a-form-model-item label="月份" prop="beginDate">
                 <a-month-picker
                   id="provinceCountList-monthBox"
                   class="monthBox"
@@ -24,7 +24,7 @@
             </a-col>
             <a-col :md="5" :sm="24">
               <a-form-model-item label="地区">
-                <AreaList id="provinceCountList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
+                <Area id="provinceCountList-areaList" v-model="queryParam.provinceSn" placeholder="请选择省份"></Area>
               </a-form-model-item>
             </a-col>
             <a-col :md="5" :sm="24">
@@ -55,7 +55,7 @@
                 @click="handleExport"
                 :disabled="disabled"
                 :loading="exportLoading"
-                v-if="$hasPermissions('B_tireFeeExport')"
+
                 id="provinceCountList-export">导出</a-button>
             </a-col>
           </a-row>
@@ -76,45 +76,16 @@
           :data="loadData"
           :scroll="{x:2200, y: tableHeight-120}"
           :defaultLoadData="false"
+          :showPagination="false"
           bordered>
-          <template slot="footer">
+          <template slot="footer" v-if="totalData&&totalData.length">
             <a-row :gutter="15">
-              <a-col :md="24" :sm="24">合计:</a-col>
-              <a-col :md="4" :sm="24">箭牌滤清器:{{ (totalData && (totalData.increaseRewardAmount || totalData.increaseRewardAmount==0)) ? toThousands(totalData.increaseRewardAmount): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌变速箱滤清器:{{ (totalData && (totalData.increaseRewardShareFactory || totalData.increaseRewardShareFactory==0)) ? toThousands(totalData.increaseRewardShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌滤清器:{{ (totalData && (totalData.increaseRewardShareSys || totalData.increaseRewardShareSys==0)) ? toThousands(totalData.increaseRewardShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">滤清器合计:{{ (totalData && (totalData.transSubsidy || totalData.transSubsidy==0)) ? toThousands(totalData.transSubsidy): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨刮片:{{ (totalData && (totalData.totalPoint || totalData.totalPoint==0)) ? toThousands(totalData.totalPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨燕雨刮片:{{ (totalData && (totalData.currentPoint || totalData.currentPoint==0)) ? toThousands(totalData.currentPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌雨刮片:{{ (totalData && (totalData.currentPointShareFactory || totalData.currentPointShareFactory==0)) ? toThousands(totalData.currentPointShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">雨刮片合计:{{ (totalData && (totalData.currentPointShareSys || totalData.currentPointShareSys==0)) ?toThousands(totalData.currentPointShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌喇叭:{{ (totalData && (totalData.serviceAmountSys || totalData.serviceAmountSys==0)) ? toThousands(totalData.serviceAmountSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU+箭牌感应线:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU至惠刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU-P刹车盘:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">刹车片合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">汇箭蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">布瑞斯蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">蓄电池合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯变速箱油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯汽车养护产品:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">科润星机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升点火线圈:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升LED灯:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">合计品牌:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">轮胎:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">NGk火花塞:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">飞利浦:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">代理品牌合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">品牌+代理品牌合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
+              <a-col span="24">合计:</a-col>
+              <a-col span="24">
+                <a-col span="4" v-for="item in totalData" :key="item.key">
+                  {{ item.title }}:{{ item[item.key] ||item[item.key] ==0?toThousands(item[item.key]) :'--' }}
+                </a-col>
+              </a-col>
             </a-row>
           </template>
         </s-table>
@@ -130,14 +101,14 @@ import moment from 'moment'
 // 组件
 import { STable, VSelect } from '@/components'
 import subarea from '@/views/common/subarea.js'
-import AreaList from '@/views/common/areaList.js'
+import Area from '@/views/common/area.js'
 import BizUser from '@/views/common/bizUser.js'
 // 接口
-import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
+import { salesStatsProvinceList, salesStatsProvinceTit, salesStatsProvinceCount, salesStatsProvinceExport } from '@/api/reportData'
 export default {
   name: 'ProvinceCountList',
   mixins: [commonMixin],
-  components: { STable, VSelect, subarea, AreaList, BizUser },
+  components: { STable, VSelect, subarea, Area, BizUser },
   data () {
     return {
       spinning: false,
@@ -147,43 +118,37 @@ export default {
       monthVal: moment().format('YYYY-MM'), // 初始化月份值
       //  查询条件
       queryParam: {
-        queryType: 'month', // 开单统计报表(客户)
-        queryDate: moment().format('YYYYMM'), // 选择月份
-        dealerLevel: undefined, // 客户等级
-        customSn: undefined, // 客户sn
-        dealerEntity: {
-          dealerName: undefined, // 客户名称
-          provinceSn: undefined, // 省
-          citySn: undefined, // 市
-          districtSn: undefined // 区
-        },
+        beginDate: moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00', // 月份开始时间
+        endDate: moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59', // 月份结束时间
+        provinceSn: undefined, // 地区
         subareaArea: {
           subareaSn: '', // 区域
           subareaAreaSn: '', // 分区
           bizUserSn: undefined// 区域负责人
-        },
-        bizUserSn: undefined// 客服
+        }
       },
+      columns: [], // 表格列
+      countLabel: null, // 统计名称合集
       totalData: null, // 合计
       rules: {
-        'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
+        'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
       },
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
-        // 获取列表数据  分页
-        return tireFeeReportList(params).then(res => {
+        // 获取列表数据  分页
+        return salesStatsProvinceList(params).then(res => {
           let data
           if (res.status == 200) {
             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
+            for (var i = 0; i < data.length; i++) {
+              data[i].no = i + 1
             }
             this.disabled = false
+            // 统计
             this.getCount(params)
           }
           this.spinning = false
@@ -197,55 +162,6 @@ export default {
       this.setTableH()
     }
   },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '40px', align: 'center', fixed: 'left' },
-        { title: '月份', dataIndex: 'monthData', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '省份', dataIndex: 'dealerEntity.provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '箭牌滤清器', dataIndex: 'serviceAmountProvince', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌变速箱滤清器', dataIndex: 'serviceAmountProvince1', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌滤清器', dataIndex: 'serviceAmountProvince2', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '滤清器合计', dataIndex: 'serviceAmountProvince3', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨刮片', dataIndex: 'serviceAmountProvince4', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨燕雨刮片', dataIndex: 'serviceAmountProvince5', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌雨刮片', dataIndex: 'serviceAmountProvince6', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '雨刮片合计', dataIndex: 'serviceAmountProvince7', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌喇叭', dataIndex: 'serviceAmountProvince8', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌刹车片', dataIndex: 'serviceAmountProvince9', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU+箭牌感应线', dataIndex: 'serviceAmountProvincea', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌刹车片', dataIndex: 'serviceAmountProvincec', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车片', dataIndex: 'serviceAmountProvinceb', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU至惠刹车片', dataIndex: 'serviceAmountProvinced', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车油', dataIndex: 'serviceAmountProvincee', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU-P刹车盘', dataIndex: 'serviceAmountProvincef', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '刹车片合计', dataIndex: 'serviceAmountProvinceg', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '汇箭蓄电池', dataIndex: 'serviceAmountProvinceh', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '布瑞斯蓄电池', dataIndex: 'serviceAmountProvincei', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '蓄电池合计', dataIndex: 'serviceAmountProvincej', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯机油', dataIndex: 'serviceAmountProvincel', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯变速箱油', dataIndex: 'serviceAmountProvincek', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯刹车油', dataIndex: 'serviceAmountProvincel6656', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯汽车养护产品', dataIndex: 'serviceAmountProvincem', width: '120px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '科润星机油', dataIndex: 'serviceAmountProvince12', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '润滑油合计', dataIndex: 'serviceAmountProvince13', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升点火线圈', dataIndex: 'serviceAmountProvince14', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升LED灯', dataIndex: 'serviceAmountProvince15', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升合计', dataIndex: 'serviceAmountProvince16', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '品牌合计', dataIndex: 'serviceAmountProvince17', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '轮胎', dataIndex: 'serviceAmountProvince18', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'NGk火花塞', dataIndex: 'serviceAmountProvince19', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '飞利浦', dataIndex: 'serviceAmountProvince20', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '代理品牌合计', dataIndex: 'serviceAmountProvince21', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '合计', dataIndex: 'serviceAmountProvince22', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
-      ]
-      return arr
-    }
-
-  },
   methods: {
     // 选择月份  禁用选择当月以后日期
     disabledDate (current) {
@@ -255,11 +171,43 @@ export default {
     onChangeMonth (date, dateString) {
       this.monthVal = dateString
       if (date && dateString != '') {
-        this.queryParam.queryDate = dateString.replace('-', '')
+        this.queryParam.beginDate = this.getMonthRange(dateString).firstDay
+        this.queryParam.endDate = this.getMonthRange(dateString).lastDay
       } else {
-        this.queryParam.queryDate = void 0
+        this.queryParam.beginDate = undefined
+        this.queryParam.endDate = undefined
       }
     },
+    // 获取指定月份   第一天和最后一天
+    getMonthRange (targetMonth) {
+      // 获取指定月第一天(格式化为 YYYY-MM-DD)
+      const firstDay = moment(targetMonth).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      // 获取指定月最后一天(格式化为 YYYY-MM-DD)
+      const lastDay = moment(targetMonth).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
+      return { firstDay, lastDay }
+    },
+    // 获取表头
+    async getTableTitle () {
+      const _this = this
+      const tableTitle = await salesStatsProvinceTit().then(res => res.data)
+      this.columns = tableTitle.list
+      this.columns.unshift({ title: '序号', dataIndex: 'no', fixed: 'left', align: 'center' })
+      this.countLabel = tableTitle.count
+      this.columns.map(item => {
+        let mw = 20
+        if (item.customRender == 'amount') {
+          mw = 15
+          item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
+        } else {
+          item.customRender = function (text) { return text || '--' }
+        }
+        const w = item.title.length * mw
+        const tw = w <= 80 ? mw * 5 : w
+        item.width = tw + 'px'
+        this.tableWidth = this.tableWidth + tw
+      })
+      this.resetSearchForm()
+    },
     // 查询
     handleSearch () {
       const _this = this
@@ -272,27 +220,22 @@ export default {
         }
       })
     },
-    // 客户名称 change
-    custChange (val) {
-      this.queryParam.dealerEntity.dealerName = val.name
-      this.queryParam.customSn = val.key
-    },
     // 统计
     getCount (params) {
-      tireFeeReportCount(params).then(res => {
+      salesStatsProvinceCount(params).then(res => {
         if (res.status == 200 && res.data) {
-          this.totalData = res.data
+          const mergedList = this.countLabel.map(item => {
+            const key = item.key
+            return key in res.data
+              ? { ...item, [key]: res.data[key] }
+              : item
+          })
+          this.totalData = mergedList
         } else {
           this.totalData = null
         }
       })
     },
-    // 地区
-    areaChange (val) {
-      this.queryParam.dealerEntity.provinceSn = val[0] ? val[0] : undefined
-      this.queryParam.dealerEntity.citySn = val[1] ? val[1] : undefined
-      this.queryParam.dealerEntity.districtSn = val[2] ? val[2] : undefined
-    },
     // 区域分区  change
     subareaChange (val) {
       this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
@@ -300,24 +243,15 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.queryType = 'month'
+      this.queryParam.beginDate = moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      this.queryParam.endDate = moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
       this.monthVal = moment().format('YYYY-MM')
-      this.queryParam.queryDate = moment().format('YYYYMM')
-      this.queryParam.dealerEntity.provinceSn = undefined
-      this.queryParam.dealerEntity.citySn = undefined
-      this.queryParam.dealerEntity.districtSn = undefined
-      this.queryParam.dealerEntity.dealerName = undefined
-      this.queryParam.customSn = undefined
-      this.queryParam.bizUserSn = undefined
+      this.queryParam.provinceSn = undefined
       this.queryParam.subareaArea.subareaSn = ''
       this.queryParam.subareaArea.subareaAreaSn = ''
       this.queryParam.subareaArea.bizUserSn = undefined
-      this.queryParam.dealerLevel = undefined
-      this.queryParam.provinceFlag = undefined
       this.$refs.subarea.clearData()
-      this.$refs.dealerSubareaScopeList.resetForm()
       this.totalData = null
-      this.$refs.areaList.clearData()
       this.$refs.table.clearTable()
       this.$refs.ruleForm.resetFields()
     },
@@ -339,7 +273,7 @@ export default {
       const params = JSON.parse(JSON.stringify(_this.queryParam))
       _this.exportLoading = true
       _this.spinning = true
-      hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
+      hdExportExcel(salesStatsProvinceExport, params, '开单统计报表(省份)', function () {
         _this.exportLoading = false
         _this.spinning = false
       })
@@ -348,8 +282,8 @@ export default {
     pageInit () {
       this.$nextTick(() => { // 页面渲染完成后的回调
         this.setTableH()
+        this.resetSearchForm()
       })
-      this.resetSearchForm()
     },
     // 计算表格高度
     setTableH () {
@@ -360,12 +294,14 @@ export default {
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
+      this.getTableTitle()
     }
   },
   activated () {
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
       this.pageInit()
+      this.getTableTitle()
     }
   }
 }

+ 70 - 108
src/views/reportData/promotionFeeReport/PromotionFeeList.vue

@@ -12,7 +12,7 @@
           :model="queryParam">
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="月份" prop="queryDate">
+              <a-form-model-item label="月份" prop="beginDate">
                 <a-month-picker
                   id="promotionFeeList-monthBox"
                   class="monthBox"
@@ -99,43 +99,14 @@
           :scroll="{x:2200, y: tableHeight-120}"
           :defaultLoadData="false"
           bordered>
-          <template slot="footer">
+          <template slot="footer" v-if="totalData&&totalData.length">
             <a-row :gutter="15">
-              <a-col :md="24" :sm="24">合计:</a-col>
-              <a-col :md="4" :sm="24">箭牌滤清器:{{ (totalData && (totalData.increaseRewardAmount || totalData.increaseRewardAmount==0)) ? toThousands(totalData.increaseRewardAmount): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌变速箱滤清器:{{ (totalData && (totalData.increaseRewardShareFactory || totalData.increaseRewardShareFactory==0)) ? toThousands(totalData.increaseRewardShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌滤清器:{{ (totalData && (totalData.increaseRewardShareSys || totalData.increaseRewardShareSys==0)) ? toThousands(totalData.increaseRewardShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">滤清器合计:{{ (totalData && (totalData.transSubsidy || totalData.transSubsidy==0)) ? toThousands(totalData.transSubsidy): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨刮片:{{ (totalData && (totalData.totalPoint || totalData.totalPoint==0)) ? toThousands(totalData.totalPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌雨燕雨刮片:{{ (totalData && (totalData.currentPoint || totalData.currentPoint==0)) ? toThousands(totalData.currentPoint): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌雨刮片:{{ (totalData && (totalData.currentPointShareFactory || totalData.currentPointShareFactory==0)) ? toThousands(totalData.currentPointShareFactory): '--' }}</a-col>
-              <a-col :md="4" :sm="24">雨刮片合计:{{ (totalData && (totalData.currentPointShareSys || totalData.currentPointShareSys==0)) ?toThousands(totalData.currentPointShareSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌喇叭:{{ (totalData && (totalData.serviceAmountSys || totalData.serviceAmountSys==0)) ? toThousands(totalData.serviceAmountSys): '--' }}</a-col>
-              <a-col :md="4" :sm="24">箭牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU+箭牌感应线:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">冠牌刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU至惠刹车片:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">TBU-P刹车盘:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">刹车片合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">汇箭蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">布瑞斯蓄电池:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">蓄电池合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯变速箱油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯刹车油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯汽车养护产品:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">科润星机油:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">德路斯合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升点火线圈:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升LED灯:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">稳升合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">全品类:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">品牌合计:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">轮胎:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">NGk火花塞:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
-              <a-col :md="4" :sm="24">全品类(含轮胎、NGK):{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
+              <a-col span="2">合计:</a-col>
+              <a-col span="22">
+                <a-col span="4" v-for="item in totalData" :key="item.key">
+                  {{ item.title }}:{{ item[item.key] ||item[item.key] ==0?toThousands(item[item.key]) :'--' }}
+                </a-col>
+              </a-col>
             </a-row>
           </template>
         </s-table>
@@ -154,13 +125,12 @@ import subarea from '@/views/common/subarea.js'
 import AreaList from '@/views/common/areaList.js'
 import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
 import BizUser from '@/views/common/bizUser.js'
-import customerService from '@/views/common/customerService.vue'
 // 接口
-import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
+import { promoSalesExpenseList, promoSalesExpenseTitle, promoSalesExpenseCount, promoSalesExpenseExport } from '@/api/reportData'
 export default {
   name: 'PromotionFeeList',
   mixins: [commonMixin],
-  components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, BizUser, customerService },
+  components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, BizUser },
   data () {
     return {
       spinning: false,
@@ -171,9 +141,10 @@ export default {
       monthVal: moment().format('YYYY-MM'), // 初始化月份值
       //  查询条件
       queryParam: {
-        queryType: 'month', // 开单统计报表(客户)
-        queryDate: moment().format('YYYYMM'), // 选择月份
-        dealerLevel: undefined, // 客户等级
+        amountType: 'sales_promo',
+        beginDate: moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00', // 月份开始时间
+        endDate: moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59', // 月份结束时间
+        dealerLevel: undefined, // 客户级别
         customSn: undefined, // 客户sn
         dealerEntity: {
           dealerName: undefined, // 客户名称
@@ -187,9 +158,11 @@ export default {
           bizUserSn: undefined// 区域负责人
         }
       },
+      columns: [], // 表头
+      countLabel: null, // 合计名称
       totalData: null, // 合计
       rules: {
-        'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
+        'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
       },
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -197,7 +170,7 @@ export default {
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
         // 获取列表数据  有分页
-        return tireFeeReportList(params).then(res => {
+        return promoSalesExpenseList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -207,6 +180,7 @@ export default {
               data.list[i].no = no + i + 1
             }
             this.disabled = false
+            // 统计
             this.getCount(params)
           }
           this.spinning = false
@@ -226,56 +200,6 @@ export default {
       this.setTableH()
     }
   },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '40px', align: 'center', fixed: 'left' },
-        { title: '月份', dataIndex: 'monthData', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '省份', dataIndex: 'dealerEntity.provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true, fixed: 'left' },
-        { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '箭牌滤清器', dataIndex: 'serviceAmountProvince', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌变速箱滤清器', dataIndex: 'serviceAmountProvince1', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌滤清器', dataIndex: 'serviceAmountProvince2', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '滤清器合计', dataIndex: 'serviceAmountProvince3', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨刮片', dataIndex: 'serviceAmountProvince4', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨燕雨刮片', dataIndex: 'serviceAmountProvince5', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌雨刮片', dataIndex: 'serviceAmountProvince6', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '雨刮片合计', dataIndex: 'serviceAmountProvince7', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌喇叭', dataIndex: 'serviceAmountProvince8', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌刹车片', dataIndex: 'serviceAmountProvince9', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU+箭牌感应线', dataIndex: 'serviceAmountProvincea', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌刹车片', dataIndex: 'serviceAmountProvincec', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车片', dataIndex: 'serviceAmountProvinceb', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU至惠刹车片', dataIndex: 'serviceAmountProvinced', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车油', dataIndex: 'serviceAmountProvincee', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU-P刹车盘', dataIndex: 'serviceAmountProvincef', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '制动系统合计', dataIndex: 'serviceAmountProvinceg', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '汇箭蓄电池', dataIndex: 'serviceAmountProvinceh', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '布瑞斯蓄电池', dataIndex: 'serviceAmountProvincei', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '蓄电池合计', dataIndex: 'serviceAmountProvincej', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯变速箱油', dataIndex: 'serviceAmountProvincek', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯刹车油', dataIndex: 'serviceAmountProvincel', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯汽车养护产品', dataIndex: 'serviceAmountProvincem', width: '120px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '科润星机油', dataIndex: 'serviceAmountProvince12', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '油品合计', dataIndex: 'serviceAmountProvince13', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升点火线圈', dataIndex: 'serviceAmountProvince14', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升LED灯', dataIndex: 'serviceAmountProvince15', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升合计', dataIndex: 'serviceAmountProvince187', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类', dataIndex: 'serviceAmountProvince16', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '品牌合计', dataIndex: 'serviceAmountProvince17', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '轮胎', dataIndex: 'serviceAmountProvince18', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'NGk火花塞', dataIndex: 'serviceAmountProvince19', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类(含轮胎、NGK)', dataIndex: 'serviceAmountProvince22', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
-      ]
-      return arr
-    }
-
-  },
   methods: {
     // 选择月份  禁用选择当月以后日期
     disabledDate (current) {
@@ -285,11 +209,43 @@ export default {
     onChangeMonth (date, dateString) {
       this.monthVal = dateString
       if (date && dateString != '') {
-        this.queryParam.queryDate = dateString.replace('-', '')
+        this.queryParam.beginDate = this.getMonthRange(dateString).firstDay
+        this.queryParam.endDate = this.getMonthRange(dateString).lastDay
       } else {
-        this.queryParam.queryDate = void 0
+        this.queryParam.beginDate = undefined
+        this.queryParam.endDate = undefined
       }
     },
+    // 获取指定月份   第一天和最后一天
+    getMonthRange (targetMonth) {
+      // 获取指定月第一天(格式化为 YYYY-MM-DD)
+      const firstDay = moment(targetMonth).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      // 获取指定月最后一天(格式化为 YYYY-MM-DD)
+      const lastDay = moment(targetMonth).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
+      return { firstDay, lastDay }
+    },
+    // 获取表头
+    async getTableTitle () {
+      const _this = this
+      const tableTitle = await promoSalesExpenseTitle().then(res => res.data)
+      this.columns = tableTitle.list
+      this.columns.unshift({ title: '序号', dataIndex: 'no', fixed: 'left', align: 'center' })
+      this.countLabel = tableTitle.count
+      this.columns.map(item => {
+        let mw = 20
+        if (item.customRender == 'amount') {
+          mw = 15
+          item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
+        } else {
+          item.customRender = function (text) { return text || '--' }
+        }
+        const w = item.title.length * mw
+        const tw = w <= 80 ? mw * 5 : w
+        item.width = tw + 'px'
+        this.tableWidth = this.tableWidth + tw
+      })
+      this.resetSearchForm()
+    },
     // 查询
     handleSearch () {
       const _this = this
@@ -309,9 +265,15 @@ export default {
     },
     // 统计
     getCount (params) {
-      tireFeeReportCount(params).then(res => {
+      promoSalesExpenseCount(params).then(res => {
         if (res.status == 200 && res.data) {
-          this.totalData = res.data
+          const mergedList = this.countLabel.map(item => {
+            const key = item.key
+            return key in res.data
+              ? { ...item, [key]: res.data[key] }
+              : item
+          })
+          this.totalData = mergedList
         } else {
           this.totalData = null
         }
@@ -330,26 +292,24 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.queryType = 'month'
+      this.queryParam.beginDate = moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      this.queryParam.endDate = moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
       this.monthVal = moment().format('YYYY-MM')
-      this.queryParam.queryDate = moment().format('YYYYMM')
       this.queryParam.dealerEntity.provinceSn = undefined
       this.queryParam.dealerEntity.citySn = undefined
       this.queryParam.dealerEntity.districtSn = undefined
       this.queryParam.dealerEntity.dealerName = undefined
       this.queryParam.customSn = undefined
-      this.queryParam.bizUserSn = undefined
       this.queryParam.subareaArea.subareaSn = ''
       this.queryParam.subareaArea.subareaAreaSn = ''
       this.queryParam.subareaArea.bizUserSn = undefined
       this.queryParam.dealerLevel = undefined
-      this.queryParam.provinceFlag = undefined
-      this.$refs.subarea.clearData()
+      this.$refs.dealerSubareaScopeList.resetForm()
       if (this.advanced) {
-        this.$refs.dealerSubareaScopeList.resetForm()
+        this.$refs.subarea.clearData()
+        this.$refs.areaList.clearData()
       }
       this.totalData = null
-      this.$refs.areaList.clearData()
       this.$refs.table.clearTable()
       this.$refs.ruleForm.resetFields()
     },
@@ -371,7 +331,7 @@ export default {
       const params = JSON.parse(JSON.stringify(_this.queryParam))
       _this.exportLoading = true
       _this.spinning = true
-      hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
+      hdExportExcel(promoSalesExpenseExport, params, '促销费用报表', function () {
         _this.exportLoading = false
         _this.spinning = false
       })
@@ -380,8 +340,8 @@ export default {
     pageInit () {
       this.$nextTick(() => { // 页面渲染完成后的回调
         this.setTableH()
+        this.resetSearchForm()
       })
-      this.resetSearchForm()
     },
     // 计算表格高度
     setTableH () {
@@ -392,11 +352,13 @@ export default {
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
+      this.getTableTitle()
     }
   },
   activated () {
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
+      this.getTableTitle()
       this.pageInit()
     }
   }

+ 77 - 74
src/views/reportData/promotionFeeReport/customerFeeList.vue

@@ -12,7 +12,7 @@
           :model="queryParam">
           <a-row :gutter="15">
             <a-col :md="6" :sm="24">
-              <a-form-model-item label="月份" prop="queryDate">
+              <a-form-model-item label="月份" prop="beginDate">
                 <a-month-picker
                   id="customerFeeList-monthBox"
                   class="monthBox"
@@ -56,7 +56,7 @@
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-model-item label="客服">
-                  <customerService ref="customerName" id="customerFeeList-customerName" v-model="queryParam.bizUserSn"></customerService>
+                  <customerService ref="customerName" id="customerFeeList-customerName" v-model="queryParam.kfSn"></customerService>
                 </a-form-model-item>
               </a-col>
             </template>
@@ -122,7 +122,7 @@ import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
 import BizUser from '@/views/common/bizUser.js'
 import customerService from '@/views/common/customerService.vue'
 // 接口
-import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
+import { promoSalesExpenseList, promoSalesExpenseTitle, promoSalesExpenseCount, promoSalesExpenseExport } from '@/api/reportData'
 export default {
   name: 'CustomerFeeList',
   mixins: [commonMixin],
@@ -137,10 +137,11 @@ export default {
       monthVal: moment().format('YYYY-MM'), // 初始化月份值
       //  查询条件
       queryParam: {
-        queryType: 'month', // 开单统计报表(客户)
-        queryDate: moment().format('YYYYMM'), // 选择月份
-        dealerLevel: undefined, // 客户等级
-        customSn: undefined, // 客户sn
+        amountType: 'promo',
+        beginDate: moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00', // 月份开始时间
+        endDate: moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59', // 月份结束时间
+        dealerLevel: undefined, // 客户级别
+        dealerSn: undefined, // 客户sn
         dealerEntity: {
           dealerName: undefined, // 客户名称
           provinceSn: undefined, // 省
@@ -152,11 +153,13 @@ export default {
           subareaAreaSn: '', // 分区
           bizUserSn: undefined// 区域负责人
         },
-        bizUserSn: undefined// 客服
+        kfSn: undefined// 客服
       },
+      columns: [], // 表头
+      countLabel: null, // 合计名称
       totalData: null, // 合计
       rules: {
-        'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
+        'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
       },
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -164,7 +167,7 @@ export default {
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
         // 获取列表数据  有分页
-        return tireFeeReportList(params).then(res => {
+        return promoSalesExpenseList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -174,6 +177,8 @@ export default {
               data.list[i].no = no + i + 1
             }
             this.disabled = false
+            // 统计
+            // this.getCount(params)
           }
           this.spinning = false
           return data
@@ -192,57 +197,6 @@ export default {
       this.setTableH()
     }
   },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '40px', align: 'center', fixed: 'left' },
-        { title: '月份', dataIndex: 'monthData', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '省份', dataIndex: 'dealerEntity.provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true, fixed: 'left' },
-        { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '箭牌滤清器', dataIndex: 'serviceAmountProvince', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌变速箱滤清器', dataIndex: 'serviceAmountProvince1', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌滤清器', dataIndex: 'serviceAmountProvince2', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '滤清器合计', dataIndex: 'serviceAmountProvince3', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨刮片', dataIndex: 'serviceAmountProvince4', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨燕雨刮片', dataIndex: 'serviceAmountProvince5', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌雨刮片', dataIndex: 'serviceAmountProvince6', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '雨刮片合计', dataIndex: 'serviceAmountProvince7', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌喇叭', dataIndex: 'serviceAmountProvince8', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌刹车片', dataIndex: 'serviceAmountProvince9', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU+箭牌感应线', dataIndex: 'serviceAmountProvincea', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌刹车片', dataIndex: 'serviceAmountProvincec', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车片', dataIndex: 'serviceAmountProvinceb', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU至惠刹车片', dataIndex: 'serviceAmountProvinced', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车油', dataIndex: 'serviceAmountProvincee', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU-P刹车盘', dataIndex: 'serviceAmountProvincef', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '制动系统合计', dataIndex: 'serviceAmountProvinceg', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '汇箭蓄电池', dataIndex: 'serviceAmountProvinceh', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '布瑞斯蓄电池', dataIndex: 'serviceAmountProvincei', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '蓄电池合计', dataIndex: 'serviceAmountProvincej', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯机油', dataIndex: 'serviceAmountProvincek21', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯变速箱油', dataIndex: 'serviceAmountProvincek', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯刹车油', dataIndex: 'serviceAmountProvincel', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯汽车养护产品', dataIndex: 'serviceAmountProvincem', width: '120px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '科润星机油', dataIndex: 'serviceAmountProvince12', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '油品合计', dataIndex: 'serviceAmountProvince13', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升点火线圈', dataIndex: 'serviceAmountProvince14', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升LED灯', dataIndex: 'serviceAmountProvince15', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升合计', dataIndex: 'serviceAmountProvince16', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类', dataIndex: 'serviceAmountProvince17', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '品牌合计', dataIndex: 'serviceAmountProvince99', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '轮胎', dataIndex: 'serviceAmountProvince18', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'NGk火花塞', dataIndex: 'serviceAmountProvince19', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类(含轮胎、NGM)', dataIndex: 'serviceAmountProvince22', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
-      ]
-      return arr
-    }
-
-  },
   methods: {
     // 选择月份  禁用选择当月以后日期
     disabledDate (current) {
@@ -252,11 +206,43 @@ export default {
     onChangeMonth (date, dateString) {
       this.monthVal = dateString
       if (date && dateString != '') {
-        this.queryParam.queryDate = dateString.replace('-', '')
+        this.queryParam.beginDate = this.getMonthRange(dateString).firstDay
+        this.queryParam.endDate = this.getMonthRange(dateString).lastDay
       } else {
-        this.queryParam.queryDate = void 0
+        this.queryParam.beginDate = undefined
+        this.queryParam.endDate = undefined
       }
     },
+    // 获取指定月份   第一天和最后一天
+    getMonthRange (targetMonth) {
+      // 获取指定月第一天(格式化为 YYYY-MM-DD)
+      const firstDay = moment(targetMonth).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      // 获取指定月最后一天(格式化为 YYYY-MM-DD)
+      const lastDay = moment(targetMonth).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
+      return { firstDay, lastDay }
+    },
+    // 获取表头
+    async getTableTitle () {
+      const _this = this
+      const tableTitle = await promoSalesExpenseTitle().then(res => res.data)
+      this.columns = tableTitle.list
+      this.columns.unshift({ title: '序号', dataIndex: 'no', fixed: 'left', align: 'center' })
+      this.countLabel = tableTitle.count
+      this.columns.map(item => {
+        let mw = 20
+        if (item.customRender == 'amount') {
+          mw = 15
+          item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
+        } else {
+          item.customRender = function (text) { return text || '--' }
+        }
+        const w = item.title.length * mw
+        const tw = w <= 80 ? mw * 5 : w
+        item.width = tw + 'px'
+        this.tableWidth = this.tableWidth + tw
+      })
+      this.resetSearchForm()
+    },
     // 查询
     handleSearch () {
       const _this = this
@@ -272,7 +258,7 @@ export default {
     // 客户名称 change
     custChange (val) {
       this.queryParam.dealerEntity.dealerName = val.name
-      this.queryParam.customSn = val.key
+      this.queryParam.dealerSn = val.key
     },
     // 地区
     areaChange (val) {
@@ -287,26 +273,25 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.queryType = 'month'
+      this.queryParam.beginDate = moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      this.queryParam.endDate = moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
       this.monthVal = moment().format('YYYY-MM')
-      this.queryParam.queryDate = moment().format('YYYYMM')
       this.queryParam.dealerEntity.provinceSn = undefined
       this.queryParam.dealerEntity.citySn = undefined
       this.queryParam.dealerEntity.districtSn = undefined
       this.queryParam.dealerEntity.dealerName = undefined
-      this.queryParam.customSn = undefined
-      this.queryParam.bizUserSn = undefined
+      this.queryParam.dealerSn = undefined
       this.queryParam.subareaArea.subareaSn = ''
       this.queryParam.subareaArea.subareaAreaSn = ''
       this.queryParam.subareaArea.bizUserSn = undefined
       this.queryParam.dealerLevel = undefined
-      this.queryParam.provinceFlag = undefined
-      this.$refs.subarea.clearData()
+      this.queryParam.kfSn = undefined
+      this.$refs.dealerSubareaScopeList.resetForm()
       if (this.advanced) {
-        this.$refs.dealerSubareaScopeList.resetForm()
+        this.$refs.subarea.clearData()
+        this.$refs.areaList.clearData()
       }
       this.totalData = null
-      this.$refs.areaList.clearData()
       this.$refs.table.clearTable()
       this.$refs.ruleForm.resetFields()
     },
@@ -328,17 +313,33 @@ export default {
       const params = JSON.parse(JSON.stringify(_this.queryParam))
       _this.exportLoading = true
       _this.spinning = true
-      hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
+      hdExportExcel(promoSalesExpenseExport, params, '促销费用报表(客户)', function () {
         _this.exportLoading = false
         _this.spinning = false
       })
     },
+    // 统计
+    getCount (params) {
+      promoSalesExpenseCount(params).then(res => {
+        if (res.status == 200 && res.data) {
+          const mergedList = this.countLabel.map(item => {
+            const key = item.key
+            return key in res.data
+              ? { ...item, [key]: res.data[key] }
+              : item
+          })
+          this.totalData = mergedList
+        } else {
+          this.totalData = null
+        }
+      })
+    },
     // 初始化
     pageInit () {
       this.$nextTick(() => { // 页面渲染完成后的回调
         this.setTableH()
+        this.resetSearchForm()
       })
-      this.resetSearchForm()
     },
     // 计算表格高度
     setTableH () {
@@ -349,12 +350,14 @@ export default {
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
+      this.getTableTitle()
     }
   },
   activated () {
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
       this.pageInit()
+      this.getTableTitle()
     }
   }
 }

+ 3 - 3
src/views/reportData/promotionFeeReport/index.vue

@@ -9,7 +9,7 @@
           <provinceFeeList ref="provinceFeeList"></provinceFeeList>
         </a-tab-pane>
         <a-tab-pane key="3" tab="促销销售费用报表" force-render>
-          <PromotionFeeList ref="promotionFeeList"></PromotionFeeList>
+          <promotionFeeList ref="promotionFeeList"></promotionFeeList>
         </a-tab-pane>
       </a-tabs>
     </a-card>
@@ -20,11 +20,11 @@ import { commonMixin } from '@/utils/mixin'
 // 组件
 import customerFeeList from './customerFeeList.vue'
 import provinceFeeList from './provinceFeeList.vue'
-import PromotionFeeList from './PromotionFeeList.vue'
+import promotionFeeList from './promotionFeeList.vue'
 export default {
   name: 'PromotionFeeReportIndex',
   mixins: [commonMixin],
-  components: { customerFeeList, provinceFeeList, PromotionFeeList },
+  components: { customerFeeList, provinceFeeList, promotionFeeList },
   data () {
     return {
       tabVal: 1 // tab值  1轮胎月度费用报表 2轮胎季度费用报表 3轮胎年度费用报表 4轮胎费用明细报表

+ 77 - 78
src/views/reportData/promotionFeeReport/provinceFeeList.vue

@@ -12,7 +12,7 @@
           :model="queryParam">
           <a-row :gutter="15">
             <a-col :md="5" :sm="24">
-              <a-form-model-item label="月份" prop="queryDate">
+              <a-form-model-item label="月份" prop="beginDate">
                 <a-month-picker
                   id="provinceFeeList-monthBox"
                   class="monthBox"
@@ -24,7 +24,7 @@
             </a-col>
             <a-col :md="5" :sm="24">
               <a-form-model-item label="地区">
-                <AreaList id="provinceFeeList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
+                <Area id="provinceFeeList-areaList" v-model="queryParam.provinceSn" placeholder="请选择省份"></Area>
               </a-form-model-item>
             </a-col>
             <a-col :md="5" :sm="24">
@@ -69,13 +69,13 @@
           class="sTable fixPagination"
           ref="table"
           size="small"
-          :rowKey="(record) => record.no"
-          rowKeyName="no"
+          :rowKey="(record) => record.id"
           :style="{ height: tableHeight+70+'px' }"
           :columns="columns"
           :data="loadData"
           :scroll="{x:2200, y: tableHeight-120}"
           :defaultLoadData="false"
+          :showPagination="false"
           bordered>
         </s-table>
       </a-spin>
@@ -90,39 +90,38 @@ import moment from 'moment'
 // 组件
 import { STable, VSelect } from '@/components'
 import subarea from '@/views/common/subarea.js'
-import AreaList from '@/views/common/areaList.js'
+import Area from '@/views/common/area.js'
 import BizUser from '@/views/common/bizUser.js'
 import customerService from '@/views/common/customerService.vue'
 // 接口
-import { tireFeeReportList, tireFeeListExport } from '@/api/reportData'
+import { promoProvinceList, promoProvinceTableTitle, promoProvinceCount, promoProvinceExport } from '@/api/reportData'
 export default {
   name: 'ProvinceFeeList',
   mixins: [commonMixin],
-  components: { STable, VSelect, subarea, AreaList, BizUser, customerService },
+  components: { STable, VSelect, subarea, Area, BizUser, customerService },
   data () {
     return {
       spinning: false,
       disabled: false, //  查询、重置按钮是否可操作
       tableHeight: 0, // 表格高度
       exportLoading: false, // 导出按钮加载状态
-      monthVal: moment().format('YYYY-MM'), // 初始化月份值
       //  查询条件
+      monthVal: moment().format('YYYY-MM'), // 初始化月份值
       queryParam: {
-        queryType: 'month', // 促销费用报表(省份)
-        queryDate: moment().format('YYYYMM'), // 选择月份
-        dealerEntity: {
-          provinceSn: undefined, // 省
-          citySn: undefined, // 市
-          districtSn: undefined // 区
-        },
+        beginDate: moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00', // 月份开始时间
+        endDate: moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59', // 月份结束时间
+        provinceSn: undefined, // 省
         subareaArea: {
           subareaSn: '', // 区域
           subareaAreaSn: '', // 分区
           bizUserSn: undefined// 区域负责人
         }
       },
+      countLabel: null, // 统计名称合集
+      totalData: null, // 统计数据
+      columns: [], // 表格列
       rules: {
-        'queryDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
+        'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
       },
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -130,16 +129,17 @@ export default {
         this.spinning = true
         const params = Object.assign(parameter, this.queryParam)
         // 获取列表数据  有分页
-        return tireFeeReportList(params).then(res => {
+        return promoProvinceList(params).then(res => {
           let data
           if (res.status == 200) {
             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
+            for (var i = 0; i < data.length; i++) {
+              data[i].no = i + 1
             }
             this.disabled = false
+            // 统计
+            // this.getCount(params)
           }
           this.spinning = false
           return data
@@ -147,54 +147,6 @@ export default {
       }
     }
   },
-  computed: {
-    columns () {
-      const _this = this
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '40px', align: 'center', fixed: 'left' },
-        { title: '月份', dataIndex: 'monthData', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '区域负责人', dataIndex: 'subareaArea.bizUserName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '省份', dataIndex: 'dealerEntity.provinceName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '箭牌滤清器', dataIndex: 'serviceAmountProvince', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌变速箱滤清器', dataIndex: 'serviceAmountProvince1', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌滤清器', dataIndex: 'serviceAmountProvince2', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '滤清器合计', dataIndex: 'serviceAmountProvince3', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨刮片', dataIndex: 'serviceAmountProvince4', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌雨燕雨刮片', dataIndex: 'serviceAmountProvince5', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌雨刮片', dataIndex: 'serviceAmountProvince6', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '雨刮片合计', dataIndex: 'serviceAmountProvince7', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌喇叭', dataIndex: 'serviceAmountProvince8', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '箭牌刹车片', dataIndex: 'serviceAmountProvince9', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU+箭牌感应线', dataIndex: 'serviceAmountProvincea', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '冠牌刹车片', dataIndex: 'serviceAmountProvincec', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车片', dataIndex: 'serviceAmountProvinceb', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU至惠刹车片', dataIndex: 'serviceAmountProvinced', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU刹车油', dataIndex: 'serviceAmountProvincee', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'TBU-P刹车盘', dataIndex: 'serviceAmountProvincef', width: '110px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '制动系统合计', dataIndex: 'serviceAmountProvinceg', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '汇箭蓄电池', dataIndex: 'serviceAmountProvinceh', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '布瑞斯蓄电池', dataIndex: 'serviceAmountProvincei', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '蓄电池合计', dataIndex: 'serviceAmountProvincej', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯机油', dataIndex: 'serviceAmountProvincek21', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯变速箱油', dataIndex: 'serviceAmountProvincek', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯刹车油', dataIndex: 'serviceAmountProvincel', width: '90px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '德路斯汽车养护产品', dataIndex: 'serviceAmountProvincem', width: '120px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '科润星机油', dataIndex: 'serviceAmountProvince12', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '油品合计', dataIndex: 'serviceAmountProvince13', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升点火线圈', dataIndex: 'serviceAmountProvince14', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升LED灯', dataIndex: 'serviceAmountProvince15', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '稳升合计', dataIndex: 'serviceAmountProvince16', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类', dataIndex: 'serviceAmountProvince17', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '品牌合计', dataIndex: 'serviceAmountProvince99', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '轮胎', dataIndex: 'serviceAmountProvince18', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: 'NGk火花塞', dataIndex: 'serviceAmountProvince19', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '全品类(含轮胎、NGM)', dataIndex: 'serviceAmountProvince22', width: '80px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
-      ]
-      return arr
-    }
-
-  },
   methods: {
     // 选择月份  禁用选择当月以后日期
     disabledDate (current) {
@@ -204,11 +156,59 @@ export default {
     onChangeMonth (date, dateString) {
       this.monthVal = dateString
       if (date && dateString != '') {
-        this.queryParam.queryDate = dateString.replace('-', '')
+        this.queryParam.beginDate = this.getMonthRange(dateString).firstDay
+        this.queryParam.endDate = this.getMonthRange(dateString).lastDay
       } else {
-        this.queryParam.queryDate = void 0
+        this.queryParam.beginDate = undefined
+        this.queryParam.endDate = undefined
       }
     },
+    // 获取指定月份   第一天和最后一天
+    getMonthRange (targetMonth) {
+      // 获取指定月第一天(格式化为 YYYY-MM-DD)
+      const firstDay = moment(targetMonth).startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      // 获取指定月最后一天(格式化为 YYYY-MM-DD)
+      const lastDay = moment(targetMonth).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
+      return { firstDay, lastDay }
+    },
+    // 获取表头
+    async getTableTitle () {
+      const _this = this
+      const tableTitle = await promoProvinceTableTitle().then(res => res.data)
+      this.columns = tableTitle.list
+      this.columns.unshift({ title: '序号', dataIndex: 'no', fixed: 'left', align: 'center' })
+      this.countLabel = tableTitle.count
+      this.columns.map(item => {
+        let mw = 20
+        if (item.customRender == 'amount') {
+          mw = 15
+          item.customRender = function (text) { return (text || text == 0) ? _this.toThousands(text) : '--' }
+        } else {
+          item.customRender = function (text) { return text || '--' }
+        }
+        const w = item.title.length * mw
+        const tw = w <= 80 ? mw * 5 : w
+        item.width = tw + 'px'
+        this.tableWidth = this.tableWidth + tw
+      })
+      this.resetSearchForm()
+    },
+    // 统计
+    getCount (params) {
+      promoProvinceCount(params).then(res => {
+        if (res.status == 200 && res.data) {
+          const mergedList = this.countLabel.map(item => {
+            const key = item.key
+            return key in res.data
+              ? { ...item, [key]: res.data[key] }
+              : item
+          })
+          this.totalData = mergedList
+        } else {
+          this.totalData = null
+        }
+      })
+    },
     // 查询
     handleSearch () {
       const _this = this
@@ -234,16 +234,13 @@ export default {
     },
     //  重置
     resetSearchForm () {
-      this.queryParam.queryType = 'month'
+      this.queryParam.beginDate = moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00'
+      this.queryParam.endDate = moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
       this.monthVal = moment().format('YYYY-MM')
-      this.queryParam.queryDate = moment().format('YYYYMM')
-      this.queryParam.dealerEntity.provinceSn = undefined
-      this.queryParam.dealerEntity.citySn = undefined
-      this.queryParam.dealerEntity.districtSn = undefined
+      this.queryParam.provinceSn = undefined
       this.queryParam.subareaArea.subareaSn = ''
       this.queryParam.subareaArea.subareaAreaSn = ''
       this.queryParam.subareaArea.bizUserSn = undefined
-      this.queryParam.provinceFlag = undefined
       this.$refs.subarea.clearData()
       this.totalData = null
       this.$refs.areaList.clearData()
@@ -268,7 +265,7 @@ export default {
       const params = JSON.parse(JSON.stringify(_this.queryParam))
       _this.exportLoading = true
       _this.spinning = true
-      hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
+      hdExportExcel(promoProvinceExport, params, '促销费用报表(省份)', function () {
         _this.exportLoading = false
         _this.spinning = false
       })
@@ -277,8 +274,8 @@ export default {
     pageInit () {
       this.$nextTick(() => { // 页面渲染完成后的回调
         this.setTableH()
+        this.resetSearchForm()
       })
-      this.resetSearchForm()
     },
     // 计算表格高度
     setTableH () {
@@ -289,12 +286,14 @@ export default {
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
+      this.getTableTitle()
     }
   },
   activated () {
     // 如果是新页签打开,则重置当前页面
     if (this.$store.state.app.isNewTab) {
       this.pageInit()
+      this.getTableTitle()
     }
   }
 }