feat: ele use desc comp

This commit is contained in:
xingyu4j
2025-10-21 15:33:32 +08:00
parent 18ef9031ca
commit d368582a90
32 changed files with 266 additions and 408 deletions

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemLoginLogApi } from '#/api/system/login-log';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -110,10 +109,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'logType',
label: '操作类型',
content: (data: SystemLoginLogApi.LoginLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_LOGIN_TYPE,
value: data?.logType,
value: val,
});
},
},
@@ -132,19 +131,17 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'result',
label: '登录结果',
content: (data: SystemLoginLogApi.LoginLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_LOGIN_RESULT,
value: data?.result,
value: val,
});
},
},
{
field: 'createTime',
label: '登录日期',
content: (data: SystemLoginLogApi.LoginLog) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
];
}

View File

@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemLoginLogApi.LoginLog>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
labelWidth: 110,
title: '',
extra: '',
},
column: 1,
labelWidth: 110,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemMailLogApi } from '#/api/system/mail/log';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -164,9 +163,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'createTime',
label: '创建时间',
content: (data: SystemMailLogApi.MailLog) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'fromMail',
@@ -175,14 +172,14 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'userId',
label: '接收用户',
content: (data: SystemMailLogApi.MailLog) => {
if (data?.userType && data?.userId) {
render: (val, data) => {
if (data?.userType && val) {
return h('div', [
h(DictTag, {
type: DICT_TYPE.USER_TYPE,
value: data.userType,
}),
` (${data.userId})`,
` (${val})`,
]);
}
return '无';
@@ -191,10 +188,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'toMails',
label: '接收信息',
content: (data: SystemMailLogApi.MailLog) => {
render: (val, data) => {
const lines: string[] = [];
if (data?.toMails && data.toMails.length > 0) {
lines.push(`收件:${data.toMails.join('、')}`);
if (val && val.length > 0) {
lines.push(`收件:${val.join('、')}`);
}
if (data?.ccMails && data.ccMails.length > 0) {
lines.push(`抄送:${data.ccMails.join('、')}`);
@@ -227,28 +224,26 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'templateContent',
label: '邮件内容',
span: 2,
content: (data: SystemMailLogApi.MailLog) => {
render: (val) => {
return h('div', {
innerHTML: data?.templateContent || '',
innerHTML: val || '',
});
},
},
{
field: 'sendStatus',
label: '发送状态',
content: (data: SystemMailLogApi.MailLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_MAIL_SEND_STATUS,
value: data?.sendStatus,
value: val,
});
},
},
{
field: 'sendTime',
label: '发送时间',
content: (data: SystemMailLogApi.MailLog) => {
return formatDateTime(data?.sendTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'sendMessageId',

View File

@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemMailLogApi.MailLog>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 2,
direction: 'horizontal',
labelWidth: 140,
title: '',
extra: '',
},
column: 2,
labelWidth: 140,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -166,10 +165,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'userType',
label: '用户类型',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.USER_TYPE,
value: data?.userType,
value: val,
});
},
},
@@ -196,9 +195,9 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'templateParams',
label: '模版参数',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
try {
return JSON.stringify(data?.templateParams);
return JSON.stringify(val);
} catch {
return '';
}
@@ -207,36 +206,32 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'templateType',
label: '模版类型',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
value: data?.templateType,
value: val,
});
},
},
{
field: 'readStatus',
label: '是否已读',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
value: data?.readStatus,
value: val,
});
},
},
{
field: 'readTime',
label: '阅读时间',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
return formatDateTime(data?.readTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'createTime',
label: '创建时间',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
];
}

View File

@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemNotifyMessageApi.NotifyMessage>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
labelWidth: 140,
title: '',
extra: '',
},
column: 1,
labelWidth: 140,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemNotifyMessageApi } from '#/api/system/notify/message';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -103,36 +102,32 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'createTime',
label: '发送时间',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'templateType',
label: '消息类型',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
value: data?.templateType,
value: val,
});
},
},
{
field: 'readStatus',
label: '是否已读',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.INFRA_BOOLEAN_STRING,
value: data?.readStatus,
value: val,
});
},
},
{
field: 'readTime',
label: '阅读时间',
content: (data: SystemNotifyMessageApi.NotifyMessage) => {
return formatDateTime(data?.readTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'templateContent',

View File

@@ -12,14 +12,8 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemNotifyMessageApi.NotifyMessage>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
labelWidth: 140,
title: '',
extra: '',
},
column: 1,
labelWidth: 140,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemOperateLogApi } from '#/api/system/operate-log';
import type { DescriptionItemSchema } from '#/components/description';
import { formatDateTime } from '@vben/utils';
@@ -134,7 +133,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'traceId',
label: '链路追踪',
hidden: (data: SystemOperateLogApi.OperateLog) => !data?.traceId,
show: (val) => !val,
},
{
field: 'userId',
@@ -167,13 +166,14 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'extra',
label: '操作拓展参数',
hidden: (data: SystemOperateLogApi.OperateLog) => !data?.extra,
show: (val) => !val,
},
{
label: '请求 URL',
content: (data: SystemOperateLogApi.OperateLog) => {
if (data?.requestMethod && data?.requestUrl) {
return `${data.requestMethod} ${data.requestUrl}`;
field: 'requestUrl',
render: (val, data) => {
if (data?.requestMethod && val) {
return `${data.requestMethod} ${val}`;
}
return '';
},
@@ -181,9 +181,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'createTime',
label: '操作时间',
content: (data: SystemOperateLogApi.OperateLog) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'bizId',

View File

@@ -12,14 +12,9 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemOperateLogApi.OperateLog>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
labelWidth: 110,
title: '',
extra: '',
},
column: 1,
direction: 'horizontal',
labelWidth: 110,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSmsLogApi } from '#/api/system/sms/log';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -179,9 +178,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'createTime',
label: '创建时间',
content: (data: SystemSmsLogApi.SmsLog) => {
return formatDateTime(data?.createTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'mobile',
@@ -198,10 +195,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'templateType',
label: '模板类型',
content: (data: SystemSmsLogApi.SmsLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_SMS_TEMPLATE_TYPE,
value: data?.templateType,
value: val,
});
},
},
@@ -212,19 +209,17 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'sendStatus',
label: '发送状态',
content: (data: SystemSmsLogApi.SmsLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_SMS_SEND_STATUS,
value: data?.sendStatus,
value: val,
});
},
},
{
field: 'sendTime',
label: '发送时间',
content: (data: SystemSmsLogApi.SmsLog) => {
return formatDateTime(data?.sendTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'apiSendCode',
@@ -237,19 +232,17 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'receiveStatus',
label: '接收状态',
content: (data: SystemSmsLogApi.SmsLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_SMS_RECEIVE_STATUS,
value: data?.receiveStatus,
value: val,
});
},
},
{
field: 'receiveTime',
label: '接收时间',
content: (data: SystemSmsLogApi.SmsLog) => {
return formatDateTime(data?.receiveTime || '') as string;
},
render: (val) => formatDateTime(val) as string,
},
{
field: 'apiReceiveCode',

View File

@@ -12,14 +12,9 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemSmsLogApi.SmsLog>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 2,
direction: 'horizontal',
labelWidth: 140,
title: '',
extra: '',
},
column: 2,
direction: 'horizontal',
labelWidth: 140,
schema: useDetailSchema(),
});

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemSocialUserApi } from '#/api/system/social/user';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -8,6 +7,8 @@ import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { ElImage } from 'element-plus';
import { DictTag } from '#/components/dict-tag';
import { getRangePickerDefaultProps } from '#/utils';
@@ -111,10 +112,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'type',
label: '社交平台',
content: (data: SystemSocialUserApi.SocialUser) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.SYSTEM_SOCIAL_TYPE,
value: data?.type,
value: val,
});
},
},
@@ -125,16 +126,13 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'avatar',
label: '用户头像',
// TODO @芋艿:使用 antd 的 Image 组件
content: (data: SystemSocialUserApi.SocialUser) => {
if (data?.avatar) {
return h('img', {
src: data.avatar,
style: 'width: 30px; height: 30px; cursor: pointer;',
onClick: () => {
// 可以添加图片预览功能
window.open(data.avatar, '_blank');
},
render: (val) => {
if (val) {
return h(ElImage, {
src: val,
previewSrcList: [val],
class: 'w-10 h-10 cursor-pointer',
previewTeleported: true,
});
}
return '无';

View File

@@ -14,14 +14,8 @@ import { useDetailSchema } from '../data';
const formData = ref<SystemSocialUserApi.SocialUser>();
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
title: '',
extra: '',
labelWidth: 185,
},
column: 1,
labelWidth: 185,
schema: useDetailSchema(),
});