fix: ele改回使用账号选择组件

This commit is contained in:
hw
2025-11-20 11:05:18 +08:00
parent cf14806b6f
commit 0ea99e5aa8
10 changed files with 49 additions and 42 deletions

View File

@@ -8,7 +8,7 @@ import { DICT_TYPE } from '@vben/constants';
import { getDictObj, getDictOptions } from '@vben/hooks';
import { getSimpleAccountList } from '#/api/mp/account';
import { ReplySelect } from '#/views/mp/components';
import { WxReplySelect } from '#/views/mp/components';
import { MsgType } from './modules/types';
@@ -143,7 +143,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
schema.push({
fieldName: 'reply',
label: '回复消息',
component: markRaw(ReplySelect),
component: markRaw(WxReplySelect),
});
return schema;
}

View File

@@ -18,6 +18,7 @@ import {
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import * as MpAutoReplyApi from '#/api/mp/autoReply';
import { $t } from '#/locales';
import { WxAccountSelect } from '#/views/mp/components';
import { useGridColumns, useGridFormSchema } from './data';
import Content from './modules/content.vue';
@@ -27,6 +28,12 @@ import { MsgType } from './modules/types';
defineOptions({ name: 'MpAutoReply' });
const msgType = ref<string>(String(MsgType.Keyword)); // 消息类型
/** 公众号变化时查询数据 */
function handleAccountChange(accountId: number) {
gridApi.formApi.setValues({ accountId });
gridApi.formApi.submitForm();
}
/** 切换回复类型 */
async function onTabChange(tabName: string) {
msgType.value = tabName;
@@ -91,8 +98,6 @@ const [FormModal, formModalApi] = useVbenModal({
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
// 表单值变化时自动提交,这样 accountId 会被正确传递到查询函数
submitOnChange: true,
},
gridOptions: {
columns: useGridColumns(Number(msgType.value) as MsgType),
@@ -109,6 +114,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
},
},
autoLoad: false,
},
rowConfig: {
keyField: 'id',
@@ -148,6 +154,9 @@ const showCreateButton = computed(() => {
<FormModal @success="handleRefresh" />
<Grid table-title="自动回复列表">
<template #form-accountId>
<WxAccountSelect @change="handleAccountChange" />
</template>
<!-- 在工具栏上方放置 Tab 切换 -->
<template #toolbar-actions>
<ElTabs

View File

@@ -1,5 +1,10 @@
<script lang="ts" setup>
import { Music, News, VideoPlayer, VoicePlayer } from '#/views/mp/components';
import {
WxMusic,
WxNews,
WxVideoPlayer,
WxVoicePlayer,
} from '#/views/mp/components';
defineOptions({ name: 'ReplyContentCell' });
@@ -14,7 +19,7 @@ const props = defineProps<{
{{ props.row.responseContent }}
</div>
<div v-else-if="props.row.responseMessageType === 'voice'">
<VoicePlayer
<WxVoicePlayer
v-if="props.row.responseMediaUrl"
:url="props.row.responseMediaUrl"
/>
@@ -30,17 +35,17 @@ const props = defineProps<{
props.row.responseMessageType === 'shortvideo'
"
>
<VideoPlayer
<WxVideoPlayer
v-if="props.row.responseMediaUrl"
:url="props.row.responseMediaUrl"
class="mt-[10px]"
/>
</div>
<div v-else-if="props.row.responseMessageType === 'news'">
<News :articles="props.row.responseArticles" />
<WxNews :articles="props.row.responseArticles" />
</div>
<div v-else-if="props.row.responseMessageType === 'music'">
<Music
<WxMusic
:title="props.row.responseTitle"
:description="props.row.responseDescription"
:thumb-media-url="props.row.responseThumbMediaUrl"