@arim-aisdc/public-components 1.0.1 → 1.0.2

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.
@@ -71,8 +71,9 @@ var QueryFilter = function QueryFilter(_ref) {
71
71
  _ref$submitLoading = _ref.submitLoading,
72
72
  submitLoading = _ref$submitLoading === void 0 ? false : _ref$submitLoading,
73
73
  _ref$renderButton = _ref.renderButton,
74
- renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton;
75
- var _Form$useForm = _Form.useForm(),
74
+ renderButton = _ref$renderButton === void 0 ? null : _ref$renderButton,
75
+ initForm = _ref.initForm;
76
+ var _Form$useForm = _Form.useForm(initForm),
76
77
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
77
78
  form = _Form$useForm2[0];
78
79
  var Option = _Select.Option;
@@ -84,10 +85,6 @@ var QueryFilter = function QueryFilter(_ref) {
84
85
  var displayRender = function displayRender(labels) {
85
86
  return labels[labels.length - 1];
86
87
  };
87
- var _useState3 = useState(false),
88
- _useState4 = _slicedToArray(_useState3, 2),
89
- isCancel = _useState4[0],
90
- setIsCancel = _useState4[1];
91
88
  // 处理初始值格式问题,主要是日期数据的格式,字符串处理为date格式
92
89
  var getHandledInitValues = function getHandledInitValues() {
93
90
  var newFormValues = {};
@@ -107,32 +104,22 @@ var QueryFilter = function QueryFilter(_ref) {
107
104
  var newValues = _objectSpread(_objectSpread({}, values), newFormValues);
108
105
  return newValues;
109
106
  };
107
+ var handledInitValues = getHandledInitValues();
110
108
 
111
109
  /**初始化表单 */
112
110
  var FormRef = useRef(null);
113
- useEffect(function () {
114
- // 修改 重置时set初始值
115
- if (isCancel) {
116
- var handledInitValues = getHandledInitValues();
117
- if (FormRef && FormRef.current) {
118
- FormRef.current.setFieldsValue(handledInitValues);
119
- }
120
- setFormValues(handledInitValues);
121
- setIsCancel(false);
122
- }
123
- }, [isCancel, initialValues]);
124
111
  useEffect(function () {
125
112
  /**回显异步初始值 */
126
113
  // FormRef && FormRef.current && FormRef.current.resetFields();
127
114
  var handledInitValues = getHandledInitValues();
128
- if (FormRef && FormRef.current) {
129
- FormRef.current.setFieldsValue(handledInitValues);
130
- }
115
+ // if (FormRef && FormRef.current) {
116
+ // FormRef.current.setFieldsValue(handledInitValues);
117
+ // }
131
118
  // console.log('handledInitValues :>> ', handledInitValues);
132
119
 
133
120
  // 更新表单数据
134
121
  setFormValues(handledInitValues);
135
- }, []);
122
+ }, [initialValues]);
136
123
 
137
124
  // 表单提交时保留数据
138
125
  var onFinish = function onFinish(values) {
@@ -179,7 +166,7 @@ var QueryFilter = function QueryFilter(_ref) {
179
166
  var _useDebounceFn = useDebounceFn(function (e, item, valueType) {
180
167
  commonChange(e, item, valueType);
181
168
  }, {
182
- wait: 500
169
+ wait: 200
183
170
  }),
184
171
  run = _useDebounceFn.run;
185
172
  var getElement = function getElement(item) {
@@ -242,7 +229,7 @@ var QueryFilter = function QueryFilter(_ref) {
242
229
  onSearch: item.showSearch ? debounce(function (value) {
243
230
  var _item$handleSearch;
244
231
  return (_item$handleSearch = item.handleSearch) === null || _item$handleSearch === void 0 ? void 0 : _item$handleSearch.call(item, value);
245
- }, 500) : undefined,
232
+ }, 200) : undefined,
246
233
  onChange: function onChange(e) {
247
234
  commonChange(e, item);
248
235
  },
@@ -257,7 +244,7 @@ var QueryFilter = function QueryFilter(_ref) {
257
244
  onSelect: item.showSelect ? debounce(function (value) {
258
245
  var _item$handleSelect;
259
246
  return (_item$handleSelect = item.handleSelect) === null || _item$handleSelect === void 0 ? void 0 : _item$handleSelect.call(item, value);
260
- }, 500) : undefined,
247
+ }, 200) : undefined,
261
248
  notFoundContent: ((_item$setting = item.setting) === null || _item$setting === void 0 ? void 0 : _item$setting.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
262
249
  size: "small"
263
250
  }),
@@ -304,7 +291,7 @@ var QueryFilter = function QueryFilter(_ref) {
304
291
  onSearch: debounce(function (value) {
305
292
  var _item$handleSearch3;
306
293
  return (_item$handleSearch3 = item.handleSearch) === null || _item$handleSearch3 === void 0 ? void 0 : _item$handleSearch3.call(item, value, item.isInitGetOptions);
307
- }, 500),
294
+ }, 200),
308
295
  onFocus: function onFocus() {
309
296
  var _item$handleSearch4;
310
297
  return (_item$handleSearch4 = item.handleSearch) === null || _item$handleSearch4 === void 0 ? void 0 : _item$handleSearch4.call(item, '', item.isInitGetOptions);
@@ -481,7 +468,7 @@ var QueryFilter = function QueryFilter(_ref) {
481
468
  onSearch: item.showSearch ? debounce(function (value) {
482
469
  var _item$handleSearch5;
483
470
  return (_item$handleSearch5 = item.handleSearch) === null || _item$handleSearch5 === void 0 ? void 0 : _item$handleSearch5.call(item, value);
484
- }, 500) : undefined,
471
+ }, 200) : undefined,
485
472
  onChange: function onChange(e) {
486
473
  run(e, item, typeList.start);
487
474
  },
@@ -492,7 +479,7 @@ var QueryFilter = function QueryFilter(_ref) {
492
479
  onSelect: item.showSelect ? debounce(function (value) {
493
480
  var _item$handleSelect2;
494
481
  return (_item$handleSelect2 = item.handleSelect) === null || _item$handleSelect2 === void 0 ? void 0 : _item$handleSelect2.call(item, value);
495
- }, 500) : undefined,
482
+ }, 200) : undefined,
496
483
  notFoundContent: ((_item$setting2 = item.setting) === null || _item$setting2 === void 0 ? void 0 : _item$setting2.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
497
484
  size: "small"
498
485
  }),
@@ -527,7 +514,7 @@ var QueryFilter = function QueryFilter(_ref) {
527
514
  onSearch: item.showSearch ? debounce(function (value) {
528
515
  var _item$handleSearch6;
529
516
  return (_item$handleSearch6 = item.handleSearch) === null || _item$handleSearch6 === void 0 ? void 0 : _item$handleSearch6.call(item, value);
530
- }, 500) : undefined,
517
+ }, 200) : undefined,
531
518
  onChange: function onChange(e) {
532
519
  run(e, item, typeList.end);
533
520
  },
@@ -538,7 +525,7 @@ var QueryFilter = function QueryFilter(_ref) {
538
525
  onSelect: item.showSelect ? debounce(function (value) {
539
526
  var _item$handleSelect3;
540
527
  return (_item$handleSelect3 = item.handleSelect) === null || _item$handleSelect3 === void 0 ? void 0 : _item$handleSelect3.call(item, value);
541
- }, 500) : undefined,
528
+ }, 200) : undefined,
542
529
  notFoundContent: ((_item$setting3 = item.setting) === null || _item$setting3 === void 0 ? void 0 : _item$setting3.length) >= 0 ? null : /*#__PURE__*/_jsx(_Spin, {
543
530
  size: "small"
544
531
  }),
@@ -599,8 +586,8 @@ var QueryFilter = function QueryFilter(_ref) {
599
586
  ref: FormRef,
600
587
  form: form
601
588
  // name={styles.customForm}
602
- // initialValues={initialValues}
603
589
  ,
590
+ initialValues: handledInitValues,
604
591
  labelAlign: "left",
605
592
  autoComplete: "off",
606
593
  onFinish: onFinish,
@@ -641,10 +628,11 @@ var QueryFilter = function QueryFilter(_ref) {
641
628
  className: "xmTtn xmTtnDefault",
642
629
  onClick: function onClick(e) {
643
630
  handleCancel(e);
644
- form.resetFields();
645
- setIsCancel(true);
646
631
  // 重置后 再次筛选 会带有上一次的记录(修改)
647
632
  setFormValues({});
633
+ setTimeout(function () {
634
+ form.resetFields();
635
+ }, 200);
648
636
  },
649
637
  children: cancelText
650
638
  }), /*#__PURE__*/_jsx(_Button, {
@@ -676,7 +664,7 @@ var QueryFilter = function QueryFilter(_ref) {
676
664
  * @returns
677
665
  */
678
666
  export function useDynamicSearchFiled(searchField, dynamicField) {
679
- var _useState5 = useState(function () {
667
+ var _useState3 = useState(function () {
680
668
  return searchField.map(function (item) {
681
669
  var tartget = dynamicField.find(function (dynamicFieldItem) {
682
670
  return dynamicFieldItem.field === item.field;
@@ -750,9 +738,9 @@ export function useDynamicSearchFiled(searchField, dynamicField) {
750
738
  return item;
751
739
  });
752
740
  }),
753
- _useState6 = _slicedToArray(_useState5, 2),
754
- wrapSearchField = _useState6[0],
755
- setWrapSearchField = _useState6[1];
741
+ _useState4 = _slicedToArray(_useState3, 2),
742
+ wrapSearchField = _useState4[0],
743
+ setWrapSearchField = _useState4[1];
756
744
  return wrapSearchField;
757
745
  }
758
746
  export default /*#__PURE__*/React.memo(QueryFilter);
@@ -1,4 +1,4 @@
1
- import { FormProps } from 'antd';
1
+ import { FormInstance, FormProps } from 'antd';
2
2
  import { MouseEventHandler } from 'react';
3
3
  export declare enum FormItemType {
4
4
  Text = "text",
@@ -114,4 +114,5 @@ export interface QueryFilterProps {
114
114
  submitLoading?: boolean;
115
115
  buttonRender?: any;
116
116
  renderButton?: any;
117
+ initForm?: FormInstance;
117
118
  }
package/package.json CHANGED
@@ -1,102 +1,104 @@
1
- {
2
- "name": "@arim-aisdc/public-components",
3
- "version": "1.0.1",
4
- "description": "前端组件库",
5
- "license": "MIT",
6
- "main": "dist/index.js",
7
- "module": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "father build",
14
- "build:watch": "father dev",
15
- "dev": "dumi dev",
16
- "docs:build": "dumi build",
17
- "doctor": "father doctor",
18
- "lint": "npm run lint:es && npm run lint:css",
19
- "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
- "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
- "local": "dumi dev",
22
- "prepare": "husky install && dumi setup",
23
- "prepublishOnly": "father doctor && npm run build",
24
- "start": "npm run dev"
25
- },
26
- "commitlint": {
27
- "extends": [
28
- "@commitlint/config-conventional"
29
- ]
30
- },
31
- "lint-staged": {
32
- "*.{md,json}": [
33
- "prettier --write --no-error-on-unmatched-pattern"
34
- ],
35
- "*.{css,less}": [
36
- "stylelint --fix",
37
- "prettier --write"
38
- ],
39
- "*.{js,jsx}": [
40
- "eslint --fix",
41
- "prettier --write"
42
- ],
43
- "*.{ts,tsx}": [
44
- "eslint --fix",
45
- "prettier --parser=typescript --write"
46
- ]
47
- },
48
- "dependencies": {
49
- "@ant-design/icons": "^4.7.0",
50
- "@ant-design/pro-components": "2.6.51",
51
- "@tanstack/match-sorter-utils": "^8.8.4",
52
- "@tanstack/react-table": "^8.9.1",
53
- "ahooks": "^3.7.8",
54
- "antd": "^4.24.15",
55
- "classnames": "^2.5.1",
56
- "css-vars-ponyfill": "^2.4.8",
57
- "fs": "^0.0.1-security",
58
- "immer": "^10.0.3",
59
- "jsep": "^1.3.8",
60
- "lodash": "^4.17.21",
61
- "path": "^0.12.7",
62
- "react-color": "^2.19.3",
63
- "react-dnd": "^16.0.1",
64
- "react-dnd-html5-backend": "^16.0.1",
65
- "react-draggable": "^4.4.6",
66
- "react-router-dom": "^6.22.3",
67
- "react-split-pane": "^0.1.92"
68
- },
69
- "devDependencies": {
70
- "@commitlint/cli": "^17.1.2",
71
- "@commitlint/config-conventional": "^17.1.0",
72
- "@types/react": "^18.0.0",
73
- "@types/react-dom": "^18.0.0",
74
- "@umijs/lint": "^4.0.0",
75
- "babel-plugin-import": "^1.13.8",
76
- "dumi": "^2.2.13",
77
- "eslint": "^8.23.0",
78
- "father": "^4.1.0",
79
- "husky": "^8.0.1",
80
- "less": "^4.1.3",
81
- "less-loader": "^11.1.0",
82
- "less-vars-to-js": "^1.3.0",
83
- "lint-staged": "^13.0.3",
84
- "mockjs": "^1.1.0",
85
- "prettier": "^2.7.1",
86
- "prettier-plugin-organize-imports": "^3.0.0",
87
- "prettier-plugin-packagejson": "^2.2.18",
88
- "stylelint": "^14.9.1"
89
- },
90
- "peerDependencies": {
91
- "moment": ">=2.29.4",
92
- "react": ">=17.0.1",
93
- "react-dom": ">=17.0.1",
94
- "umi-request": "^1.4.0"
95
- },
96
- "publishConfig": {
97
- "access": "public"
98
- },
99
- "authors": [
100
- "na.xu2278@foxmail.com"
101
- ]
102
- }
1
+ {
2
+ "name": "@arim-aisdc/public-components",
3
+ "version": "1.0.2",
4
+ "description": "前端组件库",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "father build",
14
+ "build:watch": "father dev",
15
+ "dev": "dumi dev",
16
+ "docs:build": "dumi build",
17
+ "doctor": "father doctor",
18
+ "lint": "npm run lint:es && npm run lint:css",
19
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
+ "local": "dumi dev",
22
+ "prepare": "husky install && dumi setup",
23
+ "prepublishOnly": "father doctor && npm run build",
24
+ "start": "npm run dev"
25
+ },
26
+ "commitlint": {
27
+ "extends": [
28
+ "@commitlint/config-conventional"
29
+ ]
30
+ },
31
+ "lint-staged": {
32
+ "*.{md,json}": [
33
+ "prettier --write --no-error-on-unmatched-pattern"
34
+ ],
35
+ "*.{css,less}": [
36
+ "stylelint --fix",
37
+ "prettier --write"
38
+ ],
39
+ "*.{js,jsx}": [
40
+ "eslint --fix",
41
+ "prettier --write"
42
+ ],
43
+ "*.{ts,tsx}": [
44
+ "eslint --fix",
45
+ "prettier --parser=typescript --write"
46
+ ]
47
+ },
48
+ "dependencies": {
49
+ "@ant-design/icons": "^4.7.0",
50
+ "@ant-design/pro-components": "2.6.51",
51
+ "@tanstack/match-sorter-utils": "^8.8.4",
52
+ "@tanstack/react-table": "^8.9.1",
53
+ "ahooks": "^3.7.8",
54
+ "antd": "^4.24.15",
55
+ "classnames": "^2.5.1",
56
+ "css-vars-ponyfill": "^2.4.8",
57
+ "fs": "^0.0.1-security",
58
+ "immer": "^10.0.3",
59
+ "jsep": "^1.3.8",
60
+ "lodash": "^4.17.21",
61
+ "moment": "^2.30.1",
62
+ "path": "^0.12.7",
63
+ "react-color": "^2.19.3",
64
+ "react-dnd": "^16.0.1",
65
+ "react-dnd-html5-backend": "^16.0.1",
66
+ "react-draggable": "^4.4.6",
67
+ "react-router-dom": "^6.22.3",
68
+ "react-split-pane": "^0.1.92",
69
+ "resize-observer-polyfill": "^1.5.1"
70
+ },
71
+ "devDependencies": {
72
+ "@commitlint/cli": "^17.1.2",
73
+ "@commitlint/config-conventional": "^17.1.0",
74
+ "@types/react": "^18.0.0",
75
+ "@types/react-dom": "^18.0.0",
76
+ "@umijs/lint": "^4.0.0",
77
+ "babel-plugin-import": "^1.13.8",
78
+ "dumi": "^2.2.13",
79
+ "eslint": "^8.23.0",
80
+ "father": "^4.1.0",
81
+ "husky": "^8.0.1",
82
+ "less": "^4.1.3",
83
+ "less-loader": "^11.1.0",
84
+ "less-vars-to-js": "^1.3.0",
85
+ "lint-staged": "^13.0.3",
86
+ "mockjs": "^1.1.0",
87
+ "prettier": "^2.7.1",
88
+ "prettier-plugin-organize-imports": "^3.0.0",
89
+ "prettier-plugin-packagejson": "^2.2.18",
90
+ "stylelint": "^14.9.1"
91
+ },
92
+ "peerDependencies": {
93
+ "moment": ">=2.29.4",
94
+ "react": ">=17.0.1",
95
+ "react-dom": ">=17.0.1",
96
+ "umi-request": "^1.4.0"
97
+ },
98
+ "publishConfig": {
99
+ "access": "public"
100
+ },
101
+ "authors": [
102
+ "na.xu2278@foxmail.com"
103
+ ]
104
+ }