|
@@ -2,9 +2,26 @@ import { Drawer } from 'antd';
|
|
|
import { createSchemaField } from '@formily/react';
|
|
import { createSchemaField } from '@formily/react';
|
|
|
import MetadataModel from '@/pages/device/Product/Detail/Metadata/Base/model';
|
|
import MetadataModel from '@/pages/device/Product/Detail/Metadata/Base/model';
|
|
|
import { createForm } from '@formily/core';
|
|
import { createForm } from '@formily/core';
|
|
|
-import { Radio, Select, Form, Input, FormItem, NumberPicker } from '@formily/antd';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ FormLayout,
|
|
|
|
|
+ ArrayItems,
|
|
|
|
|
+ Editable,
|
|
|
|
|
+ Radio,
|
|
|
|
|
+ Select,
|
|
|
|
|
+ Form,
|
|
|
|
|
+ Input,
|
|
|
|
|
+ FormItem,
|
|
|
|
|
+ NumberPicker,
|
|
|
|
|
+ Space,
|
|
|
|
|
+} from '@formily/antd';
|
|
|
import type { ISchema } from '@formily/json-schema';
|
|
import type { ISchema } from '@formily/json-schema';
|
|
|
-import { DataTypeList, EventLevel, PropertySource } from '@/pages/device/data';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ DataTypeList,
|
|
|
|
|
+ DateTypeList,
|
|
|
|
|
+ EventLevel,
|
|
|
|
|
+ FileTypeList,
|
|
|
|
|
+ PropertySource,
|
|
|
|
|
+} from '@/pages/device/data';
|
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
import { useCallback, useEffect, useState } from 'react';
|
|
|
import { service } from '@/pages/device/Product';
|
|
import { service } from '@/pages/device/Product';
|
|
|
import { Store } from 'jetlinks-store';
|
|
import { Store } from 'jetlinks-store';
|
|
@@ -23,6 +40,10 @@ const Edit = () => {
|
|
|
Select,
|
|
Select,
|
|
|
NumberPicker,
|
|
NumberPicker,
|
|
|
Radio,
|
|
Radio,
|
|
|
|
|
+ Editable,
|
|
|
|
|
+ ArrayItems,
|
|
|
|
|
+ Space,
|
|
|
|
|
+ FormLayout,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -43,6 +64,13 @@ const Edit = () => {
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Input',
|
|
'x-component': 'Input',
|
|
|
},
|
|
},
|
|
|
|
|
+ 'expands.source': {
|
|
|
|
|
+ title: '来源',
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Select',
|
|
|
|
|
+ enum: PropertySource,
|
|
|
|
|
+ },
|
|
|
'valueType.type': {
|
|
'valueType.type': {
|
|
|
title: '数据类型',
|
|
title: '数据类型',
|
|
|
required: true,
|
|
required: true,
|
|
@@ -50,16 +78,240 @@ const Edit = () => {
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
enum: DataTypeList,
|
|
enum: DataTypeList,
|
|
|
},
|
|
},
|
|
|
|
|
+ 'expands.maxLength': {
|
|
|
|
|
+ title: '最大长度',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'NumberPicker',
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['string'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ enumConfig: {
|
|
|
|
|
+ title: '枚举项',
|
|
|
|
|
+ type: 'array',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'ArrayItems',
|
|
|
|
|
+ items: {
|
|
|
|
|
+ type: 'object',
|
|
|
|
|
+ 'x-component': 'ArrayItems.Item',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ sort: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'ArrayItems.SortHandle',
|
|
|
|
|
+ },
|
|
|
|
|
+ popover: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ title: '枚举项配置',
|
|
|
|
|
+ 'x-decorator': 'Editable.Popover',
|
|
|
|
|
+ 'x-component': 'FormLayout',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ layout: 'vertical',
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-reactions': [
|
|
|
|
|
+ {
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ schema: {
|
|
|
|
|
+ title: '{{$self.query(".label").value() : $self.query(".value").value() }}',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ label: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ title: 'Label',
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: '标识',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ value: {
|
|
|
|
|
+ type: 'string',
|
|
|
|
|
+ title: 'Value',
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: '对该枚举项的描述',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ remove: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'ArrayItems.Remove',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ addition: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ title: '新增枚举项',
|
|
|
|
|
+ 'x-component': 'ArrayItems.Addition',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['enum'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ trueConfig: {
|
|
|
|
|
+ title: '布尔值',
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
|
|
+ asterisk: true,
|
|
|
|
|
+ feedbackLayout: 'none',
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['boolean'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-component': 'Space',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ 'valueType.elementType.trueText': {
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ default: '是',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: 'trueText',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'valueType.elementType.trueValue': {
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ default: true,
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: 'trueValue',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ falseConfig: {
|
|
|
|
|
+ type: 'void',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
|
|
+ asterisk: true,
|
|
|
|
|
+ feedbackLayout: 'none',
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['boolean'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-component': 'Space',
|
|
|
|
|
+ properties: {
|
|
|
|
|
+ 'valueType.elementType.falseText': {
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ default: '否',
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: 'falseText',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'valueType.elementType.falseValue': {
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Input',
|
|
|
|
|
+ default: false,
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ placeholder: 'falseValue',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'valueType.elementType.format': {
|
|
|
|
|
+ title: '时间格式',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Select',
|
|
|
|
|
+ enum: DateTypeList,
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['date'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
'valueType.scale': {
|
|
'valueType.scale': {
|
|
|
title: '精度',
|
|
title: '精度',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'NumberPicker',
|
|
'x-component': 'NumberPicker',
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['float','double'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'valueType.elementType.fileType': {
|
|
|
|
|
+ title: '文件类型',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'Select',
|
|
|
|
|
+ 'x-visible': false,
|
|
|
|
|
+ enum: FileTypeList,
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['file'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ 'valueType.elementType.expands.maxLength': {
|
|
|
|
|
+ title: '密码长度',
|
|
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
|
|
+ 'x-component': 'NumberPicker',
|
|
|
|
|
+ 'x-decorator-props': {
|
|
|
|
|
+ tooltip: '字节',
|
|
|
|
|
+ },
|
|
|
|
|
+ 'x-visible': false,
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['password'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
'valueType.unit': {
|
|
'valueType.unit': {
|
|
|
title: '单位',
|
|
title: '单位',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
|
|
+ 'x-visible': false,
|
|
|
enum: units,
|
|
enum: units,
|
|
|
|
|
+ 'x-reactions': {
|
|
|
|
|
+ dependencies: ['valueType.type'],
|
|
|
|
|
+ fulfill: {
|
|
|
|
|
+ state: {
|
|
|
|
|
+ visible: "{{['int','float','long','double'].includes($deps[0])}}",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
'expands.readOnly': {
|
|
'expands.readOnly': {
|
|
|
title: '是否只读',
|
|
title: '是否只读',
|
|
@@ -77,13 +329,6 @@ const Edit = () => {
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
|
- 'expands.source': {
|
|
|
|
|
- title: '来源',
|
|
|
|
|
- required: true,
|
|
|
|
|
- 'x-decorator': 'FormItem',
|
|
|
|
|
- 'x-component': 'Select',
|
|
|
|
|
- enum: PropertySource,
|
|
|
|
|
- },
|
|
|
|
|
description: {
|
|
description: {
|
|
|
title: '描述',
|
|
title: '描述',
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|