@quansitech/antd-admin 1.2.1 → 1.2.3
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 +46 -0
- package/dist/components/Column/SelectText.module.scss +3 -0
- package/dist/components/Column/index.d.ts +1 -0
- package/dist/components/Column/index.js +3 -0
- package/dist/components/Table.js +37 -12
- package/dist/global.d.ts +6 -0
- 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,46 @@
|
|
|
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
|
+
import styles from "./SelectText.module.scss";
|
|
10
|
+
export default function (props) {
|
|
11
|
+
var _props$fieldProps2;
|
|
12
|
+
var options = [];
|
|
13
|
+
(props.valueEnum || []).forEach(function (value, key) {
|
|
14
|
+
options.push({
|
|
15
|
+
label: value,
|
|
16
|
+
value: key
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
var _useState = useState(['', '']),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
value = _useState2[0],
|
|
22
|
+
setValue = _useState2[1];
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
setValue([props.text[0] || options[0].value, props.text[1]]);
|
|
25
|
+
}, [props.text]);
|
|
26
|
+
var _onChange = function onChange(value) {
|
|
27
|
+
var _props$fieldProps;
|
|
28
|
+
setValue(value);
|
|
29
|
+
(_props$fieldProps = props.fieldProps) === null || _props$fieldProps === void 0 || _props$fieldProps.onChange(value);
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space.Compact, {
|
|
32
|
+
className: styles.selectText
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
34
|
+
onChange: function onChange(v) {
|
|
35
|
+
return _onChange([v, value[1]]);
|
|
36
|
+
},
|
|
37
|
+
value: value[0],
|
|
38
|
+
options: options
|
|
39
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
40
|
+
placeholder: (_props$fieldProps2 = props.fieldProps) === null || _props$fieldProps2 === void 0 ? void 0 : _props$fieldProps2.placeholder,
|
|
41
|
+
onChange: function onChange(e) {
|
|
42
|
+
return _onChange([value[0], e.target.value]);
|
|
43
|
+
},
|
|
44
|
+
value: value[1]
|
|
45
|
+
})));
|
|
46
|
+
}
|
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];
|
|
@@ -259,6 +268,22 @@ export default function (props) {
|
|
|
259
268
|
}
|
|
260
269
|
});
|
|
261
270
|
};
|
|
271
|
+
|
|
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
|
+
};
|
|
262
287
|
var modalContext = useContext(ModalContext);
|
|
263
288
|
var tabsContext = useContext(TabsContext);
|
|
264
289
|
useEffect(function () {
|
|
@@ -281,7 +306,6 @@ export default function (props) {
|
|
|
281
306
|
});
|
|
282
307
|
setSearchUrl(s);
|
|
283
308
|
}
|
|
284
|
-
setLastQuery(props.defaultSearchValue || {});
|
|
285
309
|
setDataSource(postData(props.dataSource || []));
|
|
286
310
|
if (!modalContext.inModal) {
|
|
287
311
|
var query = qs.parse(window.location.search.replace(/^\?/, ''));
|
|
@@ -293,6 +317,7 @@ export default function (props) {
|
|
|
293
317
|
}
|
|
294
318
|
});
|
|
295
319
|
handleSearchRangeValue(query);
|
|
320
|
+
handleSearchArrayKey(query);
|
|
296
321
|
(_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.setFieldsValue(query);
|
|
297
322
|
setLastQuery(query);
|
|
298
323
|
}
|
package/dist/global.d.ts
CHANGED