@ccs-ui/rc-pro 2.3.6-alpha-9 → 2.3.6-alpha-11
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 +4 -4
- package/es/ccs.d.ts +4 -9
- package/es/dialog/button.d.ts +1 -1
- package/es/dialog/button.js +3 -3
- package/es/group-form-item/index.js +4 -4
- package/es/pro-table/form-item.d.ts +4 -2
- package/es/pro-table/form-item.js +3 -2
- package/es/pro-table/head.js +80 -61
- package/es/pro-table/index.less +15 -4
- package/es/pro-table/table.d.ts +10 -8
- package/es/pro-table/table.js +25 -9
- package/es/pro-table/tree.d.ts +3 -3
- package/es/pro-table/tree.js +28 -17
- package/es/select/index.d.ts +2 -1
- package/es/select/index.js +9 -6
- package/package.json +1 -1
package/es/cascader/index.js
CHANGED
|
@@ -19,7 +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 {
|
|
22
|
+
import { getDataByNamePath } from "../select";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
function onIsArray(data) {
|
|
25
25
|
if (Array.isArray(data)) return data;
|
|
@@ -67,9 +67,9 @@ function ApiCascader(_ref) {
|
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
result.forEach(function (r) {
|
|
70
|
-
r.label =
|
|
71
|
-
r.value =
|
|
72
|
-
r.children =
|
|
70
|
+
r.label = getDataByNamePath(r, labelField);
|
|
71
|
+
r.value = getDataByNamePath(r, valueField);
|
|
72
|
+
r.children = getDataByNamePath(r, childrenField);
|
|
73
73
|
});
|
|
74
74
|
return _context.abrupt("break", 15);
|
|
75
75
|
case 9:
|
package/es/ccs.d.ts
CHANGED
|
@@ -94,11 +94,11 @@ type ShowDependType = {
|
|
|
94
94
|
name: string;
|
|
95
95
|
value: any;
|
|
96
96
|
};
|
|
97
|
-
type
|
|
97
|
+
export type TableFormItem = {
|
|
98
98
|
/** label 标题 */
|
|
99
99
|
label?: string;
|
|
100
100
|
/** form name */
|
|
101
|
-
name?:
|
|
101
|
+
name?: NamePath;
|
|
102
102
|
/** form item element */
|
|
103
103
|
value: ReactElement;
|
|
104
104
|
/** 数据依赖、依赖项对应的name数组 */
|
|
@@ -109,14 +109,9 @@ type FormItemType = {
|
|
|
109
109
|
rules?: Rule[];
|
|
110
110
|
/** 在发起请求时调用方法,格式化值 */
|
|
111
111
|
onFormat?: (e: any) => any;
|
|
112
|
-
/**
|
|
113
|
-
|
|
112
|
+
/** 分组表单项,将解构name,生成独立的字段值,如时间范围选择,将数组结果解构成独立的字段值 */
|
|
113
|
+
isGroupItem?: boolean;
|
|
114
114
|
};
|
|
115
|
-
export type TableFormItem = ({
|
|
116
|
-
name: string;
|
|
117
|
-
} & Partial<FormItemType>) | ({
|
|
118
|
-
groupItemNames: NamePath[];
|
|
119
|
-
} & Partial<FormItemType>);
|
|
120
115
|
type TableFormItems = TableFormItem[];
|
|
121
116
|
type TableInstanceRef<T = any> = MutableRefObject<TableInstance<T> | undefined> | React.RefObject<TableInstance<T>>;
|
|
122
117
|
type TableColumns<RecordType = any> = TableColumn<RecordType>[];
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
|
|
|
16
16
|
export type DialogButtonRef = {
|
|
17
17
|
onSetButtons: (e: React.ReactElement) => void;
|
|
18
18
|
};
|
|
19
|
-
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "
|
|
19
|
+
export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "request" | "onClose" | "onOk" | "auth" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
|
|
20
20
|
formRef: React.RefObject<DialogFormRef<TParams>>;
|
|
21
21
|
formInitialValues: FormProps['initialValues'];
|
|
22
22
|
buttonRef: RefObject<DialogButtonRef>;
|
package/es/dialog/button.js
CHANGED
|
@@ -18,7 +18,7 @@ import { Button, Form } from 'antd';
|
|
|
18
18
|
import React, { useEffect, useImperativeHandle, useState } from 'react';
|
|
19
19
|
import CcsDialog from '.';
|
|
20
20
|
import { useDialogFields } from "../hooks/use-app";
|
|
21
|
-
import {
|
|
21
|
+
import { getDataByNamePath } from "../select";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -110,9 +110,9 @@ export var DialogButtonHolder = function DialogButtonHolder(_ref) {
|
|
|
110
110
|
var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), requestFieldNames);
|
|
111
111
|
|
|
112
112
|
// 获取成功标识
|
|
113
|
-
var success =
|
|
113
|
+
var success = getDataByNamePath(result, fieldNames.success);
|
|
114
114
|
// 获取异常信息
|
|
115
|
-
var msg =
|
|
115
|
+
var msg = getDataByNamePath(result, fieldNames.errorMsg);
|
|
116
116
|
if (success === fieldNames.successTag) {
|
|
117
117
|
// 关闭对话框
|
|
118
118
|
onHandleClose(values, result);
|
|
@@ -20,7 +20,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
20
20
|
import { useUpdateEffect } from 'ahooks';
|
|
21
21
|
import { Form } from 'antd';
|
|
22
22
|
import { useEffect, useState } from 'react';
|
|
23
|
-
import {
|
|
23
|
+
import { getDataByNamePath } from "../select";
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
25
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -38,7 +38,7 @@ var FormUpdateItem = function FormUpdateItem(_ref) {
|
|
|
38
38
|
|
|
39
39
|
// 根据子项初始值设置name的默认值
|
|
40
40
|
groupItemNames.forEach(function (item) {
|
|
41
|
-
initNameValue.push(
|
|
41
|
+
initNameValue.push(getDataByNamePath(initialValues, item));
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// 如果子项有初始值,则设置name的默认值
|
|
@@ -50,7 +50,7 @@ var FormUpdateItem = function FormUpdateItem(_ref) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// 如果子项没有初始值,主项有初始值
|
|
53
|
-
var groupNameValue =
|
|
53
|
+
var groupNameValue = getDataByNamePath(initialValues, name);
|
|
54
54
|
if (Array.isArray(groupNameValue)) {
|
|
55
55
|
groupItemNames.forEach(function (item, index) {
|
|
56
56
|
setFieldValue(item, groupNameValue[index]);
|
|
@@ -84,7 +84,7 @@ function GroupFormItem(_ref2) {
|
|
|
84
84
|
var groupItemNames = _ref2.groupItemNames,
|
|
85
85
|
name = _ref2.name,
|
|
86
86
|
formItemProps = _objectWithoutProperties(_ref2, _excluded);
|
|
87
|
-
var _useState = useState(name || "_".concat(JSON.stringify(groupItemNames).replace(/[^a-zA-Z]/g, ''))),
|
|
87
|
+
var _useState = useState(name || "_".concat(JSON.stringify(groupItemNames).replace(/[^a-zA-Z]/g, ''), "_")),
|
|
88
88
|
_useState2 = _slicedToArray(_useState, 1),
|
|
89
89
|
itemName = _useState2[0];
|
|
90
90
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
1
2
|
import { TableFormItem } from '../ccs';
|
|
2
|
-
import { CcsProTableProps } from './table';
|
|
3
3
|
type PropsType = TableFormItem & {
|
|
4
4
|
dependParam?: any;
|
|
5
|
-
|
|
5
|
+
groupItemNames?: NamePath[];
|
|
6
|
+
formItemLabelWidth?: number | string;
|
|
7
|
+
};
|
|
6
8
|
export default function HeadFormItem({ label, name, rules, value, dependParam, groupItemNames, formItemLabelWidth, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export {};
|
|
@@ -19,7 +19,6 @@ export default function HeadFormItem(_ref) {
|
|
|
19
19
|
groupItemNames = _ref.groupItemNames,
|
|
20
20
|
formItemLabelWidth = _ref.formItemLabelWidth;
|
|
21
21
|
var props = {
|
|
22
|
-
name: name,
|
|
23
22
|
rules: rules,
|
|
24
23
|
className: "".concat(classPrefix, "-form-label"),
|
|
25
24
|
label: formItemLabelWidth ? /*#__PURE__*/_jsx("div", {
|
|
@@ -36,7 +35,9 @@ export default function HeadFormItem(_ref) {
|
|
|
36
35
|
}));
|
|
37
36
|
}
|
|
38
37
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
39
|
-
children: /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
|
|
38
|
+
children: /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({
|
|
39
|
+
name: name
|
|
40
|
+
}, props), {}, {
|
|
40
41
|
children: dependParam ? /*#__PURE__*/cloneElement(value, dependParam) : value
|
|
41
42
|
}))
|
|
42
43
|
});
|
package/es/pro-table/head.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -5,11 +11,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
|
8
|
-
import { useUpdateEffect } from 'ahooks';
|
|
9
14
|
import { Button, Form, theme } from 'antd';
|
|
10
15
|
import _debounce from 'lodash.debounce';
|
|
11
16
|
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
12
17
|
import { CcsResizeObserver } from '..';
|
|
18
|
+
import { getDataByNamePath } from "../select";
|
|
13
19
|
import { getShowDpends } from "./_utils";
|
|
14
20
|
import HeadFormItem from "./form-item";
|
|
15
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -33,8 +39,10 @@ function HeadComponent(_ref) {
|
|
|
33
39
|
var formItemsRef = useRef(null);
|
|
34
40
|
// 根据位置判断是否换行ref
|
|
35
41
|
var endItemRef = useRef(null);
|
|
42
|
+
// 查询按钮ref
|
|
43
|
+
var searchBtnRef = useRef(null);
|
|
36
44
|
// 查询条件是否展开
|
|
37
|
-
var _useState = useState(
|
|
45
|
+
var _useState = useState(false),
|
|
38
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
47
|
isExpand = _useState2[0],
|
|
40
48
|
setIsExpand = _useState2[1];
|
|
@@ -42,9 +50,11 @@ function HeadComponent(_ref) {
|
|
|
42
50
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
51
|
hasMore = _useState4[0],
|
|
44
52
|
onToggle = _useState4[1];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
useEffect(function () {
|
|
54
|
+
if (hasMore && expandForm) {
|
|
55
|
+
setIsExpand(true);
|
|
56
|
+
}
|
|
57
|
+
}, [hasMore]);
|
|
48
58
|
useImperativeHandle(formRef, function () {
|
|
49
59
|
return form;
|
|
50
60
|
});
|
|
@@ -62,9 +72,19 @@ function HeadComponent(_ref) {
|
|
|
62
72
|
|
|
63
73
|
// 判断是否有更多条件无法一行显示
|
|
64
74
|
var onEventMore = function onEventMore() {
|
|
65
|
-
var _endItemRef$current, _formItemsRef$current;
|
|
66
|
-
if (!endItemRef.current || !formItemsRef.current
|
|
67
|
-
var
|
|
75
|
+
var _endItemRef$current, _formItemsRef$current, _searchBtnRef$current, _endItemRef$current2, _formItemsRef$current2;
|
|
76
|
+
if (!endItemRef.current || !formItemsRef.current) return;
|
|
77
|
+
var endTop = (_endItemRef$current = endItemRef.current) === null || _endItemRef$current === void 0 || (_endItemRef$current = _endItemRef$current.getClientRects()[0]) === null || _endItemRef$current === void 0 ? void 0 : _endItemRef$current.top;
|
|
78
|
+
var formTop = (_formItemsRef$current = formItemsRef.current) === null || _formItemsRef$current === void 0 || (_formItemsRef$current = _formItemsRef$current.getClientRects()[0]) === null || _formItemsRef$current === void 0 ? void 0 : _formItemsRef$current.top;
|
|
79
|
+
var searchtTop = (_searchBtnRef$current = searchBtnRef.current) === null || _searchBtnRef$current === void 0 || (_searchBtnRef$current = _searchBtnRef$current.getClientRects()[0]) === null || _searchBtnRef$current === void 0 ? void 0 : _searchBtnRef$current.top;
|
|
80
|
+
|
|
81
|
+
// 都在一行,则没有更多和展开
|
|
82
|
+
if (endTop === formTop && endTop === searchtTop) {
|
|
83
|
+
onToggle(false);
|
|
84
|
+
setIsExpand(false);
|
|
85
|
+
}
|
|
86
|
+
if (isExpand) return;
|
|
87
|
+
var hasMore = ((_endItemRef$current2 = endItemRef.current) === null || _endItemRef$current2 === void 0 || (_endItemRef$current2 = _endItemRef$current2.getClientRects()[0]) === null || _endItemRef$current2 === void 0 ? void 0 : _endItemRef$current2.top) !== ((_formItemsRef$current2 = formItemsRef.current) === null || _formItemsRef$current2 === void 0 || (_formItemsRef$current2 = _formItemsRef$current2.getClientRects()[0]) === null || _formItemsRef$current2 === void 0 ? void 0 : _formItemsRef$current2.top);
|
|
68
88
|
onToggle(hasMore);
|
|
69
89
|
};
|
|
70
90
|
|
|
@@ -86,6 +106,7 @@ function HeadComponent(_ref) {
|
|
|
86
106
|
textAlign: 'right',
|
|
87
107
|
flex: isExpand && hasMore ? '1 1 auto' : '0 0 auto'
|
|
88
108
|
},
|
|
109
|
+
ref: searchBtnRef,
|
|
89
110
|
children: [hasMore && /*#__PURE__*/_jsx(Button, {
|
|
90
111
|
type: "link",
|
|
91
112
|
icon: isExpand ? /*#__PURE__*/_jsx(UpOutlined, {}) : /*#__PURE__*/_jsx(DownOutlined, {}),
|
|
@@ -109,60 +130,53 @@ function HeadComponent(_ref) {
|
|
|
109
130
|
var depends = _ref2.depends,
|
|
110
131
|
showDepends = _ref2.showDepends,
|
|
111
132
|
name = _ref2.name,
|
|
112
|
-
|
|
133
|
+
isGroupItem = _ref2.isGroupItem,
|
|
113
134
|
label = _ref2.label,
|
|
114
135
|
rules = _ref2.rules,
|
|
115
136
|
value = _ref2.value;
|
|
137
|
+
var itemProps = {
|
|
138
|
+
name: name,
|
|
139
|
+
label: label,
|
|
140
|
+
rules: rules,
|
|
141
|
+
value: value,
|
|
142
|
+
formItemLabelWidth: formItemLabelWidth,
|
|
143
|
+
groupItemNames: isGroupItem ? name : undefined
|
|
144
|
+
};
|
|
145
|
+
var itemContent = /*#__PURE__*/_jsx(React.Fragment, {
|
|
146
|
+
children: /*#__PURE__*/_jsx(HeadFormItem, _objectSpread({}, itemProps))
|
|
147
|
+
}, index);
|
|
116
148
|
if (depends || showDepends) {
|
|
117
|
-
return /*#__PURE__*/_jsx(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return getFieldValue(i.name) === i.value;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
|
|
141
|
-
name: name,
|
|
142
|
-
groupItemNames: groupItemNames,
|
|
143
|
-
label: label,
|
|
144
|
-
rules: rules,
|
|
145
|
-
value: value,
|
|
146
|
-
dependParam: dependParam,
|
|
147
|
-
formItemLabelWidth: formItemLabelWidth
|
|
149
|
+
return /*#__PURE__*/_jsx(Form.Item, {
|
|
150
|
+
noStyle: true,
|
|
151
|
+
shouldUpdate: function shouldUpdate(l, n) {
|
|
152
|
+
return (depends === null || depends === void 0 ? void 0 : depends.some(function (i) {
|
|
153
|
+
return getDataByNamePath(l, i) !== getDataByNamePath(n, i);
|
|
154
|
+
})) || (showDepends === null || showDepends === void 0 ? void 0 : showDepends.some(function (i) {
|
|
155
|
+
return getDataByNamePath(l, i.name) !== getDataByNamePath(n, i.name);
|
|
156
|
+
})) || false;
|
|
157
|
+
},
|
|
158
|
+
children: function children(_ref3) {
|
|
159
|
+
var getFieldValue = _ref3.getFieldValue;
|
|
160
|
+
var dependParam = {};
|
|
161
|
+
depends === null || depends === void 0 || depends.forEach(function (i) {
|
|
162
|
+
var value = getFieldValue(i);
|
|
163
|
+
dependParam[i] = value;
|
|
164
|
+
});
|
|
165
|
+
var isShow = true;
|
|
166
|
+
if (showDepends && showDepends.length > 0) {
|
|
167
|
+
isShow = showDepends === null || showDepends === void 0 ? void 0 : showDepends.every(function (i) {
|
|
168
|
+
return getFieldValue(i.name) === i.value;
|
|
148
169
|
});
|
|
149
|
-
if (!isShow) return null;
|
|
150
|
-
return itemContent;
|
|
151
170
|
}
|
|
152
|
-
|
|
153
|
-
|
|
171
|
+
var itemContent = /*#__PURE__*/_jsx(HeadFormItem, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
172
|
+
dependParam: dependParam
|
|
173
|
+
}));
|
|
174
|
+
if (!isShow) return null;
|
|
175
|
+
return itemContent;
|
|
176
|
+
}
|
|
177
|
+
}, index);
|
|
154
178
|
}
|
|
155
|
-
|
|
156
|
-
groupItemNames: groupItemNames,
|
|
157
|
-
name: name,
|
|
158
|
-
value: value,
|
|
159
|
-
rules: rules,
|
|
160
|
-
label: label,
|
|
161
|
-
formItemLabelWidth: formItemLabelWidth
|
|
162
|
-
});
|
|
163
|
-
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
164
|
-
children: itemContent
|
|
165
|
-
}, index);
|
|
179
|
+
return itemContent;
|
|
166
180
|
});
|
|
167
181
|
};
|
|
168
182
|
var formStyles = {
|
|
@@ -183,16 +197,21 @@ function HeadComponent(_ref) {
|
|
|
183
197
|
onFinish: onSearch,
|
|
184
198
|
layout: "inline",
|
|
185
199
|
style: formStyles,
|
|
186
|
-
children: [/*#__PURE__*/
|
|
200
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
187
201
|
style: {
|
|
188
|
-
justifyContent: isExpand && hasMore ? 'flex-start' : 'flex-end',
|
|
189
202
|
height: isExpand ? 'auto' : controlHeight
|
|
190
203
|
},
|
|
191
204
|
className: "ccs-pl-adaptation-form",
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
ref:
|
|
195
|
-
|
|
205
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
206
|
+
className: "ccs-pl-form-".concat(isExpand && hasMore ? 'expand' : 'collapse'),
|
|
207
|
+
ref: formItemsRef,
|
|
208
|
+
children: [renderFormItems(), /*#__PURE__*/_jsx("div", {
|
|
209
|
+
style: {
|
|
210
|
+
height: 1
|
|
211
|
+
},
|
|
212
|
+
ref: endItemRef
|
|
213
|
+
}), isExpand && renderSearchBtn]
|
|
214
|
+
})
|
|
196
215
|
}), !isExpand && /*#__PURE__*/_jsx("div", {
|
|
197
216
|
style: {
|
|
198
217
|
flex: '0 0 auto'
|
package/es/pro-table/index.less
CHANGED
|
@@ -62,12 +62,23 @@
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
&-
|
|
66
|
-
flex: 1 1 auto;
|
|
65
|
+
&-form-collapse {
|
|
67
66
|
display: flex;
|
|
68
67
|
justify-content: flex-end;
|
|
69
68
|
flex-wrap: wrap;
|
|
70
|
-
gap:
|
|
69
|
+
column-gap: 10px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&-form-expand {
|
|
73
|
+
display: flex;
|
|
74
|
+
justify-content: flex-start;
|
|
75
|
+
flex-wrap: wrap;
|
|
76
|
+
column-gap: 10px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&-adaptation-form {
|
|
80
|
+
flex: 1 1 auto;
|
|
81
|
+
|
|
71
82
|
overflow: hidden;
|
|
72
83
|
|
|
73
84
|
&::-webkit-scrollbar {
|
|
@@ -76,7 +87,7 @@
|
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
.ant-form-item {
|
|
79
|
-
margin-bottom:
|
|
90
|
+
margin-bottom: 10px;
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
&-form {
|
package/es/pro-table/table.d.ts
CHANGED
|
@@ -13,14 +13,16 @@ export type ShowDependType = {
|
|
|
13
13
|
value: any;
|
|
14
14
|
};
|
|
15
15
|
export declare enum TableEvent {
|
|
16
|
-
Search = "search"
|
|
17
|
-
Reset = "reset"
|
|
18
|
-
Reload = "reload"
|
|
19
|
-
ChangePage = "changePage"
|
|
20
|
-
InitSearch = "initSearch"
|
|
21
|
-
FullScreen = "fullScreen"
|
|
22
|
-
ColumnFilter = "columnFilter"
|
|
23
|
-
SelectedRows = "SelectedRows"
|
|
16
|
+
Search = "search",// 查询
|
|
17
|
+
Reset = "reset",// 重置
|
|
18
|
+
Reload = "reload",// 刷新
|
|
19
|
+
ChangePage = "changePage",// 分页
|
|
20
|
+
InitSearch = "initSearch",// 初始化查询
|
|
21
|
+
FullScreen = "fullScreen",// 全屏
|
|
22
|
+
ColumnFilter = "columnFilter",// 列过滤
|
|
23
|
+
SelectedRows = "SelectedRows",// 选中行
|
|
24
|
+
Expand = "Expand",// 异步树展开
|
|
25
|
+
PartialReload = "PartialReload"
|
|
24
26
|
}
|
|
25
27
|
export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, 'ellipsis'> | Omit<ColumnType<RecordType>, 'ellipsis'>) & {
|
|
26
28
|
dataIndex?: keyof RecordType;
|
package/es/pro-table/table.js
CHANGED
|
@@ -24,7 +24,7 @@ import _debounce from 'lodash.debounce';
|
|
|
24
24
|
import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
25
25
|
import { CcsResizeObserver, useAppConfig, useCcsPage } from '..';
|
|
26
26
|
import { useProTableFields } from "../hooks/use-app";
|
|
27
|
-
import {
|
|
27
|
+
import { getDataByNamePath } from "../select";
|
|
28
28
|
import CcsTable from "../table";
|
|
29
29
|
import { getAllChildrenId, getDataById, onTableInModalOrDrawer, onTableInTabItem } from "./_utils";
|
|
30
30
|
import HeadComponent from "./head";
|
|
@@ -55,8 +55,10 @@ export var TableEvent = /*#__PURE__*/function (TableEvent) {
|
|
|
55
55
|
TableEvent["FullScreen"] = "fullScreen";
|
|
56
56
|
TableEvent["ColumnFilter"] = "columnFilter";
|
|
57
57
|
TableEvent["SelectedRows"] = "SelectedRows";
|
|
58
|
+
TableEvent["Expand"] = "Expand";
|
|
59
|
+
TableEvent["PartialReload"] = "PartialReload";
|
|
58
60
|
return TableEvent;
|
|
59
|
-
}({});
|
|
61
|
+
}({}); // 异步树局部刷新
|
|
60
62
|
export var classPrefix = 'ccs-pl';
|
|
61
63
|
|
|
62
64
|
/**
|
|
@@ -169,7 +171,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
169
171
|
var getFormValues = /*#__PURE__*/function () {
|
|
170
172
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
171
173
|
var _formRef$current;
|
|
172
|
-
var formValues;
|
|
174
|
+
var formValues, _delField;
|
|
173
175
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
174
176
|
while (1) switch (_context.prev = _context.next) {
|
|
175
177
|
case 0:
|
|
@@ -177,8 +179,19 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
177
179
|
return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
|
|
178
180
|
case 2:
|
|
179
181
|
formValues = _context.sent;
|
|
180
|
-
//
|
|
182
|
+
// 删除无意义字段
|
|
183
|
+
if (formValues) {
|
|
184
|
+
_delField = Object.keys(formValues).filter(function (k) {
|
|
185
|
+
return k.startsWith('_') && k.endsWith('_');
|
|
186
|
+
});
|
|
187
|
+
if (_delField.length > 0) {
|
|
188
|
+
_delField.forEach(function (d) {
|
|
189
|
+
return delete formValues[d];
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
181
193
|
if (formatFormItems.length) {
|
|
194
|
+
// 格式化条件
|
|
182
195
|
Object.keys(formValues).forEach(function (k) {
|
|
183
196
|
if (formValues[k] !== undefined) {
|
|
184
197
|
var s = formatFormItems.find(function (f) {
|
|
@@ -189,7 +202,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
189
202
|
});
|
|
190
203
|
}
|
|
191
204
|
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, requestParam), formInitValues), formValues));
|
|
192
|
-
case
|
|
205
|
+
case 6:
|
|
193
206
|
case "end":
|
|
194
207
|
return _context.stop();
|
|
195
208
|
}
|
|
@@ -274,9 +287,10 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
274
287
|
_context2.next = 19;
|
|
275
288
|
break;
|
|
276
289
|
}
|
|
277
|
-
(_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(params.query, record);
|
|
290
|
+
(_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(eventType, params.query, record);
|
|
278
291
|
return _context2.abrupt("return");
|
|
279
292
|
case 19:
|
|
293
|
+
// 事件回调,请求中
|
|
280
294
|
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
281
295
|
loading: true,
|
|
282
296
|
params: params
|
|
@@ -292,6 +306,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
292
306
|
return httpRequest(params);
|
|
293
307
|
case 23:
|
|
294
308
|
requestResult = _context2.sent;
|
|
309
|
+
// 事件回调,请求完成
|
|
295
310
|
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
296
311
|
loading: false,
|
|
297
312
|
params: params,
|
|
@@ -304,11 +319,11 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
304
319
|
break;
|
|
305
320
|
}
|
|
306
321
|
// 获取table数据
|
|
307
|
-
dataSource =
|
|
322
|
+
dataSource = getDataByNamePath(requestResult, fieldNames.dataSource); // 默认添加一条数据
|
|
308
323
|
if (table !== null && table !== void 0 && table.emptyDefaultOne && dataSource && dataSource.length === 0) {
|
|
309
324
|
dataSource.push(_defineProperty({}, rowKey || 'id', '0'));
|
|
310
325
|
}
|
|
311
|
-
total =
|
|
326
|
+
total = getDataByNamePath(requestResult, fieldNames.total);
|
|
312
327
|
if (!(total === undefined || dataSource === undefined)) {
|
|
313
328
|
_context2.next = 33;
|
|
314
329
|
break;
|
|
@@ -367,7 +382,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
367
382
|
var ids = getAllChildrenId(treeNode.children || [], rowKey);
|
|
368
383
|
// 局部重载
|
|
369
384
|
(_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 || _treeRef$current2.onExpandKeys(ids);
|
|
370
|
-
(_treeRef$current3 = treeRef.current) === null || _treeRef$current3 === void 0 || _treeRef$current3.onRequestTree({}, treeNode);
|
|
385
|
+
(_treeRef$current3 = treeRef.current) === null || _treeRef$current3 === void 0 || _treeRef$current3.onRequestTree(TableEvent.PartialReload, {}, treeNode);
|
|
371
386
|
};
|
|
372
387
|
useEffect(function () {
|
|
373
388
|
// 判断是否在弹出框中
|
|
@@ -547,6 +562,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
547
562
|
sticky: stickyRef.current || true,
|
|
548
563
|
parentFieldName: parentFieldName,
|
|
549
564
|
setData: setData,
|
|
565
|
+
onEvent: onEvent,
|
|
550
566
|
handlePageChange: handlePageChange
|
|
551
567
|
});
|
|
552
568
|
}
|
package/es/pro-table/tree.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { RefObject } from 'react';
|
|
|
4
4
|
import CCS from '..';
|
|
5
5
|
import { CcsFieldNamesType } from '../context';
|
|
6
6
|
import { TableRefType } from '../table';
|
|
7
|
-
import { CcsProTableProps } from './table';
|
|
7
|
+
import { CcsProTableProps, TableEvent } from './table';
|
|
8
8
|
export type TreeInstance<T> = {
|
|
9
|
-
onRequestTree: (query: any, record: T | any) => void;
|
|
9
|
+
onRequestTree: (eventType: TableEvent, query: any, record: T | any) => void;
|
|
10
10
|
onExpandKeys: (ids: string[]) => void;
|
|
11
11
|
};
|
|
12
|
-
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'parentFieldName' | 'leafNode'> & {
|
|
12
|
+
type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'parentFieldName' | 'leafNode' | 'onEvent'> & {
|
|
13
13
|
data: CCS.TableData<T>;
|
|
14
14
|
sticky: boolean | TableSticky;
|
|
15
15
|
tableRowSize: TableProps['size'];
|
package/es/pro-table/tree.js
CHANGED
|
@@ -21,7 +21,8 @@ import CcsUtils from '@ccs-ui/utils';
|
|
|
21
21
|
import { useImperativeHandle, useState } from 'react';
|
|
22
22
|
import { CcsTable } from '..';
|
|
23
23
|
import { useProTableTreeFields } from "../hooks/use-app";
|
|
24
|
-
import {
|
|
24
|
+
import { getDataByNamePath } from "../select";
|
|
25
|
+
import { TableEvent } from "./table";
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
var TableTree = function TableTree(props) {
|
|
27
28
|
var data = props.data,
|
|
@@ -34,7 +35,8 @@ var TableTree = function TableTree(props) {
|
|
|
34
35
|
tableContentRef = props.tableContentRef,
|
|
35
36
|
parentFieldName = props.parentFieldName,
|
|
36
37
|
handlePageChange = props.handlePageChange,
|
|
37
|
-
setData = props.setData
|
|
38
|
+
setData = props.setData,
|
|
39
|
+
onEvent = props.onEvent;
|
|
38
40
|
// async tree expand key
|
|
39
41
|
var _useState = useState([]),
|
|
40
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -53,8 +55,8 @@ var TableTree = function TableTree(props) {
|
|
|
53
55
|
var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), props.fieldNames);
|
|
54
56
|
|
|
55
57
|
// 获取数据
|
|
56
|
-
var
|
|
57
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
58
|
+
var onRequestTree = /*#__PURE__*/function () {
|
|
59
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventType) {
|
|
58
60
|
var query,
|
|
59
61
|
record,
|
|
60
62
|
params,
|
|
@@ -64,13 +66,18 @@ var TableTree = function TableTree(props) {
|
|
|
64
66
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
65
67
|
while (1) switch (_context.prev = _context.next) {
|
|
66
68
|
case 0:
|
|
67
|
-
query = _args.length >
|
|
68
|
-
record = _args.length >
|
|
69
|
+
query = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
70
|
+
record = _args.length > 2 ? _args[2] : undefined;
|
|
69
71
|
params = query;
|
|
70
72
|
if (record) {
|
|
71
73
|
params[parentFieldName] = record[rowKey];
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
// 事件回调,请求中
|
|
77
|
+
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
78
|
+
loading: true,
|
|
79
|
+
params: params
|
|
80
|
+
});
|
|
74
81
|
// 发起请求
|
|
75
82
|
setData(function (d) {
|
|
76
83
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
@@ -79,19 +86,25 @@ var TableTree = function TableTree(props) {
|
|
|
79
86
|
});
|
|
80
87
|
_context.t0 = httpRequest;
|
|
81
88
|
if (!_context.t0) {
|
|
82
|
-
_context.next =
|
|
89
|
+
_context.next = 11;
|
|
83
90
|
break;
|
|
84
91
|
}
|
|
85
|
-
_context.next =
|
|
92
|
+
_context.next = 10;
|
|
86
93
|
return httpRequest(params);
|
|
87
|
-
case 9:
|
|
88
|
-
_context.t0 = _context.sent;
|
|
89
94
|
case 10:
|
|
95
|
+
_context.t0 = _context.sent;
|
|
96
|
+
case 11:
|
|
90
97
|
requestResult = _context.t0;
|
|
98
|
+
onEvent === null || onEvent === void 0 || onEvent(eventType, {
|
|
99
|
+
loading: true,
|
|
100
|
+
params: params,
|
|
101
|
+
data: requestResult
|
|
102
|
+
});
|
|
103
|
+
|
|
91
104
|
// 请求结果
|
|
92
105
|
if (requestResult) {
|
|
93
106
|
// 获取table数据
|
|
94
|
-
dataSource =
|
|
107
|
+
dataSource = getDataByNamePath(requestResult, fieldNames.dataSource); // 判断非叶子节点,添加children
|
|
95
108
|
if (leafNode && dataSource && Array.isArray(dataSource)) {
|
|
96
109
|
dataSource.forEach(function (d) {
|
|
97
110
|
if (typeof leafNode === 'string' && !d[leafNode]) {
|
|
@@ -126,21 +139,19 @@ var TableTree = function TableTree(props) {
|
|
|
126
139
|
});
|
|
127
140
|
});
|
|
128
141
|
}
|
|
129
|
-
case
|
|
142
|
+
case 14:
|
|
130
143
|
case "end":
|
|
131
144
|
return _context.stop();
|
|
132
145
|
}
|
|
133
146
|
}, _callee);
|
|
134
147
|
}));
|
|
135
|
-
return function onRequestTree() {
|
|
148
|
+
return function onRequestTree(_x) {
|
|
136
149
|
return _ref2.apply(this, arguments);
|
|
137
150
|
};
|
|
138
151
|
}();
|
|
139
152
|
useImperativeHandle(treeRef, function () {
|
|
140
153
|
return {
|
|
141
|
-
onRequestTree:
|
|
142
|
-
_onRequestTree(query, record);
|
|
143
|
-
},
|
|
154
|
+
onRequestTree: onRequestTree,
|
|
144
155
|
onExpandKeys: function onExpandKeys(ids) {
|
|
145
156
|
setExpandKeys(expandKeys.filter(function (e) {
|
|
146
157
|
return !ids.includes(e);
|
|
@@ -158,7 +169,7 @@ var TableTree = function TableTree(props) {
|
|
|
158
169
|
var _record$childrenColum;
|
|
159
170
|
expandKeys.push(expandId);
|
|
160
171
|
if (((_record$childrenColum = record[childrenColumnName]) === null || _record$childrenColum === void 0 ? void 0 : _record$childrenColum.length) > 0) return;
|
|
161
|
-
|
|
172
|
+
onRequestTree(TableEvent.Expand, {}, record);
|
|
162
173
|
} else {
|
|
163
174
|
setExpandKeys(expandKeys.filter(function (e) {
|
|
164
175
|
return e !== expandId;
|
package/es/select/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SelectProps } from 'antd';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
2
3
|
import ModalSelect from './ modal';
|
|
3
4
|
import ApiSelect from './api';
|
|
4
5
|
import CustomizeSelect from './customize';
|
|
5
|
-
export declare function
|
|
6
|
+
export declare function getDataByNamePath(data: Record<string, any>, name: NamePath): any;
|
|
6
7
|
export interface CcsSelectProps extends Omit<SelectProps, 'fieldNames'> {
|
|
7
8
|
/** 配置全部选项 */
|
|
8
9
|
showAll?: boolean | {
|
package/es/select/index.js
CHANGED
|
@@ -20,13 +20,16 @@ import ModalSelect from "./ modal";
|
|
|
20
20
|
import ApiSelect from "./api";
|
|
21
21
|
import CustomizeSelect from "./customize";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export function
|
|
24
|
-
if (!data ||
|
|
25
|
-
|
|
23
|
+
export function getDataByNamePath(data, name) {
|
|
24
|
+
if (!data || !name) return;
|
|
25
|
+
if (typeof name === 'string') {
|
|
26
|
+
return data[name];
|
|
27
|
+
}
|
|
28
|
+
var newFields = _toConsumableArray(name);
|
|
26
29
|
var field = newFields.shift();
|
|
27
30
|
var newData = data[field];
|
|
28
31
|
if (_typeof(newData) === 'object' && newFields.length > 0) {
|
|
29
|
-
return
|
|
32
|
+
return getDataByNamePath(newData, newFields);
|
|
30
33
|
}
|
|
31
34
|
return newData;
|
|
32
35
|
}
|
|
@@ -64,8 +67,8 @@ function InternalSelect(_ref) {
|
|
|
64
67
|
while (labelField.length > 0 || valueField.length > 0) {
|
|
65
68
|
if (Array.isArray(ops)) {
|
|
66
69
|
ops.forEach(function (r) {
|
|
67
|
-
r.label =
|
|
68
|
-
r.value =
|
|
70
|
+
r.label = getDataByNamePath(r, labelField);
|
|
71
|
+
r.value = getDataByNamePath(r, valueField);
|
|
69
72
|
});
|
|
70
73
|
break;
|
|
71
74
|
}
|