From 4f4d4972c5e55efccb3a244dfa79b94adfc04ec3 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 16:24:31 +0800 Subject: [PATCH 1/6] fix: crm business --- apps/web-antd/src/views/crm/business/data.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apps/web-antd/src/views/crm/business/data.ts b/apps/web-antd/src/views/crm/business/data.ts index 32785090b..bf65a743c 100644 --- a/apps/web-antd/src/views/crm/business/data.ts +++ b/apps/web-antd/src/views/crm/business/data.ts @@ -50,16 +50,6 @@ export function useFormSchema(): VbenFormSchema[] { label: '备注', component: 'Textarea', }, - { - fieldName: 'contactNextTime', - label: '下次联系时间', - component: 'DatePicker', - componentProps: { - showTime: false, - format: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', - }, - }, ]; } From 081d08a7f859a6d9a0424627ad8711500228a4ec Mon Sep 17 00:00:00 2001 From: Netfan Date: Fri, 30 May 2025 19:54:26 +0800 Subject: [PATCH 2/6] fix: alert width fixed in small screen (#6312) --- packages/@core/ui-kit/popup-ui/src/alert/alert.vue | 3 +-- .../shadcn-ui/src/ui/alert-dialog/AlertDialogContent.vue | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@core/ui-kit/popup-ui/src/alert/alert.vue b/packages/@core/ui-kit/popup-ui/src/alert/alert.vue index 6223ecd75..6997235ac 100644 --- a/packages/@core/ui-kit/popup-ui/src/alert/alert.vue +++ b/packages/@core/ui-kit/popup-ui/src/alert/alert.vue @@ -34,7 +34,6 @@ const props = withDefaults(defineProps(), { bordered: true, buttonAlign: 'end', centered: true, - containerClass: 'w-[520px]', }); const emits = defineEmits(['closed', 'confirm', 'opened']); const open = defineModel('open', { default: false }); @@ -148,7 +147,7 @@ async function handleOpenChange(val: boolean) { :class=" cn( containerClass, - 'left-0 right-0 mx-auto flex max-h-[80%] flex-col p-0 duration-300 sm:rounded-[var(--radius)] md:w-[520px] md:max-w-[80%]', + 'left-0 right-0 mx-auto flex max-h-[80%] flex-col p-0 duration-300 sm:w-[520px] sm:max-w-[80%] sm:rounded-[var(--radius)]', { 'border-border border': bordered, 'shadow-3xl': !bordered, diff --git a/packages/@core/ui-kit/shadcn-ui/src/ui/alert-dialog/AlertDialogContent.vue b/packages/@core/ui-kit/shadcn-ui/src/ui/alert-dialog/AlertDialogContent.vue index c3d5c143c..522ada37b 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/ui/alert-dialog/AlertDialogContent.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/ui/alert-dialog/AlertDialogContent.vue @@ -80,7 +80,7 @@ defineExpose({ v-bind="forwarded" :class=" cn( - 'z-popup bg-background w-full p-6 shadow-lg outline-none sm:rounded-xl', + 'z-popup bg-background p-6 shadow-lg outline-none sm:rounded-xl', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', { From c7f207034f54650fe2a11f190618c21791f328ab Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 20:51:03 +0800 Subject: [PATCH 3/6] feat: mp api --- apps/web-antd/src/api/mp/account/index.ts | 59 +++++++++++++ apps/web-antd/src/api/mp/autoReply/index.ts | 49 +++++++++++ apps/web-antd/src/api/mp/draft/index.ts | 59 +++++++++++++ apps/web-antd/src/api/mp/freePublish/index.ts | 45 ++++++++++ apps/web-antd/src/api/mp/material/index.ts | 43 ++++++++++ apps/web-antd/src/api/mp/menu/index.ts | 58 +++++++++++++ apps/web-antd/src/api/mp/message/index.ts | 54 ++++++++++++ apps/web-antd/src/api/mp/statistics/index.ts | 84 +++++++++++++++++++ apps/web-antd/src/api/mp/tag/index.ts | 62 ++++++++++++++ apps/web-antd/src/api/mp/user/index.ts | 57 +++++++++++++ 10 files changed, 570 insertions(+) create mode 100644 apps/web-antd/src/api/mp/account/index.ts create mode 100644 apps/web-antd/src/api/mp/autoReply/index.ts create mode 100644 apps/web-antd/src/api/mp/draft/index.ts create mode 100644 apps/web-antd/src/api/mp/freePublish/index.ts create mode 100644 apps/web-antd/src/api/mp/material/index.ts create mode 100644 apps/web-antd/src/api/mp/menu/index.ts create mode 100644 apps/web-antd/src/api/mp/message/index.ts create mode 100644 apps/web-antd/src/api/mp/statistics/index.ts create mode 100644 apps/web-antd/src/api/mp/tag/index.ts create mode 100644 apps/web-antd/src/api/mp/user/index.ts diff --git a/apps/web-antd/src/api/mp/account/index.ts b/apps/web-antd/src/api/mp/account/index.ts new file mode 100644 index 000000000..918c80202 --- /dev/null +++ b/apps/web-antd/src/api/mp/account/index.ts @@ -0,0 +1,59 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpAccountApi { + /** 公众号账号信息 */ + export interface Account { + id?: number; + name: string; + account: string; + appId: string; + appSecret: string; + token: string; + aesKey?: string; + qrCodeUrl?: string; + remark?: string; + createTime?: Date; + } +} + +/** 查询公众号账号列表 */ +export function getAccountPage(params: PageParam) { + return requestClient.get>( + '/mp/account/page', + { + params, + }, + ); +} + +/** 查询公众号账号详情 */ +export function getAccount(id: number) { + return requestClient.get(`/mp/account/get?id=${id}`); +} + +/** 新增公众号账号 */ +export function createAccount(data: MpAccountApi.Account) { + return requestClient.post('/mp/account/create', data); +} + +/** 修改公众号账号 */ +export function updateAccount(data: MpAccountApi.Account) { + return requestClient.put('/mp/account/update', data); +} + +/** 删除公众号账号 */ +export function deleteAccount(id: number) { + return requestClient.delete(`/mp/account/delete?id=${id}`); +} + +/** 生成公众号账号二维码 */ +export function generateAccountQrCode(id: number) { + return requestClient.post(`/mp/account/generate-qr-code?id=${id}`); +} + +/** 清空公众号账号 API 配额 */ +export function clearAccountQuota(id: number) { + return requestClient.post(`/mp/account/clear-quota?id=${id}`); +} diff --git a/apps/web-antd/src/api/mp/autoReply/index.ts b/apps/web-antd/src/api/mp/autoReply/index.ts new file mode 100644 index 000000000..d72e5a0cb --- /dev/null +++ b/apps/web-antd/src/api/mp/autoReply/index.ts @@ -0,0 +1,49 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpAutoReplyApi { + /** 自动回复信息 */ + export interface AutoReply { + id?: number; + accountId: number; + type: number; + keyword: string; + content: string; + status: number; + remark?: string; + createTime?: Date; + } +} + +/** 查询自动回复列表 */ +export function getAutoReplyPage(params: PageParam) { + return requestClient.get>( + '/mp/auto-reply/page', + { + params, + }, + ); +} + +/** 查询自动回复详情 */ +export function getAutoReply(id: number) { + return requestClient.get( + `/mp/auto-reply/get?id=${id}`, + ); +} + +/** 新增自动回复 */ +export function createAutoReply(data: MpAutoReplyApi.AutoReply) { + return requestClient.post('/mp/auto-reply/create', data); +} + +/** 修改自动回复 */ +export function updateAutoReply(data: MpAutoReplyApi.AutoReply) { + return requestClient.put('/mp/auto-reply/update', data); +} + +/** 删除自动回复 */ +export function deleteAutoReply(id: number) { + return requestClient.delete(`/mp/auto-reply/delete?id=${id}`); +} diff --git a/apps/web-antd/src/api/mp/draft/index.ts b/apps/web-antd/src/api/mp/draft/index.ts new file mode 100644 index 000000000..435f13e0b --- /dev/null +++ b/apps/web-antd/src/api/mp/draft/index.ts @@ -0,0 +1,59 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpDraftApi { + /** 草稿文章信息 */ + export interface Article { + title: string; + author: string; + digest: string; + content: string; + contentSourceUrl: string; + thumbMediaId: string; + showCoverPic: number; + needOpenComment: number; + onlyFansCanComment: number; + } + + /** 草稿信息 */ + export interface Draft { + id?: number; + accountId: number; + mediaId: string; + articles: Article[]; + createTime?: Date; + } +} + +/** 查询草稿列表 */ +export function getDraftPage(params: PageParam) { + return requestClient.get>('/mp/draft/page', { + params, + }); +} + +/** 创建草稿 */ +export function createDraft(accountId: number, articles: MpDraftApi.Article[]) { + return requestClient.post('/mp/draft/create', articles, { + params: { accountId }, + }); +} + +/** 更新草稿 */ +export function updateDraft( + accountId: number, + mediaId: string, + articles: MpDraftApi.Article[], +) { + return requestClient.put('/mp/draft/update', articles, { + params: { accountId, mediaId }, + }); +} + +/** 删除草稿 */ +export function deleteDraft(accountId: number, mediaId: string) { + return requestClient.delete('/mp/draft/delete', { + params: { accountId, mediaId }, + }); +} diff --git a/apps/web-antd/src/api/mp/freePublish/index.ts b/apps/web-antd/src/api/mp/freePublish/index.ts new file mode 100644 index 000000000..bc50efe96 --- /dev/null +++ b/apps/web-antd/src/api/mp/freePublish/index.ts @@ -0,0 +1,45 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpFreePublishApi { + /** 自由发布文章信息 */ + export interface FreePublish { + id?: number; + accountId: number; + mediaId: string; + articleId: string; + title: string; + author: string; + digest: string; + content: string; + thumbUrl: string; + status: number; + publishTime?: Date; + createTime?: Date; + } +} + +/** 查询自由发布文章列表 */ +export function getFreePublishPage(params: PageParam) { + return requestClient.get>( + '/mp/free-publish/page', + { + params, + }, + ); +} + +/** 删除自由发布文章 */ +export function deleteFreePublish(accountId: number, articleId: string) { + return requestClient.delete('/mp/free-publish/delete', { + params: { accountId, articleId }, + }); +} + +/** 发布自由发布文章 */ +export function submitFreePublish(accountId: number, mediaId: string) { + return requestClient.post('/mp/free-publish/submit', null, { + params: { accountId, mediaId }, + }); +} diff --git a/apps/web-antd/src/api/mp/material/index.ts b/apps/web-antd/src/api/mp/material/index.ts new file mode 100644 index 000000000..73ca899ee --- /dev/null +++ b/apps/web-antd/src/api/mp/material/index.ts @@ -0,0 +1,43 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +/** 素材类型枚举 */ +export enum MaterialType { + IMAGE = 1, // 图片 + THUMB = 4, // 缩略图 + VIDEO = 3, // 视频 + VOICE = 2, // 语音 +} + +export namespace MpMaterialApi { + /** 素材信息 */ + export interface Material { + id?: number; + accountId: number; + type: MaterialType; + mediaId: string; + url: string; + name: string; + size: number; + remark?: string; + createTime?: Date; + } +} + +/** 查询素材列表 */ +export function getMaterialPage(params: PageParam) { + return requestClient.get>( + '/mp/material/page', + { + params, + }, + ); +} + +/** 删除永久素材 */ +export function deletePermanentMaterial(id: number) { + return requestClient.delete('/mp/material/delete-permanent', { + params: { id }, + }); +} diff --git a/apps/web-antd/src/api/mp/menu/index.ts b/apps/web-antd/src/api/mp/menu/index.ts new file mode 100644 index 000000000..a8ae0833b --- /dev/null +++ b/apps/web-antd/src/api/mp/menu/index.ts @@ -0,0 +1,58 @@ +import { requestClient } from '#/api/request'; + +/** 菜单类型枚举 */ +export enum MenuType { + CLICK = 'click', // 点击推事件 + LOCATION_SELECT = 'location_select', // 发送位置 + MEDIA_ID = 'media_id', // 下发消息 + MINIPROGRAM = 'miniprogram', // 小程序 + PIC_PHOTO_OR_ALBUM = 'pic_photo_or_album', // 拍照或者相册发图 + PIC_SYSPHOTO = 'pic_sysphoto', // 系统拍照发图 + PIC_WEIXIN = 'pic_weixin', // 微信相册发图 + SCANCODE_PUSH = 'scancode_push', // 扫码推事件 + SCANCODE_WAITMSG = 'scancode_waitmsg', // 扫码带提示 + VIEW = 'view', // 跳转URL + VIEW_LIMITED = 'view_limited', // 跳转图文消息URL +} + +export namespace MpMenuApi { + /** 菜单按钮信息 */ + export interface MenuButton { + type: MenuType; + name: string; + key?: string; + url?: string; + mediaId?: string; + appId?: string; + pagePath?: string; + subButtons?: MenuButton[]; + } + + /** 菜单信息 */ + export interface Menu { + accountId: number; + menus: MenuButton[]; + } +} + +/** 查询菜单列表 */ +export function getMenuList(accountId: number) { + return requestClient.get('/mp/menu/list', { + params: { accountId }, + }); +} + +/** 保存菜单 */ +export function saveMenu(accountId: number, menus: MpMenuApi.MenuButton[]) { + return requestClient.post('/mp/menu/save', { + accountId, + menus, + }); +} + +/** 删除菜单 */ +export function deleteMenu(accountId: number) { + return requestClient.delete('/mp/menu/delete', { + params: { accountId }, + }); +} diff --git a/apps/web-antd/src/api/mp/message/index.ts b/apps/web-antd/src/api/mp/message/index.ts new file mode 100644 index 000000000..cfb2dbacc --- /dev/null +++ b/apps/web-antd/src/api/mp/message/index.ts @@ -0,0 +1,54 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +/** 消息类型枚举 */ +export enum MessageType { + IMAGE = 'image', // 图片消息 + MPNEWS = 'mpnews', // 公众号图文消息 + MUSIC = 'music', // 音乐消息 + NEWS = 'news', // 图文消息 + TEXT = 'text', // 文本消息 + VIDEO = 'video', // 视频消息 + VOICE = 'voice', // 语音消息 + WXCARD = 'wxcard', // 卡券消息 +} + +export namespace MpMessageApi { + /** 消息信息 */ + export interface Message { + id?: number; + accountId: number; + type: MessageType; + openid: string; + content: string; + mediaId?: string; + status: number; + remark?: string; + createTime?: Date; + } + + /** 发送消息请求 */ + export interface SendMessageRequest { + accountId: number; + openid: string; + type: MessageType; + content: string; + mediaId?: string; + } +} + +/** 查询消息列表 */ +export function getMessagePage(params: PageParam) { + return requestClient.get>( + '/mp/message/page', + { + params, + }, + ); +} + +/** 发送消息 */ +export function sendMessage(data: MpMessageApi.SendMessageRequest) { + return requestClient.post('/mp/message/send', data); +} diff --git a/apps/web-antd/src/api/mp/statistics/index.ts b/apps/web-antd/src/api/mp/statistics/index.ts new file mode 100644 index 000000000..e36073820 --- /dev/null +++ b/apps/web-antd/src/api/mp/statistics/index.ts @@ -0,0 +1,84 @@ +import type { PageParam } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpStatisticsApi { + /** 统计查询参数 */ + export interface StatisticsQuery extends PageParam { + accountId: number; + beginDate: string; + endDate: string; + } + + /** 消息发送概况数据 */ + export interface UpstreamMessage { + refDate: string; + msgType: string; + msgUser: number; + msgCount: number; + } + + /** 用户增减数据 */ + export interface UserSummary { + refDate: string; + userSource: number; + newUser: number; + cancelUser: number; + cumulateUser: number; + } + + /** 用户累计数据 */ + export interface UserCumulate { + refDate: string; + cumulateUser: number; + } + + /** 接口分析数据 */ + export interface InterfaceSummary { + refDate: string; + callbackCount: number; + failCount: number; + totalTimeCost: number; + maxTimeCost: number; + } +} + +/** 获取消息发送概况数据 */ +export function getUpstreamMessage(params: MpStatisticsApi.StatisticsQuery) { + return requestClient.get( + '/mp/statistics/upstream-message', + { + params, + }, + ); +} + +/** 获取用户增减数据 */ +export function getUserSummary(params: MpStatisticsApi.StatisticsQuery) { + return requestClient.get( + '/mp/statistics/user-summary', + { + params, + }, + ); +} + +/** 获取用户累计数据 */ +export function getUserCumulate(params: MpStatisticsApi.StatisticsQuery) { + return requestClient.get( + '/mp/statistics/user-cumulate', + { + params, + }, + ); +} + +/** 获取接口分析数据 */ +export function getInterfaceSummary(params: MpStatisticsApi.StatisticsQuery) { + return requestClient.get( + '/mp/statistics/interface-summary', + { + params, + }, + ); +} diff --git a/apps/web-antd/src/api/mp/tag/index.ts b/apps/web-antd/src/api/mp/tag/index.ts new file mode 100644 index 000000000..3cf677e7d --- /dev/null +++ b/apps/web-antd/src/api/mp/tag/index.ts @@ -0,0 +1,62 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpTagApi { + /** 标签信息 */ + export interface Tag { + id?: number; + name: string; + accountId: number; + createTime?: Date; + } + + /** 标签分页查询参数 */ + export interface TagPageQuery extends PageParam { + accountId?: number; + name?: string; + } +} + +/** 创建公众号标签 */ +export function createTag(data: MpTagApi.Tag) { + return requestClient.post('/mp/tag/create', data); +} + +/** 更新公众号标签 */ +export function updateTag(data: MpTagApi.Tag) { + return requestClient.put('/mp/tag/update', data); +} + +/** 删除公众号标签 */ +export function deleteTag(id: number) { + return requestClient.delete('/mp/tag/delete', { + params: { id }, + }); +} + +/** 获取公众号标签 */ +export function getTag(id: number) { + return requestClient.get('/mp/tag/get', { + params: { id }, + }); +} + +/** 获取公众号标签分页 */ +export function getTagPage(params: MpTagApi.TagPageQuery) { + return requestClient.get>('/mp/tag/page', { + params, + }); +} + +/** 获取公众号标签精简信息列表 */ +export function getSimpleTagList() { + return requestClient.get('/mp/tag/list-all-simple'); +} + +/** 同步公众号标签 */ +export function syncTag(accountId: number) { + return requestClient.post('/mp/tag/sync', null, { + params: { accountId }, + }); +} diff --git a/apps/web-antd/src/api/mp/user/index.ts b/apps/web-antd/src/api/mp/user/index.ts new file mode 100644 index 000000000..e34573a1a --- /dev/null +++ b/apps/web-antd/src/api/mp/user/index.ts @@ -0,0 +1,57 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace MpUserApi { + /** 用户信息 */ + export interface User { + id?: number; + accountId: number; + openid: string; + nickname: string; + avatar: string; + sex: number; + country: string; + province: string; + city: string; + language: string; + subscribe: boolean; + subscribeTime?: Date; + remark?: string; + tagIds?: number[]; + createTime?: Date; + } + + /** 用户分页查询参数 */ + export interface UserPageQuery extends PageParam { + accountId?: number; + nickname?: string; + tagId?: number; + } +} + +/** 更新公众号粉丝 */ +export function updateUser(data: MpUserApi.User) { + return requestClient.put('/mp/user/update', data); +} + +/** 获取公众号粉丝 */ +export function getUser(id: number) { + return requestClient.get('/mp/user/get', { + params: { id }, + }); +} + +/** 获取公众号粉丝分页 */ +export function getUserPage(params: MpUserApi.UserPageQuery) { + return requestClient.get>('/mp/user/page', { + params, + }); +} + +/** 同步公众号粉丝 */ +export function syncUser(accountId: number) { + return requestClient.post('/mp/user/sync', null, { + params: { accountId }, + }); +} From 1074b90c6f4660efa306c869b56265d7d77f05f6 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 20:51:13 +0800 Subject: [PATCH 4/6] feat: mp account --- apps/web-antd/src/views/mp/account/data.ts | 135 +++++++++++ apps/web-antd/src/views/mp/account/index.vue | 209 ++++++++++++++++-- .../src/views/mp/account/modules/form.vue | 82 +++++++ 3 files changed, 403 insertions(+), 23 deletions(-) create mode 100644 apps/web-antd/src/views/mp/account/data.ts create mode 100644 apps/web-antd/src/views/mp/account/modules/form.vue diff --git a/apps/web-antd/src/views/mp/account/data.ts b/apps/web-antd/src/views/mp/account/data.ts new file mode 100644 index 000000000..cbf918cfc --- /dev/null +++ b/apps/web-antd/src/views/mp/account/data.ts @@ -0,0 +1,135 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeGridPropTypes } from '#/adapter/vxe-table'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '名称', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入名称', + }, + }, + { + fieldName: 'account', + label: '微信号', + component: 'Input', + help: '在微信公众平台(mp.weixin.qq.com)的菜单 [设置与开发 - 公众号设置 - 账号详情] 中能找到「微信号」', + rules: 'required', + componentProps: { + placeholder: '请输入微信号', + }, + }, + { + fieldName: 'appId', + label: 'appId', + component: 'Input', + help: '在微信公众平台(mp.weixin.qq.com)的菜单 [设置与开发 - 公众号设置 - 基本设置] 中能找到「开发者ID(AppID)」', + rules: 'required', + componentProps: { + placeholder: '请输入appId', + }, + }, + { + fieldName: 'appSecret', + label: 'appSecret', + component: 'Input', + help: '在微信公众平台(mp.weixin.qq.com)的菜单 [设置与开发 - 公众号设置 - 基本设置] 中能找到「开发者密码(AppSecret)」', + rules: 'required', + componentProps: { + placeholder: '请输入appSecret', + }, + }, + { + fieldName: 'token', + label: 'token', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入token', + }, + }, + { + fieldName: 'aesKey', + label: '消息加解密密钥', + component: 'Input', + componentProps: { + placeholder: '请输入aesKey', + }, + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + componentProps: { + placeholder: '请输入备注', + }, + }, + ]; +} + +/** 搜索表单配置 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '名称', + component: 'Input', + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeGridPropTypes.Columns { + return [ + { + title: '名称', + field: 'name', + }, + { + title: '微信号', + field: 'account', + }, + { + title: 'appId', + field: 'appId', + }, + { + title: '服务器地址(URL)', + field: 'utl', + slots: { + default: ({ row }) => { + return `http://服务端地址/admin-api/mp/open/${row.appId}`; + }, + }, + }, + { + title: '二维码', + field: 'qrCodeUrl', + slots: { + default: 'qrCodeUrl', + }, + }, + { + title: '备注', + field: 'remark', + }, + { + title: '操作', + width: 260, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mp/account/index.vue b/apps/web-antd/src/views/mp/account/index.vue index 34f349e11..cb105a877 100644 --- a/apps/web-antd/src/views/mp/account/index.vue +++ b/apps/web-antd/src/views/mp/account/index.vue @@ -1,31 +1,194 @@ diff --git a/apps/web-antd/src/views/mp/account/modules/form.vue b/apps/web-antd/src/views/mp/account/modules/form.vue new file mode 100644 index 000000000..865c7fab1 --- /dev/null +++ b/apps/web-antd/src/views/mp/account/modules/form.vue @@ -0,0 +1,82 @@ + + + From 5fa6ca78e293d106d65b6267e963abb387d3c37e Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 21:24:24 +0800 Subject: [PATCH 5/6] feat: tag --- apps/web-antd/src/api/mp/account/index.ts | 7 + apps/web-antd/src/api/mp/tag/index.ts | 3 +- apps/web-antd/src/views/mp/tag/data.ts | 82 +++++++++ apps/web-antd/src/views/mp/tag/index.vue | 172 +++++++++++++++--- .../src/views/mp/tag/modules/form.vue | 88 +++++++++ 5 files changed, 328 insertions(+), 24 deletions(-) create mode 100644 apps/web-antd/src/views/mp/tag/data.ts create mode 100644 apps/web-antd/src/views/mp/tag/modules/form.vue diff --git a/apps/web-antd/src/api/mp/account/index.ts b/apps/web-antd/src/api/mp/account/index.ts index 918c80202..9e7d27712 100644 --- a/apps/web-antd/src/api/mp/account/index.ts +++ b/apps/web-antd/src/api/mp/account/index.ts @@ -33,6 +33,13 @@ export function getAccount(id: number) { return requestClient.get(`/mp/account/get?id=${id}`); } +/** 查询公众号账号列表 */ +export function getSimpleAccountList() { + return requestClient.get( + '/mp/account/list-all-simple', + ); +} + /** 新增公众号账号 */ export function createAccount(data: MpAccountApi.Account) { return requestClient.post('/mp/account/create', data); diff --git a/apps/web-antd/src/api/mp/tag/index.ts b/apps/web-antd/src/api/mp/tag/index.ts index 3cf677e7d..b1acd0130 100644 --- a/apps/web-antd/src/api/mp/tag/index.ts +++ b/apps/web-antd/src/api/mp/tag/index.ts @@ -6,8 +6,9 @@ export namespace MpTagApi { /** 标签信息 */ export interface Tag { id?: number; - name: string; accountId: number; + name: string; + count?: number; createTime?: Date; } diff --git a/apps/web-antd/src/views/mp/tag/data.ts b/apps/web-antd/src/views/mp/tag/data.ts new file mode 100644 index 000000000..ce0a4f9aa --- /dev/null +++ b/apps/web-antd/src/views/mp/tag/data.ts @@ -0,0 +1,82 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { VxeGridPropTypes } from '#/adapter/vxe-table'; + +import { getSimpleAccountList } from '#/api/mp/account'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'accountId', + label: '公众号', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '标签名称', + component: 'Input', + rules: 'required', + componentProps: { + placeholder: '请输入名称', + }, + }, + ]; +} + +/** 搜索表单配置 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'accountId', + label: '公众号', + component: 'ApiSelect', + componentProps: { + api: getSimpleAccountList, + labelField: 'name', + valueField: 'id', + allowClear: true, + }, + }, + ]; +} + +/** 表格列配置 */ +export function useGridColumns(): VxeGridPropTypes.Columns { + return [ + { + title: '编号', + field: 'id', + }, + { + title: '标签名称', + field: 'name', + }, + { + title: '粉丝数', + field: 'count', + }, + { + title: '创建时间', + field: 'createTime', + formatter: 'formatDateTime', + }, + { + title: '操作', + width: 140, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mp/tag/index.vue b/apps/web-antd/src/views/mp/tag/index.vue index a54db51e9..e5ccef0c7 100644 --- a/apps/web-antd/src/views/mp/tag/index.vue +++ b/apps/web-antd/src/views/mp/tag/index.vue @@ -1,31 +1,157 @@ diff --git a/apps/web-antd/src/views/mp/tag/modules/form.vue b/apps/web-antd/src/views/mp/tag/modules/form.vue new file mode 100644 index 000000000..1c70f95a6 --- /dev/null +++ b/apps/web-antd/src/views/mp/tag/modules/form.vue @@ -0,0 +1,88 @@ + + + From f105df045709a897a163bd72104a80e871f958c3 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Fri, 30 May 2025 22:56:26 +0800 Subject: [PATCH 6/6] fix: mp tag --- apps/web-antd/src/api/mp/account/index.ts | 7 ++- apps/web-antd/src/views/mp/tag/data.ts | 19 ------- apps/web-antd/src/views/mp/tag/index.vue | 55 ++++++++++++++++--- .../src/views/mp/tag/modules/form.vue | 11 +--- 4 files changed, 57 insertions(+), 35 deletions(-) diff --git a/apps/web-antd/src/api/mp/account/index.ts b/apps/web-antd/src/api/mp/account/index.ts index 9e7d27712..60833058c 100644 --- a/apps/web-antd/src/api/mp/account/index.ts +++ b/apps/web-antd/src/api/mp/account/index.ts @@ -16,6 +16,11 @@ export namespace MpAccountApi { remark?: string; createTime?: Date; } + + export interface AccountSimple { + id: number; + name: string; + } } /** 查询公众号账号列表 */ @@ -35,7 +40,7 @@ export function getAccount(id: number) { /** 查询公众号账号列表 */ export function getSimpleAccountList() { - return requestClient.get( + return requestClient.get( '/mp/account/list-all-simple', ); } diff --git a/apps/web-antd/src/views/mp/tag/data.ts b/apps/web-antd/src/views/mp/tag/data.ts index ce0a4f9aa..bdb857050 100644 --- a/apps/web-antd/src/views/mp/tag/data.ts +++ b/apps/web-antd/src/views/mp/tag/data.ts @@ -1,8 +1,6 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeGridPropTypes } from '#/adapter/vxe-table'; -import { getSimpleAccountList } from '#/api/mp/account'; - /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -35,23 +33,6 @@ export function useFormSchema(): VbenFormSchema[] { ]; } -/** 搜索表单配置 */ -export function useGridFormSchema(): VbenFormSchema[] { - return [ - { - fieldName: 'accountId', - label: '公众号', - component: 'ApiSelect', - componentProps: { - api: getSimpleAccountList, - labelField: 'name', - valueField: 'id', - allowClear: true, - }, - }, - ]; -} - /** 表格列配置 */ export function useGridColumns(): VxeGridPropTypes.Columns { return [ diff --git a/apps/web-antd/src/views/mp/tag/index.vue b/apps/web-antd/src/views/mp/tag/index.vue index e5ccef0c7..b9471c42c 100644 --- a/apps/web-antd/src/views/mp/tag/index.vue +++ b/apps/web-antd/src/views/mp/tag/index.vue @@ -2,26 +2,64 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { MpTagApi } from '#/api/mp/tag'; -import { ref } from 'vue'; +import { onMounted, ref } from 'vue'; +import { useRouter } from 'vue-router'; import { Page, useVbenModal } from '@vben/common-ui'; +import { useTabs } from '@vben/hooks'; import { message } from 'ant-design-vue'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; +import { getSimpleAccountList } from '#/api/mp/account'; import { deleteTag, getTagPage, syncTag } from '#/api/mp/tag'; import { $t } from '#/locales'; -import { useGridColumns, useGridFormSchema } from './data'; +import { useGridColumns } from './data'; import Form from './modules/form.vue'; +const { push } = useRouter(); // 路由 +const tabs = useTabs(); + const accountId = ref(-1); +const accountOptions = ref<{ label: string; value: number }[]>([]); const [FormModal, formModalApi] = useVbenModal({ connectedComponent: Form, destroyOnClose: true, }); +async function getAccountList() { + const res = await getSimpleAccountList(); + if (res.length > 0) { + accountId.value = res[0]?.id as number; + accountOptions.value = res.map((item) => ({ + label: item.name, + value: item.id, + })); + gridApi.setState({ + formOptions: { + schema: [ + { + fieldName: 'accountId', + label: '公众号', + component: 'Select', + componentProps: { + options: accountOptions, + }, + }, + ], + }, + }); + gridApi.formApi.setValues({ + accountId: accountId.value, + }); + } else { + message.error('未配置公众号,请在【公众号管理 -> 账号管理】菜单,进行配置'); + await push({ name: 'MpAccount' }); + tabs.closeCurrentTab(); + } +} /** 刷新表格 */ function onRefresh() { gridApi.query(); @@ -29,12 +67,12 @@ function onRefresh() { /** 创建标签 */ function handleCreate() { - formModalApi.setData(null).open(); + formModalApi.setData({ accountId: accountId.value }).open(); } /** 编辑标签 */ function handleEdit(row: MpTagApi.Tag) { - formModalApi.setData(row).open(); + formModalApi.setData({ row, accountId: accountId.value }).open(); } /** 删除标签 */ @@ -74,7 +112,7 @@ async function handleSync() { const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { - schema: useGridFormSchema(), + schema: [], }, gridOptions: { columns: useGridColumns(), @@ -87,7 +125,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ return await getTagPage({ pageNo: page.currentPage, pageSize: page.pageSize, - accountId: accountId.value, ...formValues, }); }, @@ -102,11 +139,15 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, } as VxeTableGridOptions, }); + +onMounted(async () => { + await getAccountList(); +});