review:【antd】【mp】代码评审

This commit is contained in:
YunaiV
2025-11-17 13:57:41 +08:00
parent 6f0273ab4e
commit f11b7aea69
21 changed files with 101 additions and 140 deletions

View File

@@ -16,6 +16,7 @@ import { MsgType } from './types';
let accountList: MpAccountApi.AccountSimple[] = [];
getSimpleAccountList().then((data) => (accountList = data));
// TODO @芋艿:要不要使用统一枚举?
const RequestMessageTypes = new Set([
'image',
'link',
@@ -148,6 +149,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
fieldName: 'reply',
label: '回复消息',
component: markRaw(WxReply),
// TODO @hw这里注释要不要删除掉
// componentProps: {
// modelValue: { type: 'video', content: '12456' },
// },
@@ -157,6 +159,7 @@ export function useFormSchema(msgType: MsgType): VbenFormSchema[] {
}
/** 列表的搜索表单 */
// TODO @芋艿:貌似可能微信号拿不到。
export function useGridFormSchema(): VbenFormSchema[] {
return [
{

View File

@@ -1,5 +1,6 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MpAutoReplyApi } from '#/api/mp/autoReply';
import { computed, nextTick, ref } from 'vue';
@@ -25,6 +26,23 @@ defineOptions({ name: 'MpAutoReply' });
const msgType = ref<string>(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();
}
/** 切换回复类型 */
async function onTabChange(tabName: any) {
msgType.value = tabName;
@@ -41,7 +59,7 @@ async function onTabChange(tabName: any) {
await gridApi.query();
}
/** 新增按钮操作 */
/** 新增自动回复 */
async function handleCreate() {
const formValues = await gridApi.formApi.getValues();
formModalApi
@@ -52,7 +70,7 @@ async function handleCreate() {
.open();
}
/** 修改按钮操作 */
/** 修改自动回复 */
async function handleEdit(row: any) {
const data = (await getAutoReply(row.id)) as any;
formModalApi
@@ -64,7 +82,7 @@ async function handleEdit(row: any) {
.open();
}
/** 删除按钮操作 */
/** 删除自动回复 */
async function handleDelete(row: any) {
await confirm('是否确认删除此数据?');
const hideLoading = message.loading({
@@ -114,28 +132,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
refresh: true,
search: true,
},
} as VxeTableGridOptions<any>,
} as VxeTableGridOptions<MpAutoReplyApi.AutoReply>,
});
/** 刷新表格 */
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;
}
});
// DONE @hw看看能不能参考 tag/index.vue 简化下
</script>
<template>
@@ -145,9 +143,7 @@ const showCreateButton = computed(() => {
</template>
<FormModal @success="handleRefresh" />
<Grid table-title="自动回复列表">
<!-- 第一层公众号选择在表单中 -->
<!-- 第二层tab 切换 -->
<Grid>
<template #toolbar-actions>
<Tabs
v-model:active-key="msgType"

View File

@@ -41,8 +41,6 @@ const [Form, formApi] = useVbenForm({
showDefaultActions: false,
});
// 注意schema 的更新现在在 onOpenChange 中手动处理,避免时序问题
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
@@ -115,6 +113,7 @@ const [Modal, modalApi] = useVbenModal({
// 编辑:加载数据
const rowData = data.row;
const formValues: any = { ...rowData };
// TODO @hw下面要删除掉么注释。
// delete formValues.responseMessageType;
// delete formValues.responseContent;
// delete formValues.responseMediaId;