config.ts
3.27 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
import { BasicColumn, FormSchema } from '/@/components/Table';
import { findDictItemByCode } from '/@/api/system/dict';
import { h, unref } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { FunctionType } from '/@/views/device/profiles/step/cpns/physical/cpns/config';
import { useMessage } from '/@/hooks/web/useMessage';
import { useClipboard } from '@vueuse/core';
import { DictEnum } from '/@/enums/dictEnum';
// import {
// EventType,
// EventTypeColor,
// EventTypeName,
// } from '/@/views/device/list/cpns/tabs/EventManage/config';
export const columns: BasicColumn[] = [
{
title: '品类名称',
dataIndex: 'name',
slots: { customRender: 'name' },
},
{
title: '领域',
dataIndex: 'dictItemName',
},
];
export const formatFunctionType: Record<FunctionType, string> = {
[FunctionType.PROPERTIES]: '属性',
[FunctionType.EVENTS]: '事件',
[FunctionType.SERVICE]: '服务',
};
const handleCopy = async (value: string) => {
const { createMessage } = useMessage();
const { copied, copy } = useClipboard({ legacy: true });
await copy(value);
if (unref(copied)) createMessage.success('复制成功~');
else createMessage.error('复制失败~');
};
export const columnsDrawer: BasicColumn[] = [
{
title: '功能类型',
dataIndex: 'functionType',
width: 90,
format: (text: FunctionType) => {
return formatFunctionType[text];
},
},
{
title: '功能名称',
dataIndex: 'functionName',
width: 90,
ellipsis: true,
},
{
title: '标识符',
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: '数据类型',
dataIndex: 'functionJson.dataType.type',
width: 100,
format: (text: string) => {
return text || '--';
},
ellipsis: true,
},
// {
// title: '事件类型',
// dataIndex: 'eventType',
// customRender({ text }) {
// return h(
// Tag,
// {
// color: EventTypeColor[text as EventType],
// },
// () => EventTypeName[text as EventType]
// );
// },
// ellipsis: true,
// },
// {
// title: '状态',
// dataIndex: 'status',
// width: 100,
// customRender: (value: Record<'text', number>) => {
// const { text } = value;
// return h(
// Tag,
// {
// color: text ? 'green' : 'red',
// },
// () => (text ? '已发布' : '待发布')
// );
// },
// },
];
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: '请选择领域',
// getPopupContainer: () => document.body,
};
},
},
{
field: 'name',
label: '',
component: 'Input',
colProps: { span: 9 },
componentProps: {
placeholder: '请输入品类名称',
},
},
];