@ccs-ui/rc-pro 2.3.6-alpha-10 → 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.
@@ -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 { getDataFromFields } from "../select";
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 = getDataFromFields(r, labelField);
71
- r.value = getDataFromFields(r, valueField);
72
- r.children = getDataFromFields(r, childrenField);
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 FormItemType = {
97
+ export type TableFormItem = {
98
98
  /** label 标题 */
99
99
  label?: string;
100
100
  /** form name */
101
- name?: string;
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
- groupItemNames?: NamePath[];
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>[];
@@ -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>, "auth" | "request" | "onOk" | "onClose" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
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>;
@@ -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 { getDataFromFields } from "../select";
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 = getDataFromFields(result, fieldNames.success);
113
+ var success = getDataByNamePath(result, fieldNames.success);
114
114
  // 获取异常信息
115
- var msg = getDataFromFields(result, fieldNames.errorMsg);
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 { getDataFromFields } from "../select";
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(getDataFromFields(initialValues, Array.isArray(item) ? item : [item]));
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 = getDataFromFields(initialValues, Array.isArray(name) ? name : [name]);
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]);
@@ -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
- } & Pick<CcsProTableProps<any>, 'formItemLabelWidth'>;
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({}, props), {}, {
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
  });
@@ -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(expandForm),
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
- useUpdateEffect(function () {
46
- setIsExpand(expandForm);
47
- }, [expandForm]);
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 || isExpand) return;
67
- var hasMore = ((_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) !== ((_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);
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
- groupItemNames = _ref2.groupItemNames,
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(React.Fragment, {
118
- children: /*#__PURE__*/_jsx(Form.Item, {
119
- noStyle: true,
120
- shouldUpdate: function shouldUpdate(l, n) {
121
- return (depends === null || depends === void 0 ? void 0 : depends.some(function (i) {
122
- return l[i] !== n[i];
123
- })) || (showDepends === null || showDepends === void 0 ? void 0 : showDepends.some(function (i) {
124
- return l[i.name] !== n[i.name];
125
- })) || false;
126
- },
127
- children: function children(_ref3) {
128
- var getFieldValue = _ref3.getFieldValue;
129
- var dependParam = {};
130
- depends === null || depends === void 0 || depends.forEach(function (i) {
131
- var value = getFieldValue(i);
132
- dependParam[i] = value;
133
- });
134
- var isShow = true;
135
- if (showDepends && showDepends.length > 0) {
136
- isShow = showDepends === null || showDepends === void 0 ? void 0 : showDepends.every(function (i) {
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
- }, name);
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
- var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
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__*/_jsxs("div", {
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
- ref: formItemsRef,
193
- children: [renderFormItems(), /*#__PURE__*/_jsx("div", {
194
- ref: endItemRef
195
- }), isExpand && renderSearchBtn]
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'
@@ -62,12 +62,23 @@
62
62
  }
63
63
  }
64
64
 
65
- &-adaptation-form {
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: 16px 10px;
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: 0;
90
+ margin-bottom: 10px;
80
91
  }
81
92
 
82
93
  &-form {
@@ -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 { getDataFromFields } from "../select";
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";
@@ -319,11 +319,11 @@ var InternalProTable = function InternalProTable(props) {
319
319
  break;
320
320
  }
321
321
  // 获取table数据
322
- dataSource = getDataFromFields(requestResult, fieldNames.dataSource); // 默认添加一条数据
322
+ dataSource = getDataByNamePath(requestResult, fieldNames.dataSource); // 默认添加一条数据
323
323
  if (table !== null && table !== void 0 && table.emptyDefaultOne && dataSource && dataSource.length === 0) {
324
324
  dataSource.push(_defineProperty({}, rowKey || 'id', '0'));
325
325
  }
326
- total = getDataFromFields(requestResult, fieldNames.total);
326
+ total = getDataByNamePath(requestResult, fieldNames.total);
327
327
  if (!(total === undefined || dataSource === undefined)) {
328
328
  _context2.next = 33;
329
329
  break;
@@ -21,7 +21,7 @@ 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 { getDataFromFields } from "../select";
24
+ import { getDataByNamePath } from "../select";
25
25
  import { TableEvent } from "./table";
26
26
  import { jsx as _jsx } from "react/jsx-runtime";
27
27
  var TableTree = function TableTree(props) {
@@ -104,7 +104,7 @@ var TableTree = function TableTree(props) {
104
104
  // 请求结果
105
105
  if (requestResult) {
106
106
  // 获取table数据
107
- dataSource = getDataFromFields(requestResult, fieldNames.dataSource); // 判断非叶子节点,添加children
107
+ dataSource = getDataByNamePath(requestResult, fieldNames.dataSource); // 判断非叶子节点,添加children
108
108
  if (leafNode && dataSource && Array.isArray(dataSource)) {
109
109
  dataSource.forEach(function (d) {
110
110
  if (typeof leafNode === 'string' && !d[leafNode]) {
@@ -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 getDataFromFields(data: Record<string, any>, fields: string[]): any;
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 | {
@@ -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 getDataFromFields(data, fields) {
24
- if (!data || fields.length === 0) return;
25
- var newFields = _toConsumableArray(fields);
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 getDataFromFields(newData, newFields);
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 = getDataFromFields(r, labelField);
68
- r.value = getDataFromFields(r, valueField);
70
+ r.label = getDataByNamePath(r, labelField);
71
+ r.value = getDataByNamePath(r, valueField);
69
72
  });
70
73
  break;
71
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.3.6-alpha-10",
3
+ "version": "2.3.6-alpha-11",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {