config.ts
2.93 KB
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
import { BasicColumn, FormSchema } from '/@/components/Table';
import { Tag, Tooltip } from 'ant-design-vue';
import { h } from 'vue';
import { transformTime } from '/@/hooks/web/useDateToLocaleString';
import { DeviceState } from '/@/api/device/model/deviceModel';
import { handeleCopy } from '/@/views/device/profiles/step/topic';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
// 表格配置
export const columns: BasicColumn[] = [
{
title: t('edge.instance.text.deviceStatus'),
dataIndex: 'deviceState',
width: 100,
customRender: ({ record }) => {
const color =
record.deviceState == DeviceState.INACTIVE
? 'warning'
: record.deviceState == DeviceState.ONLINE
? 'success'
: 'error';
const text = t(`enum.deviceStatus.${record.deviceState}`);
return h(Tag, { color: color }, () => text);
},
},
{
dataIndex: 'name',
title: t('edge.instance.text.deviceName'),
width: 210,
slots: { customRender: 'name', title: 'deviceTitle' },
customRender: ({ record }) => {
return h('div', { style: 'display:flex;flex-direction:column' }, [
record.alias &&
h(
'div',
{
class: 'cursor-pointer truncate',
},
h(
Tooltip,
{
placement: 'topLeft',
title: `${record.alias}`,
},
() => `${record.alias}`
)
),
h(
'div',
{
class: 'cursor-pointer text-blue-500 truncate',
onClick: () => {
handeleCopy(`${record.name}`);
},
},
h(
Tooltip,
{
placement: 'topLeft',
title: `${record.name}`,
},
() => `${record.name}`
)
),
]);
},
},
{
title: t('edge.instance.text.relatedProduct'),
width: 160,
dataIndex: 'deviceProfileName',
},
{
title: t('edge.instance.text.relatedOrganization'),
dataIndex: 'organizationDTO.name',
width: 160,
},
{
title: t('edge.instance.text.deviceType'),
width: 100,
dataIndex: 'deviceType',
customRender: ({ record }) => {
const color = 'success';
const text = t(`enum.deviceType.${record.deviceType}`);
return h(Tag, { color: color }, () => text);
},
},
{
title: t('edge.instance.text.createTime'),
width: 120,
dataIndex: 'createdTime',
format: (_text: string, record: Recordable) => {
return transformTime(record.createdTime);
},
},
];
// 表格查询表单
export const searchFormSchema: FormSchema[] = [
{
field: 'textSearch',
label: t('edge.instance.search.deviceName'),
component: 'Input',
colProps: { span: 6 },
componentProps: {
maxLength: 255,
placeholder: t('edge.instance.search.deviceNamePlaceholder'),
},
},
];