ronds-metadata 1.1.59 → 1.1.61
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.
@@ -1,20 +1,21 @@
|
|
1
1
|
import "antd/es/form/style";
|
2
2
|
import _Form from "antd/es/form";
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
4
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
5
4
|
import "antd/es/upload/style";
|
6
5
|
import _Upload from "antd/es/upload";
|
7
6
|
import "antd/es/button/style";
|
8
7
|
import _Button from "antd/es/button";
|
9
8
|
import "antd/es/date-picker/style";
|
10
9
|
import _DatePicker from "antd/es/date-picker";
|
10
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
11
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
12
|
import "antd/es/input/style";
|
12
13
|
import _Input from "antd/es/input";
|
13
14
|
|
14
15
|
/*
|
15
16
|
* @Author: wangxian
|
16
17
|
* @Date: 2021-09-18 14:15:04
|
17
|
-
* @LastEditTime: 2022-
|
18
|
+
* @LastEditTime: 2022-11-22 15:49:53
|
18
19
|
*/
|
19
20
|
import React from 'react';
|
20
21
|
import { UploadOutlined } from '@ant-design/icons';
|
@@ -33,6 +34,26 @@ function Index(props) {
|
|
33
34
|
var formRefContext = React.useContext(MetadataRefContext);
|
34
35
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
35
36
|
|
37
|
+
var _React$useState = React.useState([]),
|
38
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
39
|
+
rules = _React$useState2[0],
|
40
|
+
setRules = _React$useState2[1];
|
41
|
+
|
42
|
+
React.useEffect(function () {
|
43
|
+
var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
|
44
|
+
|
45
|
+
if (_rules) {
|
46
|
+
var _ = _rules.map(function (it) {
|
47
|
+
return {
|
48
|
+
pattern: new RegExp(eval(it === null || it === void 0 ? void 0 : it.regExp), 'g'),
|
49
|
+
message: it.message
|
50
|
+
};
|
51
|
+
});
|
52
|
+
|
53
|
+
setRules(_toConsumableArray(_));
|
54
|
+
}
|
55
|
+
}, [extraInfo]);
|
56
|
+
|
36
57
|
var processInputType = function processInputType(_type) {
|
37
58
|
var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5;
|
38
59
|
|
@@ -92,7 +113,7 @@ function Index(props) {
|
|
92
113
|
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
93
114
|
rules: [{
|
94
115
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
95
|
-
}],
|
116
|
+
}].concat(_toConsumableArray(rules)),
|
96
117
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
97
118
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
98
119
|
}), processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || ''));
|
@@ -108,7 +129,7 @@ function Index(props) {
|
|
108
129
|
name: name,
|
109
130
|
rules: [{
|
110
131
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
111
|
-
}],
|
132
|
+
}].concat(_toConsumableArray(rules)),
|
112
133
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
113
134
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
114
135
|
}, processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || '')) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
@@ -120,7 +141,7 @@ function Index(props) {
|
|
120
141
|
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
121
142
|
rules: [{
|
122
143
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
123
|
-
}],
|
144
|
+
}].concat(_toConsumableArray(rules)),
|
124
145
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
125
146
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
126
147
|
}), processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || ''));
|
@@ -26,7 +26,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
26
26
|
/*
|
27
27
|
* @Author:wangxian
|
28
28
|
* @Date: 2021-09-18 14:15:04
|
29
|
-
* @LastEditTime: 2022-11-
|
29
|
+
* @LastEditTime: 2022-11-22 14:42:09
|
30
30
|
*/
|
31
31
|
import React from 'react';
|
32
32
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
@@ -35,9 +35,10 @@ import { MetadataService } from '../../../framework/metadata/MetadataService';
|
|
35
35
|
import { deepClone } from '../../../utils';
|
36
36
|
import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
|
37
37
|
import { tr } from '../../../framework/locale';
|
38
|
+
import useObservable from '@/framework/rxjs-hooks/useObservable';
|
38
39
|
|
39
40
|
function Index(props) {
|
40
|
-
var _extraInfo$
|
41
|
+
var _extraInfo$http6, _extraInfo$http7, _extraInfo$http8, _extraInfo$http9;
|
41
42
|
|
42
43
|
var id = props.id,
|
43
44
|
name = props.name,
|
@@ -58,6 +59,12 @@ function Index(props) {
|
|
58
59
|
cascaderOption = _React$useState2[0],
|
59
60
|
setCascaderOption = _React$useState2[1];
|
60
61
|
|
62
|
+
var _React$useState3 = React.useState(),
|
63
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
64
|
+
watchValue = _React$useState4[0],
|
65
|
+
setWatchValue = _React$useState4[1];
|
66
|
+
|
67
|
+
var watchValueRef = React.useRef();
|
61
68
|
var pageRef = React.useRef(1);
|
62
69
|
var totalRef = React.useRef();
|
63
70
|
|
@@ -68,6 +75,22 @@ function Index(props) {
|
|
68
75
|
});
|
69
76
|
};
|
70
77
|
|
78
|
+
useObservable(function (p) {
|
79
|
+
var _extraInfo$http;
|
80
|
+
|
81
|
+
// 判断是否有 watch的扩展属性
|
82
|
+
var _watch = extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.watch;
|
83
|
+
|
84
|
+
if (_watch) {
|
85
|
+
var _value = p.payload[_watch];
|
86
|
+
|
87
|
+
if (_value) {
|
88
|
+
setWatchValue(_value);
|
89
|
+
watchValueRef.current = _value;
|
90
|
+
formContext.form.setFieldsValue(_defineProperty({}, id, undefined));
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}, [formContext.stream$, extraInfo]);
|
71
94
|
var getEnumDataByUrl = React.useCallback( /*#__PURE__*/function () {
|
72
95
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(http, pid, page) {
|
73
96
|
var server, _url, res, _res;
|
@@ -79,16 +102,21 @@ function Index(props) {
|
|
79
102
|
server = new MetadataService();
|
80
103
|
_url = pid || pid === '' ? http.url.replace('{pid}', pid) : http.url;
|
81
104
|
_url = page ? http.url.replace('{page}', page) : _url;
|
82
|
-
|
105
|
+
|
106
|
+
if (watchValueRef.current) {
|
107
|
+
_url = _url.replace('{watch}', watchValueRef.current);
|
108
|
+
}
|
109
|
+
|
110
|
+
_context.next = 6;
|
83
111
|
return server.GetEnumDataByUrl(_url);
|
84
112
|
|
85
|
-
case
|
113
|
+
case 6:
|
86
114
|
res = _context.sent;
|
87
115
|
_res = (res === null || res === void 0 ? void 0 : res.total) ? res === null || res === void 0 ? void 0 : res.list : res;
|
88
116
|
totalRef.current = res === null || res === void 0 ? void 0 : res.total;
|
89
117
|
|
90
118
|
if (!(_res && _res.length > 0)) {
|
91
|
-
_context.next =
|
119
|
+
_context.next = 13;
|
92
120
|
break;
|
93
121
|
}
|
94
122
|
|
@@ -107,11 +135,11 @@ function Index(props) {
|
|
107
135
|
}
|
108
136
|
}));
|
109
137
|
|
110
|
-
case
|
138
|
+
case 13:
|
111
139
|
console.warn("".concat(_url, " is not return success result"));
|
112
140
|
return _context.abrupt("return", []);
|
113
141
|
|
114
|
-
case
|
142
|
+
case 15:
|
115
143
|
case "end":
|
116
144
|
return _context.stop();
|
117
145
|
}
|
@@ -155,7 +183,7 @@ function Index(props) {
|
|
155
183
|
return processSelectOptionsData();
|
156
184
|
}, [initEnumValue, myEnum, id]);
|
157
185
|
var httpOptions = useAsyncMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
158
|
-
var _extraInfo$
|
186
|
+
var _extraInfo$http2, _extraInfo$http3, res;
|
159
187
|
|
160
188
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
161
189
|
while (1) {
|
@@ -167,12 +195,12 @@ function Index(props) {
|
|
167
195
|
}
|
168
196
|
|
169
197
|
_context2.next = 3;
|
170
|
-
return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '', (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
198
|
+
return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '', (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http2 = extraInfo.http) === null || _extraInfo$http2 === void 0 ? void 0 : _extraInfo$http2.isPagination) && pageRef.current);
|
171
199
|
|
172
200
|
case 3:
|
173
201
|
res = _context2.sent;
|
174
202
|
|
175
|
-
if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
203
|
+
if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http3 = extraInfo.http) === null || _extraInfo$http3 === void 0 ? void 0 : _extraInfo$http3.isCascader) {
|
176
204
|
setCascaderOption(_toConsumableArray(res));
|
177
205
|
}
|
178
206
|
|
@@ -187,7 +215,7 @@ function Index(props) {
|
|
187
215
|
}
|
188
216
|
}
|
189
217
|
}, _callee2);
|
190
|
-
})), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http]);
|
218
|
+
})), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http, watchValue]);
|
191
219
|
|
192
220
|
var loadData = /*#__PURE__*/function () {
|
193
221
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(selectedOptions) {
|
@@ -316,7 +344,7 @@ function Index(props) {
|
|
316
344
|
};
|
317
345
|
|
318
346
|
if (isObj && isRefForm && field) {
|
319
|
-
var _extraInfo$
|
347
|
+
var _extraInfo$http4, _extraInfo$http5;
|
320
348
|
|
321
349
|
return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
322
350
|
style: {
|
@@ -331,7 +359,7 @@ function Index(props) {
|
|
331
359
|
}],
|
332
360
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
333
361
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
334
|
-
}), processSelectType((_extraInfo$
|
362
|
+
}), processSelectType((_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isCascader, (_extraInfo$http5 = extraInfo.http) === null || _extraInfo$http5 === void 0 ? void 0 : _extraInfo$http5.isPagination));
|
335
363
|
}
|
336
364
|
|
337
365
|
return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
|
@@ -347,7 +375,7 @@ function Index(props) {
|
|
347
375
|
}],
|
348
376
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
349
377
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
350
|
-
}, processSelectType((_extraInfo$
|
378
|
+
}, processSelectType((_extraInfo$http6 = extraInfo.http) === null || _extraInfo$http6 === void 0 ? void 0 : _extraInfo$http6.isCascader, (_extraInfo$http7 = extraInfo.http) === null || _extraInfo$http7 === void 0 ? void 0 : _extraInfo$http7.isPagination)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
351
379
|
style: {
|
352
380
|
flex: 1,
|
353
381
|
paddingRight: '10px'
|
@@ -359,7 +387,7 @@ function Index(props) {
|
|
359
387
|
}],
|
360
388
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
361
389
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
362
|
-
}), processSelectType((_extraInfo$
|
390
|
+
}), processSelectType((_extraInfo$http8 = extraInfo.http) === null || _extraInfo$http8 === void 0 ? void 0 : _extraInfo$http8.isCascader, (_extraInfo$http9 = extraInfo.http) === null || _extraInfo$http9 === void 0 ? void 0 : _extraInfo$http9.isPagination));
|
363
391
|
}
|
364
392
|
|
365
393
|
export default /*#__PURE__*/React.memo(Index);
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
/*
|
5
5
|
* @Author: wangxian
|
6
6
|
* @Date: 2021-09-18 14:15:04
|
7
|
-
* @LastEditTime: 2022-
|
7
|
+
* @LastEditTime: 2022-11-22 15:37:46
|
8
8
|
*/
|
9
9
|
import React from 'react';
|
10
10
|
import { deepClone } from '../../../utils';
|
@@ -48,7 +48,7 @@ export function withAddOnAfter(WrappedComponent) {
|
|
48
48
|
key: "".concat(_name.toString(), "_div"),
|
49
49
|
className: "with-add-on-after"
|
50
50
|
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
51
|
-
key: _name.toString()
|
51
|
+
key: "".concat(_name.toString(), "_Wrapped}")
|
52
52
|
}, props, {
|
53
53
|
style: {
|
54
54
|
padding: '0px',
|