@quansitech/antd-admin 1.2.7 → 1.2.9
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.
|
@@ -37,10 +37,13 @@ export default function (props) {
|
|
|
37
37
|
var tableContext = useContext(TableContext);
|
|
38
38
|
var itemContext = useContext(ItemContext);
|
|
39
39
|
var findValue = function findValue(options, value) {
|
|
40
|
+
if (!value) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
40
43
|
for (var i = 0; i < options.length; i++) {
|
|
41
44
|
var _option$children;
|
|
42
45
|
var option = options[i];
|
|
43
|
-
if (option.value
|
|
46
|
+
if (option.value == value) {
|
|
44
47
|
return [option.value];
|
|
45
48
|
}
|
|
46
49
|
if ((_option$children = option.children) !== null && _option$children !== void 0 && _option$children.length) {
|
|
@@ -70,28 +73,32 @@ export default function (props) {
|
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
var extraData;
|
|
73
|
-
|
|
76
|
+
// 表单
|
|
77
|
+
if (formContext && (_props$fieldProps = props.fieldProps) !== null && _props$fieldProps !== void 0 && _props$fieldProps.extraRenderValue) {
|
|
74
78
|
extraData = props.fieldProps.extraRenderValue;
|
|
75
79
|
}
|
|
76
|
-
|
|
80
|
+
// 表格行数据
|
|
81
|
+
if (tableContext && (_props$fieldProps2 = props.fieldProps) !== null && _props$fieldProps2 !== void 0 && _props$fieldProps2.extraRenderValues && props.record) {
|
|
77
82
|
var _props$fieldProps$ext;
|
|
78
83
|
var index = -1;
|
|
79
|
-
if (tableContext
|
|
84
|
+
if (tableContext !== null && tableContext !== void 0 && tableContext.dataSource && props.record) {
|
|
80
85
|
var key = tableContext.getTableProps().rowKey;
|
|
81
86
|
index = tableContext.dataSource.findIndex(function (item) {
|
|
82
87
|
return item[key] === props.record[key];
|
|
83
88
|
});
|
|
84
89
|
}
|
|
85
|
-
|
|
86
|
-
index = itemContext.index;
|
|
87
|
-
}
|
|
88
|
-
extraData = (_props$fieldProps$ext = props.fieldProps.extraRenderValues[index]) !== null && _props$fieldProps$ext !== void 0 ? _props$fieldProps$ext : [];
|
|
90
|
+
extraData = (_props$fieldProps$ext = props.fieldProps.extraRenderValues[index]) !== null && _props$fieldProps$ext !== void 0 ? _props$fieldProps$ext : {};
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
// 表单列表
|
|
93
|
+
if (itemContext && (itemContext === null || itemContext === void 0 ? void 0 : itemContext.index) !== undefined) {
|
|
94
|
+
var _props$fieldProps$ext2;
|
|
95
|
+
var _index = -1;
|
|
96
|
+
_index = itemContext.index;
|
|
97
|
+
extraData = (_props$fieldProps$ext2 = props.fieldProps.extraRenderValues[_index]) !== null && _props$fieldProps$ext2 !== void 0 ? _props$fieldProps$ext2 : {};
|
|
98
|
+
}
|
|
99
|
+
if (extraData && value) {
|
|
91
100
|
setOptions(extraData.options);
|
|
92
|
-
|
|
93
|
-
setValues(findValue(extraData.options, value));
|
|
94
|
-
}
|
|
101
|
+
setValues(findValue(extraData.options, value));
|
|
95
102
|
return;
|
|
96
103
|
}
|
|
97
104
|
|
|
@@ -24,7 +24,7 @@ export default function (props) {
|
|
|
24
24
|
var findValue = function findValue(options, value) {
|
|
25
25
|
for (var i = 0; i < options.length; i++) {
|
|
26
26
|
var option = options[i];
|
|
27
|
-
if (option.value
|
|
27
|
+
if (option.value == value) {
|
|
28
28
|
return [option.label];
|
|
29
29
|
} else if (option.children) {
|
|
30
30
|
return [option.label].concat(_toConsumableArray(findValue(option.children, value)));
|
|
@@ -33,8 +33,8 @@ export default function (props) {
|
|
|
33
33
|
};
|
|
34
34
|
useEffect(function () {
|
|
35
35
|
var _props$fieldProps, _props$fieldProps2, _props$fieldProps3;
|
|
36
|
-
setText(props.
|
|
37
|
-
var value = props.
|
|
36
|
+
setText(props.text);
|
|
37
|
+
var value = props.text;
|
|
38
38
|
var extraData;
|
|
39
39
|
if ((_props$fieldProps = props.fieldProps) !== null && _props$fieldProps !== void 0 && _props$fieldProps.extraRenderValue) {
|
|
40
40
|
extraData = props.fieldProps.extraRenderValue;
|
|
@@ -53,7 +53,7 @@ export default function (props) {
|
|
|
53
53
|
}
|
|
54
54
|
extraData = (_props$fieldProps$ext = props.fieldProps.extraRenderValues[index]) !== null && _props$fieldProps$ext !== void 0 ? _props$fieldProps$ext : [];
|
|
55
55
|
}
|
|
56
|
-
if (extraData) {
|
|
56
|
+
if (extraData && value && value != '-') {
|
|
57
57
|
setText(findValue(extraData.options, value).join(' / '));
|
|
58
58
|
return;
|
|
59
59
|
}
|
package/dist/components/Table.js
CHANGED
|
@@ -201,6 +201,14 @@ export default function (props) {
|
|
|
201
201
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
202
202
|
columns = _useState24[0],
|
|
203
203
|
setColumns = _useState24[1];
|
|
204
|
+
var _useState25 = useState(false),
|
|
205
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
206
|
+
inited = _useState26[0],
|
|
207
|
+
setInited = _useState26[1];
|
|
208
|
+
var _useState27 = useState(props.defaultSearchValue || {}),
|
|
209
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
210
|
+
initialValues = _useState28[0],
|
|
211
|
+
setInitialValues = _useState28[1];
|
|
204
212
|
var realColumns = useMemo(function () {
|
|
205
213
|
var _cloneDeep;
|
|
206
214
|
var processedColumns = [];
|
|
@@ -321,15 +329,17 @@ export default function (props) {
|
|
|
321
329
|
handleSearchRangeValue(query);
|
|
322
330
|
handleSearchArrayKey(query);
|
|
323
331
|
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFieldsValue(query);
|
|
332
|
+
setInitialValues(query);
|
|
324
333
|
setLastQuery(query);
|
|
325
334
|
}
|
|
326
335
|
}
|
|
336
|
+
setInited(true);
|
|
327
337
|
}, []);
|
|
328
338
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
329
339
|
dangerouslySetInnerHTML: {
|
|
330
340
|
__html: props.description
|
|
331
341
|
}
|
|
332
|
-
}), /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
342
|
+
}), inited ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
333
343
|
value: {
|
|
334
344
|
getTableProps: function getTableProps() {
|
|
335
345
|
return props;
|
|
@@ -370,7 +380,7 @@ export default function (props) {
|
|
|
370
380
|
reload: true
|
|
371
381
|
},
|
|
372
382
|
form: {
|
|
373
|
-
initialValues:
|
|
383
|
+
initialValues: initialValues,
|
|
374
384
|
onValuesChange: function onValuesChange(changedValues, allValues) {
|
|
375
385
|
var _formRef$current3;
|
|
376
386
|
var submit = realColumns.filter(function (c) {
|
|
@@ -448,5 +458,5 @@ export default function (props) {
|
|
|
448
458
|
actionRef: actionRef,
|
|
449
459
|
search: props.search,
|
|
450
460
|
dateFormatter: props.dateFormatter
|
|
451
|
-
})));
|
|
461
|
+
}))) : /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
452
462
|
}
|