zy-react-library 1.0.163 → 1.0.165
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SelectProps } from "antd/es/select";
|
|
2
|
-
import type { FC } from "react";
|
|
2
|
+
import type { FC, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
@@ -19,11 +19,13 @@ export interface BasicSelectProps extends SelectProps {
|
|
|
19
19
|
onGetOption?: (option: Record<string, any> | Record<string, any>[]) => void;
|
|
20
20
|
/** 获取数据 */
|
|
21
21
|
onGetData?: (data: Record<string, any>[]) => void;
|
|
22
|
+
/** 自定义 label 的渲染函数 */
|
|
23
|
+
labelRender?: (item: Record<string, any>) => ReactNode;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* 基础下拉组件(不建议直接使用此组件,二次继承使用)
|
|
26
28
|
*/
|
|
27
|
-
declare const
|
|
29
|
+
declare const BasicSelect: FC<BasicSelectProps>;
|
|
28
30
|
|
|
29
|
-
export default
|
|
31
|
+
export default BasicSelect;
|
|
@@ -14,6 +14,7 @@ function BasicSelect(props) {
|
|
|
14
14
|
data = [],
|
|
15
15
|
nameKey = "name",
|
|
16
16
|
idKey = "id",
|
|
17
|
+
labelRender,
|
|
17
18
|
...restProps
|
|
18
19
|
} = props;
|
|
19
20
|
|
|
@@ -59,7 +60,7 @@ function BasicSelect(props) {
|
|
|
59
60
|
<Select placeholder={`请选择${placeholder}`} showSearch allowClear optionFilterProp="children" onChange={handleChange} {...restProps}>
|
|
60
61
|
{data.map((item) => {
|
|
61
62
|
const value = item[idKey];
|
|
62
|
-
const label = item[nameKey];
|
|
63
|
+
const label = labelRender ? labelRender(item) : item[nameKey];
|
|
63
64
|
return (
|
|
64
65
|
<Select.Option key={value} value={value}>
|
|
65
66
|
{label}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import useGetUrlQuery from "../useGetUrlQuery";
|
|
3
|
-
|
|
4
|
-
const { query } = tools.router;
|
|
1
|
+
import useUrlState from "@ahooksjs/use-url-state";
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* 处理搜索条件缓存到 URL
|
|
8
5
|
*/
|
|
9
6
|
export default function useUrlQueryCriteria() {
|
|
7
|
+
const [state, setState] = useUrlState({
|
|
8
|
+
searchFormKeys: "",
|
|
9
|
+
searchFormValues: "",
|
|
10
|
+
paginationKeys: "",
|
|
11
|
+
paginationValues: "",
|
|
12
|
+
}, { navigateMode: "replace" });
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* 将搜索表单项和分页参数缓存到 URL 中
|
|
12
16
|
*/
|
|
@@ -35,20 +39,21 @@ export default function useUrlQueryCriteria() {
|
|
|
35
39
|
const paginationData = getJoinString(pagination);
|
|
36
40
|
|
|
37
41
|
// 将数据存储到 URL 查询参数中
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
setState({
|
|
43
|
+
searchFormKeys: searchFormData.keys || undefined,
|
|
44
|
+
searchFormValues: searchFormData.values || undefined,
|
|
45
|
+
paginationKeys: paginationData.keys || undefined,
|
|
46
|
+
paginationValues: paginationData.values || undefined,
|
|
47
|
+
});
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* 从 URL 中获取缓存的查询参数
|
|
46
52
|
*/
|
|
47
53
|
function getUrlCriteriaQuery(keysStr, valuesStr) {
|
|
48
|
-
const query = useGetUrlQuery();
|
|
49
54
|
// 将键值字符串分割为数组
|
|
50
|
-
const keys =
|
|
51
|
-
const values =
|
|
55
|
+
const keys = state[keysStr] ? state[keysStr].split(",") : [];
|
|
56
|
+
const values = state[valuesStr] ? state[valuesStr].split(",") : [];
|
|
52
57
|
|
|
53
58
|
// 构建结果对象
|
|
54
59
|
const resultMap = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zy-react-library",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.165",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "LiuJiaNan",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"postinstall": "echo 'Thanks for using our component library!'"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@ahooksjs/use-url-state": "^3.5.1",
|
|
25
26
|
"@ant-design/icons": "^6.1.0",
|
|
26
27
|
"@ant-design/pro-components": "^2.8.10",
|
|
27
28
|
"@cqsjjb/jjb-common-lib": "latest",
|
package/utils/index.d.ts
CHANGED
|
@@ -329,14 +329,14 @@ export function processTreeDataForOnlyLastLevel(
|
|
|
329
329
|
/**
|
|
330
330
|
* 验证结束时间是否大于开始时间
|
|
331
331
|
*/
|
|
332
|
-
export function validatorEndTime(timeStart: string, message
|
|
332
|
+
export function validatorEndTime(timeStart: string, message?: string): {
|
|
333
333
|
validator: (_: any, value: any) => Promise<void | string>;
|
|
334
334
|
};
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
337
|
* 验证时间是否大于等于当前时间
|
|
338
338
|
*/
|
|
339
|
-
export function validatorTimeGTCurrentDay(message
|
|
339
|
+
export function validatorTimeGTCurrentDay(message?: string): {
|
|
340
340
|
validator: (_: any, value: any) => Promise<void | string>;
|
|
341
341
|
};
|
|
342
342
|
|