【功能优化】公众号:未配置公众号账号的情况下,自动跳转账号管理的菜单

pull/552/head
YunaiV 2024-09-12 09:42:47 +08:00
parent 9d0e77b624
commit 0974ece199
2 changed files with 17 additions and 25 deletions

View File

@ -6,6 +6,11 @@
<script lang="ts" setup>
import * as MpAccountApi from '@/api/mp/account'
import { useTagsViewStore } from '@/store/modules/tagsView'
const message = useMessage() //
const { delView } = useTagsViewStore() //
const { push, currentRoute } = useRouter() //
defineOptions({ name: 'WxAccountSelect' })
@ -22,6 +27,12 @@ const emit = defineEmits<{
const handleQuery = async () => {
accountList.value = await MpAccountApi.getSimpleAccountList()
if (accountList.value.length == 0) {
message.error('未配置公众号,请在【公众号管理 -> 账号管理】菜单,进行配置')
delView(unref(currentRoute))
await push({ name: 'MpAccount' })
return
}
//
if (accountList.value.length > 0) {
account.id = accountList.value[0].id

View File

@ -3,14 +3,7 @@
<ContentWrap>
<el-form class="-mb-15px" ref="queryForm" :inline="true" label-width="68px">
<el-form-item label="公众号" prop="accountId">
<el-select v-model="accountId" @change="getSummary" class="!w-240px">
<el-option
v-for="item in accountList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
<WxAccountSelect @change="onAccountChanged" />
</el-form-item>
<el-form-item label="时间范围" prop="dateRange">
<el-date-picker
@ -76,7 +69,7 @@
<script lang="ts" setup>
import { formatDate, addTime, betweenDay, beginOfDay, endOfDay } from '@/utils/formatTime'
import * as StatisticsApi from '@/api/mp/statistics'
import * as MpAccountApi from '@/api/mp/account'
import WxAccountSelect from '@/views/mp/components/wx-account-select'
defineOptions({ name: 'MpStatistics' })
@ -88,7 +81,6 @@ const dateRange = ref([
endOfDay(new Date(new Date().getTime() - 3600 * 1000 * 24))
])
const accountId = ref(-1) //
const accountList = ref<MpAccountApi.AccountVO[]>([]) //
const xAxisDate = ref([] as any[]) // X
//
@ -230,13 +222,10 @@ const interfaceSummaryOption = reactive({
]
})
/** 加载公众号账号的列表 */
const getAccountList = async () => {
accountList.value = await MpAccountApi.getSimpleAccountList()
//
if (accountList.value.length > 0) {
accountId.value = accountList.value[0].id!
}
/** 侦听公众号变化 **/
const onAccountChanged = (id: number) => {
accountId.value = id
getSummary()
}
/** 加载数据 */
@ -357,12 +346,4 @@ const interfaceSummaryChart = async () => {
})
} catch {}
}
/** 初始化 */
onMounted(async () => {
//
await getAccountList()
//
getSummary()
})
</script>