@ccs-ui/rc-pro 2.1.4 → 2.1.6
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/es/cascader/index.js +15 -23
- package/es/ccs.d.ts +4 -59
- package/es/config.js +2 -3
- package/es/context/index.d.ts +6 -16
- package/es/dialog/DialogRequestButton.d.ts +1 -1
- package/es/dialog/DialogRequestButton.js +1 -6
- package/es/dialog/DialogSelfOkButton.d.ts +1 -1
- package/es/dialog/hook.d.ts +7 -1
- package/es/hooks/use-app.d.ts +6 -17
- package/es/hooks/use-app.js +2 -41
- package/es/pro-table/index.d.ts +2 -5
- package/es/pro-table/table.d.ts +6 -3
- package/es/pro-table/table.js +59 -47
- package/es/pro-table/tree.d.ts +3 -7
- package/es/pro-table/tree.js +37 -43
- package/es/select/index.d.ts +1 -1
- package/es/select/index.js +5 -10
- package/es/table/index.js +16 -18
- package/es/theme-dialog.d.ts +6 -2
- package/package.json +1 -1
package/es/cascader/index.js
CHANGED
|
@@ -19,8 +19,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
19
|
import { useRequest } from 'ahooks';
|
|
20
20
|
import { Cascader } from 'antd';
|
|
21
21
|
import { useEffect } from 'react';
|
|
22
|
-
import {
|
|
23
|
-
import { getDataFromArrayField } from "../select";
|
|
22
|
+
import { getDataFromFields } from "../select";
|
|
24
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
24
|
function onIsArray(data) {
|
|
26
25
|
if (Array.isArray(data)) return data;
|
|
@@ -42,11 +41,6 @@ export default function CcsApiCascader(_ref) {
|
|
|
42
41
|
var labelField = _toConsumableArray(onIsArray((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || ['data', 'label']));
|
|
43
42
|
var valueField = _toConsumableArray(onIsArray((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || ['data', 'value']));
|
|
44
43
|
var childrenField = _toConsumableArray(onIsArray((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || ['data', 'children']));
|
|
45
|
-
|
|
46
|
-
// 上下午接口格式化方法
|
|
47
|
-
var _useApiCascaderInterc = useApiCascaderInterceptor(),
|
|
48
|
-
onRequestFormat = _useApiCascaderInterc.onRequestFormat,
|
|
49
|
-
onResponseFormat = _useApiCascaderInterc.onResponseFormat;
|
|
50
44
|
var _useRequest = useRequest( /*#__PURE__*/function () {
|
|
51
45
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
52
46
|
var result, value;
|
|
@@ -59,39 +53,37 @@ export default function CcsApiCascader(_ref) {
|
|
|
59
53
|
}
|
|
60
54
|
return _context.abrupt("return", []);
|
|
61
55
|
case 2:
|
|
62
|
-
_context.
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
_context.next = 4;
|
|
57
|
+
return onQuery(params);
|
|
58
|
+
case 4:
|
|
59
|
+
result = _context.sent;
|
|
65
60
|
case 5:
|
|
66
|
-
_context.t1 = _context.sent;
|
|
67
|
-
result = (0, _context.t0)(_context.t1);
|
|
68
|
-
case 7:
|
|
69
61
|
if (!(labelField.length > 0 || valueField.length > 0)) {
|
|
70
|
-
_context.next =
|
|
62
|
+
_context.next = 15;
|
|
71
63
|
break;
|
|
72
64
|
}
|
|
73
65
|
if (!Array.isArray(result)) {
|
|
74
|
-
_context.next =
|
|
66
|
+
_context.next = 9;
|
|
75
67
|
break;
|
|
76
68
|
}
|
|
77
69
|
result.forEach(function (r) {
|
|
78
|
-
r.label =
|
|
79
|
-
r.value =
|
|
80
|
-
r.children =
|
|
70
|
+
r.label = getDataFromFields(r, labelField);
|
|
71
|
+
r.value = getDataFromFields(r, valueField);
|
|
72
|
+
r.children = getDataFromFields(r, childrenField);
|
|
81
73
|
});
|
|
82
|
-
return _context.abrupt("break",
|
|
83
|
-
case
|
|
74
|
+
return _context.abrupt("break", 15);
|
|
75
|
+
case 9:
|
|
84
76
|
labelField.shift();
|
|
85
77
|
childrenField.shift();
|
|
86
78
|
value = valueField.shift();
|
|
87
79
|
if (value) {
|
|
88
80
|
result = result[value];
|
|
89
81
|
}
|
|
90
|
-
_context.next =
|
|
82
|
+
_context.next = 5;
|
|
91
83
|
break;
|
|
92
|
-
case
|
|
84
|
+
case 15:
|
|
93
85
|
return _context.abrupt("return", result);
|
|
94
|
-
case
|
|
86
|
+
case 16:
|
|
95
87
|
case "end":
|
|
96
88
|
return _context.stop();
|
|
97
89
|
}
|
package/es/ccs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonProps } from 'antd';
|
|
1
|
+
import { ButtonProps, PaginationProps } from 'antd';
|
|
2
2
|
import { Rule } from 'antd/es/form';
|
|
3
3
|
import { CSSProperties, MutableRefObject, ReactElement, ReactNode } from 'react';
|
|
4
4
|
import { TableColumn } from './pro-table/table';
|
|
@@ -21,64 +21,9 @@ type MenuType = {
|
|
|
21
21
|
type TableData<T> = {
|
|
22
22
|
/** loading */
|
|
23
23
|
loading?: boolean;
|
|
24
|
-
/** 总条数 */
|
|
25
|
-
totalNum?: number;
|
|
26
|
-
/** 单页记录数 */
|
|
27
|
-
pageSize?: number;
|
|
28
|
-
/** 页码 */
|
|
29
|
-
pageNo?: number;
|
|
30
24
|
/** Array List 数据 */
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
type HttpResult<T = any> = {
|
|
34
|
-
code?: string;
|
|
35
|
-
success?: boolean;
|
|
36
|
-
data?: T;
|
|
37
|
-
msg?: string;
|
|
38
|
-
};
|
|
39
|
-
type PageType<T> = {
|
|
40
|
-
hasNext: boolean;
|
|
41
|
-
totalNum: number;
|
|
42
|
-
pageNo: number;
|
|
43
|
-
pageSize: number;
|
|
44
|
-
result: T[];
|
|
45
|
-
};
|
|
46
|
-
type HttpPageResult<T = any> = Omit<HttpResult<T>, 'data'> & {
|
|
47
|
-
data: PageType<T>;
|
|
48
|
-
};
|
|
49
|
-
type HttpListResult<T = any> = Omit<HttpResult<T>, 'data'> & {
|
|
50
|
-
data: T[];
|
|
51
|
-
};
|
|
52
|
-
type OrderProp = {
|
|
53
|
-
ascending: boolean;
|
|
54
|
-
prop: string;
|
|
55
|
-
};
|
|
56
|
-
type QueryLimit = {
|
|
57
|
-
fetchSize: number;
|
|
58
|
-
startIndex: number;
|
|
59
|
-
};
|
|
60
|
-
type PageQuery<T = any> = {
|
|
61
|
-
/** 查询的开始行数和取多少行,从0开始 */
|
|
62
|
-
limit?: QueryLimit;
|
|
63
|
-
/** 排序字段,一般前端不传,由后端指定 */
|
|
64
|
-
orderProps?: OrderProp[];
|
|
65
|
-
/** 过滤字段 */
|
|
66
|
-
filters?: Record<string, any[]>;
|
|
67
|
-
/** 页码 */
|
|
68
|
-
pageNo?: number;
|
|
69
|
-
/** 页长 */
|
|
70
|
-
pageSize?: number;
|
|
71
|
-
/** 查询条件 */
|
|
72
|
-
query: T;
|
|
73
|
-
};
|
|
74
|
-
type ListQuery<T = any> = {
|
|
75
|
-
/** 查询的开始行数和取多少行,从0开始 */
|
|
76
|
-
limit?: QueryLimit;
|
|
77
|
-
/** 排序字段,一般前端不传,由后端指定 */
|
|
78
|
-
orderProps?: OrderProp[];
|
|
79
|
-
/** 查询条件 */
|
|
80
|
-
query: T;
|
|
81
|
-
};
|
|
25
|
+
dataSource?: T[];
|
|
26
|
+
} & PaginationProps;
|
|
82
27
|
type RecordType = Record<string, any>;
|
|
83
28
|
type RouteHistory = {
|
|
84
29
|
menuName: string;
|
|
@@ -185,4 +130,4 @@ type PropsWithNodeChildren = {
|
|
|
185
130
|
type PropsWithElementChildren = {
|
|
186
131
|
children?: ReactElement;
|
|
187
132
|
};
|
|
188
|
-
export type { AuthButtonItem,
|
|
133
|
+
export type { AuthButtonItem, MenuType, PropsWithCss, PropsWithElementChildren, PropsWithNodeChildren, RecordType, RouteHistory, TableColumns, TableData, TableFormItems, TableInstance, TableInstanceRef, TriggerChildrenProps, };
|
package/es/config.js
CHANGED
|
@@ -68,8 +68,7 @@ function AppConfig(_ref) {
|
|
|
68
68
|
isCompact = _ref.isCompact,
|
|
69
69
|
watermark = _ref.watermark,
|
|
70
70
|
themeConfig = _ref.themeConfig,
|
|
71
|
-
|
|
72
|
-
interceptors = _ref$interceptors === void 0 ? {} : _ref$interceptors;
|
|
71
|
+
CcsProTableFieldNames = _ref.CcsProTableFieldNames;
|
|
73
72
|
var holderRef = React.useRef(null);
|
|
74
73
|
// 主题
|
|
75
74
|
var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
|
|
@@ -98,7 +97,7 @@ function AppConfig(_ref) {
|
|
|
98
97
|
theme: theme,
|
|
99
98
|
themeConfig: themeConfig,
|
|
100
99
|
holderRef: holderRef,
|
|
101
|
-
|
|
100
|
+
CcsProTableFieldNames: CcsProTableFieldNames
|
|
102
101
|
},
|
|
103
102
|
children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(ElementsHolder, {
|
|
104
103
|
ref: holderRef
|
package/es/context/index.d.ts
CHANGED
|
@@ -48,12 +48,6 @@ type FnContextType<T = Store> = {
|
|
|
48
48
|
formInitialValues: T;
|
|
49
49
|
close: () => void;
|
|
50
50
|
};
|
|
51
|
-
type RequestType = {
|
|
52
|
-
/** 请求参数格式化 */
|
|
53
|
-
onRequestFormat?: (query: any) => any;
|
|
54
|
-
/** 返回参数格式化 */
|
|
55
|
-
onResponseFormat?: (response: any) => any;
|
|
56
|
-
};
|
|
57
51
|
type CssAppConfigType = {
|
|
58
52
|
/** 主题 */
|
|
59
53
|
theme?: 'dark' | 'light' | 'colorful';
|
|
@@ -65,16 +59,12 @@ type CssAppConfigType = {
|
|
|
65
59
|
watermark?: WaterMarkProps;
|
|
66
60
|
/** modal or drawer holder */
|
|
67
61
|
holderRef?: React.RefObject<ElementsHolderRef>;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/** 级联接口请求 */
|
|
75
|
-
CcsApiCascader?: RequestType;
|
|
76
|
-
/** 弹框表单请求 */
|
|
77
|
-
CcsDialog?: RequestType;
|
|
62
|
+
/** CcsProTable 组件字段全局指定 */
|
|
63
|
+
CcsProTableFieldNames?: {
|
|
64
|
+
dataSource: string[];
|
|
65
|
+
total: string[];
|
|
66
|
+
current: string[];
|
|
67
|
+
pageSize: string[];
|
|
78
68
|
};
|
|
79
69
|
};
|
|
80
70
|
declare const DrawerAndModalContext: React.Context<FnContextType<any>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormProps } from 'antd';
|
|
2
2
|
import { DialogFormRef } from './form';
|
|
3
3
|
import { CcsDialogModalProps } from './hook';
|
|
4
|
-
declare const DialogRequestButton: ({ auth, formRef, extraBtn, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "
|
|
4
|
+
declare const DialogRequestButton: ({ auth, formRef, extraBtn, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "onCancel" | "extraBtn" | "request" | "onRequestBefore"> & {
|
|
5
5
|
formRef: React.RefObject<DialogFormRef>;
|
|
6
6
|
formInitialValues: FormProps['initialValues'];
|
|
7
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,7 +17,6 @@ import CcsUtils from '@ccs-ui/utils';
|
|
|
17
17
|
import { Button } from 'antd';
|
|
18
18
|
import { useState } from 'react';
|
|
19
19
|
import { CcsButton, CcsDialog } from '..';
|
|
20
|
-
import { useDialogInterceptor } from "../hooks/use-app";
|
|
21
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
21
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -34,9 +33,6 @@ var DialogRequestButton = function DialogRequestButton(_ref) {
|
|
|
34
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
34
|
loading = _useState2[0],
|
|
36
35
|
setLoading = _useState2[1];
|
|
37
|
-
var _useDialogInterceptor = useDialogInterceptor(),
|
|
38
|
-
onRequestFormat = _useDialogInterceptor.onRequestFormat,
|
|
39
|
-
onResponseFormat = _useDialogInterceptor.onResponseFormat;
|
|
40
36
|
var onOk = /*#__PURE__*/function () {
|
|
41
37
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
42
38
|
var _formRef$current;
|
|
@@ -53,8 +49,7 @@ var DialogRequestButton = function DialogRequestButton(_ref) {
|
|
|
53
49
|
formRef.current.formInstance.validateFields().then(function (values) {
|
|
54
50
|
setLoading(true);
|
|
55
51
|
var params = _objectSpread(_objectSpread({}, formInitialValues), onRequestBefore ? onRequestBefore(values) : values);
|
|
56
|
-
request(
|
|
57
|
-
var result = onResponseFormat(e);
|
|
52
|
+
request(params).then(function (result) {
|
|
58
53
|
setLoading(false);
|
|
59
54
|
if (result !== null && result !== void 0 && result.success && onCancel) {
|
|
60
55
|
onCancel(params);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormProps } from 'antd';
|
|
2
2
|
import { DialogFormRef } from './form';
|
|
3
3
|
import { CcsDialogModalProps } from './hook';
|
|
4
|
-
declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "auth" | "onCancel" | "
|
|
4
|
+
declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "auth" | "onCancel" | "onOk" | "extraBtn"> & {
|
|
5
5
|
formRef: React.RefObject<DialogFormRef>;
|
|
6
6
|
formInitialValues: FormProps['initialValues'];
|
|
7
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/es/dialog/hook.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ type DrawerFunc = (props: CcsDialogDrawerProps) => {
|
|
|
17
17
|
destroy: () => void;
|
|
18
18
|
update: (configUpdate: CcsDialogDrawerProps) => void;
|
|
19
19
|
};
|
|
20
|
+
export type DialogRequestData = {
|
|
21
|
+
/** 成功标识 */
|
|
22
|
+
success: boolean;
|
|
23
|
+
/** 失败消息 */
|
|
24
|
+
msg: string;
|
|
25
|
+
};
|
|
20
26
|
export type CcsDialogModalProps = ModalFuncProps & {
|
|
21
27
|
/** antd form */
|
|
22
28
|
form?: FormProps;
|
|
@@ -27,7 +33,7 @@ export type CcsDialogModalProps = ModalFuncProps & {
|
|
|
27
33
|
/** 通过参数传递的扩展按钮 */
|
|
28
34
|
extraBtn?: ReactNode;
|
|
29
35
|
/** 表单接口请求 */
|
|
30
|
-
request?: (values: any) => Promise<
|
|
36
|
+
request?: (values: any) => Promise<DialogRequestData>;
|
|
31
37
|
/** request执行前参数处理 */
|
|
32
38
|
onRequestBefore?: (values: any) => any;
|
|
33
39
|
/** 通过closeDialog方法关闭dialog */
|
package/es/hooks/use-app.d.ts
CHANGED
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import { onDefaultFormat } from '../config';
|
|
2
1
|
/**
|
|
3
2
|
* app配置
|
|
4
3
|
* @returns
|
|
5
4
|
*/
|
|
6
5
|
declare const useAppConfig: () => import("../context").CssAppConfigType;
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onResponseFormat: typeof onDefaultFormat;
|
|
14
|
-
};
|
|
15
|
-
export declare const useApiSelectInterceptor: () => {
|
|
16
|
-
onRequestFormat: typeof onDefaultFormat;
|
|
17
|
-
onResponseFormat: typeof onDefaultFormat;
|
|
18
|
-
};
|
|
19
|
-
export declare const useDialogInterceptor: () => {
|
|
20
|
-
onRequestFormat: typeof onDefaultFormat;
|
|
21
|
-
onResponseFormat: typeof onDefaultFormat;
|
|
22
|
-
};
|
|
6
|
+
export declare const useProTableFields: () => {
|
|
7
|
+
dataSource: string[];
|
|
8
|
+
total: string[];
|
|
9
|
+
current: string[];
|
|
10
|
+
pageSize: string[];
|
|
11
|
+
} | undefined;
|
|
23
12
|
export default useAppConfig;
|
package/es/hooks/use-app.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
1
|
import { useContext } from 'react';
|
|
8
|
-
import { onDefaultFormat } from "../config";
|
|
9
2
|
import { AppConfigContext } from "../context";
|
|
10
3
|
|
|
11
4
|
/**
|
|
@@ -19,40 +12,8 @@ var useAppConfig = function useAppConfig() {
|
|
|
19
12
|
}
|
|
20
13
|
return context;
|
|
21
14
|
};
|
|
22
|
-
export var
|
|
23
|
-
var _context$interceptors;
|
|
15
|
+
export var useProTableFields = function useProTableFields() {
|
|
24
16
|
var context = useContext(AppConfigContext) || {};
|
|
25
|
-
|
|
26
|
-
onRequestFormat: onDefaultFormat,
|
|
27
|
-
onResponseFormat: onDefaultFormat
|
|
28
|
-
}, (_context$interceptors = context.interceptors) === null || _context$interceptors === void 0 ? void 0 : _context$interceptors.CcsProTable);
|
|
29
|
-
return interceptor;
|
|
30
|
-
};
|
|
31
|
-
export var useApiCascaderInterceptor = function useApiCascaderInterceptor() {
|
|
32
|
-
var _context$interceptors2;
|
|
33
|
-
var context = useContext(AppConfigContext) || {};
|
|
34
|
-
var interceptor = _objectSpread({
|
|
35
|
-
onRequestFormat: onDefaultFormat,
|
|
36
|
-
onResponseFormat: onDefaultFormat
|
|
37
|
-
}, (_context$interceptors2 = context.interceptors) === null || _context$interceptors2 === void 0 ? void 0 : _context$interceptors2.CcsApiCascader);
|
|
38
|
-
return interceptor;
|
|
39
|
-
};
|
|
40
|
-
export var useApiSelectInterceptor = function useApiSelectInterceptor() {
|
|
41
|
-
var _context$interceptors3;
|
|
42
|
-
var context = useContext(AppConfigContext) || {};
|
|
43
|
-
var interceptor = _objectSpread({
|
|
44
|
-
onRequestFormat: onDefaultFormat,
|
|
45
|
-
onResponseFormat: onDefaultFormat
|
|
46
|
-
}, (_context$interceptors3 = context.interceptors) === null || _context$interceptors3 === void 0 ? void 0 : _context$interceptors3.CcsApiSelect);
|
|
47
|
-
return interceptor;
|
|
48
|
-
};
|
|
49
|
-
export var useDialogInterceptor = function useDialogInterceptor() {
|
|
50
|
-
var _context$interceptors4;
|
|
51
|
-
var context = useContext(AppConfigContext) || {};
|
|
52
|
-
var interceptor = _objectSpread({
|
|
53
|
-
onRequestFormat: onDefaultFormat,
|
|
54
|
-
onResponseFormat: onDefaultFormat
|
|
55
|
-
}, (_context$interceptors4 = context.interceptors) === null || _context$interceptors4 === void 0 ? void 0 : _context$interceptors4.CcsDialog);
|
|
56
|
-
return interceptor;
|
|
17
|
+
return context === null || context === void 0 ? void 0 : context.CcsProTableFieldNames;
|
|
57
18
|
};
|
|
58
19
|
export default useAppConfig;
|
package/es/pro-table/index.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { HttpPageResult, HttpResult } from '../ccs';
|
|
2
1
|
import './index.less';
|
|
3
2
|
import { CcsProTableProps, SearchEventType } from './table';
|
|
4
3
|
type TableProps<T> = Omit<CcsProTableProps<T>, 'onSearchAfter' | 'parentFieldName'> & {
|
|
5
4
|
/** 请求后格式化结果 */
|
|
6
|
-
onSearchAfter?: (data:
|
|
5
|
+
onSearchAfter?: (data: any, eventType?: SearchEventType) => any;
|
|
7
6
|
};
|
|
8
7
|
type TableTreeProps<T> = Omit<CcsProTableProps<T>, 'onSearchAfter'> & {
|
|
9
8
|
/** 父级值字段 */
|
|
10
9
|
parentFieldName: string;
|
|
11
10
|
/** 请求后格式化结果 */
|
|
12
|
-
onSearchAfter?: (data:
|
|
13
|
-
children?: T[];
|
|
14
|
-
})[]>, eventType?: SearchEventType) => any;
|
|
11
|
+
onSearchAfter?: (data: any, eventType?: SearchEventType) => any;
|
|
15
12
|
};
|
|
16
13
|
/**
|
|
17
14
|
* 查询表格组件
|
package/es/pro-table/table.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { ColumnGroupType, ColumnType } from 'antd/es/table';
|
|
|
3
3
|
import { TableSticky } from 'rc-table/lib/interface';
|
|
4
4
|
import React, { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
5
5
|
import CCS from '..';
|
|
6
|
-
import {
|
|
6
|
+
import { PropsWithCss, PropsWithNodeChildren, TableColumns } from '../ccs';
|
|
7
|
+
import { CssAppConfigType } from '../context';
|
|
7
8
|
import './index.less';
|
|
8
9
|
type ParamType = Record<string, any>;
|
|
9
10
|
export type ShowDependType = {
|
|
@@ -29,8 +30,10 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
|
|
|
29
30
|
data?: CCS.TableData<T>;
|
|
30
31
|
/** request 方法 */
|
|
31
32
|
request?: (params: any) => Promise<any>;
|
|
32
|
-
/** request 额外参数 */
|
|
33
|
+
/** request 额外参数 dataSource: ['data', 'result']; current: ['data', 'pageNo']; pageSize: ['data', 'pageSize']; total: ['data', 'totalNum'] */
|
|
33
34
|
requestParam?: ParamType;
|
|
35
|
+
/** 接口字段指定,默认: */
|
|
36
|
+
fieldNames?: CssAppConfigType['CcsProTableFieldNames'];
|
|
34
37
|
/** class name */
|
|
35
38
|
className?: string;
|
|
36
39
|
/** style */
|
|
@@ -78,7 +81,7 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
|
|
|
78
81
|
/** 请求前格式化参数 */
|
|
79
82
|
onSearchBefore?: (params: SearchBeforeType, eventType?: SearchEventType) => SearchBeforeType;
|
|
80
83
|
/** 请求后格式化结果 */
|
|
81
|
-
onSearchAfter?: (
|
|
84
|
+
onSearchAfter?: (result: any, eventType?: SearchEventType) => any;
|
|
82
85
|
};
|
|
83
86
|
export type TableEventType = {
|
|
84
87
|
key: 'columnFilter' | 'fullScreen';
|
package/es/pro-table/table.js
CHANGED
|
@@ -20,7 +20,9 @@ import classNames from 'classnames';
|
|
|
20
20
|
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
21
21
|
import { useAppConfig } from '..';
|
|
22
22
|
import { useCcsPage } from "../";
|
|
23
|
-
import {
|
|
23
|
+
import { onDefaultFormat } from "../config";
|
|
24
|
+
import { useProTableFields } from "../hooks/use-app";
|
|
25
|
+
import { getDataFromFields } from "../select";
|
|
24
26
|
import CcsTable from "../table";
|
|
25
27
|
import { getAllChildrenId, getDataById, onTableInModalOrDrawer, onTableInTabItem } from "./_utils";
|
|
26
28
|
import HeadComponent from "./head";
|
|
@@ -42,7 +44,7 @@ export var TableSelectionContext = /*#__PURE__*/React.createContext({
|
|
|
42
44
|
* @returns
|
|
43
45
|
*/
|
|
44
46
|
var InternalProTable = function InternalProTable(props) {
|
|
45
|
-
var _table$scroll2, _table$scroll3;
|
|
47
|
+
var _props$table, _table$scroll2, _table$scroll3;
|
|
46
48
|
var init = props.init,
|
|
47
49
|
auth = props.auth,
|
|
48
50
|
table = props.table,
|
|
@@ -59,9 +61,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
59
61
|
formItems = _props$formItems === void 0 ? [] : _props$formItems,
|
|
60
62
|
parentFieldName = props.parentFieldName,
|
|
61
63
|
_props$formInitValues = props.formInitValues,
|
|
62
|
-
formInitValues = _props$formInitValues === void 0 ? {} : _props$formInitValues
|
|
63
|
-
onSearchBefore = props.onSearchBefore,
|
|
64
|
-
onSearchAfter = props.onSearchAfter;
|
|
64
|
+
formInitValues = _props$formInitValues === void 0 ? {} : _props$formInitValues;
|
|
65
65
|
var _useCcsPage = useCcsPage(),
|
|
66
66
|
onAuth = _useCcsPage.onAuth;
|
|
67
67
|
var _ref = table || {},
|
|
@@ -87,10 +87,10 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
87
87
|
form = _Form$useForm2[0];
|
|
88
88
|
// table data
|
|
89
89
|
var _useState = useState({
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
total: 0,
|
|
91
|
+
dataSource: [],
|
|
92
92
|
pageSize: 10,
|
|
93
|
-
|
|
93
|
+
current: 1
|
|
94
94
|
}),
|
|
95
95
|
_useState2 = _slicedToArray(_useState, 2),
|
|
96
96
|
data = _useState2[0],
|
|
@@ -107,10 +107,17 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
107
107
|
// 上下文配置
|
|
108
108
|
var _useAppConfig = useAppConfig(),
|
|
109
109
|
theme = _useAppConfig.theme;
|
|
110
|
-
//
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
// 接口字段指定全局配置
|
|
111
|
+
var globalFieldNames = useProTableFields();
|
|
112
|
+
// 接口字段指定
|
|
113
|
+
var fieldNames = ((_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames) || globalFieldNames || {
|
|
114
|
+
dataSource: ['data', 'result'],
|
|
115
|
+
current: ['data', 'pageNo'],
|
|
116
|
+
pageSize: ['data', 'pageSize'],
|
|
117
|
+
total: ['data', 'totalNum']
|
|
118
|
+
};
|
|
119
|
+
var onSearchBefore = props.onSearchBefore || onDefaultFormat;
|
|
120
|
+
var onSearchAfter = props.onSearchAfter || onDefaultFormat;
|
|
114
121
|
|
|
115
122
|
// 暗黑模式
|
|
116
123
|
var isDark = theme === 'dark';
|
|
@@ -163,12 +170,11 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
163
170
|
_treeRef$current,
|
|
164
171
|
newParams,
|
|
165
172
|
requestResult,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
result,
|
|
173
|
+
newReqResult,
|
|
174
|
+
dataSource,
|
|
175
|
+
_pageSize,
|
|
176
|
+
current,
|
|
177
|
+
total,
|
|
172
178
|
_args = arguments;
|
|
173
179
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
174
180
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -200,56 +206,61 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
200
206
|
return _context.abrupt("return");
|
|
201
207
|
case 7:
|
|
202
208
|
// onSearchBefore 请求前回传参数,可以在父组件进行修改
|
|
203
|
-
newParams = onSearchBefore
|
|
209
|
+
newParams = onSearchBefore(params, eventType); // 发起请求
|
|
204
210
|
setData(function (d) {
|
|
205
211
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
206
212
|
loading: true
|
|
207
213
|
});
|
|
208
214
|
});
|
|
209
|
-
_context.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (!(requestResult && requestResult.success)) {
|
|
216
|
-
_context.next = 24;
|
|
215
|
+
_context.next = 11;
|
|
216
|
+
return httpRequest(_objectSpread({}, newParams));
|
|
217
|
+
case 11:
|
|
218
|
+
requestResult = _context.sent;
|
|
219
|
+
if (!requestResult) {
|
|
220
|
+
_context.next = 25;
|
|
217
221
|
break;
|
|
218
222
|
}
|
|
219
223
|
// onSearchAfter 处理请求结果
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
newReqResult = onSearchAfter(requestResult, eventType); // 获取table数据
|
|
225
|
+
dataSource = getDataFromFields(newReqResult, fieldNames.dataSource);
|
|
226
|
+
_pageSize = getDataFromFields(newReqResult, fieldNames.pageSize);
|
|
227
|
+
current = getDataFromFields(newReqResult, fieldNames.current);
|
|
228
|
+
total = getDataFromFields(newReqResult, fieldNames.total);
|
|
229
|
+
if (!(total === undefined || _pageSize === undefined || current === undefined || dataSource === undefined)) {
|
|
230
|
+
_context.next = 22;
|
|
224
231
|
break;
|
|
225
232
|
}
|
|
226
|
-
CcsUtils.showLogWarning('分页返回对象,
|
|
227
|
-
setData(
|
|
233
|
+
CcsUtils.showLogWarning('分页返回对象,total,pageSize,current,dataSource不能为空');
|
|
234
|
+
setData({
|
|
235
|
+
dataSource: dataSource,
|
|
236
|
+
pageSize: _pageSize,
|
|
237
|
+
current: current,
|
|
238
|
+
total: total,
|
|
228
239
|
loading: false
|
|
229
|
-
})
|
|
240
|
+
});
|
|
230
241
|
return _context.abrupt("return");
|
|
231
|
-
case
|
|
242
|
+
case 22:
|
|
232
243
|
// 当前页无数据,返回上一页
|
|
233
|
-
if (!
|
|
234
|
-
onRequest('reload',
|
|
244
|
+
if (!dataSource.length && current !== 1 && current !== undefined) {
|
|
245
|
+
onRequest('reload', current - 1);
|
|
235
246
|
} else {
|
|
236
247
|
setData({
|
|
237
|
-
|
|
238
|
-
pageSize:
|
|
248
|
+
current: current,
|
|
249
|
+
pageSize: _pageSize,
|
|
239
250
|
loading: false,
|
|
240
|
-
|
|
241
|
-
|
|
251
|
+
dataSource: dataSource,
|
|
252
|
+
total: total || 0
|
|
242
253
|
});
|
|
243
254
|
}
|
|
244
|
-
_context.next =
|
|
255
|
+
_context.next = 26;
|
|
245
256
|
break;
|
|
246
|
-
case
|
|
257
|
+
case 25:
|
|
247
258
|
setData(function (d) {
|
|
248
259
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
249
260
|
loading: false
|
|
250
261
|
});
|
|
251
262
|
});
|
|
252
|
-
case
|
|
263
|
+
case 26:
|
|
253
264
|
case "end":
|
|
254
265
|
return _context.stop();
|
|
255
266
|
}
|
|
@@ -270,7 +281,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
270
281
|
var _onPartialReload = function onPartialReload(id) {
|
|
271
282
|
var _treeRef$current2, _treeRef$current3;
|
|
272
283
|
// 查找需要刷新的节点
|
|
273
|
-
var treeNode = getDataById(data.
|
|
284
|
+
var treeNode = getDataById(data.dataSource || [], rowKey, id);
|
|
274
285
|
// 没有查找到、全部刷新
|
|
275
286
|
if (!treeNode) {
|
|
276
287
|
onRequest('search');
|
|
@@ -337,7 +348,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
337
348
|
|
|
338
349
|
// 刷新
|
|
339
350
|
var _onReload = function onReload() {
|
|
340
|
-
onRequest('reload', data.
|
|
351
|
+
onRequest('reload', data.current, data.pageSize);
|
|
341
352
|
};
|
|
342
353
|
|
|
343
354
|
// form 数据 查询,重载,重置方法
|
|
@@ -456,7 +467,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
456
467
|
// table title
|
|
457
468
|
var tableTitle = table.title ? table.title({
|
|
458
469
|
selectedRows: selectedRows,
|
|
459
|
-
data: data.
|
|
470
|
+
data: data.dataSource || [],
|
|
460
471
|
onClear: function onClear() {
|
|
461
472
|
return setSelectedRows([]);
|
|
462
473
|
}
|
|
@@ -467,6 +478,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
467
478
|
return /*#__PURE__*/_jsx(TableTree, {
|
|
468
479
|
data: data,
|
|
469
480
|
table: _objectSpread(_objectSpread({}, table), {}, {
|
|
481
|
+
fieldNames: fieldNames,
|
|
470
482
|
rowSelection: rowSelection,
|
|
471
483
|
title: tableTitle ? function () {
|
|
472
484
|
return tableTitle;
|
package/es/pro-table/tree.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ import { TableProps } from 'antd';
|
|
|
2
2
|
import { TableSticky } from 'rc-table/lib/interface';
|
|
3
3
|
import { RefObject } from 'react';
|
|
4
4
|
import CCS from '..';
|
|
5
|
-
import { HttpResult } from '../ccs';
|
|
6
5
|
import { TableRefType } from '../table';
|
|
7
|
-
import { CcsProTableProps
|
|
6
|
+
import { CcsProTableProps } from './table';
|
|
8
7
|
export type TreeInstance<T> = {
|
|
9
8
|
onRequestTree: (query: any, record: T | any) => void;
|
|
10
9
|
onExpandKeys: (ids: string[]) => void;
|
|
11
10
|
};
|
|
12
|
-
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' | 'parentFieldName'> & {
|
|
11
|
+
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' | 'parentFieldName' | 'onSearchAfter'> & {
|
|
13
12
|
data: CCS.TableData<T>;
|
|
14
13
|
sticky: boolean | TableSticky;
|
|
15
14
|
tableRowSize: TableProps['size'];
|
|
@@ -18,9 +17,6 @@ type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' |
|
|
|
18
17
|
tableContentRef: React.RefObject<HTMLDivElement>;
|
|
19
18
|
setData: React.Dispatch<React.SetStateAction<CCS.TableData<T>>>;
|
|
20
19
|
handlePageChange: any;
|
|
21
|
-
onSearchAfter: (data: HttpResult<T[]>, eventType?: SearchEventType) => HttpResult<(T & {
|
|
22
|
-
children: T[];
|
|
23
|
-
})[]>;
|
|
24
20
|
};
|
|
25
|
-
declare const TableTree: <T extends object = any>(
|
|
21
|
+
declare const TableTree: <T extends object = any>(props: TreeTableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
26
22
|
export default TableTree;
|
package/es/pro-table/tree.js
CHANGED
|
@@ -20,48 +20,44 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
20
20
|
import CcsUtils from '@ccs-ui/utils';
|
|
21
21
|
import { useImperativeHandle, useState } from 'react';
|
|
22
22
|
import { CcsTable } from '..';
|
|
23
|
-
import {
|
|
23
|
+
import { getDataFromFields } from "../select";
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
-
var TableTree = function TableTree(
|
|
26
|
-
var data =
|
|
27
|
-
table =
|
|
28
|
-
sticky =
|
|
29
|
-
treeRef =
|
|
30
|
-
tableRef =
|
|
31
|
-
tableRowSize =
|
|
32
|
-
tableContentRef =
|
|
33
|
-
parentFieldName =
|
|
34
|
-
handlePageChange =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
var TableTree = function TableTree(props) {
|
|
26
|
+
var data = props.data,
|
|
27
|
+
table = props.table,
|
|
28
|
+
sticky = props.sticky,
|
|
29
|
+
treeRef = props.treeRef,
|
|
30
|
+
tableRef = props.tableRef,
|
|
31
|
+
tableRowSize = props.tableRowSize,
|
|
32
|
+
tableContentRef = props.tableContentRef,
|
|
33
|
+
parentFieldName = props.parentFieldName,
|
|
34
|
+
handlePageChange = props.handlePageChange,
|
|
35
|
+
onSearchAfter = props.onSearchAfter,
|
|
36
|
+
onSearchBefore = props.onSearchBefore,
|
|
37
|
+
setData = props.setData;
|
|
38
38
|
// async tree expand key
|
|
39
39
|
var _useState = useState([]),
|
|
40
40
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
41
|
expandKeys = _useState2[0],
|
|
42
42
|
setExpandKeys = _useState2[1];
|
|
43
|
-
var
|
|
44
|
-
rowKey =
|
|
45
|
-
expandable =
|
|
46
|
-
columns =
|
|
47
|
-
httpRequest =
|
|
43
|
+
var _ref = table,
|
|
44
|
+
rowKey = _ref.rowKey,
|
|
45
|
+
expandable = _ref.expandable,
|
|
46
|
+
columns = _ref.columns,
|
|
47
|
+
httpRequest = _ref.request,
|
|
48
|
+
fieldNames = _ref.fieldNames;
|
|
48
49
|
var childrenColumnName = (expandable === null || expandable === void 0 ? void 0 : expandable.childrenColumnName) || 'children';
|
|
49
50
|
|
|
50
|
-
// 接口格式化方法
|
|
51
|
-
var _useProTableIntercept = useProTableInterceptor(),
|
|
52
|
-
onRequestFormat = _useProTableIntercept.onRequestFormat,
|
|
53
|
-
onResponseFormat = _useProTableIntercept.onResponseFormat;
|
|
54
|
-
|
|
55
51
|
// 获取数据
|
|
56
52
|
var _onRequestTree = /*#__PURE__*/function () {
|
|
57
|
-
var
|
|
53
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
58
54
|
var query,
|
|
59
55
|
record,
|
|
60
56
|
params,
|
|
61
57
|
newParams,
|
|
62
58
|
requestResult,
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
newReqResult,
|
|
60
|
+
dataSource,
|
|
65
61
|
_args = arguments;
|
|
66
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67
63
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -74,7 +70,7 @@ var TableTree = function TableTree(_ref) {
|
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
// onSearchBefore 请求前回传参数,可以在父组件进行修改
|
|
77
|
-
newParams = onSearchBefore
|
|
73
|
+
newParams = onSearchBefore(params); // 发起请求
|
|
78
74
|
setData(function (d) {
|
|
79
75
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
80
76
|
loading: true
|
|
@@ -82,28 +78,26 @@ var TableTree = function TableTree(_ref) {
|
|
|
82
78
|
});
|
|
83
79
|
_context.t0 = httpRequest;
|
|
84
80
|
if (!_context.t0) {
|
|
85
|
-
_context.next =
|
|
81
|
+
_context.next = 11;
|
|
86
82
|
break;
|
|
87
83
|
}
|
|
88
|
-
_context.
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
_context.next = 10;
|
|
85
|
+
return httpRequest(_objectSpread({}, newParams));
|
|
86
|
+
case 10:
|
|
87
|
+
_context.t0 = _context.sent;
|
|
91
88
|
case 11:
|
|
92
|
-
_context.t2 = _context.sent;
|
|
93
|
-
_context.t0 = (0, _context.t1)(_context.t2);
|
|
94
|
-
case 13:
|
|
95
89
|
requestResult = _context.t0;
|
|
96
90
|
// 请求结果
|
|
97
|
-
if (requestResult
|
|
91
|
+
if (requestResult) {
|
|
98
92
|
// onSearchAfter 处理请求结果
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
newReqResult = onSearchAfter(requestResult); // 获取table数据
|
|
94
|
+
dataSource = getDataFromFields(newReqResult, fieldNames.dataSource);
|
|
101
95
|
if (record) {
|
|
102
96
|
// 异步树
|
|
103
|
-
record[childrenColumnName] =
|
|
97
|
+
record[childrenColumnName] = dataSource;
|
|
104
98
|
setData(function (d) {
|
|
105
99
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
106
|
-
|
|
100
|
+
dataSource: _toConsumableArray(d.dataSource || []),
|
|
107
101
|
loading: false
|
|
108
102
|
});
|
|
109
103
|
});
|
|
@@ -111,7 +105,7 @@ var TableTree = function TableTree(_ref) {
|
|
|
111
105
|
setExpandKeys([]);
|
|
112
106
|
setData({
|
|
113
107
|
loading: false,
|
|
114
|
-
|
|
108
|
+
dataSource: dataSource
|
|
115
109
|
});
|
|
116
110
|
}
|
|
117
111
|
} else {
|
|
@@ -121,14 +115,14 @@ var TableTree = function TableTree(_ref) {
|
|
|
121
115
|
});
|
|
122
116
|
});
|
|
123
117
|
}
|
|
124
|
-
case
|
|
118
|
+
case 13:
|
|
125
119
|
case "end":
|
|
126
120
|
return _context.stop();
|
|
127
121
|
}
|
|
128
122
|
}, _callee);
|
|
129
123
|
}));
|
|
130
124
|
return function onRequestTree() {
|
|
131
|
-
return
|
|
125
|
+
return _ref2.apply(this, arguments);
|
|
132
126
|
};
|
|
133
127
|
}();
|
|
134
128
|
useImperativeHandle(treeRef, function () {
|
package/es/select/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type ApiSelectProps = Omit<SelectProps, 'fieldNames'> & {
|
|
|
20
20
|
/** 查询请求 */
|
|
21
21
|
onQuery?: (params?: any) => Promise<any>;
|
|
22
22
|
};
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function getDataFromFields(data: Record<string, any>, fields: string[]): any;
|
|
24
24
|
/**
|
|
25
25
|
* 基于接口查询的select组件
|
|
26
26
|
* @param CcsSelectProps
|
package/es/select/index.js
CHANGED
|
@@ -19,15 +19,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
19
19
|
import { useRequest } from 'ahooks';
|
|
20
20
|
import { Select } from 'antd';
|
|
21
21
|
import { useEffect } from 'react';
|
|
22
|
-
import { useApiSelectInterceptor } from "../hooks/use-app";
|
|
23
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
export function
|
|
23
|
+
export function getDataFromFields(data, fields) {
|
|
25
24
|
if (!data || fields.length === 0) return;
|
|
26
25
|
var newFields = _toConsumableArray(fields);
|
|
27
26
|
var field = newFields.shift();
|
|
28
27
|
var newData = data[field];
|
|
29
28
|
if (_typeof(newData) === 'object' && newFields.length > 0) {
|
|
30
|
-
return
|
|
29
|
+
return getDataFromFields(newData, newFields);
|
|
31
30
|
}
|
|
32
31
|
return newData;
|
|
33
32
|
}
|
|
@@ -50,10 +49,6 @@ export default function CcsApiSelect(_ref) {
|
|
|
50
49
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
51
50
|
var labelField = _toConsumableArray(onIsArray((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || ['data', 'label']));
|
|
52
51
|
var valueField = _toConsumableArray(onIsArray((fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || ['data', 'value']));
|
|
53
|
-
// 接口格式化方法
|
|
54
|
-
var _useApiSelectIntercep = useApiSelectInterceptor(),
|
|
55
|
-
onRequestFormat = _useApiSelectIntercep.onRequestFormat,
|
|
56
|
-
onResponseFormat = _useApiSelectIntercep.onResponseFormat;
|
|
57
52
|
var _useRequest = useRequest( /*#__PURE__*/function () {
|
|
58
53
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
59
54
|
var result, value;
|
|
@@ -67,7 +62,7 @@ export default function CcsApiSelect(_ref) {
|
|
|
67
62
|
return _context.abrupt("return", []);
|
|
68
63
|
case 2:
|
|
69
64
|
_context.next = 4;
|
|
70
|
-
return
|
|
65
|
+
return onQuery(params);
|
|
71
66
|
case 4:
|
|
72
67
|
result = _context.sent;
|
|
73
68
|
case 5:
|
|
@@ -80,8 +75,8 @@ export default function CcsApiSelect(_ref) {
|
|
|
80
75
|
break;
|
|
81
76
|
}
|
|
82
77
|
result.forEach(function (r) {
|
|
83
|
-
r.label =
|
|
84
|
-
r.value =
|
|
78
|
+
r.label = getDataFromFields(r, labelField);
|
|
79
|
+
r.value = getDataFromFields(r, valueField);
|
|
85
80
|
});
|
|
86
81
|
return _context.abrupt("break", 14);
|
|
87
82
|
case 9:
|
package/es/table/index.js
CHANGED
|
@@ -15,12 +15,6 @@ import { useEffect, useImperativeHandle } from 'react';
|
|
|
15
15
|
import { Resizable } from 'react-resizable';
|
|
16
16
|
import "./index.less";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
var DEFAULT_PAGE = {
|
|
19
|
-
totalNum: 0,
|
|
20
|
-
result: [],
|
|
21
|
-
pageSize: 10,
|
|
22
|
-
pageNo: 1
|
|
23
|
-
};
|
|
24
18
|
var ResizableTitle = function ResizableTitle(props) {
|
|
25
19
|
var onResize = props.onResize,
|
|
26
20
|
width = props.width,
|
|
@@ -58,11 +52,15 @@ var CustomTable = function CustomTable(props) {
|
|
|
58
52
|
tableContentRef = props.tableContentRef,
|
|
59
53
|
restProps = _objectWithoutProperties(props, _excluded2);
|
|
60
54
|
var update = useUpdate();
|
|
61
|
-
var _ref = data ||
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
pageSize = _ref
|
|
55
|
+
var _ref = data || {},
|
|
56
|
+
_ref$dataSource = _ref.dataSource,
|
|
57
|
+
dataSource = _ref$dataSource === void 0 ? [] : _ref$dataSource,
|
|
58
|
+
_ref$pageSize = _ref.pageSize,
|
|
59
|
+
pageSize = _ref$pageSize === void 0 ? 10 : _ref$pageSize,
|
|
60
|
+
_ref$current = _ref.current,
|
|
61
|
+
current = _ref$current === void 0 ? 1 : _ref$current,
|
|
62
|
+
_ref$total = _ref.total,
|
|
63
|
+
total = _ref$total === void 0 ? 0 : _ref$total;
|
|
66
64
|
|
|
67
65
|
// table 固定表头,内容滚动
|
|
68
66
|
var _useDebounceFn = useDebounceFn(function () {
|
|
@@ -101,7 +99,7 @@ var CustomTable = function CustomTable(props) {
|
|
|
101
99
|
onFixedThead = _useDebounceFn.run;
|
|
102
100
|
useEffect(function () {
|
|
103
101
|
onFixedThead();
|
|
104
|
-
}, [
|
|
102
|
+
}, [total]);
|
|
105
103
|
|
|
106
104
|
// 监听窗口变化
|
|
107
105
|
// useEventListener('resize', onFixedThead, { target: window });
|
|
@@ -169,7 +167,7 @@ var CustomTable = function CustomTable(props) {
|
|
|
169
167
|
ellipsis: true,
|
|
170
168
|
width: 60,
|
|
171
169
|
render: function render(_value, _record, index) {
|
|
172
|
-
return index + 1 + ((
|
|
170
|
+
return index + 1 + ((current || 1) - 1) * (pageSize || 10);
|
|
173
171
|
}
|
|
174
172
|
});
|
|
175
173
|
}
|
|
@@ -184,15 +182,15 @@ var CustomTable = function CustomTable(props) {
|
|
|
184
182
|
}),
|
|
185
183
|
children: /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({
|
|
186
184
|
rowKey: rowKey,
|
|
187
|
-
dataSource:
|
|
185
|
+
dataSource: dataSource,
|
|
188
186
|
pagination: pagination === false ? false : _objectSpread({
|
|
189
|
-
total:
|
|
187
|
+
total: total,
|
|
190
188
|
pageSize: pageSize,
|
|
191
|
-
current:
|
|
189
|
+
current: current,
|
|
192
190
|
showSizeChanger: true,
|
|
193
191
|
showQuickJumper: true,
|
|
194
192
|
showTotal: function showTotal() {
|
|
195
|
-
return "\u5171".concat(
|
|
193
|
+
return "\u5171".concat(total, "\u6761\u8BB0\u5F55");
|
|
196
194
|
},
|
|
197
195
|
pageSizeOptions: ['10', '20', '30', '50', '100'],
|
|
198
196
|
size: restProps.size === 'small' ? 'small' : 'default',
|
|
@@ -209,7 +207,7 @@ var CustomTable = function CustomTable(props) {
|
|
|
209
207
|
}
|
|
210
208
|
}, restProps), {}, {
|
|
211
209
|
size: restProps.size || 'middle',
|
|
212
|
-
className: classNames(_defineProperty(_defineProperty(_defineProperty({}, 'ccs-table-nodata', !
|
|
210
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty({}, 'ccs-table-nodata', !dataSource || dataSource.length === 0), 'ccs-table-wrapper', !rowSelection), "className", className)),
|
|
213
211
|
scroll: scroll
|
|
214
212
|
}))
|
|
215
213
|
});
|
package/es/theme-dialog.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MessageInstance } from 'antd/es/message/interface';
|
|
2
2
|
import { HookAPI } from 'antd/es/modal/useModal';
|
|
3
3
|
import { NotificationInstance } from 'antd/es/notification/interface';
|
|
4
|
-
import CCS from '.';
|
|
5
4
|
export default class ThemeDialog {
|
|
6
5
|
static message: MessageInstance;
|
|
7
6
|
static notice: NotificationInstance;
|
|
@@ -13,7 +12,12 @@ export default class ThemeDialog {
|
|
|
13
12
|
* @param successText // 成功提示
|
|
14
13
|
* @param failText // 失败提示
|
|
15
14
|
*/
|
|
16
|
-
static easyMessage(result
|
|
15
|
+
static easyMessage(result?: {
|
|
16
|
+
/** 成功标识 */
|
|
17
|
+
success?: boolean;
|
|
18
|
+
/** 失败信息 */
|
|
19
|
+
msg?: string;
|
|
20
|
+
}, successText?: string, failText?: string): void;
|
|
17
21
|
static confirm(content?: string): Promise<boolean>;
|
|
18
22
|
/**
|
|
19
23
|
* 确认提示框
|