@zat-design/sisyphus-react 3.13.14-deta.2 → 3.13.15-beta.1

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.
Files changed (27) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/ProForm/components/FormFooter/index.js +2 -1
  4. package/es/ProForm/components/combination/Group/component/ComRender.js +10 -8
  5. package/es/ProForm/components/combination/Group/index.js +7 -7
  6. package/es/ProForm/components/combination/ProCascader/index.js +100 -51
  7. package/es/ProForm/components/combination/ProCascader/propsType.d.ts +12 -4
  8. package/es/ProForm/components/combination/ProCascader/style/index.less +1 -1
  9. package/es/ProForm/components/render/Render.js +13 -3
  10. package/es/ProStep/components/Item/index.js +3 -1
  11. package/lib/ProForm/components/FormFooter/index.js +2 -1
  12. package/lib/ProForm/components/combination/Group/component/ComRender.js +10 -8
  13. package/lib/ProForm/components/combination/Group/index.js +7 -7
  14. package/lib/ProForm/components/combination/ProCascader/index.js +99 -50
  15. package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +12 -4
  16. package/lib/ProForm/components/combination/ProCascader/style/index.less +1 -1
  17. package/lib/ProForm/components/render/Render.js +13 -3
  18. package/lib/ProStep/components/Item/index.js +3 -1
  19. package/package.json +1 -1
  20. package/es/ProForm/utils/_useChanged.d.ts +0 -8
  21. package/es/ProForm/utils/_useChanged.js +0 -25
  22. package/es/ProForm/utils/_useListChanged.d.ts +0 -16
  23. package/es/ProForm/utils/_useListChanged.js +0 -93
  24. package/lib/ProForm/utils/_useChanged.d.ts +0 -8
  25. package/lib/ProForm/utils/_useChanged.js +0 -32
  26. package/lib/ProForm/utils/_useListChanged.d.ts +0 -16
  27. package/lib/ProForm/utils/_useListChanged.js +0 -100
@@ -2491,7 +2491,7 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
2491
2491
  width: 45%;
2492
2492
  }
2493
2493
  .pro-address .ant-cascader.no-detail {
2494
- width: 100% !important;
2494
+ width: 100%;
2495
2495
  }
2496
2496
  .pro-address .pro-address-detail {
2497
2497
  width: 55%;
package/dist/less.esm.css CHANGED
@@ -2491,7 +2491,7 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
2491
2491
  width: 45%;
2492
2492
  }
2493
2493
  .pro-address .ant-cascader.no-detail {
2494
- width: 100% !important;
2494
+ width: 100%;
2495
2495
  }
2496
2496
  .pro-address .pro-address-detail {
2497
2497
  width: 55%;
@@ -51,8 +51,9 @@ var FormFooter = function FormFooter(props) {
51
51
  // 使用自定义验证逻辑
52
52
  form.validateFields().then(function () {
53
53
  onOk();
54
- }).catch(function () {
54
+ }).catch(function (error) {
55
55
  // 验证失败,不执行 onOk
56
+ console.log('校验失败', error);
56
57
  });
57
58
  } else {
58
59
  onOk();
@@ -1,6 +1,7 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _omit from "lodash/omit";
4
5
  var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType", "isView", "viewRender"];
5
6
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
6
7
  import React from 'react';
@@ -17,16 +18,17 @@ var wrapperMap = {
17
18
  // 增加middleware根据配置增加多层包裹
18
19
  var getComRender = function getComRender(component, props, componentProps) {
19
20
  var wrappers = Object.keys(wrapperMap);
20
- var Com = component;
21
+ var renderComponent = component;
21
22
  wrappers.forEach(function (item) {
22
23
  if (item in props) {
23
24
  var Wrapper = wrapperMap[item];
24
- Com = _jsx(Wrapper, _objectSpread(_objectSpread(_objectSpread({}, componentProps), _defineProperty({}, item, props[item])), {}, {
25
- children: Com
25
+ // console.log(props[item]);
26
+ renderComponent = _jsx(Wrapper, _objectSpread(_objectSpread(_objectSpread({}, componentProps), _defineProperty({}, item, props[item])), {}, {
27
+ children: renderComponent
26
28
  }));
27
29
  }
28
30
  });
29
- return Com;
31
+ return renderComponent;
30
32
  };
31
33
  /** 渲染组件 */
32
34
  var ComRender = function ComRender(props) {
@@ -49,8 +51,8 @@ var ComRender = function ComRender(props) {
49
51
  var mergedGetValueProps = getValueProps || function (val) {
50
52
  return _defineProperty({}, valuePropName, val);
51
53
  };
52
- var _props = mergedGetValueProps(fieldProps.value);
53
- var componentProps = _objectSpread(_objectSpread(_objectSpread({}, fieldProps), rest), _props);
54
+ var nextProps = mergedGetValueProps(fieldProps.value);
55
+ var componentProps = _omit(_objectSpread(_objectSpread(_objectSpread({}, fieldProps), rest), nextProps), ['onFieldChange']);
54
56
  var isSeparator = (props === null || props === void 0 ? void 0 : (_props$component = props.component) === null || _props$component === void 0 ? void 0 : (_props$component$prop = _props$component.props) === null || _props$component$prop === void 0 ? void 0 : _props$component$prop.className) === 'group-separator';
55
57
  if (isSeparator && isView) {
56
58
  var _props$component2, _props$component2$pro;
@@ -69,14 +71,14 @@ var ComRender = function ComRender(props) {
69
71
  });
70
72
  }
71
73
  var Component = component ? (/*#__PURE__*/React.cloneElement(component, _objectSpread({}, componentProps))) : _jsx(TypeComponent, _objectSpread({}, componentProps));
72
- var Com = getComRender(Component, props, componentProps);
74
+ var renderComponent = getComRender(Component, props, componentProps);
73
75
  return _jsx(FieldProvider, {
74
76
  value: _objectSpread(_objectSpread({}, contextProps), {}, {
75
77
  valueType: valueType,
76
78
  type: type,
77
79
  isView: isView
78
80
  }),
79
- children: Com
81
+ children: renderComponent
80
82
  });
81
83
  };
82
84
  export default ComRender;
@@ -39,13 +39,13 @@ var Group = function Group(props) {
39
39
  namePath = contextProps.namePath,
40
40
  index = contextProps.index,
41
41
  isView = contextProps.isView;
42
- var _option = React.useRef([]);
42
+ var nextOption = React.useRef([]);
43
43
  // 组合onChange
44
44
  var handleChange = function handleChange(value, option, index) {
45
- var _value = props.value ? _toConsumableArray(props.value) : [];
46
- _value[index] = value;
47
- _option.current[index] = option;
48
- onChange(_value, _option.current);
45
+ var nextValue = props.value ? _toConsumableArray(props.value) : [];
46
+ nextValue[index] = value;
47
+ nextOption.current[index] = option;
48
+ onChange(nextValue, nextOption.current);
49
49
  };
50
50
  var columnsProps = useTransformColumns({
51
51
  columns: children,
@@ -61,7 +61,7 @@ var Group = function Group(props) {
61
61
  desensitizationKey: desensitizationKey
62
62
  });
63
63
  var columns = insertSeparator(columnsProps, space);
64
- var _className = classnames(_defineProperty({
64
+ var nextClassName = classnames(_defineProperty({
65
65
  'pro-group': true,
66
66
  'pro-group-diy-width': columns.some(function (item) {
67
67
  var _item$fieldProps, _item$fieldProps$styl;
@@ -72,7 +72,7 @@ var Group = function Group(props) {
72
72
  })
73
73
  }, "".concat(className), className));
74
74
  return _jsx("div", {
75
- className: _className,
75
+ className: nextClassName,
76
76
  id: id,
77
77
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
78
78
  children: columns.map(function (column, index) {
@@ -3,8 +3,8 @@ import _Tooltip from "antd/es/tooltip";
3
3
  import "antd/es/cascader/style";
4
4
  import _Cascader from "antd/es/cascader";
5
5
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
7
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
+ import "antd/es/message/style";
7
+ import _message from "antd/es/message";
8
8
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
10
10
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
@@ -16,7 +16,8 @@ import _find2 from "lodash/find";
16
16
  import _omit from "lodash/omit";
17
17
  var _excluded = ["className", "hasDetail", "detailMaxLength", "fieldNames", "value", "disabled", "dataSource", "onChange", "useRequest", "transformResponse", "level", "isView", "enumCode", "code", "tooltip", "separator", "detailPlaceholder", "scrollFollowParent", "desensitization", "otherProps"];
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
- import { useEffect, useState, memo, useMemo } from 'react';
19
+ import { useEffect, useState, memo, useMemo, useCallback } from 'react';
20
+ import { useRequest as useRequestFunc, useDeepCompareEffect } from 'ahooks';
20
21
  import { transformDataName } from './utils/index';
21
22
  import { useProConfig } from '../../../../ProConfigProvider';
22
23
  import Input from '../../base/Input';
@@ -57,7 +58,7 @@ var getViewLabel = function getViewLabel(_ref) {
57
58
  return viewLabel;
58
59
  };
59
60
  var ProCascader = function ProCascader(props) {
60
- var _props$otherProps, _value$slice, _ref5, _ref5$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
61
+ var _props$otherProps, _useRequest$options3, _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
61
62
  var _ref2 = useProConfig('ProAddressBar') || {},
62
63
  configDetailMaxLength = _ref2.detailMaxLength,
63
64
  configEnumCode = _ref2.enumCode,
@@ -120,10 +121,6 @@ var ProCascader = function ProCascader(props) {
120
121
  }
121
122
  return disabled;
122
123
  }, [disabled]);
123
- var _useRequest = _objectSpread({}, useRequest),
124
- service = _useRequest.service,
125
- _useRequest$defaultPa = _useRequest.defaultParams,
126
- defaultParams = _useRequest$defaultPa === void 0 ? {} : _useRequest$defaultPa;
127
124
  var _useState = useState([]),
128
125
  _useState2 = _slicedToArray(_useState, 2),
129
126
  serviceData = _useState2[0],
@@ -132,53 +129,104 @@ var ProCascader = function ProCascader(props) {
132
129
  _useState4 = _slicedToArray(_useState3, 2),
133
130
  defaultLabel = _useState4[0],
134
131
  setDefaultLabel = _useState4[1];
135
- var getFirstLevelOptions = /*#__PURE__*/function () {
136
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
137
- var _yield$service, data, newData, transFormData, serviceData;
138
- return _regeneratorRuntime().wrap(function _callee$(_context) {
139
- while (1) switch (_context.prev = _context.next) {
140
- case 0:
141
- _context.next = 2;
142
- return service(defaultParams);
143
- case 2:
144
- _yield$service = _context.sent;
145
- data = _yield$service.data;
146
- newData = data;
147
- if (transformResponse) {
148
- newData = transformResponse(data);
149
- }
150
- transFormData = transformDataName(newData, {
151
- label: fieldNames.label,
152
- value: fieldNames.value,
153
- children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
154
- });
155
- serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
156
- setServiceData(serviceData);
157
- case 9:
158
- case "end":
159
- return _context.stop();
160
- }
161
- }, _callee);
162
- }));
163
- return function getFirstLevelOptions() {
164
- return _ref4.apply(this, arguments);
165
- };
166
- }();
132
+ // 默认成功处理函数
133
+ var defaultOnSuccessFun = function defaultOnSuccessFun(res) {
134
+ var _ref4 = res || {},
135
+ _ref4$status = _ref4.status,
136
+ status = _ref4$status === void 0 ? 200 : _ref4$status,
137
+ msg = _ref4.message,
138
+ data = _ref4.data;
139
+ if (status !== 200) {
140
+ _message.error(msg);
141
+ return;
142
+ }
143
+ var newData = data;
144
+ if (transformResponse) {
145
+ newData = transformResponse(data);
146
+ }
147
+ var transFormData = transformDataName(newData, {
148
+ label: fieldNames.label,
149
+ value: fieldNames.value,
150
+ children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
151
+ });
152
+ var serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
153
+ setServiceData(serviceData);
154
+ };
155
+ // 数据转换处理
156
+ var successTransformDataHandle = useCallback(function (res) {
157
+ if (transformResponse && typeof transformResponse === 'function') {
158
+ return transformResponse(res);
159
+ }
160
+ var _ref5 = res || {},
161
+ _ref5$status = _ref5.status,
162
+ status = _ref5$status === void 0 ? 200 : _ref5$status,
163
+ msg = _ref5.message,
164
+ data = _ref5.data;
165
+ if (status !== 200) {
166
+ _message.error(msg);
167
+ return;
168
+ }
169
+ return data;
170
+ }, [transformResponse]);
171
+ // 使用ahooks的useRequest
172
+ var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread(_objectSpread({
173
+ manual: true,
174
+ debounceWait: 300
175
+ }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
176
+ onSuccess: function onSuccess(data) {
177
+ var _useRequest$options, _useRequest$options$o, _useRequest$options2;
178
+ if (transformResponse && typeof transformResponse === 'function') {
179
+ var responseData = transformResponse(data);
180
+ var transFormData = transformDataName(responseData, {
181
+ label: fieldNames.label,
182
+ value: fieldNames.value,
183
+ children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
184
+ });
185
+ var _serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
186
+ setServiceData(_serviceData);
187
+ } else {
188
+ defaultOnSuccessFun(data);
189
+ }
190
+ // 执行传入的onSuccess
191
+ useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : (_useRequest$options$o = _useRequest$options.onSuccess) === null || _useRequest$options$o === void 0 ? void 0 : _useRequest$options$o.call(_useRequest$options, data, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams);
192
+ }
193
+ }));
194
+ // 缓存数据处理
195
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options3 = useRequest.options) === null || _useRequest$options3 === void 0 ? void 0 : _useRequest$options3.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
167
196
  // 提取出来默认每次都执行
168
197
  if (transformResponse) {
169
198
  realDataSource = transformResponse(realDataSource);
170
199
  }
171
- useEffect(function () {
172
- if (service) {
173
- // 传入useRequest时,初次加载级联第一级数据源
174
- getFirstLevelOptions();
200
+ // 设置缓存数据
201
+ useDeepCompareEffect(function () {
202
+ var _useRequest$options4;
203
+ if (!(serviceData === null || serviceData === void 0 ? void 0 : serviceData.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options4 = useRequest.options) === null || _useRequest$options4 === void 0 ? void 0 : _useRequest$options4.cacheKey)) {
204
+ if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
205
+ setServiceData(cacheList);
206
+ }
207
+ }
208
+ }, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
209
+ // 初始化请求数据
210
+ useDeepCompareEffect(function () {
211
+ var _useRequest$options5;
212
+ if (!(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service)) {
213
+ return;
214
+ }
215
+ var _ref6 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
216
+ manual = _ref6.manual;
217
+ if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
218
+ return;
175
219
  }
176
- }, [service]);
220
+ // 向后兼容性:优先使用 options.defaultParams,fallback 到 useRequest.defaultParams
221
+ var defaultParams = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options5 = useRequest.options) === null || _useRequest$options5 === void 0 ? void 0 : _useRequest$options5.defaultParams) || (useRequest === null || useRequest === void 0 ? void 0 : useRequest.defaultParams);
222
+ var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
223
+ fetchFunction.run(params);
224
+ }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
177
225
  useEffect(function () {
178
226
  if (realIsView && value) {
179
227
  var _realDataSource;
180
228
  // 传入dataSource + 查看时初始化展示
181
- if (service) {
229
+ if (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) {
182
230
  setDefaultLabel(getViewLabel({
183
231
  dataSource: serviceData,
184
232
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
@@ -217,9 +265,9 @@ var ProCascader = function ProCascader(props) {
217
265
  var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
218
266
  return !!item;
219
267
  })) ? value.slice(0, realLevel) : undefined : value;
220
- var viewValue = isAddressMode ? ((_ref5 = [].concat(_toConsumableArray(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref5 === void 0 ? void 0 : (_ref5$filter = _ref5.filter(function (item) {
268
+ var viewValue = isAddressMode ? ((_ref7 = [].concat(_toConsumableArray(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
221
269
  return !!item;
222
- })) === null || _ref5$filter === void 0 ? void 0 : _ref5$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
270
+ })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
223
271
  return !!item;
224
272
  })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
225
273
  var _findSelectedOptions = function findSelectedOptions(options, value) {
@@ -250,8 +298,8 @@ var ProCascader = function ProCascader(props) {
250
298
  return null;
251
299
  };
252
300
  var _selectedOptions = useMemo(function () {
253
- return _findSelectedOptions(service ? serviceData : realDataSource, addressValue);
254
- }, [service, serviceData, realDataSource, addressValue]);
301
+ return _findSelectedOptions((useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) ? serviceData : realDataSource, addressValue);
302
+ }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, serviceData, realDataSource, addressValue]);
255
303
  var handleAddressChange = function handleAddressChange(e) {
256
304
  var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
257
305
  if (onChange) {
@@ -276,8 +324,9 @@ var ProCascader = function ProCascader(props) {
276
324
  className: hasDetail ? '' : 'no-detail',
277
325
  placeholder: locale === null || locale === void 0 ? void 0 : (_locale$ProAddressBar = locale.ProAddressBar) === null || _locale$ProAddressBar === void 0 ? void 0 : _locale$ProAddressBar.placeholder,
278
326
  value: addressValue,
279
- options: service ? serviceData : realDataSource,
327
+ options: (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) ? serviceData : realDataSource,
280
328
  disabled: lastDisabled[0],
329
+ loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
281
330
  displayRender: displayRender,
282
331
  showSearch: {
283
332
  filter: handlefilter,
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { DefaultOptionType } from 'rc-select/lib/Select';
3
- import { Service } from 'ahooks/lib/useRequest/src/types';
3
+ import { Service, Options } from 'ahooks/lib/useRequest/src/types';
4
4
  export interface FieldNamesType {
5
5
  label: string;
6
6
  value: string;
@@ -19,10 +19,18 @@ export interface ProCascaderType {
19
19
  fieldNames?: FieldNamesType;
20
20
  dataSource?: DefaultOptionType[];
21
21
  useRequest?: {
22
- loadData?: boolean;
23
- service: Service<any, any>;
22
+ /**
23
+ * @description 请求服务函数
24
+ */
25
+ service?: Service<any, any>;
26
+ /**
27
+ * @description 请求选项
28
+ */
29
+ options?: Options<any, any>;
30
+ /**
31
+ * @deprecated 保留向后兼容性,使用 options.defaultParams 替代
32
+ */
24
33
  defaultParams?: any;
25
- parentKey?: string;
26
34
  };
27
35
  onChange?: (value: string[], selectedOptions?: any[]) => void;
28
36
  transformResponse?: (data: any[]) => any[];
@@ -9,7 +9,7 @@
9
9
  width: 45%;
10
10
 
11
11
  &.no-detail {
12
- width: 100% !important;
12
+ width: 100%;
13
13
  }
14
14
  }
15
15
 
@@ -35,7 +35,7 @@ import ConfirmWrapper from './ConfirmWrapper';
35
35
  import ChangedWrapper from './ChangedWrapper';
36
36
  // 这个组件只管渲染, 参数的整理在外部处理
37
37
  var Render = function Render(props) {
38
- var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
38
+ var _ref2, _ref3, _ref4, _ref5, _otherProps$names3;
39
39
  var component = props.component,
40
40
  originComponent = props.originComponent,
41
41
  _props$formItemProps = props.formItemProps,
@@ -447,9 +447,19 @@ var Render = function Render(props) {
447
447
  });
448
448
  }
449
449
  if (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues) {
450
+ var _otherProps$namePath, _otherProps$names2;
451
+ var _names = otherProps.names;
452
+ // FormList中的names字段需要去除前缀
453
+ if ((otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$namePath = otherProps.namePath) === null || _otherProps$namePath === void 0 ? void 0 : _otherProps$namePath.length) && ((_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length)) {
454
+ var _otherProps$namePath2;
455
+ var prefixLength = (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$namePath2 = otherProps.namePath) === null || _otherProps$namePath2 === void 0 ? void 0 : _otherProps$namePath2.length) - 1;
456
+ _names = otherProps.names.map(function (name) {
457
+ return name.slice(prefixLength);
458
+ });
459
+ }
450
460
  child = _jsx(ChangedWrapper, {
451
461
  name: formItemProps.name,
452
- names: otherProps.names,
462
+ names: _names,
453
463
  namesStr: namesStr,
454
464
  diffConfig: diffConfig,
455
465
  form: form,
@@ -482,7 +492,7 @@ var Render = function Render(props) {
482
492
  return renderItem();
483
493
  }
484
494
  })
485
- }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
495
+ }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names3 = otherProps.names) === null || _otherProps$names3 === void 0 ? void 0 : _otherProps$names3.length) ? otherProps.names.map(function (name) {
486
496
  return _jsx(_Form.Item, {
487
497
  hidden: true,
488
498
  name: name,
@@ -26,7 +26,8 @@ var ProStepItem = function ProStepItem(_ref) {
26
26
  var _useStep = useStep(),
27
27
  register = _useStep.register,
28
28
  collapse = _useStep.collapse,
29
- globalLazyLoad = _useStep.lazyLoad;
29
+ globalLazyLoad = _useStep.lazyLoad,
30
+ unNotify = _useStep.unNotify;
30
31
  var lazyLoad = stepLazyLoad !== null && stepLazyLoad !== void 0 ? stepLazyLoad : globalLazyLoad;
31
32
  useEffect(function () {
32
33
  // Schedule registration to avoid re-render issues
@@ -39,6 +40,7 @@ var ProStepItem = function ProStepItem(_ref) {
39
40
  }, restProps));
40
41
  }, 0);
41
42
  return function () {
43
+ unNotify([id]);
42
44
  clearTimeout(timeoutId);
43
45
  };
44
46
  }, [id, title, order, lazyLoad, restProps, register]);
@@ -58,8 +58,9 @@ var FormFooter = function FormFooter(props) {
58
58
  // 使用自定义验证逻辑
59
59
  form.validateFields().then(function () {
60
60
  onOk();
61
- }).catch(function () {
61
+ }).catch(function (error) {
62
62
  // 验证失败,不执行 onOk
63
+ console.log('校验失败', error);
63
64
  });
64
65
  } else {
65
66
  onOk();
@@ -9,6 +9,7 @@ exports.default = void 0;
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
+ var _omit2 = _interopRequireDefault(require("lodash/omit"));
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  var _react = _interopRequireDefault(require("react"));
14
15
  var _ConfirmWrapper = _interopRequireDefault(require("../../../../components/render/ConfirmWrapper"));
@@ -25,16 +26,17 @@ var wrapperMap = {
25
26
  // 增加middleware根据配置增加多层包裹
26
27
  var getComRender = function getComRender(component, props, componentProps) {
27
28
  var wrappers = Object.keys(wrapperMap);
28
- var Com = component;
29
+ var renderComponent = component;
29
30
  wrappers.forEach(function (item) {
30
31
  if (item in props) {
31
32
  var Wrapper = wrapperMap[item];
32
- Com = (0, _jsxRuntime.jsx)(Wrapper, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, componentProps), (0, _defineProperty2.default)({}, item, props[item])), {}, {
33
- children: Com
33
+ // console.log(props[item]);
34
+ renderComponent = (0, _jsxRuntime.jsx)(Wrapper, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, componentProps), (0, _defineProperty2.default)({}, item, props[item])), {}, {
35
+ children: renderComponent
34
36
  }));
35
37
  }
36
38
  });
37
- return Com;
39
+ return renderComponent;
38
40
  };
39
41
  /** 渲染组件 */
40
42
  var ComRender = function ComRender(props) {
@@ -57,8 +59,8 @@ var ComRender = function ComRender(props) {
57
59
  var mergedGetValueProps = getValueProps || function (val) {
58
60
  return (0, _defineProperty2.default)({}, valuePropName, val);
59
61
  };
60
- var _props = mergedGetValueProps(fieldProps.value);
61
- var componentProps = (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, fieldProps), rest), _props);
62
+ var nextProps = mergedGetValueProps(fieldProps.value);
63
+ var componentProps = (0, _omit2.default)((0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, fieldProps), rest), nextProps), ['onFieldChange']);
62
64
  var isSeparator = (props === null || props === void 0 ? void 0 : (_props$component = props.component) === null || _props$component === void 0 ? void 0 : (_props$component$prop = _props$component.props) === null || _props$component$prop === void 0 ? void 0 : _props$component$prop.className) === 'group-separator';
63
65
  if (isSeparator && isView) {
64
66
  var _props$component2, _props$component2$pro;
@@ -77,14 +79,14 @@ var ComRender = function ComRender(props) {
77
79
  });
78
80
  }
79
81
  var Component = component ? (/*#__PURE__*/_react.default.cloneElement(component, (0, _objectSpread3.default)({}, componentProps))) : (0, _jsxRuntime.jsx)(TypeComponent, (0, _objectSpread3.default)({}, componentProps));
80
- var Com = getComRender(Component, props, componentProps);
82
+ var renderComponent = getComRender(Component, props, componentProps);
81
83
  return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
82
84
  value: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, contextProps), {}, {
83
85
  valueType: valueType,
84
86
  type: type,
85
87
  isView: isView
86
88
  }),
87
- children: Com
89
+ children: renderComponent
88
90
  });
89
91
  };
90
92
  var _default = exports.default = ComRender;
@@ -46,13 +46,13 @@ var Group = function Group(props) {
46
46
  namePath = contextProps.namePath,
47
47
  index = contextProps.index,
48
48
  isView = contextProps.isView;
49
- var _option = _react.default.useRef([]);
49
+ var nextOption = _react.default.useRef([]);
50
50
  // 组合onChange
51
51
  var handleChange = function handleChange(value, option, index) {
52
- var _value = props.value ? (0, _toConsumableArray2.default)(props.value) : [];
53
- _value[index] = value;
54
- _option.current[index] = option;
55
- onChange(_value, _option.current);
52
+ var nextValue = props.value ? (0, _toConsumableArray2.default)(props.value) : [];
53
+ nextValue[index] = value;
54
+ nextOption.current[index] = option;
55
+ onChange(nextValue, nextOption.current);
56
56
  };
57
57
  var columnsProps = (0, _hooks.useTransformColumns)({
58
58
  columns: children,
@@ -68,7 +68,7 @@ var Group = function Group(props) {
68
68
  desensitizationKey: desensitizationKey
69
69
  });
70
70
  var columns = (0, _utils.insertSeparator)(columnsProps, space);
71
- var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
71
+ var nextClassName = (0, _classnames2.default)((0, _defineProperty2.default)({
72
72
  'pro-group': true,
73
73
  'pro-group-diy-width': columns.some(function (item) {
74
74
  var _item$fieldProps, _item$fieldProps$styl;
@@ -79,7 +79,7 @@ var Group = function Group(props) {
79
79
  })
80
80
  }, "".concat(className), className));
81
81
  return (0, _jsxRuntime.jsx)("div", {
82
- className: _className,
82
+ className: nextClassName,
83
83
  id: id,
84
84
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_space.default.Compact, {
85
85
  children: columns.map(function (column, index) {
@@ -10,8 +10,8 @@ var _tooltip = _interopRequireDefault(require("antd/es/tooltip"));
10
10
  require("antd/es/cascader/style");
11
11
  var _cascader = _interopRequireDefault(require("antd/es/cascader"));
12
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
- var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+ require("antd/es/message/style");
14
+ var _message2 = _interopRequireDefault(require("antd/es/message"));
15
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -23,6 +23,7 @@ var _find = _interopRequireDefault(require("lodash/find"));
23
23
  var _omit2 = _interopRequireDefault(require("lodash/omit"));
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
  var _react = require("react");
26
+ var _ahooks = require("ahooks");
26
27
  var _index = require("./utils/index");
27
28
  var _ProConfigProvider = require("../../../../ProConfigProvider");
28
29
  var _Input = _interopRequireDefault(require("../../base/Input"));
@@ -64,7 +65,7 @@ var getViewLabel = function getViewLabel(_ref) {
64
65
  return viewLabel;
65
66
  };
66
67
  var ProCascader = function ProCascader(props) {
67
- var _props$otherProps, _value$slice, _ref5, _ref5$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
68
+ var _props$otherProps, _useRequest$options3, _value$slice, _ref7, _ref7$filter, _defaultLabel$filter, _locale$ProAddressBar, _locale$ProAddressBar2;
68
69
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProAddressBar') || {},
69
70
  configDetailMaxLength = _ref2.detailMaxLength,
70
71
  configEnumCode = _ref2.enumCode,
@@ -127,10 +128,6 @@ var ProCascader = function ProCascader(props) {
127
128
  }
128
129
  return disabled;
129
130
  }, [disabled]);
130
- var _useRequest = (0, _objectSpread3.default)({}, useRequest),
131
- service = _useRequest.service,
132
- _useRequest$defaultPa = _useRequest.defaultParams,
133
- defaultParams = _useRequest$defaultPa === void 0 ? {} : _useRequest$defaultPa;
134
131
  var _useState = (0, _react.useState)([]),
135
132
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
136
133
  serviceData = _useState2[0],
@@ -139,53 +136,104 @@ var ProCascader = function ProCascader(props) {
139
136
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
140
137
  defaultLabel = _useState4[0],
141
138
  setDefaultLabel = _useState4[1];
142
- var getFirstLevelOptions = /*#__PURE__*/function () {
143
- var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
144
- var _yield$service, data, newData, transFormData, serviceData;
145
- return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
146
- while (1) switch (_context.prev = _context.next) {
147
- case 0:
148
- _context.next = 2;
149
- return service(defaultParams);
150
- case 2:
151
- _yield$service = _context.sent;
152
- data = _yield$service.data;
153
- newData = data;
154
- if (transformResponse) {
155
- newData = transformResponse(data);
156
- }
157
- transFormData = (0, _index.transformDataName)(newData, {
158
- label: fieldNames.label,
159
- value: fieldNames.value,
160
- children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
161
- });
162
- serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
163
- setServiceData(serviceData);
164
- case 9:
165
- case "end":
166
- return _context.stop();
167
- }
168
- }, _callee);
169
- }));
170
- return function getFirstLevelOptions() {
171
- return _ref4.apply(this, arguments);
172
- };
173
- }();
139
+ // 默认成功处理函数
140
+ var defaultOnSuccessFun = function defaultOnSuccessFun(res) {
141
+ var _ref4 = res || {},
142
+ _ref4$status = _ref4.status,
143
+ status = _ref4$status === void 0 ? 200 : _ref4$status,
144
+ msg = _ref4.message,
145
+ data = _ref4.data;
146
+ if (status !== 200) {
147
+ _message2.default.error(msg);
148
+ return;
149
+ }
150
+ var newData = data;
151
+ if (transformResponse) {
152
+ newData = transformResponse(data);
153
+ }
154
+ var transFormData = (0, _index.transformDataName)(newData, {
155
+ label: fieldNames.label,
156
+ value: fieldNames.value,
157
+ children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
158
+ });
159
+ var serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
160
+ setServiceData(serviceData);
161
+ };
162
+ // 数据转换处理
163
+ var successTransformDataHandle = (0, _react.useCallback)(function (res) {
164
+ if (transformResponse && typeof transformResponse === 'function') {
165
+ return transformResponse(res);
166
+ }
167
+ var _ref5 = res || {},
168
+ _ref5$status = _ref5.status,
169
+ status = _ref5$status === void 0 ? 200 : _ref5$status,
170
+ msg = _ref5.message,
171
+ data = _ref5.data;
172
+ if (status !== 200) {
173
+ _message2.default.error(msg);
174
+ return;
175
+ }
176
+ return data;
177
+ }, [transformResponse]);
178
+ // 使用ahooks的useRequest
179
+ var fetchFunction = (0, _ahooks.useRequest)(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, (0, _objectSpread3.default)((0, _objectSpread3.default)({
180
+ manual: true,
181
+ debounceWait: 300
182
+ }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
183
+ onSuccess: function onSuccess(data) {
184
+ var _useRequest$options, _useRequest$options$o, _useRequest$options2;
185
+ if (transformResponse && typeof transformResponse === 'function') {
186
+ var responseData = transformResponse(data);
187
+ var transFormData = (0, _index.transformDataName)(responseData, {
188
+ label: fieldNames.label,
189
+ value: fieldNames.value,
190
+ children: (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children'
191
+ });
192
+ var _serviceData = isAddressMode && realLevel === 2 ? _filterDataSource(transFormData, level, fieldNames) : transFormData;
193
+ setServiceData(_serviceData);
194
+ } else {
195
+ defaultOnSuccessFun(data);
196
+ }
197
+ // 执行传入的onSuccess
198
+ useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : (_useRequest$options$o = _useRequest$options.onSuccess) === null || _useRequest$options$o === void 0 ? void 0 : _useRequest$options$o.call(_useRequest$options, data, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.defaultParams);
199
+ }
200
+ }));
201
+ // 缓存数据处理
202
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options3 = useRequest.options) === null || _useRequest$options3 === void 0 ? void 0 : _useRequest$options3.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
174
203
  // 提取出来默认每次都执行
175
204
  if (transformResponse) {
176
205
  realDataSource = transformResponse(realDataSource);
177
206
  }
178
- (0, _react.useEffect)(function () {
179
- if (service) {
180
- // 传入useRequest时,初次加载级联第一级数据源
181
- getFirstLevelOptions();
207
+ // 设置缓存数据
208
+ (0, _ahooks.useDeepCompareEffect)(function () {
209
+ var _useRequest$options4;
210
+ if (!(serviceData === null || serviceData === void 0 ? void 0 : serviceData.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options4 = useRequest.options) === null || _useRequest$options4 === void 0 ? void 0 : _useRequest$options4.cacheKey)) {
211
+ if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
212
+ setServiceData(cacheList);
213
+ }
214
+ }
215
+ }, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
216
+ // 初始化请求数据
217
+ (0, _ahooks.useDeepCompareEffect)(function () {
218
+ var _useRequest$options5;
219
+ if (!(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service)) {
220
+ return;
221
+ }
222
+ var _ref6 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
223
+ manual = _ref6.manual;
224
+ if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
225
+ return;
182
226
  }
183
- }, [service]);
227
+ // 向后兼容性:优先使用 options.defaultParams,fallback 到 useRequest.defaultParams
228
+ var defaultParams = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options5 = useRequest.options) === null || _useRequest$options5 === void 0 ? void 0 : _useRequest$options5.defaultParams) || (useRequest === null || useRequest === void 0 ? void 0 : useRequest.defaultParams);
229
+ var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
230
+ fetchFunction.run(params);
231
+ }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
184
232
  (0, _react.useEffect)(function () {
185
233
  if (realIsView && value) {
186
234
  var _realDataSource;
187
235
  // 传入dataSource + 查看时初始化展示
188
- if (service) {
236
+ if (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) {
189
237
  setDefaultLabel(getViewLabel({
190
238
  dataSource: serviceData,
191
239
  value: isAddressMode && hasDetail ? value === null || value === void 0 ? void 0 : value.slice(0, realLevel) : value
@@ -224,9 +272,9 @@ var ProCascader = function ProCascader(props) {
224
272
  var addressValue = isAddressMode ? value && ((_value$slice = value.slice(0, realLevel)) === null || _value$slice === void 0 ? void 0 : _value$slice.some(function (item) {
225
273
  return !!item;
226
274
  })) ? value.slice(0, realLevel) : undefined : value;
227
- var viewValue = isAddressMode ? ((_ref5 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref5 === void 0 ? void 0 : (_ref5$filter = _ref5.filter(function (item) {
275
+ var viewValue = isAddressMode ? ((_ref7 = [].concat((0, _toConsumableArray2.default)(defaultLabel), [value === null || value === void 0 ? void 0 : value[realLevel]])) === null || _ref7 === void 0 ? void 0 : (_ref7$filter = _ref7.filter(function (item) {
228
276
  return !!item;
229
- })) === null || _ref5$filter === void 0 ? void 0 : _ref5$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
277
+ })) === null || _ref7$filter === void 0 ? void 0 : _ref7$filter.join(separator)) || '-' : (defaultLabel === null || defaultLabel === void 0 ? void 0 : (_defaultLabel$filter = defaultLabel.filter(function (item) {
230
278
  return !!item;
231
279
  })) === null || _defaultLabel$filter === void 0 ? void 0 : _defaultLabel$filter.join(separator)) || '-';
232
280
  var _findSelectedOptions = function findSelectedOptions(options, value) {
@@ -257,8 +305,8 @@ var ProCascader = function ProCascader(props) {
257
305
  return null;
258
306
  };
259
307
  var _selectedOptions = (0, _react.useMemo)(function () {
260
- return _findSelectedOptions(service ? serviceData : realDataSource, addressValue);
261
- }, [service, serviceData, realDataSource, addressValue]);
308
+ return _findSelectedOptions((useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) ? serviceData : realDataSource, addressValue);
309
+ }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, serviceData, realDataSource, addressValue]);
262
310
  var handleAddressChange = function handleAddressChange(e) {
263
311
  var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
264
312
  if (onChange) {
@@ -283,8 +331,9 @@ var ProCascader = function ProCascader(props) {
283
331
  className: hasDetail ? '' : 'no-detail',
284
332
  placeholder: _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProAddressBar = _locale.default.ProAddressBar) === null || _locale$ProAddressBar === void 0 ? void 0 : _locale$ProAddressBar.placeholder,
285
333
  value: addressValue,
286
- options: service ? serviceData : realDataSource,
334
+ options: (useRequest === null || useRequest === void 0 ? void 0 : useRequest.service) ? serviceData : realDataSource,
287
335
  disabled: lastDisabled[0],
336
+ loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
288
337
  displayRender: displayRender,
289
338
  showSearch: {
290
339
  filter: handlefilter,
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { DefaultOptionType } from 'rc-select/lib/Select';
3
- import { Service } from 'ahooks/lib/useRequest/src/types';
3
+ import { Service, Options } from 'ahooks/lib/useRequest/src/types';
4
4
  export interface FieldNamesType {
5
5
  label: string;
6
6
  value: string;
@@ -19,10 +19,18 @@ export interface ProCascaderType {
19
19
  fieldNames?: FieldNamesType;
20
20
  dataSource?: DefaultOptionType[];
21
21
  useRequest?: {
22
- loadData?: boolean;
23
- service: Service<any, any>;
22
+ /**
23
+ * @description 请求服务函数
24
+ */
25
+ service?: Service<any, any>;
26
+ /**
27
+ * @description 请求选项
28
+ */
29
+ options?: Options<any, any>;
30
+ /**
31
+ * @deprecated 保留向后兼容性,使用 options.defaultParams 替代
32
+ */
24
33
  defaultParams?: any;
25
- parentKey?: string;
26
34
  };
27
35
  onChange?: (value: string[], selectedOptions?: any[]) => void;
28
36
  transformResponse?: (data: any[]) => any[];
@@ -9,7 +9,7 @@
9
9
  width: 45%;
10
10
 
11
11
  &.no-detail {
12
- width: 100% !important;
12
+ width: 100%;
13
13
  }
14
14
  }
15
15
 
@@ -42,7 +42,7 @@ var _excluded = ["labelWidth", "hiddenNames", "trim", "upperCase", "className",
42
42
  /* eslint-disable prefer-destructuring */
43
43
  // 这个组件只管渲染, 参数的整理在外部处理
44
44
  var Render = function Render(props) {
45
- var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
45
+ var _ref2, _ref3, _ref4, _ref5, _otherProps$names3;
46
46
  var component = props.component,
47
47
  originComponent = props.originComponent,
48
48
  _props$formItemProps = props.formItemProps,
@@ -454,9 +454,19 @@ var Render = function Render(props) {
454
454
  });
455
455
  }
456
456
  if (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues) {
457
+ var _otherProps$namePath, _otherProps$names2;
458
+ var _names = otherProps.names;
459
+ // FormList中的names字段需要去除前缀
460
+ if ((otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$namePath = otherProps.namePath) === null || _otherProps$namePath === void 0 ? void 0 : _otherProps$namePath.length) && ((_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length)) {
461
+ var _otherProps$namePath2;
462
+ var prefixLength = (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$namePath2 = otherProps.namePath) === null || _otherProps$namePath2 === void 0 ? void 0 : _otherProps$namePath2.length) - 1;
463
+ _names = otherProps.names.map(function (name) {
464
+ return name.slice(prefixLength);
465
+ });
466
+ }
457
467
  child = (0, _jsxRuntime.jsx)(_ChangedWrapper.default, {
458
468
  name: formItemProps.name,
459
- names: otherProps.names,
469
+ names: _names,
460
470
  namesStr: namesStr,
461
471
  diffConfig: diffConfig,
462
472
  form: form,
@@ -489,7 +499,7 @@ var Render = function Render(props) {
489
499
  return renderItem();
490
500
  }
491
501
  })
492
- }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
502
+ }) : renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names3 = otherProps.names) === null || _otherProps$names3 === void 0 ? void 0 : _otherProps$names3.length) ? otherProps.names.map(function (name) {
493
503
  return (0, _jsxRuntime.jsx)(_form.default.Item, {
494
504
  hidden: true,
495
505
  name: name,
@@ -34,7 +34,8 @@ var ProStepItem = function ProStepItem(_ref) {
34
34
  var _useStep = (0, _index.useStep)(),
35
35
  register = _useStep.register,
36
36
  collapse = _useStep.collapse,
37
- globalLazyLoad = _useStep.lazyLoad;
37
+ globalLazyLoad = _useStep.lazyLoad,
38
+ unNotify = _useStep.unNotify;
38
39
  var lazyLoad = stepLazyLoad !== null && stepLazyLoad !== void 0 ? stepLazyLoad : globalLazyLoad;
39
40
  (0, _react.useEffect)(function () {
40
41
  // Schedule registration to avoid re-render issues
@@ -47,6 +48,7 @@ var ProStepItem = function ProStepItem(_ref) {
47
48
  }, restProps));
48
49
  }, 0);
49
50
  return function () {
51
+ unNotify([id]);
50
52
  clearTimeout(timeoutId);
51
53
  };
52
54
  }, [id, title, order, lazyLoad, restProps, register]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.13.14-deta.2",
3
+ "version": "3.13.15-beta.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,8 +0,0 @@
1
- export declare const useChanged: ({ name, names, namesStr, originalValues, form, onDiff }: {
2
- name: any;
3
- names: any;
4
- namesStr: any;
5
- originalValues: any;
6
- form: any;
7
- onDiff: any;
8
- }) => any[];
@@ -1,25 +0,0 @@
1
- import "antd/es/form/style";
2
- import _Form from "antd/es/form";
3
- import _get from "lodash/get";
4
- import { diffOriginal } from './diffOriginal';
5
- export var useChanged = function useChanged(_ref) {
6
- var name = _ref.name,
7
- names = _ref.names,
8
- namesStr = _ref.namesStr,
9
- originalValues = _ref.originalValues,
10
- form = _ref.form,
11
- onDiff = _ref.onDiff;
12
- var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
13
- return _get(originalValues, name);
14
- }) : _get(originalValues, name);
15
- var notWatch = !onDiff && (!originalValues || originalValue === undefined);
16
- if (notWatch) return [false];
17
- var value = _Form.useWatch(namesStr || name, form);
18
- var changed = diffOriginal({
19
- originalValue: originalValue,
20
- value: value,
21
- form: form,
22
- onDiff: onDiff
23
- });
24
- return [changed, originalValue];
25
- };
@@ -1,16 +0,0 @@
1
- import { FormInstance } from 'antd';
2
- import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
3
- interface Params {
4
- name?: any;
5
- names?: NamePath[];
6
- namesStr?: NamePath;
7
- originalName?: NamePath;
8
- originalNames?: NamePath[];
9
- originalNameStr?: NamePath;
10
- originalValues: any;
11
- form: FormInstance;
12
- rowKeyPath?: InternalNamePath;
13
- onDiff?: (originalValue: any, currentValue: any) => boolean;
14
- }
15
- export declare const useListChanged: (params: Params) => any[];
16
- export {};
@@ -1,93 +0,0 @@
1
- import "antd/es/form/style";
2
- import _Form from "antd/es/form";
3
- import _get from "lodash/get";
4
- import { diffOriginal } from './diffOriginal';
5
- var toNamePath = function toNamePath(name) {
6
- if (Array.isArray(name)) {
7
- return name;
8
- }
9
- return [name];
10
- };
11
- var toNamePaths = function toNamePaths(names) {
12
- return names.map(function (name) {
13
- return toNamePath(name);
14
- });
15
- };
16
- var getOriginalValue = function getOriginalValue(_ref) {
17
- var namePath = _ref.namePath,
18
- originalName = _ref.originalName,
19
- originalNames = _ref.originalNames,
20
- originalValues = _ref.originalValues,
21
- rowKeyPath = _ref.rowKeyPath,
22
- form = _ref.form;
23
- if (!originalValues) {
24
- return undefined;
25
- }
26
- if (rowKeyPath) {
27
- var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
28
- var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
29
- var rowValue = form.getFieldValue(rowValueNamePath);
30
- if (!rowValue) return undefined;
31
- var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
32
- if (!keyValue) return undefined;
33
- var originalValueList = _get(originalValues, originalName.slice(0, rowKeyPath.length - 2));
34
- var originalValueRow = originalValueList.find(function (item) {
35
- return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
36
- });
37
- var originalValue;
38
- if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
39
- var originalNamesValue = originalNames.map(function (originalName) {
40
- return _get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
41
- });
42
- // 有可能出现数组中全是undefined的情况 视为没有值
43
- var fillUndefined = originalNamesValue.every(function (valItem) {
44
- return valItem === undefined;
45
- });
46
- originalValue = fillUndefined ? undefined : originalNamesValue;
47
- } else {
48
- originalValue = _get(originalValueRow, originalName.slice(rowKeyPath.length - 1));
49
- }
50
- return originalValue;
51
- }
52
- // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
53
- return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
54
- return _get(originalValues, originalName);
55
- }) : _get(originalValues, originalName);
56
- };
57
- export var useListChanged = function useListChanged(params) {
58
- var name = params.name,
59
- names = params.names,
60
- namesStr = params.namesStr,
61
- _params$originalName = params.originalName,
62
- originalName = _params$originalName === void 0 ? name : _params$originalName,
63
- _params$originalNames = params.originalNames,
64
- originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
65
- originalValues = params.originalValues,
66
- form = params.form,
67
- onDiff = params.onDiff,
68
- rowKeyPath = params.rowKeyPath;
69
- var namePath = toNamePath(namesStr || name);
70
- var originalNamePath = toNamePath(originalName);
71
- var originalNamePaths = originalNames && toNamePaths(originalNames);
72
- var notWatch = !originalValues;
73
- var originalValue = !notWatch ? getOriginalValue({
74
- namePath: namePath,
75
- originalName: originalNamePath,
76
- originalNames: originalNamePaths,
77
- originalValues: originalValues,
78
- rowKeyPath: rowKeyPath,
79
- form: form
80
- }) : undefined;
81
- var noChange = !onDiff && (!originalValues || originalValue === undefined);
82
- var _form = form;
83
- if (notWatch || noChange) return [false];
84
- var value = _Form.useWatch(namePath, _form);
85
- var changed = diffOriginal({
86
- value: value,
87
- originalValue: originalValue,
88
- form: form,
89
- onDiff: onDiff
90
- // name: isString(namesStr) ? namesStr : originalName || name,
91
- });
92
- return [changed, originalValue];
93
- };
@@ -1,8 +0,0 @@
1
- export declare const useChanged: ({ name, names, namesStr, originalValues, form, onDiff }: {
2
- name: any;
3
- names: any;
4
- namesStr: any;
5
- originalValues: any;
6
- form: any;
7
- onDiff: any;
8
- }) => any[];
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useChanged = void 0;
8
- require("antd/es/form/style");
9
- var _form = _interopRequireDefault(require("antd/es/form"));
10
- var _get2 = _interopRequireDefault(require("lodash/get"));
11
- var _diffOriginal = require("./diffOriginal");
12
- var useChanged = exports.useChanged = function useChanged(_ref) {
13
- var name = _ref.name,
14
- names = _ref.names,
15
- namesStr = _ref.namesStr,
16
- originalValues = _ref.originalValues,
17
- form = _ref.form,
18
- onDiff = _ref.onDiff;
19
- var originalValue = (names === null || names === void 0 ? void 0 : names.length) ? names.map(function (name) {
20
- return (0, _get2.default)(originalValues, name);
21
- }) : (0, _get2.default)(originalValues, name);
22
- var notWatch = !onDiff && (!originalValues || originalValue === undefined);
23
- if (notWatch) return [false];
24
- var value = _form.default.useWatch(namesStr || name, form);
25
- var changed = (0, _diffOriginal.diffOriginal)({
26
- originalValue: originalValue,
27
- value: value,
28
- form: form,
29
- onDiff: onDiff
30
- });
31
- return [changed, originalValue];
32
- };
@@ -1,16 +0,0 @@
1
- import { FormInstance } from 'antd';
2
- import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
3
- interface Params {
4
- name?: any;
5
- names?: NamePath[];
6
- namesStr?: NamePath;
7
- originalName?: NamePath;
8
- originalNames?: NamePath[];
9
- originalNameStr?: NamePath;
10
- originalValues: any;
11
- form: FormInstance;
12
- rowKeyPath?: InternalNamePath;
13
- onDiff?: (originalValue: any, currentValue: any) => boolean;
14
- }
15
- export declare const useListChanged: (params: Params) => any[];
16
- export {};
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useListChanged = void 0;
8
- require("antd/es/form/style");
9
- var _form2 = _interopRequireDefault(require("antd/es/form"));
10
- var _get2 = _interopRequireDefault(require("lodash/get"));
11
- var _diffOriginal = require("./diffOriginal");
12
- var toNamePath = function toNamePath(name) {
13
- if (Array.isArray(name)) {
14
- return name;
15
- }
16
- return [name];
17
- };
18
- var toNamePaths = function toNamePaths(names) {
19
- return names.map(function (name) {
20
- return toNamePath(name);
21
- });
22
- };
23
- var getOriginalValue = function getOriginalValue(_ref) {
24
- var namePath = _ref.namePath,
25
- originalName = _ref.originalName,
26
- originalNames = _ref.originalNames,
27
- originalValues = _ref.originalValues,
28
- rowKeyPath = _ref.rowKeyPath,
29
- form = _ref.form;
30
- if (!originalValues) {
31
- return undefined;
32
- }
33
- if (rowKeyPath) {
34
- var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
35
- var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
36
- var rowValue = form.getFieldValue(rowValueNamePath);
37
- if (!rowValue) return undefined;
38
- var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
39
- if (!keyValue) return undefined;
40
- var originalValueList = (0, _get2.default)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
41
- var originalValueRow = originalValueList.find(function (item) {
42
- return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
43
- });
44
- var originalValue;
45
- if (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) {
46
- var originalNamesValue = originalNames.map(function (originalName) {
47
- return (0, _get2.default)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
48
- });
49
- // 有可能出现数组中全是undefined的情况 视为没有值
50
- var fillUndefined = originalNamesValue.every(function (valItem) {
51
- return valItem === undefined;
52
- });
53
- originalValue = fillUndefined ? undefined : originalNamesValue;
54
- } else {
55
- originalValue = (0, _get2.default)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
56
- }
57
- return originalValue;
58
- }
59
- // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
60
- return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
61
- return (0, _get2.default)(originalValues, originalName);
62
- }) : (0, _get2.default)(originalValues, originalName);
63
- };
64
- var useListChanged = exports.useListChanged = function useListChanged(params) {
65
- var name = params.name,
66
- names = params.names,
67
- namesStr = params.namesStr,
68
- _params$originalName = params.originalName,
69
- originalName = _params$originalName === void 0 ? name : _params$originalName,
70
- _params$originalNames = params.originalNames,
71
- originalNames = _params$originalNames === void 0 ? names : _params$originalNames,
72
- originalValues = params.originalValues,
73
- form = params.form,
74
- onDiff = params.onDiff,
75
- rowKeyPath = params.rowKeyPath;
76
- var namePath = toNamePath(namesStr || name);
77
- var originalNamePath = toNamePath(originalName);
78
- var originalNamePaths = originalNames && toNamePaths(originalNames);
79
- var notWatch = !originalValues;
80
- var originalValue = !notWatch ? getOriginalValue({
81
- namePath: namePath,
82
- originalName: originalNamePath,
83
- originalNames: originalNamePaths,
84
- originalValues: originalValues,
85
- rowKeyPath: rowKeyPath,
86
- form: form
87
- }) : undefined;
88
- var noChange = !onDiff && (!originalValues || originalValue === undefined);
89
- var _form = form;
90
- if (notWatch || noChange) return [false];
91
- var value = _form2.default.useWatch(namePath, _form);
92
- var changed = (0, _diffOriginal.diffOriginal)({
93
- value: value,
94
- originalValue: originalValue,
95
- form: form,
96
- onDiff: onDiff
97
- // name: isString(namesStr) ? namesStr : originalName || name,
98
- });
99
- return [changed, originalValue];
100
- };