diff --git a/apps/web-antd/src/views/mp/autoReply/data.ts b/apps/web-antd/src/views/mp/autoReply/data.ts index 9d8736ee7..c3fdb981e 100644 --- a/apps/web-antd/src/views/mp/autoReply/data.ts +++ b/apps/web-antd/src/views/mp/autoReply/data.ts @@ -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', }, ]; } diff --git a/apps/web-antd/src/views/mp/autoReply/index.vue b/apps/web-antd/src/views/mp/autoReply/index.vue index 22cb3bea9..bc75396c7 100644 --- a/apps/web-antd/src/views/mp/autoReply/index.vue +++ b/apps/web-antd/src/views/mp/autoReply/index.vue @@ -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({ +