zmdms-webui 0.0.141 → 0.0.142

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.
@@ -0,0 +1,59 @@
1
+ import { __awaiter, __generator, __assign } from '../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, useCallback } from 'react';
4
+ import { htmlToPdf } from '../utils.js';
5
+ import ButtonCom from '../../button/button.js';
6
+
7
+ var ExportPdfBtn = function (_a) {
8
+ var config = _a.config, waterRef = _a.waterRef, setSpinning = _a.setSpinning, clickExportHandle = _a.clickExportHandle, beforeExportHandle = _a.beforeExportHandle, afterExportHandle = _a.afterExportHandle;
9
+ var onExport = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
10
+ var isWater, res, err_1;
11
+ var _a;
12
+ return __generator(this, function (_b) {
13
+ switch (_b.label) {
14
+ case 0:
15
+ setSpinning && setSpinning(true);
16
+ _b.label = 1;
17
+ case 1:
18
+ _b.trys.push([1, 5, , 6]);
19
+ if (!clickExportHandle) return [3 /*break*/, 3];
20
+ return [4 /*yield*/, clickExportHandle()];
21
+ case 2:
22
+ _b.sent();
23
+ _b.label = 3;
24
+ case 3:
25
+ beforeExportHandle && beforeExportHandle();
26
+ isWater = ((_a = waterRef.current) === null || _a === void 0 ? void 0 : _a.getIsWater()) || true;
27
+ return [4 /*yield*/, htmlToPdf({
28
+ pageDom: ".ztxk-print--page",
29
+ waterConfig: isWater ? config : undefined,
30
+ isDownload: true,
31
+ })];
32
+ case 4:
33
+ res = _b.sent();
34
+ console.log(res);
35
+ setSpinning && setSpinning(false);
36
+ return [3 /*break*/, 6];
37
+ case 5:
38
+ err_1 = _b.sent();
39
+ setSpinning && setSpinning(false);
40
+ console.log("导出执行出错", err_1);
41
+ return [3 /*break*/, 6];
42
+ case 6:
43
+ afterExportHandle && afterExportHandle();
44
+ return [2 /*return*/];
45
+ }
46
+ });
47
+ }); }, [
48
+ waterRef,
49
+ config,
50
+ setSpinning,
51
+ clickExportHandle,
52
+ beforeExportHandle,
53
+ afterExportHandle,
54
+ ]);
55
+ return (jsx(ButtonCom, __assign({ type: "primary", className: "ph__item", onClick: onExport }, { children: "\u5BFC\u51FAPDF" })));
56
+ };
57
+ var ExportPdfBtn$1 = memo(ExportPdfBtn);
58
+
59
+ export { ExportPdfBtn$1 as default };
@@ -0,0 +1,53 @@
1
+ import { __awaiter, __generator, __assign } from '../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, useCallback } from 'react';
4
+ import { useLatest, useMount } from 'ahooks';
5
+ import ButtonCom from '../../button/button.js';
6
+
7
+ var PrintBtn = function (_a) {
8
+ var clickPrintHandle = _a.clickPrintHandle, beforePrintHandle = _a.beforePrintHandle, afterPrintHandle = _a.afterPrintHandle;
9
+ var beforePrintHandleRef = useLatest(beforePrintHandle);
10
+ var afterPrintHandleRef = useLatest(afterPrintHandle);
11
+ useMount(function () {
12
+ var beforeprintHandle = function (event) {
13
+ var _a;
14
+ (_a = beforePrintHandleRef.current) === null || _a === void 0 ? void 0 : _a.call(beforePrintHandleRef);
15
+ };
16
+ var afterprintHandle = function (event) {
17
+ var _a;
18
+ (_a = afterPrintHandleRef.current) === null || _a === void 0 ? void 0 : _a.call(afterPrintHandleRef);
19
+ };
20
+ window.addEventListener("beforeprint", beforeprintHandle);
21
+ window.addEventListener("afterprint", afterprintHandle);
22
+ return function () {
23
+ window.removeEventListener("beforeprint", beforeprintHandle);
24
+ window.removeEventListener("afterprint", afterprintHandle);
25
+ };
26
+ });
27
+ var onPrint = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
28
+ var err_1;
29
+ return __generator(this, function (_a) {
30
+ switch (_a.label) {
31
+ case 0:
32
+ _a.trys.push([0, 3, , 4]);
33
+ if (!clickPrintHandle) return [3 /*break*/, 2];
34
+ return [4 /*yield*/, clickPrintHandle()];
35
+ case 1:
36
+ _a.sent();
37
+ _a.label = 2;
38
+ case 2:
39
+ window.print();
40
+ return [3 /*break*/, 4];
41
+ case 3:
42
+ err_1 = _a.sent();
43
+ console.log("打印执行出错", err_1);
44
+ return [3 /*break*/, 4];
45
+ case 4: return [2 /*return*/];
46
+ }
47
+ });
48
+ }); }, [clickPrintHandle]);
49
+ return (jsx(ButtonCom, __assign({ type: "primary", className: "ph__item", onClick: onPrint }, { children: "\u6253\u5370" })));
50
+ };
51
+ var PrintBtn$1 = memo(PrintBtn);
52
+
53
+ export { PrintBtn$1 as default };
@@ -0,0 +1,26 @@
1
+ import { __assign } from '../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useImperativeHandle } from 'react';
4
+ import useToggleWater from '../useToggleWater.js';
5
+ import { useMount } from 'ahooks';
6
+ import ButtonCom from '../../button/button.js';
7
+
8
+ var WaterBtn = function (_a, ref) {
9
+ var config = _a.config;
10
+ // 水印相关方法
11
+ var _b = useToggleWater(config), toggleWater = _b.toggleWater, isWater = _b.isWater;
12
+ useMount(function () {
13
+ toggleWater();
14
+ });
15
+ useImperativeHandle(ref, function () {
16
+ return {
17
+ getIsWater: function () {
18
+ return isWater;
19
+ },
20
+ };
21
+ });
22
+ return (jsx(ButtonCom, __assign({ type: "primary", className: "ph__item", onClick: toggleWater }, { children: isWater ? "移除水印" : "添加水印" })));
23
+ };
24
+ var WaterBtn$1 = memo(forwardRef(WaterBtn));
25
+
26
+ export { WaterBtn$1 as default };
@@ -1 +1 @@
1
- @media print{.non-printable,body *{display:none}.ztxk-print--content{display:block}}
1
+ .ztxk-print .ztxk-print--header{background-color:#fff;padding:10px;position:sticky;top:0;z-index:100}.ztxk-print .ztxk-print--header .ph__item,.ztxk-print .ztxk-print--header button{margin-left:10px}.ztxk-print .ztxk-print--header .ph__item:first-child,.ztxk-print .ztxk-print--header button:first-child{margin-left:0}.ztxk-print .ztxk-print--content{font-family:microsoft-yahei;min-height:500px;width:100%}.ztxk-print .ztxk-print--content .ztxk-print--main{margin:auto;width:1000px}.ztxk-print .ztxk-print--page-break__before{display:block;page-break-before:always}.ztxk-print .ztxk-print--page__pagination{margin:10px 0;text-align:center}.ztxk-print .ztxk-print--page-break__after{display:block;page-break-after:always}@media print{.non-printable{display:none}.non-printable,body *{visibility:hidden}.ztxk-print--content,.ztxk-print--content *{visibility:visible}footer.ztxk-print--page__pagination{bottom:0;position:fixed;width:100%}}
@@ -1,16 +1,68 @@
1
1
  import React__default from 'react';
2
+ import PrintPage from './print-page.js';
2
3
 
3
4
  interface IPrintProps {
4
5
  /** 是否显示打印按钮 */
5
- showPrintBtn?: boolean;
6
+ isPrintBtn?: boolean;
7
+ /** 点击打印按钮时调用 */
8
+ clickPrintHandle?: () => Promise<any>;
9
+ /** 开始打印前 */
10
+ beforePrintHandle?: () => void;
11
+ /** 结束打印后 没法确定用户是否实际调用了打印功能 */
12
+ afterPrintHandle?: () => void;
13
+ /** 点击导出按钮时调用 */
14
+ clickExportHandle?: () => Promise<any>;
15
+ /** 开始导出前 */
16
+ beforeExportHandle?: () => void;
17
+ /** 结束导出后 */
18
+ afterExportHandle?: () => void;
19
+ /** 是否显示添加水印按钮 */
20
+ isWaterBtn?: boolean;
21
+ /** 水印相关配置 */
22
+ waterConfig?: IWaterConfig;
23
+ /** 是否显示导出pdf按钮 */
24
+ isExportPdfBtn?: boolean;
25
+ /** 导出PDF名字 */
26
+ pdfName?: string;
27
+ /** 容器类名 */
28
+ className?: string;
6
29
  /** 头部容器类名 */
7
30
  headerClassName?: string;
8
31
  /** 子元素 */
9
32
  children?: React__default.ReactNode;
33
+ /** 加载态 */
34
+ spinning?: boolean;
35
+ }
36
+ interface IWaterConfig {
37
+ width?: number;
38
+ height?: number;
39
+ rotate?: number;
40
+ zIndex?: number;
41
+ image?: string;
42
+ content?: string | string[];
43
+ font?: {
44
+ color?: CanvasFillStrokeStyles["fillStyle"];
45
+ fontSize?: number;
46
+ fontWeight?: "normal" | "light" | "weight" | number;
47
+ fontStyle?: "none" | "normal" | "italic" | "oblique";
48
+ fontFamily?: string;
49
+ textAlign?: CanvasTextAlign;
50
+ };
10
51
  }
11
52
  interface PrintComponent extends React__default.FC<IPrintProps> {
12
53
  displayName: string;
54
+ /** 不需要打印的样式 */
13
55
  NON_PRINTABLE: string;
56
+ PrintPage: typeof PrintPage;
57
+ }
58
+ interface IPrintPageProps {
59
+ children: React__default.ReactNode;
60
+ /** 当前是第几页 */
61
+ index?: number;
62
+ /** 总共几页 */
63
+ count?: number;
64
+ /** pdf名称 */
65
+ pdfName?: string;
14
66
  }
15
67
 
16
- export { IPrintProps, PrintComponent };
68
+ export { IPrintPageProps, IPrintProps, IWaterConfig, PrintComponent };
@@ -1,20 +1,28 @@
1
1
  import { __assign } from '../_virtual/_tslib.js';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { memo } from 'react';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { memo, useRef } from 'react';
4
4
  import classNames from '../node_modules/classnames/index.js';
5
5
  import { NON_PRINTABLE } from './print.js';
6
+ import useCreateWater from './useCreateWater.js';
7
+ import WaterBtn from './components/WaterBtn.js';
8
+ import PrintBtn from './components/PrintBtn.js';
9
+ import ExportPdfBtn from './components/ExportPdfBtn.js';
6
10
  import ButtonCom from '../button/button.js';
7
11
 
8
12
  var PrintHeader = function (props) {
9
13
  var _a;
10
- var _b = props.showPrintBtn, showPrintBtn = _b === void 0 ? true : _b, headerClassName = props.headerClassName;
14
+ var isPrintBtn = props.isPrintBtn, clickPrintHandle = props.clickPrintHandle, beforePrintHandle = props.beforePrintHandle, afterPrintHandle = props.afterPrintHandle, isWaterBtn = props.isWaterBtn, waterConfig = props.waterConfig, isExportPdfBtn = props.isExportPdfBtn, clickExportHandle = props.clickExportHandle, beforeExportHandle = props.beforeExportHandle, afterExportHandle = props.afterExportHandle, headerClassName = props.headerClassName, setSpinning = props.setSpinning;
11
15
  // 主容器类名
12
16
  var classes = classNames("ztxk-print--header", headerClassName, (_a = {},
13
17
  _a[NON_PRINTABLE] = true,
14
18
  _a));
15
- return (jsx("div", __assign({ className: classes }, { children: showPrintBtn && (jsx(ButtonCom, __assign({ type: "primary", onClick: function () {
16
- window.print();
17
- } }, { children: "\u6253\u5370" }))) })));
19
+ // 生成水印图片
20
+ var config = useCreateWater(waterConfig).config;
21
+ // 水印相关逻辑获取
22
+ var waterRef = useRef();
23
+ return (jsxs("div", __assign({ className: classes }, { children: [isWaterBtn && jsx(WaterBtn, { config: config, ref: waterRef }), isPrintBtn && (jsx(PrintBtn, { clickPrintHandle: clickPrintHandle, beforePrintHandle: beforePrintHandle, afterPrintHandle: afterPrintHandle })), isExportPdfBtn && (jsx(ExportPdfBtn, { config: config, waterRef: waterRef, setSpinning: setSpinning, clickExportHandle: clickExportHandle, beforeExportHandle: beforeExportHandle, afterExportHandle: afterExportHandle })), jsx(ButtonCom, __assign({ type: "primary", className: "ph__item", onClick: function () {
24
+ window.close();
25
+ } }, { children: "\u5173\u95ED" }))] })));
18
26
  };
19
27
  var PrintHeader$1 = memo(PrintHeader);
20
28
 
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+ import { IPrintPageProps } from './interface.js';
3
+
4
+ declare const PrintPage: React__default.FC<IPrintPageProps>;
5
+
6
+ export { PrintPage as default };
@@ -0,0 +1,9 @@
1
+ import { __assign } from '../_virtual/_tslib.js';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+
4
+ var PrintPage = function (_a) {
5
+ var children = _a.children, index = _a.index, count = _a.count, pdfName = _a.pdfName;
6
+ return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "ztxk-print--page", "data-title": pdfName }, { children: [jsx("div", __assign({ className: "ztxk-print--page__content" }, { children: children })), index && (jsxs("footer", __assign({ className: "ztxk-print--page__pagination" }, { children: ["\u7B2C", index, "\u9875/\u5171", count, "\u9875"] })))] })), jsx("div", { className: "ztxk-print--page-break__after" })] }));
7
+ };
8
+
9
+ export { PrintPage as default };
@@ -1,18 +1,36 @@
1
- import { __assign } from '../_virtual/_tslib.js';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { memo, forwardRef } from 'react';
1
+ import { __rest, __assign } from '../_virtual/_tslib.js';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useState } from 'react';
4
4
  import PrintHeader from './print-header.js';
5
+ import PrintPage from './print-page.js';
5
6
  import classNames from '../node_modules/classnames/index.js';
7
+ import WatermarkCom from '../watermark/watermark.js';
8
+ import { Spin } from 'antd';
6
9
 
7
10
  var NON_PRINTABLE = "non-printable";
8
11
  var Print = function (props, ref) {
9
- var showPrintBtn = props.showPrintBtn, headerClassName = props.headerClassName, children = props.children;
12
+ var className = props.className, children = props.children, _a = props.spinning, outSpinning = _a === void 0 ? false : _a, headerProps = __rest(props, ["className", "children", "spinning"]);
13
+ // 设置默认值
14
+ // if (headerProps.isWaterBtn == null) {
15
+ // headerProps.isWaterBtn = true;
16
+ // }
17
+ if (headerProps.isPrintBtn == null) {
18
+ headerProps.isPrintBtn = true;
19
+ }
20
+ if (headerProps.isExportPdfBtn == null) {
21
+ headerProps.isExportPdfBtn = true;
22
+ }
23
+ var waterConfig = headerProps.waterConfig;
10
24
  // 主容器类名
11
- var classes = classNames("ztxk-print", headerClassName, {});
12
- return (jsxs("div", __assign({ className: classes }, { children: [jsx(PrintHeader, { showPrintBtn: showPrintBtn, headerClassName: headerClassName }), jsx("div", __assign({ className: "ztxk-print--content" }, { children: children }))] })));
25
+ var classes = classNames("ztxk-print", className, {
26
+ "ztxk-print--water": headerProps.isWaterBtn,
27
+ });
28
+ var _b = useState(false), spinning = _b[0], setSpinning = _b[1];
29
+ return (jsx(Spin, __assign({ spinning: spinning || outSpinning }, { children: jsxs("div", __assign({ className: classes }, { children: [jsx(PrintHeader, __assign({ setSpinning: setSpinning }, headerProps)), jsx(WatermarkCom, __assign({ className: "ztxk-print--content" }, waterConfig, { children: jsx("div", __assign({ className: "ztxk-print--main" }, { children: children })) }))] })) })));
13
30
  };
14
31
  var PrintCom = memo(forwardRef(Print));
15
32
  PrintCom.displayName = "ZTXK_WEBUI_Print";
16
- PrintCom.NON_PRINTABLE = NON_PRINTABLE;
33
+ PrintCom.NON_PRINTABLE = NON_PRINTABLE;
34
+ PrintCom.PrintPage = PrintPage;
17
35
 
18
36
  export { NON_PRINTABLE, PrintCom as default };
@@ -0,0 +1,36 @@
1
+ import { useMemo } from 'react';
2
+ import { mergeWaterConfig, createWater } from 'zmdms-utils';
3
+
4
+ /**
5
+ * 生成水印
6
+ */
7
+ function useCreateWater(waterConfig) {
8
+ var _a = mergeWaterConfig(waterConfig), image = _a.image, content = _a.content, width = _a.width, height = _a.height, rotate = _a.rotate, font = _a.font;
9
+ var config = useMemo(function () {
10
+ // 文本水印
11
+ if (!image) {
12
+ var _a = createWater({
13
+ content: content,
14
+ width: width,
15
+ height: height,
16
+ rotate: rotate,
17
+ font: font,
18
+ }), imgBase64 = _a.imgBase64, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight;
19
+ return {
20
+ image: imgBase64,
21
+ width: canvasWidth,
22
+ height: canvasHeight,
23
+ };
24
+ }
25
+ return {
26
+ image: image,
27
+ width: width,
28
+ height: height,
29
+ };
30
+ }, [content, font, height, image, rotate, width]);
31
+ return {
32
+ config: config,
33
+ };
34
+ }
35
+
36
+ export { useCreateWater as default };
@@ -0,0 +1,25 @@
1
+ import { useState, useCallback } from 'react';
2
+
3
+ function useToggleWater(config) {
4
+ var _a = useState(false), isWater = _a[0], setIsWater = _a[1];
5
+ var toggleWater = useCallback(function () {
6
+ var waterStyleDom = document.getElementById("water-style-dom-110011");
7
+ if (waterStyleDom) {
8
+ setIsWater(false);
9
+ waterStyleDom.remove();
10
+ return;
11
+ }
12
+ setIsWater(true);
13
+ var styleDom = document.createElement("style");
14
+ styleDom.setAttribute("type", "text/css");
15
+ styleDom.setAttribute("id", "water-style-dom-110011");
16
+ styleDom.innerHTML = "\n @media print {\n body {\n background-image: url('".concat(config === null || config === void 0 ? void 0 : config.image, "');\n background-repeat: repeat !important;\n background-position: left top;\n -webkit-print-color-adjust: exact; /* Chrome, Safari */\n color-adjust: exact; /* Firefox */\n }\n .ztxk-print--content {\n background-image: none !important;\n }\n }\n @page { size: auto; }\n .ztxk-print--content {\n background-image: url('").concat(config === null || config === void 0 ? void 0 : config.image, "');\n background-repeat: repeat !important;\n background-position: left top;\n }\n ");
17
+ document.body.appendChild(styleDom);
18
+ }, [config]);
19
+ return {
20
+ toggleWater: toggleWater,
21
+ isWater: isWater,
22
+ };
23
+ }
24
+
25
+ export { useToggleWater as default };
@@ -0,0 +1,59 @@
1
+ import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
+ import dayjs from 'dayjs';
3
+ import { domToCanvas, imgToPdf } from 'zmdms-utils';
4
+
5
+ /**
6
+ * dom 转 pdf
7
+ */
8
+ function htmlToPdf(config) {
9
+ var _this = this;
10
+ var container = config.container, pageDom = config.pageDom, imgToPdfOptions = __rest(config, ["container", "pageDom"]);
11
+ // 找到需要转换的dom
12
+ var domList;
13
+ if (typeof pageDom === "string") {
14
+ domList = container
15
+ ? container.querySelectorAll(pageDom)
16
+ : document.body.querySelectorAll(pageDom);
17
+ domList = Array.from(domList);
18
+ }
19
+ else {
20
+ domList = Array.isArray(pageDom) ? pageDom : [pageDom];
21
+ }
22
+ if (domList.length === 0) {
23
+ return Promise.reject("没有可以导出的元素!");
24
+ }
25
+ if (domList.length === 1) {
26
+ var domItem = domList[0];
27
+ var dataTitle_1 = domItem.dataset.title || "".concat(dayjs().format("YYYY-MM-DD"), "-1");
28
+ return domToCanvas(domItem).then(function (canvas) {
29
+ // 计算canvas的宽度和高度转换为PDF的宽度和高度
30
+ var canvasWidth = canvas.width;
31
+ var canvasHeight = canvas.height;
32
+ return imgToPdf(__assign({ image: canvas, width: canvasWidth, height: canvasHeight, pdfName: dataTitle_1 }, imgToPdfOptions));
33
+ });
34
+ }
35
+ else {
36
+ var promiseArr_1 = [];
37
+ domList.forEach(function (domItem, index) {
38
+ var dataTitle = domItem.dataset.title || "".concat(dayjs().format("YYYY-MM-DD"), "-").concat(index + 1);
39
+ var item = domToCanvas(domItem).then(function (canvas) { return __awaiter(_this, void 0, void 0, function () {
40
+ var canvasWidth, canvasHeight, pdf;
41
+ return __generator(this, function (_a) {
42
+ switch (_a.label) {
43
+ case 0:
44
+ canvasWidth = canvas.width;
45
+ canvasHeight = canvas.height;
46
+ return [4 /*yield*/, imgToPdf(__assign({ image: canvas, width: canvasWidth, height: canvasHeight, pdfName: dataTitle }, imgToPdfOptions))];
47
+ case 1:
48
+ pdf = _a.sent();
49
+ return [2 /*return*/, pdf];
50
+ }
51
+ });
52
+ }); });
53
+ promiseArr_1.push(item);
54
+ });
55
+ return Promise.all(promiseArr_1);
56
+ }
57
+ }
58
+
59
+ export { htmlToPdf };
@@ -154,7 +154,6 @@ function useInitRemeberCheckedValues(_a) {
154
154
  return;
155
155
  }
156
156
  if (Array.isArray(value)) {
157
- console.log(1111);
158
157
  var result = value.map(function (v) {
159
158
  var _a, _b;
160
159
  var checked = (_a = defaultCheckedValuesRef.current) === null || _a === void 0 ? void 0 : _a.find(function (item) { return (item === null || item === void 0 ? void 0 : item[dataKey]) === v; });
@@ -165,7 +164,6 @@ function useInitRemeberCheckedValues(_a) {
165
164
  if (current) {
166
165
  return current;
167
166
  }
168
- console.log("性能遍历");
169
167
  var item = list === null || list === void 0 ? void 0 : list.find(function (item) {
170
168
  if (!item) {
171
169
  return null;
@@ -35,7 +35,7 @@ var EnhanceCell = function (props) {
35
35
  var isCurrentRef = useRef(false);
36
36
  // 修改验证状态之一
37
37
  var changeCurrentState = useCallback(function (isChange) {
38
- console.log("验证开关是否打开", isChange);
38
+ // console.log("验证开关是否打开", isChange);
39
39
  // setIsCurrent(isChange);
40
40
  isCurrentRef.current = isChange;
41
41
  }, []);
@@ -31,6 +31,10 @@ interface ITreeProps extends TreeProps {
31
31
  * 懒加载一次性搜索树属性
32
32
  */
33
33
  lazySearchTreeData?: TreeProps["treeData"];
34
+ /**
35
+ * 是否展示统计
36
+ */
37
+ showCount?: boolean;
34
38
  }
35
39
  interface TreeComponent extends React__default.ForwardRefExoticComponent<ITreeProps & React__default.RefAttributes<unknown>> {
36
40
  DirectoryTree: typeof Tree.DirectoryTree;
@@ -8,18 +8,18 @@ import { useBasicInfo, useAllCheckData, useAllDataHandle, useSearchHandle, useLa
8
8
 
9
9
  var Tree = function (props, ref) {
10
10
  var _a;
11
- var searchType = props.searchType, onSearch = props.onSearch, className = props.className, style = props.style, treeStyle = props.treeStyle, cssTreeHeight = props.cssTreeHeight, _b = props.searchMode, searchMode = _b === void 0 ? "change" : _b, treeData = props.treeData, lazySearchTreeData = props.lazySearchTreeData, loadData = props.loadData, onCheck = props.onCheck, onSelect = props.onSelect, resetProps = __rest(props, ["searchType", "onSearch", "className", "style", "treeStyle", "cssTreeHeight", "searchMode", "treeData", "lazySearchTreeData", "loadData", "onCheck", "onSelect"]);
11
+ var searchType = props.searchType, onSearch = props.onSearch, className = props.className, style = props.style, treeStyle = props.treeStyle, cssTreeHeight = props.cssTreeHeight, _b = props.searchMode, searchMode = _b === void 0 ? "change" : _b, treeData = props.treeData, lazySearchTreeData = props.lazySearchTreeData, loadData = props.loadData, onCheck = props.onCheck, onSelect = props.onSelect, _c = props.showCount, showCount = _c === void 0 ? true : _c, resetProps = __rest(props, ["searchType", "onSearch", "className", "style", "treeStyle", "cssTreeHeight", "searchMode", "treeData", "lazySearchTreeData", "loadData", "onCheck", "onSelect", "showCount"]);
12
12
  var fieldNames = resetProps.fieldNames, checkedKeys = resetProps.checkedKeys;
13
13
  var classes = classNames("ztxk-tree", className, {
14
14
  "ztxk-tree--height": cssTreeHeight,
15
15
  });
16
16
  // 获取基础数据的key值
17
- var _c = useBasicInfo({ fieldNames: fieldNames }), valueKey = _c.valueKey, titleKey = _c.titleKey, childrenKey = _c.childrenKey;
18
- var _d = useAllCheckData({
17
+ var _d = useBasicInfo({ fieldNames: fieldNames }), valueKey = _d.valueKey, titleKey = _d.titleKey, childrenKey = _d.childrenKey;
18
+ var _e = useAllCheckData({
19
19
  onCheck: onCheck,
20
20
  onSelect: onSelect,
21
21
  valueKey: valueKey,
22
- }), onCheckHandle = _d.onCheckHandle, onSelectHandle = _d.onSelectHandle, allCompleteData = _d.allCompleteData;
22
+ }), onCheckHandle = _e.onCheckHandle, onSelectHandle = _e.onSelectHandle, allCompleteData = _e.allCompleteData;
23
23
  // 获取拉平数据
24
24
  var flatDataList = useAllDataHandle({
25
25
  searchType: searchType,
@@ -28,7 +28,7 @@ var Tree = function (props, ref) {
28
28
  childrenKey: childrenKey,
29
29
  titleKey: titleKey,
30
30
  }).flatDataList;
31
- var _e = useSearchHandle({
31
+ var _f = useSearchHandle({
32
32
  treeData: treeData,
33
33
  flatDataList: flatDataList,
34
34
  titleKey: titleKey,
@@ -36,8 +36,8 @@ var Tree = function (props, ref) {
36
36
  searchType: searchType,
37
37
  onSearch: onSearch,
38
38
  searchMode: searchMode,
39
- }), onSearchHandle = _e.onSearchHandle, onChangeHandle = _e.onChangeHandle, searchValue = _e.searchValue, expandedKeys = _e.expandedKeys, autoExpandParent = _e.autoExpandParent, onExpand = _e.onExpand;
40
- var _f = useLazySearchExpands(lazySearchTreeData), lazySearchExpandedKeys = _f.expandedKeys, lazySearchAutoExpandParent = _f.autoExpandParent, lazySearchOnExpand = _f.onExpand;
39
+ }), onSearchHandle = _f.onSearchHandle, onChangeHandle = _f.onChangeHandle, searchValue = _f.searchValue, expandedKeys = _f.expandedKeys, autoExpandParent = _f.autoExpandParent, onExpand = _f.onExpand;
40
+ var _g = useLazySearchExpands(lazySearchTreeData), lazySearchExpandedKeys = _g.expandedKeys, lazySearchAutoExpandParent = _g.autoExpandParent, lazySearchOnExpand = _g.onExpand;
41
41
  var showLazySearchTreeData = !!(searchType === "lazy" && searchValue);
42
42
  useImperativeHandle(ref, function () {
43
43
  return {
@@ -47,7 +47,7 @@ var Tree = function (props, ref) {
47
47
  },
48
48
  };
49
49
  });
50
- return (jsxs("div", __assign({ className: classes, style: __assign({ height: cssTreeHeight }, style) }, { children: [searchType ? (jsx(MemoInput.Search, { value: searchValue, onChange: onChangeHandle, onSearch: onSearchHandle })) : null, (props.checkable || props.multiple) && checkedKeys ? (jsxs("div", { children: ["\u5DF2\u9009\u4E2D\uFF1A", checkedKeys
50
+ return (jsxs("div", __assign({ className: classes, style: __assign({ height: cssTreeHeight }, style) }, { children: [searchType ? (jsx(MemoInput.Search, { value: searchValue, onChange: onChangeHandle, onSearch: onSearchHandle })) : null, (props.checkable || props.multiple) && checkedKeys && showCount ? (jsxs("div", { children: ["\u5DF2\u9009\u4E2D\uFF1A", checkedKeys
51
51
  ? Array.isArray(checkedKeys)
52
52
  ? checkedKeys.length
53
53
  : (_a = checkedKeys.checked) === null || _a === void 0 ? void 0 : _a.length
File without changes
@@ -0,0 +1,5 @@
1
+ import WatermarkCom from './watermark.js';
2
+
3
+
4
+
5
+ export { WatermarkCom as default };
@@ -0,0 +1,5 @@
1
+ import WatermarkCom from './watermark.js';
2
+
3
+
4
+
5
+ export { WatermarkCom as default };
@@ -0,0 +1,13 @@
1
+ import React__default from 'react';
2
+ import { IWaterConfig } from 'zmdms-utils/dist/es/water';
3
+
4
+ interface IWatermark extends IWaterConfig {
5
+ children?: React__default.ReactNode;
6
+ className?: string;
7
+ visible?: boolean;
8
+ }
9
+ interface WatermarkComponent extends React__default.FC<IWatermark> {
10
+ displayName: string;
11
+ }
12
+
13
+ export { IWatermark, WatermarkComponent };
@@ -0,0 +1,67 @@
1
+ import { __rest } from '../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo, forwardRef, useRef, useState, useMemo, useImperativeHandle } from 'react';
4
+ import { mergeWaterConfig, createWater } from 'zmdms-utils';
5
+ import { useMutationObserver } from 'ahooks';
6
+
7
+ var WatermarkDiv = function (props, ref) {
8
+ props.children; props.className; var waterConfigProps = __rest(props, ["children", "className"]);
9
+ var _a = mergeWaterConfig(waterConfigProps), zIndex = _a.zIndex, image = _a.image, content = _a.content, width = _a.width, height = _a.height, rotate = _a.rotate, font = _a.font, lineSpacing = _a.lineSpacing;
10
+ var waterDomRef = useRef(null);
11
+ var _b = useState(1), num = _b[0], setNum = _b[1];
12
+ var config = useMemo(function () {
13
+ // 文本水印
14
+ if (!image) {
15
+ var _a = createWater({
16
+ content: content,
17
+ width: width,
18
+ height: height,
19
+ rotate: rotate,
20
+ font: font,
21
+ lineSpacing: lineSpacing,
22
+ }), imgBase64 = _a.imgBase64, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight;
23
+ return {
24
+ image: imgBase64,
25
+ width: canvasWidth,
26
+ height: canvasHeight,
27
+ };
28
+ }
29
+ return {
30
+ image: image,
31
+ width: width,
32
+ height: height,
33
+ };
34
+ }, [content, font, height, image, rotate, width, lineSpacing]);
35
+ useImperativeHandle(ref, function () {
36
+ return {
37
+ getWaterDomRef: function () { return waterDomRef.current; },
38
+ toggleVisible: function () {
39
+ if (waterDomRef.current) {
40
+ waterDomRef.current.style.visibility = "hidden";
41
+ }
42
+ },
43
+ };
44
+ });
45
+ useMutationObserver(function (mutationsList) {
46
+ console.log("触发子级", mutationsList);
47
+ setNum(function (num) { return num + 1; });
48
+ }, waterDomRef, {
49
+ attributes: true,
50
+ });
51
+ return (jsx("div", { ref: waterDomRef, className: "ztxk-watermark--div", style: {
52
+ zIndex: zIndex,
53
+ position: "absolute",
54
+ visibility: "visible",
55
+ left: 0,
56
+ top: 0,
57
+ width: "100%",
58
+ height: "100%",
59
+ pointerEvents: "none",
60
+ backgroundRepeat: "repeat",
61
+ backgroundPosition: "left top",
62
+ backgroundImage: "url(".concat(config.image, ")"),
63
+ } }, num));
64
+ };
65
+ var WatermarkDiv$1 = memo(forwardRef(WatermarkDiv));
66
+
67
+ export { WatermarkDiv$1 as default };
@@ -0,0 +1,5 @@
1
+ import { WatermarkComponent } from './interface.js';
2
+
3
+ declare const WatermarkCom: WatermarkComponent;
4
+
5
+ export { WatermarkCom as default };