ronds-metadata 1.0.36 → 1.0.39

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.
@@ -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;
@@ -0,0 +1,24 @@
1
+ export declare const BASIC_TYPES_OPTIONS: {
2
+ label: string;
3
+ value: string;
4
+ }[];
5
+ export declare const ARRAY_TYPES_OPTIONS: {
6
+ label: string;
7
+ value: string;
8
+ }[];
9
+ export declare const OUTERMOST_TYPES_OPTIONS: {
10
+ label: string;
11
+ value: string;
12
+ }[];
13
+ export declare const RULE_TYPES_OPTIONS: {
14
+ label: string;
15
+ value: string;
16
+ }[];
17
+ export declare const NUMBER_FORMAT_OPTIONS: {
18
+ label: string;
19
+ value: string;
20
+ }[];
21
+ export declare const REF_OPTIONS: {
22
+ label: string;
23
+ value: string;
24
+ }[];
@@ -0,0 +1,69 @@
1
+ export var BASIC_TYPES_OPTIONS = [{
2
+ label: '数字',
3
+ value: 'number'
4
+ }, {
5
+ label: '文本',
6
+ value: 'text'
7
+ }, {
8
+ label: '布尔类型',
9
+ value: 'bool'
10
+ }, {
11
+ label: '枚举类型',
12
+ value: 'enum'
13
+ }, {
14
+ label: '数组',
15
+ value: 'array'
16
+ }, {
17
+ label: '引用类型',
18
+ value: 'ref'
19
+ }];
20
+ export var ARRAY_TYPES_OPTIONS = [{
21
+ label: '数字',
22
+ value: 'number'
23
+ }, {
24
+ label: '文本',
25
+ value: 'text'
26
+ }, {
27
+ label: '布尔类型',
28
+ value: 'bool'
29
+ }, {
30
+ label: '引用类型',
31
+ value: 'ref'
32
+ }];
33
+ export var OUTERMOST_TYPES_OPTIONS = [{
34
+ label: '对象',
35
+ value: 'object'
36
+ }, {
37
+ label: '数字',
38
+ value: 'number'
39
+ }, {
40
+ label: '文本',
41
+ value: 'text'
42
+ }, {
43
+ label: '布尔类型',
44
+ value: 'bool'
45
+ }];
46
+ export var RULE_TYPES_OPTIONS = [{
47
+ label: '引用',
48
+ value: 'ref'
49
+ }, {
50
+ label: '数字',
51
+ value: 'number'
52
+ }, {
53
+ label: '文本',
54
+ value: 'text'
55
+ }, {
56
+ label: '布尔类型',
57
+ value: 'bool'
58
+ }];
59
+ export var NUMBER_FORMAT_OPTIONS = [{
60
+ label: 'int',
61
+ value: 'int'
62
+ }, {
63
+ label: 'double',
64
+ value: 'double'
65
+ }];
66
+ export var REF_OPTIONS = [{
67
+ label: '表单扩展规则',
68
+ value: 'FormRules'
69
+ }];
@@ -0,0 +1,4 @@
1
+ export declare const useMetaType: (tag?: string, isFresh?: boolean) => {
2
+ label: string;
3
+ value: string;
4
+ }[];
@@ -0,0 +1,46 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+
3
+ /*
4
+ * @Author: your name
5
+ * @Date: 2022-03-03 16:12:34
6
+ * @LastEditTime: 2022-03-07 10:55:07
7
+ * @LastEditors: your name
8
+ * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
9
+ * @FilePath: \MetaData\src\comps\MetadataEditV2\hooks\index.ts
10
+ */
11
+ import { MetadataService } from './../../../framework/metadata/MetadataService';
12
+ import React from 'react';
13
+ export var useMetaType = function useMetaType(tag) {
14
+ var isFresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
15
+
16
+ var _React$useState = React.useState([]),
17
+ _React$useState2 = _slicedToArray(_React$useState, 2),
18
+ metaType = _React$useState2[0],
19
+ setMetaType = _React$useState2[1];
20
+
21
+ React.useEffect(function () {
22
+ if (isFresh) {
23
+ var service = new MetadataService();
24
+
25
+ var _tag = tag ? [tag] : [];
26
+
27
+ service.GetMetadataList(_tag).then(function (res) {
28
+ var _metaType = []; // console.log('res', res);
29
+
30
+ if (res) {
31
+ for (var i = 0; i < res.length; i++) {
32
+ var obj = {
33
+ label: res[i].name,
34
+ value: res[i].id
35
+ };
36
+
37
+ _metaType.push(obj);
38
+ }
39
+ }
40
+
41
+ setMetaType([].concat(_metaType));
42
+ });
43
+ }
44
+ }, [tag, isFresh]);
45
+ return metaType;
46
+ };
@@ -0,0 +1,11 @@
1
+ .metadata-edit {
2
+ height: 100%;
3
+ width: 100%;
4
+ }
5
+ .metadata-edit .ant-row {
6
+ display: block;
7
+ }
8
+ .metadata-edit .pr-10 {
9
+ padding-right: 10px;
10
+ width: 50%;
11
+ }
@@ -0,0 +1,25 @@
1
+ import './index.less';
2
+ interface IMetadataEditProps {
3
+ /**
4
+ * 默认元数据最外层的名称无法编辑
5
+ */
6
+ isNameDisabled?: boolean;
7
+ /**
8
+ * 元数据的标签,根据这个标签在元数据库里检索元数据
9
+ */
10
+ metadataTag?: string;
11
+ /**
12
+ * 初始化值
13
+ */
14
+ initialValues?: any;
15
+ /**
16
+ * 确定点击事件
17
+ */
18
+ onFinish: (data: string) => void;
19
+ /**
20
+ * 添加新的引用类型点击事件
21
+ */
22
+ onNewRefClick?: () => void;
23
+ }
24
+ declare const MetadataEditV2: (props: IMetadataEditProps) => JSX.Element;
25
+ export default MetadataEditV2;