ztxkui 3.8.7 → 3.8.9
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/DemoCom/PrintContainerDemo.js +1 -1
- package/dist/TableDemo/EditableTable.js +2 -0
- package/dist/components/EnhanceSelect/index.js +127 -46
- package/dist/components/PrintContainer/print-container.js +2 -0
- package/dist/components/PrintContainer/utils.d.ts +12 -0
- package/dist/components/PrintContainer/utils.js +15 -10
- package/dist/components/Table/hooks/useColumns.d.ts +1 -0
- package/dist/components/Table/hooks/useColumns.js +18 -1
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/table.js +33 -0
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ function request(options) {
|
|
|
30
30
|
return axios({
|
|
31
31
|
baseURL: options.baseURL ? options.baseURL : 'http://192.168.0.83:8000',
|
|
32
32
|
url: options.url,
|
|
33
|
-
headers: __assign({ 'Zmdms-Auth': 'bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
33
|
+
headers: __assign({ 'Zmdms-Auth': 'bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJtZW1iZXJfdHlwZSI6MSwiaGFuZGxlX2hyX3Bob25lIjpudWxsLCJyZXN1bWVfZGF0ZSI6bnVsbCwidXNlcl9uYW1lIjoiY2hlbnl4IiwiZW1wX25hbWUiOm51bGwsImVtcF9udW1iZXIiOm51bGwsImltdF9pZCI6bnVsbCwicmVhbF9uYW1lIjoi6ZmI5Lqa6ZuEIiwiY2xpZW50X3R5cGUiOiJ3ZWIiLCJkYXRhX3JvbGVfaWQiOiIxMzQ1OTc4NTA1MzAyMDU2OTYyLDE0NjgwMzUzNTE2MjUyODU2MzQsMTU0MjA3NjMwODU3ODAyNTQ3NCIsImNsaWVudF9pZCI6InN3b3JkIiwidXNlcl90eXBlIjoid2ViIiwicm9sZV9pZCI6IjExMjM1OTg4MTY3Mzg2NzUyMDEsMTQ2NzAxNTk3NTQ4NDc2MDA2NiwxNDY4MDM0NDM3MTU3OTYxNzI5LDE0ODA4MjkzMzc5MzkxMzI0MTciLCJwb3N0X25hbWUiOm51bGwsInNjb3BlIjpbImFsbCJdLCJpbnRlcnZpZXdfaWQiOm51bGwsImV4cCI6MTY2NTAzMzgwMywib3JnX25hbWUiOm51bGwsImp0aSI6Ijk1MDJkZjkxLWEwZDAtNDU5Ni1hZGEwLWU1YmEzM2RiYjkzOCIsIm1lbWJlcl9pZCI6MSwiY29tcGFueV9pZCI6bnVsbCwic3lzdGVtX2lkIjpudWxsLCJkZXB0X25hbWUiOm51bGwsImF2YXRhciI6IiIsImRhdGFfcm9sZV9uYW1lIjoiYWRtaW4sYWRtaW4sYWRtaW4iLCJhdXRob3JpdGllcyI6WyJhZG1pbiIsInVzZXIiLCJhZG1pbmlzdHJhdG9yIl0sInJvbGVfbmFtZSI6ImFkbWluaXN0cmF0b3IsdXNlcixhZG1pbixhZG1pbiIsInJlc3VtZV90ZW1wbGF0ZSI6bnVsbCwibGljZW5zZSI6InBvd2VyZWQgYnkgem1kbXMiLCJwb3N0X2lkIjoiIiwidXNlcl9pZCI6IjE0MTI5NTM4MDQzMzM1NTU3MTQiLCJvcmdfaWQiOm51bGwsIm5pY2tfbmFtZSI6IumZiOS6mumbhCIsImNvbXBhbnlfbmFtZSI6bnVsbCwiZGVwdF9pZCI6IiIsImhhbmRsZV9ocl9uYW1lIjpudWxsLCJhY2NvdW50IjoiY2hlbnl4IiwicmVzdW1lX2lkIjpudWxsfQ.YhEz7JGYIXKXVinlyHEqgmxltIEPCySypAvfOqbxQWY' }, options.headers),
|
|
34
34
|
method: options.method,
|
|
35
35
|
data: options.data,
|
|
36
36
|
params: options.params,
|
|
@@ -30,7 +30,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
30
30
|
* @description 增强下拉框功能
|
|
31
31
|
*/
|
|
32
32
|
import React, { useCallback, useEffect, memo, useRef, useState, useMemo, } from 'react';
|
|
33
|
-
import { Select } from 'antd';
|
|
33
|
+
import { Divider, Select } from 'antd';
|
|
34
|
+
import Button from '../Button';
|
|
34
35
|
import { useFetchState } from 'ztxkutils/dist/hooks';
|
|
35
36
|
import debounce from 'lodash/debounce';
|
|
36
37
|
import { dangerouslySetXss } from 'ztxkutils/dist/tools';
|
|
@@ -103,7 +104,9 @@ function textContent(children) {
|
|
|
103
104
|
*/
|
|
104
105
|
function EnhanceSelect(_a) {
|
|
105
106
|
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"]);
|
|
106
|
-
|
|
107
|
+
// TODO: 注释动态设置open逻辑 start
|
|
108
|
+
// const currentClick = useRef<boolean>(true);
|
|
109
|
+
// TODO: 注释动态设置open逻辑 end
|
|
107
110
|
// 下拉数据源
|
|
108
111
|
var _k = useFetchState([]), selectList = _k[0], setSelectList = _k[1];
|
|
109
112
|
// 手动添加的数据源
|
|
@@ -124,8 +127,10 @@ function EnhanceSelect(_a) {
|
|
|
124
127
|
var _t = useState(1), currentPage = _t[0], setCurrentPage = _t[1];
|
|
125
128
|
// 总条数
|
|
126
129
|
var _u = useState(0), count = _u[0], setCount = _u[1];
|
|
127
|
-
//
|
|
128
|
-
|
|
130
|
+
// TODO: 注释动态设置open逻辑 start
|
|
131
|
+
// // 手动清空数据
|
|
132
|
+
// const handleClearDataRef = useRef<boolean>(false);
|
|
133
|
+
// TODO: 注释动态设置open逻辑 end
|
|
129
134
|
// 是否自动请求
|
|
130
135
|
var isAutoRequest = useRef(false); // 请求过了
|
|
131
136
|
// 处理value
|
|
@@ -317,10 +322,12 @@ function EnhanceSelect(_a) {
|
|
|
317
322
|
// if (value) {
|
|
318
323
|
console.log(value);
|
|
319
324
|
// setIsOpen(true);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
325
|
+
// TODO: 注释动态设置open逻辑 start
|
|
326
|
+
// if (value || handleClearDataRef.current) {
|
|
327
|
+
// setIsOpen(true);
|
|
328
|
+
// }
|
|
329
|
+
// handleClearDataRef.current = false;
|
|
330
|
+
// TODO: 注释动态设置open逻辑 end
|
|
324
331
|
if (isHandAddItem) {
|
|
325
332
|
if (value) {
|
|
326
333
|
setHandleAddItems([
|
|
@@ -345,10 +352,12 @@ function EnhanceSelect(_a) {
|
|
|
345
352
|
var _a;
|
|
346
353
|
// console.log(value);
|
|
347
354
|
// setIsOpen(true);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
355
|
+
// TODO: 注释动态设置open逻辑 start
|
|
356
|
+
// if (value || handleClearDataRef.current) {
|
|
357
|
+
// setIsOpen(true);
|
|
358
|
+
// }
|
|
359
|
+
// handleClearDataRef.current = false;
|
|
360
|
+
// TODO: 注释动态设置open逻辑 end
|
|
352
361
|
if (isHandAddItem) {
|
|
353
362
|
if (value) {
|
|
354
363
|
setHandleAddItems([
|
|
@@ -431,6 +440,52 @@ function EnhanceSelect(_a) {
|
|
|
431
440
|
url,
|
|
432
441
|
remoteSearch,
|
|
433
442
|
]);
|
|
443
|
+
var sendRequestNoCatch = function () {
|
|
444
|
+
if (!url || remoteSearch) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (isCatch) {
|
|
448
|
+
if (enhanceSelectCatchObj) {
|
|
449
|
+
enhanceSelectCatchObj[url] = enhanceSelectCatchObj[url]
|
|
450
|
+
? enhanceSelectCatchObj[url]
|
|
451
|
+
: {};
|
|
452
|
+
var currentIndex = enhanceSelectCatchLruKeys.indexOf(url);
|
|
453
|
+
if (currentIndex !== -1) {
|
|
454
|
+
enhanceSelectCatchLruKeys.splice(currentIndex, 1);
|
|
455
|
+
enhanceSelectCatchLruKeys.push(url);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
enhanceSelectCatchLruKeys.push(url);
|
|
459
|
+
}
|
|
460
|
+
if (enhanceSelectCatchLruKeys.length > enhanceSelectCatchLruMaxSize) {
|
|
461
|
+
var oldKey = enhanceSelectCatchLruKeys.shift();
|
|
462
|
+
try {
|
|
463
|
+
delete enhanceSelectCatchLruKeys[oldKey];
|
|
464
|
+
}
|
|
465
|
+
catch (err) {
|
|
466
|
+
//
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
var catchData = enhanceSelectCatchObj[url];
|
|
470
|
+
var catchDataKey = params ? JSON.stringify(params) : 'single';
|
|
471
|
+
// 发送接口请求,并设置缓存数据
|
|
472
|
+
getDataHandle(request, { url: url, params: params, method: method, timeout: timeout }, {
|
|
473
|
+
appointObj: {
|
|
474
|
+
obj: catchData,
|
|
475
|
+
key: catchDataKey,
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
getDataHandle(request, {
|
|
482
|
+
url: url,
|
|
483
|
+
params: params,
|
|
484
|
+
method: method,
|
|
485
|
+
timeout: timeout,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
};
|
|
434
489
|
useEffect(function () {
|
|
435
490
|
if (!url || remoteSearch) {
|
|
436
491
|
return;
|
|
@@ -737,12 +792,13 @@ function EnhanceSelect(_a) {
|
|
|
737
792
|
};
|
|
738
793
|
// onChange 方法
|
|
739
794
|
var onChangeHandle = function (value, option) {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
else {
|
|
744
|
-
|
|
745
|
-
}
|
|
795
|
+
// TODO: 注释动态设置open逻辑 start
|
|
796
|
+
// if ((Array.isArray(value) && value.length === 0) || !value) {
|
|
797
|
+
// currentClick.current = true;
|
|
798
|
+
// } else {
|
|
799
|
+
// currentClick.current = false;
|
|
800
|
+
// }
|
|
801
|
+
// TODO: 注释动态设置open逻辑 end
|
|
746
802
|
setFirstLoading(true);
|
|
747
803
|
if (((Array.isArray(value) && value.length === 0) || !value) &&
|
|
748
804
|
remoteSearch &&
|
|
@@ -824,20 +880,26 @@ function EnhanceSelect(_a) {
|
|
|
824
880
|
var onFocusHandle = function (e) {
|
|
825
881
|
console.log('焦点事件');
|
|
826
882
|
setIsOpen(true);
|
|
827
|
-
|
|
883
|
+
// TODO: 注释动态设置open逻辑 start
|
|
884
|
+
// currentClick.current = false;
|
|
885
|
+
// TODO: 注释动态设置open逻辑 end
|
|
828
886
|
onFocus && onFocus(e);
|
|
829
887
|
};
|
|
830
888
|
var onBlurHandle = function (e) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
889
|
+
// TODO: 注释动态设置open逻辑 start
|
|
890
|
+
// console.log('失去焦点事件');
|
|
891
|
+
// setIsOpen(false);
|
|
892
|
+
// currentClick.current = false;
|
|
893
|
+
// TODO: 注释动态设置open逻辑 end
|
|
834
894
|
onBlur && onBlur(e);
|
|
835
895
|
};
|
|
836
896
|
// 清空数据时
|
|
837
897
|
var onClearHandle = function () {
|
|
838
898
|
// console.log('清空数据事件');
|
|
839
|
-
|
|
840
|
-
|
|
899
|
+
// TODO: 注释动态设置open逻辑 start
|
|
900
|
+
// handleClearDataRef.current = true;
|
|
901
|
+
// setIsOpen(false);
|
|
902
|
+
// TODO: 注释动态设置open逻辑 end
|
|
841
903
|
};
|
|
842
904
|
// 选中时
|
|
843
905
|
var onSelectHandle = function (value, obj) {
|
|
@@ -852,9 +914,11 @@ function EnhanceSelect(_a) {
|
|
|
852
914
|
document === null || document === void 0 ? void 0 : document.execCommand('copy');
|
|
853
915
|
document.body.removeChild(textarea);
|
|
854
916
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
917
|
+
// TODO: 注释动态设置open逻辑 start
|
|
918
|
+
// if (!restProps.mode) {
|
|
919
|
+
// setIsOpen(false);
|
|
920
|
+
// }
|
|
921
|
+
// TODO: 注释动态设置open逻辑 end
|
|
858
922
|
};
|
|
859
923
|
// 点击时
|
|
860
924
|
var onClickHandle = function (e) {
|
|
@@ -865,24 +929,24 @@ function EnhanceSelect(_a) {
|
|
|
865
929
|
sendRemoteRequest();
|
|
866
930
|
sendRemoteRequest1();
|
|
867
931
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
932
|
+
// TODO: 注释动态设置open逻辑 start
|
|
933
|
+
// if (currentClick.current) {
|
|
934
|
+
// console.log(e.nativeEvent.target.getAttribute('class'));
|
|
935
|
+
// let className = '';
|
|
936
|
+
// try {
|
|
937
|
+
// className = e.nativeEvent.target.getAttribute('class');
|
|
938
|
+
// } catch (err) {
|
|
939
|
+
// console.log(err);
|
|
940
|
+
// }
|
|
941
|
+
// const bool = className.indexOf('rc-virtual-list') === -1;
|
|
942
|
+
// if (isOpen && bool) {
|
|
943
|
+
// setIsOpen(false);
|
|
944
|
+
// } else {
|
|
945
|
+
// setIsOpen(true);
|
|
946
|
+
// }
|
|
947
|
+
// }
|
|
948
|
+
// currentClick.current = true;
|
|
949
|
+
// TODO: 注释动态设置open逻辑 end
|
|
886
950
|
};
|
|
887
951
|
// 滚动加载
|
|
888
952
|
var onPopupScrollHandle = function (e) {
|
|
@@ -899,7 +963,24 @@ function EnhanceSelect(_a) {
|
|
|
899
963
|
};
|
|
900
964
|
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,
|
|
901
965
|
// getPopupContainer={(trigger) => trigger || document.body}
|
|
902
|
-
open: isOpen,
|
|
966
|
+
open: isOpen, onDropdownVisibleChange: function (visible) { return setIsOpen(visible); }, onPopupScroll: onPopupScrollHandle, dropdownRender: url && !remoteSearch && isCatch
|
|
967
|
+
? function (menu) { return (React.createElement(React.Fragment, null,
|
|
968
|
+
menu,
|
|
969
|
+
React.createElement(Divider, { style: { marginTop: 0, marginBottom: '4px' } }),
|
|
970
|
+
React.createElement("div", { style: {
|
|
971
|
+
display: 'flex',
|
|
972
|
+
alignItems: 'center',
|
|
973
|
+
flexDirection: 'row',
|
|
974
|
+
justifyContent: 'space-between',
|
|
975
|
+
padding: '0 6px',
|
|
976
|
+
} },
|
|
977
|
+
React.createElement("span", null),
|
|
978
|
+
React.createElement(Button, { onClick: function (e) {
|
|
979
|
+
console.log(e);
|
|
980
|
+
e.preventDefault();
|
|
981
|
+
sendRequestNoCatch();
|
|
982
|
+
} }, "\u5237\u65B0\u6570\u636E")))); }
|
|
983
|
+
: undefined }, restProps, { value: newValue,
|
|
903
984
|
// 这里需要注释掉,因为修改了一部分逻辑
|
|
904
985
|
disabled: remoteSearch || isClickRequest
|
|
905
986
|
? restProps.disabled
|
|
@@ -67,6 +67,7 @@ import { printCurrentDom, htmlToPdfNoCanvas, htmlToPdf, addWaterHandle, removeWa
|
|
|
67
67
|
import { createDownloadUrlNoBase, createDownloadUrl, } from 'ztxkutils/dist/fileOperation';
|
|
68
68
|
import { dataURLtoFile, setPositionLocal, getPositionLocal, setPositionDom, setPositionDeviation, } from './handle';
|
|
69
69
|
import { createTask } from './lodop';
|
|
70
|
+
import { useNeedLodop } from './utils';
|
|
70
71
|
var fontTTF = {
|
|
71
72
|
data: '',
|
|
72
73
|
};
|
|
@@ -114,6 +115,7 @@ var PrintContainer = function (_a) {
|
|
|
114
115
|
top: 0,
|
|
115
116
|
left: 0,
|
|
116
117
|
}), value = _w[0], setValue = _w[1];
|
|
118
|
+
useNeedLodop();
|
|
117
119
|
useEffect(function () {
|
|
118
120
|
var v = getPositionLocal(localKey);
|
|
119
121
|
setValue(v);
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author 陈亚雄
|
|
3
|
+
* @description 判断是否需要CLodop(那些不支持插件的浏览器,需要CLodop服务)
|
|
4
|
+
*/
|
|
5
|
+
export function needCLodop(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* @author 陈亚雄
|
|
8
|
+
* @description 加载CLodop时用双端口(http是 8000/18000, 而https是8443/8444)以防其中某端口被占
|
|
9
|
+
* 主JS文件名“CLodopfuncs.js”是固定名称,其内容是动态的,与其链接的打印环境有关
|
|
10
|
+
*/
|
|
11
|
+
export function loadCLodop(): void;
|
|
12
|
+
export function useNeedLodop(): void;
|
|
1
13
|
/**
|
|
2
14
|
* @author 陈亚雄
|
|
3
15
|
* @description 获取Lodop对象主过程,判断是否安装、需否升级
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
2
|
/* eslint-disable no-var */
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { Modal } from '../../index';
|
|
4
5
|
/**
|
|
5
6
|
* @author 陈亚雄
|
|
@@ -28,7 +29,7 @@ var CreatedOKLodopObject, CLodopIsLocal, CLodopJsState;
|
|
|
28
29
|
* @author 陈亚雄
|
|
29
30
|
* @description 判断是否需要CLodop(那些不支持插件的浏览器,需要CLodop服务)
|
|
30
31
|
*/
|
|
31
|
-
function needCLodop() {
|
|
32
|
+
export function needCLodop() {
|
|
32
33
|
try {
|
|
33
34
|
var ua = navigator.userAgent;
|
|
34
35
|
if (ua.match(/Windows\sPhone/i))
|
|
@@ -75,7 +76,7 @@ function needCLodop() {
|
|
|
75
76
|
* @description 加载CLodop时用双端口(http是 8000/18000, 而https是8443/8444)以防其中某端口被占
|
|
76
77
|
* 主JS文件名“CLodopfuncs.js”是固定名称,其内容是动态的,与其链接的打印环境有关
|
|
77
78
|
*/
|
|
78
|
-
function loadCLodop() {
|
|
79
|
+
export function loadCLodop() {
|
|
79
80
|
if (CLodopJsState === 'loading' || CLodopJsState === 'complete')
|
|
80
81
|
return;
|
|
81
82
|
CLodopJsState = 'loading';
|
|
@@ -102,14 +103,18 @@ function loadCLodop() {
|
|
|
102
103
|
head.insertBefore(JS2, head.firstChild);
|
|
103
104
|
CLodopIsLocal = !!(JS1.src + JS2.src).match(/\/\/localho|\/\/127.0.0./i);
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
export function useNeedLodop() {
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
if (needCLodop()) {
|
|
109
|
+
console.log("=============\u9700\u8981CLodop=============");
|
|
110
|
+
try {
|
|
111
|
+
loadCLodop();
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
console.log(err);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
113
118
|
}
|
|
114
119
|
/**
|
|
115
120
|
* @author 陈亚雄
|
|
@@ -26,6 +26,7 @@ interface IProps<RecordType> {
|
|
|
26
26
|
onEditableSave?: (record: RecordType, index: number | undefined, dataIndex: string) => void;
|
|
27
27
|
/** 表格列配置相关信息 */
|
|
28
28
|
configInfo?: IConfigInfo;
|
|
29
|
+
copyByKey?: any;
|
|
29
30
|
}
|
|
30
31
|
export declare const getTableLayoutFullData: (columns: any, tableLayout: any) => any;
|
|
31
32
|
export declare const LOCALSTORAGE_KEY = "ztui_dynamic_table_key";
|
|
@@ -15,6 +15,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
18
|
+
import Button from '../../Button';
|
|
18
19
|
import { PicRightOutlined } from '@ant-design/icons';
|
|
19
20
|
import TableAddDelColumn from '../table-adddel-column';
|
|
20
21
|
// 获取表格columns完整数据
|
|
@@ -151,7 +152,7 @@ export function setDynamicKey(dynamicStorageKey, value) {
|
|
|
151
152
|
localStorage.setItem(LOCALSTORAGE_LRU_KEY, JSON.stringify(lruKeys));
|
|
152
153
|
}
|
|
153
154
|
function useColumns(props) {
|
|
154
|
-
var columns = props.columns, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, delIconText = props.delIconText, showDynamicHandle = props.showDynamicHandle, onEditableSave = props.onEditableSave, configInfo = props.configInfo;
|
|
155
|
+
var columns = props.columns, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, delIconText = props.delIconText, showDynamicHandle = props.showDynamicHandle, onEditableSave = props.onEditableSave, configInfo = props.configInfo, copyByKey = props.copyByKey;
|
|
155
156
|
var tableLayout = getStorage(showColumnDynamicKey);
|
|
156
157
|
// 新的columns
|
|
157
158
|
var _a = useState(getTableLayoutFullData(columns, tableLayout)), newColumns = _a[0], setNewColumns = _a[1];
|
|
@@ -227,6 +228,21 @@ function useColumns(props) {
|
|
|
227
228
|
_column.ellipsis = false;
|
|
228
229
|
}
|
|
229
230
|
}
|
|
231
|
+
// 如果列需要添加复制按钮
|
|
232
|
+
if (_column.showCopy) {
|
|
233
|
+
if (_column.validate) {
|
|
234
|
+
_column.validate.title = _column.validate.title
|
|
235
|
+
? _column.validate.title
|
|
236
|
+
: _column.title;
|
|
237
|
+
}
|
|
238
|
+
_column.title = (React.createElement(React.Fragment, null,
|
|
239
|
+
_column.title,
|
|
240
|
+
React.createElement(Button, { type: "link", onClick: function () {
|
|
241
|
+
copyByKey(typeof _column.showCopy === 'string'
|
|
242
|
+
? _column.showCopy
|
|
243
|
+
: _column.key || _column.dataIndex);
|
|
244
|
+
}, style: { fontSize: '13px', marginLeft: '2px', display: 'block' } }, "\u590D\u5236\u6574\u5217")));
|
|
245
|
+
}
|
|
230
246
|
// 如果配置了固定列的 不做处理
|
|
231
247
|
if (!col.fixed) {
|
|
232
248
|
_dynamicColumns.push(__assign({}, col));
|
|
@@ -297,6 +313,7 @@ function useColumns(props) {
|
|
|
297
313
|
}
|
|
298
314
|
setNewColumns(_newColumns);
|
|
299
315
|
setDynamicColumns(_dynamicColumns);
|
|
316
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
300
317
|
}, [
|
|
301
318
|
columns,
|
|
302
319
|
showColumnDynamic,
|
|
@@ -34,6 +34,8 @@ export interface IColumnType<RecordType> extends ColumnType<RecordType> {
|
|
|
34
34
|
editableConfig?: IEditableConfig;
|
|
35
35
|
/** 表格单元格验证逻辑 */
|
|
36
36
|
validate?: IValidate;
|
|
37
|
+
/** 是否添加复制当前列功能 */
|
|
38
|
+
showCopy?: boolean;
|
|
37
39
|
}
|
|
38
40
|
export interface IColumnGroupType<RecordType> extends Omit<IColumnType<RecordType>, ''> {
|
|
39
41
|
children: ColumnsType<RecordType>;
|
|
@@ -63,6 +63,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
63
63
|
};
|
|
64
64
|
import React, { useCallback, memo, useState, useEffect, useRef, useMemo, useImperativeHandle, } from 'react';
|
|
65
65
|
import { Table as AntTable } from 'antd';
|
|
66
|
+
import { message } from '../../index';
|
|
66
67
|
import { ERROR_TD_CLASSNAME } from './';
|
|
67
68
|
import TableDynamic from './table-dynamic';
|
|
68
69
|
// import TableSummary from './table-summary';
|
|
@@ -110,6 +111,7 @@ function Table(props) {
|
|
|
110
111
|
var _e = useState(columns), _columns = _e[0], setColumns = _e[1];
|
|
111
112
|
var showDynamicHandle = useCallback(function () { return setDynamicVisible(true); }, []);
|
|
112
113
|
var hideDynamicHandle = useCallback(function () { return setDynamicVisible(false); }, []);
|
|
114
|
+
var dataSourceRef = useRef();
|
|
113
115
|
var myScroll = useMemo(function () {
|
|
114
116
|
if (scroll) {
|
|
115
117
|
return isFlex ? __assign(__assign({}, scroll), { y: scroll.y || 100 }) : scroll;
|
|
@@ -120,6 +122,36 @@ function Table(props) {
|
|
|
120
122
|
useEffect(function () {
|
|
121
123
|
setColumns(columns);
|
|
122
124
|
}, [columns]);
|
|
125
|
+
useEffect(function () {
|
|
126
|
+
dataSourceRef.current = dataSource;
|
|
127
|
+
}, [dataSource]);
|
|
128
|
+
var copyByKey = useCallback(function (key) {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
if (Array.isArray(dataSourceRef.current)) {
|
|
131
|
+
var result = dataSourceRef.current.map(function (item) { return item[key]; });
|
|
132
|
+
var str = result.join('\n');
|
|
133
|
+
try {
|
|
134
|
+
if ((navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) && window.isSecureContext) {
|
|
135
|
+
(_b = (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(str)) === null || _b === void 0 ? void 0 : _b.then(function () {
|
|
136
|
+
message.info('复制成功!');
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
var input = document.createElement('input');
|
|
141
|
+
document.body.appendChild(input);
|
|
142
|
+
input.setAttribute('value', str);
|
|
143
|
+
input.select();
|
|
144
|
+
if (document.execCommand) {
|
|
145
|
+
document.execCommand('copy');
|
|
146
|
+
}
|
|
147
|
+
document.body.removeChild(input);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
message.info("\u590D\u5236\u5931\u8D25\uFF01\u8BF7\u624B\u5DE5\u590D\u5236\n " + str);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}, []);
|
|
123
155
|
/**
|
|
124
156
|
* @description 根据配置生成一个新的columns
|
|
125
157
|
* 以及一个需要动态列配置的columns
|
|
@@ -136,6 +168,7 @@ function Table(props) {
|
|
|
136
168
|
showDynamicHandle: showDynamicHandle,
|
|
137
169
|
onEditableSave: onEditableSave,
|
|
138
170
|
configInfo: configInfo,
|
|
171
|
+
copyByKey: copyByKey,
|
|
139
172
|
}), newColumns = _f.newColumns, dynamicColumns = _f.dynamicColumns, setNewColumns = _f.setNewColumns;
|
|
140
173
|
/**
|
|
141
174
|
* @description 保存列配置
|