config.ts
3.03 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
import { BasicColumn, FormSchema } from '/@/components/Table';
import { findDictItemByCode } from '/@/api/system/dict';
import { h, unref } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { FunctionTypeEnum } from '/@/enums/objectModelEnum';
import { useMessage } from '/@/hooks/web/useMessage';
import { useClipboard } from '@vueuse/core';
import { DictEnum } from '/@/enums/dictEnum';
import { useI18n } from '/@/hooks/web/useI18n';
// import {
// EventType,
// EventTypeColor,
// EventTypeName,
// } from '/@/views/device/list/cpns/tabs/EventManage/config';
const { t } = useI18n();
export const columns: BasicColumn[] = [
{
title: t('deviceManagement.product.categoryName'),
dataIndex: 'name',
slots: { customRender: 'name' },
},
{
title: t('deviceManagement.product.area'),
dataIndex: 'dictItemName',
format: (text: string) => {
return t(text);
},
},
];
export const formatFunctionType: Record<FunctionTypeEnum, string> = {
[FunctionTypeEnum.PROPERTIES]: t('deviceManagement.product.properties'),
[FunctionTypeEnum.EVENTS]: t('deviceManagement.product.events'),
[FunctionTypeEnum.SERVICE]: t('deviceManagement.product.services'),
};
const handleCopy = async (value: string) => {
const { createMessage } = useMessage();
const { copied, copy } = useClipboard({ legacy: true });
const { t } = useI18n();
await copy(value);
if (unref(copied)) createMessage.success(t('common.copyOk'));
else createMessage.success(t('common.copyFail'));
};
export const columnsDrawer: BasicColumn[] = [
{
title: t('deviceManagement.product.featureTypeText'),
dataIndex: 'functionType',
width: 90,
format: (text: FunctionTypeEnum) => {
return formatFunctionType[text];
},
},
{
title: t('deviceManagement.product.featureNameText'),
dataIndex: 'functionName',
width: 90,
ellipsis: true,
},
{
title: t('deviceManagement.product.identifierText'),
dataIndex: 'identifier',
width: 90,
ellipsis: true,
customRender: ({ text }: Record<'text', string>) => {
return h(Tooltip, { title: text }, () =>
h('span', { class: 'cursor-pointer', onClick: () => handleCopy(text) }, text)
);
},
},
{
title: t('deviceManagement.product.dataTypeText'),
dataIndex: 'functionJson.dataType.type',
width: 100,
format: (text: string) => {
return text || '--';
},
ellipsis: true,
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'dictItemId',
label: '',
component: 'ApiSelect',
colProps: { span: 7 },
componentProps() {
return {
api: findDictItemByCode,
params: {
dictCode: DictEnum.CATEGORY_FIELD,
},
labelField: 'itemText',
valueField: 'itemValue',
placeholder: t('deviceManagement.product.pleaseSelectArea'),
};
},
},
{
field: 'name',
label: '',
component: 'Input',
colProps: { span: 9 },
componentProps: {
placeholder: t('deviceManagement.product.pleaseEnterCategoryName'),
},
},
];