review:【antd】【mp】自动回复优化

pull/259/MERGE
YunaiV 2025-11-09 16:55:03 +08:00
parent f8abee2b63
commit d6cbad72e5
5 changed files with 33 additions and 32 deletions

View File

@ -68,6 +68,7 @@ defineExpose({
</script>
<template>
<!-- TODO @hw可以使用 <Form class="mx-4" /> 这种组件形式么 融合到 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mp/autoReply/modules/form.vue -->
<div>
<Form
ref="formRef"
@ -135,5 +136,3 @@ defineExpose({
</Form>
</div>
</template>
<style scoped></style>

View File

@ -3,7 +3,7 @@ import { WxMusic } from '#/views/mp/modules/wx-music';
import { WxNews } from '#/views/mp/modules/wx-news';
import { WxVideoPlayer } from '#/views/mp/modules/wx-video-play';
import { WxVoicePlayer } from '#/views/mp/modules/wx-voice-play';
// TODO @hw /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mp/autoReply/modules = = content.vue ~
defineOptions({ name: 'ReplyContentCell' });
const props = defineProps<{

View File

@ -26,10 +26,12 @@ import Form from './modules/form.vue';
defineOptions({ name: 'MpAutoReply' });
const msgType = ref<string>(String(MsgType.Keyword)); //
async function onTabChange(_tabName: string) {
msgType.value = _tabName;
// msgType
/** 切换回复类型 */
async function onTabChange(tabName: string) {
msgType.value = tabName;
await nextTick();
// columns
const columns = useGridColumns(Number(msgType.value) as MsgType);
if (columns) {
// 使 setGridOptions
@ -37,15 +39,14 @@ async function onTabChange(_tabName: string) {
//
await nextTick();
}
//
await gridApi.query();
//
updateTableDataLength();
}
/** 新增按钮操作 */
async function handleCreate() {
const formValues = await gridApi.formApi.getValues();
formModalApi
.setData({
isCreating: true,
@ -93,13 +94,11 @@ const [FormModal, formModalApi] = useVbenModal({
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
// accountId
submitOnChange: true,
submitOnChange: true, // accountId
},
gridOptions: {
columns: useGridColumns(Number(msgType.value) as MsgType),
height: 'calc(100vh - 300px)',
// height: '600px',
keepSource: true,
proxyConfig: {
ajax: {
@ -112,8 +111,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
});
},
},
//
autoLoad: false,
autoLoad: false, //
},
rowConfig: {
keyField: 'id',
@ -126,10 +124,10 @@ const [Grid, gridApi] = useVbenVxeGrid({
} as VxeTableGridOptions<any>,
});
//
const tableDataLength = ref(0);
// TODO @hw
const tableDataLength = ref(0); //
// getTableData
/** 更新表格数据长度(避免在模板中直接调用 getTableData 导致响应式循环) */
function updateTableDataLength() {
try {
if (!gridApi.grid) {
@ -142,6 +140,7 @@ function updateTableDataLength() {
}
}
// TODO @hw tableaction
//
const showCreateButton = computed(() => {
if (Number(msgType.value) !== MsgType.Follow) {
@ -150,20 +149,21 @@ const showCreateButton = computed(() => {
return tableDataLength.value <= 0;
});
//
/** 页面挂载后,等待表单初始化完成再加载数据 */
onMounted(async () => {
// WxAccountSelect
await nextTick();
if (gridApi.formApi) {
const formValues = await gridApi.formApi.getValues();
// accountId
if (formValues.accountId) {
//
gridApi.formApi.setLatestSubmissionValues(formValues);
//
await gridApi.query();
updateTableDataLength();
}
if (!gridApi.formApi) {
return;
}
const formValues = await gridApi.formApi.getValues();
// accountId
if (formValues.accountId) {
//
gridApi.formApi.setLatestSubmissionValues(formValues);
//
await gridApi.query();
updateTableDataLength();
}
});
</script>
@ -173,6 +173,7 @@ onMounted(async () => {
<DocAlert title="自动回复" url="https://doc.iocoder.cn/mp/auto-reply/" />
<!-- tab 切换 -->
<!-- TODO @hw貌似 tabs 里面套 table 的样式在 vben 里有点丑要不我们按照 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/views/mall/trade/afterSale/index.vue1第一层是公众号的选择2第二层是 tab3第三层是 table -->
<ContentWrap>
<Tabs
v-model:active-key="msgType"

View File

@ -13,6 +13,7 @@ import { ReplyType } from '#/views/mp/modules/wx-reply/types';
import ReplyForm from '../components/ReplyForm.vue';
import { MsgType } from '../components/types';
import Form from '#/views/system/user/modules/form.vue';
const emit = defineEmits(['success']);
@ -24,7 +25,6 @@ const reply = ref<Reply>({
type: ReplyType.Text,
accountId: -1,
});
const getTitle = computed(() => {
return formData.value?.isCreating
? $t('ui.actionTitle.create', ['自动回复'])
@ -130,6 +130,7 @@ const [Modal, modalApi] = useVbenModal({
</script>
<template>
<!-- TODO @hw可以使用 <Form class="mx-4" /> 这种组件形式么 -->
<Modal :title="getTitle" class="w-4/5">
<ReplyForm
v-if="formData"

View File

@ -39,11 +39,11 @@ const [Modal, modalApi] = useVbenModal({
return;
}
modalApi.lock();
/** 提交表单 */
//
const values = (await formApi.getValues()) as MpUserApi.User;
try {
await updateUser({ ...formData.value, ...values });
/** 关闭并提示 */
//
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
@ -56,7 +56,7 @@ const [Modal, modalApi] = useVbenModal({
formData.value = undefined;
return;
}
/** 加载数据 */
//
const data = modalApi.getData<{ id: number }>();
if (!data || !data.id) {
return;
@ -64,7 +64,7 @@ const [Modal, modalApi] = useVbenModal({
modalApi.lock();
try {
formData.value = await getUser(data.id);
/** 设置到 values */
// values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();