@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.
@@ -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: 20, ...params };
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) && !showSearch) {
136
+ if (Array.isArray(localListData) && isSearchObjectAllEmpty(searchValue)) {
125
137
  setListData(localListData);
126
138
  return;
127
139
  }
@@ -19,7 +19,7 @@ export async function queryAllPermissions() {
19
19
  }
20
20
 
21
21
  const checkStatus = (status: string): boolean => {
22
- return status.toUpperCase() === 'Y';
22
+ return status === '1' || status === 'Y';
23
23
  }
24
24
 
25
25
  /**
@@ -32,11 +32,11 @@ export const useRouteAuth = (currentUser?: CurrentUser) => {
32
32
  }, [pathname, params]);
33
33
 
34
34
  /**
35
- * 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(status='Y')。
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: 20, ...params };
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) && !showSearch) {
136
+ if (Array.isArray(localListData) && isSearchObjectAllEmpty(searchValue)) {
125
137
  setListData(localListData);
126
138
  return;
127
139
  }
@@ -19,7 +19,7 @@ export async function queryAllPermissions() {
19
19
  }
20
20
 
21
21
  const checkStatus = (status: string): boolean => {
22
- return status.toUpperCase() === 'Y';
22
+ return status === '1' || status === 'Y';
23
23
  }
24
24
 
25
25
  /**
@@ -32,11 +32,11 @@ export const useRouteAuth = (currentUser?: CurrentUser) => {
32
32
  }, [pathname, params]);
33
33
 
34
34
  /**
35
- * 后端按权限下发菜单,返回的即为当前用户有权访问的全部菜单(status='Y')。
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
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cfmm/umi-plugins-ui-v2",
3
3
  "author": "ysj <411367308@qq.com>",
4
- "version": "0.0.21",
4
+ "version": "0.0.22",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
7
7
  "publishConfig": {