From e2848653f981c8275aeb0803ef2f907df45350e2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 20 Nov 2025 21:18:21 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91=E3=80=90mp?= =?UTF-8?q?=E3=80=91mp=20=E7=9A=84=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=EF=BC=88autoReply=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/mp/autoReply/data.ts | 2 +- .../web-antd/src/views/mp/autoReply/index.vue | 3 +- .../views/mp/autoReply/modules/content.vue | 4 +- apps/web-ele/src/views/mp/autoReply/data.ts | 9 +++ apps/web-ele/src/views/mp/autoReply/index.vue | 62 ++++++++++--------- .../src/views/mp/autoReply/modules/form.vue | 6 +- 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/apps/web-antd/src/views/mp/autoReply/data.ts b/apps/web-antd/src/views/mp/autoReply/data.ts index 0fba1d20a..4054ec64b 100644 --- a/apps/web-antd/src/views/mp/autoReply/data.ts +++ b/apps/web-antd/src/views/mp/autoReply/data.ts @@ -8,7 +8,7 @@ import { getDictOptions } from '@vben/hooks'; import { WxReply } from '#/views/mp/components'; -// TODO @芋艿:要不要使用统一枚举? +// TODO @hw:要不要使用统一枚举? const RequestMessageTypes = new Set([ 'image', 'link', diff --git a/apps/web-antd/src/views/mp/autoReply/index.vue b/apps/web-antd/src/views/mp/autoReply/index.vue index 860625b6b..c3c84a442 100644 --- a/apps/web-antd/src/views/mp/autoReply/index.vue +++ b/apps/web-antd/src/views/mp/autoReply/index.vue @@ -5,6 +5,7 @@ import type { MpAutoReplyApi } from '#/api/mp/autoReply'; import { computed, nextTick, ref } from 'vue'; import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui'; +// TODO @hw:直接使用 AutoReplyMsgType,不用 as import { AutoReplyMsgType as MsgType } from '@vben/constants'; import { IconifyIcon } from '@vben/icons'; @@ -51,7 +52,7 @@ function handleAccountChange(accountId: number) { } /** 切换回复类型 */ -async function onTabChange(tabName: any) { +async function onTabChange(tabName: string) { msgType.value = tabName; await nextTick(); // 更新 columns diff --git a/apps/web-antd/src/views/mp/autoReply/modules/content.vue b/apps/web-antd/src/views/mp/autoReply/modules/content.vue index 0ce483ebe..caa022c6e 100644 --- a/apps/web-antd/src/views/mp/autoReply/modules/content.vue +++ b/apps/web-antd/src/views/mp/autoReply/modules/content.vue @@ -26,7 +26,7 @@ const props = defineProps<{
- +
diff --git a/apps/web-ele/src/views/mp/autoReply/data.ts b/apps/web-ele/src/views/mp/autoReply/data.ts index d72fa9643..dbac8b7f1 100644 --- a/apps/web-ele/src/views/mp/autoReply/data.ts +++ b/apps/web-ele/src/views/mp/autoReply/data.ts @@ -16,6 +16,7 @@ import { MsgType } from './modules/types'; let accountList: MpAccountApi.AccountSimple[] = []; getSimpleAccountList().then((data) => (accountList = data)); +// TODO @hw:要不要使用统一枚举? const RequestMessageTypes = new Set([ 'image', 'link', @@ -25,6 +26,7 @@ const RequestMessageTypes = new Set([ 'video', 'voice', ]); // 允许选择的请求消息类型 + /** 获取表格列配置 */ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { const columns: VxeGridPropTypes.Columns = []; @@ -65,6 +67,7 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { field: 'responseMessageType', title: '回复消息类型', minWidth: 120, + // TODO @hw:这里和 antd 有差别。两侧尽量统一; formatter: ({ cellValue }) => getDictObj(DICT_TYPE.MP_MESSAGE_TYPE, String(cellValue))?.label ?? '', }, @@ -93,7 +96,9 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { /** 新增/修改的表单 */ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { const schema: VbenFormSchema[] = []; + // 消息类型(仅消息回复显示) + // TODO @hw:这里和 antd 有差别。两侧尽量统一; if (Number(msgType) === MsgType.Message) { schema.push({ fieldName: 'requestMessageType', @@ -109,6 +114,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { } // 匹配类型(仅关键词回复显示) + // TODO @hw:这里和 antd 有差别。两侧尽量统一; if (Number(msgType) === MsgType.Keyword) { schema.push({ fieldName: 'requestMatch', @@ -127,6 +133,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { } // 关键词(仅关键词回复显示) + // TODO @hw:这里和 antd 有差别。两侧尽量统一; if (Number(msgType) === MsgType.Keyword) { schema.push({ fieldName: 'requestKeyword', @@ -140,6 +147,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { }); } // 回复消息 + // TODO @hw:这里和 antd 有差别。两侧尽量统一; schema.push({ fieldName: 'reply', label: '回复消息', @@ -149,6 +157,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { } /** 列表的搜索表单 */ +// TODO @hw:是不是用 wxselect 组件哈? export function useGridFormSchema(): VbenFormSchema[] { return [ { diff --git a/apps/web-ele/src/views/mp/autoReply/index.vue b/apps/web-ele/src/views/mp/autoReply/index.vue index f3938b595..23680868b 100644 --- a/apps/web-ele/src/views/mp/autoReply/index.vue +++ b/apps/web-ele/src/views/mp/autoReply/index.vue @@ -16,7 +16,11 @@ import { } from 'element-plus'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; -import * as MpAutoReplyApi from '#/api/mp/autoReply'; +import { + deleteAutoReply, + getAutoReply, + getAutoReplyPage, +} from '#/api/mp/autoReply'; import { $t } from '#/locales'; import { WxAccountSelect } from '#/views/mp/components'; @@ -29,11 +33,29 @@ defineOptions({ name: 'MpAutoReply' }); const msgType = ref(String(MsgType.Keyword)); // 消息类型 +const showCreateButton = computed(() => { + if (Number(msgType.value) !== MsgType.Follow) { + return true; + } + try { + const tableData = gridApi.grid?.getTableData(); + return (tableData?.tableData?.length || 0) <= 0; + } catch { + return true; + } +}); // 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示 + +/** 刷新表格 */ +function handleRefresh() { + gridApi.query(); +} + /** 公众号变化时查询数据 */ function handleAccountChange(accountId: number) { gridApi.formApi.setValues({ accountId }); gridApi.formApi.submitForm(); } + /** 切换回复类型 */ async function onTabChange(tabName: string) { msgType.value = tabName; @@ -50,24 +72,26 @@ async function onTabChange(tabName: string) { await gridApi.query(); } -/** 新增按钮操作 */ +/** 新增自动回复 */ async function handleCreate() { const formValues = await gridApi.formApi.getValues(); - formModalApi .setData({ + // TODO @hw:这里和 antd 不同,需要 number 下么? msgType: msgType.value, accountId: formValues.accountId, }) .open(); } -/** 修改按钮操作 */ +/** 修改自动回复 */ async function handleEdit(row: any) { - const data = (await MpAutoReplyApi.getAutoReply(row.id)) as any; + const data = (await getAutoReply(row.id)) as any; + // TODO @hw:这里使用 formValues,还是使用 row? const formValues = await gridApi.formApi.getValues(); formModalApi .setData({ + // TODO @hw:这里和 antd 不同,需要 number 下么? msgType: msgType.value, row: data, accountId: formValues.accountId, @@ -75,14 +99,14 @@ async function handleEdit(row: any) { .open(); } -/** 删除按钮操作 */ +/** 删除自动回复 */ async function handleDelete(row: any) { await ElMessageBox.confirm('是否确认删除此数据?'); const loadingInstance = ElLoading.service({ text: $t('ui.actionMessage.deleting', ['自动回复']), }); try { - await MpAutoReplyApi.deleteAutoReply(row.id); + await deleteAutoReply(row.id); ElMessage.success('删除成功'); handleRefresh(); } finally { @@ -106,7 +130,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ proxyConfig: { ajax: { query: async ({ page }, formValues) => { - return await MpAutoReplyApi.getAutoReplyPage({ + return await getAutoReplyPage({ pageNo: page.currentPage, pageSize: page.pageSize, type: Number(msgType.value) as MsgType, @@ -124,26 +148,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ refresh: true, search: true, }, + // TODO @hw:这里要调整下,linter 报错; } as VxeTableGridOptions, }); - -/** 刷新表格 */ -function handleRefresh() { - gridApi.query(); -} - -// 计算是否显示新增按钮:关注时回复类型只有在没有数据时才显示 -const showCreateButton = computed(() => { - if (Number(msgType.value) !== MsgType.Follow) { - return true; - } - try { - const tableData = gridApi.grid?.getTableData(); - return (tableData?.tableData?.length || 0) <= 0; - } catch { - return true; - } -}); - + -