@quansitech/antd-admin 1.2.0 → 1.2.2
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/SelectText.d.ts +9 -0
- package/dist/components/Column/SelectText.js +43 -0
- package/dist/components/Column/index.d.ts +1 -0
- package/dist/components/Column/index.js +3 -0
- package/dist/components/Table.d.ts +1 -0
- package/dist/components/Table.js +50 -36
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColumnProps } from './types';
|
|
3
|
+
export default function (props: ColumnProps & {
|
|
4
|
+
valueEnum?: Map<string | number, string>;
|
|
5
|
+
fieldProps?: {
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
};
|
|
8
|
+
text: [string, string | number];
|
|
9
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import { Input, Select, Space } from 'antd';
|
|
9
|
+
export default function (props) {
|
|
10
|
+
var _props$fieldProps2;
|
|
11
|
+
var options = [];
|
|
12
|
+
(props.valueEnum || []).forEach(function (value, key) {
|
|
13
|
+
options.push({
|
|
14
|
+
label: value,
|
|
15
|
+
value: key
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
var _useState = useState(['', '']),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
value = _useState2[0],
|
|
21
|
+
setValue = _useState2[1];
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
setValue([props.text[0] || options[0].value, props.text[1]]);
|
|
24
|
+
}, [props.text]);
|
|
25
|
+
var _onChange = function onChange(value) {
|
|
26
|
+
var _props$fieldProps;
|
|
27
|
+
setValue(value);
|
|
28
|
+
(_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 || _props$fieldProps.onChange(value);
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space.Compact, null, /*#__PURE__*/React.createElement(Select, {
|
|
31
|
+
onChange: function onChange(v) {
|
|
32
|
+
return _onChange([v, value[1]]);
|
|
33
|
+
},
|
|
34
|
+
value: value[0],
|
|
35
|
+
options: options
|
|
36
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
37
|
+
placeholder: (_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 ? void 0 : _props$fieldProps2.placeholder,
|
|
38
|
+
onChange: function onChange(e) {
|
|
39
|
+
return _onChange([value[0], e.target.value]);
|
|
40
|
+
},
|
|
41
|
+
value: value[1]
|
|
42
|
+
})));
|
|
43
|
+
}
|
package/dist/components/Table.js
CHANGED
|
@@ -39,6 +39,15 @@ export default function (props) {
|
|
|
39
39
|
case 0:
|
|
40
40
|
data = _objectSpread(_objectSpread(_objectSpread({}, params), filter), {}, {
|
|
41
41
|
sort: sort
|
|
42
|
+
}); // 兼容 key:value 的写法
|
|
43
|
+
Object.keys(data).forEach(function (key) {
|
|
44
|
+
if (key.indexOf(':') !== -1) {
|
|
45
|
+
var keys = key.split(':');
|
|
46
|
+
keys.map(function (k, i) {
|
|
47
|
+
data[k] = data[key][i];
|
|
48
|
+
});
|
|
49
|
+
delete data[key];
|
|
50
|
+
}
|
|
42
51
|
});
|
|
43
52
|
if (props.pagination) {
|
|
44
53
|
data[props.pagination.paramName || 'page'] = params.current;
|
|
@@ -49,7 +58,7 @@ export default function (props) {
|
|
|
49
58
|
setEditableValues([]);
|
|
50
59
|
setSelectedRows([]);
|
|
51
60
|
if (modalContext.inModal) {
|
|
52
|
-
_context.next =
|
|
61
|
+
_context.next = 9;
|
|
53
62
|
break;
|
|
54
63
|
}
|
|
55
64
|
// 如果不在 modal 中,则使用 routerNavigateTo
|
|
@@ -76,16 +85,16 @@ export default function (props) {
|
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
return _context.abrupt("return");
|
|
79
|
-
case
|
|
80
|
-
_context.prev =
|
|
81
|
-
_context.next =
|
|
88
|
+
case 9:
|
|
89
|
+
_context.prev = 9;
|
|
90
|
+
_context.next = 12;
|
|
82
91
|
return http.get(searchUrl, {
|
|
83
92
|
params: data,
|
|
84
93
|
headers: {
|
|
85
94
|
'X-Table-Search': '1'
|
|
86
95
|
}
|
|
87
96
|
});
|
|
88
|
-
case
|
|
97
|
+
case 12:
|
|
89
98
|
res = _context.sent;
|
|
90
99
|
_props = res.data;
|
|
91
100
|
setToolActions(_props.actions);
|
|
@@ -98,15 +107,15 @@ export default function (props) {
|
|
|
98
107
|
data: res.data.dataSource || [],
|
|
99
108
|
success: true
|
|
100
109
|
});
|
|
101
|
-
case
|
|
102
|
-
_context.prev =
|
|
110
|
+
case 21:
|
|
111
|
+
_context.prev = 21;
|
|
103
112
|
setLoading(false);
|
|
104
|
-
return _context.finish(
|
|
105
|
-
case
|
|
113
|
+
return _context.finish(21);
|
|
114
|
+
case 24:
|
|
106
115
|
case "end":
|
|
107
116
|
return _context.stop();
|
|
108
117
|
}
|
|
109
|
-
}, _callee, null, [[
|
|
118
|
+
}, _callee, null, [[9,, 21, 24]]);
|
|
110
119
|
}));
|
|
111
120
|
return function request(_x, _x2, _x3) {
|
|
112
121
|
return _ref.apply(this, arguments);
|
|
@@ -143,7 +152,7 @@ export default function (props) {
|
|
|
143
152
|
setSearchUrl = _useState2[1];
|
|
144
153
|
var formRef = useRef();
|
|
145
154
|
var actionRef = useRef();
|
|
146
|
-
var _useState3 = useState({}),
|
|
155
|
+
var _useState3 = useState(props.defaultSearchValue || {}),
|
|
147
156
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
148
157
|
lastQuery = _useState4[0],
|
|
149
158
|
setLastQuery = _useState4[1];
|
|
@@ -199,7 +208,7 @@ export default function (props) {
|
|
|
199
208
|
*/
|
|
200
209
|
var createSearchRangeColumn = function createSearchRangeColumn(column, rangeType) {
|
|
201
210
|
return _objectSpread(_objectSpread({}, column), {}, {
|
|
202
|
-
dataIndex: column.dataIndex
|
|
211
|
+
dataIndex: column.dataIndex,
|
|
203
212
|
valueType: rangeType,
|
|
204
213
|
title: typeof column.title === 'string' ? "".concat(column.title, "\u8303\u56F4") : column.title,
|
|
205
214
|
hideInTable: true,
|
|
@@ -219,18 +228,6 @@ export default function (props) {
|
|
|
219
228
|
search: false
|
|
220
229
|
});
|
|
221
230
|
};
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* 处理普通column
|
|
225
|
-
*/
|
|
226
|
-
var processNormalColumn = function processNormalColumn(column, processedColumns) {
|
|
227
|
-
if (container.schemaHandler[column.valueType]) {
|
|
228
|
-
var processedColumn = container.schemaHandler[column.valueType](column);
|
|
229
|
-
processedColumns.push(processedColumn);
|
|
230
|
-
} else {
|
|
231
|
-
processedColumns.push(column);
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
231
|
(_cloneDeep = cloneDeep(columns)) === null || _cloneDeep === void 0 || _cloneDeep.forEach(function (column) {
|
|
235
232
|
// 设置column的key
|
|
236
233
|
column.key = column.dataIndex;
|
|
@@ -248,10 +245,15 @@ export default function (props) {
|
|
|
248
245
|
processedColumns.push(searchColumn, tableColumn);
|
|
249
246
|
} else {
|
|
250
247
|
// 处理普通column
|
|
251
|
-
|
|
248
|
+
processedColumns.push(column);
|
|
252
249
|
}
|
|
253
250
|
});
|
|
254
|
-
return processedColumns
|
|
251
|
+
return processedColumns.map(function (column) {
|
|
252
|
+
if (container.schemaHandler[column.valueType]) {
|
|
253
|
+
column = container.schemaHandler[column.valueType](column);
|
|
254
|
+
}
|
|
255
|
+
return column;
|
|
256
|
+
});
|
|
255
257
|
}, [columns]);
|
|
256
258
|
var handleSearchRangeValue = function handleSearchRangeValue(processedValue) {
|
|
257
259
|
Object.keys(processedValue).forEach(function (key) {
|
|
@@ -267,13 +269,21 @@ export default function (props) {
|
|
|
267
269
|
});
|
|
268
270
|
};
|
|
269
271
|
|
|
270
|
-
//
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
// 处理数组类型的搜索栏key {'key:value': ['【key】','【value】']}
|
|
273
|
+
var handleSearchArrayKey = function handleSearchArrayKey(processedValue) {
|
|
274
|
+
realColumns.forEach(function (col) {
|
|
275
|
+
var dataIndex = col.dataIndex;
|
|
276
|
+
if (dataIndex.indexOf(':') !== -1) {
|
|
277
|
+
var keys = dataIndex.split(':');
|
|
278
|
+
var values = [];
|
|
279
|
+
keys.map(function (key) {
|
|
280
|
+
values.push(processedValue[key]);
|
|
281
|
+
delete processedValue[key];
|
|
282
|
+
});
|
|
283
|
+
processedValue[dataIndex] = values;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
};
|
|
277
287
|
var modalContext = useContext(ModalContext);
|
|
278
288
|
var tabsContext = useContext(TabsContext);
|
|
279
289
|
useEffect(function () {
|
|
@@ -296,7 +306,6 @@ export default function (props) {
|
|
|
296
306
|
});
|
|
297
307
|
setSearchUrl(s);
|
|
298
308
|
}
|
|
299
|
-
setLastQuery(props.defaultSearchValue || {});
|
|
300
309
|
setDataSource(postData(props.dataSource || []));
|
|
301
310
|
if (!modalContext.inModal) {
|
|
302
311
|
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
@@ -308,12 +317,17 @@ export default function (props) {
|
|
|
308
317
|
}
|
|
309
318
|
});
|
|
310
319
|
handleSearchRangeValue(query);
|
|
320
|
+
handleSearchArrayKey(query);
|
|
311
321
|
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setFieldsValue(query);
|
|
312
322
|
setLastQuery(query);
|
|
313
323
|
}
|
|
314
324
|
}
|
|
315
325
|
}, []);
|
|
316
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
326
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
327
|
+
dangerouslySetInnerHTML: {
|
|
328
|
+
__html: props.description
|
|
329
|
+
}
|
|
330
|
+
}), /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
317
331
|
value: {
|
|
318
332
|
getTableProps: function getTableProps() {
|
|
319
333
|
return props;
|
|
@@ -354,7 +368,7 @@ export default function (props) {
|
|
|
354
368
|
reload: true
|
|
355
369
|
},
|
|
356
370
|
form: {
|
|
357
|
-
initialValues:
|
|
371
|
+
initialValues: props.defaultSearchValue,
|
|
358
372
|
onValuesChange: function onValuesChange(changedValues, allValues) {
|
|
359
373
|
var _formRef$current2;
|
|
360
374
|
var submit = realColumns.filter(function (c) {
|