|
@@ -2,7 +2,7 @@ import { Button, Drawer, Dropdown, Menu, message } from 'antd';
|
|
|
import { createSchemaField, observer } from '@formily/react';
|
|
import { createSchemaField, observer } from '@formily/react';
|
|
|
import MetadataModel from '../model';
|
|
import MetadataModel from '../model';
|
|
|
import type { Field, IFieldState } from '@formily/core';
|
|
import type { Field, IFieldState } from '@formily/core';
|
|
|
-import { createForm } from '@formily/core';
|
|
|
|
|
|
|
+import { createForm, registerValidateRules } from '@formily/core';
|
|
|
import {
|
|
import {
|
|
|
ArrayItems,
|
|
ArrayItems,
|
|
|
Editable,
|
|
Editable,
|
|
@@ -133,6 +133,13 @@ const Edit = observer((props: Props) => {
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ registerValidateRules({
|
|
|
|
|
+ validateId(value) {
|
|
|
|
|
+ if (!value) return '';
|
|
|
|
|
+ const reg = new RegExp('^\\w{3,20}$');
|
|
|
|
|
+ return reg.exec(value) ? '' : 'ID只能由数字、26个英文字母或者下划线组成';
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
const valueTypeConfig = {
|
|
const valueTypeConfig = {
|
|
|
type: 'object',
|
|
type: 'object',
|
|
|
'x-index': 4,
|
|
'x-index': 4,
|
|
@@ -142,7 +149,16 @@ const Edit = observer((props: Props) => {
|
|
|
required: true,
|
|
required: true,
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
- enum: DataTypeList,
|
|
|
|
|
|
|
+ default: MetadataModel.type === 'events' ? 'object' : null,
|
|
|
|
|
+ enum:
|
|
|
|
|
+ MetadataModel.type === 'events'
|
|
|
|
|
+ ? [
|
|
|
|
|
+ {
|
|
|
|
|
+ value: 'object',
|
|
|
|
|
+ label: 'object(结构体)',
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ : DataTypeList,
|
|
|
},
|
|
},
|
|
|
unit: {
|
|
unit: {
|
|
|
title: intl.formatMessage({
|
|
title: intl.formatMessage({
|
|
@@ -152,6 +168,12 @@ const Edit = observer((props: Props) => {
|
|
|
'x-decorator': 'FormItem',
|
|
'x-decorator': 'FormItem',
|
|
|
'x-component': 'Select',
|
|
'x-component': 'Select',
|
|
|
'x-visible': false,
|
|
'x-visible': false,
|
|
|
|
|
+ 'x-component-props': {
|
|
|
|
|
+ showSearch: true,
|
|
|
|
|
+ showArrow: true,
|
|
|
|
|
+ filterOption: (input: string, option: any) =>
|
|
|
|
|
+ option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
|
|
|
+ },
|
|
|
'x-reactions': [
|
|
'x-reactions': [
|
|
|
{
|
|
{
|
|
|
dependencies: ['.type'],
|
|
dependencies: ['.type'],
|
|
@@ -329,7 +351,11 @@ const Edit = observer((props: Props) => {
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
required: true,
|
|
required: true,
|
|
|
- message: '请输入ID',
|
|
|
|
|
|
|
+ message: '请输入标识',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ validateId: true,
|
|
|
|
|
+ message: 'ID只能由数字、26个英文字母或者下划线组成',
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
|
},
|
|
},
|
|
@@ -764,6 +790,7 @@ const Edit = observer((props: Props) => {
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<Drawer
|
|
<Drawer
|
|
|
|
|
+ maskClosable={false}
|
|
|
width="25vw"
|
|
width="25vw"
|
|
|
visible
|
|
visible
|
|
|
title={`${intl.formatMessage({
|
|
title={`${intl.formatMessage({
|