Procházet zdrojové kódy

销售场次分析:销售量、核销量数据合计处理

shipeng před 1 měsícem
rodič
revize
9914ead01e
1 změnil soubory, kde provedl 36 přidání a 3 odebrání
  1. 36 3
      src/views/statisticalReport/session.vue

+ 36 - 3
src/views/statisticalReport/session.vue

@@ -30,7 +30,15 @@
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table ref="tables" v-loading="loading" :data="dataList" max-height="500px" border>
+    <el-table 
+      ref="tables" 
+      v-loading="loading" 
+      :data="dataList" 
+      max-height="500px" 
+      border 
+      :summary-method="getSummaries"
+      show-summary
+    >
       <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
       <!-- <el-table-column label="剧目名称" align="center" prop="performName" />
       <el-table-column label="票务名称" align="center" prop="goodsName" /> -->
@@ -44,12 +52,12 @@
           <span>{{ scope.row.performTimeStart }} -- {{ scope.row.performTimeEnd }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="销售量" align="center">
+      <el-table-column label="销售量" align="center" prop="saleTotal">
         <template slot-scope="scope">
           <span>{{ scope.row.saleTotal?scope.row.saleTotal+'张' : '-' }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="核销量" align="center">
+      <el-table-column label="核销量" align="center" prop="usedTotal">
         <template slot-scope="scope">
           <span>{{ scope.row.usedTotal?scope.row.usedTotal+'张' : '-' }}</span>
         </template>
@@ -129,6 +137,31 @@ export default {
     this.ticketListApi();
   },
   methods: {
+    getSummaries(param) {
+      const { columns, data } = param;
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          sums[index] = '合计';
+          return;
+        }
+        const values = data.map(item => Number(item[column.property]));
+        if (!values.every(value => isNaN(value))) {
+          sums[index] = values.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + curr;
+            } else {
+              return prev;
+            }
+          }, 0);
+          sums[index] += ' 张';
+        } else {
+          sums[index] = '';
+        }
+      });
+      return sums;
+    },
     /** 查询列表 */
     getList() {
       this.loading = true;