ronds-metadata 1.2.44 → 1.2.46
Sign up to get free protection for your applications and to get access to all the features.
@@ -16,15 +16,16 @@ import _Input from "antd/es/input";
|
|
16
16
|
/*
|
17
17
|
* @Author: wangxian
|
18
18
|
* @Date: 2021-09-18 14:15:04
|
19
|
-
* @LastEditTime: 2023-
|
19
|
+
* @LastEditTime: 2023-05-11 08:26:41
|
20
20
|
*/
|
21
21
|
import React from 'react';
|
22
22
|
import { UploadOutlined } from '@ant-design/icons';
|
23
23
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
24
24
|
import { useGetExtraInfo } from '../hooks';
|
25
|
+
import useObservable from '@/framework/rxjs-hooks/useObservable';
|
25
26
|
var TextArea = _Input.TextArea;
|
26
27
|
function Index(props) {
|
27
|
-
var _extraInfo$
|
28
|
+
var _extraInfo$addonAfter7;
|
28
29
|
var id = props.id,
|
29
30
|
isRefForm = props.isRefForm,
|
30
31
|
disabled = props.disabled,
|
@@ -36,11 +37,29 @@ function Index(props) {
|
|
36
37
|
var formContext = React.useContext(MetadataFormContext) || {};
|
37
38
|
var formRefContext = React.useContext(MetadataRefContext);
|
38
39
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
39
|
-
|
40
|
-
var _React$useState = React.useState([]),
|
40
|
+
var _React$useState = React.useState(),
|
41
41
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
42
|
-
|
43
|
-
|
42
|
+
valueTitle = _React$useState2[0],
|
43
|
+
setValueTitle = _React$useState2[1];
|
44
|
+
var _React$useState3 = React.useState([]),
|
45
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
46
|
+
rules = _React$useState4[0],
|
47
|
+
setRules = _React$useState4[1];
|
48
|
+
useObservable(function (p) {
|
49
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === 'onValuesChange') {
|
50
|
+
var _extraInfo$addonAfter;
|
51
|
+
var evalString = '';
|
52
|
+
for (var i = 0; i < name.length; i++) {
|
53
|
+
evalString = "".concat(evalString, "[name[").concat(i, "]]");
|
54
|
+
}
|
55
|
+
var _value = eval("p?.payload?.allVals".concat(evalString));
|
56
|
+
if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter = extraInfo.addonAfter) === null || _extraInfo$addonAfter === void 0 ? void 0 : _extraInfo$addonAfter.key) {
|
57
|
+
setValueTitle(_value === null || _value === void 0 ? void 0 : _value.value);
|
58
|
+
} else {
|
59
|
+
setValueTitle(_value);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}, [formContext.stream$, name, extraInfo]);
|
44
63
|
React.useEffect(function () {
|
45
64
|
var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
|
46
65
|
if (_rules) {
|
@@ -53,9 +72,8 @@ function Index(props) {
|
|
53
72
|
setRules(_toConsumableArray(_));
|
54
73
|
}
|
55
74
|
}, [extraInfo]);
|
56
|
-
var onChange = function onChange(e) {};
|
57
75
|
var processInputType = function processInputType(_type) {
|
58
|
-
var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$
|
76
|
+
var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$addonAfter2, _extraInfo$addonAfter3, _extraInfo$addonAfter4, _extraInfo$addonAfter5, _extraInfo$disabled6;
|
59
77
|
switch (_type) {
|
60
78
|
case 'password':
|
61
79
|
return /*#__PURE__*/React.createElement(_Input.Password, {
|
@@ -64,6 +82,7 @@ function Index(props) {
|
|
64
82
|
});
|
65
83
|
case 'textarea':
|
66
84
|
return /*#__PURE__*/React.createElement(TextArea, {
|
85
|
+
title: valueTitle,
|
67
86
|
showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
|
68
87
|
maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
|
69
88
|
rows: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.textareaRows) || 4,
|
@@ -94,11 +113,11 @@ function Index(props) {
|
|
94
113
|
}, "\u4E0A\u4F20"));
|
95
114
|
default:
|
96
115
|
return /*#__PURE__*/React.createElement(_Input, {
|
97
|
-
addonAfter: ((_extraInfo$
|
98
|
-
name: [].concat(_toConsumableArray(name), [(_extraInfo$
|
116
|
+
addonAfter: ((_extraInfo$addonAfter2 = extraInfo.addonAfter) === null || _extraInfo$addonAfter2 === void 0 ? void 0 : _extraInfo$addonAfter2.key) ? /*#__PURE__*/React.createElement(_Form.Item, {
|
117
|
+
name: [].concat(_toConsumableArray(name), [(_extraInfo$addonAfter3 = extraInfo.addonAfter) === null || _extraInfo$addonAfter3 === void 0 ? void 0 : _extraInfo$addonAfter3.key]),
|
99
118
|
noStyle: true,
|
100
|
-
initialValue: (_extraInfo$
|
101
|
-
}, /*#__PURE__*/React.createElement(_Select, null, (((_extraInfo$
|
119
|
+
initialValue: (_extraInfo$addonAfter4 = extraInfo.addonAfter) === null || _extraInfo$addonAfter4 === void 0 ? void 0 : _extraInfo$addonAfter4.defaultValue
|
120
|
+
}, /*#__PURE__*/React.createElement(_Select, null, (((_extraInfo$addonAfter5 = extraInfo.addonAfter) === null || _extraInfo$addonAfter5 === void 0 ? void 0 : _extraInfo$addonAfter5.value) || []).map(function (v) {
|
102
121
|
return /*#__PURE__*/React.createElement(_Select.Option, {
|
103
122
|
key: v,
|
104
123
|
value: v
|
@@ -108,14 +127,14 @@ function Index(props) {
|
|
108
127
|
maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
|
109
128
|
disabled: (_extraInfo$disabled6 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled6 !== void 0 ? _extraInfo$disabled6 : disabled,
|
110
129
|
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
|
111
|
-
|
112
|
-
|
130
|
+
title: valueTitle,
|
131
|
+
allowClear: true
|
113
132
|
});
|
114
133
|
}
|
115
134
|
};
|
116
135
|
// ref引用的 应用类型是否展示成表单
|
117
136
|
if (isObj && isRefForm && field) {
|
118
|
-
var _extraInfo$
|
137
|
+
var _extraInfo$addonAfter6;
|
119
138
|
return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
120
139
|
style: {
|
121
140
|
flex: 1,
|
@@ -137,7 +156,7 @@ function Index(props) {
|
|
137
156
|
flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
|
138
157
|
offset: 0
|
139
158
|
} : undefined,
|
140
|
-
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
159
|
+
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter6 = extraInfo.addonAfter) === null || _extraInfo$addonAfter6 === void 0 ? void 0 : _extraInfo$addonAfter6.key) ? [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name), ['value']) : [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name)),
|
141
160
|
rules: [{
|
142
161
|
required: notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
143
162
|
}].concat(_toConsumableArray(rules)),
|
@@ -170,7 +189,7 @@ function Index(props) {
|
|
170
189
|
flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
|
171
190
|
offset: 0
|
172
191
|
} : undefined,
|
173
|
-
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
192
|
+
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter7 = extraInfo.addonAfter) === null || _extraInfo$addonAfter7 === void 0 ? void 0 : _extraInfo$addonAfter7.key) ? [].concat(_toConsumableArray(name), ['value']) : name,
|
174
193
|
rules: [{
|
175
194
|
required: notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
176
195
|
}].concat(_toConsumableArray(rules)),
|