ronds-metadata 1.2.44 → 1.2.45
Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ 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-10 15:46:56
|
20
20
|
*/
|
21
21
|
import React from 'react';
|
22
22
|
import { UploadOutlined } from '@ant-design/icons';
|
@@ -24,7 +24,7 @@ import { MetadataFormContext, MetadataRefContext } from '../interface';
|
|
24
24
|
import { useGetExtraInfo } from '../hooks';
|
25
25
|
var TextArea = _Input.TextArea;
|
26
26
|
function Index(props) {
|
27
|
-
var _extraInfo$
|
27
|
+
var _extraInfo$addonAfter7;
|
28
28
|
var id = props.id,
|
29
29
|
isRefForm = props.isRefForm,
|
30
30
|
disabled = props.disabled,
|
@@ -36,11 +36,25 @@ function Index(props) {
|
|
36
36
|
var formContext = React.useContext(MetadataFormContext) || {};
|
37
37
|
var formRefContext = React.useContext(MetadataRefContext);
|
38
38
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
39
|
-
|
40
|
-
var _React$useState = React.useState([]),
|
39
|
+
var _React$useState = React.useState(),
|
41
40
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
42
|
-
|
43
|
-
|
41
|
+
valueTitle = _React$useState2[0],
|
42
|
+
setValueTitle = _React$useState2[1];
|
43
|
+
var _React$useState3 = React.useState([]),
|
44
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
45
|
+
rules = _React$useState4[0],
|
46
|
+
setRules = _React$useState4[1];
|
47
|
+
React.useEffect(function () {
|
48
|
+
if ((formContext === null || formContext === void 0 ? void 0 : formContext.form) && name && id) {
|
49
|
+
var _formContext$form, _extraInfo$addonAfter;
|
50
|
+
var _title = formContext === null || formContext === void 0 ? void 0 : (_formContext$form = formContext.form) === null || _formContext$form === void 0 ? void 0 : _formContext$form.getFieldsValue(name)[id];
|
51
|
+
if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter = extraInfo.addonAfter) === null || _extraInfo$addonAfter === void 0 ? void 0 : _extraInfo$addonAfter.key) {
|
52
|
+
setValueTitle(_title === null || _title === void 0 ? void 0 : _title.value);
|
53
|
+
} else {
|
54
|
+
setValueTitle(_title);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}, [formContext === null || formContext === void 0 ? void 0 : formContext.form, extraInfo.addonAfter, name, id]);
|
44
58
|
React.useEffect(function () {
|
45
59
|
var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
|
46
60
|
if (_rules) {
|
@@ -53,9 +67,8 @@ function Index(props) {
|
|
53
67
|
setRules(_toConsumableArray(_));
|
54
68
|
}
|
55
69
|
}, [extraInfo]);
|
56
|
-
var onChange = function onChange(e) {};
|
57
70
|
var processInputType = function processInputType(_type) {
|
58
|
-
var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$
|
71
|
+
var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$addonAfter2, _extraInfo$addonAfter3, _extraInfo$addonAfter4, _extraInfo$addonAfter5, _extraInfo$disabled6;
|
59
72
|
switch (_type) {
|
60
73
|
case 'password':
|
61
74
|
return /*#__PURE__*/React.createElement(_Input.Password, {
|
@@ -64,6 +77,7 @@ function Index(props) {
|
|
64
77
|
});
|
65
78
|
case 'textarea':
|
66
79
|
return /*#__PURE__*/React.createElement(TextArea, {
|
80
|
+
title: valueTitle,
|
67
81
|
showCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.showCount,
|
68
82
|
maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
|
69
83
|
rows: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.textareaRows) || 4,
|
@@ -94,11 +108,12 @@ function Index(props) {
|
|
94
108
|
}, "\u4E0A\u4F20"));
|
95
109
|
default:
|
96
110
|
return /*#__PURE__*/React.createElement(_Input, {
|
97
|
-
|
98
|
-
|
111
|
+
title: valueTitle,
|
112
|
+
addonAfter: ((_extraInfo$addonAfter2 = extraInfo.addonAfter) === null || _extraInfo$addonAfter2 === void 0 ? void 0 : _extraInfo$addonAfter2.key) ? /*#__PURE__*/React.createElement(_Form.Item, {
|
113
|
+
name: [].concat(_toConsumableArray(name), [(_extraInfo$addonAfter3 = extraInfo.addonAfter) === null || _extraInfo$addonAfter3 === void 0 ? void 0 : _extraInfo$addonAfter3.key]),
|
99
114
|
noStyle: true,
|
100
|
-
initialValue: (_extraInfo$
|
101
|
-
}, /*#__PURE__*/React.createElement(_Select, null, (((_extraInfo$
|
115
|
+
initialValue: (_extraInfo$addonAfter4 = extraInfo.addonAfter) === null || _extraInfo$addonAfter4 === void 0 ? void 0 : _extraInfo$addonAfter4.defaultValue
|
116
|
+
}, /*#__PURE__*/React.createElement(_Select, null, (((_extraInfo$addonAfter5 = extraInfo.addonAfter) === null || _extraInfo$addonAfter5 === void 0 ? void 0 : _extraInfo$addonAfter5.value) || []).map(function (v) {
|
102
117
|
return /*#__PURE__*/React.createElement(_Select.Option, {
|
103
118
|
key: v,
|
104
119
|
value: v
|
@@ -108,14 +123,13 @@ function Index(props) {
|
|
108
123
|
maxLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxLength,
|
109
124
|
disabled: (_extraInfo$disabled6 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled6 !== void 0 ? _extraInfo$disabled6 : disabled,
|
110
125
|
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
|
111
|
-
allowClear: true
|
112
|
-
onChange: onChange
|
126
|
+
allowClear: true
|
113
127
|
});
|
114
128
|
}
|
115
129
|
};
|
116
130
|
// ref引用的 应用类型是否展示成表单
|
117
131
|
if (isObj && isRefForm && field) {
|
118
|
-
var _extraInfo$
|
132
|
+
var _extraInfo$addonAfter6;
|
119
133
|
return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
120
134
|
style: {
|
121
135
|
flex: 1,
|
@@ -137,7 +151,7 @@ function Index(props) {
|
|
137
151
|
flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
|
138
152
|
offset: 0
|
139
153
|
} : undefined,
|
140
|
-
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
154
|
+
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
155
|
rules: [{
|
142
156
|
required: notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
143
157
|
}].concat(_toConsumableArray(rules)),
|
@@ -170,7 +184,7 @@ function Index(props) {
|
|
170
184
|
flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
|
171
185
|
offset: 0
|
172
186
|
} : undefined,
|
173
|
-
name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$
|
187
|
+
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
188
|
rules: [{
|
175
189
|
required: notRequire ? !notRequire : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
176
190
|
}].concat(_toConsumableArray(rules)),
|