1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { DescriptionItemSchema } from '#/components/description';
|
| import { h } from 'vue';
|
| import { DICT_TYPE } from '../../../../packages/constants/src';
| import { getDictOptions } from '../../../../packages/effects/hooks/src';
| import { formatDateTime } from '../../../../packages/utils/src';
|
| import dayjs from 'dayjs';
|
| import { DictTag } from '#/components/dict-tag';
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'handlerName',
| label: '处理器的名字',
| component: 'Input',
| componentProps: {
| allowClear: true,
| placeholder: '请输入处理器的名字',
| },
| },
| {
| fieldName: 'beginTime',
| label: '开始执行时间',
| component: 'DatePicker',
| componentProps: {
| allowClear: true,
| placeholder: '选择开始执行时间',
| valueFormat: 'YYYY-MM-DD HH:mm:ss',
| showTime: {
| format: 'HH:mm:ss',
| defaultValue: dayjs('00:00:00', 'HH:mm:ss'),
| },
| },
| },
| {
| fieldName: 'endTime',
| label: '结束执行时间',
| component: 'DatePicker',
| componentProps: {
| allowClear: true,
| placeholder: '选择结束执行时间',
| valueFormat: 'YYYY-MM-DD HH:mm:ss',
| showTime: {
| format: 'HH:mm:ss',
| defaultValue: dayjs('23:59:59', 'HH:mm:ss'),
| },
| },
| },
| {
| fieldName: 'status',
| label: '任务状态',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.INFRA_JOB_LOG_STATUS, 'number'),
| allowClear: true,
| placeholder: '请选择任务状态',
| },
| },
| ];
| }
|
| /** 表格列配置 */
| export function useGridColumns(): VxeTableGridOptions['columns'] {
| return [
| {
| field: 'id',
| title: '日志编号',
| minWidth: 80,
| },
| {
| field: 'jobId',
| title: '任务编号',
| minWidth: 80,
| },
| {
| field: 'handlerName',
| title: '处理器的名字',
| minWidth: 180,
| },
| {
| field: 'handlerParam',
| title: '处理器的参数',
| minWidth: 140,
| },
| {
| field: 'executeIndex',
| title: '第几次执行',
| minWidth: 100,
| },
| {
| field: 'beginTime',
| title: '执行时间',
| minWidth: 280,
| formatter: ({ row }) => {
| return `${formatDateTime(row.beginTime)} ~ ${formatDateTime(row.endTime)}`;
| },
| },
| {
| field: 'duration',
| title: '执行时长',
| minWidth: 120,
| formatter: ({ row }) => {
| return `${row.duration} 毫秒`;
| },
| },
| {
| field: 'status',
| title: '任务状态',
| minWidth: 100,
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.INFRA_JOB_LOG_STATUS },
| },
| },
| {
| title: '操作',
| width: 80,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
| /** 详情页的字段 */
| export function useDetailSchema(): DescriptionItemSchema[] {
| return [
| {
| field: 'id',
| label: '日志编号',
| },
| {
| field: 'jobId',
| label: '任务编号',
| },
| {
| field: 'handlerName',
| label: '处理器的名字',
| },
| {
| field: 'handlerParam',
| label: '处理器的参数',
| },
| {
| field: 'executeIndex',
| label: '第几次执行',
| },
| {
| field: 'beginTime',
| label: '执行时间',
| render: (val, data) => {
| if (val && data?.endTime) {
| return `${formatDateTime(val)} ~ ${formatDateTime(data.endTime)}`;
| }
| return '';
| },
| },
| {
| field: 'duration',
| label: '执行时长',
| render: (val) => {
| return val ? `${val} 毫秒` : '';
| },
| },
| {
| field: 'status',
| label: '任务状态',
| render: (val) => {
| return h(DictTag, {
| type: DICT_TYPE.INFRA_JOB_LOG_STATUS,
| value: val,
| });
| },
| },
| {
| field: 'result',
| label: '执行结果',
| },
| ];
| }
|
|