htui-yllkbz 1.2.40 → 1.2.41

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htui-yllkbz",
3
- "version": "1.2.40",
3
+ "version": "1.2.41",
4
4
  "typings": "types/index.d.ts",
5
5
  "main": "lib/htui.common.js",
6
6
  "style": "lib/htui.css",
@@ -24,7 +24,6 @@
24
24
  "element-ui": "^2.14.1",
25
25
  "html2canvas": "1.0.0-rc.1",
26
26
  "htui-yllkbz": "^1.2.35",
27
- "jspdf": "^1.5.3",
28
27
  "mavon-editor": "^2.10.4",
29
28
  "moment": "^2.29.1",
30
29
  "vue": "^2.6.11",
@@ -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-29 09:55:45
7
+ * @LastEditTime: 2022-01-04 09:47:12
8
8
  */
9
9
 
10
10
  // 导入组件
@@ -18,10 +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
  // 存储组件列表
24
- const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf]
24
+ const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown]
25
25
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
26
26
  const install = function (Vue: any) {
27
27
  // 判断是否安装
@@ -37,6 +37,6 @@ export default {
37
37
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
38
38
  install,
39
39
  // 以下是具体的组件列表
40
- HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf
40
+ HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown
41
41
  }
42
42
 
@@ -68,7 +68,7 @@ export interface Column {
68
68
  hide?: boolean;
69
69
  /** 时间是否跨行展示 */
70
70
  spread?: boolean;
71
- /** 通过type展示相应的数据 用户id|部门id|时间格式化*/
71
+ /** 通过type展示相应的数据 用户id|部门id|时间格式化|是否布尔值*/
72
72
  type?: 'userId' | 'org' | 'time' | 'common' | 'booolean',
73
73
  /** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
74
74
  commonType?: 'userId' | 'departmentId' | 'baseDataId' | 'roleId' | 'baseDataName' | 'baseDataValue',
@@ -4,13 +4,11 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-11-15 14:41:40
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-01-04 09:31:44
7
+ * @LastEditTime: 2022-01-04 09:47:44
8
8
  -->
9
9
  <template>
10
10
  <div>
11
- <HtExportPdf selector="f"
12
- ref="pdf"
13
- :title="'测试'"></HtExportPdf>
11
+
14
12
  <el-button type=""
15
13
  @click="test">test</el-button>
16
14
  <!-- <ht-count-down :stopwatch="true"
@@ -62,7 +60,6 @@
62
60
  import { Component, Vue } from "vue-property-decorator";
63
61
  import HtTable from "@/packages/HtTable/index.vue";
64
62
  import HtCountDown from "@/packages/HtCountDown/index.vue";
65
- import HtExportPdf from "@/packages/HtExportPdf/index.vue";
66
63
  import HtUi from "htui-yllkbz";
67
64
  import "htui-yllkbz/lib/htui.css";
68
65
  Vue.use(HtUi);
@@ -78,7 +75,6 @@ interface State {
78
75
  components: {
79
76
  HtTable,
80
77
  HtCountDown,
81
- HtExportPdf,
82
78
  },
83
79
  })
84
80
  export default class Index extends Vue {
@@ -1,16 +0,0 @@
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;
@@ -1,46 +0,0 @@
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>
@@ -1,108 +0,0 @@
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
- }