ztxkui 3.8.1 → 3.8.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.
package/dist/Demo.js CHANGED
@@ -6,7 +6,7 @@ var selectStyle = { width: '200px' };
6
6
  function request(options) {
7
7
  return fetch(options.url + "?" + stringify(options.params), {
8
8
  headers: {
9
- 'Zmdms-Auth': 'bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJtZW1iZXJfdHlwZSI6MSwiaGFuZGxlX2hyX3Bob25lIjpudWxsLCJyZXN1bWVfZGF0ZSI6bnVsbCwidXNlcl9uYW1lIjoiY2hlbnl4IiwiZW1wX25hbWUiOm51bGwsImVtcF9udW1iZXIiOm51bGwsImltdF9pZCI6bnVsbCwicmVhbF9uYW1lIjoi6ZmI5Lqa6ZuEIiwiY2xpZW50X3R5cGUiOiJ3ZWIiLCJkYXRhX3JvbGVfaWQiOiIxMzQzNDkwNjg2MjYwMjI4MDk3LDEzNDU5Nzg1MDUzMDIwNTY5NjIsMTQ2ODAzNTM1MTYyNTI4NTYzNCwxNTQyMDc2MzA4NTc4MDI1NDc0IiwiY2xpZW50X2lkIjoic3dvcmQiLCJ1c2VyX3R5cGUiOiJ3ZWIiLCJyb2xlX2lkIjoiMTEyMzU5ODgxNjczODY3NTIwMSwxNDY3MDE1OTc1NDg0NzYwMDY2LDE0NjgwMzQ0MzcxNTc5NjE3MjksMTQ4MDgyOTMzNzkzOTEzMjQxNyIsInBvc3RfbmFtZSI6bnVsbCwic2NvcGUiOlsiYWxsIl0sImludGVydmlld19pZCI6bnVsbCwiZXhwIjoxNjU4NDc2NTY5LCJvcmdfbmFtZSI6bnVsbCwianRpIjoiMGI2OWZjMTYtODhkMS00YjIxLWIwMWEtYzFkY2Y0MjVmZGVlIiwibWVtYmVyX2lkIjoxLCJjb21wYW55X2lkIjpudWxsLCJzeXN0ZW1faWQiOm51bGw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(response) { return response.json(); });
@@ -23,6 +23,9 @@ function Demo() {
23
23
  tenantId: '000000',
24
24
  isCreateUser: 0,
25
25
  })[0];
26
+ var _g = useState(JSON.stringify({
27
+ status: 50,
28
+ })), params1 = _g[0], setParams1 = _g[1];
26
29
  // 模拟接口请求
27
30
  useEffect(function () {
28
31
  var timeoutId = setTimeout(function () {
@@ -91,23 +94,28 @@ function Demo() {
91
94
  console.log(value, option, fullData);
92
95
  } }),
93
96
  React.createElement("h2", null, "\u5F02\u6B65\u83B7\u53D6\u6570\u636E"),
94
- React.createElement(EnhanceSelect, { style: selectStyle, url: "http://192.168.0.83:8000/api/zmdms-user/page", params: JSON.stringify({
95
- status: 50,
96
- companyId: '1397074605412696066',
97
- }), request: request, joinKey: "depName" }),
98
97
  React.createElement("h2", null, "\u5F02\u6B65\u83B7\u53D6\u6570\u636E\uFF0C\u5E76\u7F13\u5B58\u6570\u636E"),
99
- React.createElement(EnhanceSelect, { style: selectStyle, url: "http://192.168.0.83:8000/api/zmdms-user/page", params: JSON.stringify({
100
- status: 50,
101
- companyId: '1397074605412696066',
102
- }), request: request, isCatch: true }),
103
98
  React.createElement("h2", null, "\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22"),
104
99
  React.createElement("button", { onClick: function () { return setValue('1462433051208762629'); } }, "\u4FEE\u6539"),
100
+ React.createElement("p", null, "\u8FDC\u7A0B\u641C\u7D22"),
105
101
  React.createElement(EnhanceSelect, { style: selectStyle,
106
102
  // defaultList={list}
107
103
  placeholder: "\u53EF\u8FDC\u7A0B\u6A21\u7CCA\u641C\u7D22", url: "http://192.168.0.83:8000/api/zmdms-system/employee/page", request: request, remoteSearch: true, isHandAddItem: true, isRemoteSearchDataKey: false, dataKey: "id", titleKey: "empName", value: value, showAll: true, onChange: function (value, option, fullData) {
108
104
  setValue(value);
109
105
  }, params: JSON.stringify(params),
110
106
  // value={value}
111
- mode: "multiple", isPage: true })));
107
+ mode: "multiple", isPage: true,
108
+ // defaultList={defaultList}
109
+ isClickRequest: true }),
110
+ React.createElement("p", null, "\u4E00\u6B21\u6027\u52A0\u8F7D\u6570\u636E"),
111
+ React.createElement(EnhanceSelect, { style: selectStyle, placeholder: "\u4E00\u6B21\u6027\u52A0\u8F7D\u6570\u636E", url: "http://192.168.0.83:8000/api/zmdms-system/company/list", request: request, dataKey: "id", titleKey: "name", isClickRequest: true }),
112
+ React.createElement("p", null, "\u5F02\u6B65\u83B7\u53D6\u6570\u636E"),
113
+ React.createElement("button", { onClick: function () {
114
+ setParams1(JSON.stringify({
115
+ status: 50,
116
+ companyId: '1414851965111283713',
117
+ }));
118
+ } }, "\u4FEE\u6539"),
119
+ React.createElement(EnhanceSelect, { style: selectStyle, placeholder: "\u5F02\u6B65\u83B7\u53D6\u6570\u636E", url: "http://192.168.0.83:8000/api/zmdms-user/page", params: params1, request: request, joinKey: "depName", dataKey: "id", titleKey: "name", remoteSearch: true, isRemoteSearchDataKey: false, isClickRequest: true })));
112
120
  }
113
121
  export default Demo;
@@ -127,6 +127,10 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
127
127
  * 是否需要选中复制到剪切板
128
128
  */
129
129
  isCopy?: boolean;
130
+ /**
131
+ * 是否点击时才请求
132
+ */
133
+ isClickRequest?: boolean;
130
134
  }
131
135
  /**
132
136
  * 增强下拉框功能组件
@@ -143,6 +147,6 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
143
147
  * { code: 200, data: { records: [] } } || { status: 200, data: { code: 200, data: { records: [] } } }
144
148
  * 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
145
149
  */
146
- declare function EnhanceSelect<VT extends SelectValue = SelectValue>({ list, defaultList, params, url, method, timeout, dataKey, componentKey, titleKey, showAll, isCatch, onCompleted, onChange, onSearch, request, remoteSearch, remoteSearchKey, remoteSearchDataKey, isRemoteSearchDataKey, transformData, joinKey, joinStr, lineFeedKey, lineFeedStr, mustHasParams, disabledValues, searchDeleteKeys, isHandAddItem, isPage, currentSize, isCopy, onBlur, onFocus, ...restProps }: IProps<VT>): JSX.Element;
150
+ declare function EnhanceSelect<VT extends SelectValue = SelectValue>({ list, defaultList, params, url, method, timeout, dataKey, componentKey, titleKey, showAll, isCatch, onCompleted, onChange, onSearch, request, remoteSearch, remoteSearchKey, remoteSearchDataKey, isRemoteSearchDataKey, transformData, joinKey, joinStr, lineFeedKey, lineFeedStr, mustHasParams, disabledValues, searchDeleteKeys, isHandAddItem, isPage, currentSize, isCopy, onBlur, onFocus, isClickRequest, ...restProps }: IProps<VT>): JSX.Element;
147
151
  declare const _default: React.MemoExoticComponent<typeof EnhanceSelect>;
148
152
  export default _default;
@@ -100,7 +100,7 @@ function textContent(children) {
100
100
  * 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
101
101
  */
102
102
  function EnhanceSelect(_a) {
103
- var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.timeout, timeout = _c === void 0 ? 60000 : _c, _d = _a.dataKey, dataKey = _d === void 0 ? 'id' : _d, componentKey = _a.componentKey, _e = _a.titleKey, titleKey = _e === void 0 ? 'name' : _e, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, onSearch = _a.onSearch, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, _f = _a.isRemoteSearchDataKey, isRemoteSearchDataKey = _f === void 0 ? true : _f, transformData = _a.transformData, joinKey = _a.joinKey, _g = _a.joinStr, joinStr = _g === void 0 ? '-' : _g, lineFeedKey = _a.lineFeedKey, _h = _a.lineFeedStr, lineFeedStr = _h === void 0 ? '-' : _h, mustHasParams = _a.mustHasParams, disabledValues = _a.disabledValues, searchDeleteKeys = _a.searchDeleteKeys, isHandAddItem = _a.isHandAddItem, isPage = _a.isPage, _j = _a.currentSize, currentSize = _j === void 0 ? 30 : _j, isCopy = _a.isCopy, onBlur = _a.onBlur, onFocus = _a.onFocus, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "timeout", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "onSearch", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "isRemoteSearchDataKey", "transformData", "joinKey", "joinStr", "lineFeedKey", "lineFeedStr", "mustHasParams", "disabledValues", "searchDeleteKeys", "isHandAddItem", "isPage", "currentSize", "isCopy", "onBlur", "onFocus"]);
103
+ var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.timeout, timeout = _c === void 0 ? 60000 : _c, _d = _a.dataKey, dataKey = _d === void 0 ? 'id' : _d, componentKey = _a.componentKey, _e = _a.titleKey, titleKey = _e === void 0 ? 'name' : _e, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, onSearch = _a.onSearch, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, _f = _a.isRemoteSearchDataKey, isRemoteSearchDataKey = _f === void 0 ? true : _f, transformData = _a.transformData, joinKey = _a.joinKey, _g = _a.joinStr, joinStr = _g === void 0 ? '-' : _g, lineFeedKey = _a.lineFeedKey, _h = _a.lineFeedStr, lineFeedStr = _h === void 0 ? '-' : _h, mustHasParams = _a.mustHasParams, disabledValues = _a.disabledValues, searchDeleteKeys = _a.searchDeleteKeys, isHandAddItem = _a.isHandAddItem, isPage = _a.isPage, _j = _a.currentSize, currentSize = _j === void 0 ? 30 : _j, isCopy = _a.isCopy, onBlur = _a.onBlur, onFocus = _a.onFocus, isClickRequest = _a.isClickRequest, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "timeout", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "onSearch", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "isRemoteSearchDataKey", "transformData", "joinKey", "joinStr", "lineFeedKey", "lineFeedStr", "mustHasParams", "disabledValues", "searchDeleteKeys", "isHandAddItem", "isPage", "currentSize", "isCopy", "onBlur", "onFocus", "isClickRequest"]);
104
104
  var currentClick = useRef(true);
105
105
  // 下拉数据源
106
106
  var _k = useFetchState([]), selectList = _k[0], setSelectList = _k[1];
@@ -124,6 +124,8 @@ function EnhanceSelect(_a) {
124
124
  var _u = useState(0), count = _u[0], setCount = _u[1];
125
125
  // 手动清空数据
126
126
  var handleClearDataRef = useRef(false);
127
+ // 是否自动请求
128
+ var isAutoRequest = useRef(false); // 请求过了
127
129
  // 处理value
128
130
  var newValue = useMemo(function () {
129
131
  var _a, _b;
@@ -370,24 +372,18 @@ function EnhanceSelect(_a) {
370
372
  }
371
373
  }, [list, setSelectList]);
372
374
  // 2、如果是走接口请求的,url必须传递
373
- useEffect(function () {
375
+ var sendRequest = useCallback(function () {
374
376
  if (!url || remoteSearch) {
375
377
  return;
376
378
  }
377
- // console.log('TEST: 异步获取');
378
379
  if (isCatch) {
379
- // 如果是走缓存的话,那么先往缓存数据中取,有没有当前数据,如果没有就发请求
380
380
  if (enhanceSelectCatchObj) {
381
381
  enhanceSelectCatchObj[url] = enhanceSelectCatchObj[url]
382
382
  ? enhanceSelectCatchObj[url]
383
383
  : {};
384
384
  var catchData = enhanceSelectCatchObj[url];
385
385
  var catchDataKey = params ? JSON.stringify(params) : 'single';
386
- if (catchData[catchDataKey]) {
387
- // 读取缓存数据
388
- setSelectList(catchData[catchDataKey]);
389
- }
390
- else {
386
+ if (!catchData[catchDataKey]) {
391
387
  // 发送接口请求,并设置缓存数据
392
388
  getDataHandle(request, { url: url, params: params, method: method, timeout: timeout }, {
393
389
  appointObj: {
@@ -399,7 +395,6 @@ function EnhanceSelect(_a) {
399
395
  }
400
396
  }
401
397
  else {
402
- // 直接发送接口请求
403
398
  getDataHandle(request, {
404
399
  url: url,
405
400
  params: params,
@@ -408,19 +403,119 @@ function EnhanceSelect(_a) {
408
403
  });
409
404
  }
410
405
  }, [
411
- url,
412
- params,
406
+ getDataHandle,
407
+ isCatch,
413
408
  method,
414
- timeout,
409
+ params,
415
410
  request,
411
+ timeout,
412
+ url,
413
+ remoteSearch,
414
+ ]);
415
+ useEffect(function () {
416
+ if (!url || remoteSearch) {
417
+ return;
418
+ }
419
+ // console.log('TEST: 异步获取');
420
+ if (isCatch) {
421
+ // 如果是走缓存的话,那么先往缓存数据中取,有没有当前数据,如果没有就发请求
422
+ if (enhanceSelectCatchObj) {
423
+ enhanceSelectCatchObj[url] = enhanceSelectCatchObj[url]
424
+ ? enhanceSelectCatchObj[url]
425
+ : {};
426
+ var catchData = enhanceSelectCatchObj[url];
427
+ var catchDataKey = params ? JSON.stringify(params) : 'single';
428
+ if (catchData[catchDataKey]) {
429
+ // 读取缓存数据
430
+ setSelectList(catchData[catchDataKey]);
431
+ }
432
+ else {
433
+ if (isClickRequest) {
434
+ isAutoRequest.current = false;
435
+ return;
436
+ }
437
+ // 发送接口请求,并设置缓存数据
438
+ sendRequest();
439
+ // getDataHandle(
440
+ // request,
441
+ // { url, params, method, timeout },
442
+ // {
443
+ // appointObj: {
444
+ // obj: catchData,
445
+ // key: catchDataKey,
446
+ // },
447
+ // }
448
+ // );
449
+ }
450
+ }
451
+ }
452
+ else {
453
+ if (isClickRequest) {
454
+ return;
455
+ }
456
+ // 直接发送接口请求
457
+ sendRequest();
458
+ // getDataHandle(request, {
459
+ // url,
460
+ // params,
461
+ // method,
462
+ // timeout,
463
+ // });
464
+ }
465
+ }, [
466
+ // url,
467
+ // params,
468
+ // method,
469
+ // timeout,
470
+ // request,
471
+ // isCatch,
472
+ // setSelectList,
473
+ // getDataHandle,
474
+ // remoteSearch,
416
475
  isCatch,
417
- setSelectList,
418
- getDataHandle,
476
+ isClickRequest,
477
+ params,
419
478
  remoteSearch,
479
+ sendRequest,
480
+ setSelectList,
481
+ url,
420
482
  ]);
421
483
  // 3、远程搜索,url必须传递
422
484
  // 关于远程查询,最好的做法还是后台根据主键再去查一次详情数据,这样就能保证
423
485
  // 查出来的数据就能保证不止一条
486
+ var sendRemoteRequest = useCallback(function () {
487
+ if (!url || !remoteSearch) {
488
+ return;
489
+ }
490
+ if (firstLoading) {
491
+ // console.log('已经通过id访问了');
492
+ return;
493
+ }
494
+ if (!isRemoteSearchDataKey) {
495
+ setFirstLoading(true);
496
+ return;
497
+ }
498
+ if (!restProps.value) {
499
+ // console.log('第一次请求数据');
500
+ getRemoteDataHandle('', '');
501
+ }
502
+ else {
503
+ if (typeof restProps.value === 'string' ||
504
+ (Array.isArray(restProps.value) && restProps.value.length > 0)) {
505
+ // console.log('第二次请求数据,默认为需要根据主键去请求', restProps.value);
506
+ setFirstLoading(true);
507
+ getRemoteDataHandle('', restProps.value);
508
+ }
509
+ }
510
+ }, [
511
+ url,
512
+ remoteSearch,
513
+ firstLoading,
514
+ isRemoteSearchDataKey,
515
+ setFirstLoading,
516
+ restProps.value,
517
+ getRemoteDataHandle,
518
+ ]);
424
519
  useEffect(function () {
425
520
  if (!url || !remoteSearch) {
426
521
  return;
@@ -437,6 +532,10 @@ function EnhanceSelect(_a) {
437
532
  setFirstLoading(true);
438
533
  return;
439
534
  }
535
+ if (isClickRequest) {
536
+ isAutoRequest.current = false;
537
+ return;
538
+ }
440
539
  if (!restProps.value) {
441
540
  // console.log('第一次请求数据');
442
541
  getRemoteDataHandle('', '');
@@ -457,11 +556,33 @@ function EnhanceSelect(_a) {
457
556
  firstLoading,
458
557
  isRemoteSearchDataKey,
459
558
  setFirstLoading,
559
+ isClickRequest,
560
+ ]);
561
+ var sendRemoteRequest1 = useCallback(function () {
562
+ if (!url || !remoteSearch) {
563
+ return;
564
+ }
565
+ // console.log('TEST: 远程搜索');
566
+ // 这种情况不需要启用远程搜索key值
567
+ if (!isRemoteSearchDataKey) {
568
+ getRemoteDataHandle('', '');
569
+ setFirstLoading(true);
570
+ }
571
+ }, [
572
+ url,
573
+ remoteSearch,
574
+ setFirstLoading,
575
+ getRemoteDataHandle,
576
+ isRemoteSearchDataKey,
460
577
  ]);
461
578
  useEffect(function () {
462
579
  if (!url || !remoteSearch) {
463
580
  return;
464
581
  }
582
+ if (isClickRequest) {
583
+ isAutoRequest.current = false;
584
+ return;
585
+ }
465
586
  // console.log('TEST: 远程搜索');
466
587
  // 这种情况不需要启用远程搜索key值
467
588
  if (!isRemoteSearchDataKey) {
@@ -474,6 +595,7 @@ function EnhanceSelect(_a) {
474
595
  setFirstLoading,
475
596
  getRemoteDataHandle,
476
597
  isRemoteSearchDataKey,
598
+ isClickRequest,
477
599
  ]);
478
600
  // 数据合并
479
601
  function concatData(originalData, newData) {
@@ -663,13 +785,13 @@ function EnhanceSelect(_a) {
663
785
  };
664
786
  // 焦点事件
665
787
  var onFocusHandle = function (e) {
666
- // console.log('焦点事件');
788
+ console.log('焦点事件');
667
789
  setIsOpen(true);
668
790
  currentClick.current = false;
669
791
  onFocus && onFocus(e);
670
792
  };
671
793
  var onBlurHandle = function (e) {
672
- // console.log('失去焦点事件');
794
+ console.log('失去焦点事件');
673
795
  setIsOpen(false);
674
796
  currentClick.current = false;
675
797
  onBlur && onBlur(e);
@@ -700,6 +822,12 @@ function EnhanceSelect(_a) {
700
822
  // 点击时
701
823
  var onClickHandle = function (e) {
702
824
  // console.log('点击事件', currentClick.current);
825
+ if (!isAutoRequest.current && isClickRequest) {
826
+ isAutoRequest.current = true;
827
+ sendRequest();
828
+ sendRemoteRequest();
829
+ sendRemoteRequest1();
830
+ }
703
831
  if (currentClick.current) {
704
832
  console.log(e.nativeEvent.target.getAttribute('class'));
705
833
  var className = '';
@@ -734,6 +862,10 @@ function EnhanceSelect(_a) {
734
862
  };
735
863
  return (React.createElement(Select, __assign({ defaultValue: showAll ? '' : undefined, allowClear: true, showSearch: true, filterOption: remoteSearch ? false : filterOptionHandle, onSearch: remoteSearch ? onSearchHandle : onSearchHandleInner, onChange: onChangeHandle, optionLabelProp: "title", loading: loading, onFocus: onFocusHandle, onBlur: onBlurHandle, onClear: onClearHandle, onSelect: onSelectHandle, onClick: onClickHandle,
736
864
  // getPopupContainer={(trigger) => trigger || document.body}
737
- open: isOpen, onPopupScroll: onPopupScrollHandle }, restProps, { value: newValue, disabled: remoteSearch ? restProps.disabled : loading || restProps.disabled }), renderSelectOption()));
865
+ open: isOpen, onPopupScroll: onPopupScrollHandle }, restProps, { value: newValue,
866
+ // 这里需要注释掉,因为修改了一部分逻辑
867
+ disabled: remoteSearch || isClickRequest
868
+ ? restProps.disabled
869
+ : loading || restProps.disabled }), renderSelectOption()));
738
870
  }
739
871
  export default memo(EnhanceSelect);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",