@cfmm/umi-plugins-ui-v2 0.0.21 → 0.0.22
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/cjs/components/MySelect.tpl +14 -2
- package/dist/cjs/components/PermissionSelect.tpl +1 -1
- package/dist/cjs/hooks/useRouteAuth.tpl +2 -2
- package/dist/esm/components/MySelect.tpl +14 -2
- package/dist/esm/components/PermissionSelect.tpl +1 -1
- package/dist/esm/hooks/useRouteAuth.tpl +2 -2
- package/package.json +1 -1
|
@@ -16,6 +16,18 @@ import { MySelectProps } from '../types';
|
|
|
16
16
|
|
|
17
17
|
const { Option } = Select;
|
|
18
18
|
|
|
19
|
+
/** 无对象、无键,或每个键的值均为 undefined / null / 空串(含纯空白)时视为“无搜索条件” */
|
|
20
|
+
function isSearchObjectAllEmpty(obj?: { [key: string]: string | undefined }): boolean {
|
|
21
|
+
if (!obj) return true;
|
|
22
|
+
const keys = Object.keys(obj);
|
|
23
|
+
if (keys.length === 0) return true;
|
|
24
|
+
return keys.every((key) => {
|
|
25
|
+
const v = obj[key];
|
|
26
|
+
if (v === undefined || v === null) return true;
|
|
27
|
+
return String(v).trim() === '';
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
20
32
|
const {
|
|
21
33
|
readonly,
|
|
@@ -102,7 +114,7 @@ const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
|
102
114
|
setListData([]);
|
|
103
115
|
let params = showSearch ? { ...searchValue, ...otherSearchValue } : otherSearchValue;
|
|
104
116
|
// 如果显示全部,则不分页
|
|
105
|
-
params = showAllList ? params : { pageIndex: 1, pageSize
|
|
117
|
+
params = showAllList ? params : { pageIndex: 1, pageSize, ...params };
|
|
106
118
|
const response = await request(params);
|
|
107
119
|
if (response.rows && response.rows.length > 0) {
|
|
108
120
|
// 如果有搜索值,则不添加回显值
|
|
@@ -121,7 +133,7 @@ const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
|
121
133
|
};
|
|
122
134
|
|
|
123
135
|
useEffect(() => {
|
|
124
|
-
if (Array.isArray(localListData) &&
|
|
136
|
+
if (Array.isArray(localListData) && isSearchObjectAllEmpty(searchValue)) {
|
|
125
137
|
setListData(localListData);
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
@@ -32,11 +32,11 @@ export const useRouteAuth = (currentUser?: CurrentUser) => {
|
|
|
32
32
|
}, [pathname, params]);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(status
|
|
35
|
+
* 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(item.status === '1' || item.status === 'Y')。
|
|
36
36
|
* 无需再区分「存在性」与「权限」两份列表。
|
|
37
37
|
*/
|
|
38
38
|
const validMenus = useMemo(
|
|
39
|
-
() => currentUser?.menus?.filter((item: any) => item.status === 'Y') ?? [],
|
|
39
|
+
() => currentUser?.menus?.filter((item: any) => item.status === '1' || item.status === 'Y') ?? [],
|
|
40
40
|
[currentUser?.menus],
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -16,6 +16,18 @@ import { MySelectProps } from '../types';
|
|
|
16
16
|
|
|
17
17
|
const { Option } = Select;
|
|
18
18
|
|
|
19
|
+
/** 无对象、无键,或每个键的值均为 undefined / null / 空串(含纯空白)时视为“无搜索条件” */
|
|
20
|
+
function isSearchObjectAllEmpty(obj?: { [key: string]: string | undefined }): boolean {
|
|
21
|
+
if (!obj) return true;
|
|
22
|
+
const keys = Object.keys(obj);
|
|
23
|
+
if (keys.length === 0) return true;
|
|
24
|
+
return keys.every((key) => {
|
|
25
|
+
const v = obj[key];
|
|
26
|
+
if (v === undefined || v === null) return true;
|
|
27
|
+
return String(v).trim() === '';
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
20
32
|
const {
|
|
21
33
|
readonly,
|
|
@@ -102,7 +114,7 @@ const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
|
102
114
|
setListData([]);
|
|
103
115
|
let params = showSearch ? { ...searchValue, ...otherSearchValue } : otherSearchValue;
|
|
104
116
|
// 如果显示全部,则不分页
|
|
105
|
-
params = showAllList ? params : { pageIndex: 1, pageSize
|
|
117
|
+
params = showAllList ? params : { pageIndex: 1, pageSize, ...params };
|
|
106
118
|
const response = await request(params);
|
|
107
119
|
if (response.rows && response.rows.length > 0) {
|
|
108
120
|
// 如果有搜索值,则不添加回显值
|
|
@@ -121,7 +133,7 @@ const MySelect = <T,>(props: MySelectProps<T>, ref: ForwardedRef<any>) => {
|
|
|
121
133
|
};
|
|
122
134
|
|
|
123
135
|
useEffect(() => {
|
|
124
|
-
if (Array.isArray(localListData) &&
|
|
136
|
+
if (Array.isArray(localListData) && isSearchObjectAllEmpty(searchValue)) {
|
|
125
137
|
setListData(localListData);
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
@@ -32,11 +32,11 @@ export const useRouteAuth = (currentUser?: CurrentUser) => {
|
|
|
32
32
|
}, [pathname, params]);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(status
|
|
35
|
+
* 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(item.status === '1' || item.status === 'Y')。
|
|
36
36
|
* 无需再区分「存在性」与「权限」两份列表。
|
|
37
37
|
*/
|
|
38
38
|
const validMenus = useMemo(
|
|
39
|
-
() => currentUser?.menus?.filter((item: any) => item.status === 'Y') ?? [],
|
|
39
|
+
() => currentUser?.menus?.filter((item: any) => item.status === '1' || item.status === 'Y') ?? [],
|
|
40
40
|
[currentUser?.menus],
|
|
41
41
|
);
|
|
42
42
|
|