3
3
<ContentWrap >
4
4
<el-form class =" -mb-15px" ref =" queryForm" :inline =" true" label-width =" 68px" >
5
5
<el-form-item label =" 公众号" prop =" accountId" >
6
- <el-select v-model =" accountId" @change =" getSummary" class =" !w-240px" >
7
- <el-option
8
- v-for =" item in accountList"
9
- :key =" item.id"
10
- :label =" item.name"
11
- :value =" item.id"
12
- />
13
- </el-select >
6
+ <WxAccountSelect @change =" onAccountChanged" />
14
7
</el-form-item >
15
8
<el-form-item label =" 时间范围" prop =" dateRange" >
16
9
<el-date-picker
76
69
<script lang="ts" setup>
77
70
import { formatDate , addTime , betweenDay , beginOfDay , endOfDay } from ' @/utils/formatTime'
78
71
import * as StatisticsApi from ' @/api/mp/statistics'
79
- import * as MpAccountApi from ' @/api /mp/account'
72
+ import WxAccountSelect from ' @/views /mp/components/wx- account-select '
80
73
81
74
defineOptions ({ name: ' MpStatistics' })
82
75
@@ -88,7 +81,6 @@ const dateRange = ref([
88
81
endOfDay (new Date (new Date ().getTime () - 3600 * 1000 * 24 ))
89
82
])
90
83
const accountId = ref (- 1 ) // 选中的公众号编号
91
- const accountList = ref <MpAccountApi .AccountVO []>([]) // 公众号账号列表
92
84
93
85
const xAxisDate = ref ([] as any []) // X 轴的日期范围
94
86
// 用户增减数据图表配置项
@@ -230,13 +222,10 @@ const interfaceSummaryOption = reactive({
230
222
]
231
223
})
232
224
233
- /** 加载公众号账号的列表 */
234
- const getAccountList = async () => {
235
- accountList .value = await MpAccountApi .getSimpleAccountList ()
236
- // 默认选中第一个
237
- if (accountList .value .length > 0 ) {
238
- accountId .value = accountList .value [0 ].id !
239
- }
225
+ /** 侦听公众号变化 **/
226
+ const onAccountChanged = (id : number ) => {
227
+ accountId .value = id
228
+ getSummary ()
240
229
}
241
230
242
231
/** 加载数据 */
@@ -357,12 +346,4 @@ const interfaceSummaryChart = async () => {
357
346
})
358
347
} catch {}
359
348
}
360
-
361
- /** 初始化 */
362
- onMounted (async () => {
363
- // 获取公众号下拉列表
364
- await getAccountList ()
365
- // 加载数据
366
- getSummary ()
367
- })
368
349
</script >
0 commit comments