htui-yllkbz 1.2.38 → 1.2.39
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/lib/htui.common.js +1607 -91
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +1602 -86
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +388 -4
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +56 -54
- package/src/packages/HtCountDown/index.vue +55 -8
- package/src/packages/HtExportPdf/index.ts +16 -0
- package/src/packages/HtExportPdf/index.vue +46 -0
- package/src/packages/HtTable/index.vue +8 -2
- package/src/packages/index.ts +4 -3
- package/src/shims-vue.d.ts +6 -1
- package/src/unit/htmlToPdf.js +108 -0
- package/src/views/About.vue +43 -16
package/lib/htui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "htui-yllkbz",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"typings": "types/index.d.ts",
|
|
5
|
-
"main": "lib/htui.common.js",
|
|
6
|
-
"style": "lib/htui.css",
|
|
7
|
-
"private": false,
|
|
8
|
-
"files": [
|
|
9
|
-
"lib/**",
|
|
10
|
-
"types",
|
|
11
|
-
"src"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"serve": "vue-cli-service serve",
|
|
15
|
-
"build": "vue-cli-service build",
|
|
16
|
-
"lint": "vue-cli-service lint",
|
|
17
|
-
"lib": "vue-cli-service build --target lib --name htui --dest lib src/packages/index.ts",
|
|
18
|
-
"publish": "npm run lib && npm publish",
|
|
19
|
-
"build-exports": "vue-cli-service build --dest dist/components --target wc-async --name xhsj src/exports/* --inline-vue"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"axios": "^0.21.0",
|
|
23
|
-
"core-js": "^3.6.5",
|
|
24
|
-
"element-ui": "^2.14.1",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"vue
|
|
31
|
-
"vue-
|
|
32
|
-
"vue-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@vue/cli-plugin-
|
|
41
|
-
"@vue/cli-
|
|
42
|
-
"@vue/
|
|
43
|
-
"@vue/
|
|
44
|
-
"
|
|
45
|
-
"eslint": "^
|
|
46
|
-
"
|
|
47
|
-
"eslint
|
|
48
|
-
"prettier": "^1.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "htui-yllkbz",
|
|
3
|
+
"version": "1.2.39",
|
|
4
|
+
"typings": "types/index.d.ts",
|
|
5
|
+
"main": "lib/htui.common.js",
|
|
6
|
+
"style": "lib/htui.css",
|
|
7
|
+
"private": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"lib/**",
|
|
10
|
+
"types",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"serve": "vue-cli-service serve",
|
|
15
|
+
"build": "vue-cli-service build",
|
|
16
|
+
"lint": "vue-cli-service lint",
|
|
17
|
+
"lib": "vue-cli-service build --target lib --name htui --dest lib src/packages/index.ts",
|
|
18
|
+
"publish": "npm run lib && npm publish",
|
|
19
|
+
"build-exports": "vue-cli-service build --dest dist/components --target wc-async --name xhsj src/exports/* --inline-vue"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^0.21.0",
|
|
23
|
+
"core-js": "^3.6.5",
|
|
24
|
+
"element-ui": "^2.14.1",
|
|
25
|
+
"html2canvas": "1.0.0-rc.1",
|
|
26
|
+
"htui-yllkbz": "^1.2.35",
|
|
27
|
+
"jspdf": "^1.5.3",
|
|
28
|
+
"mavon-editor": "^2.10.4",
|
|
29
|
+
"moment": "^2.29.1",
|
|
30
|
+
"vue": "^2.6.11",
|
|
31
|
+
"vue-class-component": "^7.2.3",
|
|
32
|
+
"vue-kst-auth": "^2.1.15",
|
|
33
|
+
"vue-property-decorator": "^8.4.2",
|
|
34
|
+
"vue-router": "^3.2.0",
|
|
35
|
+
"vuex": "^3.4.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
|
39
|
+
"@typescript-eslint/parser": "^2.33.0",
|
|
40
|
+
"@vue/cli-plugin-babel": "^4.5.0",
|
|
41
|
+
"@vue/cli-plugin-eslint": "^4.5.0",
|
|
42
|
+
"@vue/cli-plugin-typescript": "^4.5.0",
|
|
43
|
+
"@vue/cli-service": "^4.5.0",
|
|
44
|
+
"@vue/eslint-config-prettier": "^6.0.0",
|
|
45
|
+
"@vue/eslint-config-typescript": "^5.0.2",
|
|
46
|
+
"compression-webpack-plugin": "^3.0.0",
|
|
47
|
+
"eslint": "^6.7.2",
|
|
48
|
+
"eslint-plugin-prettier": "^3.1.3",
|
|
49
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
50
|
+
"prettier": "^1.19.1",
|
|
51
|
+
"sass": "^1.26.5",
|
|
52
|
+
"sass-loader": "^8.0.2",
|
|
53
|
+
"typescript": "~3.9.3",
|
|
54
|
+
"vue-template-compiler": "^2.6.11"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-12-21 16:24:07
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2021-12-
|
|
7
|
+
* @LastEditTime: 2021-12-29 10:11:23
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
@@ -32,6 +32,10 @@ export default class HtCountDown extends Vue {
|
|
|
32
32
|
@Prop() times!: number;
|
|
33
33
|
/** 是否启动 */
|
|
34
34
|
@Prop() start?: boolean;
|
|
35
|
+
/** 是否是秒表 */
|
|
36
|
+
@Prop() stopwatch?: boolean;
|
|
37
|
+
/** 刷新频率 --默认1000毫秒 */
|
|
38
|
+
@Prop() frequency?: number;
|
|
35
39
|
|
|
36
40
|
/** 数据 */
|
|
37
41
|
state: State = {
|
|
@@ -39,16 +43,49 @@ export default class HtCountDown extends Vue {
|
|
|
39
43
|
count: 0,
|
|
40
44
|
};
|
|
41
45
|
timer: any = undefined;
|
|
46
|
+
|
|
42
47
|
created() {
|
|
43
48
|
/** 如果是传入的秒数 */
|
|
49
|
+
|
|
50
|
+
if (!this.stopwatch) {
|
|
51
|
+
if (this.times) {
|
|
52
|
+
this.state.count = this.times;
|
|
53
|
+
}
|
|
54
|
+
/** 如果传入的是哪一天 */
|
|
55
|
+
if (this.date) {
|
|
56
|
+
const sec =
|
|
57
|
+
(new Date(this.date).getTime() - new Date().getTime()) / 1000;
|
|
58
|
+
this.state.count = sec > 0 ? sec : 0;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
//如果是秒表则启动秒表计时:
|
|
62
|
+
this.startStopWatch(true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** 秒表 */
|
|
66
|
+
startStopWatch(reset: boolean) {
|
|
67
|
+
if (reset) {
|
|
68
|
+
this.state.count = 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.timer = setInterval(() => {
|
|
72
|
+
this.state.count = parseFloat(
|
|
73
|
+
(this.state.count + this.getFrequency / 1000).toFixed(5)
|
|
74
|
+
);
|
|
75
|
+
}, this.getFrequency);
|
|
76
|
+
}
|
|
77
|
+
/** 重置 */
|
|
78
|
+
reset() {
|
|
44
79
|
if (this.times) {
|
|
80
|
+
clearInterval(this.timer);
|
|
45
81
|
this.state.count = this.times;
|
|
82
|
+
this.getTimer();
|
|
46
83
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.state.count = sec > 0 ? sec : 0;
|
|
84
|
+
if (this.stopwatch) {
|
|
85
|
+
clearInterval(this.timer);
|
|
86
|
+
this.startStopWatch(true);
|
|
51
87
|
}
|
|
88
|
+
//
|
|
52
89
|
}
|
|
53
90
|
/** 时间倒计时开始 */
|
|
54
91
|
getTimer() {
|
|
@@ -57,10 +94,14 @@ export default class HtCountDown extends Vue {
|
|
|
57
94
|
if (this.state.count === 0) {
|
|
58
95
|
clearInterval(this.timer);
|
|
59
96
|
}
|
|
60
|
-
},
|
|
97
|
+
}, this.getFrequency);
|
|
61
98
|
}
|
|
62
99
|
dateLess() {
|
|
63
100
|
const total: number = this.state.count;
|
|
101
|
+
|
|
102
|
+
if (this.stopwatch) {
|
|
103
|
+
return total;
|
|
104
|
+
}
|
|
64
105
|
if (!total) {
|
|
65
106
|
return "--";
|
|
66
107
|
}
|
|
@@ -110,15 +151,21 @@ export default class HtCountDown extends Vue {
|
|
|
110
151
|
(new Date(this.date).getTime() - new Date().getTime()) / 1000;
|
|
111
152
|
this.state.count = sec > 0 ? sec : 0;
|
|
112
153
|
}
|
|
113
|
-
if (
|
|
154
|
+
if (this.stopwatch) {
|
|
155
|
+
this.startStopWatch(false);
|
|
156
|
+
} else if (!this.date && !this.times) {
|
|
114
157
|
this.$notify.error("请先传入完成的参数");
|
|
115
158
|
return;
|
|
159
|
+
} else {
|
|
160
|
+
this.getTimer();
|
|
116
161
|
}
|
|
117
|
-
this.getTimer();
|
|
118
162
|
} else {
|
|
119
163
|
clearInterval(this.timer);
|
|
120
164
|
}
|
|
121
165
|
}
|
|
166
|
+
get getFrequency() {
|
|
167
|
+
return this.frequency || 1000;
|
|
168
|
+
}
|
|
122
169
|
}
|
|
123
170
|
</script>
|
|
124
171
|
<style lang='scss' scoped></style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:导出PDF
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-15 15:00:57
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-12-29 09:53:53
|
|
8
|
+
*/
|
|
9
|
+
import HtExportPdf from "./index.vue";
|
|
10
|
+
|
|
11
|
+
(HtExportPdf as any).install = function (Vue: any) {
|
|
12
|
+
|
|
13
|
+
Vue.component("HtExportPdf", HtExportPdf);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default HtExportPdf;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion: 导出PDF
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-09-02 09:03:43
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-12-29 14:25:39
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<div @click="exportPdf">
|
|
11
|
+
<slot>
|
|
12
|
+
<el-button type="primary">
|
|
13
|
+
导出PDF
|
|
14
|
+
</el-button>
|
|
15
|
+
</slot>
|
|
16
|
+
<div ref="demo">dsdsdsdsdsds</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<script lang='ts'>
|
|
20
|
+
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
21
|
+
import htmlToPdf from "@/unit/htmlToPdf.js";
|
|
22
|
+
/** 设置axios返回类型 */
|
|
23
|
+
Vue.config.productionTip = false;
|
|
24
|
+
interface State {
|
|
25
|
+
/** 数据状态 */
|
|
26
|
+
loading: boolean;
|
|
27
|
+
}
|
|
28
|
+
@Component
|
|
29
|
+
export default class HtExportPdf extends Vue {
|
|
30
|
+
/** 导出文件对应的id */
|
|
31
|
+
@Prop() selector!: string;
|
|
32
|
+
/** 文件导出名 */
|
|
33
|
+
@Prop() title!: string;
|
|
34
|
+
exportPdf(t: any) {
|
|
35
|
+
console.log("this.selector", this.selector, t);
|
|
36
|
+
if (!this.selector) {
|
|
37
|
+
this.$notify.error("请用selector传入需要导出的内容id");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.log('document.querySelector("#ht-pdf")', this.$refs.demo);
|
|
41
|
+
htmlToPdf.downloadPDF(t, this.title);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style lang='scss' scoped></style>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @Author: hutao
|
|
6
6
|
* @Date: 2021-11-11 11:23:24
|
|
7
7
|
* @LastEditors: hutao
|
|
8
|
-
* @LastEditTime:
|
|
8
|
+
* @LastEditTime: 2022-01-04 09:30:09
|
|
9
9
|
-->
|
|
10
10
|
<template>
|
|
11
11
|
<div v-loading="state.loading">
|
|
@@ -120,6 +120,13 @@
|
|
|
120
120
|
</div>
|
|
121
121
|
<span v-else>--</span>
|
|
122
122
|
</template>
|
|
123
|
+
<!-- 处理部门人员 -->
|
|
124
|
+
<template v-else-if="item.type==='boolean'">
|
|
125
|
+
<el-tag :type="'success'"
|
|
126
|
+
v-if="getPropByPath(row,item.key)">是</el-tag>
|
|
127
|
+
<el-tag type="danger"
|
|
128
|
+
v-else>否</el-tag>
|
|
129
|
+
</template>
|
|
123
130
|
<!-- 其他 -->
|
|
124
131
|
<span v-else>{{getPropByPath(row,item.key)}}</span>
|
|
125
132
|
</slot>
|
|
@@ -157,7 +164,6 @@
|
|
|
157
164
|
</template>
|
|
158
165
|
<script lang='ts'>
|
|
159
166
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
160
|
-
import { _axios } from "vue-kst-auth";
|
|
161
167
|
import { Column, PageInfoType } from "@/packages/type";
|
|
162
168
|
import PageInfo from "@/packages/PageInfo/index.vue";
|
|
163
169
|
interface State {
|
package/src/packages/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-10-21 10:08:41
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2021-12-
|
|
7
|
+
* @LastEditTime: 2021-12-29 09:55:45
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
// 导入组件
|
|
@@ -18,9 +18,10 @@ import HtExport from './HtExport/index'
|
|
|
18
18
|
import HtUpload from './HtUpload/index'
|
|
19
19
|
import HtMd from './HtMd/index'
|
|
20
20
|
import HtCountDown from './HtCountDown/index'
|
|
21
|
+
import HtExportPdf from './HtExportPdf/index'
|
|
21
22
|
|
|
22
23
|
// 存储组件列表
|
|
23
|
-
const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown]
|
|
24
|
+
const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf]
|
|
24
25
|
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
|
|
25
26
|
const install = function (Vue: any) {
|
|
26
27
|
// 判断是否安装
|
|
@@ -36,6 +37,6 @@ export default {
|
|
|
36
37
|
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
37
38
|
install,
|
|
38
39
|
// 以下是具体的组件列表
|
|
39
|
-
HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown
|
|
40
|
+
HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf
|
|
40
41
|
}
|
|
41
42
|
|
package/src/shims-vue.d.ts
CHANGED
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-11-15 14:41:40
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2021-12-
|
|
7
|
+
* @LastEditTime: 2021-12-29 10:23:59
|
|
8
8
|
*/
|
|
9
9
|
declare module "*.vue" {
|
|
10
10
|
import Vue from "vue";
|
|
11
11
|
export default Vue;
|
|
12
12
|
}
|
|
13
|
+
declare module "*.js" {
|
|
14
|
+
const body: any
|
|
15
|
+
|
|
16
|
+
export default body;
|
|
17
|
+
}
|
|
13
18
|
declare module "*.png"
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-12-29 09:52:58
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-12-29 14:15:53
|
|
8
|
+
*/
|
|
9
|
+
//不使用JQuery版的
|
|
10
|
+
|
|
11
|
+
import html2canvas from 'html2canvas';
|
|
12
|
+
import JsPDF from 'jspdf';
|
|
13
|
+
/**
|
|
14
|
+
* @param ele 要生成 pdf 的DOM元素(容器)
|
|
15
|
+
* @param padfName PDF文件生成后的文件名字
|
|
16
|
+
* */
|
|
17
|
+
|
|
18
|
+
function downloadPDF(ele, pdfName){
|
|
19
|
+
|
|
20
|
+
const eleW = ele.offsetWidth;// 获得该容器的宽
|
|
21
|
+
const eleH = ele.offsetHeight;// 获得该容器的高
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const eleOffsetTop = ele.offsetTop; // 获得该容器到文档顶部的距离
|
|
25
|
+
const eleOffsetLeft = ele.offsetLeft; // 获得该容器到文档最左的距离
|
|
26
|
+
|
|
27
|
+
const canvas = document.createElement("canvas");
|
|
28
|
+
let abs = 0;
|
|
29
|
+
|
|
30
|
+
const winIn = document.documentElement.clientWidth || document.body.clientWidth; // 获得当前可视窗口的宽度(不包含滚动条)
|
|
31
|
+
const winOut = window.innerWidth; // 获得当前窗口的宽度(包含滚动条)
|
|
32
|
+
|
|
33
|
+
if(winOut>winIn){
|
|
34
|
+
// abs = (win_o - win_i)/2; // 获得滚动条长度的一半
|
|
35
|
+
abs = (winOut - winIn)/2; // 获得滚动条宽度的一半
|
|
36
|
+
// console.log(a, '新abs');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
canvas.width = eleW * 2; // 将画布宽&&高放大两倍
|
|
40
|
+
canvas.height = eleH * 2;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const context = canvas.getContext("2d");
|
|
46
|
+
|
|
47
|
+
context.scale(2, 2);
|
|
48
|
+
|
|
49
|
+
context.translate(-eleOffsetLeft -abs, -eleOffsetTop);
|
|
50
|
+
// 这里默认横向没有滚动条的情况,因为offset.left(),有无滚动条的时候存在差值,因此
|
|
51
|
+
// translate的时候,要把这个差值去掉
|
|
52
|
+
|
|
53
|
+
// html2canvas(element).then( (canvas)=>{ //报错
|
|
54
|
+
// html2canvas(element[0]).then( (canvas)=>{
|
|
55
|
+
console.log('baocuo',);
|
|
56
|
+
html2canvas( ele, {
|
|
57
|
+
dpi: 300,
|
|
58
|
+
// allowTaint: true, //允许 canvas 污染, allowTaint参数要去掉,否则是无法通过toDataURL导出canvas数据的
|
|
59
|
+
useCORS:true //允许canvas画布内 可以跨域请求外部链接图片, 允许跨域请求。
|
|
60
|
+
}).then((canvas) => {
|
|
61
|
+
console.log('baocuo-------1',);
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
const contentWidth = canvas.width;
|
|
64
|
+
const contentHeight = canvas.height;
|
|
65
|
+
//一页pdf显示html页面生成的canvas高度;
|
|
66
|
+
const pageHeight = contentWidth / 592.28 * 841.89;
|
|
67
|
+
//未生成pdf的html页面高度
|
|
68
|
+
let leftHeight = contentHeight;
|
|
69
|
+
//页面偏移
|
|
70
|
+
let position = 0;
|
|
71
|
+
//a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
|
|
72
|
+
const imgWidth = 595.28;
|
|
73
|
+
const imgHeight = 595.28/contentWidth * contentHeight;
|
|
74
|
+
|
|
75
|
+
const pageData = canvas.toDataURL('image/jpeg', 1.0);
|
|
76
|
+
const pdf = new JsPDF('', 'pt', 'a4');
|
|
77
|
+
|
|
78
|
+
//有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
|
|
79
|
+
//当内容未超过pdf一页显示的范围,无需分页
|
|
80
|
+
if (leftHeight < pageHeight) {
|
|
81
|
+
//在pdf.addImage(pageData, 'JPEG', 左,上,宽度,高度)设置在pdf中显示;
|
|
82
|
+
pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);
|
|
83
|
+
// pdf.addImage(pageData, 'JPEG', 20, 40, imgWidth, imgHeight);
|
|
84
|
+
} else { // 分页
|
|
85
|
+
while(leftHeight > 0) {
|
|
86
|
+
pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight);
|
|
87
|
+
leftHeight -= pageHeight;
|
|
88
|
+
position -= 841.89;
|
|
89
|
+
//避免添加空白页
|
|
90
|
+
if(leftHeight > 0) {
|
|
91
|
+
pdf.addPage();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//可动态生成
|
|
97
|
+
pdf.save(pdfName);
|
|
98
|
+
},1000)
|
|
99
|
+
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export default {
|
|
107
|
+
downloadPDF
|
|
108
|
+
}
|
package/src/views/About.vue
CHANGED
|
@@ -4,33 +4,44 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-11-15 14:41:40
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime:
|
|
7
|
+
* @LastEditTime: 2022-01-04 09:31:44
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
11
|
-
<
|
|
12
|
-
|
|
11
|
+
<HtExportPdf selector="f"
|
|
12
|
+
ref="pdf"
|
|
13
|
+
:title="'测试'"></HtExportPdf>
|
|
14
|
+
<el-button type=""
|
|
15
|
+
@click="test">test</el-button>
|
|
16
|
+
<!-- <ht-count-down :stopwatch="true"
|
|
17
|
+
:frequency="200"
|
|
13
18
|
:start="!state.start">
|
|
14
19
|
<template slot-scope="{timeStr}">
|
|
15
20
|
{{timeStr}}
|
|
16
21
|
</template>
|
|
17
22
|
</ht-count-down>
|
|
18
|
-
|
|
23
|
+
<ht-count-down :stopwatch="true"
|
|
24
|
+
:start="!state.start">
|
|
25
|
+
<template slot-scope="{timeStr}">
|
|
26
|
+
{{timeStr}}
|
|
27
|
+
</template>
|
|
28
|
+
</ht-count-down> -->
|
|
19
29
|
|
|
20
30
|
<ht-md v-model="state.content"
|
|
21
31
|
:subfield="true"></ht-md>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
<div ref="ht-pdf">
|
|
33
|
+
<HtTable :data="state.data"
|
|
34
|
+
:height="200"
|
|
35
|
+
:columns="state.columns">
|
|
36
|
+
<div slot="sex"
|
|
37
|
+
slot-scope="{row}">{{row.sex?'男':'女'}}</div>
|
|
38
|
+
<div slot="age"
|
|
39
|
+
slot-scope="{row}">
|
|
40
|
+
<el-tag>{{row.age}}</el-tag>
|
|
41
|
+
</div>
|
|
42
|
+
<div slot="header_name">测试名字</div>
|
|
43
|
+
</HtTable>
|
|
44
|
+
</div>
|
|
34
45
|
<!-- <el-dropdown>
|
|
35
46
|
<el-select placeholder="请选择">
|
|
36
47
|
</el-select>
|
|
@@ -51,6 +62,7 @@
|
|
|
51
62
|
import { Component, Vue } from "vue-property-decorator";
|
|
52
63
|
import HtTable from "@/packages/HtTable/index.vue";
|
|
53
64
|
import HtCountDown from "@/packages/HtCountDown/index.vue";
|
|
65
|
+
import HtExportPdf from "@/packages/HtExportPdf/index.vue";
|
|
54
66
|
import HtUi from "htui-yllkbz";
|
|
55
67
|
import "htui-yllkbz/lib/htui.css";
|
|
56
68
|
Vue.use(HtUi);
|
|
@@ -66,6 +78,7 @@ interface State {
|
|
|
66
78
|
components: {
|
|
67
79
|
HtTable,
|
|
68
80
|
HtCountDown,
|
|
81
|
+
HtExportPdf,
|
|
69
82
|
},
|
|
70
83
|
})
|
|
71
84
|
export default class Index extends Vue {
|
|
@@ -143,10 +156,24 @@ export default class Index extends Vue {
|
|
|
143
156
|
],
|
|
144
157
|
};
|
|
145
158
|
/** 生命周期 */
|
|
159
|
+
created() {
|
|
160
|
+
//this.rewriteGetComputedStyle();
|
|
161
|
+
}
|
|
146
162
|
/** 方法 */
|
|
147
163
|
test() {
|
|
164
|
+
(this.$refs.pdf as any).exportPdf(this.$refs["ht-pdf"]);
|
|
148
165
|
//console.log("ee", e);
|
|
149
166
|
}
|
|
167
|
+
// rewriteGetComputedStyle() {
|
|
168
|
+
// const getComputedStyle = window.getComputedStyle;
|
|
169
|
+
// window.getComputedStyle = function (element: any, property) {
|
|
170
|
+
// console.log("element", element, typeof element);
|
|
171
|
+
// if (element != "localhost:8080") {
|
|
172
|
+
// return getComputedStyle(element.host || element, property);
|
|
173
|
+
// }
|
|
174
|
+
// return "";
|
|
175
|
+
// };
|
|
176
|
+
// }
|
|
150
177
|
save(e: string, f: string) {
|
|
151
178
|
console.log("e,f", e, f);
|
|
152
179
|
}
|