ztxkui 3.9.0 → 3.9.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.
@@ -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" },
@@ -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: 0, max: 200, step: 0.01, value: (value === null || value === void 0 ? void 0 : value.top) || 0, onChange: function (value) {
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: 0, max: 200, step: 0.01, value: (value === null || value === void 0 ? void 0 : value.left) || 0, onChange: function (value) {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",