htui-yllkbz 1.2.35 → 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.
Binary file
package/package.json CHANGED
@@ -1,52 +1,56 @@
1
- {
2
- "name": "htui-yllkbz",
3
- "version": "1.2.35",
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
- "mavon-editor": "^2.10.4",
26
- "vue": "^2.6.11",
27
- "vue-class-component": "^7.2.3",
28
- "vue-kst-auth": "^2.1.15",
29
- "vue-property-decorator": "^8.4.2",
30
- "vue-router": "^3.2.0",
31
- "vuex": "^3.4.0"
32
- },
33
- "devDependencies": {
34
- "@typescript-eslint/eslint-plugin": "^2.33.0",
35
- "@typescript-eslint/parser": "^2.33.0",
36
- "@vue/cli-plugin-babel": "^4.5.0",
37
- "@vue/cli-plugin-eslint": "^4.5.0",
38
- "@vue/cli-plugin-typescript": "^4.5.0",
39
- "@vue/cli-service": "^4.5.0",
40
- "@vue/eslint-config-prettier": "^6.0.0",
41
- "@vue/eslint-config-typescript": "^5.0.2",
42
- "compression-webpack-plugin": "^3.0.0",
43
- "eslint": "^6.7.2",
44
- "eslint-plugin-prettier": "^3.1.3",
45
- "eslint-plugin-vue": "^6.2.2",
46
- "prettier": "^1.19.1",
47
- "sass": "^1.26.5",
48
- "sass-loader": "^8.0.2",
49
- "typescript": "~3.9.3",
50
- "vue-template-compiler": "^2.6.11"
51
- }
52
- }
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
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * @Descripttion简易版的倒计时
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2021-11-15 15:00:57
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2021-12-26 11:20:45
8
+ */
9
+ import HtCountDown from "./index.vue";
10
+ (HtCountDown as any).install = function (Vue: any) {
11
+ Vue.component("HtCountDown", HtCountDown);
12
+ };
13
+ export default HtCountDown;
@@ -0,0 +1,171 @@
1
+ <!--
2
+ * @Descripttion:倒计时
3
+ * @version:
4
+ * @Author: hutao
5
+ * @Date: 2021-12-21 16:24:07
6
+ * @LastEditors: hutao
7
+ * @LastEditTime: 2021-12-29 10:11:23
8
+ -->
9
+ <template>
10
+ <div>
11
+ <span>
12
+ <slot :time="parseInt(state.count.toString())"
13
+ :timeStr="dateLess()">
14
+ <span>{{dateLess()}}</span>
15
+ </slot>
16
+ </span>
17
+ </div>
18
+ </template>
19
+ <script lang='ts'>
20
+ import { Component, Prop, Vue, Watch } from "vue-property-decorator";
21
+ interface State {
22
+ /** 数据状态 */
23
+ loading: boolean;
24
+ /** 差额 */
25
+ count: number;
26
+ }
27
+ @Component
28
+ export default class HtCountDown extends Vue {
29
+ /** 倒计时具体日期 2022-01-01 */
30
+ @Prop() date!: string;
31
+ /** 倒计时多少秒 250秒*/
32
+ @Prop() times!: number;
33
+ /** 是否启动 */
34
+ @Prop() start?: boolean;
35
+ /** 是否是秒表 */
36
+ @Prop() stopwatch?: boolean;
37
+ /** 刷新频率 --默认1000毫秒 */
38
+ @Prop() frequency?: number;
39
+
40
+ /** 数据 */
41
+ state: State = {
42
+ loading: false,
43
+ count: 0,
44
+ };
45
+ timer: any = undefined;
46
+
47
+ created() {
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() {
79
+ if (this.times) {
80
+ clearInterval(this.timer);
81
+ this.state.count = this.times;
82
+ this.getTimer();
83
+ }
84
+ if (this.stopwatch) {
85
+ clearInterval(this.timer);
86
+ this.startStopWatch(true);
87
+ }
88
+ //
89
+ }
90
+ /** 时间倒计时开始 */
91
+ getTimer() {
92
+ this.timer = setInterval(() => {
93
+ this.state.count--;
94
+ if (this.state.count === 0) {
95
+ clearInterval(this.timer);
96
+ }
97
+ }, this.getFrequency);
98
+ }
99
+ dateLess() {
100
+ const total: number = this.state.count;
101
+
102
+ if (this.stopwatch) {
103
+ return total;
104
+ }
105
+ if (!total) {
106
+ return "--";
107
+ }
108
+ const day: number = parseInt((total / (24 * 60 * 60)).toString()); //计算整数天数
109
+ const afterDay: number = total - day * 24 * 60 * 60; //取得算出天数后剩余的秒数
110
+ const hour: number = parseInt((afterDay / (60 * 60)).toString()); //计算整数小时数
111
+ const afterHour = total - day * 24 * 60 * 60 - hour * 60 * 60; //取得算出小时数后剩余的秒数
112
+ const min: number = parseInt((afterHour / 60).toString()); //计算整数分
113
+ const afterMin: number = parseInt(
114
+ (total - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60).toString()
115
+ ); //取得算出分后剩余的秒数
116
+ function buwei(t: number) {
117
+ return t > 9 ? t : "0" + t;
118
+ }
119
+ if (!day) {
120
+ if (!hour) {
121
+ if (min) {
122
+ return buwei(min) + "分" + buwei(afterMin) + "秒";
123
+ } else {
124
+ return buwei(afterMin) + "秒";
125
+ }
126
+ } else {
127
+ return (
128
+ buwei(hour) + "小时" + buwei(min) + "分" + buwei(afterMin) + "秒"
129
+ );
130
+ }
131
+ } else {
132
+ return (
133
+ day +
134
+ "天" +
135
+ buwei(hour) +
136
+ "小时" +
137
+ buwei(min) +
138
+ "分" +
139
+ buwei(afterMin) +
140
+ "秒"
141
+ );
142
+ }
143
+ }
144
+ /** 监听是否启动倒计时 针对传入是秒的不用重新计算,时间的要进行重新计算*/
145
+ @Watch("start", { deep: true, immediate: true })
146
+ onStart(val?: boolean) {
147
+ if (val !== false) {
148
+ /** 如果传入的是哪一天 */
149
+ if (this.date) {
150
+ const sec =
151
+ (new Date(this.date).getTime() - new Date().getTime()) / 1000;
152
+ this.state.count = sec > 0 ? sec : 0;
153
+ }
154
+ if (this.stopwatch) {
155
+ this.startStopWatch(false);
156
+ } else if (!this.date && !this.times) {
157
+ this.$notify.error("请先传入完成的参数");
158
+ return;
159
+ } else {
160
+ this.getTimer();
161
+ }
162
+ } else {
163
+ clearInterval(this.timer);
164
+ }
165
+ }
166
+ get getFrequency() {
167
+ return this.frequency || 1000;
168
+ }
169
+ }
170
+ </script>
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: 2021-12-14 16:06:12
8
+ * @LastEditTime: 2022-01-04 09:30:09
9
9
  -->
10
10
  <template>
11
11
  <div v-loading="state.loading">
@@ -110,9 +110,23 @@
110
110
  </template>
111
111
  <!-- 处理时间 -->
112
112
  <template v-else-if="item.type==='time'">
113
- <span v-if='getPropByPath(row,item.key)'>{{getPropByPath(row,item.key).replace('T', ' ').slice(0,19)}}</span>
113
+ <div v-if='getPropByPath(row,item.key)'
114
+ class="ht-column-cell">
115
+ <span v-if="!item.spread"> {{getPropByPath(row,item.key).replace('T', ' ').slice(0,19)}}</span>
116
+ <template v-else>
117
+ <p style="color:var(--primary);margin:0;padding:0">{{getPropByPath(row,item.key).slice(11,19)}}</p>
118
+ <p style="margin:0;padding:0">{{getPropByPath(row,item.key).replace('T', ' ').slice(0,10)}}</p>
119
+ </template>
120
+ </div>
114
121
  <span v-else>--</span>
115
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>
116
130
  <!-- 其他 -->
117
131
  <span v-else>{{getPropByPath(row,item.key)}}</span>
118
132
  </slot>
@@ -150,7 +164,6 @@
150
164
  </template>
151
165
  <script lang='ts'>
152
166
  import { Component, Prop, Vue, Watch } from "vue-property-decorator";
153
- import { _axios } from "vue-kst-auth";
154
167
  import { Column, PageInfoType } from "@/packages/type";
155
168
  import PageInfo from "@/packages/PageInfo/index.vue";
156
169
  interface State {
@@ -206,7 +219,8 @@ export default class HtTable extends Vue {
206
219
  created() {
207
220
  this.setPageInfo(this.pageInfo);
208
221
  }
209
- getPropByPath(obj: any, path: string, strict: boolean) {
222
+ /** 处理table里面根据字段获取对应的值 */
223
+ getPropByPath(obj: any, path: string, strict = true) {
210
224
  let tempObj = obj;
211
225
  path = path.replace(/\[(\w+)\]/g, ".$1");
212
226
  path = path.replace(/^\./, "");
@@ -220,7 +234,7 @@ export default class HtTable extends Vue {
220
234
  tempObj = tempObj[key];
221
235
  } else {
222
236
  if (strict) {
223
- throw new Error("please transfer a valid prop path to form item!");
237
+ throw new Error(`table中${path}字段发生错误,请检查`);
224
238
  }
225
239
  break;
226
240
  }
@@ -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-21 16:25:06
7
+ * @LastEditTime: 2021-12-29 09:55:45
8
8
  */
9
9
 
10
10
  // 导入组件
@@ -17,9 +17,11 @@ import HtTable from './HtTable/index'
17
17
  import HtExport from './HtExport/index'
18
18
  import HtUpload from './HtUpload/index'
19
19
  import HtMd from './HtMd/index'
20
+ import HtCountDown from './HtCountDown/index'
21
+ import HtExportPdf from './HtExportPdf/index'
20
22
 
21
23
  // 存储组件列表
22
- const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd]
24
+ const components = [HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf]
23
25
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
24
26
  const install = function (Vue: any) {
25
27
  // 判断是否安装
@@ -35,6 +37,6 @@ export default {
35
37
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
36
38
  install,
37
39
  // 以下是具体的组件列表
38
- HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd
40
+ HtSelectTable, HtPagination, HtTable, HtExport, HtUpload, HtMd, HtCountDown, HtExportPdf
39
41
  }
40
42
 
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2021-10-25 17:05:17
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2021-12-21 14:24:52
7
+ * @LastEditTime: 2021-12-23 11:33:43
8
8
  */
9
9
  /** 初始的默认条数 */
10
10
  export const defalutPageSize = 10
@@ -66,6 +66,8 @@ export interface Column {
66
66
  headerSlot?: boolean;
67
67
  /** 是否隐藏当前列 */
68
68
  hide?: boolean;
69
+ /** 时间是否跨行展示 */
70
+ spread?: boolean;
69
71
  /** 通过type展示相应的数据 用户id|部门id|时间格式化*/
70
72
  type?: 'userId' | 'org' | 'time' | 'common',
71
73
  /** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
@@ -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-21 14:28:09
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
+ }