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

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,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
+ }
@@ -3,7 +3,7 @@
3
3
  <template v-if="layoutType=='PC'">
4
4
  <x-tabs ref="xTabs" v-model="activeName" class="tab-box">
5
5
  <el-tab-pane :label="$t2('常规')" name="first">
6
- <vFormRender :formCode="formCode2" :dataId.sync="dataId" :param="param" :formData="formData"
6
+ <vFormRender :formCode.sync="formCode1" :dataId.sync="dataId" :param="param" :formData="formData"
7
7
  v-if="showEdit" visible-key="showEdit" :parent-target="_self"
8
8
  @reload="reload" @openCopyEditTab="openCopyEditTab"></vFormRender>
9
9
  </el-tab-pane>
@@ -74,7 +74,9 @@ export default {
74
74
  /* formCode: null,*/
75
75
  layoutType: null,
76
76
  formCode: null,
77
+ formCode1: null,
77
78
  formCode2: null,
79
+ addFormCode:null,
78
80
  dataId: null,
79
81
  showEditDialog: false,
80
82
  param: {},
@@ -109,7 +111,13 @@ export default {
109
111
  let formJson = formTemplate.formViewContent ? JSON.parse(formTemplate.formViewContent) : {};
110
112
  this.formJson = formJson;
111
113
  this.layoutType = formJson.formConfig?.layoutType
114
+ let addFormCode = formJson.formConfig?.addFormCode ?? null;
112
115
  this.formCode2 = formJson.formConfig?.editFormCode ?? null;
116
+ debugger
117
+ if(!addFormCode) {
118
+ addFormCode = formCode2
119
+ }
120
+ this.addFormCode = addFormCode;
113
121
  this.multiTabLabelField = formJson.formConfig?.multiTabLabelField
114
122
  }
115
123
  });
@@ -126,6 +134,7 @@ export default {
126
134
  this.$refs.xTabs.openEditTab(row,param);
127
135
  }else{
128
136
  this.dataId = dataId
137
+ this.formCode1 = this.addFormCode;
129
138
  this.activeName = 'first';
130
139
  this.showEdit = false;
131
140
  this.showEditDialog = true;
@@ -136,6 +145,7 @@ export default {
136
145
 
137
146
  },
138
147
  openEditH5Dialog(row) {
148
+ this.formCode1 = this.addFormCode;
139
149
  this.dataId = row && row.id ? row.id : null;
140
150
  this.activeName = 'first';
141
151
  this.showEdit = false;
@@ -147,6 +157,7 @@ export default {
147
157
 
148
158
  openCopyEditTab(formData) {
149
159
  this.dataId = null
160
+ this.formCode1 = this.addFormCode;
150
161
  this.activeName = 'first';
151
162
  this.showEdit = false;
152
163
  this.showEditDialog = true;