diff --git a/apps/web-antd/src/views/mp/autoReply/data.ts b/apps/web-antd/src/views/mp/autoReply/data.ts index 4054ec64b3e230a691fb389eee8baf9752614595..3bd3ab03c4d29be301deb7cadbf775a9871816d9 100644 --- a/apps/web-antd/src/views/mp/autoReply/data.ts +++ b/apps/web-antd/src/views/mp/autoReply/data.ts @@ -3,27 +3,22 @@ import type { VxeGridPropTypes } from '#/adapter/vxe-table'; import { markRaw } from 'vue'; -import { DICT_TYPE, AutoReplyMsgType as MsgType } from '@vben/constants'; +import { + AutoReplyMsgType, + DICT_TYPE, + RequestMessageTypes, +} from '@vben/constants'; import { getDictOptions } from '@vben/hooks'; import { WxReply } from '#/views/mp/components'; -// TODO @hw:要不要使用统一枚举? -const RequestMessageTypes = new Set([ - 'image', - 'link', - 'location', - 'shortvideo', - 'text', - 'video', - 'voice', -]); // 允许选择的请求消息类型 - /** 获取表格列配置 */ -export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { +export function useGridColumns( + msgType: AutoReplyMsgType, +): VxeGridPropTypes.Columns { const columns: VxeGridPropTypes.Columns = []; // 请求消息类型列(仅消息回复显示) - if (msgType === MsgType.Message) { + if (msgType === AutoReplyMsgType.Message) { columns.push({ field: 'requestMessageType', title: '请求消息类型', @@ -32,7 +27,7 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { } // 关键词列(仅关键词回复显示) - if (msgType === MsgType.Keyword) { + if (msgType === AutoReplyMsgType.Keyword) { columns.push({ field: 'requestKeyword', title: '关键词', @@ -41,7 +36,7 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { } // 匹配类型列(仅关键词回复显示) - if (msgType === MsgType.Keyword) { + if (msgType === AutoReplyMsgType.Keyword) { columns.push({ field: 'requestMatch', title: '匹配类型', @@ -87,11 +82,11 @@ export function useGridColumns(msgType: MsgType): VxeGridPropTypes.Columns { } /** 新增/修改的表单 */ -export function useFormSchema(msgType: MsgType): VbenFormSchema[] { +export function useFormSchema(msgType: AutoReplyMsgType): VbenFormSchema[] { const schema: VbenFormSchema[] = []; // 消息类型(仅消息回复显示) - if (msgType === MsgType.Message) { + if (msgType === AutoReplyMsgType.Message) { schema.push({ fieldName: 'requestMessageType', label: '消息类型', @@ -106,7 +101,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { } // 匹配类型(仅关键词回复显示) - if (msgType === MsgType.Keyword) { + if (msgType === AutoReplyMsgType.Keyword) { schema.push({ fieldName: 'requestMatch', label: '匹配类型', @@ -124,7 +119,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] { } // 关键词(仅关键词回复显示) - if (msgType === MsgType.Keyword) { + if (msgType === AutoReplyMsgType.Keyword) { schema.push({ fieldName: 'requestKeyword', label: '关键词', diff --git a/apps/web-antd/src/views/mp/autoReply/index.vue b/apps/web-antd/src/views/mp/autoReply/index.vue index c3c84a4424ac5f1f33349e0f027c6da6d1a8fd24..71191c59475fb92dc111388767f64eb503c56353 100644 --- a/apps/web-antd/src/views/mp/autoReply/index.vue +++ b/apps/web-antd/src/views/mp/autoReply/index.vue @@ -5,8 +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 { AutoReplyMsgType } from '@vben/constants'; import { IconifyIcon } from '@vben/icons'; import { message, Row, Tabs } from 'ant-design-vue'; @@ -26,10 +25,10 @@ import Form from './modules/form.vue'; defineOptions({ name: 'MpAutoReply' }); -const msgType = ref(String(MsgType.Keyword)); // 消息类型 +const msgType = ref(String(AutoReplyMsgType.Keyword)); // 消息类型 const showCreateButton = computed(() => { - if (Number(msgType.value) !== MsgType.Follow) { + if (Number(msgType.value) !== AutoReplyMsgType.Follow) { return true; } try { @@ -56,7 +55,7 @@ async function onTabChange(tabName: string) { msgType.value = tabName; await nextTick(); // 更新 columns - const columns = useGridColumns(Number(msgType.value) as MsgType); + const columns = useGridColumns(Number(msgType.value) as AutoReplyMsgType); if (columns) { // 使用 setGridOptions 更新列配置 gridApi.setGridOptions({ columns }); @@ -72,7 +71,7 @@ async function handleCreate() { const formValues = await gridApi.formApi.getValues(); formModalApi .setData({ - msgType: Number(msgType.value) as MsgType, + msgType: Number(msgType.value) as AutoReplyMsgType, accountId: formValues.accountId, }) .open(); @@ -83,7 +82,7 @@ async function handleEdit(row: any) { const data = (await getAutoReply(row.id)) as any; formModalApi .setData({ - msgType: Number(msgType.value) as MsgType, + msgType: Number(msgType.value) as AutoReplyMsgType, accountId: row.accountId, row: data, }) @@ -116,7 +115,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ schema: useGridFormSchema(), }, gridOptions: { - columns: useGridColumns(Number(msgType.value) as MsgType), + columns: useGridColumns(Number(msgType.value) as AutoReplyMsgType), height: 'auto', keepSource: true, proxyConfig: { @@ -125,7 +124,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ return await getAutoReplyPage({ pageNo: page.currentPage, pageSize: page.pageSize, - type: Number(msgType.value) as MsgType, + type: Number(msgType.value) as AutoReplyMsgType, ...formValues, }); }, @@ -161,14 +160,14 @@ const [Grid, gridApi] = useVbenVxeGrid({ class="w-full" @change="(activeKey) => onTabChange(activeKey as string)" > - + - + - +