cloud-web-corejs 1.0.54-dev.284 → 1.0.54-dev.286

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.284",
4
+ "version": "1.0.54-dev.286",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -1,135 +1,135 @@
1
- <template>
2
- <div>
3
- <div id="uploadImage" :class="classList">
4
- <div class="upload-list" model="singer" v-for="(attachment, index) in attachments" :key="index"
5
- style="display: inline-block;vertical-align: middle;float: left;">
6
- <template v-if="$attrs.hideInfo !== true && $attrs.hideInfo !== 'true'">
7
- <div class="upload-box">
8
- <ul class="el-upload-list el-upload-list--picture">
9
- <li tabindex="0" class="el-upload-list__item">
10
- <div>
11
- <div class="el-upload-list__item-thumbnail">
12
- <div class="show-video" v-if="hasPreview(attachment)" @click="openPreview(attachment,index)"><i
13
- class="icon-chakan"></i></div>
14
- <p>
15
- <el-image
16
- :src="getShowUrl(attachment)"
17
- @click="openPreview(attachment,index)"
18
- :z-index="999999"
19
- />
20
- </p>
21
- </div>
22
- <div class="el-upload-list__item-name">
23
- <el-tooltip :enterable="false" class="item" effect="dark" :content="getAttachmentName(attachment)"
24
- placement="top">
25
- <p v-if="$attrs.hideName !== true">{{ getAttachmentName(attachment) }}</p>
26
- </el-tooltip>
27
- <p v-if="$attrs.showSize === true || $attrs.showSize === 'true'">
28
- {{ formatFileSize(attachment.fileSize) }}</p>
29
- <!-- <p v-if="$attrs.showSortInput !== true && !dataType && $attrs.createBy !== false">
30
- {{ attachment.createBy }}</p>-->
31
- <p v-if="$attrs.showSortInput !== true && !dataType && $attrs.createDate !== false">
32
- {{ attachment.createDate }}</p>
33
- </div>
34
- <div class="el-upload-input" v-if="$attrs.showSortInput">
35
- <base-input-number v-model="attachment.orders" class="button-sty"
36
- :placeholder="$t2('序号', 'components.VabUpload.orders')" :scale="0"/>
37
- </div>
38
- <div class="el-upload-input" v-if="$attrs.showNameInput">
39
- <el-input v-model="attachment.name" class="button-sty"
40
- :placeholder="$t2('请输入名称', 'components.VabUpload.name')" :scale="0"/>
41
- </div>
42
- <div class="el-upload-list__item-status-label"><i class="el-icon-upload-success el-icon-check"></i>
43
- </div>
44
- <div class="el-icon-close" @click="deleteFile(index)"
45
- v-if="$attrs.edit !== false && $attrs.edit !== 'false' && attachment.h5!==1">
46
- <i class="el-tooltip iconfont iconshanchu" aria-describedby="el-tooltip-6144" tabindex="0"></i>
47
- </div>
48
- <div class="el-icon-tagEdit" v-if="attachment.h5!==1">
49
- <el-tooltip class="item" effect="dark" :content="$t2('下载', 'system.button.download')"
50
- placement="top">
51
- <i class="el-icon-download"
52
- @click="downloadFile(attachment)"></i>
53
- </el-tooltip>
54
- <el-tooltip class="item" effect="dark" :content="$t2('详情', 'components.VabUpload.detail')"
55
- placement="top"
56
- v-if="attachment && attachment.id && $attrs.showProperties!==false && !dataType">
57
- <i class="iconfont icon-shuxing" @click="openPropertiesDialog(attachment)"></i>
58
- </el-tooltip>
59
- </div>
60
- </div>
61
- </li>
62
- </ul>
63
- </div>
64
- </template>
65
- <template v-else>
66
- <a>
67
- <el-image
68
- :src="getShowUrl(attachment)"
69
- @click="openPreview(attachment,index)"
70
- :z-index="999999"
71
- />
72
- </a>
73
- <a href="javascript:void(0);" class="del" @click="deleteFile(index)"
74
- v-if="$attrs.edit !== false && $attrs.edit !== 'false'"><i class="el-icon-error"></i></a>
75
- </template>
76
- </div>
77
- <div class="el-upload el-upload--picture" style="vertical-align: middle;display: inline-block;float:left"
78
- v-if="$attrs.edit !== false && $attrs.edit !== 'false'">
79
- <button
80
- type="button"
81
- class=" avatar-uploader"
82
- v-if="showUploadBtn"
83
- @keyup.prevent
84
- @keydown.enter.prevent
85
- @click="
86
- $baseUpload.open({
87
- ..._props,
88
- ...$attrs,
89
- limit: limit,
90
- multi:multi,
91
- accept: accept ? accept : 'file',
92
- auto: auto,
93
- size: fileMaxSize,
94
- chunkSize: chunkSize,
95
- callback: fileConfirm,
96
- pickPrivateProfile:pickPrivateProfile,
97
- confirmUpload:confirmUpload,
98
- otherParams:$attrs
99
- })
100
- "
101
- >
102
- <i class="el-icon-plus avatar-uploader-icon"></i>
103
- </button>
104
- </div>
105
- </div>
106
- <propertiesDialog v-if="showPropertiesDialog" :visiable.sync="showPropertiesDialog"
107
- :editAttachment.sync="editAttachment" :edit.sync="$attrs.edit"></propertiesDialog>
108
- <el-image-viewer v-if="showViewer" :on-close="closeViewer" :initial-index.sync="chooseIndex"
109
- :url-list="pictureDtoList"/>
110
- </div>
111
- </template>
112
-
113
- <script>
114
- import {viewMixins} from './mixins';
115
-
116
- export default {
117
- mixins: [viewMixins],
118
- components: {propertiesDialog: () => import('./propertiesDialog.vue'), ElImageViewer: () => import('./image-viewer')},
119
- computed:{
120
- classList(){
121
- // 'upload-img': this.dataType || (this.$attrs.hideInfo == true || this.$attrs.hideInfo == 'true')
122
- let arr = [];
123
- if(this.dataType || (this.$attrs.hideInfo == true || this.$attrs.hideInfo == 'true')){
124
- arr.push('upload-img')
125
- }
126
- let widgetSize = this.$attrs.widgetSize || 2
127
- if(widgetSize){
128
- let str1 = "widgetSize-" + widgetSize
129
- arr.push(str1)
130
- }
131
- return arr
132
- },
133
- }
134
- };
135
- </script>
1
+ <template>
2
+ <div>
3
+ <div id="uploadImage" :class="classList">
4
+ <div class="upload-list" model="singer" v-for="(attachment, index) in attachments" :key="index"
5
+ style="display: inline-block;vertical-align: middle;float: left;">
6
+ <template v-if="$attrs.hideInfo !== true && $attrs.hideInfo !== 'true'">
7
+ <div class="upload-box">
8
+ <ul class="el-upload-list el-upload-list--picture">
9
+ <li tabindex="0" class="el-upload-list__item">
10
+ <div>
11
+ <div class="el-upload-list__item-thumbnail">
12
+ <div class="show-video" v-if="hasPreview(attachment)" @click="openPreview(attachment,index)"><i
13
+ class="icon-chakan"></i></div>
14
+ <p>
15
+ <el-image
16
+ :src="getShowUrl(attachment)"
17
+ @click="openPreview(attachment,index)"
18
+ :z-index="999999"
19
+ />
20
+ </p>
21
+ </div>
22
+ <div class="el-upload-list__item-name">
23
+ <el-tooltip :enterable="false" class="item" effect="dark" :content="getAttachmentName(attachment)"
24
+ placement="top">
25
+ <p v-if="$attrs.hideName !== true">{{ getAttachmentName(attachment) }}</p>
26
+ </el-tooltip>
27
+ <p v-if="$attrs.showSize === true || $attrs.showSize === 'true'">
28
+ {{ formatFileSize(attachment.fileSize) }}</p>
29
+ <!-- <p v-if="$attrs.showSortInput !== true && !dataType && $attrs.createBy !== false">
30
+ {{ attachment.createBy }}</p>-->
31
+ <p v-if="$attrs.showSortInput !== true && !dataType && $attrs.createDate !== false">
32
+ {{ attachment.createDate }}</p>
33
+ </div>
34
+ <div class="el-upload-input" v-if="$attrs.showSortInput">
35
+ <base-input-number v-model="attachment.orders" class="button-sty"
36
+ :placeholder="$t2('序号', 'components.VabUpload.orders')" :scale="0"/>
37
+ </div>
38
+ <div class="el-upload-input" v-if="$attrs.showNameInput">
39
+ <el-input v-model="attachment.name" class="button-sty"
40
+ :placeholder="$t2('请输入名称', 'components.VabUpload.name')" :scale="0"/>
41
+ </div>
42
+ <div class="el-upload-list__item-status-label"><i class="el-icon-upload-success el-icon-check"></i>
43
+ </div>
44
+ <div class="el-icon-close" @click="deleteFile(index)"
45
+ v-if="$attrs.edit !== false && $attrs.edit !== 'false' && attachment.h5!==1">
46
+ <i class="el-tooltip iconfont iconshanchu" aria-describedby="el-tooltip-6144" tabindex="0"></i>
47
+ </div>
48
+ <div class="el-icon-tagEdit" v-if="attachment.h5!==1">
49
+ <el-tooltip class="item" effect="dark" :content="$t2('下载', 'system.button.download')"
50
+ placement="top">
51
+ <i class="el-icon-download"
52
+ @click="downloadFile(attachment)"></i>
53
+ </el-tooltip>
54
+ <el-tooltip class="item" effect="dark" :content="$t2('详情', 'components.VabUpload.detail')"
55
+ placement="top"
56
+ v-if="attachment && attachment.id && $attrs.showProperties!==false && !dataType">
57
+ <i class="iconfont icon-shuxing" @click="openPropertiesDialog(attachment)"></i>
58
+ </el-tooltip>
59
+ </div>
60
+ </div>
61
+ </li>
62
+ </ul>
63
+ </div>
64
+ </template>
65
+ <template v-else>
66
+ <a>
67
+ <el-image
68
+ :src="getShowUrl(attachment)"
69
+ @click="openPreview(attachment,index)"
70
+ :z-index="999999"
71
+ />
72
+ </a>
73
+ <a href="javascript:void(0);" class="del" @click="deleteFile(index)"
74
+ v-if="$attrs.edit !== false && $attrs.edit !== 'false'"><i class="el-icon-error"></i></a>
75
+ </template>
76
+ </div>
77
+ <div class="el-upload el-upload--picture" style="vertical-align: middle;display: inline-block;float:left"
78
+ v-if="$attrs.edit !== false && $attrs.edit !== 'false'">
79
+ <button
80
+ type="button"
81
+ class=" avatar-uploader"
82
+ v-if="showUploadBtn"
83
+ @keyup.prevent
84
+ @keydown.enter.prevent
85
+ @click="
86
+ $baseUpload.open({
87
+ ..._props,
88
+ ...$attrs,
89
+ limit: limit,
90
+ multi:multi,
91
+ accept: accept ? accept : 'file',
92
+ auto: auto,
93
+ size: fileMaxSize,
94
+ chunkSize: chunkSize,
95
+ callback: fileConfirm,
96
+ pickPrivateProfile:pickPrivateProfile,
97
+ confirmUpload:confirmUpload,
98
+ otherParams:$attrs
99
+ })
100
+ "
101
+ >
102
+ <i class="el-icon-plus avatar-uploader-icon"></i>
103
+ </button>
104
+ </div>
105
+ </div>
106
+ <propertiesDialog v-if="showPropertiesDialog" :visiable.sync="showPropertiesDialog"
107
+ :editAttachment.sync="editAttachment" :edit.sync="$attrs.edit"></propertiesDialog>
108
+ <el-image-viewer v-if="showViewer" :on-close="closeViewer" :initial-index.sync="chooseIndex"
109
+ :url-list="pictureDtoList"/>
110
+ </div>
111
+ </template>
112
+
113
+ <script>
114
+ import {viewMixins} from './mixins';
115
+
116
+ export default {
117
+ mixins: [viewMixins],
118
+ components: {propertiesDialog: () => import('./propertiesDialog.vue'), ElImageViewer: () => import('./image-viewer')},
119
+ computed:{
120
+ classList(){
121
+ // 'upload-img': this.dataType || (this.$attrs.hideInfo == true || this.$attrs.hideInfo == 'true')
122
+ let arr = [];
123
+ if(this.dataType || (this.$attrs.hideInfo == true || this.$attrs.hideInfo == 'true')){
124
+ arr.push('upload-img')
125
+ }
126
+ let widgetSize = this.$attrs.widgetSize || 2
127
+ if(widgetSize){
128
+ let str1 = "widgetSize-" + widgetSize
129
+ arr.push(str1)
130
+ }
131
+ return arr
132
+ },
133
+ }
134
+ };
135
+ </script>
@@ -2538,6 +2538,115 @@ modules = {
2538
2538
  async exportPdf() {
2539
2539
  // statusEl.style.display = 'block';
2540
2540
  // statusEl.textContent = '正在准备导出内容...';
2541
+ const loadingObj = this.$baseLoading();
2542
+ try {
2543
+ // 获取要导出的元素
2544
+ const element = this.$parent.$el;
2545
+ // 计算内容总高度
2546
+
2547
+
2548
+ // 克隆元素(不影响原始页面)
2549
+ // statusEl.textContent = '克隆内容...';
2550
+
2551
+
2552
+ const constainter = this.$parent.$parent.$el;
2553
+
2554
+
2555
+ const clonedElement = element.cloneNode(true);
2556
+ let wfTab = clonedElement.querySelector(".wf-tab");
2557
+ if(wfTab)wfTab.remove()
2558
+
2559
+ clonedElement.style.width = element.offsetWidth + 'px';
2560
+
2561
+ // 应用样式以展开内容
2562
+ clonedElement.style.height = 'auto';
2563
+ clonedElement.style.overflow = 'visible';
2564
+ clonedElement.style.position = 'absolute';
2565
+ clonedElement.style.left = '-9999px';
2566
+ // document.body.appendChild(clonedElement);
2567
+ // document.body.appendChild(constainter);
2568
+
2569
+ constainter.appendChild(clonedElement)
2570
+
2571
+ const contentHeight = clonedElement.scrollHeight;
2572
+ const contentWidth = clonedElement.offsetWidth;
2573
+
2574
+ // 设置PDF参数
2575
+ const pdf = new JsPDF('p', 'mm', 'a4');
2576
+ const pageWidth = pdf.internal.pageSize.getWidth();
2577
+ const pageHeight = pdf.internal.pageSize.getHeight();
2578
+ const padding = 10;
2579
+
2580
+
2581
+
2582
+ // 计算需要多少页
2583
+ const scale = pageWidth / contentWidth;
2584
+ const scaledHeight = contentHeight * scale;
2585
+ const pages = Math.ceil(scaledHeight / pageHeight);
2586
+
2587
+ // 分页捕获并添加到PDF
2588
+ // statusEl.textContent = '正在生成PDF (0/' + pages + ')';
2589
+
2590
+ for (let i = 0; i < pages; i++) {
2591
+ // 计算当前页的裁剪位置
2592
+ const position = i * pageHeight / scale;
2593
+
2594
+ // 使用html2canvas捕获当前页内容
2595
+ const canvas = await html2Canvas(clonedElement, {
2596
+ scale: 2,
2597
+ // useCORS: true,
2598
+ windowHeight: pageHeight / scale,
2599
+ y: position,
2600
+ height: pageHeight / scale,
2601
+ width: contentWidth,
2602
+ logging: false
2603
+ });
2604
+
2605
+ // 将canvas转换为图像
2606
+ const imgData = canvas.toDataURL('image/jpeg', 0.95);
2607
+
2608
+ // 添加新页面(第一页除外)
2609
+ if (i > 0) {
2610
+ pdf.addPage();
2611
+ }
2612
+
2613
+ // 将图像添加到PDF
2614
+ pdf.addImage(imgData, 'JPEG', padding, padding, pageWidth - 2*padding, pageHeight - 2*padding);
2615
+
2616
+ // statusEl.textContent = '正在生成PDF (' + (i+1) + '/' + pages + ')';
2617
+ }
2618
+
2619
+ // 移除克隆元素
2620
+ // document.body.removeChild(constainter);
2621
+ constainter.removeChild(clonedElement);
2622
+
2623
+ // 保存PDF
2624
+ // statusEl.textContent = '正在保存文件...';
2625
+ let fileName = this.reportTemplate.formName+".pdf";
2626
+ pdf.save(fileName);
2627
+
2628
+ // statusEl.textContent = 'PDF导出成功!';
2629
+ // statusEl.style.background = '#e8f5e9';
2630
+ // statusEl.style.color = '#2e7d32';
2631
+
2632
+ // 3秒后隐藏状态
2633
+ /* setTimeout(() => {
2634
+ statusEl.style.display = 'none';
2635
+ }, 3000); */
2636
+
2637
+ } catch (error) {
2638
+ console.error('导出失败:', error);
2639
+ // statusEl.textContent = '导出失败: ' + error.message;
2640
+ // statusEl.style.background = '#ffebee';
2641
+ // statusEl.style.color = '#c62828';
2642
+ }finally{
2643
+ loadingObj.close();
2644
+ }
2645
+ },
2646
+
2647
+ async exportPdf1() {
2648
+ // statusEl.style.display = 'block';
2649
+ // statusEl.textContent = '正在准备导出内容...';
2541
2650
 
2542
2651
  try {
2543
2652
 
@@ -2557,6 +2666,18 @@ modules = {
2557
2666
  let wfTab = clonedElement.querySelector(".wf-tab");
2558
2667
  if(wfTab)wfTab.remove()
2559
2668
 
2669
+
2670
+ const scrollElements = clonedElement.querySelectorAll('.vxe-table--body-wrapper')
2671
+
2672
+ // 临时禁用虚拟滚动
2673
+ /* for(let scrollElement of scrollElements){
2674
+ const originalScrollTop = scrollElement.scrollTop
2675
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
2676
+ scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
2677
+ // scrollElement.style["max-height"] = 'inherit !important'
2678
+ scrollElement.scrollTop = 0
2679
+ } */
2680
+
2560
2681
  clonedElement.style.width = element.offsetWidth + 'px';
2561
2682
 
2562
2683
  // 应用样式以展开内容
@@ -2567,6 +2688,114 @@ modules = {
2567
2688
  // document.body.appendChild(clonedElement);
2568
2689
  // document.body.appendChild(constainter);
2569
2690
 
2691
+
2692
+ /* let dom1 = clonedElement.querySelector(".detail-wrap")
2693
+ debugger
2694
+ if(dom1){
2695
+ debugger
2696
+ let dom2 = dom1.children[1];
2697
+ dom2.style.height = "auto;"
2698
+ dom2.querySelector(".d-cont").style.height = "auto;"
2699
+
2700
+ } */
2701
+
2702
+ constainter.appendChild(clonedElement)
2703
+
2704
+ html2Canvas(clonedElement, {
2705
+ scrollY: 0,
2706
+ useCORS: true,
2707
+ allowTaint: true,
2708
+ scale: 2 // 提高分辨率
2709
+ }).then(canvas => {
2710
+ const pdf = new JsPDF('p', 'mm', 'a4')
2711
+ const imgData = canvas.toDataURL('image/png')
2712
+ const imgWidth = 210 // A4宽度
2713
+ const imgHeight = (canvas.height * imgWidth) / canvas.width
2714
+
2715
+ // 分页处理
2716
+ let heightLeft = imgHeight
2717
+ let position = 0
2718
+ pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight)
2719
+
2720
+ while (heightLeft > 0) {
2721
+ position = heightLeft - imgHeight
2722
+ pdf.addPage()
2723
+ pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight)
2724
+ heightLeft -= 297 // A4高度
2725
+ }
2726
+
2727
+ pdf.save(`导出.pdf`)
2728
+
2729
+ constainter.removeChild(clonedElement);
2730
+ })
2731
+
2732
+ } catch (error) {
2733
+ console.error('导出失败:', error);
2734
+ // statusEl.textContent = '导出失败: ' + error.message;
2735
+ // statusEl.style.background = '#ffebee';
2736
+ // statusEl.style.color = '#c62828';
2737
+ }
2738
+ },
2739
+ async exportPdf2() {
2740
+ // statusEl.style.display = 'block';
2741
+ // statusEl.textContent = '正在准备导出内容...';
2742
+
2743
+ try {
2744
+
2745
+ // 获取要导出的元素
2746
+ const element = this.$parent.$el;
2747
+ // 计算内容总高度
2748
+
2749
+
2750
+ // 克隆元素(不影响原始页面)
2751
+ // statusEl.textContent = '克隆内容...';
2752
+
2753
+
2754
+ const constainter = this.$parent.$parent.$el;
2755
+
2756
+
2757
+ const clonedElement = element.cloneNode(true);
2758
+ let wfTab = clonedElement.querySelector(".wf-tab");
2759
+ if(wfTab)wfTab.remove()
2760
+
2761
+
2762
+ const scrollElements = clonedElement.querySelectorAll('.vxe-table--body-wrapper')
2763
+
2764
+ // 临时禁用虚拟滚动
2765
+ /* for(let scrollElement of scrollElements){
2766
+ const originalScrollTop = scrollElement.scrollTop
2767
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
2768
+ // scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
2769
+ scrollElement.style["overflow"] = 'visible'
2770
+ scrollElement.style["max-height"] = 'inherit !important'
2771
+ scrollElement.scrollTop = 0
2772
+ } */
2773
+
2774
+
2775
+ let dom4 = clonedElement.querySelector(".designer-view")
2776
+ // dom4.style.height = "auto;"
2777
+ let dom1 = clonedElement.querySelector(".detail-wrap")
2778
+ debugger
2779
+ if(dom1){
2780
+ debugger
2781
+ // designer-view
2782
+ let dom2 = dom1.children[1];
2783
+ dom2.style.height = "auto;"
2784
+ dom2.querySelector(".d-cont").style.height = "auto;"
2785
+
2786
+ }
2787
+
2788
+ clonedElement.style.width = element.offsetWidth + 'px';
2789
+
2790
+ // 应用样式以展开内容
2791
+ clonedElement.style.height = 'auto';
2792
+ clonedElement.style.overflow = 'visible';
2793
+ clonedElement.style.position = 'absolute';
2794
+ // clonedElement.style.left = '-9999px';
2795
+ clonedElement.style.left = '100px';
2796
+ // document.body.appendChild(clonedElement);
2797
+ // document.body.appendChild(constainter);
2798
+
2570
2799
  constainter.appendChild(clonedElement)
2571
2800
 
2572
2801
  const contentHeight = clonedElement.scrollHeight;
@@ -2585,9 +2814,9 @@ modules = {
2585
2814
  const scaledHeight = contentHeight * scale;
2586
2815
  const pages = Math.ceil(scaledHeight / pageHeight);
2587
2816
 
2817
+ debugger
2588
2818
  // 分页捕获并添加到PDF
2589
2819
  // statusEl.textContent = '正在生成PDF (0/' + pages + ')';
2590
-
2591
2820
  for (let i = 0; i < pages; i++) {
2592
2821
  // 计算当前页的裁剪位置
2593
2822
  const position = i * pageHeight / scale;
@@ -2640,6 +2869,204 @@ modules = {
2640
2869
  // statusEl.style.background = '#ffebee';
2641
2870
  // statusEl.style.color = '#c62828';
2642
2871
  }
2872
+ },
2873
+ async exportPdf4() {
2874
+ // statusEl.style.display = 'block';
2875
+ // statusEl.textContent = '正在准备导出内容...';
2876
+
2877
+ try {
2878
+
2879
+ // 获取要导出的元素
2880
+ const element = this.$parent.$el;
2881
+ // 计算内容总高度
2882
+
2883
+
2884
+ // 克隆元素(不影响原始页面)
2885
+ // statusEl.textContent = '克隆内容...';
2886
+
2887
+
2888
+ const constainter = this.$parent.$parent.$el;
2889
+
2890
+
2891
+ const clonedElement = element.cloneNode(true);
2892
+ let wfTab = clonedElement.querySelector(".wf-tab");
2893
+ if(wfTab)wfTab.remove()
2894
+
2895
+
2896
+ const scrollElements = clonedElement.querySelectorAll('.vxe-table--body-wrapper')
2897
+
2898
+ // 临时禁用虚拟滚动
2899
+ for(let scrollElement of scrollElements){
2900
+ const originalScrollTop = scrollElement.scrollTop
2901
+ // scrollElement.style = 'overflow:visible;max-height:inherit !important'
2902
+ // scrollElement.style = scrollElement.style+ 'overflow:visible;max-height:inherit !important;'
2903
+ scrollElement.style["overflow"] = 'visible'
2904
+ scrollElement.style["max-height"] = 'inherit !important'
2905
+ scrollElement.scrollTop = 0
2906
+ }
2907
+
2908
+
2909
+ let dom4 = clonedElement.querySelector(".designer-view")
2910
+ // dom4.style.height = "auto;"
2911
+ let dom1 = clonedElement.querySelector(".detail-wrap")
2912
+ debugger
2913
+ if(dom1){
2914
+ debugger
2915
+ // designer-view
2916
+ let dom2 = dom1.children[1];
2917
+ dom2.style.height = "auto;"
2918
+ dom2.querySelector(".d-cont").style.height = "auto;"
2919
+
2920
+ }
2921
+
2922
+ clonedElement.style.width = element.offsetWidth + 'px';
2923
+
2924
+ // 应用样式以展开内容
2925
+ clonedElement.style.height = 'auto';
2926
+ clonedElement.style.overflow = 'visible';
2927
+ clonedElement.style.position = 'absolute';
2928
+ // clonedElement.style.left = '-9999px';
2929
+ clonedElement.style.left = '100px';
2930
+ // document.body.appendChild(clonedElement);
2931
+ // document.body.appendChild(constainter);
2932
+
2933
+ constainter.appendChild(clonedElement)
2934
+
2935
+
2936
+ const canvas = await html2Canvas(clonedElement, {
2937
+ scale: 2,
2938
+ useCORS: true,
2939
+ logging: false,
2940
+ onclone: (clonedDoc) => {
2941
+
2942
+ }
2943
+ });
2944
+
2945
+
2946
+ // 移除克隆元素
2947
+ // document.body.removeChild(constainter);
2948
+ constainter.removeChild(clonedElement);
2949
+
2950
+ // 5. 生成PDF
2951
+ this.currentStep = '创建PDF文档...';
2952
+ this.progress = 70;
2953
+
2954
+ const imgData = canvas.toDataURL('image/jpeg', 0.95);
2955
+ const pdf = new JsPDF('p', 'mm', 'a4');
2956
+
2957
+ const pageWidth = pdf.internal.pageSize.getWidth();
2958
+ const pageHeight = pdf.internal.pageSize.getHeight();
2959
+
2960
+ // const imgWidth = canvas.width;
2961
+ const imgWidth = element.offsetWidth;
2962
+ const imgHeight = canvas.height;
2963
+
2964
+ const ratio = pageWidth / imgWidth;
2965
+ const imgHeightOnPDF = imgHeight * ratio;
2966
+
2967
+ // 计算需要多少页
2968
+ let totalPages = Math.ceil(imgHeightOnPDF / pageHeight);
2969
+ let position = 0;
2970
+
2971
+ // 添加第一页
2972
+ pdf.addImage(imgData, 'JPEG', 0, position, pageWidth, imgHeightOnPDF);
2973
+
2974
+ // 添加额外页面(如果需要)
2975
+ for (let i = 1; i < totalPages; i++) {
2976
+ position -= pageHeight;
2977
+ pdf.addPage();
2978
+ pdf.addImage(imgData, 'JPEG', 0, position, pageWidth, imgHeightOnPDF);
2979
+ }
2980
+
2981
+ this.pdfPages = totalPages;
2982
+
2983
+ // 6. 生成预览
2984
+ this.currentStep = '生成预览...';
2985
+ this.progress = 90;
2986
+
2987
+ const pdfBlob = pdf.output('blob');
2988
+ this.pdfPreviewUrl = URL.createObjectURL(pdfBlob);
2989
+
2990
+ // 7. 自动下载
2991
+ pdf.save('exported-content.pdf');
2992
+
2993
+ this.progress = 100;
2994
+ setTimeout(() => {
2995
+ this.isExporting = false;
2996
+ }, 500);
2997
+
2998
+ } catch (error) {
2999
+ console.error('导出失败:', error);
3000
+ // statusEl.textContent = '导出失败: ' + error.message;
3001
+ // statusEl.style.background = '#ffebee';
3002
+ // statusEl.style.color = '#c62828';
3003
+ }
3004
+ },
3005
+ async exportPdf5() {
3006
+ try {
3007
+ // 获取要导出的元素
3008
+ const element = this.$parent.$el;
3009
+ // 计算内容总高度
3010
+
3011
+
3012
+ // 克隆元素(不影响原始页面)
3013
+ // statusEl.textContent = '克隆内容...';
3014
+
3015
+
3016
+ const constainter = this.$parent.$parent.$el;
3017
+ // 获取dom元素
3018
+ // const dom = document.querySelector('#id名称')
3019
+ if (element) {
3020
+ html2Canvas(element).then(async canvas => {
3021
+ // A4纸,纵向
3022
+ let pdf = new JsPDF('p', 'mm', 'a4')
3023
+ let ctx = canvas.getContext('2d')
3024
+ let a4w = 190
3025
+ // A4大小,210mm x 297mm,四边各保留10mm的边距,显示区域190x277
3026
+ let a4h = 277
3027
+ // 按A4显示比例换算一页图像的像素高度
3028
+ let imgHeight = Math.floor((a4h * canvas.width) / a4w)
3029
+ let renderedHeight = 0
3030
+ while (renderedHeight < canvas.height) {
3031
+ let page = document.createElement('canvas')
3032
+ page.width = canvas.width
3033
+ // 可能内容不足一页
3034
+ page.height = Math.min(imgHeight, canvas.height - renderedHeight)
3035
+ // 用getImageData剪裁指定区域,并画到前面创建的canvas对象中
3036
+ page.getContext('2d').putImageData(
3037
+ ctx.getImageData(
3038
+ 0,
3039
+ renderedHeight,
3040
+ canvas.width,
3041
+ Math.min(imgHeight, canvas.height - renderedHeight)
3042
+ ),
3043
+ 0,
3044
+ 0
3045
+ )
3046
+ // 添加图像到页面,保留10mm边距
3047
+ pdf.addImage(
3048
+ page.toDataURL('image/jpeg', 1.0),
3049
+ 'JPEG',
3050
+ 10,
3051
+ 10,
3052
+ a4w,
3053
+ Math.min(a4h, (a4w * page.height) / page.width)
3054
+ )
3055
+
3056
+ renderedHeight += imgHeight
3057
+ if (renderedHeight < canvas.height) {
3058
+ // 如果后面还有内容,添加一个空页
3059
+ pdf.addPage()
3060
+ }
3061
+ // delete page;
3062
+ }
3063
+ // 保存文件
3064
+ pdf.save('文档名称.pdf')
3065
+ })
3066
+ }
3067
+ } catch (err) {
3068
+ console.log(err)
3069
+ }
2643
3070
  }
2644
3071
  }
2645
3072
  };
@@ -0,0 +1,71 @@
1
+ import html2canvas from "html2canvas";
2
+ import jspdf from "jspdf";
3
+ export async function exportPDF(option) {
4
+ const dom = option.dom;
5
+ let fileName = option.fileName;
6
+ if (!dom) return
7
+ let height = "";
8
+ // 获取dom元素
9
+ let dom1 = dom.querySelector(".d-cont");
10
+ try {
11
+ if (dom1) {
12
+ height = dom1.style.height;
13
+ dom1.style.height = "auto";
14
+ }
15
+
16
+ if (dom) {
17
+ html2canvas(dom).then(async (canvas) => {
18
+ // A4纸,纵向
19
+ let pdf = new jspdf("p", "mm", "a4");
20
+ let ctx = canvas.getContext("2d");
21
+ let a4w = 190;
22
+ // A4大小,210mm x 297mm,四边各保留10mm的边距,显示区域190x277
23
+ let a4h = 277;
24
+ // 按A4显示比例换算一页图像的像素高度
25
+ let imgHeight = Math.floor((a4h * canvas.width) / a4w);
26
+ let renderedHeight = 0;
27
+ while (renderedHeight < canvas.height) {
28
+ let page = document.createElement("canvas");
29
+ page.width = canvas.width;
30
+ // 可能内容不足一页
31
+ page.height = Math.min(imgHeight, canvas.height - renderedHeight);
32
+ // 用getImageData剪裁指定区域,并画到前面创建的canvas对象中
33
+ page
34
+ .getContext("2d")
35
+ .putImageData(
36
+ ctx.getImageData(
37
+ 0,
38
+ renderedHeight,
39
+ canvas.width,
40
+ Math.min(imgHeight, canvas.height - renderedHeight)
41
+ ),
42
+ 0,
43
+ 0
44
+ );
45
+ // 添加图像到页面,保留10mm边距
46
+ pdf.addImage(
47
+ page.toDataURL("image/jpeg", 1.0),
48
+ "JPEG",
49
+ 10,
50
+ 10,
51
+ a4w,
52
+ Math.min(a4h, (a4w * page.height) / page.width)
53
+ );
54
+
55
+ renderedHeight += imgHeight;
56
+ if (renderedHeight < canvas.height) {
57
+ // 如果后面还有内容,添加一个空页
58
+ pdf.addPage();
59
+ }
60
+ // delete page;
61
+ }
62
+ // 保存文件
63
+ pdf.save(`${fileName}.pdf`);
64
+ });
65
+ }
66
+ } catch (err) {
67
+ console.log(err);
68
+ } finally {
69
+ if (dom1) dom1.style.height = height;
70
+ }
71
+ }