ronds-metadata 1.0.37 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.d.ts +6 -0
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +237 -0
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.d.ts +12 -0
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +367 -0
- package/es/comps/MetadataEditV2/constant/index.d.ts +24 -0
- package/es/comps/MetadataEditV2/constant/index.js +69 -0
- package/es/comps/MetadataEditV2/hooks/index.d.ts +4 -0
- package/es/comps/MetadataEditV2/hooks/index.js +46 -0
- package/es/comps/MetadataEditV2/index.css +11 -0
- package/es/comps/MetadataEditV2/index.d.ts +25 -0
- package/es/comps/MetadataEditV2/index.js +303 -0
- package/es/comps/MetadataEditV2/type.d.ts +20 -0
- package/es/framework/http/cache.js +3 -2
- package/es/framework/http/index.js +2 -2
- package/es/framework/metadata/index.js +2 -2
- package/es/framework/metadata/types.d.ts +87 -87
- package/es/index.d.ts +1 -0
- package/es/index.js +3 -2
- package/package.json +72 -73
package/README.md
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# ronds-metadata
|
2
|
-
|
3
|
-
# 使用前准备
|
4
|
-
|
5
|
-
在使用之前,推荐学习[容知的元数据规则](http://172.16.0.8:5000/oo/r/634418027609242111)
|
6
|
-
|
7
|
-
# 安装及使用
|
8
|
-
|
9
|
-
## 安装
|
10
|
-
|
11
|
-
```
|
12
|
-
yarn add ronds-metadata
|
13
|
-
```
|
14
|
-
|
15
|
-
## 使用
|
16
|
-
|
17
|
-
### 引入所需组件
|
18
|
-
|
19
|
-
在代码中 import 需要的组件并按照文档说明使用
|
20
|
-
|
21
|
-
```
|
22
|
-
import { MetadataFrom, MetadataEdit, JsonView, JsonEdit } from 'ronds-metadata';
|
23
|
-
|
24
|
-
import { JsonMetadataProvider } from 'ronds-metadata/es/framework/metadata/index';
|
25
|
-
```
|
1
|
+
# ronds-metadata
|
2
|
+
|
3
|
+
# 使用前准备
|
4
|
+
|
5
|
+
在使用之前,推荐学习[容知的元数据规则](http://172.16.0.8:5000/oo/r/634418027609242111)
|
6
|
+
|
7
|
+
# 安装及使用
|
8
|
+
|
9
|
+
## 安装
|
10
|
+
|
11
|
+
```
|
12
|
+
yarn add ronds-metadata
|
13
|
+
```
|
14
|
+
|
15
|
+
## 使用
|
16
|
+
|
17
|
+
### 引入所需组件
|
18
|
+
|
19
|
+
在代码中 import 需要的组件并按照文档说明使用
|
20
|
+
|
21
|
+
```
|
22
|
+
import { MetadataFrom, MetadataEdit, JsonView, JsonEdit } from 'ronds-metadata';
|
23
|
+
|
24
|
+
import { JsonMetadataProvider } from 'ronds-metadata/es/framework/metadata/index';
|
25
|
+
```
|
@@ -0,0 +1,237 @@
|
|
1
|
+
import "antd/es/button/style";
|
2
|
+
import _Button from "antd/es/button";
|
3
|
+
import "antd/es/switch/style";
|
4
|
+
import _Switch from "antd/es/switch";
|
5
|
+
import "antd/es/input-number/style";
|
6
|
+
import _InputNumber from "antd/es/input-number";
|
7
|
+
import "antd/es/select/style";
|
8
|
+
import _Select from "antd/es/select";
|
9
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
10
|
+
import "antd/es/input/style";
|
11
|
+
import _Input from "antd/es/input";
|
12
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
13
|
+
import "antd/es/form/style";
|
14
|
+
import _Form from "antd/es/form";
|
15
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
16
|
+
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
17
|
+
import React from 'react';
|
18
|
+
import { RULE_TYPES_OPTIONS } from '../constant';
|
19
|
+
import { useMetaType } from '../hooks';
|
20
|
+
import MetadataForm from '../../MetadataForm';
|
21
|
+
|
22
|
+
var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
23
|
+
var defaultValues = props.defaultValues,
|
24
|
+
onChange = props.onChange;
|
25
|
+
|
26
|
+
var _Form$useForm = _Form.useForm(),
|
27
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
28
|
+
form = _Form$useForm2[0];
|
29
|
+
|
30
|
+
var _React$useState = React.useState({}),
|
31
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
32
|
+
ruleTypes = _React$useState2[0],
|
33
|
+
setRuleTypes = _React$useState2[1];
|
34
|
+
|
35
|
+
var _React$useState3 = React.useState({}),
|
36
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
37
|
+
refIds = _React$useState4[0],
|
38
|
+
setRefIds = _React$useState4[1];
|
39
|
+
|
40
|
+
var _React$useState5 = React.useState({}),
|
41
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
42
|
+
refValues = _React$useState6[0],
|
43
|
+
setRefValues = _React$useState6[1];
|
44
|
+
|
45
|
+
var metaType = useMetaType('扩展规则');
|
46
|
+
React.useEffect(function () {
|
47
|
+
if (defaultValues) {
|
48
|
+
// console.log('defaultValues', defaultValues);
|
49
|
+
form.setFieldsValue({
|
50
|
+
fields: defaultValues
|
51
|
+
});
|
52
|
+
var _ruleTypes = ruleTypes;
|
53
|
+
var _refIds = refIds;
|
54
|
+
|
55
|
+
for (var i = 0; i < defaultValues.length; i++) {
|
56
|
+
_ruleTypes[i] = defaultValues[i].type;
|
57
|
+
|
58
|
+
if (defaultValues[i].type === 'ref') {
|
59
|
+
_refIds[i] = defaultValues[i].refId;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
setRefIds(_objectSpread({}, _refIds));
|
64
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
65
|
+
}
|
66
|
+
}, [defaultValues, form]);
|
67
|
+
|
68
|
+
var onFinish = function onFinish(values) {
|
69
|
+
var _fields = values.fields;
|
70
|
+
|
71
|
+
for (var i = 0; i < _fields.length; i++) {
|
72
|
+
if (_fields[i].type === 'ref') {
|
73
|
+
_fields[i].value = refValues[i] || _fields[i].value;
|
74
|
+
}
|
75
|
+
} // console.log('_fields', _fields);
|
76
|
+
|
77
|
+
|
78
|
+
onChange && onChange(_fields);
|
79
|
+
};
|
80
|
+
|
81
|
+
var onRefRulesValuesChange = function onRefRulesValuesChange(values, idx) {
|
82
|
+
// console.log('onRefRulesValuesChange', values, refValues);
|
83
|
+
var _refValues = refValues;
|
84
|
+
_refValues[idx] = _refValues[idx] ? _objectSpread(_objectSpread({}, _refValues[idx]), values) : _objectSpread({}, values);
|
85
|
+
setRefValues(_objectSpread({}, _refValues));
|
86
|
+
};
|
87
|
+
|
88
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form, {
|
89
|
+
className: "metadata-edit",
|
90
|
+
style: {
|
91
|
+
position: 'relative'
|
92
|
+
},
|
93
|
+
form: form,
|
94
|
+
name: "control-hooks",
|
95
|
+
onFinish: onFinish
|
96
|
+
}, /*#__PURE__*/React.createElement("div", {
|
97
|
+
style: {
|
98
|
+
padding: '10px'
|
99
|
+
}
|
100
|
+
}, /*#__PURE__*/React.createElement(_Form.List, {
|
101
|
+
name: "fields"
|
102
|
+
}, function (fields, _ref) {
|
103
|
+
var add = _ref.add,
|
104
|
+
remove = _ref.remove;
|
105
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, index) {
|
106
|
+
var _defaultValues$index;
|
107
|
+
|
108
|
+
// console.log('fields=========', fields);
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
110
|
+
key: field.key
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
112
|
+
style: {
|
113
|
+
display: 'flex',
|
114
|
+
alignItems: 'flex-start'
|
115
|
+
}
|
116
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, _extends({
|
117
|
+
className: "pr-10"
|
118
|
+
}, field, {
|
119
|
+
label: "\u89C4\u5219\u540D\u79F0",
|
120
|
+
name: [field.name, 'id'],
|
121
|
+
fieldKey: [field.fieldKey, 'id'],
|
122
|
+
rules: [{
|
123
|
+
required: true
|
124
|
+
}]
|
125
|
+
}), /*#__PURE__*/React.createElement(_Input, {
|
126
|
+
style: {
|
127
|
+
width: '120px'
|
128
|
+
}
|
129
|
+
})), /*#__PURE__*/React.createElement(_Form.Item, _extends({
|
130
|
+
className: "pr-10"
|
131
|
+
}, field, {
|
132
|
+
label: "\u89C4\u5219\u7C7B\u578B",
|
133
|
+
name: [field.name, 'type'],
|
134
|
+
fieldKey: [field.fieldKey, 'type'],
|
135
|
+
rules: [{
|
136
|
+
required: true
|
137
|
+
}]
|
138
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
139
|
+
style: {
|
140
|
+
width: '120px'
|
141
|
+
},
|
142
|
+
onChange: function onChange(value) {
|
143
|
+
var _ruleTypes = ruleTypes;
|
144
|
+
_ruleTypes[index] = value;
|
145
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
146
|
+
},
|
147
|
+
options: RULE_TYPES_OPTIONS
|
148
|
+
})), ruleTypes[index] === 'text' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
149
|
+
label: "\u89C4\u5219\u503C",
|
150
|
+
name: [field.name, 'value'],
|
151
|
+
fieldKey: [field.fieldKey, 'value'],
|
152
|
+
rules: [{
|
153
|
+
required: true
|
154
|
+
}]
|
155
|
+
}), /*#__PURE__*/React.createElement(_Input, {
|
156
|
+
style: {
|
157
|
+
width: '120px'
|
158
|
+
}
|
159
|
+
})), ruleTypes[index] === 'number' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
160
|
+
label: "\u89C4\u5219\u503C",
|
161
|
+
name: [field.name, 'value'],
|
162
|
+
fieldKey: [field.fieldKey, 'value'],
|
163
|
+
rules: [{
|
164
|
+
required: true
|
165
|
+
}]
|
166
|
+
}), /*#__PURE__*/React.createElement(_InputNumber, {
|
167
|
+
style: {
|
168
|
+
width: '120px'
|
169
|
+
}
|
170
|
+
})), ruleTypes[index] === 'bool' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
171
|
+
label: "\u89C4\u5219\u503C",
|
172
|
+
name: [field.name, 'value'],
|
173
|
+
fieldKey: [field.fieldKey, 'value'],
|
174
|
+
rules: [{
|
175
|
+
required: true
|
176
|
+
}]
|
177
|
+
}), /*#__PURE__*/React.createElement(_Switch, null)), ruleTypes[index] === 'ref' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
178
|
+
label: "Ref",
|
179
|
+
name: [field.name, 'refId'],
|
180
|
+
fieldKey: [field.fieldKey, 'refId'],
|
181
|
+
rules: [{
|
182
|
+
required: true
|
183
|
+
}]
|
184
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
185
|
+
style: {
|
186
|
+
width: '120px'
|
187
|
+
},
|
188
|
+
onChange: function onChange(value) {
|
189
|
+
var _refIds = refIds;
|
190
|
+
_refIds[index] = value;
|
191
|
+
setRefIds(_objectSpread({}, _refIds));
|
192
|
+
var newData = form.getFieldValue('fields'); // console.log('newData', newData);
|
193
|
+
|
194
|
+
newData[index].id = value;
|
195
|
+
form.setFieldsValue({
|
196
|
+
fields: newData
|
197
|
+
});
|
198
|
+
},
|
199
|
+
options: metaType || []
|
200
|
+
})), /*#__PURE__*/React.createElement("div", {
|
201
|
+
style: {
|
202
|
+
lineHeight: '88px',
|
203
|
+
paddingLeft: '15px'
|
204
|
+
}
|
205
|
+
}, /*#__PURE__*/React.createElement(MinusCircleOutlined, {
|
206
|
+
onClick: function onClick() {
|
207
|
+
return remove(field.name);
|
208
|
+
}
|
209
|
+
}))), refIds[index] && /*#__PURE__*/React.createElement("div", {
|
210
|
+
style: {
|
211
|
+
border: '1px solid #d9d9d9',
|
212
|
+
padding: '10px',
|
213
|
+
marginBottom: '10px'
|
214
|
+
}
|
215
|
+
}, /*#__PURE__*/React.createElement(MetadataForm, {
|
216
|
+
initialValues: defaultValues && defaultValues.length > 0 && ((_defaultValues$index = defaultValues[index]) === null || _defaultValues$index === void 0 ? void 0 : _defaultValues$index.value),
|
217
|
+
refId: refIds[index],
|
218
|
+
onValuesChange: function onValuesChange(values, allValues) {
|
219
|
+
onRefRulesValuesChange(allValues, index);
|
220
|
+
}
|
221
|
+
})));
|
222
|
+
}), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
|
223
|
+
type: "dashed",
|
224
|
+
onClick: function onClick() {
|
225
|
+
return add();
|
226
|
+
},
|
227
|
+
block: true,
|
228
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
229
|
+
}, "\u6DFB\u52A0\u6269\u5C55\u89C4\u5219")));
|
230
|
+
}), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
|
231
|
+
type: "primary",
|
232
|
+
block: true,
|
233
|
+
htmlType: "submit"
|
234
|
+
}, "\u786E\u5B9A")))));
|
235
|
+
};
|
236
|
+
|
237
|
+
export default MetaFieldsEdit;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { FormInstance } from 'antd/lib/form';
|
2
|
+
interface IMetaPropsEditProps {
|
3
|
+
form: FormInstance;
|
4
|
+
id?: string;
|
5
|
+
metadataTag?: string;
|
6
|
+
name: string;
|
7
|
+
isEdit?: boolean;
|
8
|
+
onAddFields?: (idx: number) => void;
|
9
|
+
onNewRefClick?: () => void;
|
10
|
+
}
|
11
|
+
declare const MetaPropsEdit: (props: IMetaPropsEditProps) => JSX.Element;
|
12
|
+
export default MetaPropsEdit;
|
@@ -0,0 +1,367 @@
|
|
1
|
+
import "antd/es/space/style";
|
2
|
+
import _Space from "antd/es/space";
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
4
|
+
import "antd/es/tooltip/style";
|
5
|
+
import _Tooltip from "antd/es/tooltip";
|
6
|
+
import "antd/es/button/style";
|
7
|
+
import _Button from "antd/es/button";
|
8
|
+
import "antd/es/select/style";
|
9
|
+
import _Select from "antd/es/select";
|
10
|
+
import "antd/es/form/style";
|
11
|
+
import _Form from "antd/es/form";
|
12
|
+
import "antd/es/input/style";
|
13
|
+
import _Input from "antd/es/input";
|
14
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
15
|
+
import React from 'react';
|
16
|
+
import { MinusCircleOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons';
|
17
|
+
import { ARRAY_TYPES_OPTIONS, BASIC_TYPES_OPTIONS, NUMBER_FORMAT_OPTIONS } from '../constant';
|
18
|
+
import { useMetaType } from '../hooks'; // import { guid } from '../../../utils';
|
19
|
+
|
20
|
+
import TextArea from "antd/es/input/TextArea";
|
21
|
+
|
22
|
+
var MetaPropsEdit = function MetaPropsEdit(props) {
|
23
|
+
var form = props.form,
|
24
|
+
id = props.id,
|
25
|
+
metadataTag = props.metadataTag,
|
26
|
+
name = props.name,
|
27
|
+
onAddFields = props.onAddFields,
|
28
|
+
onNewRefClick = props.onNewRefClick;
|
29
|
+
|
30
|
+
var _React$useState = React.useState(true),
|
31
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
32
|
+
refresh = _React$useState2[0],
|
33
|
+
setRefresh = _React$useState2[1];
|
34
|
+
|
35
|
+
var metaType = useMetaType(metadataTag, refresh); // console.log('metaType', metaType, id);
|
36
|
+
// 赋值
|
37
|
+
|
38
|
+
var onTypeChange = function onTypeChange(idx) {
|
39
|
+
var _properties = form.getFieldValue('properties'); // console.log('_propertie=========', _properties, idx);
|
40
|
+
|
41
|
+
|
42
|
+
var __properties = {
|
43
|
+
id: _properties[idx].id,
|
44
|
+
type: _properties[idx].type,
|
45
|
+
name: _properties[idx].name,
|
46
|
+
code: _properties[idx].code,
|
47
|
+
desc: _properties[idx].desc
|
48
|
+
};
|
49
|
+
_properties[idx] = __properties;
|
50
|
+
form.setFieldsValue({
|
51
|
+
properties: _properties
|
52
|
+
});
|
53
|
+
};
|
54
|
+
|
55
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form.List, {
|
56
|
+
name: name
|
57
|
+
}, function (fields, _ref) {
|
58
|
+
var add = _ref.add,
|
59
|
+
remove = _ref.remove;
|
60
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, index) {
|
61
|
+
// console.log('field=============', field);
|
62
|
+
return /*#__PURE__*/React.createElement("div", {
|
63
|
+
key: Math.random()
|
64
|
+
}, /*#__PURE__*/React.createElement("div", {
|
65
|
+
key: Math.random(),
|
66
|
+
style: {
|
67
|
+
display: 'flex',
|
68
|
+
alignItems: 'flex-end',
|
69
|
+
flexWrap: 'wrap'
|
70
|
+
}
|
71
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, {
|
72
|
+
className: "pr-10",
|
73
|
+
label: "\u540D\u79F0",
|
74
|
+
name: [field.name, 'name'],
|
75
|
+
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey, 'name'],
|
76
|
+
rules: [{
|
77
|
+
required: true
|
78
|
+
}]
|
79
|
+
}, /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, {
|
80
|
+
className: "pr-10",
|
81
|
+
label: "\u7F16\u7801",
|
82
|
+
name: [field.name, 'code'],
|
83
|
+
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey, 'code'],
|
84
|
+
rules: [{
|
85
|
+
required: true
|
86
|
+
}]
|
87
|
+
}, /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, {
|
88
|
+
className: "pr-10",
|
89
|
+
label: "\u5B57\u6BB5\u540D\u79F0",
|
90
|
+
name: [field === null || field === void 0 ? void 0 : field.name, 'id'],
|
91
|
+
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey, 'id'],
|
92
|
+
rules: [{
|
93
|
+
required: true
|
94
|
+
}]
|
95
|
+
}, /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, {
|
96
|
+
className: "pr-10",
|
97
|
+
label: "\u5B57\u6BB5\u7C7B\u578B",
|
98
|
+
name: [field === null || field === void 0 ? void 0 : field.name, 'type'],
|
99
|
+
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey, 'type'],
|
100
|
+
rules: [{
|
101
|
+
required: true
|
102
|
+
}]
|
103
|
+
}, /*#__PURE__*/React.createElement(_Select, {
|
104
|
+
style: {
|
105
|
+
width: '100%'
|
106
|
+
},
|
107
|
+
options: BASIC_TYPES_OPTIONS,
|
108
|
+
onChange: function onChange() {
|
109
|
+
onTypeChange(index);
|
110
|
+
}
|
111
|
+
})), /*#__PURE__*/React.createElement(_Form.Item, {
|
112
|
+
className: "pr-10",
|
113
|
+
label: "\u63CF\u8FF0",
|
114
|
+
style: {
|
115
|
+
width: '80%'
|
116
|
+
},
|
117
|
+
name: [field.name, 'desc'],
|
118
|
+
fieldKey: [field.fieldKey, 'desc']
|
119
|
+
}, /*#__PURE__*/React.createElement(TextArea, null)), /*#__PURE__*/React.createElement("div", {
|
120
|
+
style: {
|
121
|
+
lineHeight: '88px',
|
122
|
+
paddingLeft: '15px'
|
123
|
+
}
|
124
|
+
}, /*#__PURE__*/React.createElement(MinusCircleOutlined, {
|
125
|
+
onClick: function onClick() {
|
126
|
+
return remove(field.name);
|
127
|
+
}
|
128
|
+
})), onAddFields && /*#__PURE__*/React.createElement(_Form.Item, {
|
129
|
+
style: {
|
130
|
+
flex: 1,
|
131
|
+
textAlign: 'right'
|
132
|
+
}
|
133
|
+
}, /*#__PURE__*/React.createElement(_Tooltip, {
|
134
|
+
title: "\u6DFB\u52A0\u6269\u5C55\u89C4\u5219"
|
135
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
136
|
+
shape: "circle",
|
137
|
+
size: "small",
|
138
|
+
type: "primary",
|
139
|
+
onClick: function onClick() {
|
140
|
+
onAddFields(index);
|
141
|
+
},
|
142
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
143
|
+
})))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Form.Item, {
|
144
|
+
noStyle: true,
|
145
|
+
shouldUpdate: function shouldUpdate(prevValues, currentValues) {
|
146
|
+
var _prevValues$name$inde, _currentValues$name$i, _prevValues$name$inde2, _currentValues$name$i2;
|
147
|
+
|
148
|
+
return (prevValues === null || prevValues === void 0 ? void 0 : (_prevValues$name$inde = prevValues[name][index]) === null || _prevValues$name$inde === void 0 ? void 0 : _prevValues$name$inde.type) !== (currentValues === null || currentValues === void 0 ? void 0 : (_currentValues$name$i = currentValues[name][index]) === null || _currentValues$name$i === void 0 ? void 0 : _currentValues$name$i.type) || (prevValues === null || prevValues === void 0 ? void 0 : (_prevValues$name$inde2 = prevValues[name][index]) === null || _prevValues$name$inde2 === void 0 ? void 0 : _prevValues$name$inde2.items) !== (currentValues === null || currentValues === void 0 ? void 0 : (_currentValues$name$i2 = currentValues[name][index]) === null || _currentValues$name$i2 === void 0 ? void 0 : _currentValues$name$i2.items);
|
149
|
+
}
|
150
|
+
}, function (_ref2) {
|
151
|
+
var _properties$index, _properties$index2, _properties$index2$it, _properties$index3, _properties$index3$it;
|
152
|
+
|
153
|
+
var getFieldValue = _ref2.getFieldValue;
|
154
|
+
|
155
|
+
var _properties = getFieldValue(name);
|
156
|
+
|
157
|
+
switch ((_properties$index = _properties[index]) === null || _properties$index === void 0 ? void 0 : _properties$index.type) {
|
158
|
+
case 'number':
|
159
|
+
return /*#__PURE__*/React.createElement("div", {
|
160
|
+
style: {
|
161
|
+
border: '1px solid #d9d9d9',
|
162
|
+
padding: '10px',
|
163
|
+
marginBottom: '10px'
|
164
|
+
}
|
165
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
166
|
+
label: "format",
|
167
|
+
name: [field.name, 'format'],
|
168
|
+
fieldKey: [field.fieldKey, 'format'],
|
169
|
+
rules: [{
|
170
|
+
required: true
|
171
|
+
}]
|
172
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
173
|
+
style: {
|
174
|
+
width: '180px'
|
175
|
+
},
|
176
|
+
options: NUMBER_FORMAT_OPTIONS
|
177
|
+
})));
|
178
|
+
|
179
|
+
case 'ref':
|
180
|
+
return /*#__PURE__*/React.createElement("div", {
|
181
|
+
style: {
|
182
|
+
border: '1px solid #d9d9d9',
|
183
|
+
padding: '10px',
|
184
|
+
display: 'flex',
|
185
|
+
alignItems: 'center',
|
186
|
+
marginBottom: '10px'
|
187
|
+
}
|
188
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
189
|
+
label: "Ref",
|
190
|
+
name: [field.name, 'refId'],
|
191
|
+
fieldKey: [field.fieldKey, 'refId'],
|
192
|
+
rules: [{
|
193
|
+
required: true
|
194
|
+
}]
|
195
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
196
|
+
style: {
|
197
|
+
width: '180px'
|
198
|
+
},
|
199
|
+
options: metaType || []
|
200
|
+
})), /*#__PURE__*/React.createElement("div", {
|
201
|
+
style: {
|
202
|
+
padding: '0 10px'
|
203
|
+
}
|
204
|
+
}, /*#__PURE__*/React.createElement(_Tooltip, {
|
205
|
+
title: "\u6DFB\u52A0\u5F15\u7528\u7C7B\u578B"
|
206
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
207
|
+
shape: "circle",
|
208
|
+
size: "small",
|
209
|
+
type: "primary",
|
210
|
+
onClick: function onClick() {
|
211
|
+
onNewRefClick && onNewRefClick();
|
212
|
+
},
|
213
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
214
|
+
})), /*#__PURE__*/React.createElement(_Tooltip, {
|
215
|
+
title: "\u5237\u65B0"
|
216
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
217
|
+
shape: "circle",
|
218
|
+
size: "small",
|
219
|
+
style: {
|
220
|
+
marginLeft: '10px'
|
221
|
+
},
|
222
|
+
onClick: function onClick() {
|
223
|
+
setRefresh(false);
|
224
|
+
setTimeout(function () {
|
225
|
+
setRefresh(true);
|
226
|
+
}, 100);
|
227
|
+
},
|
228
|
+
icon: /*#__PURE__*/React.createElement(ReloadOutlined, null)
|
229
|
+
}))));
|
230
|
+
|
231
|
+
case 'array':
|
232
|
+
return /*#__PURE__*/React.createElement("div", {
|
233
|
+
style: {
|
234
|
+
border: '1px solid #d9d9d9',
|
235
|
+
borderRadius: '5px',
|
236
|
+
padding: '10px',
|
237
|
+
marginBottom: '10px',
|
238
|
+
display: 'flex',
|
239
|
+
alignItems: 'center'
|
240
|
+
}
|
241
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
242
|
+
label: "Array",
|
243
|
+
className: "pr-10",
|
244
|
+
name: [field.name, 'items', 'type'],
|
245
|
+
fieldKey: [field.fieldKey, 'items', 'type'],
|
246
|
+
rules: [{
|
247
|
+
required: true
|
248
|
+
}]
|
249
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
250
|
+
style: {
|
251
|
+
width: '180px'
|
252
|
+
},
|
253
|
+
options: ARRAY_TYPES_OPTIONS
|
254
|
+
})), _properties && ((_properties$index2 = _properties[index]) === null || _properties$index2 === void 0 ? void 0 : (_properties$index2$it = _properties$index2.items) === null || _properties$index2$it === void 0 ? void 0 : _properties$index2$it.type) === 'ref' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
255
|
+
label: "Ref",
|
256
|
+
name: [field.name, 'items', 'refId'],
|
257
|
+
fieldKey: [field.fieldKey, 'items', 'refId'],
|
258
|
+
rules: [{
|
259
|
+
required: true
|
260
|
+
}]
|
261
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
262
|
+
style: {
|
263
|
+
width: '180px'
|
264
|
+
},
|
265
|
+
options: metaType || []
|
266
|
+
})), /*#__PURE__*/React.createElement("div", {
|
267
|
+
style: {
|
268
|
+
padding: '0 10px'
|
269
|
+
}
|
270
|
+
}, /*#__PURE__*/React.createElement(_Tooltip, {
|
271
|
+
title: "\u6DFB\u52A0\u5F15\u7528\u7C7B\u578B"
|
272
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
273
|
+
shape: "circle",
|
274
|
+
size: "small",
|
275
|
+
type: "primary",
|
276
|
+
onClick: function onClick() {
|
277
|
+
onNewRefClick && onNewRefClick();
|
278
|
+
},
|
279
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
280
|
+
})), /*#__PURE__*/React.createElement(_Tooltip, {
|
281
|
+
title: "\u5237\u65B0"
|
282
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
283
|
+
shape: "circle",
|
284
|
+
size: "small",
|
285
|
+
style: {
|
286
|
+
marginLeft: '10px'
|
287
|
+
},
|
288
|
+
onClick: function onClick() {
|
289
|
+
setRefresh(false);
|
290
|
+
setTimeout(function () {
|
291
|
+
setRefresh(true);
|
292
|
+
}, 100);
|
293
|
+
},
|
294
|
+
icon: /*#__PURE__*/React.createElement(ReloadOutlined, null)
|
295
|
+
})))), _properties && ((_properties$index3 = _properties[index]) === null || _properties$index3 === void 0 ? void 0 : (_properties$index3$it = _properties$index3.items) === null || _properties$index3$it === void 0 ? void 0 : _properties$index3$it.type) === 'number' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
296
|
+
label: "format",
|
297
|
+
name: [field.name, 'items', 'format'],
|
298
|
+
fieldKey: [field.fieldKey, 'items', 'format'],
|
299
|
+
rules: [{
|
300
|
+
required: true
|
301
|
+
}]
|
302
|
+
}), /*#__PURE__*/React.createElement(_Select, {
|
303
|
+
style: {
|
304
|
+
width: '180px'
|
305
|
+
},
|
306
|
+
options: NUMBER_FORMAT_OPTIONS
|
307
|
+
}))));
|
308
|
+
|
309
|
+
case 'enum':
|
310
|
+
return /*#__PURE__*/React.createElement("div", {
|
311
|
+
style: {
|
312
|
+
border: '1px solid #d9d9d9',
|
313
|
+
padding: '10px',
|
314
|
+
marginBottom: '10px'
|
315
|
+
}
|
316
|
+
}, /*#__PURE__*/React.createElement(_Form.List, {
|
317
|
+
name: [field.name, 'enum']
|
318
|
+
}, function (enumFields, operation) {
|
319
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, enumFields.map(function (enumField) {
|
320
|
+
return /*#__PURE__*/React.createElement(_Space, {
|
321
|
+
key: "enumField-".concat(enumField.key),
|
322
|
+
align: "baseline"
|
323
|
+
}, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
324
|
+
className: "pr-10",
|
325
|
+
label: "Enum",
|
326
|
+
name: [enumField.name, 'value'],
|
327
|
+
fieldKey: [enumField.fieldKey, 'value'],
|
328
|
+
rules: [{
|
329
|
+
required: true
|
330
|
+
}]
|
331
|
+
}), /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(MinusCircleOutlined, {
|
332
|
+
onClick: function onClick() {
|
333
|
+
return operation.remove(enumField.name);
|
334
|
+
}
|
335
|
+
}));
|
336
|
+
}), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
|
337
|
+
type: "dashed",
|
338
|
+
onClick: function onClick() {
|
339
|
+
return operation.add();
|
340
|
+
},
|
341
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
342
|
+
}, "\u6DFB\u52A0Enum")));
|
343
|
+
}));
|
344
|
+
|
345
|
+
default:
|
346
|
+
return null;
|
347
|
+
}
|
348
|
+
})));
|
349
|
+
}), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
|
350
|
+
type: "dashed",
|
351
|
+
onClick: function onClick() {
|
352
|
+
return add();
|
353
|
+
},
|
354
|
+
block: true,
|
355
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
356
|
+
}, "\u6DFB\u52A0".concat(name, "\u540D\u79F0"))), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
|
357
|
+
type: "dashed",
|
358
|
+
onClick: function onClick() {
|
359
|
+
onAddFields(-1);
|
360
|
+
},
|
361
|
+
block: true,
|
362
|
+
icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
|
363
|
+
}, "\u6DFB\u52A0\u6269\u5C55\u89C4\u5219")));
|
364
|
+
}));
|
365
|
+
};
|
366
|
+
|
367
|
+
export default MetaPropsEdit;
|