@quansitech/antd-admin 1.2.6 → 1.2.8
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.
- package/dist/components/Column/Cascader.js +19 -12
- package/dist/components/Table.js +38 -19
- package/package.json +1 -1
|
@@ -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
|
|
package/dist/components/Table.js
CHANGED
|
@@ -33,11 +33,13 @@ import { TabsContext } from "./TabsContext";
|
|
|
33
33
|
export default function (props) {
|
|
34
34
|
var request = /*#__PURE__*/function () {
|
|
35
35
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, sort, filter) {
|
|
36
|
+
var _formRef$current;
|
|
36
37
|
var data, res, _props;
|
|
37
38
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38
39
|
while (1) switch (_context.prev = _context.next) {
|
|
39
40
|
case 0:
|
|
40
|
-
|
|
41
|
+
setLoading(true);
|
|
42
|
+
data = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldsValue()), params), filter), {}, {
|
|
41
43
|
sort: sort
|
|
42
44
|
}); // 兼容 key:value 的写法
|
|
43
45
|
Object.keys(data).forEach(function (key) {
|
|
@@ -58,7 +60,7 @@ export default function (props) {
|
|
|
58
60
|
setEditableValues([]);
|
|
59
61
|
setSelectedRows([]);
|
|
60
62
|
if (modalContext.inModal) {
|
|
61
|
-
_context.next =
|
|
63
|
+
_context.next = 10;
|
|
62
64
|
break;
|
|
63
65
|
}
|
|
64
66
|
// 如果不在 modal 中,则使用 routerNavigateTo
|
|
@@ -85,16 +87,16 @@ export default function (props) {
|
|
|
85
87
|
}
|
|
86
88
|
});
|
|
87
89
|
return _context.abrupt("return");
|
|
88
|
-
case
|
|
89
|
-
_context.prev =
|
|
90
|
-
_context.next =
|
|
90
|
+
case 10:
|
|
91
|
+
_context.prev = 10;
|
|
92
|
+
_context.next = 13;
|
|
91
93
|
return http.get(searchUrl, {
|
|
92
94
|
params: data,
|
|
93
95
|
headers: {
|
|
94
96
|
'X-Table-Search': '1'
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
|
-
case
|
|
99
|
+
case 13:
|
|
98
100
|
res = _context.sent;
|
|
99
101
|
_props = res.data;
|
|
100
102
|
setToolActions(_props.actions);
|
|
@@ -107,15 +109,15 @@ export default function (props) {
|
|
|
107
109
|
data: res.data.dataSource || [],
|
|
108
110
|
success: true
|
|
109
111
|
});
|
|
110
|
-
case
|
|
111
|
-
_context.prev =
|
|
112
|
+
case 22:
|
|
113
|
+
_context.prev = 22;
|
|
112
114
|
setLoading(false);
|
|
113
|
-
return _context.finish(
|
|
114
|
-
case
|
|
115
|
+
return _context.finish(22);
|
|
116
|
+
case 25:
|
|
115
117
|
case "end":
|
|
116
118
|
return _context.stop();
|
|
117
119
|
}
|
|
118
|
-
}, _callee, null, [[
|
|
120
|
+
}, _callee, null, [[10,, 22, 25]]);
|
|
119
121
|
}));
|
|
120
122
|
return function request(_x, _x2, _x3) {
|
|
121
123
|
return _ref.apply(this, arguments);
|
|
@@ -199,6 +201,14 @@ export default function (props) {
|
|
|
199
201
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
200
202
|
columns = _useState24[0],
|
|
201
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];
|
|
202
212
|
var realColumns = useMemo(function () {
|
|
203
213
|
var _cloneDeep;
|
|
204
214
|
var processedColumns = [];
|
|
@@ -297,13 +307,20 @@ export default function (props) {
|
|
|
297
307
|
|
|
298
308
|
// 搜索
|
|
299
309
|
if (!searchUrl) {
|
|
300
|
-
|
|
310
|
+
var s = window.location.href;
|
|
311
|
+
s = s.replace(/page=\d+&?/, '');
|
|
312
|
+
realColumns.filter(function (c) {
|
|
313
|
+
return c.search !== false;
|
|
314
|
+
}).map(function (c) {
|
|
315
|
+
s = s.replace(new RegExp("".concat(c.dataIndex, "=[^&]*&?")), '');
|
|
316
|
+
});
|
|
317
|
+
setSearchUrl(s);
|
|
301
318
|
}
|
|
302
319
|
setDataSource(postData(props.dataSource || []));
|
|
303
320
|
if (!modalContext.inModal) {
|
|
304
321
|
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
305
322
|
if (query && Object.keys(query).length) {
|
|
306
|
-
var _formRef$
|
|
323
|
+
var _formRef$current2;
|
|
307
324
|
Object.keys(query).forEach(function (key) {
|
|
308
325
|
if (typeof query[key] === 'string') {
|
|
309
326
|
/^\d+$/.test(query[key]) && (query[key] = parseInt(query[key]));
|
|
@@ -311,16 +328,18 @@ export default function (props) {
|
|
|
311
328
|
});
|
|
312
329
|
handleSearchRangeValue(query);
|
|
313
330
|
handleSearchArrayKey(query);
|
|
314
|
-
(_formRef$
|
|
331
|
+
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFieldsValue(query);
|
|
332
|
+
setInitialValues(query);
|
|
315
333
|
setLastQuery(query);
|
|
316
334
|
}
|
|
317
335
|
}
|
|
336
|
+
setInited(true);
|
|
318
337
|
}, []);
|
|
319
338
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
320
339
|
dangerouslySetInnerHTML: {
|
|
321
340
|
__html: props.description
|
|
322
341
|
}
|
|
323
|
-
}), /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
342
|
+
}), inited ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
324
343
|
value: {
|
|
325
344
|
getTableProps: function getTableProps() {
|
|
326
345
|
return props;
|
|
@@ -361,9 +380,9 @@ export default function (props) {
|
|
|
361
380
|
reload: true
|
|
362
381
|
},
|
|
363
382
|
form: {
|
|
364
|
-
initialValues:
|
|
383
|
+
initialValues: initialValues,
|
|
365
384
|
onValuesChange: function onValuesChange(changedValues, allValues) {
|
|
366
|
-
var _formRef$
|
|
385
|
+
var _formRef$current3;
|
|
367
386
|
var submit = realColumns.filter(function (c) {
|
|
368
387
|
if (!c.searchOnChange) {
|
|
369
388
|
return false;
|
|
@@ -374,7 +393,7 @@ export default function (props) {
|
|
|
374
393
|
return;
|
|
375
394
|
}
|
|
376
395
|
// 是否立即搜索
|
|
377
|
-
(_formRef$
|
|
396
|
+
(_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.submit();
|
|
378
397
|
}
|
|
379
398
|
},
|
|
380
399
|
rowSelection: props.rowSelection && {
|
|
@@ -439,5 +458,5 @@ export default function (props) {
|
|
|
439
458
|
actionRef: actionRef,
|
|
440
459
|
search: props.search,
|
|
441
460
|
dateFormatter: props.dateFormatter
|
|
442
|
-
})));
|
|
461
|
+
}))) : /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
443
462
|
}
|