@zat-design/sisyphus-react 3.13.6 → 3.13.7-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 (33) hide show
  1. package/es/ProAction/components/CheckModalContent/index.d.ts +8 -0
  2. package/es/ProAction/components/CheckModalContent/index.js +44 -0
  3. package/es/ProAction/components/CheckModalContent/index.less +29 -0
  4. package/es/ProAction/index.js +38 -38
  5. package/es/ProAction/propsType.d.ts +7 -0
  6. package/es/ProTable/components/FormatColumn/index.js +4 -4
  7. package/es/ProTable/hooks/useAntdTable.js +28 -19
  8. package/es/ProTable/propsType.d.ts +2 -2
  9. package/es/ProTable/utils/index.js +2 -2
  10. package/es/ProTree/components/AdaptiveTooltip.js +4 -30
  11. package/es/ProTree/components/ProTree.js +0 -1
  12. package/es/ProTree/components/ProTreeSelect/index.js +52 -12
  13. package/es/locale/en_US.d.ts +1 -0
  14. package/es/locale/en_US.js +1 -0
  15. package/es/locale/zh_CN.d.ts +1 -0
  16. package/es/locale/zh_CN.js +1 -0
  17. package/lib/ProAction/components/CheckModalContent/index.d.ts +8 -0
  18. package/lib/ProAction/components/CheckModalContent/index.js +49 -0
  19. package/lib/ProAction/components/CheckModalContent/index.less +29 -0
  20. package/lib/ProAction/index.js +38 -38
  21. package/lib/ProAction/propsType.d.ts +7 -0
  22. package/lib/ProTable/components/FormatColumn/index.js +4 -4
  23. package/lib/ProTable/hooks/useAntdTable.js +25 -18
  24. package/lib/ProTable/propsType.d.ts +2 -2
  25. package/lib/ProTable/utils/index.js +2 -2
  26. package/lib/ProTree/components/AdaptiveTooltip.js +3 -30
  27. package/lib/ProTree/components/ProTree.js +0 -1
  28. package/lib/ProTree/components/ProTreeSelect/index.js +51 -11
  29. package/lib/locale/en_US.d.ts +1 -0
  30. package/lib/locale/en_US.js +1 -0
  31. package/lib/locale/zh_CN.d.ts +1 -0
  32. package/lib/locale/zh_CN.js +1 -0
  33. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import './index.less';
2
+ interface propsWithCheckModal {
3
+ errorTitle?: string;
4
+ list?: string[];
5
+ [key: string]: any;
6
+ }
7
+ declare const CheckModalContent: (props: propsWithCheckModal) => import("react/jsx-runtime").JSX.Element;
8
+ export default CheckModalContent;
@@ -0,0 +1,44 @@
1
+ import "antd/es/tooltip/style";
2
+ import _Tooltip from "antd/es/tooltip";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ /*
5
+ * @Author: za-xuwenli xuwenli@zhongan.io
6
+ * @Date: 2025-02-17 11:49:02
7
+ * @LastEditors: za-xuwenli xuwenli@zhongan.io
8
+ * @LastEditTime: 2025-05-28 18:23:47
9
+ * @FilePath: /zat-wjs-pro-product-web/src/components/CheckModalContent/index.tsx
10
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
11
+ */
12
+
13
+ import './index.less';
14
+ var CheckModalContent = function CheckModalContent(props) {
15
+ var _ref = props !== null && props !== void 0 ? props : {},
16
+ errorTitle = _ref.errorTitle,
17
+ _ref$list = _ref.list,
18
+ list = _ref$list === void 0 ? [] : _ref$list;
19
+ return _jsx("div", {
20
+ className: "pro-action-check-modal-box",
21
+ children: _jsxs("div", {
22
+ className: "res-err-list",
23
+ children: [_jsx("span", {
24
+ className: "err-tip",
25
+ children: errorTitle
26
+ }), _jsxs(_Tooltip, {
27
+ title: list.join('\n') || [],
28
+ children: [Array.isArray(list) && list.length === 1 ? _jsx("span", {
29
+ className: "err-item",
30
+ children: list[0]
31
+ }) : null, Array.isArray(list) && list.length > 1 ? _jsx("div", {
32
+ className: "list-wrap",
33
+ children: list.map(function (item) {
34
+ return _jsx("div", {
35
+ className: "err-item",
36
+ children: item
37
+ });
38
+ })
39
+ }) : null]
40
+ })]
41
+ })
42
+ });
43
+ };
44
+ export default CheckModalContent;
@@ -0,0 +1,29 @@
1
+ .pro-action-check-modal-box {
2
+ .res-err-list {
3
+ .err-tip {
4
+ color: #666;
5
+ }
6
+
7
+ .err-item {
8
+ box-sizing: border-box;
9
+ padding-left: 6px;
10
+ color: #333;
11
+ border-radius: 4px;
12
+ &:hover {
13
+ color: var(--zaui-brand);
14
+ background-color: #f0f0f0;
15
+ }
16
+ }
17
+
18
+ .list-wrap {
19
+ box-sizing: border-box;
20
+ height: 110px;
21
+ margin-top: 12px;
22
+ padding: 4px;
23
+ overflow-y: auto;
24
+ line-height: 1.8;
25
+ border: 1px solid #ccc;
26
+ border-radius: 6px;
27
+ }
28
+ }
29
+ }
@@ -1,3 +1,4 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import "antd/es/popconfirm/style";
2
3
  import _Popconfirm from "antd/es/popconfirm";
3
4
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
@@ -10,6 +11,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
10
11
  import React from 'react';
11
12
  import { useSetState } from 'ahooks';
12
13
  import { isFunction } from 'lodash';
14
+ import CheckModalContent from './components/CheckModalContent';
13
15
  import { ProDrawerForm } from '../index';
14
16
  import locale from '../locale';
15
17
  import './index.less';
@@ -24,7 +26,8 @@ var ProAction = function ProAction(props) {
24
26
  index: 0,
25
27
  open: false,
26
28
  servicesArray: [],
27
- loading: false
29
+ loading: false,
30
+ errorModalDataSource: null
28
31
  }),
29
32
  _useSetState2 = _slicedToArray(_useSetState, 2),
30
33
  state = _useSetState2[0],
@@ -37,12 +40,12 @@ var ProAction = function ProAction(props) {
37
40
  });
38
41
  }
39
42
  var index = state.index,
40
- servicesArray = state.servicesArray;
43
+ errorModalDataSource = state.errorModalDataSource;
41
44
  var length = config.length;
42
45
  var _onActionRun = /*#__PURE__*/function () {
43
46
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(currentIndex, array) {
44
47
  var _actionProps$useReque, _options$defaultParam, _options$onSuccess, _newServicesArray$cur, _newServicesArray$cur2, _newServicesArray$cur3, _actionProps$onAction, _actionProps$continue;
45
- var actionProps, newServicesArray, _ref2, service, options, transformResponse, params, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, _newServicesArray$cur6, list, errorTitle, isContinue;
48
+ var actionProps, newServicesArray, _ref2, service, options, transformResponse, params, res, data, open, _newServicesArray$cur4, _newServicesArray$cur5, list, errorTitle, isContinue;
46
49
  return _regeneratorRuntime().wrap(function _callee$(_context) {
47
50
  while (1) switch (_context.prev = _context.next) {
48
51
  case 0:
@@ -109,14 +112,18 @@ var ProAction = function ProAction(props) {
109
112
  _context.next = 37;
110
113
  break;
111
114
  }
112
- list = ((_newServicesArray$cur4 = newServicesArray[currentIndex]) === null || _newServicesArray$cur4 === void 0 ? void 0 : (_newServicesArray$cur5 = _newServicesArray$cur4.list) === null || _newServicesArray$cur5 === void 0 ? void 0 : _newServicesArray$cur5.join('\n')) || [];
113
- errorTitle = (_newServicesArray$cur6 = newServicesArray[currentIndex]) === null || _newServicesArray$cur6 === void 0 ? void 0 : _newServicesArray$cur6.errorTitle;
115
+ list = ((_newServicesArray$cur4 = newServicesArray[currentIndex]) === null || _newServicesArray$cur4 === void 0 ? void 0 : _newServicesArray$cur4.list) || [];
116
+ errorTitle = (_newServicesArray$cur5 = newServicesArray[currentIndex]) === null || _newServicesArray$cur5 === void 0 ? void 0 : _newServicesArray$cur5.errorTitle;
114
117
  form.setFieldsValue({
115
118
  errorTitle: errorTitle,
116
119
  list: list
117
120
  });
118
121
  setState({
119
- loading: false
122
+ loading: false,
123
+ errorModalDataSource: {
124
+ errorTitle: errorTitle,
125
+ list: list
126
+ }
120
127
  });
121
128
  return _context.abrupt("return");
122
129
  case 37:
@@ -164,6 +171,27 @@ var ProAction = function ProAction(props) {
164
171
  open: false
165
172
  });
166
173
  };
174
+ var errorModalConfig = config === null || config === void 0 ? void 0 : config[index];
175
+ var _ref3 = errorModalConfig || {},
176
+ contextRender = _ref3.contextRender;
177
+ var renderContent = function renderContent() {
178
+ var TargetComponent = _jsx(_Fragment, {});
179
+ if (typeof contextRender === 'function') {
180
+ var View = contextRender(errorModalDataSource);
181
+ TargetComponent = _jsx(_Fragment, {
182
+ children: View
183
+ });
184
+ } else if (typeof contextRender === 'string' || typeof contextRender === 'number') {
185
+ TargetComponent = _jsx(_Fragment, {
186
+ children: contextRender
187
+ });
188
+ } else if (/*#__PURE__*/React.isValidElement(contextRender)) {
189
+ TargetComponent = _jsx(_Fragment, {
190
+ children: contextRender
191
+ });
192
+ }
193
+ return TargetComponent;
194
+ };
167
195
  return _jsxs(_Fragment, {
168
196
  children: [((_config$ = config[0]) === null || _config$ === void 0 ? void 0 : _config$.mode) === 'confirm' ? _jsx(_Popconfirm, {
169
197
  onConfirm: function onConfirm() {
@@ -176,8 +204,10 @@ var ProAction = function ProAction(props) {
176
204
  mode: "Modal",
177
205
  title: config === null || config === void 0 ? void 0 : (_config$index = config[index]) === null || _config$index === void 0 ? void 0 : _config$index.title,
178
206
  onCancel: function onCancel() {
207
+ form.resetFields();
179
208
  setState({
180
- open: false
209
+ open: false,
210
+ errorModalDataSource: null
181
211
  });
182
212
  },
183
213
  modalProps: {
@@ -186,37 +216,7 @@ var ProAction = function ProAction(props) {
186
216
  size: "small",
187
217
  onOk: onOk,
188
218
  form: form,
189
- proFormProps: {
190
- span: 24,
191
- isView: true,
192
- columns: [{
193
- type: 'Input',
194
- name: 'errorTitle',
195
- viewRender: function viewRender(value) {
196
- var _servicesArray$index;
197
- var list = ((_servicesArray$index = servicesArray[index]) === null || _servicesArray$index === void 0 ? void 0 : _servicesArray$index.list) || [];
198
- return _jsxs("div", {
199
- className: "pro-action-view-tile",
200
- children: [value, list.length === 1 ? _jsxs("span", {
201
- children: [" ", list[0]]
202
- }) : '']
203
- });
204
- }
205
- }, {
206
- type: 'TextArea',
207
- name: 'list',
208
- fieldProps: {
209
- autoSize: {
210
- minRows: 4,
211
- maxRows: 7
212
- }
213
- },
214
- show: function show() {
215
- var _servicesArray$index2, _servicesArray$index3;
216
- return ((_servicesArray$index2 = servicesArray[index]) === null || _servicesArray$index2 === void 0 ? void 0 : (_servicesArray$index3 = _servicesArray$index2.list) === null || _servicesArray$index3 === void 0 ? void 0 : _servicesArray$index3.length) > 1;
217
- }
218
- }]
219
- }
219
+ children: !contextRender ? _jsx(CheckModalContent, _objectSpread({}, errorModalDataSource !== null && errorModalDataSource !== void 0 ? errorModalDataSource : {})) : renderContent()
220
220
  }) : null]
221
221
  });
222
222
  };
@@ -1,5 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Service, Options } from 'ahooks/lib/useRequest/src/types';
3
+ /**
4
+ * 视图渲染函数类型
5
+ * @template T 记录类型
6
+ */
7
+ export type contextRenderFn = (errorTitle?: string, list?: string[]) => string | number | ReactNode | void;
3
8
  export interface ProActionType {
4
9
  /**
5
10
  * @description 模式类型:check执行校验并解析错误信息展示,confirm确认提示
@@ -40,5 +45,7 @@ export interface ProActionType {
40
45
  * @default -
41
46
  */
42
47
  continue?: (previouData: any, args: any[]) => boolean;
48
+ /** 自定义错误弹窗内容视图渲染 */
49
+ contextRender?: string | number | ReactNode | contextRenderFn;
43
50
  }
44
51
  export type ProActionProps = ProActionType;
@@ -130,8 +130,8 @@ export var formatColumn = function formatColumn(_ref2) {
130
130
  if (isFunction(otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewRender)) {
131
131
  var _originalObj$record$r;
132
132
  var diffResult = otherProps.viewRender({
133
- originalValue: originalValue,
134
- originalRecord: (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {},
133
+ originValue: originalValue,
134
+ originRecord: (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {},
135
135
  value: value,
136
136
  record: record,
137
137
  index: index
@@ -167,8 +167,8 @@ export var formatColumn = function formatColumn(_ref2) {
167
167
  if (isFunction(onDiff)) {
168
168
  var _originalObj$record$r2;
169
169
  var _diffResult = onDiff({
170
- originalValue: originalValue,
171
- originalRecord: (_originalObj$record$r2 = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r2 !== void 0 ? _originalObj$record$r2 : {},
170
+ originValue: originalValue,
171
+ originRecord: (_originalObj$record$r2 = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r2 !== void 0 ? _originalObj$record$r2 : {},
172
172
  value: value,
173
173
  record: record,
174
174
  index: index
@@ -4,10 +4,12 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
4
  import "antd/es/message/style";
5
5
  import _message from "antd/es/message";
6
6
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
7
+ import "antd/es/form/style";
8
+ import _Form from "antd/es/form";
7
9
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
11
  var _excluded = ["page", "filters", "sorter"];
10
- import { useCallback, useEffect, useMemo, useState } from 'react';
12
+ import { useEffect, useMemo, useState } from 'react';
11
13
  import { useRequest, useSetState, useDeepCompareEffect, usePrevious } from 'ahooks';
12
14
  import { pickBy, isObject, merge, set, isEqual, omit } from 'lodash';
13
15
  import { defaultPage } from '../index';
@@ -36,7 +38,8 @@ function useAntdTable(service, options, useRequestOptions) {
36
38
  filters: undefined,
37
39
  sorter: undefined
38
40
  },
39
- allSelected: false
41
+ allSelected: false,
42
+ searchValues: {}
40
43
  }),
41
44
  _useSetState2 = _slicedToArray(_useSetState, 2),
42
45
  _useSetState2$ = _useSetState2[0],
@@ -46,9 +49,10 @@ function useAntdTable(service, options, useRequestOptions) {
46
49
  selectedRowKeys = _useSetState2$.selectedRowKeys,
47
50
  extraFilter = _useSetState2$.extraFilter,
48
51
  allSelected = _useSetState2$.allSelected,
52
+ searchValues = _useSetState2$.searchValues,
49
53
  setState = _useSetState2[1];
50
54
  var _useDefaultOptions = useDefaultOptions(options),
51
- form = _useDefaultOptions.form,
55
+ _form = _useDefaultOptions.form,
52
56
  page = _useDefaultOptions.page,
53
57
  extraParams = _useDefaultOptions.extraParams,
54
58
  rowKey = _useDefaultOptions.rowKey,
@@ -64,12 +68,15 @@ function useAntdTable(service, options, useRequestOptions) {
64
68
  transformParams = _useDefaultOptions.transformParams,
65
69
  transformResponse = _useDefaultOptions.transformResponse,
66
70
  disabled = _useDefaultOptions.disabled;
71
+ var _Form$useForm = _Form.useForm(_form),
72
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
73
+ form = _Form$useForm2[0];
67
74
  var _ref = useRequestOptions || {},
68
75
  defaultParams = _ref.defaultParams;
69
76
  var defaultParam = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
70
77
  var initPage = (options === null || options === void 0 ? void 0 : options.page) || defaultPage;
71
78
  var previousPage = usePrevious(page || defaultPage);
72
- var getTransformParams = useCallback(function (params) {
79
+ var getTransformParams = function getTransformParams(params) {
73
80
  var _pickBy;
74
81
  var realParams = _objectSpread(_objectSpread(_objectSpread({}, defaultParam), extraParams), params);
75
82
  var _realParams$page = realParams.page,
@@ -90,7 +97,7 @@ function useAntdTable(service, options, useRequestOptions) {
90
97
  return transformParams(realParams, requestParams);
91
98
  }
92
99
  return requestParams;
93
- }, [defaultParam, extraParams]);
100
+ };
94
101
  // 仅清数据源相关,查询相关
95
102
  var handleSetStateCallback = function handleSetStateCallback(values) {
96
103
  setState(_objectSpread({
@@ -135,13 +142,13 @@ function useAntdTable(service, options, useRequestOptions) {
135
142
  var run = result.run,
136
143
  refreshAsync = result.refreshAsync;
137
144
  // service变化时触发 (禁止掉防止service变更时导致的死循环)
138
- var clearSelected = useCallback(function () {
145
+ var clearSelected = function clearSelected() {
139
146
  setState({
140
147
  allSelected: false,
141
148
  selectedRecords: [],
142
149
  selectedRowKeys: []
143
150
  });
144
- }, []);
151
+ };
145
152
  /**
146
153
  * 手动触发时,手动调用run
147
154
  */
@@ -187,7 +194,7 @@ function useAntdTable(service, options, useRequestOptions) {
187
194
  };
188
195
  }, []);
189
196
  // 分页变更
190
- var handlePageChange = useCallback(function (current, pageSize) {
197
+ var handlePageChange = function handlePageChange(current, pageSize) {
191
198
  var _form$getFieldsValue;
192
199
  var page = {
193
200
  pageNum: current,
@@ -205,8 +212,8 @@ function useAntdTable(service, options, useRequestOptions) {
205
212
  run(getTransformParams(_objectSpread(_objectSpread({
206
213
  page: page
207
214
  }, nextValues), extraFilter)));
208
- }, [allSelected, extraFilter, data, getTransformParams]);
209
- var handleTableChange = useCallback(function (pagination, filters, sorter, extra) {
215
+ };
216
+ var handleTableChange = function handleTableChange(pagination, filters, sorter, extra) {
210
217
  var _form$getFieldsValue2;
211
218
  // 跳过分页改变,使用pagination的onChange
212
219
  if (extra.action === 'paginate') {
@@ -225,15 +232,15 @@ function useAntdTable(service, options, useRequestOptions) {
225
232
  sorter: sorter
226
233
  }
227
234
  });
228
- var _values = (_form$getFieldsValue2 = form.getFieldsValue()) !== null && _form$getFieldsValue2 !== void 0 ? _form$getFieldsValue2 : {};
235
+ var _values = (_form$getFieldsValue2 = form === null || form === void 0 ? void 0 : form.getFieldsValue()) !== null && _form$getFieldsValue2 !== void 0 ? _form$getFieldsValue2 : {};
229
236
  run(getTransformParams(_objectSpread(_objectSpread({
230
237
  page: page
231
238
  }, _values), {}, {
232
239
  filters: filters,
233
240
  sorter: sorter
234
241
  })));
235
- }, [allSelected, getTransformParams]);
236
- var onSearch = useCallback(function (values) {
242
+ };
243
+ var onSearch = function onSearch(values) {
237
244
  var newPage = {
238
245
  pageNum: 1,
239
246
  pageSize: page.pageSize
@@ -247,6 +254,7 @@ function useAntdTable(service, options, useRequestOptions) {
247
254
  if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) || isNonEmptyObject(_values) || !isEqual(previousSearchValues, _values)) {
248
255
  previousSearchValues = _values;
249
256
  setState({
257
+ searchValues: _values,
250
258
  allSelected: false,
251
259
  selectedRecords: [],
252
260
  selectedRowKeys: []
@@ -255,9 +263,10 @@ function useAntdTable(service, options, useRequestOptions) {
255
263
  run(getTransformParams(_objectSpread(_objectSpread({
256
264
  page: newPage
257
265
  }, extraFilter), _values)));
258
- }, [extraFilter, page.pageSize, previousPage, getTransformParams]);
259
- var resetParams = useCallback(function (page) {
266
+ };
267
+ var resetParams = function resetParams(page) {
260
268
  setState({
269
+ searchValues: {},
261
270
  allSelected: false,
262
271
  selectedRecords: [],
263
272
  selectedRowKeys: [],
@@ -266,9 +275,9 @@ function useAntdTable(service, options, useRequestOptions) {
266
275
  sorter: undefined
267
276
  }
268
277
  });
269
- }, []);
278
+ };
270
279
  // 重置查询条件: 页码还原、勾选清空
271
- var onReset = useCallback(function () {
280
+ var onReset = function onReset() {
272
281
  form === null || form === void 0 ? void 0 : form.resetFields();
273
282
  var newPage = {
274
283
  pageNum: 1,
@@ -281,7 +290,7 @@ function useAntdTable(service, options, useRequestOptions) {
281
290
  page: newPage
282
291
  }));
283
292
  }
284
- }, [page.pageSize, run, resetParams, getTransformParams]);
293
+ };
285
294
  var refreshPage = function refreshPage(res) {
286
295
  var transformResult = transformResponse ? transformResponse(res) : res || {};
287
296
  var _ref3 = isListResult(transformResult) ? transformResult : (transformResult === null || transformResult === void 0 ? void 0 : transformResult.data) || {},
@@ -475,7 +484,7 @@ function useAntdTable(service, options, useRequestOptions) {
475
484
  data: data,
476
485
  params: (result === null || result === void 0 ? void 0 : (_result$params = result.params) === null || _result$params === void 0 ? void 0 : _result$params[0]) || {},
477
486
  rowSelection: rowSelection,
478
- searchValues: (_form$getFieldsValue3 = form.getFieldsValue()) !== null && _form$getFieldsValue3 !== void 0 ? _form$getFieldsValue3 : {},
487
+ searchValues: (_form$getFieldsValue3 = form === null || form === void 0 ? void 0 : form.getFieldsValue()) !== null && _form$getFieldsValue3 !== void 0 ? _form$getFieldsValue3 : {},
479
488
  allSelected: allSelected,
480
489
  selectedTip: selectedTip,
481
490
  selectedRowKeys: selectedRowKeys,
@@ -186,13 +186,13 @@ export interface ProTableColumnType extends Omit<ColumnType<any>, 'dataIndex'> {
186
186
  * @description 自定义如何比较数据差异,触发条件必须写render
187
187
  * @default undefined
188
188
  */
189
- onDiff?: ({ value, record, index, originalValue, originalRecord }: any) => any;
189
+ onDiff?: ({ value, record, index, originValue, originRecord }: any) => any;
190
190
  /**
191
191
  * 自定义比对渲染
192
192
  * @description 用于开启比对时,自定义 render 渲染初始值,触发条件必须写render
193
193
  * @default undefined
194
194
  */
195
- viewRender?: ({ value, record, index, originalValue, originalRecord, }: any) => 'same' | 'changed' | 'add' | undefined;
195
+ viewRender?: ({ value, record, index, originValue, originRecord, }: any) => 'same' | 'changed' | 'add' | undefined;
196
196
  /**
197
197
  * 是否已更改
198
198
  * @description 标记列值是否已变更
@@ -30,8 +30,8 @@ export var getOriginalValue = function getOriginalValue(value, record, originalO
30
30
  isAddCell: null
31
31
  };
32
32
  }
33
- var originalRecord = get(originalObj, get(record, rowKey));
34
- var originalValue = get(originalRecord, dataIndex);
33
+ var originRecord = get(originalObj, get(record, rowKey));
34
+ var originalValue = get(originRecord, dataIndex);
35
35
  if (isEmpty(originalValue) && !isEmpty(value)) {
36
36
  return {
37
37
  originalValue: originalValue,
@@ -1,45 +1,19 @@
1
1
  import "antd/es/tooltip/style";
2
2
  import _Tooltip from "antd/es/tooltip";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
5
- import { useEffect, useState } from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
6
4
  var AdaptiveTooltip = function AdaptiveTooltip(_ref) {
7
5
  var children = _ref.children;
8
- var _useState = useState('right'),
9
- _useState2 = _slicedToArray(_useState, 2),
10
- placement = _useState2[0],
11
- setPlacement = _useState2[1];
12
- useEffect(function () {
13
- var handleResize = function handleResize() {
14
- var tooltipElement = document.getElementById('adaptive-tooltip');
15
- if (tooltipElement) {
16
- var boundingRect = tooltipElement.getBoundingClientRect();
17
- var windowWidth = window.innerWidth;
18
- if (windowWidth - boundingRect.right < 150) {
19
- setPlacement('left');
20
- } else {
21
- setPlacement('right');
22
- }
23
- }
24
- };
25
- window.addEventListener('resize', handleResize);
26
- handleResize();
27
- return function () {
28
- window.removeEventListener('resize', handleResize);
29
- };
30
- }, [children]);
31
6
  return _jsx(_Tooltip, {
32
- placement: placement,
7
+ placement: "rightTop",
33
8
  title: _jsx("div", {
34
9
  onMouseDown: function onMouseDown(e) {
35
10
  return e.stopPropagation();
36
11
  },
37
12
  children: children
38
13
  }),
39
- id: "adaptive-tooltip",
40
- children: _jsxs("span", {
14
+ children: _jsx("span", {
41
15
  className: "pro-tree-wrap-ellipse",
42
- children: [" ", children]
16
+ children: children
43
17
  })
44
18
  });
45
19
  };
@@ -75,7 +75,6 @@ var ProTree = function ProTree(props) {
75
75
  showExpand = _props$showExpand === void 0 ? false : _props$showExpand,
76
76
  defaultExpandAll = props.defaultExpandAll,
77
77
  other = _objectWithoutProperties(props, _excluded);
78
- var fieldNameLabel = fieldNames.label;
79
78
  var fieldNameValue = fieldNames.value;
80
79
  var _useSetState = useSetState({
81
80
  open: false,
@@ -12,20 +12,22 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
13
13
  import "antd/es/tree-select/style";
14
14
  import _TreeSelect from "antd/es/tree-select";
15
- var _excluded = ["disabled", "code", "dataSource", "defaultDisableValue", "onChange", "useRequest", "transformResponse", "fieldNames", "tooltip", "showSearch", "filterTreeNode", "treeNodeFilterProp", "defaultExpandAll", "expandedKeys", "treeCheckable", "onSearch", "otherProps", "width", "dropdownStyle", "popupClassName", "style", "allowClear", "listHeight", "showCodeName", "className", "checkStrictly", "checkable"],
15
+ var _excluded = ["disabled", "code", "dataSource", "defaultDisableValue", "onChange", "useRequest", "transformResponse", "fieldNames", "placeholder", "tooltip", "showSearch", "filterTreeNode", "treeNodeFilterProp", "defaultExpandAll", "expandedKeys", "treeCheckable", "onSearch", "otherProps", "width", "dropdownStyle", "popupClassName", "style", "allowClear", "listHeight", "showCodeName", "className", "checkStrictly", "checkable"],
16
16
  _excluded2 = ["children"];
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  /* eslint-disable react/no-danger */
19
19
  /* eslint-disable react/jsx-closing-tag-location */
20
20
  import { useDeepCompareEffect, useRequest as useRequestFunc, useSetState } from 'ahooks';
21
21
  import classnames from 'classnames';
22
- import { useImperativeHandle, forwardRef } from 'react';
22
+ import { useImperativeHandle, forwardRef, useCallback } from 'react';
23
23
  import { cloneDeep, debounce } from 'lodash';
24
+ import locale from '../../../locale';
24
25
  import { useProConfig } from '../../../ProConfigProvider';
25
26
  import Container from '../../../ProForm/components/Container';
26
27
  import AdaptiveTooltip from '../AdaptiveTooltip';
27
28
  var SHOW_PARENT = _TreeSelect.SHOW_PARENT;
28
29
  export var ProTreeSelect = function ProTreeSelect(props, ref) {
30
+ var _useRequest$options;
29
31
  // 全局属性配置在ConfigProvider
30
32
  var _ref = useProConfig('ProTreeSelect') || {},
31
33
  _ref$fieldNames = _ref.fieldNames,
@@ -50,6 +52,7 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
50
52
  useRequest = props.useRequest,
51
53
  transformResponse = props.transformResponse,
52
54
  fieldNames = props.fieldNames,
55
+ placeholder = props.placeholder,
53
56
  _props$tooltip = props.tooltip,
54
57
  tooltip = _props$tooltip === void 0 ? false : _props$tooltip,
55
58
  _props$showSearch = props.showSearch,
@@ -168,11 +171,26 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
168
171
  origDataSource: resultData || []
169
172
  });
170
173
  };
174
+ var successTransformDataHandle = useCallback(function (res) {
175
+ if (transformResponse && typeof transformResponse === 'function') {
176
+ return transformResponse(res);
177
+ }
178
+ var _ref4 = res || {},
179
+ _ref4$status = _ref4.status,
180
+ status = _ref4$status === void 0 ? 200 : _ref4$status,
181
+ msg = _ref4.message,
182
+ data = _ref4.data;
183
+ if (status !== 200) {
184
+ _message.error(msg);
185
+ return;
186
+ }
187
+ return data;
188
+ }, []);
171
189
  // 配置了异步数据源,拉取枚举数据逻辑 如果有code不掉接口从local里根据code取值
172
190
  var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread({
173
191
  manual: true,
192
+ debounceWait: 300,
174
193
  onSuccess: function onSuccess(data) {
175
- // 用户配置了处理枚举函数
176
194
  if (transformResponse && typeof transformResponse === 'function') {
177
195
  var responseData = transformResponse(data);
178
196
  var resultData = transferDataSource(responseData, showCodeName);
@@ -181,16 +199,33 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
181
199
  origDataSource: resultData
182
200
  });
183
201
  } else {
184
- defaultOnSuccessFun(data);
202
+ defaultOnSuccessFun(fetchFunction.data);
185
203
  }
186
- },
187
- debounceWait: 300
204
+ }
188
205
  }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
206
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
189
207
  useImperativeHandle(ref, function () {
190
208
  return {
191
209
  useRequestRef: fetchFunction
192
210
  };
193
211
  });
212
+ // 设置cacheKey后使用缓存的数据
213
+ useDeepCompareEffect(function () {
214
+ var _useRequest$options2;
215
+ if (fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data, useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey) {
216
+ if (transformResponse && typeof transformResponse === 'function') {
217
+ var responseData = transformResponse(fetchFunction.data);
218
+ // debugger;
219
+ var resultData = transferDataSource(responseData, showCodeName);
220
+ setState({
221
+ selectList: countChild(resultData),
222
+ origDataSource: resultData
223
+ });
224
+ } else {
225
+ defaultOnSuccessFun(fetchFunction.data);
226
+ }
227
+ }
228
+ }, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
194
229
  useDeepCompareEffect(function () {
195
230
  if (enumCode) {
196
231
  var dictEnum = dics[enumCode] || [];
@@ -212,17 +247,21 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
212
247
  if (enumCode || dataSource) {
213
248
  return undefined;
214
249
  }
250
+ // 如果配置手动加载,不执行请求
251
+ var _ref5 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
252
+ defaultParams = _ref5.defaultParams,
253
+ manual = _ref5.manual;
215
254
  // disabled 状态时,不查询接口
216
255
  if (defaultDisableValue || !useRequest) {
217
256
  return undefined;
218
257
  }
219
- // 如果配置手动加载,不执行请求
220
- var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
221
- defaultParams = _ref4.defaultParams;
258
+ if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
259
+ return;
260
+ }
222
261
  var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
223
262
  // 执行用户配置的枚举服务,拉取枚举数据进行更新
224
263
  fetchFunction.run(params);
225
- }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, defaultDisableValue]);
264
+ }, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options, defaultDisableValue]);
226
265
  // disable默认值
227
266
  if (defaultDisableValue) {
228
267
  return _jsx("span", {
@@ -399,7 +438,7 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
399
438
  return sourceList;
400
439
  }
401
440
  var searchTreeEvent = debounce(/*#__PURE__*/function () {
402
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchVal) {
441
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchVal) {
403
442
  var result;
404
443
  return _regeneratorRuntime().wrap(function _callee$(_context) {
405
444
  while (1) switch (_context.prev = _context.next) {
@@ -424,7 +463,7 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
424
463
  }, _callee);
425
464
  }));
426
465
  return function (_x) {
427
- return _ref5.apply(this, arguments);
466
+ return _ref6.apply(this, arguments);
428
467
  };
429
468
  }(), 500);
430
469
  function findTreeNode(treeList, nodeValue) {
@@ -565,6 +604,7 @@ export var ProTreeSelect = function ProTreeSelect(props, ref) {
565
604
  onClick: nodeChangeEvent,
566
605
  className: cls,
567
606
  children: _jsx(_TreeSelect, _objectSpread(_objectSpread({
607
+ placeholder: placeholder || locale.ProForm.treeSelectPlaceholder,
568
608
  maxTagPlaceholder: function maxTagPlaceholder(rest) {
569
609
  var _rest = rest.map(function (tag) {
570
610
  var _tag$label, _tag$label$props, _tag$label2, _tag$label2$props, _tag$label2$props$chi, _tag$label2$props$chi2, _tag$label2$props$chi3, _tag$label3, _tag$label3$props, _tag$label3$props$dan;