mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
feat:【antd/ele】【mp】优化 mp 账号的选择逻辑
This commit is contained in:
@@ -1,21 +1,15 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
import { WxReply } from '#/views/mp/components';
|
||||
|
||||
import { MsgType } from './types';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
// TODO @芋艿:要不要使用统一枚举?
|
||||
const RequestMessageTypes = new Set([
|
||||
'image',
|
||||
@@ -159,21 +153,12 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// TODO @芋艿:貌似可能微信号拿不到。
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
getAutoReplyPage,
|
||||
} from '#/api/mp/autoReply';
|
||||
import { $t } from '#/locales';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import ReplyContentCell from './modules/content.vue';
|
||||
@@ -43,6 +44,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 切换回复类型 */
|
||||
async function onTabChange(tabName: any) {
|
||||
msgType.value = tabName;
|
||||
@@ -106,7 +113,6 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
submitOnChange: true, // 表单值变化时自动提交,这样 accountId 会被正确传递到查询函数
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(Number(msgType.value) as MsgType),
|
||||
@@ -123,6 +129,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -144,6 +151,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid>
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-actions>
|
||||
<Tabs
|
||||
v-model:active-key="msgType"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// 消息类型(Follow: 关注时回复;Message: 消息回复;Keyword: 关键词回复)
|
||||
// 作为 tab.name,enum 的数字不能随意修改,与 api 参数相关
|
||||
// TODO @hw:可以搞到 biz-mp-enum.ts 里。
|
||||
export enum MsgType {
|
||||
Follow = 1,
|
||||
Keyword = 3,
|
||||
|
||||
@@ -59,7 +59,7 @@ onMounted(handleQuery);
|
||||
<Select
|
||||
v-model:value="account.id"
|
||||
placeholder="请选择公众号"
|
||||
class="!w-[240px]"
|
||||
class="!w-full"
|
||||
@change="onChanged"
|
||||
>
|
||||
<Select.Option v-for="item in accountList" :key="item.id" :value="item.id">
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 获取表格列配置 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
@@ -32,15 +25,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { message } from 'ant-design-vue';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteDraft, getDraftPage } from '#/api/mp/draft';
|
||||
import { submitFreePublish } from '#/api/mp/freePublish';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
import { createEmptyNewsItem } from '#/views/mp/draft/modules/types';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
@@ -24,6 +25,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 新增草稿 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
@@ -115,7 +122,6 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
submitOnChange: true,
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
@@ -144,6 +150,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
};
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'mediaId',
|
||||
@@ -167,6 +174,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="草稿列表">
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { beginOfDay, endOfDay, formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'dateRange',
|
||||
@@ -36,7 +21,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
defaultValue: [
|
||||
formatDateTime(beginOfDay(new Date(Date.now() - 3600 * 1000 * 24 * 7))),
|
||||
formatDateTime(endOfDay(new Date(Date.now() - 3600 * 1000 * 24))),
|
||||
] as [Date, Date],
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { ContentWrap, Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
getUserCumulate,
|
||||
getUserSummary,
|
||||
} from '#/api/mp/statistics';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import {
|
||||
interfaceSummaryOption,
|
||||
@@ -95,6 +96,12 @@ async function getSummary(values: Record<string, any>) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
queryFormApi.setValues({ accountId });
|
||||
queryFormApi.submitForm();
|
||||
}
|
||||
|
||||
const [QueryForm, queryFormApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
@@ -106,17 +113,16 @@ const [QueryForm, queryFormApi] = useVbenForm({
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||
handleSubmit: getSummary,
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
queryFormApi.submitForm();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<ContentWrap class="h-full w-full">
|
||||
<QueryForm />
|
||||
<QueryForm>
|
||||
<template #accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
</QueryForm>
|
||||
|
||||
<div class="flex h-1/3 w-full gap-4">
|
||||
<Card class="h-full w-1/2" title="用户增减数据">
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -41,21 +34,12 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
// TODO @YunaiV 这种方式获取刷新浏览器会导致空白
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { message } from 'ant-design-vue';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteTag, getTagPage, syncTag } from '#/api/mp/tag';
|
||||
import { $t } from '#/locales';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
@@ -23,6 +24,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 创建标签 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
@@ -101,6 +108,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -118,6 +126,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="公众号标签列表">
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -43,15 +37,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'openid',
|
||||
|
||||
@@ -9,6 +9,7 @@ import { message } from 'ant-design-vue';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getUserPage, syncUser } from '#/api/mp/user';
|
||||
import { $t } from '#/locales';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
@@ -25,6 +26,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 编辑用户 */
|
||||
function handleEdit(row: MpUserApi.User) {
|
||||
formModalApi.setData({ id: row.id }).open();
|
||||
@@ -73,6 +80,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -95,6 +103,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="粉丝列表">
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
@@ -2,13 +2,13 @@ import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MpStatisticsApi {
|
||||
/** 统计查询参数 */
|
||||
export interface StatisticsQuery {
|
||||
export interface StatisticsGetReqVO {
|
||||
accountId: number;
|
||||
date: Date[];
|
||||
}
|
||||
|
||||
/** 消息发送概况数据 */
|
||||
export interface UpstreamMessage {
|
||||
export interface StatisticsUpstreamMessageRespVO {
|
||||
refDate: string;
|
||||
msgType: string;
|
||||
msgUser: number;
|
||||
@@ -16,7 +16,7 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 用户增减数据 */
|
||||
export interface UserSummary {
|
||||
export interface StatisticsUserSummaryRespVO {
|
||||
refDate: string;
|
||||
userSource: number;
|
||||
newUser: number;
|
||||
@@ -25,13 +25,13 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 用户累计数据 */
|
||||
export interface UserCumulate {
|
||||
export interface StatisticsUserCumulateRespVO {
|
||||
refDate: string;
|
||||
cumulateUser: number;
|
||||
}
|
||||
|
||||
/** 接口分析数据 */
|
||||
export interface InterfaceSummary {
|
||||
export interface StatisticsInterfaceSummaryRespVO {
|
||||
refDate: string;
|
||||
callbackCount: number;
|
||||
failCount: number;
|
||||
@@ -41,8 +41,8 @@ export namespace MpStatisticsApi {
|
||||
}
|
||||
|
||||
/** 获取消息发送概况数据 */
|
||||
export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UpstreamMessage[]>(
|
||||
export function getUpstreamMessage(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUpstreamMessageRespVO[]>(
|
||||
'/mp/statistics/upstream-message',
|
||||
{
|
||||
params,
|
||||
@@ -51,8 +51,8 @@ export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取用户增减数据 */
|
||||
export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserSummary[]>(
|
||||
export function getUserSummary(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUserSummaryRespVO[]>(
|
||||
'/mp/statistics/user-summary',
|
||||
{
|
||||
params,
|
||||
@@ -61,8 +61,8 @@ export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取用户累计数据 */
|
||||
export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.UserCumulate[]>(
|
||||
export function getUserCumulate(params: MpStatisticsApi.StatisticsGetReqVO) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsUserCumulateRespVO[]>(
|
||||
'/mp/statistics/user-cumulate',
|
||||
{
|
||||
params,
|
||||
@@ -71,8 +71,10 @@ export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) {
|
||||
}
|
||||
|
||||
/** 获取接口分析数据 */
|
||||
export function getInterfaceSummary(params: MpStatisticsApi.StatisticsQuery) {
|
||||
return requestClient.get<MpStatisticsApi.InterfaceSummary[]>(
|
||||
export function getInterfaceSummary(
|
||||
params: MpStatisticsApi.StatisticsGetReqVO,
|
||||
) {
|
||||
return requestClient.get<MpStatisticsApi.StatisticsInterfaceSummaryRespVO[]>(
|
||||
'/mp/statistics/interface-summary',
|
||||
{
|
||||
params,
|
||||
|
||||
@@ -11,12 +11,6 @@ export namespace MpTagApi {
|
||||
count?: number;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 标签分页查询参数 */
|
||||
export interface TagPageQuery extends PageParam {
|
||||
accountId?: number;
|
||||
name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建公众号标签 */
|
||||
@@ -44,7 +38,7 @@ export function getTag(id: number) {
|
||||
}
|
||||
|
||||
/** 获取公众号标签分页 */
|
||||
export function getTagPage(params: MpTagApi.TagPageQuery) {
|
||||
export function getTagPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MpTagApi.Tag>>('/mp/tag/page', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -124,7 +124,7 @@ onMounted(() => {
|
||||
<ElSelect
|
||||
v-model="currentId"
|
||||
placeholder="请选择公众号"
|
||||
class="!w-240px"
|
||||
class="!w-full"
|
||||
@change="onChanged"
|
||||
>
|
||||
<ElOption
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// 统一导出所有模块组件
|
||||
|
||||
export { default as AccountSelect } from './account-select/account-select.vue';
|
||||
export { default as WxAccountSelect } from './account-select/account-select.vue';
|
||||
|
||||
// TODO @hw:还是带着 wx 前缀。。。貌似好点,我的锅!!!
|
||||
export { default as Location } from './location/location.vue';
|
||||
export { default as MaterialSelect } from './material-select/material-select.vue';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { MpStatisticsApi } from '#/api/mp/statistics';
|
||||
|
||||
/** 用户增减数据图表配置项 */
|
||||
export function userSummaryOption(
|
||||
data: MpStatisticsApi.UserSummary[],
|
||||
data: MpStatisticsApi.StatisticsUserSummaryRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -41,7 +41,7 @@ export function userSummaryOption(
|
||||
|
||||
/** 累计用户数据图表配置项 */
|
||||
export function userCumulateOption(
|
||||
data: MpStatisticsApi.UserCumulate[],
|
||||
data: MpStatisticsApi.StatisticsUserCumulateRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -71,7 +71,7 @@ export function userCumulateOption(
|
||||
|
||||
/** 消息发送概况数据图表配置项 */
|
||||
export function upstreamMessageOption(
|
||||
data: MpStatisticsApi.UpstreamMessage[],
|
||||
data: MpStatisticsApi.StatisticsUpstreamMessageRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
@@ -111,7 +111,7 @@ export function upstreamMessageOption(
|
||||
|
||||
/** 接口分析况数据图表配置项 */
|
||||
export function interfaceSummaryOption(
|
||||
data: MpStatisticsApi.InterfaceSummary[],
|
||||
data: MpStatisticsApi.StatisticsInterfaceSummaryRespVO[],
|
||||
dates: string[],
|
||||
): any {
|
||||
return {
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { beginOfDay, endOfDay, formatDateTime } from '@vben/utils';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'dateRange',
|
||||
@@ -36,7 +21,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
defaultValue: [
|
||||
formatDateTime(beginOfDay(new Date(Date.now() - 3600 * 1000 * 24 * 7))),
|
||||
formatDateTime(endOfDay(new Date(Date.now() - 3600 * 1000 * 24))),
|
||||
] as [Date, Date],
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { ContentWrap, Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
getUserCumulate,
|
||||
getUserSummary,
|
||||
} from '#/api/mp/statistics';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import {
|
||||
interfaceSummaryOption,
|
||||
@@ -95,6 +96,12 @@ async function getSummary(values: Record<string, any>) {
|
||||
);
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
queryFormApi.setValues({ accountId });
|
||||
queryFormApi.submitForm();
|
||||
}
|
||||
|
||||
const [QueryForm, queryFormApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
@@ -106,17 +113,16 @@ const [QueryForm, queryFormApi] = useVbenForm({
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||
handleSubmit: getSummary,
|
||||
});
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
queryFormApi.submitForm();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<ContentWrap class="h-full w-full">
|
||||
<QueryForm />
|
||||
<QueryForm>
|
||||
<template #accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
</QueryForm>
|
||||
|
||||
<div class="flex h-1/3 w-full gap-4">
|
||||
<ElCard class="h-full w-1/2">
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
/** 关联数据 */
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -46,15 +39,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ElLoading, ElMessage } from 'element-plus';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteTag, getTagPage, syncTag } from '#/api/mp/tag';
|
||||
import { $t } from '#/locales';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
@@ -23,6 +24,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 创建标签 */
|
||||
async function handleCreate() {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
@@ -99,6 +106,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -116,6 +124,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="公众号标签列表">
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MpAccountApi } from '#/api/mp/account';
|
||||
|
||||
import { getSimpleAccountList } from '#/api/mp/account';
|
||||
|
||||
let accountList: MpAccountApi.AccountSimple[] = [];
|
||||
getSimpleAccountList().then((data) => (accountList = data));
|
||||
|
||||
/** 修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
@@ -43,15 +37,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '公众号',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: accountList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择公众号',
|
||||
},
|
||||
defaultValue: accountList[0]?.id,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
fieldName: 'openid',
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ElLoading, ElMessage } from 'element-plus';
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getUserPage, syncUser } from '#/api/mp/user';
|
||||
import { $t } from '#/locales';
|
||||
import { WxAccountSelect } from '#/views/mp/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
@@ -25,6 +26,12 @@ function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 公众号变化时查询数据 */
|
||||
function handleAccountChange(accountId: number) {
|
||||
gridApi.formApi.setValues({ accountId });
|
||||
gridApi.formApi.submitForm();
|
||||
}
|
||||
|
||||
/** 编辑用户 */
|
||||
function handleEdit(row: MpUserApi.User) {
|
||||
formModalApi.setData({ id: row.id }).open();
|
||||
@@ -72,6 +79,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
},
|
||||
},
|
||||
autoLoad: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
@@ -94,6 +102,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="粉丝列表">
|
||||
<template #form-accountId>
|
||||
<WxAccountSelect @change="handleAccountChange" />
|
||||
</template>
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
|
||||
Reference in New Issue
Block a user