ztxkui 2.9.8 → 3.0.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.
@@ -92,7 +92,7 @@ var FormDemo = function () {
92
92
  return (React.createElement(React.Fragment, null,
93
93
  React.createElement(Form, { name: "test-list", form: form },
94
94
  React.createElement(SearchContainer, { dark: true },
95
- React.createElement(SearchLeft, { configInfo: configInfoMemo },
95
+ React.createElement(SearchLeft, { isDynamic: true, dynamicStorageKey: "symbol-key-00001" },
96
96
  React.createElement(SearchItem, { width: "half", name: "pwNo", configname: "pwNoCopy", label: "\u5165\u5E93\u5355\u53F7", rules: [
97
97
  {
98
98
  required: true,
@@ -127,7 +127,7 @@ var FormDemo = function () {
127
127
  React.createElement(Select, { allowClear: true },
128
128
  React.createElement(Select.Option, { value: "1" }, "\u662F"),
129
129
  React.createElement(Select.Option, { value: "0" }, "\u5426"))),
130
- React.createElement(SearchItem, { name: "test1", label: "\u90E8\u95E8\u540D\u79F0" },
130
+ React.createElement(SearchItem, { name: "test1", label: "", hiddenLabelName: "\u6D4B\u8BD5\u90E8\u95E8\u4E0D\u663E\u793A" },
131
131
  React.createElement(Checkbox.Group, null,
132
132
  React.createElement(Checkbox, { value: "1" }, "\u662F"),
133
133
  React.createElement(Checkbox, { value: "2" }, "\u5426"))),
@@ -20,29 +20,30 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React from 'react';
23
+ import React, { useRef } from 'react';
24
24
  import { Button as AntButton } from 'antd';
25
25
  import classNames from 'classnames';
26
26
  var maxClickTime = 1000;
27
27
  var Button = function (props) {
28
28
  var _a;
29
29
  var children = props.children, type = props.type, size = props.size, disabled = props.disabled, danger = props.danger, className = props.className, onClick = props.onClick, _b = props.agentClick, agentClick = _b === void 0 ? true : _b, restProps = __rest(props, ["children", "type", "size", "disabled", "danger", "className", "onClick", "agentClick"]);
30
+ var startTimeRef = useRef(0);
30
31
  var classes = classNames('zt-btn', className, (_a = {},
31
32
  _a["zt-btn-" + type] = type,
32
33
  _a["zt-btn-disabled"] = disabled,
33
34
  _a["zt-btn-" + size] = size,
34
35
  _a["zt-btn-dangerous"] = danger,
35
36
  _a));
36
- var startTime = 0;
37
37
  var myOnClick = function (event) {
38
38
  if (agentClick) {
39
39
  var nowDateTime = Date.now();
40
- if (startTime === 0 || nowDateTime - startTime > maxClickTime) {
41
- startTime = nowDateTime;
40
+ if (startTimeRef.current === 0 ||
41
+ nowDateTime - startTimeRef.current > maxClickTime) {
42
+ startTimeRef.current = nowDateTime;
42
43
  onClick && onClick(event);
43
44
  }
44
45
  else {
45
- startTime = nowDateTime;
46
+ startTimeRef.current = nowDateTime;
46
47
  console.log('点击按钮过于频繁');
47
48
  }
48
49
  }
@@ -28,6 +28,7 @@ import React, { useCallback, useEffect, memo, useRef, useState } from 'react';
28
28
  import { Select } from 'antd';
29
29
  import { useFetchState } from 'ztxkutils/dist/hooks';
30
30
  import debounce from 'lodash/debounce';
31
+ import axios from 'axios';
31
32
  /**
32
33
  * 组件缓存的数据格式,在当前浏览器运行内,能保证是唯一的引用,用来缓存数据用
33
34
  * {
@@ -154,7 +155,8 @@ function EnhanceSelect(_a) {
154
155
  });
155
156
  }, [setSelectList, setLoading, transformData, mustHasParams]);
156
157
  // 远程搜索
157
- var getRemoteDataHandle = useCallback(function (value, dataKeyValue) {
158
+ var getRemoteDataHandle = useCallback(function (value, dataKeyValue, options) {
159
+ if (options === void 0) { options = {}; }
158
160
  var searchKey = remoteSearchKey ? remoteSearchKey : titleKey;
159
161
  var searchDataKey = remoteSearchDataKey ? remoteSearchDataKey : dataKey;
160
162
  var outParams = params;
@@ -177,13 +179,10 @@ function EnhanceSelect(_a) {
177
179
  if (dataKeyValue) {
178
180
  searchParams[searchDataKey] = dataKeyValue + '';
179
181
  }
180
- getData(request, {
181
- url: url,
182
- method: method,
183
- params: __assign(__assign({ size: Array.isArray(dataKeyValue) && dataKeyValue.length > 30
182
+ getData(request, __assign({ url: url,
183
+ method: method, params: __assign(__assign({ size: Array.isArray(dataKeyValue) && dataKeyValue.length > 30
184
184
  ? dataKeyValue.length
185
- : 30, page: 1 }, outParams), searchParams),
186
- })
185
+ : 30, page: 1 }, outParams), searchParams) }, options))
187
186
  .then(function (resData) {
188
187
  var _a, _b, _c, _d;
189
188
  if (fetchIdClosure < fetchId.current) {
@@ -256,6 +255,7 @@ function EnhanceSelect(_a) {
256
255
  if (!url || remoteSearch) {
257
256
  return;
258
257
  }
258
+ var source = null;
259
259
  // console.log('TEST: 异步获取');
260
260
  if (isCatch) {
261
261
  // 如果是走缓存的话,那么先往缓存数据中取,有没有当前数据,如果没有就发请求
@@ -271,7 +271,8 @@ function EnhanceSelect(_a) {
271
271
  }
272
272
  else {
273
273
  // 发送接口请求,并设置缓存数据
274
- getDataHandle(request, { url: url, params: params, method: method, timeout: timeout }, {
274
+ source = axios.CancelToken.source();
275
+ getDataHandle(request, { url: url, params: params, method: method, timeout: timeout, cancelToken: source.token }, {
275
276
  obj: catchData,
276
277
  key: catchDataKey,
277
278
  });
@@ -280,8 +281,20 @@ function EnhanceSelect(_a) {
280
281
  }
281
282
  else {
282
283
  // 直接发送接口请求
283
- getDataHandle(request, { url: url, params: params, method: method, timeout: timeout });
284
+ source = axios.CancelToken.source();
285
+ getDataHandle(request, {
286
+ url: url,
287
+ params: params,
288
+ method: method,
289
+ timeout: timeout,
290
+ cancelToken: source.token,
291
+ });
284
292
  }
293
+ return function () {
294
+ if (source) {
295
+ source.cancel();
296
+ }
297
+ };
285
298
  }, [
286
299
  url,
287
300
  params,
@@ -300,6 +313,7 @@ function EnhanceSelect(_a) {
300
313
  if (!url || !remoteSearch) {
301
314
  return;
302
315
  }
316
+ var source = null;
303
317
  // console.log('TEST: 远程搜索');
304
318
  // 如果初始化请求已经做过了,那么这个副作用直接返回
305
319
  if (firstLoading) {
@@ -314,16 +328,23 @@ function EnhanceSelect(_a) {
314
328
  }
315
329
  if (!restProps.value) {
316
330
  // console.log('第一次请求数据');
317
- getRemoteDataHandle('', '');
331
+ source = axios.CancelToken.source();
332
+ getRemoteDataHandle('', '', { cancelToken: source.token });
318
333
  }
319
334
  else {
320
335
  if (typeof restProps.value === 'string' ||
321
336
  (Array.isArray(restProps.value) && restProps.value.length > 0)) {
322
337
  // console.log('第二次请求数据,默认为需要根据主键去请求', restProps.value);
323
338
  setFirstLoading(true);
324
- getRemoteDataHandle('', restProps.value);
339
+ source = axios.CancelToken.source();
340
+ getRemoteDataHandle('', restProps.value, { cancelToken: source.token });
325
341
  }
326
342
  }
343
+ return function () {
344
+ if (source) {
345
+ source.cancel();
346
+ }
347
+ };
327
348
  }, [
328
349
  url,
329
350
  remoteSearch,
@@ -337,13 +358,19 @@ function EnhanceSelect(_a) {
337
358
  if (!url || !remoteSearch) {
338
359
  return;
339
360
  }
361
+ var source = null;
340
362
  // console.log('TEST: 远程搜索');
341
363
  // 这种情况不需要启用远程搜索key值
342
364
  if (!isRemoteSearchDataKey) {
343
- getRemoteDataHandle('', '');
365
+ source = axios.CancelToken.source();
366
+ getRemoteDataHandle('', '', { cancelToken: source.token });
344
367
  setFirstLoading(true);
345
- return;
346
368
  }
369
+ return function () {
370
+ if (source) {
371
+ source.cancel();
372
+ }
373
+ };
347
374
  }, [
348
375
  url,
349
376
  remoteSearch,
@@ -4,6 +4,8 @@ export interface ISearchLayout {
4
4
  label?: string;
5
5
  show?: boolean;
6
6
  disabled?: boolean;
7
+ hiddenLabelName?: string;
8
+ [props: string]: any;
7
9
  }
8
10
  /**
9
11
  * @description 将动态配置存在本地存储中
@@ -98,10 +98,11 @@ dynamicStorageKey // 动态列配置的key值
98
98
  // 遍历当前子元素
99
99
  React.Children.forEach(children, function (item) {
100
100
  if (item === null || item === void 0 ? void 0 : item.props) {
101
- var _a = item.props, name_2 = _a.name, label = _a.label, disabled = _a.disabled;
101
+ var _a = item.props, name_2 = _a.name, label = _a.label, hiddenLabelName = _a.hiddenLabelName, disabled = _a.disabled;
102
102
  _initDynamicList_1.push({
103
103
  name: name_2,
104
104
  label: label,
105
+ hiddenLabelName: hiddenLabelName,
105
106
  show: true,
106
107
  disabled: disabled,
107
108
  });
@@ -109,6 +110,7 @@ dynamicStorageKey // 动态列配置的key值
109
110
  _currentDynamicList_1.push({
110
111
  name: name_2,
111
112
  label: label,
113
+ hiddenLabelName: hiddenLabelName,
112
114
  show: true,
113
115
  disabled: disabled,
114
116
  });
@@ -60,6 +60,6 @@ var SearchDrawer = function (_a) {
60
60
  return (React.createElement(Drawer, { className: "search-drawer", title: "\u67E5\u8BE2\u6761\u4EF6\u5207\u6362", placement: "right", visible: visible, closable: false, maskClosable: false, footer: renderFooter() },
61
61
  React.createElement(DndProvider, { backend: HTML5Backend, context: window },
62
62
  React.createElement(Checkbox.Group, { value: checkedValues, onChange: onCheckboxChange }, dynamicList.map(function (item, index) { return (React.createElement(Sortable, { key: item.name, type: "search-drawer", index: index, onMoveItem: onMoveItem },
63
- React.createElement(Checkbox, { value: item.name }, item.label || item.name))); })))));
63
+ React.createElement(Checkbox, { value: item.name }, item.label || item.hiddenLabelName || item.name))); })))));
64
64
  };
65
65
  export default memo(SearchDrawer);
@@ -14,6 +14,8 @@ export interface ISearchItem extends FormItemProps {
14
14
  configname?: string;
15
15
  /**不需要自动配置 */
16
16
  noauto?: string;
17
+ /**不显示label,但是作为动态表单配置启用 */
18
+ hiddenLabelName?: string;
17
19
  }
18
20
  declare const SearchItem: React.FC<ISearchItem>;
19
21
  export default SearchItem;
@@ -4,6 +4,8 @@ export interface ISearchLayout {
4
4
  label?: string;
5
5
  show?: boolean;
6
6
  disabled?: boolean;
7
+ hiddenLabelName?: string;
8
+ [props: string]: any;
7
9
  }
8
10
  export interface ISearchLeft {
9
11
  isDynamic?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.9.8",
3
+ "version": "3.0.1",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",