@zat-design/sisyphus-react 3.11.14-beta.13 → 3.11.14-beta.14

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.
@@ -4,7 +4,7 @@ import { DataOption } from '../propsType';
4
4
  * @param code
5
5
  * const [options,fn] = useEnum("code")
6
6
  */
7
- declare function useEnum(code: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
7
+ declare function useEnum(code?: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
8
8
  /**
9
9
  * input codes output { code1:DataOption[],code2:DataOption[] }
10
10
  * @param codes
@@ -17,5 +17,5 @@ declare function useEnum(codes: string[]): Record<string, DataOption[]>;
17
17
  * @param value
18
18
  * @param compose 展示 value-label
19
19
  */
20
- declare function useEnum(code: string, value?: string, compose?: boolean): [string, DataOption];
20
+ declare function useEnum(code?: string, value?: string, compose?: boolean): [string, DataOption];
21
21
  export default useEnum;
@@ -1,8 +1,17 @@
1
- var _ref;
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  /* eslint-disable no-redeclare */
3
3
  import { useProConfig } from '../../ProConfigProvider';
4
4
  import { getEnumData } from '../utils';
5
- var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
5
+ var baseEnumStorage = null;
6
+ try {
7
+ var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
8
+ if (storedData) {
9
+ baseEnumStorage = JSON.parse(storedData);
10
+ }
11
+ } catch (error) {
12
+ console.error('解析枚举缓存数据失败', error);
13
+ baseEnumStorage = null;
14
+ }
6
15
  /**
7
16
  * 根据 code 从枚举缓存取出对应的 options 、以及回显
8
17
  * @param codes
@@ -11,24 +20,44 @@ var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-compon
11
20
  * @returns
12
21
  */
13
22
  function useEnum(codes, value, compose) {
14
- var _ref2 = useProConfig('globalConfig') || {},
15
- _ref2$storage = _ref2.storage,
16
- storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
17
- var _ref3 = useProConfig('ProEnum') || {},
18
- _ref3$cacheKey = _ref3.cacheKey,
19
- cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
20
- _ref3$fieldNames = _ref3.fieldNames,
21
- fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
22
- _ref3$clear = _ref3.clear,
23
- clear = _ref3$clear === void 0 ? true : _ref3$clear;
24
- var catchData = getEnumData(storage, cacheKey, baseEnumStorage);
23
+ var _ref = useProConfig('globalConfig') || {},
24
+ _ref$storage = _ref.storage,
25
+ storage = _ref$storage === void 0 ? 'localStorage' : _ref$storage;
26
+ var _ref2 = useProConfig('ProEnum') || {},
27
+ _ref2$cacheKey = _ref2.cacheKey,
28
+ cacheKey = _ref2$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref2$cacheKey,
29
+ _ref2$fieldNames = _ref2.fieldNames,
30
+ fieldNames = _ref2$fieldNames === void 0 ? {} : _ref2$fieldNames,
31
+ _ref2$clear = _ref2.clear,
32
+ clear = _ref2$clear === void 0 ? true : _ref2$clear,
33
+ _ref2$dataSource = _ref2.dataSource,
34
+ dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
35
+ var catchData = getEnumData(storage, cacheKey, baseEnumStorage, dataSource);
25
36
  // 默认枚举缓存数据
26
37
  baseEnumStorage = catchData;
27
38
  if (!codes) {
39
+ if (!Object.keys(catchData).length) {
40
+ return [];
41
+ }
28
42
  return catchData;
29
43
  }
30
44
  var fieldLabel = '';
31
45
  var fieldValue = '';
46
+ // 获取枚举数据源
47
+ var enumDataSource = (catchData === null || catchData === void 0 ? void 0 : catchData.data) || {};
48
+ // 当dataSource有值时,检查是否需要合并
49
+ if (dataSource && Object.keys(dataSource).length > 0) {
50
+ // 创建合并后的数据源
51
+ var mergedDataSource = _objectSpread({}, enumDataSource);
52
+ // 遍历dataSource中的每个键
53
+ Object.keys(dataSource).forEach(function (key) {
54
+ // 如果enumDataSource中不存在该键或者该键对应的值为空数组,则合并
55
+ if (!enumDataSource[key] || enumDataSource[key].length === 0) {
56
+ mergedDataSource[key] = dataSource[key];
57
+ }
58
+ });
59
+ enumDataSource = mergedDataSource;
60
+ }
32
61
  if (fieldNames && Object.keys(fieldNames).length) {
33
62
  fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
34
63
  fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
@@ -38,8 +67,8 @@ function useEnum(codes, value, compose) {
38
67
  fieldValue = 'value';
39
68
  }
40
69
  if (typeof codes === 'string') {
41
- var _catchData$data;
42
- var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
70
+ var _enumDataSource;
71
+ var options = ((_enumDataSource = enumDataSource) === null || _enumDataSource === void 0 ? void 0 : _enumDataSource[codes]) || [];
43
72
  var getEnumLabel = function getEnumLabel(v, composezTow) {
44
73
  var option = options.find(function (item) {
45
74
  return item[fieldValue] === v;
@@ -62,8 +91,8 @@ function useEnum(codes, value, compose) {
62
91
  if (Array.isArray(codes)) {
63
92
  var _options = {};
64
93
  codes.forEach(function (code) {
65
- var _catchData$data2;
66
- var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
94
+ var _enumDataSource2;
95
+ var values = (_enumDataSource2 = enumDataSource) === null || _enumDataSource2 === void 0 ? void 0 : _enumDataSource2[code];
67
96
  if (Array.isArray(values) && values.length) {
68
97
  _options[code] = values;
69
98
  }
@@ -4,7 +4,14 @@ interface EnumRes {
4
4
  data: Record<string, DataOption[]>;
5
5
  [key: string]: any;
6
6
  }
7
- export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
7
+ /**
8
+ * 获取枚举数据
9
+ * @param storage
10
+ * @param cacheKey
11
+ * @param baseEnumStorage
12
+ * @returns
13
+ */
14
+ export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any, dataSource?: any[]): EnumRes;
8
15
  export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
9
16
  export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
10
17
  export declare function isObject(obj: any): boolean;
@@ -1,8 +1,15 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  var _excluded = ["children"];
3
3
  import { isNull, isUndefined } from 'lodash';
4
- export function getEnumData(storage, cacheKey, baseEnumStorage) {
5
- if (baseEnumStorage) {
4
+ /**
5
+ * 获取枚举数据
6
+ * @param storage
7
+ * @param cacheKey
8
+ * @param baseEnumStorage
9
+ * @returns
10
+ */
11
+ export function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
12
+ if (baseEnumStorage && cacheKey === 'zat-design-pro-component-cacheKey') {
6
13
  return baseEnumStorage;
7
14
  }
8
15
  if (storage === 'localStorage') {
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { ProTableTabsType } from '../../propsType';
3
+ declare const _default: import("react").MemoExoticComponent<(props: ProTableTabsType) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;
@@ -0,0 +1,78 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import "antd/es/tabs/style";
4
+ import _Tabs from "antd/es/tabs";
5
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
+ import "antd/es/form/style";
7
+ import _Form from "antd/es/form";
8
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { useMemo, useState, useEffect, memo } from 'react';
11
+ import useEnum from '../../../ProEnum/hooks/useEnum';
12
+ var RenderTabs = function RenderTabs(props) {
13
+ var code = props.code,
14
+ _props$dataSource = props.dataSource,
15
+ dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
16
+ transformResponse = props.transformResponse,
17
+ tabsProps = props.tabsProps,
18
+ name = props.name,
19
+ formTableProps = props.formTableProps;
20
+ var _ref = formTableProps || {},
21
+ form = _ref.form,
22
+ onSearch = _ref.onSearch;
23
+ var _useState = useState(props.activeKey),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ activeKey = _useState2[0],
26
+ setActiveKey = _useState2[1];
27
+ var _useEnum = useEnum(code),
28
+ _useEnum2 = _slicedToArray(_useEnum, 1),
29
+ options = _useEnum2[0];
30
+ var fieldValue = _Form.useWatch(name, form);
31
+ // 使用useMemo计算派生状态
32
+ var tabItems = useMemo(function () {
33
+ var defaultItems = [].concat(_toConsumableArray(dataSource), _toConsumableArray(options || []));
34
+ // 合并数据源并转换格式
35
+ var mergedData = defaultItems.map(function (item) {
36
+ return {
37
+ key: item.value,
38
+ label: item.label
39
+ };
40
+ });
41
+ if (transformResponse && typeof transformResponse === 'function') {
42
+ mergedData = transformResponse(defaultItems, formTableProps);
43
+ return mergedData.map(function (item) {
44
+ return {
45
+ key: String(item.value),
46
+ label: item.label
47
+ };
48
+ });
49
+ }
50
+ return mergedData.map(function (item) {
51
+ return {
52
+ key: String(item.key),
53
+ label: item.label
54
+ };
55
+ });
56
+ }, [dataSource, options, transformResponse]);
57
+ useEffect(function () {
58
+ var _tabItems$;
59
+ setActiveKey(fieldValue || (tabItems === null || tabItems === void 0 ? void 0 : (_tabItems$ = tabItems[0]) === null || _tabItems$ === void 0 ? void 0 : _tabItems$.key));
60
+ }, [fieldValue]);
61
+ if (!(tabItems === null || tabItems === void 0 ? void 0 : tabItems.length)) {
62
+ return null;
63
+ }
64
+ return _jsx(_Tabs, _objectSpread(_objectSpread({
65
+ className: "pro-table-tabs",
66
+ onChange: function onChange(key) {
67
+ var fieldsValues = (form === null || form === void 0 ? void 0 : form.getFieldsValue()) || {};
68
+ setActiveKey(key);
69
+ form.setFieldValue(name, key);
70
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(_objectSpread(_objectSpread({}, fieldsValues), {}, _defineProperty({}, name, key)));
71
+ },
72
+ type: "card"
73
+ }, tabsProps), {}, {
74
+ items: tabItems,
75
+ activeKey: activeKey
76
+ }));
77
+ };
78
+ export default /*#__PURE__*/memo(RenderTabs);
@@ -1,5 +1,30 @@
1
+ /**
2
+ * 表格可伸缩列组件
3
+ * @description 实现表格列宽可调整功能
4
+ */
1
5
  export { default as TableResizable } from './TableResizable';
6
+ /**
7
+ * 表格空数据渲染组件
8
+ * @description 当表格数据为空时的显示内容
9
+ */
2
10
  export { default as RenderEmptyText } from './RenderEmptyText';
11
+ /**
12
+ * 表格汇总行组件
13
+ * @description 用于渲染表格底部的汇总信息
14
+ */
3
15
  export { default as RenderSummary } from './RenderSummary';
16
+ /**
17
+ * 表格头部渲染组件
18
+ * @description 自定义表格头部区域,支持自定义内容和操作按钮
19
+ */
4
20
  export { default as RenderTableHeader } from './RenderTableHeader';
21
+ /**
22
+ * 表格底部渲染组件
23
+ * @description 自定义表格底部区域,支持添加额外操作按钮
24
+ */
5
25
  export { default as RenderFooter } from './RenderFooter';
26
+ /**
27
+ * 表格标签页组件
28
+ * @description 实现表格顶部的标签页切换功能,用于数据分类展示
29
+ */
30
+ export { default as RenderTabs } from './RenderTabs';
@@ -1,5 +1,30 @@
1
+ /**
2
+ * 表格可伸缩列组件
3
+ * @description 实现表格列宽可调整功能
4
+ */
1
5
  export { default as TableResizable } from './TableResizable';
6
+ /**
7
+ * 表格空数据渲染组件
8
+ * @description 当表格数据为空时的显示内容
9
+ */
2
10
  export { default as RenderEmptyText } from './RenderEmptyText';
11
+ /**
12
+ * 表格汇总行组件
13
+ * @description 用于渲染表格底部的汇总信息
14
+ */
3
15
  export { default as RenderSummary } from './RenderSummary';
16
+ /**
17
+ * 表格头部渲染组件
18
+ * @description 自定义表格头部区域,支持自定义内容和操作按钮
19
+ */
4
20
  export { default as RenderTableHeader } from './RenderTableHeader';
5
- export { default as RenderFooter } from './RenderFooter';
21
+ /**
22
+ * 表格底部渲染组件
23
+ * @description 自定义表格底部区域,支持添加额外操作按钮
24
+ */
25
+ export { default as RenderFooter } from './RenderFooter';
26
+ /**
27
+ * 表格标签页组件
28
+ * @description 实现表格顶部的标签页切换功能,用于数据分类展示
29
+ */
30
+ export { default as RenderTabs } from './RenderTabs';
@@ -1,95 +1,4 @@
1
- import { Key } from 'react';
2
1
  import { useRequest } from 'ahooks';
3
2
  import type { ProTableRequestOptionsType, ProTableServiceType } from '../propsType';
4
- declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]): {
5
- data: R[];
6
- params: any;
7
- rowSelection: {
8
- fixed: boolean;
9
- type: import("antd/es/table/interface").RowSelectionType;
10
- columnWidth: number;
11
- selectedRowKeys: Key[];
12
- onChange(rowKeys: Key[], rows: any[]): void;
13
- onSelectAll: (selected: boolean) => void;
14
- getCheckboxProps: (record?: any) => {
15
- className: string;
16
- };
17
- selections: boolean | ({
18
- key: string;
19
- text: string;
20
- onSelect: (changeableRowKeys: Key[]) => void;
21
- } | {
22
- key: string;
23
- text: any;
24
- onSelect: () => Promise<void>;
25
- })[];
26
- };
27
- searchValues: I;
28
- allSelected: boolean;
29
- selectedTip: string;
30
- selectedRowKeys: Key[];
31
- selectedRecords: R[];
32
- clearSelected: () => void;
33
- setSelectedRowKeys: (selectedRowKeys: Key[]) => void;
34
- setSelectedRecords: (selectedRecords: R[]) => void;
35
- pagination: {
36
- current: number;
37
- pageSize: number;
38
- showSizeChanger: boolean;
39
- showQuickJumper: boolean;
40
- onPaginationChange: boolean;
41
- total: number;
42
- showTotal: (total: any) => string;
43
- onShowSizeChange: (current: number, pageSize: number) => void;
44
- onChange: (current: number, pageSize: number) => void;
45
- };
46
- onReset: () => void;
47
- onSearch: (values: any) => void;
48
- refresh: () => Promise<void>;
49
- tableProps: {
50
- rowKey: string | import("rc-table/lib/interface").GetRowKey<R>;
51
- loading: boolean;
52
- dataSource: R[];
53
- rowSelection: {
54
- fixed: boolean;
55
- type: import("antd/es/table/interface").RowSelectionType;
56
- columnWidth: number;
57
- selectedRowKeys: Key[];
58
- onChange(rowKeys: Key[], rows: any[]): void;
59
- onSelectAll: (selected: boolean) => void;
60
- getCheckboxProps: (record?: any) => {
61
- className: string;
62
- };
63
- selections: boolean | ({
64
- key: string;
65
- text: string;
66
- onSelect: (changeableRowKeys: Key[]) => void;
67
- } | {
68
- key: string;
69
- text: any;
70
- onSelect: () => Promise<void>;
71
- })[];
72
- };
73
- pagination: {
74
- current: number;
75
- pageSize: number;
76
- showSizeChanger: boolean;
77
- showQuickJumper: boolean;
78
- onPaginationChange: boolean;
79
- total: number;
80
- showTotal: (total: any) => string;
81
- onShowSizeChange: (current: number, pageSize: number) => void;
82
- onChange: (current: number, pageSize: number) => void;
83
- };
84
- onChange: (pagination: any, filters: any, sorter: any, extra: any) => void;
85
- };
86
- handleSetStateCallback: (values: any) => void;
87
- loading: boolean;
88
- error?: Error;
89
- cancel: () => void;
90
- refreshAsync: () => Promise<unknown>;
91
- run: (...params: any[]) => void;
92
- runAsync: (...params: any[]) => Promise<unknown>;
93
- mutate: (data?: unknown) => void;
94
- };
3
+ declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]): any;
95
4
  export default useAntdTable;
@@ -9,7 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  var _excluded = ["page", "filters", "sorter"];
10
10
  import { useCallback, useEffect, useMemo, useState } from 'react';
11
11
  import { useRequest, useSetState, useDeepCompareEffect, usePrevious } from 'ahooks';
12
- import { pickBy, isObject, merge, set, isEqual } from 'lodash';
12
+ import { pickBy, isObject, merge, set, isEqual, omit } from 'lodash';
13
13
  import { defaultPage } from '../index';
14
14
  import { isListResult, removeEmptyKeys, isNonEmptyObject } from '../utils';
15
15
  import locale, { formatMessage } from '../../locale';
@@ -475,7 +475,7 @@ function useAntdTable(service, options, useRequestOptions) {
475
475
  onShowSizeChange: handlePageChange,
476
476
  onChange: handlePageChange
477
477
  };
478
- return _objectSpread(_objectSpread({}, result), {}, {
478
+ var useAntdTableProps = _objectSpread(_objectSpread({}, result), {}, {
479
479
  data: data,
480
480
  params: params,
481
481
  rowSelection: rowSelection,
@@ -509,5 +509,9 @@ function useAntdTable(service, options, useRequestOptions) {
509
509
  },
510
510
  handleSetStateCallback: handleSetStateCallback
511
511
  });
512
+ useAntdTableProps.tableProps.formTableProps = _objectSpread(_objectSpread({}, omit(useAntdTableProps, 'tableProps')), {}, {
513
+ form: form
514
+ });
515
+ return useAntdTableProps;
512
516
  }
513
517
  export default useAntdTable;
@@ -5,7 +5,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
5
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
6
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
8
- var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd"],
8
+ var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd", "tabs"],
9
9
  _excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
10
10
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { useEffect, useMemo, useState, createContext } from 'react';
@@ -13,7 +13,7 @@ import { get, keyBy, assign, isObject, isFunction, isBoolean } from 'lodash';
13
13
  import { useDebounceEffect, useDeepCompareEffect, useSetState } from 'ahooks';
14
14
  import classnames from 'classnames';
15
15
  import { useProConfig } from '../index';
16
- import { RenderTableHeader, RenderFooter } from './components';
16
+ import { RenderTableHeader, RenderFooter, RenderTabs } from './components';
17
17
  import useAntdTable from './hooks/useAntdTable';
18
18
  import { BaseTable, DraggableTable } from './components/RcTable';
19
19
  import { formatColumn } from './components/FormatColumn';
@@ -55,6 +55,7 @@ var ProTable = function ProTable(props) {
55
55
  diffConfig = props.diffConfig,
56
56
  onDragStartGuard = props.onDragStart,
57
57
  onDragEndGuard = props.onDragEnd,
58
+ tabs = props.tabs,
58
59
  restProps = _objectWithoutProperties(props, _excluded);
59
60
  var _props$scrollFollowPa = props.scrollFollowParent,
60
61
  scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
@@ -393,7 +394,9 @@ var ProTable = function ProTable(props) {
393
394
  },
394
395
  children: _jsxs("div", {
395
396
  className: cls,
396
- children: [_jsx(RenderTableHeader, {
397
+ children: [tabs && _jsx(RenderTabs, _objectSpread(_objectSpread({}, tabs), {}, {
398
+ formTableProps: restProps === null || restProps === void 0 ? void 0 : restProps.formTableProps
399
+ })), _jsx(RenderTableHeader, {
397
400
  dataSource: {
398
401
  headerRender: headerRender,
399
402
  columnConfig: columnConfig,
@@ -1,5 +1,6 @@
1
1
  import { Key, ReactNode } from 'react';
2
2
  import { TableProps } from 'antd/es/table/Table';
3
+ import { NamePath } from 'antd/es/form/interface';
3
4
  import { ColumnType, GetRowKey, RowSelectionType } from 'antd/es/table/interface';
4
5
  import { FormInstance } from 'antd';
5
6
  import type { TooltipProps } from 'antd';
@@ -314,6 +315,54 @@ export interface ProTableDiffConfigType {
314
315
  */
315
316
  addTipColor?: string;
316
317
  }
318
+ export interface ProTableTabsType {
319
+ /**
320
+ * 激活的 key
321
+ * @description 激活的 key
322
+ * @default undefined
323
+ */
324
+ activeKey?: string;
325
+ /**
326
+ * 枚举 code
327
+ * @description 枚举 code
328
+ * @default undefined
329
+ */
330
+ code?: string;
331
+ /**
332
+ * 枚举数据源
333
+ * @description 枚举数据源
334
+ * @default undefined
335
+ */
336
+ dataSource?: {
337
+ label: string;
338
+ value: string;
339
+ }[];
340
+ /**
341
+ * 枚举数据源转换
342
+ * @description 枚举数据源转换
343
+ * @default undefined
344
+ */
345
+ transformResponse?: (dataSource: {
346
+ label: string;
347
+ value: string;
348
+ }[], useAntdTableProps: ProTableUseAntdTableType<any, any>) => {
349
+ key: string;
350
+ label: string | ReactNode;
351
+ }[];
352
+ /**
353
+ * 标签属性
354
+ * @description 标签属性
355
+ * @default undefined
356
+ */
357
+ tabsProps?: TabsProps;
358
+ /**
359
+ * 表单字段名
360
+ * @description 表单字段名
361
+ * @default undefined
362
+ */
363
+ name: NamePath;
364
+ [key: string]: any;
365
+ }
317
366
  /**
318
367
  * ProTable 主要属性
319
368
  */
@@ -321,30 +370,25 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
321
370
  /**
322
371
  * table 唯一标识
323
372
  * @description 用于缓存和获取 columns 配置,在开启 resizeColumn/columnConfig 功能时需要传递以保证缓存和获取到正确的 columns 配置
324
- * @default undefined
373
+ * @default -
325
374
  */
326
375
  tableId?: string;
327
376
  /**
328
377
  * 表格 tabs查询 配置
329
378
  * @description 用于配置表格的 tabs 选项
330
- * @default undefined
379
+ * @default -
331
380
  */
332
- tabs?: {
333
- code: string;
334
- dataSource: any[];
335
- transformResponse?: (res: any) => any[];
336
- tabsProps?: TabsProps;
337
- };
381
+ tabs?: ProTableTabsType;
338
382
  /**
339
383
  * 表格行 key 的取值
340
384
  * @description 表格行数据的唯一标识字段
341
- * @default undefined
385
+ * @default -
342
386
  */
343
387
  rowKey?: string | GetRowKey<any>;
344
388
  /**
345
389
  * 自定义 table header 左侧渲染
346
390
  * @description 可以是 ReactNode 或返回 ReactNode 的函数
347
- * @default undefined
391
+ * @default -
348
392
  */
349
393
  headerRender?: ReactNode | (() => ReactNode);
350
394
  /**
@@ -394,7 +438,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
394
438
  /**
395
439
  * 自定义 table footer 左侧渲染
396
440
  * @description 可以是 ReactNode 或返回 ReactNode 的函数
397
- * @default undefined
441
+ * @default -
398
442
  */
399
443
  footerRender?: ReactNode | (() => ReactNode);
400
444
  /**
@@ -430,7 +474,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
430
474
  /**
431
475
  * 行禁用判断
432
476
  * @description 判断指定行是否禁用
433
- * @default undefined
477
+ * @default -
434
478
  */
435
479
  rowDisabled?: (record?: T) => string | boolean;
436
480
  /**
@@ -448,19 +492,19 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
448
492
  /**
449
493
  * 表单比对配置
450
494
  * @description 用于标记数据变化的配置
451
- * @default undefined
495
+ * @default -
452
496
  */
453
497
  diffConfig?: ProTableDiffConfigType;
454
498
  /**
455
499
  * 开始拖拽回调
456
500
  * @description 拖拽开始时触发
457
- * @default undefined
501
+ * @default -
458
502
  */
459
503
  onDragStart?: ProTableDragStartGuardType;
460
504
  /**
461
505
  * 结束拖拽回调
462
506
  * @description 拖拽结束时触发,务必返回变更后的数据源
463
- * @default undefined
507
+ * @default -
464
508
  */
465
509
  onDragEnd?: ProTableDragEndGuardType;
466
510
  /**
@@ -469,6 +513,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
469
513
  * @default true
470
514
  */
471
515
  scrollFollowParent?: boolean;
516
+ [key: string]: any;
472
517
  }
473
518
  /**
474
519
  * ProTable 值类型
@@ -702,6 +747,7 @@ export interface ProTableUseAntdTableType<I, R> {
702
747
  * @default false
703
748
  */
704
749
  allSelected: boolean;
750
+ [key: string]: any;
705
751
  }
706
752
  export type ProTableProps<T = any> = ProTableType<T>;
707
753
  export type ProTableColumn = ProTableColumnType;
@@ -4,7 +4,7 @@ import { DataOption } from '../propsType';
4
4
  * @param code
5
5
  * const [options,fn] = useEnum("code")
6
6
  */
7
- declare function useEnum(code: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
7
+ declare function useEnum(code?: string): [DataOption[], (val: string, showCodeName?: boolean) => string];
8
8
  /**
9
9
  * input codes output { code1:DataOption[],code2:DataOption[] }
10
10
  * @param codes
@@ -17,5 +17,5 @@ declare function useEnum(codes: string[]): Record<string, DataOption[]>;
17
17
  * @param value
18
18
  * @param compose 展示 value-label
19
19
  */
20
- declare function useEnum(code: string, value?: string, compose?: boolean): [string, DataOption];
20
+ declare function useEnum(code?: string, value?: string, compose?: boolean): [string, DataOption];
21
21
  export default useEnum;
@@ -1,14 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
7
9
  var _ProConfigProvider = require("../../ProConfigProvider");
8
10
  var _utils = require("../utils");
9
- var _ref;
10
11
  /* eslint-disable no-redeclare */
11
- var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-component-cacheKey') && JSON.parse(window.localStorage.getItem('zat-design-pro-component-cacheKey'))) !== null && _ref !== void 0 ? _ref : null;
12
+
13
+ var baseEnumStorage = null;
14
+ try {
15
+ var storedData = window.localStorage.getItem('zat-design-pro-component-cacheKey');
16
+ if (storedData) {
17
+ baseEnumStorage = JSON.parse(storedData);
18
+ }
19
+ } catch (error) {
20
+ console.error('解析枚举缓存数据失败', error);
21
+ baseEnumStorage = null;
22
+ }
12
23
  /**
13
24
  * 根据 code 从枚举缓存取出对应的 options 、以及回显
14
25
  * @param codes
@@ -17,24 +28,44 @@ var baseEnumStorage = (_ref = window.localStorage.getItem('zat-design-pro-compon
17
28
  * @returns
18
29
  */
19
30
  function useEnum(codes, value, compose) {
20
- var _ref2 = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
21
- _ref2$storage = _ref2.storage,
22
- storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage;
23
- var _ref3 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
24
- _ref3$cacheKey = _ref3.cacheKey,
25
- cacheKey = _ref3$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref3$cacheKey,
26
- _ref3$fieldNames = _ref3.fieldNames,
27
- fieldNames = _ref3$fieldNames === void 0 ? {} : _ref3$fieldNames,
28
- _ref3$clear = _ref3.clear,
29
- clear = _ref3$clear === void 0 ? true : _ref3$clear;
30
- var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage);
31
+ var _ref = (0, _ProConfigProvider.useProConfig)('globalConfig') || {},
32
+ _ref$storage = _ref.storage,
33
+ storage = _ref$storage === void 0 ? 'localStorage' : _ref$storage;
34
+ var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEnum') || {},
35
+ _ref2$cacheKey = _ref2.cacheKey,
36
+ cacheKey = _ref2$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref2$cacheKey,
37
+ _ref2$fieldNames = _ref2.fieldNames,
38
+ fieldNames = _ref2$fieldNames === void 0 ? {} : _ref2$fieldNames,
39
+ _ref2$clear = _ref2.clear,
40
+ clear = _ref2$clear === void 0 ? true : _ref2$clear,
41
+ _ref2$dataSource = _ref2.dataSource,
42
+ dataSource = _ref2$dataSource === void 0 ? {} : _ref2$dataSource;
43
+ var catchData = (0, _utils.getEnumData)(storage, cacheKey, baseEnumStorage, dataSource);
31
44
  // 默认枚举缓存数据
32
45
  baseEnumStorage = catchData;
33
46
  if (!codes) {
47
+ if (!Object.keys(catchData).length) {
48
+ return [];
49
+ }
34
50
  return catchData;
35
51
  }
36
52
  var fieldLabel = '';
37
53
  var fieldValue = '';
54
+ // 获取枚举数据源
55
+ var enumDataSource = (catchData === null || catchData === void 0 ? void 0 : catchData.data) || {};
56
+ // 当dataSource有值时,检查是否需要合并
57
+ if (dataSource && Object.keys(dataSource).length > 0) {
58
+ // 创建合并后的数据源
59
+ var mergedDataSource = (0, _objectSpread2.default)({}, enumDataSource);
60
+ // 遍历dataSource中的每个键
61
+ Object.keys(dataSource).forEach(function (key) {
62
+ // 如果enumDataSource中不存在该键或者该键对应的值为空数组,则合并
63
+ if (!enumDataSource[key] || enumDataSource[key].length === 0) {
64
+ mergedDataSource[key] = dataSource[key];
65
+ }
66
+ });
67
+ enumDataSource = mergedDataSource;
68
+ }
38
69
  if (fieldNames && Object.keys(fieldNames).length) {
39
70
  fieldLabel = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label;
40
71
  fieldValue = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
@@ -44,8 +75,8 @@ function useEnum(codes, value, compose) {
44
75
  fieldValue = 'value';
45
76
  }
46
77
  if (typeof codes === 'string') {
47
- var _catchData$data;
48
- var options = (catchData === null || catchData === void 0 ? void 0 : (_catchData$data = catchData.data) === null || _catchData$data === void 0 ? void 0 : _catchData$data[codes]) || [];
78
+ var _enumDataSource;
79
+ var options = ((_enumDataSource = enumDataSource) === null || _enumDataSource === void 0 ? void 0 : _enumDataSource[codes]) || [];
49
80
  var getEnumLabel = function getEnumLabel(v, composezTow) {
50
81
  var option = options.find(function (item) {
51
82
  return item[fieldValue] === v;
@@ -68,8 +99,8 @@ function useEnum(codes, value, compose) {
68
99
  if (Array.isArray(codes)) {
69
100
  var _options = {};
70
101
  codes.forEach(function (code) {
71
- var _catchData$data2;
72
- var values = catchData === null || catchData === void 0 ? void 0 : (_catchData$data2 = catchData.data) === null || _catchData$data2 === void 0 ? void 0 : _catchData$data2[code];
102
+ var _enumDataSource2;
103
+ var values = (_enumDataSource2 = enumDataSource) === null || _enumDataSource2 === void 0 ? void 0 : _enumDataSource2[code];
73
104
  if (Array.isArray(values) && values.length) {
74
105
  _options[code] = values;
75
106
  }
@@ -4,7 +4,14 @@ interface EnumRes {
4
4
  data: Record<string, DataOption[]>;
5
5
  [key: string]: any;
6
6
  }
7
- export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any): EnumRes;
7
+ /**
8
+ * 获取枚举数据
9
+ * @param storage
10
+ * @param cacheKey
11
+ * @param baseEnumStorage
12
+ * @returns
13
+ */
14
+ export declare function getEnumData(storage: StorageType, cacheKey: string, baseEnumStorage?: any, dataSource?: any[]): EnumRes;
8
15
  export declare function setEnumData(storage: StorageType, cacheKey: string, data: any): boolean;
9
16
  export declare function hasEnumList(storage: StorageType, cacheKey: any, code: string): import("../propsType").DataOptionType[];
10
17
  export declare function isObject(obj: any): boolean;
@@ -14,8 +14,15 @@ exports.setEnumData = setEnumData;
14
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
15
  var _lodash = require("lodash");
16
16
  var _excluded = ["children"];
17
- function getEnumData(storage, cacheKey, baseEnumStorage) {
18
- if (baseEnumStorage) {
17
+ /**
18
+ * 获取枚举数据
19
+ * @param storage
20
+ * @param cacheKey
21
+ * @param baseEnumStorage
22
+ * @returns
23
+ */
24
+ function getEnumData(storage, cacheKey, baseEnumStorage, dataSource) {
25
+ if (baseEnumStorage && cacheKey === 'zat-design-pro-component-cacheKey') {
19
26
  return baseEnumStorage;
20
27
  }
21
28
  if (storage === 'localStorage') {
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { ProTableTabsType } from '../../propsType';
3
+ declare const _default: import("react").MemoExoticComponent<(props: ProTableTabsType) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ var _antd = require("antd");
14
+ var _react = require("react");
15
+ var _useEnum3 = _interopRequireDefault(require("../../../ProEnum/hooks/useEnum"));
16
+ var RenderTabs = function RenderTabs(props) {
17
+ var code = props.code,
18
+ _props$dataSource = props.dataSource,
19
+ dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
20
+ transformResponse = props.transformResponse,
21
+ tabsProps = props.tabsProps,
22
+ name = props.name,
23
+ formTableProps = props.formTableProps;
24
+ var _ref = formTableProps || {},
25
+ form = _ref.form,
26
+ onSearch = _ref.onSearch;
27
+ var _useState = (0, _react.useState)(props.activeKey),
28
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
29
+ activeKey = _useState2[0],
30
+ setActiveKey = _useState2[1];
31
+ var _useEnum = (0, _useEnum3.default)(code),
32
+ _useEnum2 = (0, _slicedToArray2.default)(_useEnum, 1),
33
+ options = _useEnum2[0];
34
+ var fieldValue = _antd.Form.useWatch(name, form);
35
+ // 使用useMemo计算派生状态
36
+ var tabItems = (0, _react.useMemo)(function () {
37
+ var defaultItems = [].concat((0, _toConsumableArray2.default)(dataSource), (0, _toConsumableArray2.default)(options || []));
38
+ // 合并数据源并转换格式
39
+ var mergedData = defaultItems.map(function (item) {
40
+ return {
41
+ key: item.value,
42
+ label: item.label
43
+ };
44
+ });
45
+ if (transformResponse && typeof transformResponse === 'function') {
46
+ mergedData = transformResponse(defaultItems, formTableProps);
47
+ return mergedData.map(function (item) {
48
+ return {
49
+ key: String(item.value),
50
+ label: item.label
51
+ };
52
+ });
53
+ }
54
+ return mergedData.map(function (item) {
55
+ return {
56
+ key: String(item.key),
57
+ label: item.label
58
+ };
59
+ });
60
+ }, [dataSource, options, transformResponse]);
61
+ (0, _react.useEffect)(function () {
62
+ var _tabItems$;
63
+ setActiveKey(fieldValue || (tabItems === null || tabItems === void 0 ? void 0 : (_tabItems$ = tabItems[0]) === null || _tabItems$ === void 0 ? void 0 : _tabItems$.key));
64
+ }, [fieldValue]);
65
+ if (!(tabItems === null || tabItems === void 0 ? void 0 : tabItems.length)) {
66
+ return null;
67
+ }
68
+ return (0, _jsxRuntime.jsx)(_antd.Tabs, (0, _objectSpread3.default)((0, _objectSpread3.default)({
69
+ className: "pro-table-tabs",
70
+ onChange: function onChange(key) {
71
+ var fieldsValues = (form === null || form === void 0 ? void 0 : form.getFieldsValue()) || {};
72
+ setActiveKey(key);
73
+ form.setFieldValue(name, key);
74
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch((0, _objectSpread3.default)((0, _objectSpread3.default)({}, fieldsValues), {}, (0, _defineProperty2.default)({}, name, key)));
75
+ },
76
+ type: "card"
77
+ }, tabsProps), {}, {
78
+ items: tabItems,
79
+ activeKey: activeKey
80
+ }));
81
+ };
82
+ var _default = exports.default = /*#__PURE__*/(0, _react.memo)(RenderTabs);
@@ -1,5 +1,30 @@
1
+ /**
2
+ * 表格可伸缩列组件
3
+ * @description 实现表格列宽可调整功能
4
+ */
1
5
  export { default as TableResizable } from './TableResizable';
6
+ /**
7
+ * 表格空数据渲染组件
8
+ * @description 当表格数据为空时的显示内容
9
+ */
2
10
  export { default as RenderEmptyText } from './RenderEmptyText';
11
+ /**
12
+ * 表格汇总行组件
13
+ * @description 用于渲染表格底部的汇总信息
14
+ */
3
15
  export { default as RenderSummary } from './RenderSummary';
16
+ /**
17
+ * 表格头部渲染组件
18
+ * @description 自定义表格头部区域,支持自定义内容和操作按钮
19
+ */
4
20
  export { default as RenderTableHeader } from './RenderTableHeader';
21
+ /**
22
+ * 表格底部渲染组件
23
+ * @description 自定义表格底部区域,支持添加额外操作按钮
24
+ */
5
25
  export { default as RenderFooter } from './RenderFooter';
26
+ /**
27
+ * 表格标签页组件
28
+ * @description 实现表格顶部的标签页切换功能,用于数据分类展示
29
+ */
30
+ export { default as RenderTabs } from './RenderTabs';
@@ -28,6 +28,12 @@ Object.defineProperty(exports, "RenderTableHeader", {
28
28
  return _RenderTableHeader.default;
29
29
  }
30
30
  });
31
+ Object.defineProperty(exports, "RenderTabs", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _RenderTabs.default;
35
+ }
36
+ });
31
37
  Object.defineProperty(exports, "TableResizable", {
32
38
  enumerable: true,
33
39
  get: function get() {
@@ -38,4 +44,5 @@ var _TableResizable = _interopRequireDefault(require("./TableResizable"));
38
44
  var _RenderEmptyText = _interopRequireDefault(require("./RenderEmptyText"));
39
45
  var _RenderSummary = _interopRequireDefault(require("./RenderSummary"));
40
46
  var _RenderTableHeader = _interopRequireDefault(require("./RenderTableHeader"));
41
- var _RenderFooter = _interopRequireDefault(require("./RenderFooter"));
47
+ var _RenderFooter = _interopRequireDefault(require("./RenderFooter"));
48
+ var _RenderTabs = _interopRequireDefault(require("./RenderTabs"));
@@ -1,95 +1,4 @@
1
- import { Key } from 'react';
2
1
  import { useRequest } from 'ahooks';
3
2
  import type { ProTableRequestOptionsType, ProTableServiceType } from '../propsType';
4
- declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]): {
5
- data: R[];
6
- params: any;
7
- rowSelection: {
8
- fixed: boolean;
9
- type: import("antd/es/table/interface").RowSelectionType;
10
- columnWidth: number;
11
- selectedRowKeys: Key[];
12
- onChange(rowKeys: Key[], rows: any[]): void;
13
- onSelectAll: (selected: boolean) => void;
14
- getCheckboxProps: (record?: any) => {
15
- className: string;
16
- };
17
- selections: boolean | ({
18
- key: string;
19
- text: string;
20
- onSelect: (changeableRowKeys: Key[]) => void;
21
- } | {
22
- key: string;
23
- text: any;
24
- onSelect: () => Promise<void>;
25
- })[];
26
- };
27
- searchValues: I;
28
- allSelected: boolean;
29
- selectedTip: string;
30
- selectedRowKeys: Key[];
31
- selectedRecords: R[];
32
- clearSelected: () => void;
33
- setSelectedRowKeys: (selectedRowKeys: Key[]) => void;
34
- setSelectedRecords: (selectedRecords: R[]) => void;
35
- pagination: {
36
- current: number;
37
- pageSize: number;
38
- showSizeChanger: boolean;
39
- showQuickJumper: boolean;
40
- onPaginationChange: boolean;
41
- total: number;
42
- showTotal: (total: any) => string;
43
- onShowSizeChange: (current: number, pageSize: number) => void;
44
- onChange: (current: number, pageSize: number) => void;
45
- };
46
- onReset: () => void;
47
- onSearch: (values: any) => void;
48
- refresh: () => Promise<void>;
49
- tableProps: {
50
- rowKey: string | import("rc-table/lib/interface").GetRowKey<R>;
51
- loading: boolean;
52
- dataSource: R[];
53
- rowSelection: {
54
- fixed: boolean;
55
- type: import("antd/es/table/interface").RowSelectionType;
56
- columnWidth: number;
57
- selectedRowKeys: Key[];
58
- onChange(rowKeys: Key[], rows: any[]): void;
59
- onSelectAll: (selected: boolean) => void;
60
- getCheckboxProps: (record?: any) => {
61
- className: string;
62
- };
63
- selections: boolean | ({
64
- key: string;
65
- text: string;
66
- onSelect: (changeableRowKeys: Key[]) => void;
67
- } | {
68
- key: string;
69
- text: any;
70
- onSelect: () => Promise<void>;
71
- })[];
72
- };
73
- pagination: {
74
- current: number;
75
- pageSize: number;
76
- showSizeChanger: boolean;
77
- showQuickJumper: boolean;
78
- onPaginationChange: boolean;
79
- total: number;
80
- showTotal: (total: any) => string;
81
- onShowSizeChange: (current: number, pageSize: number) => void;
82
- onChange: (current: number, pageSize: number) => void;
83
- };
84
- onChange: (pagination: any, filters: any, sorter: any, extra: any) => void;
85
- };
86
- handleSetStateCallback: (values: any) => void;
87
- loading: boolean;
88
- error?: Error;
89
- cancel: () => void;
90
- refreshAsync: () => Promise<unknown>;
91
- run: (...params: any[]) => void;
92
- runAsync: (...params: any[]) => Promise<unknown>;
93
- mutate: (data?: unknown) => void;
94
- };
3
+ declare function useAntdTable<I, R extends Record<string, any>, S extends ProTableServiceType<I, R>>(service: S, options?: ProTableRequestOptionsType<I, R>, useRequestOptions?: Parameters<typeof useRequest>[1]): any;
95
4
  export default useAntdTable;
@@ -482,7 +482,7 @@ function useAntdTable(service, options, useRequestOptions) {
482
482
  onShowSizeChange: handlePageChange,
483
483
  onChange: handlePageChange
484
484
  };
485
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, result), {}, {
485
+ var useAntdTableProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, result), {}, {
486
486
  data: data,
487
487
  params: params,
488
488
  rowSelection: rowSelection,
@@ -516,5 +516,9 @@ function useAntdTable(service, options, useRequestOptions) {
516
516
  },
517
517
  handleSetStateCallback: handleSetStateCallback
518
518
  });
519
+ useAntdTableProps.tableProps.formTableProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(useAntdTableProps, 'tableProps')), {}, {
520
+ form: form
521
+ });
522
+ return useAntdTableProps;
519
523
  }
520
524
  var _default = exports.default = useAntdTable;
@@ -27,7 +27,7 @@ var _reset = _interopRequireDefault(require("../assets/reset.svg"));
27
27
  var _customColumn = _interopRequireDefault(require("../assets/customColumn.svg"));
28
28
  var _utils = require("./utils");
29
29
  var _locale = _interopRequireDefault(require("../locale"));
30
- var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd"],
30
+ var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "diffConfig", "onDragStart", "onDragEnd", "tabs"],
31
31
  _excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
32
32
  var defaultCacheTime = 1; // columns 配置保存时间为一天
33
33
  // 全局上下文
@@ -62,6 +62,7 @@ var ProTable = function ProTable(props) {
62
62
  diffConfig = props.diffConfig,
63
63
  onDragStartGuard = props.onDragStart,
64
64
  onDragEndGuard = props.onDragEnd,
65
+ tabs = props.tabs,
65
66
  restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
66
67
  var _props$scrollFollowPa = props.scrollFollowParent,
67
68
  scrollFollowParent = _props$scrollFollowPa === void 0 ? true : _props$scrollFollowPa;
@@ -400,7 +401,9 @@ var ProTable = function ProTable(props) {
400
401
  },
401
402
  children: (0, _jsxRuntime.jsxs)("div", {
402
403
  className: cls,
403
- children: [(0, _jsxRuntime.jsx)(_components.RenderTableHeader, {
404
+ children: [tabs && (0, _jsxRuntime.jsx)(_components.RenderTabs, (0, _objectSpread4.default)((0, _objectSpread4.default)({}, tabs), {}, {
405
+ formTableProps: restProps === null || restProps === void 0 ? void 0 : restProps.formTableProps
406
+ })), (0, _jsxRuntime.jsx)(_components.RenderTableHeader, {
404
407
  dataSource: {
405
408
  headerRender: headerRender,
406
409
  columnConfig: columnConfig,
@@ -1,5 +1,6 @@
1
1
  import { Key, ReactNode } from 'react';
2
2
  import { TableProps } from 'antd/es/table/Table';
3
+ import { NamePath } from 'antd/es/form/interface';
3
4
  import { ColumnType, GetRowKey, RowSelectionType } from 'antd/es/table/interface';
4
5
  import { FormInstance } from 'antd';
5
6
  import type { TooltipProps } from 'antd';
@@ -314,6 +315,54 @@ export interface ProTableDiffConfigType {
314
315
  */
315
316
  addTipColor?: string;
316
317
  }
318
+ export interface ProTableTabsType {
319
+ /**
320
+ * 激活的 key
321
+ * @description 激活的 key
322
+ * @default undefined
323
+ */
324
+ activeKey?: string;
325
+ /**
326
+ * 枚举 code
327
+ * @description 枚举 code
328
+ * @default undefined
329
+ */
330
+ code?: string;
331
+ /**
332
+ * 枚举数据源
333
+ * @description 枚举数据源
334
+ * @default undefined
335
+ */
336
+ dataSource?: {
337
+ label: string;
338
+ value: string;
339
+ }[];
340
+ /**
341
+ * 枚举数据源转换
342
+ * @description 枚举数据源转换
343
+ * @default undefined
344
+ */
345
+ transformResponse?: (dataSource: {
346
+ label: string;
347
+ value: string;
348
+ }[], useAntdTableProps: ProTableUseAntdTableType<any, any>) => {
349
+ key: string;
350
+ label: string | ReactNode;
351
+ }[];
352
+ /**
353
+ * 标签属性
354
+ * @description 标签属性
355
+ * @default undefined
356
+ */
357
+ tabsProps?: TabsProps;
358
+ /**
359
+ * 表单字段名
360
+ * @description 表单字段名
361
+ * @default undefined
362
+ */
363
+ name: NamePath;
364
+ [key: string]: any;
365
+ }
317
366
  /**
318
367
  * ProTable 主要属性
319
368
  */
@@ -321,30 +370,25 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
321
370
  /**
322
371
  * table 唯一标识
323
372
  * @description 用于缓存和获取 columns 配置,在开启 resizeColumn/columnConfig 功能时需要传递以保证缓存和获取到正确的 columns 配置
324
- * @default undefined
373
+ * @default -
325
374
  */
326
375
  tableId?: string;
327
376
  /**
328
377
  * 表格 tabs查询 配置
329
378
  * @description 用于配置表格的 tabs 选项
330
- * @default undefined
379
+ * @default -
331
380
  */
332
- tabs?: {
333
- code: string;
334
- dataSource: any[];
335
- transformResponse?: (res: any) => any[];
336
- tabsProps?: TabsProps;
337
- };
381
+ tabs?: ProTableTabsType;
338
382
  /**
339
383
  * 表格行 key 的取值
340
384
  * @description 表格行数据的唯一标识字段
341
- * @default undefined
385
+ * @default -
342
386
  */
343
387
  rowKey?: string | GetRowKey<any>;
344
388
  /**
345
389
  * 自定义 table header 左侧渲染
346
390
  * @description 可以是 ReactNode 或返回 ReactNode 的函数
347
- * @default undefined
391
+ * @default -
348
392
  */
349
393
  headerRender?: ReactNode | (() => ReactNode);
350
394
  /**
@@ -394,7 +438,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
394
438
  /**
395
439
  * 自定义 table footer 左侧渲染
396
440
  * @description 可以是 ReactNode 或返回 ReactNode 的函数
397
- * @default undefined
441
+ * @default -
398
442
  */
399
443
  footerRender?: ReactNode | (() => ReactNode);
400
444
  /**
@@ -430,7 +474,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
430
474
  /**
431
475
  * 行禁用判断
432
476
  * @description 判断指定行是否禁用
433
- * @default undefined
477
+ * @default -
434
478
  */
435
479
  rowDisabled?: (record?: T) => string | boolean;
436
480
  /**
@@ -448,19 +492,19 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
448
492
  /**
449
493
  * 表单比对配置
450
494
  * @description 用于标记数据变化的配置
451
- * @default undefined
495
+ * @default -
452
496
  */
453
497
  diffConfig?: ProTableDiffConfigType;
454
498
  /**
455
499
  * 开始拖拽回调
456
500
  * @description 拖拽开始时触发
457
- * @default undefined
501
+ * @default -
458
502
  */
459
503
  onDragStart?: ProTableDragStartGuardType;
460
504
  /**
461
505
  * 结束拖拽回调
462
506
  * @description 拖拽结束时触发,务必返回变更后的数据源
463
- * @default undefined
507
+ * @default -
464
508
  */
465
509
  onDragEnd?: ProTableDragEndGuardType;
466
510
  /**
@@ -469,6 +513,7 @@ export interface ProTableType<T = any> extends Omit<TableProps<any>, 'summary' |
469
513
  * @default true
470
514
  */
471
515
  scrollFollowParent?: boolean;
516
+ [key: string]: any;
472
517
  }
473
518
  /**
474
519
  * ProTable 值类型
@@ -702,6 +747,7 @@ export interface ProTableUseAntdTableType<I, R> {
702
747
  * @default false
703
748
  */
704
749
  allSelected: boolean;
750
+ [key: string]: any;
705
751
  }
706
752
  export type ProTableProps<T = any> = ProTableType<T>;
707
753
  export type ProTableColumn = ProTableColumnType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.11.14-beta.13",
3
+ "version": "3.11.14-beta.14",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "kisstkondoros.vscode-codemetrics"
4
- ]
5
- }
File without changes
File without changes