htui-yllkbz 1.2.28 → 1.2.32
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 +1886 -4
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +1886 -4
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +4 -4
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/packages/HtExport/index.ts +16 -0
- package/src/packages/HtExport/index.vue +136 -0
- package/src/packages/HtTable/index.ts +1 -3
- package/src/packages/index.ts +4 -6
- package/src/packages/type.ts +2 -2
- package/src/views/About.vue +15 -2
package/lib/htui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:导出公共组件Excel
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-11-15 15:00:57
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-12-19 13:38:48
|
|
8
|
+
*/
|
|
9
|
+
import HtExport from "./index.vue";
|
|
10
|
+
|
|
11
|
+
(HtExport as any).install = function (Vue: any) {
|
|
12
|
+
|
|
13
|
+
Vue.component("HtExport", HtExport);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default HtExport;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Descripttion: 文件导出按钮
|
|
3
|
+
* @version:
|
|
4
|
+
* @Author: hutao
|
|
5
|
+
* @Date: 2021-09-02 09:03:43
|
|
6
|
+
* @LastEditors: hutao
|
|
7
|
+
* @LastEditTime: 2021-12-19 15:08:14
|
|
8
|
+
-->
|
|
9
|
+
<template>
|
|
10
|
+
<span @click="exportExcel"
|
|
11
|
+
v-loading="state.loading">
|
|
12
|
+
<slot :loading="state.loading">
|
|
13
|
+
<el-button type="primary">
|
|
14
|
+
导出Excel
|
|
15
|
+
</el-button>
|
|
16
|
+
</slot>
|
|
17
|
+
</span>
|
|
18
|
+
</template>
|
|
19
|
+
<script lang='ts'>
|
|
20
|
+
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
21
|
+
import { AxiosRequestConfig, Method } from "axios";
|
|
22
|
+
import { _axios } from "vue-kst-auth";
|
|
23
|
+
/** 设置axios返回类型 */
|
|
24
|
+
Vue.config.productionTip = false;
|
|
25
|
+
interface State {
|
|
26
|
+
/** 数据状态 */
|
|
27
|
+
loading: boolean;
|
|
28
|
+
}
|
|
29
|
+
@Component
|
|
30
|
+
export default class HtExport extends Vue {
|
|
31
|
+
/** 请求方式 */
|
|
32
|
+
@Prop() method!: Method;
|
|
33
|
+
/** 请求地址 */
|
|
34
|
+
@Prop() url!: string;
|
|
35
|
+
/** 请求参数 */
|
|
36
|
+
@Prop() params?: object;
|
|
37
|
+
/** 下载的文件名 */
|
|
38
|
+
@Prop() fileName!: string;
|
|
39
|
+
/** 下载之前的验证 */
|
|
40
|
+
@Prop() exportBefore!: boolean;
|
|
41
|
+
|
|
42
|
+
/** 数据 */
|
|
43
|
+
state: State = {
|
|
44
|
+
loading: false,
|
|
45
|
+
};
|
|
46
|
+
/** 生命周期 */
|
|
47
|
+
/** 方法 */
|
|
48
|
+
|
|
49
|
+
/** 导出方法 */
|
|
50
|
+
exportExcel() {
|
|
51
|
+
if (this.exportBefore !== false) {
|
|
52
|
+
//return false;
|
|
53
|
+
this.state.loading = true;
|
|
54
|
+
let fileName = this.fileName || "未知文件名.xlsx";
|
|
55
|
+
let config: AxiosRequestConfig = {
|
|
56
|
+
responseType: "blob",
|
|
57
|
+
params: {},
|
|
58
|
+
};
|
|
59
|
+
if (this.params) {
|
|
60
|
+
config = this.params;
|
|
61
|
+
}
|
|
62
|
+
if (this.url) {
|
|
63
|
+
if (this.method === "post") {
|
|
64
|
+
_axios
|
|
65
|
+
.post(this.url, config, { responseType: "blob" })
|
|
66
|
+
.then((res) => {
|
|
67
|
+
const content = res.data;
|
|
68
|
+
if (!this.fileName) {
|
|
69
|
+
const headers = res.headers["content-disposition"];
|
|
70
|
+
if (!headers) {
|
|
71
|
+
this.$notify.warning("暂无数据导出");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
fileName = decodeURIComponent(
|
|
75
|
+
headers.split("filename*=UTF-8")[1]
|
|
76
|
+
).replace("''", "");
|
|
77
|
+
}
|
|
78
|
+
const blob = new Blob([content as any]);
|
|
79
|
+
if ("download" in document.createElement("a")) {
|
|
80
|
+
// 非IE下载
|
|
81
|
+
const elink = document.createElement("a");
|
|
82
|
+
elink.download = fileName;
|
|
83
|
+
elink.style.display = "none";
|
|
84
|
+
elink.href = URL.createObjectURL(blob);
|
|
85
|
+
document.body.appendChild(elink);
|
|
86
|
+
elink.click();
|
|
87
|
+
URL.revokeObjectURL(elink.href); // 释放URL 对象
|
|
88
|
+
document.body.removeChild(elink);
|
|
89
|
+
} else {
|
|
90
|
+
// IE10+下载
|
|
91
|
+
(navigator as any).msSaveBlob(blob, fileName);
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
.finally(() => {
|
|
95
|
+
this.state.loading = false;
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
_axios
|
|
99
|
+
.get(this.url, { responseType: "blob", params: config })
|
|
100
|
+
.then((res) => {
|
|
101
|
+
const content = res.data;
|
|
102
|
+
if (!this.fileName) {
|
|
103
|
+
const headers = res.headers["content-disposition"];
|
|
104
|
+
fileName = decodeURIComponent(
|
|
105
|
+
headers.split("filename*=UTF-8")[1]
|
|
106
|
+
).replace("''", "");
|
|
107
|
+
}
|
|
108
|
+
const blob = new Blob([content as any]);
|
|
109
|
+
if ("download" in document.createElement("a")) {
|
|
110
|
+
// 非IE下载
|
|
111
|
+
const elink = document.createElement("a");
|
|
112
|
+
elink.download = fileName;
|
|
113
|
+
elink.style.display = "none";
|
|
114
|
+
elink.href = URL.createObjectURL(blob);
|
|
115
|
+
document.body.appendChild(elink);
|
|
116
|
+
elink.click();
|
|
117
|
+
URL.revokeObjectURL(elink.href); // 释放URL 对象
|
|
118
|
+
document.body.removeChild(elink);
|
|
119
|
+
} else {
|
|
120
|
+
// IE10+下载
|
|
121
|
+
(navigator as any).msSaveBlob(blob, fileName);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.finally(() => {
|
|
125
|
+
this.state.loading = false;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** 监听 */
|
|
132
|
+
/** 计算属性 */
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style lang='scss' scoped></style>
|
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
* @Author: hutao
|
|
5
5
|
* @Date: 2021-11-15 15:00:57
|
|
6
6
|
* @LastEditors: hutao
|
|
7
|
-
* @LastEditTime: 2021-12-
|
|
7
|
+
* @LastEditTime: 2021-12-19 14:10:11
|
|
8
8
|
*/
|
|
9
9
|
import HtTable from "./index.vue";
|
|
10
|
-
|
|
11
10
|
(HtTable as any).install = function (Vue: any) {
|
|
12
11
|
|
|
13
12
|
Vue.component("HtTable", HtTable);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
14
|
export default HtTable;
|
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-19 13:39:11
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
// 导入组件
|
|
@@ -14,12 +14,10 @@ import HtSelectTable from './SelectTable/index'
|
|
|
14
14
|
/** 分页组装配件 */
|
|
15
15
|
import HtPagination from './PageInfo/index'
|
|
16
16
|
import HtTable from './HtTable/index'
|
|
17
|
+
import HtExport from './HtExport/index'
|
|
17
18
|
|
|
18
19
|
// 存储组件列表
|
|
19
|
-
const components = [
|
|
20
|
-
HtSelectTable,
|
|
21
|
-
HtPagination, HtTable
|
|
22
|
-
]
|
|
20
|
+
const components = [HtSelectTable, HtPagination, HtTable, HtExport]
|
|
23
21
|
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
|
|
24
22
|
const install = function (Vue: any) {
|
|
25
23
|
// 判断是否安装
|
|
@@ -36,6 +34,6 @@ export default {
|
|
|
36
34
|
// 导出的对象必须具有 install,才能被 Vue.use() 方法安装
|
|
37
35
|
install,
|
|
38
36
|
// 以下是具体的组件列表
|
|
39
|
-
HtSelectTable, HtPagination, HtTable
|
|
37
|
+
HtSelectTable, HtPagination, HtTable, HtExport
|
|
40
38
|
}
|
|
41
39
|
|
package/src/packages/type.ts
CHANGED
|
@@ -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-
|
|
7
|
+
* @LastEditTime: 2021-12-19 14:00:13
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -77,4 +77,4 @@ export interface PageInfoType {
|
|
|
77
77
|
pageSize: number;
|
|
78
78
|
skipCount: number;
|
|
79
79
|
totalCount: number;
|
|
80
|
-
}
|
|
80
|
+
}
|
package/src/views/About.vue
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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-15 15:46:44
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
@@ -19,12 +19,25 @@
|
|
|
19
19
|
<el-tag>{{row.age}}</el-tag>
|
|
20
20
|
</div>
|
|
21
21
|
<div slot="header_name">测试名字</div>
|
|
22
|
-
|
|
23
22
|
<!-- <div slot="header_age"
|
|
24
23
|
slot-scope="{column,$index}">
|
|
25
24
|
<el-tag>年龄{{$index}}</el-tag>
|
|
26
25
|
</div> -->
|
|
27
26
|
</HtTable>
|
|
27
|
+
<el-dropdown>
|
|
28
|
+
<el-select placeholder="请选择">
|
|
29
|
+
</el-select>
|
|
30
|
+
|
|
31
|
+
<el-dropdown-menu slot="dropdown">
|
|
32
|
+
<el-dropdown-item>
|
|
33
|
+
<p style="width:300px">re</p>
|
|
34
|
+
</el-dropdown-item>
|
|
35
|
+
<el-dropdown-item>狮子头</el-dropdown-item>
|
|
36
|
+
<el-dropdown-item>螺蛳粉</el-dropdown-item>
|
|
37
|
+
<el-dropdown-item>双皮奶</el-dropdown-item>
|
|
38
|
+
<el-dropdown-item>蚵仔煎</el-dropdown-item>
|
|
39
|
+
</el-dropdown-menu>
|
|
40
|
+
</el-dropdown>
|
|
28
41
|
</div>
|
|
29
42
|
</template>
|
|
30
43
|
<script lang='ts'>
|