ztxkui 3.8.8 → 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/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,
|
|
@@ -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 保存列配置
|