@teamix/pro 1.2.33 → 1.2.34

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.
@@ -40,7 +40,7 @@ import debounce from 'lodash.debounce';
40
40
  import { Tag } from '@alicloudfe/components';
41
41
  import { createForm, onFormReact, onFormInputChange } from '@formily/core';
42
42
  import { toJS } from '@formily/reactive';
43
- import { usePrefixCls, isSignificative, isNum } from '@teamix/utils';
43
+ import { usePrefixCls, isSignificative, isNum, getValidValues } from '@teamix/utils';
44
44
  import ProField from '../../field/index';
45
45
  import fieldTypeMap from '../fieldTypeMap';
46
46
  import { getFormDisplayValues } from '../ProForm/useFormDisplayValues';
@@ -72,10 +72,14 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
72
72
 
73
73
  var _onFormInit = function onFormInit(form, _ref, configFilterItem) {
74
74
  var initialRequest = _ref.initialRequest,
75
+ initialValues = _ref.initialValues,
75
76
  onInit = _ref.onInit;
76
77
 
77
78
  if (!form.mounted) {
78
- form.loading = !!initialRequest;
79
+ // formloading为自定义属性
80
+ form.setState({
81
+ loading: !!initialRequest || !!initialValues
82
+ });
79
83
  }
80
84
 
81
85
  var loadingField = Object.values(form.fields).filter(function (field) {
@@ -84,14 +88,25 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
84
88
 
85
89
  if (form.mounted) {
86
90
  if (loadingField.length === 0 && !form.loading) {
87
- var onInitResult = onInit && onInit(toJS(form.values));
91
+ // 仅执行一次onInit
92
+ _onFormInit = function onFormInit() {};
93
+
94
+ var onInitResult = onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values));
88
95
 
89
96
  if (onInitResult) {
90
97
  // 根据onInit返回值,判断是否使用该事件执行筛选,使用过则添加筛选标签
91
- configFilterItem && configFilterItem(form);
92
- }
98
+ configFilterItem === null || configFilterItem === void 0 ? void 0 : configFilterItem(form);
99
+ configTag();
100
+ } // 防止onInit前后的无效onFilter
93
101
 
94
- _onFormInit = function onFormInit() {};
102
+
103
+ if (!Object.keys(form.initialValues).length) {
104
+ // 如果没有默认值,直接开启onFilter
105
+ filterEnable.current = true;
106
+ } else {
107
+ // 否则,拿onFilter的值与默认值进行比较
108
+ filterEnable.current = form.initialValues;
109
+ }
95
110
  }
96
111
  }
97
112
  }; // 设置当前form
@@ -172,6 +187,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
172
187
 
173
188
  var filterItem = useRef([]);
174
189
  var currentForm = useRef(mode === 'panel' ? advancedFilterVisible ? 'advanced' : 'light' : 'simple');
190
+ var filterEnable = useRef(false);
175
191
  var prefixCls = usePrefixCls('', {
176
192
  prefix: 'teamix-pro-form-query-filter'
177
193
  }); // 设置筛选数据
@@ -237,7 +253,22 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
237
253
 
238
254
  setAdvancedFilterVisible(result);
239
255
  onExpand === null || onExpand === void 0 ? void 0 : onExpand(result);
240
- }, [advancedFilterVisible, configTag, currentForm.current]); // 简单搜索Filter
256
+ }, [advancedFilterVisible, configTag, currentForm.current]); // 是否开启onFilter
257
+
258
+ var enableFilter = function enableFilter(values) {
259
+ var initialValues = JSON.stringify(getValidValues(filterEnable.current));
260
+ var changeValues = JSON.stringify(getValidValues(values));
261
+
262
+ if (filterEnable.current === true) {
263
+ return true;
264
+ } else if (initialValues === changeValues) {
265
+ filterEnable.current = true;
266
+ return false;
267
+ }
268
+
269
+ return false;
270
+ }; // 简单搜索Filter
271
+
241
272
 
242
273
  var onSimpleFilter = useCallback( /*#__PURE__*/function () {
243
274
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(values) {
@@ -245,23 +276,31 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
245
276
  while (1) {
246
277
  switch (_context.prev = _context.next) {
247
278
  case 0:
279
+ if (enableFilter(values)) {
280
+ _context.next = 2;
281
+ break;
282
+ }
283
+
284
+ return _context.abrupt("return");
285
+
286
+ case 2:
248
287
  if (!(currentForm.current === 'simple')) {
249
- _context.next = 5;
288
+ _context.next = 7;
250
289
  break;
251
290
  }
252
291
 
253
292
  if (!hasRequired) {
254
- _context.next = 4;
293
+ _context.next = 6;
255
294
  break;
256
295
  }
257
296
 
258
- _context.next = 4;
297
+ _context.next = 6;
259
298
  return simpleForm.validate();
260
299
 
261
- case 4:
262
- onFilter && onFilter(values);
300
+ case 6:
301
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
263
302
 
264
- case 5:
303
+ case 7:
265
304
  case "end":
266
305
  return _context.stop();
267
306
  }
@@ -272,7 +311,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
272
311
  return function (_x) {
273
312
  return _ref4.apply(this, arguments);
274
313
  };
275
- }(), [onFilter, currentForm.current, hasRequired]); // 轻量搜索Filter
314
+ }(), [onFilter, currentForm.current, hasRequired, enableFilter]); // 轻量搜索Filter
276
315
 
277
316
  var onLightFilter = useCallback( /*#__PURE__*/function () {
278
317
  var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
@@ -280,21 +319,29 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
280
319
  while (1) {
281
320
  switch (_context2.prev = _context2.next) {
282
321
  case 0:
322
+ if (enableFilter(values)) {
323
+ _context2.next = 2;
324
+ break;
325
+ }
326
+
327
+ return _context2.abrupt("return");
328
+
329
+ case 2:
283
330
  if (!(currentForm.current === 'light')) {
284
- _context2.next = 6;
331
+ _context2.next = 8;
285
332
  break;
286
333
  }
287
334
 
288
- onFilter && onFilter(values);
289
- _context2.next = 4;
335
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
336
+ _context2.next = 6;
290
337
  return advancedForm.reset();
291
338
 
292
- case 4:
339
+ case 6:
293
340
  // 不会触发高级筛选的onReset回调函数
294
341
  configFilterItem(advancedForm);
295
342
  configTag();
296
343
 
297
- case 6:
344
+ case 8:
298
345
  case "end":
299
346
  return _context2.stop();
300
347
  }
@@ -305,18 +352,28 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
305
352
  return function (_x2) {
306
353
  return _ref5.apply(this, arguments);
307
354
  };
308
- }(), [onFilter, currentForm.current]); // 高级搜索Filter
355
+ }(), [onFilter, currentForm.current, enableFilter]); // 高级搜索Filter
309
356
 
310
357
  var onAdvancedFilter = useCallback(function (values) {
358
+ if (!enableFilter(values)) {
359
+ return;
360
+ }
361
+
311
362
  setCurrentForm('advanced');
312
- onFilter && onFilter(values);
363
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
313
364
  configFilterItem(advancedForm);
314
365
  lightForm.reset();
315
- }, [onFilter, currentForm.current]); // 高级搜索Reset
366
+ }, [onFilter, currentForm.current, enableFilter]); // 高级搜索Change
367
+
368
+ var onAdvancedChange = useCallback(function (values) {
369
+ if (!enableFilter(values)) {
370
+ return;
371
+ }
372
+ }, [enableFilter]); // 高级搜索Reset
316
373
 
317
374
  var onAdvancedReset = useCallback(function () {
318
375
  setCurrentForm('advanced');
319
- onReset && onReset(toJS(advancedForm.values));
376
+ onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
320
377
  configFilterItem(advancedForm);
321
378
  lightForm.reset();
322
379
  }, [onReset]); // 关闭标签清空表单字段值
@@ -332,11 +389,10 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
332
389
  advancedForm.setValuesIn(key, newValue);
333
390
  configFilterItem(advancedForm);
334
391
  configTag();
335
- onFilter && onFilter(toJS(advancedForm.values));
336
- }, []); // 异步默认值回调,设置form的loading状态为false
392
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(advancedForm.values));
393
+ }, []); // initialValues和initialRequest的回调
337
394
 
338
- var onInitialRequestComplete = useCallback(function (_, __, _ref6) {
339
- var form = _ref6.form;
395
+ var onInitialComplete = useCallback(function (form) {
340
396
  form.setState({
341
397
  loading: false
342
398
  });
@@ -362,22 +418,22 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
362
418
  }, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
363
419
  form: simpleForm,
364
420
  onChange: debounce(onSimpleFilter, filterDebounce),
365
- onSubmit: onSimpleFilter
421
+ onSubmit: onSimpleFilter,
422
+ onInitialComplete: onInitialComplete
366
423
  }))),
367
424
  panelContent: mode === 'panel' ? /*#__PURE__*/React.createElement(AdvancedFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
368
- initialRequest: otherProps.initialRequest ? _objectSpread(_objectSpread({}, otherProps.initialRequest), {}, {
369
- onComplete: onInitialRequestComplete
370
- }) : undefined,
371
425
  form: advancedForm,
426
+ onChange: debounce(onAdvancedChange, filterDebounce),
372
427
  onSubmit: onAdvancedFilter,
373
- onReset: onAdvancedReset
428
+ onReset: onAdvancedReset,
429
+ onInitialComplete: onInitialComplete
374
430
  })) : null
375
- }, mode === 'panel' && !advancedFilterVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref7) {
376
- var key = _ref7.key,
377
- label = _ref7.label,
378
- value = _ref7.value,
379
- type = _ref7.type,
380
- index = _ref7.index;
431
+ }, mode === 'panel' && !advancedFilterVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref6) {
432
+ var key = _ref6.key,
433
+ label = _ref6.label,
434
+ value = _ref6.value,
435
+ type = _ref6.type,
436
+ index = _ref6.index;
381
437
  return /*#__PURE__*/React.createElement(Tag.Closeable, {
382
438
  key: isNum(index) ? key + label : key,
383
439
  afterClose: function afterClose() {
@@ -1,4 +1,4 @@
1
- var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "className"];
1
+ var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "onInitialComplete", "className"];
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
@@ -41,6 +41,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
41
41
  onChange = _ref.onChange,
42
42
  onSubmit = _ref.onSubmit,
43
43
  onSubmitFailed = _ref.onSubmitFailed,
44
+ onInitialComplete = _ref.onInitialComplete,
44
45
  className = _ref.className,
45
46
  otherProps = _objectWithoutProperties(_ref, _excluded);
46
47
 
@@ -91,13 +92,12 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
91
92
  useEffect(function () {
92
93
  if (initialValues) {
93
94
  form.setInitialValues(initialValues);
95
+ onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
94
96
  } else if (initialRequest) {
95
97
  useInitialRequest(initialRequest).then(function (values) {
96
98
  form.setInitialValues(values);
97
99
  }).finally(function () {
98
- initialRequest.onComplete && initialRequest.onComplete(undefined, undefined, {
99
- form: form
100
- });
100
+ onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
101
101
  });
102
102
  }
103
103
  }, []); // 配置国际化
@@ -1,6 +1,6 @@
1
1
  import type { ProFormRequestConfig } from '../typing';
2
2
  interface IInitializeRequest {
3
- (requestConfig?: ProFormRequestConfig, suffix?: string): {
3
+ (requestConfig?: ProFormRequestConfig | ProFormRequestConfig[], suffix?: string): {
4
4
  reactions: any[];
5
5
  scope: {
6
6
  [x: string]: any;
@@ -1,12 +1,48 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
1
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
6
 
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
+
19
+ import { isArr } from '@teamix/utils';
20
+
3
21
  var initializeRequest = function initializeRequest(requestConfig, suffix) {
4
22
  if (requestConfig) {
5
- var requestConfigName = "$requestConfig_".concat(suffix);
6
- return {
7
- reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
8
- scope: _defineProperty({}, requestConfigName, requestConfig)
9
- };
23
+ if (isArr(requestConfig)) {
24
+ var reactionsMap = [];
25
+ var scopeMap = {};
26
+ requestConfig.forEach(function (item, index) {
27
+ var _initializeRequest = initializeRequest(item, "".concat(suffix).concat(index)),
28
+ reactions = _initializeRequest.reactions,
29
+ scope = _initializeRequest.scope;
30
+
31
+ reactionsMap = [].concat(_toConsumableArray(reactionsMap), _toConsumableArray(reactions));
32
+ scopeMap = _objectSpread(_objectSpread({}, scopeMap), scope);
33
+ });
34
+ return {
35
+ reactions: reactionsMap,
36
+ scope: scopeMap
37
+ };
38
+ } else {
39
+ var requestConfigName = "$requestConfig_".concat(suffix);
40
+ var requestIndex = (/\d{1,}\w(\d{0,})/g.exec(suffix) || [])[1];
41
+ return {
42
+ reactions: ["{{$common($request,".concat(requestConfigName, ",context,").concat(requestIndex, ")}}")],
43
+ scope: _defineProperty({}, requestConfigName, requestConfig)
44
+ };
45
+ }
10
46
  }
11
47
 
12
48
  return {
@@ -1,6 +1,6 @@
1
1
  import type { ProFormRequestConfig } from '../typing';
2
- declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any) => Promise<unknown>;
3
- declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
2
+ declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any, type: string | number) => Promise<unknown>;
3
+ declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any, index: string) => (field: any) => any;
4
4
  declare const $validator: (services: any, requestConfig: ProFormRequestConfig, context: any) => (value: any, rules: any, { field }: any) => any;
5
5
  declare const $dataSource: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
6
6
  export { $request, $common, $dataSource, $validator };
@@ -6,10 +6,17 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import { isFn, isPlainObj, doCommonRequest, getValueByValue } from '@teamix/utils'; // 配置请求
8
8
 
9
- var $request = function $request(field, requestConfig, context) {
9
+ var $request = function $request(field, requestConfig, context, type) {
10
10
  var _field$data;
11
11
 
12
- var refresh = field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
12
+ // let refresh
13
+ // if(isStr(type)){
14
+ // refresh = field.data?.refreshMap?.[type]
15
+ // }else if(isNum(type)){
16
+ // }else{
17
+ // refresh = field.data?.refresh;
18
+ // }
19
+ var refresh = (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
13
20
  var beforeRequest = requestConfig.beforeRequest,
14
21
  onSuccess = requestConfig.onSuccess;
15
22
  var refreshResult = isPlainObj(refresh) ? refresh : {};
@@ -26,9 +33,9 @@ var $request = function $request(field, requestConfig, context) {
26
33
  }; // 通用请求配置上下文
27
34
 
28
35
 
29
- var $common = function $common(services, requestConfig, context) {
36
+ var $common = function $common(services, requestConfig, context, index) {
30
37
  return function (field) {
31
- return services(field, requestConfig, context).then(function (res) {
38
+ return services(field, requestConfig, context, index || 'common').then(function (res) {
32
39
  return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
33
40
  });
34
41
  };
@@ -38,7 +45,7 @@ var $common = function $common(services, requestConfig, context) {
38
45
  var $validator = function $validator(services, requestConfig, context) {
39
46
  return function (value, rules, _ref) {
40
47
  var field = _ref.field;
41
- return services(field, requestConfig, context).then(function (res) {
48
+ return services(field, requestConfig, context, 'validator').then(function (res) {
42
49
  return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
43
50
  });
44
51
  };
@@ -51,7 +58,7 @@ var $dataSource = function $dataSource(services, requestConfig, context) {
51
58
  loading: true,
52
59
  readOnly: true
53
60
  });
54
- return services(field, requestConfig, context).then(function (res) {
61
+ return services(field, requestConfig, context, 'dataSource').then(function (res) {
55
62
  var isValueInDataSource = getValueByValue(res, field.value);
56
63
  var clearValue = isValueInDataSource ? {} : {
57
64
  value: undefined
@@ -44,7 +44,7 @@ export interface ProFormSchemaItem {
44
44
  readPretty?: boolean | string;
45
45
  pattern?: FieldPatternTypes;
46
46
  default?: any;
47
- request?: ProFormRequestConfig;
47
+ request?: ProFormRequestConfig | ProFormRequestConfig[];
48
48
  data?: AnyObject;
49
49
  }
50
50
  export declare type ProFormSchema = ProFormSchemaItem[];
@@ -63,6 +63,7 @@ export interface ProFormProps extends IFormLayoutProps {
63
63
  onChange?: (values: any, fieldValue?: any, fieldName?: any) => any;
64
64
  onSubmit?: ((values: any) => any) | CommonRequestConfig;
65
65
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
66
+ onInitialComplete?: (form: FormType) => void;
66
67
  }
67
68
  export interface FilterProps extends ProFormProps {
68
69
  form: FormType;
package/es/index.d.ts CHANGED
@@ -24,5 +24,5 @@ export * from './skeleton';
24
24
  export * from './table';
25
25
  export * from './utils';
26
26
  export * from './step';
27
- declare const version = "1.2.33";
27
+ declare const version = "1.2.34";
28
28
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProStep, hooks, nocode, templates, utils, };
package/es/index.js CHANGED
@@ -30,7 +30,7 @@ export * from './table';
30
30
  export * from './utils'; // export * from './sidebar';
31
31
 
32
32
  export * from './step';
33
- var version = '1.2.33';
33
+ var version = '1.2.34';
34
34
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
35
35
  ProPageContainer, ProPageHeader, ProSkeleton, ProTable, // ProSidebar,
36
36
  ProStep, hooks, nocode, templates, utils };
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { Message, Overlay } from '@alicloudfe/components';
3
3
  import './index.scss';
4
- import { getMessage } from '@teamix/utils';
4
+ import { getMessage, getValidValues } from '@teamix/utils';
5
5
 
6
6
  var FullScreen = function FullScreen(props) {
7
7
  var children = props.children,
@@ -9,7 +9,8 @@ var FullScreen = function FullScreen(props) {
9
9
  actionRef = props.actionRef;
10
10
  var _actionRef$current = actionRef.current,
11
11
  normalDataFilterForm = _actionRef$current.normalDataFilterForm,
12
- fullscreenDataFilterForm = _actionRef$current.fullscreenDataFilterForm;
12
+ fullscreenDataFilterForm = _actionRef$current.fullscreenDataFilterForm,
13
+ filterEnableRef = _actionRef$current.filterEnableRef;
13
14
 
14
15
  var closeByESC = function closeByESC(e) {
15
16
  if (visible && e.code === 'Escape') {
@@ -28,12 +29,39 @@ var FullScreen = function FullScreen(props) {
28
29
  }, [visible, actionRef]);
29
30
 
30
31
  var afterClose = function afterClose() {
31
- normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.setValues(fullscreenDataFilterForm.values);
32
+ // 判断全屏前后筛选表单值是否有改变
33
+ var n = JSON.stringify(getValidValues(normalDataFilterForm.values));
34
+ var f = JSON.stringify(getValidValues(fullscreenDataFilterForm.values));
35
+
36
+ if (n === f) {
37
+ // 关闭全屏后,表单值未变化,开启普通表单onFilter
38
+ filterEnableRef.current.normal = true;
39
+ } else {
40
+ // 关闭全屏后,表单值有变化,修改表单值
41
+ normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.setValues(fullscreenDataFilterForm.values);
42
+ } // 关闭全屏后,关闭全屏表单onFilter
43
+
44
+
45
+ filterEnableRef.current.fullscreen = false;
32
46
  }; // 全屏开启之后
33
47
 
34
48
 
35
49
  var afterOpen = function afterOpen() {
36
- fullscreenDataFilterForm.setValues(normalDataFilterForm.values);
50
+ // 判断全屏前后筛选表单值是否有改变
51
+ var n = JSON.stringify(getValidValues(normalDataFilterForm.values));
52
+ var f = JSON.stringify(getValidValues(fullscreenDataFilterForm.values));
53
+
54
+ if (n === f) {
55
+ // 全屏后,表单值未变化,开启全屏表单onFilter
56
+ filterEnableRef.current.fullscreen = true;
57
+ } else {
58
+ // 全屏后,表单值变化,修改表单值
59
+ fullscreenDataFilterForm === null || fullscreenDataFilterForm === void 0 ? void 0 : fullscreenDataFilterForm.setValues(normalDataFilterForm.values);
60
+ } // 全屏后,关闭普通表单onFilter
61
+
62
+
63
+ filterEnableRef.current.normal = false; // 消息提示
64
+
37
65
  Message.show({
38
66
  type: 'notice',
39
67
  content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, getMessage('press')), /*#__PURE__*/React.createElement("span", {
package/es/table/index.js CHANGED
@@ -121,7 +121,7 @@ var globalFormatSort = function globalFormatSort(sort) {
121
121
  };
122
122
 
123
123
  var ProTable = function ProTable(props) {
124
- var _rowSelection$selecte, _dataFilterForm4;
124
+ var _rowSelection$selecte;
125
125
 
126
126
  var header = props.header,
127
127
  className = props.className,
@@ -287,9 +287,14 @@ var ProTable = function ProTable(props) {
287
287
  var _useState27 = useState(false),
288
288
  _useState28 = _slicedToArray(_useState27, 2),
289
289
  fullscreenState = _useState28[0],
290
- setFullscreenState = _useState28[1]; // 非全屏状态下的
290
+ setFullscreenState = _useState28[1]; // 切换全屏搜索开关
291
291
 
292
292
 
293
+ var filterEnableRef = useRef({
294
+ fullscreen: false,
295
+ normal: true
296
+ }); // 非全屏状态下的
297
+
293
298
  var normalDataFilterFormRef = useRef();
294
299
  var fullscreenDataFilterFormRef = useRef();
295
300
  var normalDataFilterForm = normalDataFilterFormRef.current;
@@ -505,12 +510,12 @@ var ProTable = function ProTable(props) {
505
510
  _request(params);
506
511
  },
507
512
  reset: function reset() {
508
- var _actionRef$current4, _actionRef$current4$s, _dataFilterForm;
513
+ var _actionRef$current4, _actionRef$current4$s;
509
514
 
510
515
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
511
516
 
512
517
  (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setFilterRules) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, {});
513
- (_dataFilterForm = dataFilterForm) === null || _dataFilterForm === void 0 ? void 0 : _dataFilterForm.reset();
518
+ dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.reset();
514
519
  setCurrentPage(1);
515
520
 
516
521
  _request(_defineProperty({}, targetPageKey, 1));
@@ -535,6 +540,7 @@ var ProTable = function ProTable(props) {
535
540
  dataFilterForm: dataFilterForm,
536
541
  normalDataFilterForm: normalDataFilterForm,
537
542
  fullscreenDataFilterForm: fullscreenDataFilterForm,
543
+ filterEnableRef: filterEnableRef,
538
544
  resetTableMaxBodyHeight: function resetTableMaxBodyHeight() {
539
545
  getHeaderHeight().then(function (height) {
540
546
  setHeaderHeight(height);
@@ -623,8 +629,8 @@ var ProTable = function ProTable(props) {
623
629
  }
624
630
  }); // 请求函数
625
631
 
626
- function _request(params, noLoading) {
627
- var _dataFilterForm2, _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread2;
632
+ function _request(params, noLoading, filterParams) {
633
+ var _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread2;
628
634
 
629
635
  // 如果没有传 url 且没有 customRequest,直接返回
630
636
  if (!url && !customRequest) {
@@ -637,7 +643,7 @@ var ProTable = function ProTable(props) {
637
643
 
638
644
  var sortParams = targetFormatSort(sort); // 筛选区请求参数
639
645
 
640
- var dataFilterParams = toJS((_dataFilterForm2 = dataFilterForm) === null || _dataFilterForm2 === void 0 ? void 0 : _dataFilterForm2.values); // 列过滤请求参数
646
+ var dataFilterParams = filterParams !== null && filterParams !== void 0 ? filterParams : dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.values; // 列过滤请求参数
641
647
 
642
648
  var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$g = _actionRef$current5.getFilterRules) === null || _actionRef$current5$g === void 0 ? void 0 : _actionRef$current5$g.call(_actionRef$current5)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
643
649
 
@@ -688,31 +694,24 @@ var ProTable = function ProTable(props) {
688
694
  }
689
695
 
690
696
  useEffect(function () {
691
- dataFilterForm = dataFilterFormRef.current; // 监听 浏览器变化 更吸底状态
697
+ var _propsDataFilter$sche, _propsDataFilter$sche2;
692
698
 
699
+ // 监听 浏览器变化 更吸底状态
693
700
  if (footerSuction) {
694
701
  getFooterSuctionState();
695
702
 
696
703
  window.onresize = function () {
697
704
  getFooterSuctionState();
698
705
  };
699
- }
706
+ } // 如果不传 dataFilter,则在这里初始化请求
700
707
 
701
- if (propsDataFilter) {
702
- var _dataFilterForm3;
703
708
 
704
- if (requestWhenMount && ((_dataFilterForm3 = dataFilterForm) === null || _dataFilterForm3 === void 0 ? void 0 : _dataFilterForm3.id)) {
705
- // 在请求发送之前 处理漏斗默认数据
706
- processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
709
+ var hasDataFilter = (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche = propsDataFilter.schema) === null || _propsDataFilter$sche === void 0 ? void 0 : _propsDataFilter$sche.length) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : (_propsDataFilter$sche2 = propsDataFilter.schema) === null || _propsDataFilter$sche2 === void 0 ? void 0 : _propsDataFilter$sche2.length) > 0;
707
710
 
708
- _request();
709
- }
710
- } else {
711
- if (requestWhenMount) {
712
- processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
711
+ if (requestWhenMount && !hasDataFilter) {
712
+ processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
713
713
 
714
- _request();
715
- }
714
+ _request();
716
715
  }
717
716
 
718
717
  return function () {
@@ -726,7 +725,7 @@ var ProTable = function ProTable(props) {
726
725
 
727
726
  actionRef.current = undefined;
728
727
  };
729
- }, [(_dataFilterForm4 = dataFilterForm) === null || _dataFilterForm4 === void 0 ? void 0 : _dataFilterForm4.id]);
728
+ }, []);
730
729
 
731
730
  function onSort(dataIndex, order) {
732
731
  var nextSort = _defineProperty({}, dataIndex, order);
@@ -740,24 +739,40 @@ var ProTable = function ProTable(props) {
740
739
  var dataFilter = _objectSpread(_objectSpread({
741
740
  mode: 'inline'
742
741
  }, propsDataFilter), {}, {
742
+ onInit: function onInit(values) {
743
+ // 表单初始化请求处理
744
+ (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit(values));
745
+ !fullscreenState && _request({}, false, values);
746
+ return true;
747
+ },
743
748
  onFilter: function onFilter(values) {
744
749
  var _actionRef$current6, _actionRef$current6$c;
745
750
 
751
+ // 全屏状态,判断全屏表单onFilter是否禁用
752
+ if (fullscreenState && !filterEnableRef.current.fullscreen) {
753
+ filterEnableRef.current.fullscreen = true;
754
+ return;
755
+ } // 非全屏状态,判断普通表单onFiler是否禁用
756
+
757
+
758
+ if (!fullscreenState && !filterEnableRef.current.normal) {
759
+ filterEnableRef.current.normal = true;
760
+ return;
761
+ }
762
+
746
763
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values)); // 搜索变化时,暂时先清空选择
747
764
 
748
765
  (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
749
766
  setCurrentPage(1);
750
767
 
751
- _request(_defineProperty({}, targetPageKey, 1));
768
+ _request(_defineProperty({}, targetPageKey, 1), false, values);
752
769
  },
753
- onReset: function onReset() {
754
- var _dataFilterForm5;
755
-
770
+ onReset: function onReset(values) {
756
771
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
757
- (_dataFilterForm5 = dataFilterForm) === null || _dataFilterForm5 === void 0 ? void 0 : _dataFilterForm5.reset();
772
+ dataFilterForm === null || dataFilterForm === void 0 ? void 0 : dataFilterForm.reset();
758
773
  setCurrentPage(1);
759
774
 
760
- _request(_defineProperty({}, targetPageKey, 1));
775
+ _request(_defineProperty({}, targetPageKey, 1), false, values);
761
776
  }
762
777
  });
763
778