ronds-metadata 1.1.99 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,14 +12,13 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
12
12
|
/*
|
13
13
|
* @Author: wangxian
|
14
14
|
* @Date: 2021-09-18 14:15:04
|
15
|
-
* @LastEditTime: 2023-02-
|
15
|
+
* @LastEditTime: 2023-02-22 13:54:18
|
16
16
|
*/
|
17
17
|
import React from 'react';
|
18
18
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
19
19
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
20
20
|
import { useGetExtraInfo } from '../hooks';
|
21
21
|
import { getDataCell } from '../utils';
|
22
|
-
import { deepClone } from '../../../utils';
|
23
22
|
import { tr } from '../../../framework/locale';
|
24
23
|
import TableArray from './layout/TableArray';
|
25
24
|
|
@@ -56,18 +55,16 @@ function Index(props) {
|
|
56
55
|
help = _React$useState2[0],
|
57
56
|
setHelp = _React$useState2[1];
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
return res;
|
70
|
-
}, [name, id]);
|
58
|
+
// const myName = React.useMemo(() => {
|
59
|
+
// let res = [];
|
60
|
+
// if (name && name.length > 0) {
|
61
|
+
// res = deepClone(name);
|
62
|
+
// res.push(id);
|
63
|
+
// } else {
|
64
|
+
// return id;
|
65
|
+
// }
|
66
|
+
// return res;
|
67
|
+
// }, [name, id]);
|
71
68
|
React.useEffect(function () {
|
72
69
|
if (items && items.refId) {
|
73
70
|
var arr = items.refId.split('.');
|
@@ -104,7 +101,7 @@ function Index(props) {
|
|
104
101
|
rowNumber: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rowNumber) || 10,
|
105
102
|
refId: items.refId,
|
106
103
|
form: formContext.form,
|
107
|
-
name:
|
104
|
+
name: name
|
108
105
|
}) : /*#__PURE__*/React.createElement("div", {
|
109
106
|
style: {
|
110
107
|
padding: '10px',
|
@@ -114,7 +111,7 @@ function Index(props) {
|
|
114
111
|
margin: '0 0 8px'
|
115
112
|
}
|
116
113
|
}, /*#__PURE__*/React.createElement(_Form.List, {
|
117
|
-
name:
|
114
|
+
name: name,
|
118
115
|
key: id
|
119
116
|
}, function (fields, _ref) {
|
120
117
|
var add = _ref.add,
|
@@ -283,7 +283,7 @@ var TableArray = function TableArray(props) {
|
|
283
283
|
form.setFieldsValue(_objectSpread({}, _defineProperty({}, "".concat(name), values)));
|
284
284
|
} else {
|
285
285
|
var val = {};
|
286
|
-
assign(name,
|
286
|
+
assign(name, _toConsumableArray(values), val);
|
287
287
|
form.setFieldsValue(_objectSpread({}, val));
|
288
288
|
}
|
289
289
|
|
@@ -111,13 +111,6 @@ var MetadataForm = function MetadataForm(props) {
|
|
111
111
|
type: 'setFieldsValue',
|
112
112
|
payload: vals
|
113
113
|
});
|
114
|
-
stream$.next({
|
115
|
-
type: 'onValuesChange',
|
116
|
-
payload: {
|
117
|
-
val: vals,
|
118
|
-
allVals: vals
|
119
|
-
}
|
120
|
-
});
|
121
114
|
};
|
122
115
|
|
123
116
|
form.setFieldsValue = setFieldsValue;
|
@@ -184,6 +177,24 @@ var MetadataForm = function MetadataForm(props) {
|
|
184
177
|
}
|
185
178
|
}
|
186
179
|
}, [initialValues, fields]);
|
180
|
+
var myLabelSpan = React.useMemo(function () {
|
181
|
+
var _labelSpan = undefined;
|
182
|
+
|
183
|
+
if (labelSpan || (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan)) {
|
184
|
+
_labelSpan = (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan) ? formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan : labelSpan;
|
185
|
+
}
|
186
|
+
|
187
|
+
return _labelSpan;
|
188
|
+
}, [labelSpan, formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan]);
|
189
|
+
var myLayout = React.useMemo(function () {
|
190
|
+
var _layout = undefined;
|
191
|
+
|
192
|
+
if (layout || (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout)) {
|
193
|
+
_layout = (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout) ? formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout : layout;
|
194
|
+
}
|
195
|
+
|
196
|
+
return _layout;
|
197
|
+
}, [layout, formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout]);
|
187
198
|
|
188
199
|
var onMyValuesChange = function onMyValuesChange(value, allValues) {
|
189
200
|
var _extra$text;
|
@@ -226,8 +237,8 @@ var MetadataForm = function MetadataForm(props) {
|
|
226
237
|
value: {
|
227
238
|
fields: fields,
|
228
239
|
colSpan: colSpan,
|
229
|
-
labelSpan:
|
230
|
-
layout:
|
240
|
+
labelSpan: myLabelSpan,
|
241
|
+
layout: myLayout,
|
231
242
|
form: form,
|
232
243
|
stream$: stream$,
|
233
244
|
initialValues: initialValues,
|
@@ -237,16 +248,16 @@ var MetadataForm = function MetadataForm(props) {
|
|
237
248
|
}
|
238
249
|
}, /*#__PURE__*/React.createElement(_Form, {
|
239
250
|
className: "metadata-form",
|
240
|
-
wrapperCol:
|
241
|
-
span: 24 -
|
251
|
+
wrapperCol: myLabelSpan && myLayout === 'horizontal' ? {
|
252
|
+
span: 24 - myLabelSpan,
|
242
253
|
offset: 0
|
243
254
|
} : undefined,
|
244
|
-
labelCol:
|
245
|
-
span:
|
255
|
+
labelCol: myLabelSpan && myLayout === 'horizontal' ? {
|
256
|
+
span: myLabelSpan,
|
246
257
|
offset: 0
|
247
258
|
} : undefined,
|
248
259
|
labelWrap: labelWrap,
|
249
|
-
layout:
|
260
|
+
layout: myLayout,
|
250
261
|
form: form,
|
251
262
|
name: "control-hooks",
|
252
263
|
onFinish: onMyFinish,
|