ledger.data.ts
5.45 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import { formatToDate } from '/@/utils/dateUtil';
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { DeviceRecord } from '/@/api/device/model/deviceModel';
// import { deviceProfile } from '/@/api/device/deviceManager';
import { h } from 'vue';
import { Tag, Tooltip } from 'ant-design-vue';
import { handeleCopy } from '../../../device/profiles/step/topic';
import { useI18n } from '/@/hooks/web/useI18n';
import { DeviceStatusEnum, DeviceTypeEnum } from '/@/enums/deviceEnum';
const { t } = useI18n();
import edgefornt from '/@/assets/icons/edgefornt.svg';
export enum DeviceListAuthEnum {
/**
* @description 新增
*/
CREATE = 'api:yt:device:post',
/**
* @description 删除
*/
DELETE = 'api:yt:device:delete',
/**
* @description 编辑
*/
UPDATE = 'api:yt:device:update',
/**
* @description 详情
*/
DETAIL = 'api:yt:device:get',
/**
* @description 导入
*/
IMPORT = 'api:yt:device:import',
/**
* @description 公开
*/
PUBLIC = 'api:yt:device:public',
/**
* @description 上下线
*/
ONLINE = 'api:yt:device:online:record',
/**
* @description 管理设备凭证
*/
EQUIPMENT = 'api:yt:device:equipment',
/**
* @description 分配客户
*/
ASSIGN = 'api:yt:device:assign',
/**
* @description 命令下发
*/
RPC = 'api:yt:device:rpc',
/**
* @description 更新产品
*/
UPDATE_PRODUCT = 'api:yt:device:update:product',
}
// 表格列数据
export const columns: BasicColumn[] = [
{
title: t('business.deviceStatusText'),
dataIndex: 'deviceState',
width: 110,
className: 'device-status',
slots: { customRender: 'deviceState' },
},
{
title: t('business.deviceImageText'),
dataIndex: 'deviceInfo.avatar',
width: 70,
slots: { customRender: 'img' },
},
{
dataIndex: 'name',
title: t('deviceManagement.device.aliasNameText'),
width: 210,
slots: { customRender: 'name', title: 'deviceTitle' },
className: 'device-name-edge',
customRender: ({ record }) => {
return h('div', { class: 'py-3 px-3.5' }, [
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}`
)
),
record.isEdge
? h('div', { class: 'absolute top-0 left-0', fill: '#1890ff' }, [
h('img', { src: edgefornt, class: 'w-12.5 h-12.5' }),
h(
'span',
{
class:
'absolute top-0.5 left-0.5 text-light-50 transform -rotate-45 translate-y-0 !text-10px',
},
t('common.edgeFlag')
),
])
: '',
]);
},
},
{
title: t('business.deviceTypeText'),
dataIndex: 'deviceType',
width: 130,
customRender({ text }) {
return h(Tag, { color: 'success' }, () => t(`enum.deviceType.${text}`));
},
},
{
title: t('business.affiliatedProductText'),
dataIndex: 'deviceProfile.name',
width: 180,
slots: { customRender: 'deviceProfile' },
ellipsis: true,
},
{
title: t('business.affiliatedOrganizationText'),
dataIndex: 'organizationDTO.name',
width: 100,
},
// {
// title: '客户',
// dataIndex: 'customerName',
// width: 100,
// },
{
title: t('business.publicText'),
dataIndex: 'public',
width: 100,
customRender({ record }: { record: DeviceRecord }) {
const flag = record?.customerAdditionalInfo?.isPublic;
return h(Tag, { color: flag ? 'blue' : 'orange' }, () =>
flag ? t('business.publicText') : t('business.privateText')
);
},
},
{
title: t('deviceManagement.device.lastOnlineTimeText'),
dataIndex: 'lastOnlineTime',
format: (text) => text && formatToDate(text, 'YYYY-MM-DD HH:mm:ss'),
width: 160,
},
{
title: t('deviceManagement.device.lastOfflineTimeText'),
dataIndex: 'lastOfflineTime',
format: (text) => {
return text ? formatToDate(text, 'YYYY-MM-DD HH:mm:ss') : '';
},
width: 160,
},
];
// 查询字段
export const searchFormSchema: FormSchema[] = [
{
field: 'code',
label: t('equipment.ledger.deviceCode'),
component: 'Input',
colProps: { span: 6 },
componentProps: {
maxLength: 255,
},
},
{
field: 'deviceType',
label: t('equipment.ledger.deviceType'),
component: 'Select',
componentProps: {
options: Object.values(DeviceTypeEnum).map((value) => ({
label: t(`enum.deviceType.${value}`),
value,
})),
},
colProps: { span: 6 },
},
{
field: 'deviceState',
label: t('business.deviceStatusText'),
component: 'Select',
componentProps: {
options: Object.values(DeviceStatusEnum).map((value) => ({
label: t(`enum.deviceStatus.${value}`),
value,
})),
},
colProps: { span: 6 },
}
];