ztxkui 3.9.0 → 3.9.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/DemoCom/PrintContainerDemo.js +2 -2
- package/dist/DemoCom/TableDemo.js +16 -4
- package/dist/DemoCom/TestCom.d.ts +1 -0
- package/dist/DemoCom/TestCom.js +12 -3
- package/dist/components/EnhanceSelect/index.d.ts +3 -1
- package/dist/components/EnhanceSelect/index.js +9 -3
- package/dist/components/PrintContainer/PrintModal.js +28 -6
- package/dist/components/PrintContainer/handle.d.ts +4 -0
- package/dist/components/PrintContainer/handle.js +95 -3
- package/dist/components/PrintContainer/print-container.js +2 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ var PrintContainerDemo = function () {
|
|
|
101
101
|
// keywordList={keywordList}
|
|
102
102
|
imgWaterBg: water, isSetPosition: false, showPrintMessage: true, showAddSeal: true, apiUrl: "http://192.168.0.83:8000", fileBaseUrl: "http://192.168.0.83:88" },
|
|
103
103
|
React.createElement("div", { className: "html2canvas-container-page simple-print", "data-title": "\u6D4B\u8BD5\u6807\u98981" },
|
|
104
|
-
React.createElement("div", { className: "print-header" },
|
|
104
|
+
React.createElement("div", { className: "print-header set-box" },
|
|
105
105
|
React.createElement("img", { src: base64Img, alt: "" }),
|
|
106
106
|
React.createElement("h3", { className: "print-title" }, "\u63D0\u8D27\u53551"),
|
|
107
107
|
React.createElement("div", { className: "right-info" },
|
|
@@ -223,7 +223,7 @@ var PrintContainerDemo = function () {
|
|
|
223
223
|
React.createElement("span", null, "\u6253\u5370\u4EBA\uFF1A"),
|
|
224
224
|
React.createElement("span", null, "chenyx"))))))),
|
|
225
225
|
React.createElement("div", { className: "html2canvas-container-page simple-print" },
|
|
226
|
-
React.createElement("div", { className: "print-header" },
|
|
226
|
+
React.createElement("div", { className: "print-header set-box" },
|
|
227
227
|
React.createElement("img", { src: base64Img, alt: "" }),
|
|
228
228
|
React.createElement("h3", { className: "print-title" }, "\u63D0\u8D27\u53552"),
|
|
229
229
|
React.createElement("div", { className: "right-info" },
|
|
@@ -56,7 +56,7 @@ import EnhanceSelect from 'components/EnhanceSelect';
|
|
|
56
56
|
import { OperationBtnGroup, Empty, Button, message, Container } from '../index';
|
|
57
57
|
import MaterialComp, {
|
|
58
58
|
// clearData,
|
|
59
|
-
clearDataFn,
|
|
59
|
+
clearDataFn, clearAllCatchData,
|
|
60
60
|
// transformDataFn,
|
|
61
61
|
} from './TestCom';
|
|
62
62
|
import { DatePicker } from 'index';
|
|
@@ -66,7 +66,7 @@ import FormDemo from './FormDemo';
|
|
|
66
66
|
// 获取表格数据
|
|
67
67
|
function useGetTableRecords() {
|
|
68
68
|
// 表格数据
|
|
69
|
-
var _a = useState(Array.from({ length:
|
|
69
|
+
var _a = useState(Array.from({ length: 10 }).map(function (item, index) {
|
|
70
70
|
var newItem = {
|
|
71
71
|
id: "" + (index + 1),
|
|
72
72
|
test1: index + 1 + "-test1",
|
|
@@ -488,6 +488,9 @@ var TableDemo = function () {
|
|
|
488
488
|
materialId: { isChangeable: 1, isDisplay: 1, isRequired: 1 },
|
|
489
489
|
test1: { isChangeable: 1, isDisplay: 1, isRequired: 1 },
|
|
490
490
|
}), tableConfig = _g[0], setTableConfig = _g[1];
|
|
491
|
+
// 刷新选择框
|
|
492
|
+
var _h = useState(false), refreshSel = _h[0], setRefreshSel = _h[1];
|
|
493
|
+
var refreshId = useRef(1);
|
|
491
494
|
useEffect(function () {
|
|
492
495
|
setTimeout(function () {
|
|
493
496
|
setTableConfig({
|
|
@@ -553,11 +556,15 @@ var TableDemo = function () {
|
|
|
553
556
|
setMoveChange(false);
|
|
554
557
|
return true;
|
|
555
558
|
}
|
|
559
|
+
if (refreshSel) {
|
|
560
|
+
setRefreshSel(false);
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
556
563
|
return (record.key1 !== preRecord.key1 ||
|
|
557
564
|
record.materialId !== preRecord.materialId);
|
|
558
565
|
},
|
|
559
566
|
render: function (text, record, index) {
|
|
560
|
-
return (React.createElement(MaterialComp, { value: record, materialId: record.materialId, prefix: "prefix", onChange: function (value) {
|
|
567
|
+
return (React.createElement(MaterialComp, { key: index + refreshId.current, value: record, materialId: record.materialId, prefix: "prefix", onChange: function (value) {
|
|
561
568
|
console.log(value);
|
|
562
569
|
var newRecord = __assign({}, value);
|
|
563
570
|
onEditableSaveHandle(newRecord, index);
|
|
@@ -907,7 +914,12 @@ var TableDemo = function () {
|
|
|
907
914
|
});
|
|
908
915
|
});
|
|
909
916
|
})();
|
|
910
|
-
} }, "\u70B9\u51FB")
|
|
917
|
+
} }, "\u70B9\u51FB"),
|
|
918
|
+
React.createElement(Button, { onClick: function () {
|
|
919
|
+
clearAllCatchData();
|
|
920
|
+
setRefreshSel(true);
|
|
921
|
+
refreshId.current = refreshId.current + 1;
|
|
922
|
+
} }, "\u6E32\u67D3")),
|
|
911
923
|
React.createElement(Table
|
|
912
924
|
// 如果需要保留本地偏好,那么这里需要预处理一下columns数据
|
|
913
925
|
// columns={getTableLayoutFullData(columns, tableLayout)}
|
package/dist/DemoCom/TestCom.js
CHANGED
|
@@ -51,10 +51,11 @@ import SearchContainer from '../components/business/SearchContainer';
|
|
|
51
51
|
import Input from '../components/Input';
|
|
52
52
|
import Modal from '../components/Modal';
|
|
53
53
|
import { message, Row, Col } from 'index';
|
|
54
|
-
import EnhanceSelect from 'components/EnhanceSelect';
|
|
54
|
+
import EnhanceSelect, { clearCatchData } from 'components/EnhanceSelect';
|
|
55
55
|
import './style.scss';
|
|
56
56
|
import Button from 'components/Button';
|
|
57
57
|
import { stringify } from 'qs';
|
|
58
|
+
import { token } from '../constants';
|
|
58
59
|
var SearchItem = SearchContainer.SearchItem, SearchLeft = SearchContainer.SearchLeft;
|
|
59
60
|
/**
|
|
60
61
|
* @description 获取当前物料对应的配置信息
|
|
@@ -62,7 +63,7 @@ var SearchItem = SearchContainer.SearchItem, SearchLeft = SearchContainer.Search
|
|
|
62
63
|
function getAttributeList(params) {
|
|
63
64
|
return fetch("http://192.168.0.83:8000/api/zmdms-mdm-data/newmaterialproductlevel/get-attribute-list?" + stringify(params), {
|
|
64
65
|
headers: {
|
|
65
|
-
'Zmdms-Auth':
|
|
66
|
+
'Zmdms-Auth': "bearer " + token,
|
|
66
67
|
},
|
|
67
68
|
method: 'get',
|
|
68
69
|
}).then(function (response) { return response.json(); });
|
|
@@ -70,7 +71,7 @@ function getAttributeList(params) {
|
|
|
70
71
|
function request(options) {
|
|
71
72
|
return fetch("http://192.168.0.83:8000" + options.url + "?" + stringify(options.params), {
|
|
72
73
|
headers: {
|
|
73
|
-
'Zmdms-Auth':
|
|
74
|
+
'Zmdms-Auth': "bearer " + token,
|
|
74
75
|
},
|
|
75
76
|
method: options.method,
|
|
76
77
|
}).then(function (response) {
|
|
@@ -176,6 +177,14 @@ var listDataAbout = {
|
|
|
176
177
|
url: "/api/zmdms-mdm-data/material-meta-info/packingMethod-list",
|
|
177
178
|
},
|
|
178
179
|
};
|
|
180
|
+
export function clearAllCatchData() {
|
|
181
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/brand-list');
|
|
182
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/texture-list');
|
|
183
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/specification-list');
|
|
184
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/placesteel-list');
|
|
185
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/workmanship-list');
|
|
186
|
+
clearCatchData('/api/zmdms-mdm-data/material-meta-info/packingMethod-list');
|
|
187
|
+
}
|
|
179
188
|
var MaterialComp = function (_a) {
|
|
180
189
|
var value = _a.value, onChange = _a.onChange, _b = _a.controleType, controleType = _b === void 0 ? 'hide' : _b, materialRef = _a.materialRef, materialId = _a.materialId, onlyDetail = _a.onlyDetail, prefix = _a.prefix, postfix = _a.postfix;
|
|
181
190
|
var form = Form.useForm()[0];
|
|
@@ -131,7 +131,9 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
|
|
|
131
131
|
* 是否点击时才请求
|
|
132
132
|
*/
|
|
133
133
|
isClickRequest?: boolean;
|
|
134
|
+
handleRef?: any;
|
|
134
135
|
}
|
|
136
|
+
export declare function clearCatchData(url: string): void;
|
|
135
137
|
/**
|
|
136
138
|
* 增强下拉框功能组件
|
|
137
139
|
* 添加远程搜索
|
|
@@ -147,6 +149,6 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
|
|
|
147
149
|
* { code: 200, data: { records: [] } } || { status: 200, data: { code: 200, data: { records: [] } } }
|
|
148
150
|
* 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
|
|
149
151
|
*/
|
|
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;
|
|
152
|
+
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, handleRef, ...restProps }: IProps<VT>): JSX.Element;
|
|
151
153
|
declare const _default: React.MemoExoticComponent<typeof EnhanceSelect>;
|
|
152
154
|
export default _default;
|
|
@@ -29,7 +29,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
29
29
|
* @author cyx
|
|
30
30
|
* @description 增强下拉框功能
|
|
31
31
|
*/
|
|
32
|
-
import React, { useCallback, useEffect, memo, useRef, useState, useMemo, } from 'react';
|
|
32
|
+
import React, { useCallback, useEffect, memo, useRef, useState, useMemo, useImperativeHandle, } from 'react';
|
|
33
33
|
import { Divider, Select } from 'antd';
|
|
34
34
|
import Button from '../Button';
|
|
35
35
|
import { useFetchState } from 'ztxkutils/dist/hooks';
|
|
@@ -46,6 +46,9 @@ import { dangerouslySetXss } from 'ztxkutils/dist/tools';
|
|
|
46
46
|
var enhanceSelectCatchObj = {};
|
|
47
47
|
var enhanceSelectCatchLruKeys = [];
|
|
48
48
|
var enhanceSelectCatchLruMaxSize = 800;
|
|
49
|
+
export function clearCatchData(url) {
|
|
50
|
+
enhanceSelectCatchObj[url] = {};
|
|
51
|
+
}
|
|
49
52
|
// 获取接口数据
|
|
50
53
|
function getData(request, options) {
|
|
51
54
|
var _a;
|
|
@@ -123,7 +126,7 @@ function clearNullData(arr, dataKey, titleKey) {
|
|
|
123
126
|
* 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
|
|
124
127
|
*/
|
|
125
128
|
function EnhanceSelect(_a) {
|
|
126
|
-
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"]);
|
|
129
|
+
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, handleRef = _a.handleRef, 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", "handleRef"]);
|
|
127
130
|
// TODO: 注释动态设置open逻辑 start
|
|
128
131
|
// const currentClick = useRef<boolean>(true);
|
|
129
132
|
// TODO: 注释动态设置open逻辑 end
|
|
@@ -983,6 +986,10 @@ function EnhanceSelect(_a) {
|
|
|
983
986
|
}
|
|
984
987
|
}
|
|
985
988
|
};
|
|
989
|
+
// 暴露一些方法给外部使用
|
|
990
|
+
useImperativeHandle(handleRef, function () { return ({
|
|
991
|
+
sendRequestNoCatch: sendRequestNoCatch,
|
|
992
|
+
}); });
|
|
986
993
|
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,
|
|
987
994
|
// getPopupContainer={(trigger) => trigger || document.body}
|
|
988
995
|
open: isOpen, onDropdownVisibleChange: function (visible) { return setIsOpen(visible); }, onPopupScroll: onPopupScrollHandle, dropdownRender: url && !remoteSearch && isCatch
|
|
@@ -998,7 +1005,6 @@ function EnhanceSelect(_a) {
|
|
|
998
1005
|
} },
|
|
999
1006
|
React.createElement("span", null),
|
|
1000
1007
|
React.createElement(Button, { onClick: function (e) {
|
|
1001
|
-
console.log(e);
|
|
1002
1008
|
e.preventDefault();
|
|
1003
1009
|
sendRequestNoCatch();
|
|
1004
1010
|
} }, "\u5237\u65B0\u6570\u636E")))); }
|
|
@@ -13,13 +13,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
* @author 陈亚雄
|
|
14
14
|
* @description 内容边距调整
|
|
15
15
|
*/
|
|
16
|
-
import React, { useState, useEffect } from 'react';
|
|
16
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
17
17
|
// redux
|
|
18
18
|
// ztxkui公共组件
|
|
19
19
|
import { Modal, Slider } from '../../index';
|
|
20
|
+
// 路由配置
|
|
21
|
+
// store
|
|
22
|
+
// 自定义组件
|
|
23
|
+
// 其他文件
|
|
24
|
+
import { setMinusPosition, reductionMinusPostion } from './handle';
|
|
20
25
|
var PrintModal = function (_a) {
|
|
21
26
|
var loading = _a.loading, onChange = _a.onChange, visible = _a.visible, onCancel = _a.onCancel, value = _a.value, setValue = _a.setValue;
|
|
22
27
|
var _b = useState({ __html: '' }), vhtml = _b[0], setVhtml = _b[1];
|
|
28
|
+
var divDomRef = useRef(null);
|
|
23
29
|
// const [topPadding, setTopPadding] = useState(0);
|
|
24
30
|
// const [leftPadding, setLeftPadding] = useState(0);
|
|
25
31
|
useEffect(function () {
|
|
@@ -40,17 +46,33 @@ var PrintModal = function (_a) {
|
|
|
40
46
|
return (React.createElement(Modal, { title: "\u8FB9\u8DDD\u8C03\u6574", visible: visible, loading: false, width: "90%", onCancel: onCancel, onOk: onSure },
|
|
41
47
|
React.createElement("div", null,
|
|
42
48
|
"\u4E0A\u8FB9\u8DDD\uFF1A",
|
|
43
|
-
React.createElement(Slider, { min:
|
|
49
|
+
React.createElement(Slider, { min: -180, max: 200, step: 0.01, value: (value === null || value === void 0 ? void 0 : value.top) || 0, onChange: function (value) {
|
|
50
|
+
if (value < 0) {
|
|
51
|
+
setMinusPosition(divDomRef.current, {
|
|
52
|
+
top: value,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
reductionMinusPostion(divDomRef.current, 'top');
|
|
57
|
+
}
|
|
44
58
|
setValue(function (preValue) { return (__assign(__assign({}, (preValue || {})), { top: value })); });
|
|
45
59
|
} })),
|
|
46
60
|
React.createElement("div", null,
|
|
47
61
|
"\u5DE6\u8FB9\u8DDD\uFF1A",
|
|
48
|
-
React.createElement(Slider, { min:
|
|
62
|
+
React.createElement(Slider, { min: -180, max: 200, step: 0.01, value: (value === null || value === void 0 ? void 0 : value.left) || 0, onChange: function (value) {
|
|
63
|
+
if (value < 0) {
|
|
64
|
+
setMinusPosition(divDomRef.current, {
|
|
65
|
+
left: value,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
reductionMinusPostion(divDomRef.current, 'left');
|
|
70
|
+
}
|
|
49
71
|
setValue(function (preValue) { return (__assign(__assign({}, (preValue || {})), { left: value })); });
|
|
50
72
|
} })),
|
|
51
|
-
React.createElement("div", { className: "print-modal--container", style: {
|
|
52
|
-
paddingTop: ((value === null || value === void 0 ? void 0 : value.top) || 0) + "px",
|
|
53
|
-
paddingLeft: ((value === null || value === void 0 ? void 0 : value.left) || 0) + "px",
|
|
73
|
+
React.createElement("div", { className: "print-modal--container", ref: divDomRef, style: {
|
|
74
|
+
paddingTop: ((value === null || value === void 0 ? void 0 : value.top) < 0 ? 0 : (value === null || value === void 0 ? void 0 : value.top) || 0) + "px",
|
|
75
|
+
paddingLeft: ((value === null || value === void 0 ? void 0 : value.left) < 0 ? 0 : (value === null || value === void 0 ? void 0 : value.left) || 0) + "px",
|
|
54
76
|
}, dangerouslySetInnerHTML: vhtml })));
|
|
55
77
|
};
|
|
56
78
|
export default PrintModal;
|
|
@@ -52,3 +52,7 @@ export declare function setPositionDeviation(value: any): {
|
|
|
52
52
|
top: number;
|
|
53
53
|
left: number;
|
|
54
54
|
};
|
|
55
|
+
export declare function setMinusPosition(dom: any, style: any): void;
|
|
56
|
+
export declare function initMinusPosition(dom: any): void;
|
|
57
|
+
export declare function reductionMinusPostion(dom: any, type?: any): void;
|
|
58
|
+
export declare function useInitSetPostion(): void;
|
|
@@ -39,6 +39,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
39
39
|
* @description 一些工具方法
|
|
40
40
|
*/
|
|
41
41
|
import jsPDF from 'jspdf';
|
|
42
|
+
import { useEffect } from 'react';
|
|
42
43
|
import { plus } from 'ztxkutils/dist/tools';
|
|
43
44
|
/**
|
|
44
45
|
* 图片转base64
|
|
@@ -282,10 +283,27 @@ export function getPositionLocal(localKey) {
|
|
|
282
283
|
* @description 设置标签位置
|
|
283
284
|
*/
|
|
284
285
|
export function setPositionDom(value) {
|
|
286
|
+
var _a;
|
|
285
287
|
var printDom = document.querySelectorAll('.html2canvas-container-page');
|
|
286
288
|
for (var i = 0; i < printDom.length; i++) {
|
|
287
289
|
var item = printDom[i];
|
|
288
|
-
item.setAttribute('style', "padding-top: " + ((value === null || value === void 0 ? void 0 : value.top) || 0) + "px; padding-left: " + ((value === null || value === void 0 ? void 0 : value.left) || 0) + "px");
|
|
290
|
+
item.setAttribute('style', "padding-top: " + ((value === null || value === void 0 ? void 0 : value.top) < 0 ? 0 : (value === null || value === void 0 ? void 0 : value.top) || 0) + "px; padding-left: " + ((value === null || value === void 0 ? void 0 : value.left) < 0 ? 0 : (value === null || value === void 0 ? void 0 : value.left) || 0) + "px");
|
|
291
|
+
var childResultStyle = {};
|
|
292
|
+
var childrenDom = item.querySelectorAll('.set-box');
|
|
293
|
+
if ((value === null || value === void 0 ? void 0 : value.top) < 0) {
|
|
294
|
+
var initTop = (_a = childrenDom[0]) === null || _a === void 0 ? void 0 : _a.dataset.top;
|
|
295
|
+
console.log(initTop);
|
|
296
|
+
childResultStyle.top = value === null || value === void 0 ? void 0 : value.top;
|
|
297
|
+
}
|
|
298
|
+
if ((value === null || value === void 0 ? void 0 : value.left) < 0) {
|
|
299
|
+
childResultStyle.left = value === null || value === void 0 ? void 0 : value.left;
|
|
300
|
+
}
|
|
301
|
+
if (childResultStyle.top || childResultStyle.left) {
|
|
302
|
+
setMinusPosition(item, childResultStyle);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
reductionMinusPostion(item);
|
|
306
|
+
}
|
|
289
307
|
}
|
|
290
308
|
}
|
|
291
309
|
/**
|
|
@@ -294,7 +312,81 @@ export function setPositionDom(value) {
|
|
|
294
312
|
*/
|
|
295
313
|
export function setPositionDeviation(value) {
|
|
296
314
|
return {
|
|
297
|
-
top: plus((value === null || value === void 0 ? void 0 : value.top) || 0, 25.03),
|
|
298
|
-
left: plus((value === null || value === void 0 ? void 0 : value.left) || 0, 39.39),
|
|
315
|
+
top: (value === null || value === void 0 ? void 0 : value.top) < 0 ? 0 : plus((value === null || value === void 0 ? void 0 : value.top) || 0, 25.03),
|
|
316
|
+
left: (value === null || value === void 0 ? void 0 : value.left) < 0 ? 0 : plus((value === null || value === void 0 ? void 0 : value.left) || 0, 39.39),
|
|
299
317
|
};
|
|
300
318
|
}
|
|
319
|
+
export function setMinusPosition(dom, style) {
|
|
320
|
+
var _a, _b;
|
|
321
|
+
try {
|
|
322
|
+
var childrenDom = dom.querySelectorAll('.set-box');
|
|
323
|
+
if (childrenDom) {
|
|
324
|
+
var top_1 = childrenDom[0].dataset.top
|
|
325
|
+
? parseInt(childrenDom[0].dataset.top)
|
|
326
|
+
: 0;
|
|
327
|
+
var left = childrenDom[0].dataset.left
|
|
328
|
+
? parseInt(childrenDom[0].dataset.left)
|
|
329
|
+
: 0;
|
|
330
|
+
var resultTop = top_1;
|
|
331
|
+
var resultLeft = left;
|
|
332
|
+
if (style.top) {
|
|
333
|
+
resultTop += style.top;
|
|
334
|
+
}
|
|
335
|
+
if (style.left) {
|
|
336
|
+
resultLeft += style.left;
|
|
337
|
+
}
|
|
338
|
+
(_b = (_a = childrenDom[0]) === null || _a === void 0 ? void 0 : _a.setAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, 'style', "top: " + resultTop + "px; left: " + resultLeft + "px");
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
console.log(err);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
export function initMinusPosition(dom) {
|
|
346
|
+
try {
|
|
347
|
+
var childrenDom = dom.querySelectorAll('.set-box');
|
|
348
|
+
if (childrenDom && childrenDom[0]) {
|
|
349
|
+
var style = getComputedStyle(childrenDom[0]) || {};
|
|
350
|
+
if (!childrenDom[0].dataset.top) {
|
|
351
|
+
var initTop = style.top || 0;
|
|
352
|
+
childrenDom[0].dataset.top = initTop;
|
|
353
|
+
}
|
|
354
|
+
if (!childrenDom[0].dataset.left) {
|
|
355
|
+
var initLeft = style.left || 0;
|
|
356
|
+
childrenDom[0].dataset.left = initLeft;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch (err) {
|
|
361
|
+
console.log(err);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
export function reductionMinusPostion(dom, type) {
|
|
365
|
+
var _a, _b, _c, _d, _e, _f;
|
|
366
|
+
try {
|
|
367
|
+
var childrenDom = dom.querySelectorAll('.set-box');
|
|
368
|
+
if (childrenDom) {
|
|
369
|
+
if (type === 'top') {
|
|
370
|
+
(_b = (_a = childrenDom[0]) === null || _a === void 0 ? void 0 : _a.setAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, 'style', "top: " + childrenDom[0].dataset.top + "; ");
|
|
371
|
+
}
|
|
372
|
+
else if (type === 'left') {
|
|
373
|
+
(_d = (_c = childrenDom[0]) === null || _c === void 0 ? void 0 : _c.setAttribute) === null || _d === void 0 ? void 0 : _d.call(_c, 'style', "left: " + childrenDom[0].dataset.left + "; ");
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
(_f = (_e = childrenDom[0]) === null || _e === void 0 ? void 0 : _e.setAttribute) === null || _f === void 0 ? void 0 : _f.call(_e, 'style', "top: " + childrenDom[0].dataset.top + "; left: " + childrenDom[0].dataset.left);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
catch (err) {
|
|
381
|
+
console.log(err);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
export function useInitSetPostion() {
|
|
385
|
+
useEffect(function () {
|
|
386
|
+
var printDom = document.querySelectorAll('.html2canvas-container-page');
|
|
387
|
+
for (var i = 0; i < printDom.length; i++) {
|
|
388
|
+
var item = printDom[i];
|
|
389
|
+
initMinusPosition(item);
|
|
390
|
+
}
|
|
391
|
+
}, []);
|
|
392
|
+
}
|
|
@@ -65,7 +65,7 @@ import PrintModal from './PrintModal';
|
|
|
65
65
|
// 其他文件
|
|
66
66
|
import { printCurrentDom, htmlToPdfNoCanvas, htmlToPdf, addWaterHandle, removeWaterHandle, } from 'ztxkutils/dist/print';
|
|
67
67
|
import { createDownloadUrlNoBase, createDownloadUrl, } from 'ztxkutils/dist/fileOperation';
|
|
68
|
-
import { dataURLtoFile, setPositionLocal, getPositionLocal, setPositionDom, setPositionDeviation, } from './handle';
|
|
68
|
+
import { dataURLtoFile, setPositionLocal, getPositionLocal, setPositionDom, setPositionDeviation, useInitSetPostion, } from './handle';
|
|
69
69
|
import { createTask } from './lodop';
|
|
70
70
|
import { useNeedLodop } from './utils';
|
|
71
71
|
var fontTTF = {
|
|
@@ -117,6 +117,7 @@ var PrintContainer = function (_a) {
|
|
|
117
117
|
left: 0,
|
|
118
118
|
}), value = _v[0], setValue = _v[1];
|
|
119
119
|
useNeedLodop();
|
|
120
|
+
useInitSetPostion();
|
|
120
121
|
useEffect(function () {
|
|
121
122
|
var v = getPositionLocal(localKey);
|
|
122
123
|
setValue(v);
|
package/dist/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
1
|
+
export declare const token = "e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