lilei 1 miesiąc temu
rodzic
commit
6a53409b35

+ 13 - 0
src/api/reportData.js

@@ -1,4 +1,17 @@
 import { axios } from '@/utils/request'
+
+// 每日报表
+export const salesReportDailyList = (params) => {
+  const url = `/report/reportData/query`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('每日报表查询')
+    }
+  })
+}
 // 获取开单退货单表头
 export const salesReportReturnTitle = (params) => {
   return axios({

+ 65 - 41
src/views/reportData/dailyReport/index.vue

@@ -51,22 +51,34 @@
         <table0
           v-if="activeKey == 0"
           ref="table0"
-          :totalData="totalData"
+          :month="queryParam.month"
+          :columns="columns"
+          :tableData="tableData"
+          :nowDate="nowDate"
         ></table0>
         <table1
           v-if="activeKey == 1"
           ref="table1"
-          :totalData="totalData"
+          :month="queryParam.month"
+          :columns="columns"
+          :tableData="tableData"
+          :nowDate="nowDate"
         ></table1>
         <table2
           v-if="activeKey == 2"
           ref="table2"
-          :totalData="totalData"
+          :month="queryParam.month"
+          :columns="columns"
+          :tableData="tableData"
+          :nowDate="nowDate"
         ></table2>
         <table3
           v-if="activeKey == 3"
           ref="table3"
-          :totalData="totalData"
+          :month="queryParam.month"
+          :columns="columns"
+          :tableData="tableData"
+          :nowDate="nowDate"
         ></table3>
       </a-card>
     </a-spin>
@@ -75,9 +87,7 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { hdExportExcel } from '@/libs/exportExcel'
 import XLSX from 'xlsx-js-style'
-
 // 组件
 import rangeDate from '@/views/common/rangeDate.vue'
 import moment from 'moment'
@@ -86,7 +96,7 @@ import table1 from './table1'
 import table2 from './table2'
 import table3 from './table3'
 // 接口
-import { subareaAreaReportTitle } from '@/api/reportData.js'
+import { salesReportDailyList } from '@/api/reportData.js'
 export default {
   name: 'RegionTypeSalesReportList',
   mixins: [commonMixin],
@@ -101,14 +111,16 @@ export default {
       tableHeight: 0, // 表格高度
       tabsList: [{ id: 0, name: '全国销售日报' }, { id: 1, name: '项目销售日报1' }, { id: 2, name: '项目销售日报2' }, { id: 3, name: '分区销售日报' }], // tab切换data
       columns: [], // 表头数据
-      totalData: null, // 统计
+      tableData: [], // 表格数据
+      totalNums: 0, // 总条数
       // 查询参数
       queryParam: {
         month: moment().format('YYYY-MM') // 月份默认值
       },
       rules: {
         'month': [{ required: true, message: '请选择月份', trigger: 'change' }]
-      }
+      },
+      nowDate: ''
     }
   },
   methods: {
@@ -125,8 +137,7 @@ export default {
       this.activeKey = key
       const _this = this
       _this.$nextTick(() => {
-        this.getTableData()
-        this.setTableH()
+        this.resetSearchForm()
       })
     },
     // 查询
@@ -134,7 +145,7 @@ export default {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
-          _this.$refs.table.refresh(true)
+          _this.getTableData()
         } else {
           _this.$message.error('请选择月份')
           return false
@@ -146,9 +157,10 @@ export default {
       this.$refs.ruleForm.resetFields()
       this.queryParam.time = []
       this.$refs.rangeDate.resetDate(this.queryParam.time)
-      this.$refs.table.clearTable()
+      this.tableData = []
     },
     exportTable (dom, title) {
+      const zim = 'A、B、C、D、E、F、G、H、I、J、K、L、M、N、O、P、Q、R、S、T、U、V、W、X、Y、Z‌'.split('、')
       var ws = XLSX.utils.table_to_sheet(dom)
       var wb = XLSX.utils.book_new()
       console.log(ws)
@@ -163,9 +175,19 @@ export default {
           }
         }
       })
-      ws['C5'].z = (ws['C5'].v * 100) + '%' // 设置单元格格式为百分比
+      // 表格1
+      if (this.activeKey == 1) {
+        const cols = zim[this.columns.length - 1]
+        Array(this.totalNums).fill().forEach((item, i) => {
+          const a = ws[cols + (i + 2)]
+          console.log(cols + (i + 2))
+          if (a) {
+            a.z = (a.v * 100) + '%' // 设置单元格格式为百分比
+          }
+        })
+      }
       // 4. 设置列宽
-      ws['!cols'] = Array(5).fill().map(() => ({ wch: 35 }))
+      ws['!cols'] = Array(this.columns.length).fill().map(() => ({ wch: 35 }))
 
       XLSX.utils.book_append_sheet(wb, ws, 'Sheet1')
       XLSX.writeFile(wb, this.queryParam.month + title + '.xlsx')
@@ -175,43 +197,45 @@ export default {
       const excelTitle = this.tabsList.find(item => item.id == this.activeKey)
       if (this.$refs.table0 && this.activeKey == 0) {
         this.exportTable(this.$refs.table0.getTable(), excelTitle.name)
+      } else if (this.$refs.table1 && this.activeKey == 1) {
+        this.totalNums = this.$refs.table1.list.length
+        this.exportTable(this.$refs.table1.getTable(), excelTitle.name)
+      } else if (this.$refs.table2 && this.activeKey == 2) {
+        this.exportTable(this.$refs.table2.getTable(), excelTitle.name)
+      } else if (this.$refs.table3 && this.activeKey == 3) {
+        this.exportTable(this.$refs.table3.getTable(), excelTitle.name)
       }
-      // const _this = this
-      // const url = [subareaAreaReportTitle, subareaAreaReportTitle, subareaAreaReportTitle, subareaAreaReportTitle]
-      // const excelTitle = this.tabsList.find(item => item.id == _this.activeKey)
-      // this.$refs.ruleForm.validate(valid => {
-      //   if (valid) {
-      //     const params = _this.queryParam
-      //     _this.exportLoading = true
-      //     _this.spinning = true
-      //     hdExportExcel(url[this.activeKey], params, excelTitle.name, function () {
-      //       _this.exportLoading = false
-      //       _this.spinning = false
-      //       _this.$store.state.app.curActionPermission = ''
-      //     })
-      //   } else {
-      //     return false
-      //   }
-      // })
     },
     // 获取表格数据
     async getTableData () {
-      const url = [subareaAreaReportTitle, subareaAreaReportTitle, subareaAreaReportTitle, subareaAreaReportTitle]
-      const data = await url[this.activeKey](this.queryParam).then(res => res.data)
+      const url = [salesReportDailyList, salesReportDailyList, salesReportDailyList, salesReportDailyList]
+      const reportType = ['DailyPL', 'DailyPL', 'DailyPL', 'DailyPL'][this.activeKey]
+      const reportDate = this.queryParam.month + '-01 00:00:00'
+      this.nowDate = moment().format('DD日HH点mm分')
+      this.spinning = true
+      const data = await url[this.activeKey]({ reportType, reportDate }).then(res => res.data)
       if (data) {
         this.tableData = data
+        this.columns = this.getColumns()
+        this.spinning = false
+      }
+    },
+    getColumns () {
+      const row = this.tableData[0]
+      const ret = []
+      if (row) {
+        row.detailList[0].forEach(item => {
+          ret.push(item)
+        })
+        ret.push(row.bymb)
+        ret.push(row.wcl)
       }
+      return ret
     },
     // 初始化
     pageInit () {
       this.activeKey = 0
-      this.getTableData()
-      this.setTableH()
-    },
-    // 计算表格高度
-    setTableH () {
-      const tableSearchH = this.$refs.tableSearch.offsetHeight
-      this.tableHeight = window.innerHeight - tableSearchH - 250
+      this.tableData = []
     }
   },
   mounted () {

+ 62 - 33
src/views/reportData/dailyReport/table1.vue

@@ -1,47 +1,31 @@
 <template>
   <div>
     <!-- 项目销售日报 -->
-    <h2 class="table-title">2025年3月 项目销售日报(截止22日17点30分)</h2>
-    <table class="table-box">
+    <h2 class="table-title" v-if="tableData.length">{{ month.replace('-','年')+'月' }} 项目销售日报(截止{{ nowDate }})</h2>
+    <table class="table-box" id="day-table-1" v-if="tableData.length">
       <thead>
         <tr>
-          <th></th>
-          <th>销售部</th>
-          <th>东莞服务中心</th>
-          <th>销售额合计</th>
-          <th>本月目标</th>
-          <th>完成率</th>
+          <th v-for="item in columns" :key="item">{{ item }}</th>
         </tr>
       </thead>
       <tbody>
-        <tr>
-          <td width="150">箭牌滤清器</td>
-          <td align="right">141,150,000.00</td>
-          <td align="right">10,850,000.00</td>
-          <td align="right">10,850,000.00</td>
-          <td rowspan="4" width="150" align="right">152,000,000.00</td>
-          <td rowspan="4" width="150" align="center">46464646</td>
-        </tr>
-        <tr>
-          <td>箭牌滤清器</td>
-          <td align="right">11,553,506.00</td>
-          <td align="right">3,199,085.00</td>
-          <td align="right">14,752,590.00</td>
-        </tr>
-        <tr>
-          <td>箭牌滤清器</td>
-          <td align="right">14,863,711.00</td>
-          <td align="right">3,942,037.00</td>
-          <td align="right">18,805,748.00</td>
-        </tr>
-        <tr>
-          <td>箭牌滤清器</td>
-          <td align="right">9,858,800.00</td>
-          <td align="right">2,481,200.00</td>
-          <td align="right">12,340,000.00</td>
+        <tr v-for="(sitem,index) in list" :key="index">
+          <td
+            width="150"
+            v-for="(td,tdi) in sitem"
+            :key="tdi+'td'"
+            :rowspan="hasRowspan(td)[1]"
+            :align="typeof td == 'number' ? 'right':'center'"
+            :class="hasRed(td)?'red':''"
+          >
+            {{ hasRowspan(td)[1] ? hasRowspan(td)[0] : td }}
+          </td>
         </tr>
       </tbody>
     </table>
+    <div v-else class="noData">
+      暂无数据,请点击查询
+    </div>
   </div>
 </template>
 
@@ -52,9 +36,43 @@ export default {
     tableData: {
       type: Array,
       default: () => []
+    },
+    month: {
+      type: String,
+      default: () => ''
+    },
+    columns: {
+      type: Array,
+      default: () => []
+    },
+    nowDate: {
+      type: String,
+      default: () => ''
+    }
+  },
+  computed: {
+    list () {
+      let rets = []
+      this.tableData.forEach((item, i) => {
+        if (i > 0) {
+          item.detailList[0].push(item.bymb + 'rowspan' + item.detailList.length, item.wcl + 'rowspan' + item.detailList.length)
+          rets = rets.concat(item.detailList)
+        }
+      })
+      return rets
     }
   },
   methods: {
+    hasRowspan (row) {
+      return row.toString().split('rowspan')
+    },
+    hasRed (row) {
+      const arr = ['合计', '箭牌喇叭', '制动系统']
+      return arr.find(item => row.toString().indexOf(item) >= 0)
+    },
+    getTable () {
+      return document.getElementById('day-table-1')
+    }
   }
 }
 </script>
@@ -68,10 +86,21 @@ export default {
     max-width: 1024px;
     text-align: center;
   }
+  .noData{
+    width: 100%;
+    text-align: center;
+    font-size: 16px;
+    color: #999;
+    min-height: 100px;
+    line-height: 100px;
+  }
   .table-box{
     width: 100%;
     max-width: 1024px;
     font-size: 14px;
+    .red{
+      color: red;
+    }
     tr > th{
       padding: 6px 8px;
       border: 1px solid #eee;