perf: notify detail
parent
85a976cf40
commit
073f9ddcdb
|
@ -1,7 +1,13 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
|
||||||
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
|
@ -108,3 +114,44 @@ export function useGridColumns<T = SystemNotifyMessageApi.NotifyMessage>(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useDetailSchema(): DescriptionItemSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'templateNickname',
|
||||||
|
label: '发送人',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
label: '发送时间',
|
||||||
|
content: (data) => formatDateTime(data?.createTime) as string,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'templateType',
|
||||||
|
label: '消息类型',
|
||||||
|
content: (data) =>
|
||||||
|
h(DictTag, {
|
||||||
|
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
||||||
|
value: data?.templateType,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'readStatus',
|
||||||
|
label: '是否已读',
|
||||||
|
content: (data) =>
|
||||||
|
h(DictTag, {
|
||||||
|
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
|
||||||
|
value: data?.readStatus,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'readTime',
|
||||||
|
label: '阅读时间',
|
||||||
|
content: (data) => formatDateTime(data?.readTime) as string,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'templateContent',
|
||||||
|
label: '消息内容',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
|
||||||
|
|
||||||
import { h, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { formatDateTime } from '@vben/utils';
|
|
||||||
|
|
||||||
import { useDescription } from '#/components/description';
|
import { useDescription } from '#/components/description';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
|
||||||
import { DICT_TYPE } from '#/utils';
|
|
||||||
|
|
||||||
// TODO @puhui999:formData 貌似不需要了
|
import { useDetailSchema } from '../data';
|
||||||
const formData = ref<SystemNotifyMessageApi.NotifyMessage>();
|
|
||||||
|
|
||||||
// TODO @puhui999:descriptionApi 好点,更清晰哈;
|
|
||||||
const [Description, descApi] = useDescription({
|
const [Description, descApi] = useDescription({
|
||||||
componentProps: {
|
componentProps: {
|
||||||
bordered: true,
|
bordered: true,
|
||||||
|
@ -21,51 +14,12 @@ const [Description, descApi] = useDescription({
|
||||||
size: 'middle',
|
size: 'middle',
|
||||||
class: 'mx-4',
|
class: 'mx-4',
|
||||||
},
|
},
|
||||||
// TODO @puhui999:是不是也放到 data 里;
|
schema: useDetailSchema(),
|
||||||
schema: [
|
|
||||||
{
|
|
||||||
field: 'templateNickname',
|
|
||||||
label: '发送人',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'createTime',
|
|
||||||
label: '发送时间',
|
|
||||||
content: (data) => formatDateTime(data?.createTime) as string,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'templateType',
|
|
||||||
label: '消息类型',
|
|
||||||
content: (data) =>
|
|
||||||
h(DictTag, {
|
|
||||||
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
|
|
||||||
value: data?.templateType,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'readStatus',
|
|
||||||
label: '是否已读',
|
|
||||||
content: (data) =>
|
|
||||||
h(DictTag, {
|
|
||||||
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
|
|
||||||
value: data?.readStatus,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'readTime',
|
|
||||||
label: '阅读时间',
|
|
||||||
content: (data) => formatDateTime(data?.readTime) as string,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'templateContent',
|
|
||||||
label: '消息内容',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
async onOpenChange(isOpen: boolean) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
formData.value = undefined;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 加载数据
|
// 加载数据
|
||||||
|
@ -75,7 +29,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
}
|
}
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
formData.value = data;
|
|
||||||
descApi.setState({ data });
|
descApi.setState({ data });
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
|
|
Loading…
Reference in New Issue