Vue3 重构:REVIEW 公众号统计

This commit is contained in:
YunaiV 2023-03-28 23:28:29 +08:00
parent 80b690b305
commit 337b80ca3d

View File

@ -1,9 +1,9 @@
<template> <template>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<content-wrap> <content-wrap>
<el-form ref="queryForm" class="-mb-15px" :inline="true" label-width="68px"> <el-form class="-mb-15px" ref="queryForm" :inline="true" label-width="68px">
<el-form-item label="公众号" prop="accountId"> <el-form-item label="公众号" prop="accountId">
<el-select v-model="accountId" @change="getSummary"> <el-select v-model="accountId" @change="getSummary" class="!w-240px">
<el-option <el-option
v-for="item in accountList" v-for="item in accountList"
:key="item.id" :key="item.id"
@ -15,13 +15,12 @@
<el-form-item label="时间范围" prop="dateRange"> <el-form-item label="时间范围" prop="dateRange">
<el-date-picker <el-date-picker
v-model="dateRange" v-model="dateRange"
style="width: 260px"
type="daterange" type="daterange"
range-separator="-"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
:default-time="defaultTime" :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
@change="getSummary" @change="getSummary"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -75,22 +74,17 @@
</template> </template>
<script setup lang="ts" name="MpStatistics"> <script setup lang="ts" name="MpStatistics">
import * as StatisticsApi from '@/api/mp/statistics'
import { formatDate, addTime, betweenDay, beginOfDay, endOfDay } from '@/utils/formatTime' import { formatDate, addTime, betweenDay, beginOfDay, endOfDay } from '@/utils/formatTime'
import * as StatisticsApi from '@/api/mp/statistics'
import * as MpAccountApi from '@/api/mp/account' import * as MpAccountApi from '@/api/mp/account'
const message = useMessage() // const message = useMessage() //
// 00:00:00 23:59:59
const defaultTime = ref<[Date, Date]>([
new Date(2000, 1, 1, 0, 0, 0),
new Date(2000, 2, 1, 23, 59, 59)
])
// -7-1 // -7-1
const dateRange = ref([ const dateRange = ref([
beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7)), beginOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24 * 7)),
endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24)) endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24))
]) ])
const accountId = ref() const accountId = ref() //
const accountList = ref<MpAccountApi.AccountVO[]>([]) // const accountList = ref<MpAccountApi.AccountVO[]>([]) //
const xAxisDate = ref([] as any[]) // X const xAxisDate = ref([] as any[]) // X
@ -269,6 +263,7 @@ const getSummary = () => {
initUpstreamMessageChart() initUpstreamMessageChart()
interfaceSummaryChart() interfaceSummaryChart()
} }
/** 用户增减数据 */ /** 用户增减数据 */
const initUserSummaryChart = async () => { const initUserSummaryChart = async () => {
userSummaryOption.xAxis.data = [] userSummaryOption.xAxis.data = []
@ -297,6 +292,7 @@ const initUserSummaryChart = async () => {
}) })
} catch {} } catch {}
} }
/** 累计用户数据 */ /** 累计用户数据 */
const initUserCumulateChart = async () => { const initUserCumulateChart = async () => {
userCumulateOption.xAxis.data = [] userCumulateOption.xAxis.data = []
@ -314,6 +310,7 @@ const initUserCumulateChart = async () => {
}) })
} catch {} } catch {}
} }
/** 消息概况数据 */ /** 消息概况数据 */
const initUpstreamMessageChart = async () => { const initUpstreamMessageChart = async () => {
upstreamMessageOption.xAxis.data = [] upstreamMessageOption.xAxis.data = []
@ -333,6 +330,7 @@ const initUpstreamMessageChart = async () => {
}) })
} catch {} } catch {}
} }
/** 接口分析数据 */ /** 接口分析数据 */
const interfaceSummaryChart = async () => { const interfaceSummaryChart = async () => {
interfaceSummaryOption.xAxis.data = [] interfaceSummaryOption.xAxis.data = []