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 { InfraJobApi } from '#/api/infra/job';
import type { DescriptionItemSchema } from '#/components/description';
import { h, markRaw } from 'vue';
@@ -197,10 +196,10 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'status',
label: '任务状态',
content: (data: InfraJobApi.Job) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.INFRA_JOB_STATUS,
value: data?.status,
value: val,
});
},
},
@@ -222,27 +221,23 @@ export function useDetailSchema(): DescriptionItemSchema[] {
},
{
label: '重试间隔',
content: (data: InfraJobApi.Job) => {
return data?.retryInterval ? `${data.retryInterval} 毫秒` : '无间隔';
},
field: 'retryInterval',
render: (val) => (val ? `${val} 毫秒` : '无间隔'),
},
{
label: '监控超时时间',
content: (data: InfraJobApi.Job) => {
return data?.monitorTimeout && data.monitorTimeout > 0
? `${data.monitorTimeout} 毫秒`
: '未开启';
},
field: 'monitorTimeout',
render: (val) => (val && val > 0 ? `${val} 毫秒` : '未开启'),
},
{
field: 'nextTimes',
label: '后续执行时间',
content: (data: InfraJobApi.Job) => {
if (!data?.nextTimes || data.nextTimes.length === 0) {
render: (val) => {
if (!val || val.length === 0) {
return '无后续执行时间';
}
return h(ElTimeline, {}, () =>
data.nextTimes?.map((time: Date) =>
val?.map((time: Date) =>
h(ElTimelineItem, {}, () => formatDateTime(time)),
),
);

View File

@@ -1,6 +1,5 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { InfraJobLogApi } from '#/api/infra/job-log';
import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue';
@@ -154,9 +153,9 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'beginTime',
label: '执行时间',
content: (data: InfraJobLogApi.JobLog) => {
if (data?.beginTime && data?.endTime) {
return `${formatDateTime(data.beginTime)} ~ ${formatDateTime(data.endTime)}`;
render: (val, data) => {
if (val && data?.endTime) {
return `${formatDateTime(val)} ~ ${formatDateTime(data.endTime)}`;
}
return '';
},
@@ -164,17 +163,15 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{
field: 'duration',
label: '执行时长',
content: (data: InfraJobLogApi.JobLog) => {
return data?.duration ? `${data.duration} 毫秒` : '';
},
render: (val) => (val ? `${val} 毫秒` : ''),
},
{
field: 'status',
label: '任务状态',
content: (data: InfraJobLogApi.JobLog) => {
render: (val) => {
return h(DictTag, {
type: DICT_TYPE.INFRA_JOB_LOG_STATUS,
value: data?.status,
value: val,
});
},
},

View File

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

View File

@@ -14,14 +14,8 @@ const formData = ref<InfraJobApi.Job>(); // 任务详情
const nextTimes = ref<Date[]>([]); // 下一次执行时间
const [Descriptions] = useDescription({
componentProps: {
border: true,
column: 1,
direction: 'horizontal',
labelWidth: 140,
title: '',
extra: '',
},
column: 1,
labelWidth: 140,
schema: useDetailSchema(),
});