zy-react-library 1.0.145 → 1.0.147

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.
@@ -12,6 +12,8 @@ export interface UseTableOptions<TData extends Data, TParams extends Params> ext
12
12
  defaultPagination?: { current: number; pageSize: number };
13
13
  /** 是否使用存储查询条件,默认是 */
14
14
  useStorageQueryCriteria?: boolean;
15
+ /** 是否使用数据权限,默认是 */
16
+ usePermission?: boolean;
15
17
  /** 额外参数 */
16
18
  params?: Record<string, any> | (() => Record<string, any>);
17
19
  /** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */
@@ -4,7 +4,7 @@ import useUrlQueryCriteria from "../useUrlQueryCriteria";
4
4
  /**
5
5
  * 获取数据
6
6
  */
7
- function getService(service, getExtraParams = {}, transform) {
7
+ function getService(service, getExtraParams = {}, transform, usePermission) {
8
8
  // 获取额外的参数
9
9
  const extraParams = (typeof getExtraParams === "function" ? getExtraParams() : getExtraParams) || {};
10
10
  // 获取数据
@@ -19,14 +19,18 @@ function getService(service, getExtraParams = {}, transform) {
19
19
  }
20
20
  }
21
21
 
22
- // 发起请求
23
- const res = await service({
22
+ const params = {
24
23
  pageIndex: current,
25
24
  pageSize,
26
25
  ...transformedFormData,
27
26
  ...extraParams,
28
- menuPath: window.location.pathname,
29
- });
27
+ }
28
+
29
+ if (usePermission)
30
+ params.menuPath = window.location.pathname
31
+
32
+ // 发起请求
33
+ const res = await service(params);
30
34
  // 返回数据
31
35
  return {
32
36
  list: res.data || [],
@@ -50,6 +54,7 @@ function useTable(service, options) {
50
54
  const {
51
55
  useStorageQueryCriteria = true,
52
56
  usePagination = true,
57
+ usePermission = true,
53
58
  defaultType = "advance",
54
59
  defaultCurrent = 1,
55
60
  defaultPageSize = 20,
@@ -70,7 +75,7 @@ function useTable(service, options) {
70
75
 
71
76
  // 调用 ahooks 的 useAntdTable
72
77
  const res = useAntdTable(
73
- getService(service, extraParams, transform),
78
+ getService(service, extraParams, transform, usePermission),
74
79
  {
75
80
  ...restRestOptions,
76
81
  defaultParams: [actualPagination, actualSearchForm],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.145",
4
+ "version": "1.0.147",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",
package/utils/index.d.ts CHANGED
@@ -334,9 +334,9 @@ export function validatorEndTime(timeStart: string): {
334
334
  };
335
335
 
336
336
  /**
337
- * 验证结束时间是否大于等于当前时间
337
+ * 验证时间是否大于等于当前时间
338
338
  */
339
- export function validatorEndTimeGTCurrentDay(): {
339
+ export function validatorTimeGTCurrentDay(): {
340
340
  validator: (_: any, value: any) => Promise<void | string>;
341
341
  };
342
342
 
package/utils/index.js CHANGED
@@ -525,13 +525,13 @@ export const validatorEndTime = (timeStart) => {
525
525
  }
526
526
 
527
527
  /**
528
- * 验证结束时间是否大于等于当前时间
528
+ * 验证时间是否大于等于当前时间
529
529
  */
530
- export const validatorEndTimeGTCurrentDay = () => {
530
+ export const validatorTimeGTCurrentDay = () => {
531
531
  return {
532
532
  validator: (_, value) => {
533
533
  if (value && value <= dayjs().format("YYYY-MM-DD hh:mm:ss")) {
534
- return Promise.reject("结束时间必须大于当前时间");
534
+ return Promise.reject("需要大于当前时间");
535
535
  }
536
536
  else {
537
537
  return Promise.resolve();