Browse Source

feat: 企微数据 - 账号数据趋势 - adq & mp汇总接口联调

zhengxy 2 years ago
parent
commit
27c2667e76

+ 4 - 2
project/src/assets/config/interface_api.js

@@ -256,8 +256,10 @@ var api = {
256 256
   adqAccount_setAdqAccountReportRule: "/api/pitcher/setAdqAccountReportRule",
257 257
 
258 258
   dataBoard_dataCycleList: "/api/statistics/dataCycleList", // 数据循环统计
259
-  dataBoard_adqAccount: "/api/accountDataTrend/adqAccount", // 账号数据趋势 - adq
260
-  dataBoard_mpAccount: "/api/accountDataTrend/mpAccount", // 账号数据趋势 - mp
259
+  dataBoard_adqAccount: "/api/accountDataTrend/adqAccount", // 账号数据趋势 - adq列表
260
+  dataBoard_mpAccount: "/api/accountDataTrend/mpAccount", // 账号数据趋势 - mp列表
261
+  dataBoard_adqAccountSummary: "/api/accountDataTrend/adqAccountSummary", // 账号数据趋势 - adq汇总
262
+  dataBoard_mpAccountSummary: "/api/accountDataTrend/mpAccountSummary", // 账号数据趋势 - mp汇总
261 263
 };
262 264
 
263 265
 export { api };

+ 169 - 96
project/src/components/dataBoard/accountTrends.vue

@@ -40,101 +40,108 @@
40 40
     <!-- E 折线图 -->
41 41
 
42 42
     <!-- S 表 -->
43
-    <div v-loading="loading">
43
+
44 44
       <!-- S 汇总表 summaryTable -->
45
-      <ux-grid class="summaryTable" ref="summaryTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
46
-        <ux-table-column v-for="item in summaryTableCol" :key="item.column" :resizable="true" :field="item.column" :title="item.name" :min-width="item.min_width ? item.min_width : 120" :fixed="item.fixed ? item.fixed : ''" align="center">
47
-          <template #header>
48
-            <div class="flex-align-jus-center">
49
-              {{ item.name }}
50
-              <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
51
-                <div><i class="el-icon-question"></i></div>
52
-              </el-tooltip>
53
-            </div>
54
-          </template>
55
-          <template v-slot="{ row }">
56
-            <span>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
57
-          </template>
58
-        </ux-table-column>
59
-      </ux-grid>
45
+      <div v-loading="summaryLoading">
46
+        <ux-grid class="summaryTable" ref="summaryTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
47
+          <ux-table-column v-for="item in summaryTableCol" :key="item.column + item.name" :resizable="true" :field="item.column" :title="item.name" :min-width="item.min_width ? item.min_width : 140" :fixed="item.fixed ? item.fixed : ''" align="center">
48
+            <template #header>
49
+              <div class="flex-align-jus-center">
50
+                {{ item.name }}
51
+                <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
52
+                  <div><i class="el-icon-question"></i></div>
53
+                </el-tooltip>
54
+              </div>
55
+            </template>
56
+            <template v-slot="{ row }">
57
+              <!-- 时间 -->
58
+              <div v-if="item.name === '时间' || item.name === '账户'">
59
+                <span>汇总</span>
60
+              </div>
61
+              <span v-else>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
62
+            </template>
63
+          </ux-table-column>
64
+        </ux-grid>
65
+      </div>
60 66
       <!-- E 汇总表 summaryTable -->
61 67
       <!-- S 明细表 detailsTable -->
62
-      <ux-grid class="detailsTable" ref="detailsTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini">
63
-        <ux-table-column v-for="item in detailsTableCol" :key="item.column" :resizable="true" :field="item.column" :title="item.name" :min-width="item.min_width ? item.min_width : 140" :fixed="item.fixed ? item.fixed : ''" align="center">
64
-          <template #header>
65
-            <div class="flex-align-jus-center">
66
-              {{ item.name }}
67
-              <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
68
-                <div><i class="el-icon-question"></i></div>
69
-              </el-tooltip>
70
-              <div v-if="item.enable_to_sort" class="sort-wrap">
71
-                <i class="el-icon-caret-top" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'asc' }" @click="onClickSort(item.column, 'asc')" />
72
-                <i class="el-icon-caret-bottom" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'desc' }" @click="onClickSort(item.column, 'desc')" />
68
+      <div v-loading="detailLoading">
69
+        <ux-grid class="detailsTable" ref="detailsTable" :border="false" @row-click="() => { return }" :header-cell-style="getHeaderCellStyle" show-footer-overflow="tooltip" show-overflow="tooltip" size="mini" :height="height">
70
+          <ux-table-column v-for="item in detailsTableCol" :key="item.column" :resizable="true" :field="item.column" :title="item.name" :min-width="item.min_width ? item.min_width : 140" :fixed="item.fixed ? item.fixed : ''" align="center">
71
+            <template #header>
72
+              <div class="flex-align-jus-center">
73
+                {{ item.name }}
74
+                <el-tooltip v-if="item.notes" :content="item.notes" placement="top">
75
+                  <div><i class="el-icon-question"></i></div>
76
+                </el-tooltip>
77
+                <div v-if="item.enable_to_sort" class="sort-wrap">
78
+                  <i class="el-icon-caret-top" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'asc' }" @click="onClickSort(item.column, 'asc')" />
79
+                  <i class="el-icon-caret-bottom" :class="{ 'active': filter.sort_field === item.column && filter.sort_type === 'desc' }" @click="onClickSort(item.column, 'desc')" />
80
+                </div>
81
+              </div>
82
+            </template>
83
+            <template v-slot="{ row }">
84
+              <!-- 时间 -->
85
+              <div v-if="item.column === 'ref_date'">
86
+                <span>{{ row['expense_date'] }}</span><span v-if="row['expense_date_end']"> - {{ row['expense_date_end'] }}</span>
87
+              </div>
88
+              <!-- adq账号 -->
89
+              <span v-else-if="item.column === 'account_id'">
90
+                {{ row['account_id'] || '-' }}
91
+              </span>
92
+              <!-- 其他 -->
93
+              <span v-else>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
94
+            </template>
95
+          </ux-table-column>
96
+          <!-- DAY1、DAY2... -->
97
+          <ux-table-column width="120" v-for="(dayItem, dayIdx) in detailsTableColDays" :key="dayIdx + 'extra'">
98
+            <template #header>
99
+              <div class="flex-align-jus-center">{{ dayItem.name }}
100
+                <el-tooltip placement="top" v-if="dayIdx === 0">
101
+                  <div slot="content">充:这天的充值金额<br />回:截止这天的累计金额/当天消耗<br />增:这天回收金额/当天消耗<br />倍:累计金额/第一天累计金额<br />充值人数:这天充值的人数</div>
102
+                  <div><i class="el-icon-question" /></div>
103
+                </el-tooltip>
104
+              </div>
105
+            </template>
106
+            <template v-slot="{ row }">
107
+              <div>
108
+                <span class="font" style="color:#2C9841">充:</span>
109
+                <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].pay_money ?
110
+                    row.day_info[dayIdx].pay_money : '-'
111
+                }}</span>
112
+              </div>
113
+              <div>
114
+                <span class="font" style="color:#EB4315">回:</span>
115
+                <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].total_roi ?
116
+                    row.day_info[dayIdx].total_roi : '-'
117
+                }}</span>
118
+              </div>
119
+              <div>
120
+                <span class="font" style="color:#F28544">增:</span>
121
+                <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].new_roi ?
122
+                    row.day_info[dayIdx].new_roi : '-'
123
+                }}</span>
124
+              </div>
125
+              <div>
126
+                <span class="font" style="color:#2983DF">倍:</span>
127
+                <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].income_times ?
128
+                    row.day_info[dayIdx].income_times : '-'
129
+                }}</span>
130
+              </div>
131
+              <div>
132
+                <span class="font" style="color:#7366FF">充值人数:</span>
133
+                <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].charge_user ?
134
+                    row.day_info[dayIdx].charge_user : '-'
135
+                }}</span>
73 136
               </div>
74
-            </div>
75
-          </template>
76
-          <template v-slot="{ row }">
77
-            <!-- 时间 -->
78
-            <div v-if="item.column === 'ref_date'">
79
-              <span>{{ row['expense_date'] }}</span><span v-if="row['expense_date_end']"> - {{ row['expense_date_end'] }}</span>
80
-            </div>
81
-            <!-- adq账号 -->
82
-            <span v-else-if="item.column === 'account_id'">
83
-              {{ row['account_id'] || '-' }}
84
-            </span>
85
-            <!-- 其他 -->
86
-            <span v-else>{{ row[item.column] ? $formatNum(row[item.column]) : '-' }}</span>
87
-          </template>
88
-        </ux-table-column>
89
-        <!-- DAY1、DAY2... -->
90
-        <ux-table-column width="120" v-for="(dayItem, dayIdx) in detailsTableColDays" :key="dayIdx + 'extra'">
91
-          <template #header>
92
-            <div class="flex-align-jus-center">{{ dayItem.name }}
93
-              <el-tooltip placement="top" v-if="dayIdx === 0">
94
-                <div slot="content">充:这天的充值金额<br />回:截止这天的累计金额/当天消耗<br />增:这天回收金额/当天消耗<br />倍:累计金额/第一天累计金额<br />充值人数:这天充值的人数</div>
95
-                <div><i class="el-icon-question" /></div>
96
-              </el-tooltip>
97
-            </div>
98
-          </template>
99
-          <template v-slot="{ row }">
100
-            <div>
101
-              <span class="font" style="color:#2C9841">充:</span>
102
-              <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].pay_money ?
103
-                  row.day_info[dayIdx].pay_money : '-'
104
-              }}</span>
105
-            </div>
106
-            <div>
107
-              <span class="font" style="color:#EB4315">回:</span>
108
-              <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].total_roi ?
109
-                  row.day_info[dayIdx].total_roi : '-'
110
-              }}</span>
111
-            </div>
112
-            <div>
113
-              <span class="font" style="color:#F28544">增:</span>
114
-              <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].new_roi ?
115
-                  row.day_info[dayIdx].new_roi : '-'
116
-              }}</span>
117
-            </div>
118
-            <div>
119
-              <span class="font" style="color:#2983DF">倍:</span>
120
-              <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].income_times ?
121
-                  row.day_info[dayIdx].income_times : '-'
122
-              }}</span>
123
-            </div>
124
-            <div>
125
-              <span class="font" style="color:#7366FF">充值人数:</span>
126
-              <span>{{ row && row.day_info && row.day_info[dayIdx] && row.day_info[dayIdx].charge_user ?
127
-                  row.day_info[dayIdx].charge_user : '-'
128
-              }}</span>
129
-            </div>
130
-          </template>
131
-        </ux-table-column>
132
-      </ux-grid>
133
-      <div class="pagination" v-show="pagination.total > 0">
134
-        <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pagination.pages)' />
137
+            </template>
138
+          </ux-table-column>
139
+        </ux-grid>
140
+        <div class="pagination" v-show="pagination.total > 0">
141
+          <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pagination.pages)' />
142
+        </div>
135 143
       </div>
136 144
       <!-- E 明细表 detailsTable -->
137
-    </div>
138 145
     <!-- E 表 -->
139 146
   </div>
140 147
 </template>
@@ -158,6 +165,7 @@ export default {
158 165
     return {
159 166
       default_time: DEFAULT_TIME,
160 167
       reset: false,
168
+      height: '',
161 169
 
162 170
       chartLoading: false,
163 171
       myChart: null,
@@ -173,8 +181,9 @@ export default {
173 181
         { name: '30天倍率', key: 'charge_user_cost', color: '#E360C8', selectFlag: true },
174 182
       ],
175 183
 
176
-      loading: false,
184
+      summaryLoading: false,
177 185
       summaryTableCol: [],
186
+      detailLoading: false,
178 187
       detailsTableCol: [],
179 188
       detailsTableColDays: [],
180 189
       pagination: {
@@ -207,6 +216,8 @@ export default {
207 216
     },
208 217
   },
209 218
   created () {
219
+    this.initTableHeight()
220
+    this.handleGetSummaryList()
210 221
     this.handleGetList()
211 222
     this.handleGetChart()
212 223
   },
@@ -214,11 +225,63 @@ export default {
214 225
     this.myChart && this.myChart.clear()
215 226
   },
216 227
   methods: {
228
+    initTableHeight() {
229
+      this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
230
+    },
231
+    // 获取汇总表数据
232
+    async handleGetSummaryList() {
233
+      console.log('handleGetSummaryList => ',)
234
+      try {
235
+        this.summaryLoading = true
236
+        const params = {
237
+          start_date: this.filter.time[0],
238
+          end_date: this.filter.time[1],
239
+          closing_date: this.filter.closing_date,
240
+          plat_order_type: this.filter.plat_order_type,
241
+          cost_cover_min: this.filter.costCover[0],
242
+          cost_cover_max: this.filter.costCover[1],
243
+        }
244
+        let url = ''
245
+
246
+        if (this.isADQ) { // adq 参数 & api
247
+          params.account_id = this.filter.account_id_adq
248
+          url = `${this.URL.BASEURL}${this.URL.dataBoard_adqAccountSummary}`
249
+        } else if (this.isMP) { // mp 参数 & api
250
+          params.app_id = this.filter.account_id
251
+          url = `${this.URL.BASEURL}${this.URL.dataBoard_mpAccountSummary}`
252
+        }
253
+
254
+        const { data: res = {} } = await this.$axios.post(url, params)
255
+        if (res && res.errno == 0) {
256
+          // res.rst.header[0].fixed = 'left' // 前2列固定左侧
257
+          // res.rst.header[1].fixed = 'left' // 前2列固定左侧
258
+          const summaryTableCol = []
259
+          res.rst.header.forEach(item => {
260
+            if (item.name && item.name.length > 6) { // 长字符宽度
261
+              item['min_width'] = item.name.length * 20
262
+            }
263
+            summaryTableCol.push(item) // 收集普通表头
264
+          })
265
+          this.summaryTableCol = Object.freeze(summaryTableCol)
266
+          await this.$nextTick()
267
+          const summaryTableList = Array.isArray(res.rst.data) ? res.rst.data : [res.rst.data]
268
+          this.$refs.summaryTable.reloadData(summaryTableList)
269
+        } else if (res.errno != 4002) {
270
+          this.$message.warning(res.err)
271
+          this.$refs.summaryTable.reloadData([])
272
+        }
273
+      } catch (error) {
274
+        console.log(error)
275
+        this.$refs.summaryTable.reloadData([])
276
+      } finally {
277
+        this.summaryLoading = false
278
+      }
279
+    },
217 280
     // 获取列表数据
218 281
     async handleGetList() {
219 282
       console.log('handleGetList => ',)
220 283
       try {
221
-        this.loading = true
284
+        this.detailLoading = true
222 285
         const params = {
223 286
           page: this.pagination.page,
224 287
           page_size: this.pagination.page_size,
@@ -242,7 +305,6 @@ export default {
242 305
         }
243 306
 
244 307
         const { data: res = {} } = await this.$axios.post(url, params)
245
-        this.loading = false
246 308
         if (res && res.errno == 0) {
247 309
           res.rst.extra[0].fixed = 'left' // 前2列固定左侧
248 310
           res.rst.extra[1].fixed = 'left' // 前2列固定左侧
@@ -276,8 +338,11 @@ export default {
276 338
         }
277 339
       } catch (error) {
278 340
         console.log(error)
341
+        this.$refs.detailsTable.reloadData([])
342
+        this.pagination.total = 0
343
+        this.pagination.pages = 0
279 344
       } finally {
280
-        this.loading = false
345
+        this.detailLoading = false
281 346
       }
282 347
     },
283 348
     // 获取折线图数据
@@ -450,36 +515,42 @@ export default {
450 515
     },
451 516
     // 监听数据类型切换
452 517
     onChangeOrderType() {
518
+      this.handleGetSummaryList()
453 519
       this.pagination.page = 1
454 520
       this.handleGetList()
455 521
     },
456 522
     // 监听时间筛选变化
457 523
     onChangeTime(time) {
458 524
       this.filter.time = Array.isArray(time) ? time : []
525
+      this.handleGetSummaryList()
459 526
       this.pagination.page = 1
460 527
       this.handleGetList()
461 528
     },
462 529
     // 监听“MP账号”筛选变化
463 530
     onChangeAccountId(val) {
464 531
       this.filter.account_id = val
532
+      this.handleGetSummaryList()
465 533
       this.pagination.page = 1
466 534
       this.handleGetList()
467 535
     },
468 536
     // 监听“MP账号”筛选变化
469 537
     onChangeAccountIdAdq(val) {
470 538
       this.filter.account_id_adq = val
539
+      this.handleGetSummaryList()
471 540
       this.pagination.page = 1
472 541
       this.handleGetList()
473 542
     },
474 543
     // 监听“收益截止日期”筛选变化
475 544
     onChangeClosingDate(val) {
476 545
       this.filter.closing_date = val || ''
546
+      this.handleGetSummaryList()
477 547
       this.pagination.page = 1
478 548
       this.handleGetList()
479 549
     },
480 550
     // 监听“推广类型”筛选变化
481 551
     onChangePromotionType(val) {
482 552
       this.filter.plat_order_type = val
553
+      this.handleGetSummaryList()
483 554
       this.pagination.page = 1
484 555
       this.handleGetList()
485 556
     },
@@ -490,6 +561,7 @@ export default {
490 561
     },
491 562
     // 监听点击"确定(搜索)"按钮
492 563
     onClickSearch() {
564
+      this.handleGetSummaryList()
493 565
       this.pagination.page = 1
494 566
       this.handleGetList()
495 567
     },
@@ -527,13 +599,14 @@ export default {
527 599
       this.filter.sort_field = 'expense_date'
528 600
       this.filter.sort_type = 'desc'
529 601
       this.pagination.page = 1
602
+      this.handleGetSummaryList()
530 603
       this.handleGetList()
531 604
     },
532 605
     // 监听点击"导出"按钮
533 606
     onClickExport() {
534 607
       console.log('onClickExport => ')
535 608
       if (!this.pagination.total) return this.$message.warning('暂无数据可导出')
536
-      this.loading = true
609
+      this.detailLoading = true
537 610
       this.$axios.get(`${this.URL.BASEURL}${this.URL.statistics_reg_range_report_new}`, {
538 611
         params: {
539 612
           begin_date: this.filter.time[0],
@@ -545,7 +618,7 @@ export default {
545 618
         }
546 619
       }).then((res) => {
547 620
         var res = res.data
548
-        this.loading = false
621
+        this.detailLoading = false
549 622
         if (res && res.errno == 0) {
550 623
           this.handleExport(res.rst.data.list)
551 624
         } else if (res.errno != 4002) {
@@ -555,7 +628,7 @@ export default {
555 628
           })
556 629
         }
557 630
       }).catch((err) => {
558
-        this.loading = false
631
+        this.detailLoading = false
559 632
       });
560 633
     },
561 634
     // 执行导出逻辑