htui-yllkbz 1.2.24 → 1.2.28
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/LICENSE +21 -0
- package/README.md +10 -3
- package/lib/htui.common.js +12 -11
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +12 -11
- package/lib/htui.umd.js.gz +0 -0
- package/lib/htui.umd.min.js +3 -3
- package/lib/htui.umd.min.js.gz +0 -0
- package/package.json +1 -2
- package/src/packages/HtAsyncTable/index.ts +16 -0
- package/src/packages/HtAsyncTable/index.vue +266 -0
- package/src/packages/HtTable/index.vue +24 -7
- package/src/packages/type.ts +5 -2
- package/src/views/About.vue +2 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
|
|
2
|
+
<!--
|
|
3
|
+
* @Descripttion: ht-table
|
|
4
|
+
* @version:
|
|
5
|
+
* @Author: hutao
|
|
6
|
+
* @Date: 2021-11-11 11:23:24
|
|
7
|
+
* @LastEditors: hutao
|
|
8
|
+
* @LastEditTime: 2021-12-13 15:02:13
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<div v-loading="state.loading">
|
|
12
|
+
<article>
|
|
13
|
+
|
|
14
|
+
<el-table ref="comTable"
|
|
15
|
+
:height="height"
|
|
16
|
+
:max-height="maxHeight"
|
|
17
|
+
:border="border"
|
|
18
|
+
:stripe="stripe"
|
|
19
|
+
:size="size"
|
|
20
|
+
:fit="fit"
|
|
21
|
+
:show-header="showHeader"
|
|
22
|
+
:empty-text="emptyText||'暂无数据'"
|
|
23
|
+
:row-style="rowStyle"
|
|
24
|
+
:row-class-name="rowClassName"
|
|
25
|
+
:current-row-key="currentRowKey"
|
|
26
|
+
:highlight-current-row="highlightCurrentRow"
|
|
27
|
+
:row-key="rowKey||'id'"
|
|
28
|
+
:data="data"
|
|
29
|
+
tooltip-effect="dark"
|
|
30
|
+
@row-click="(row, column, event)=>$emit('row-click',row, column, event)"
|
|
31
|
+
@row-contextmenu="(row, column, event)=>$emit('row-contextmenu',row, column, event)"
|
|
32
|
+
@row-dblclick="(row, column, event)=>$emit('row-dblclick',row, column, event)"
|
|
33
|
+
@header-click="( column, event)=>$emit('header-click', column, event)"
|
|
34
|
+
@header-contextmenu="( column, event)=>$emit('header-contextmenu', column, event)"
|
|
35
|
+
@sort-change="({ column, prop, order})=>$emit('sort-change', { column, prop, order})"
|
|
36
|
+
@filter-change="(filter)=>$emit('filter-change', filter)"
|
|
37
|
+
@current-change="(currentRow, oldCurrentRow)=>$emit('current-change', currentRow, oldCurrentRow)"
|
|
38
|
+
@select="(selection, row)=>$emit('select',selection, row)"
|
|
39
|
+
@select-all="(selection)=>$emit('select-all',selection)"
|
|
40
|
+
@selection-change="(selection)=>$emit('selection-change',selection)"
|
|
41
|
+
@cell-mouse-enter="(row, column, cell, event)=>$emit('cell-mouse-enter',row, column, cell, event)"
|
|
42
|
+
@cell-mouse-leave="(row, column, cell, event)=>$emit('cell-mouse-leave',row, column, cell, event)"
|
|
43
|
+
@cell-click="(row, column, cell, event)=>$emit('cell-click',row, column, cell, event)"
|
|
44
|
+
@cell-dblclick="(row, column, cell, event)=>$emit('cell-dblclick',row, column, cell, event)">
|
|
45
|
+
<el-table-column width="55"
|
|
46
|
+
v-if="checked"
|
|
47
|
+
:reserve-selection="reserveSelection"
|
|
48
|
+
:selectable="selectable"
|
|
49
|
+
type='selection'>
|
|
50
|
+
</el-table-column>
|
|
51
|
+
<el-table-column v-if="!hideOrder"
|
|
52
|
+
:label="keyName||''"
|
|
53
|
+
:align="'center'"
|
|
54
|
+
width="55">
|
|
55
|
+
<template slot="header">
|
|
56
|
+
<slot :name="'header_order'"></slot>
|
|
57
|
+
</template>
|
|
58
|
+
<template slot-scope="scope">
|
|
59
|
+
{{(state.pageInfo.currentPage-1)*state.pageInfo.pageSize+(scope.$index+1)}}
|
|
60
|
+
</template>
|
|
61
|
+
</el-table-column>
|
|
62
|
+
<template v-for="item in columns">
|
|
63
|
+
<el-table-column :label="item.title"
|
|
64
|
+
:key='item.key'
|
|
65
|
+
:fixed="item.fixed"
|
|
66
|
+
:align="item.align"
|
|
67
|
+
v-if="!item.hide"
|
|
68
|
+
:header-align="item.headerAlign"
|
|
69
|
+
:column-key="item.columnKey"
|
|
70
|
+
:class-name="item.className"
|
|
71
|
+
:prop="item.key"
|
|
72
|
+
:show-overflow-tooltip="item.type==='org'||item.type==='userId'?false:(item.showOverflowTooltip===false?false:true)"
|
|
73
|
+
:sortable="item.sortable"
|
|
74
|
+
:sort-method="item.sortMethod"
|
|
75
|
+
:sort-orders="item.sortOrders"
|
|
76
|
+
:formatter="item.formatter"
|
|
77
|
+
:sort-by="item.sortBy"
|
|
78
|
+
:min-width="item.minWidth"
|
|
79
|
+
:width="item.width">
|
|
80
|
+
<template slot-scope="{row,column,rowIndex}">
|
|
81
|
+
<slot :name="item.key"
|
|
82
|
+
:row="row"
|
|
83
|
+
:column="column"
|
|
84
|
+
:rowIndex="rowIndex">
|
|
85
|
+
<!-- 处理部门 -->
|
|
86
|
+
<template v-if="item.type==='org'">
|
|
87
|
+
<common-org-info v-if="getPropByPath(row,item.key)"
|
|
88
|
+
:org-id="getPropByPath(row,item.key)"
|
|
89
|
+
type="tag"></common-org-info>
|
|
90
|
+
<span v-else>--</span>
|
|
91
|
+
</template>
|
|
92
|
+
<!-- 处理部门人员 -->
|
|
93
|
+
<template v-else-if="item.type==='userId'">
|
|
94
|
+
<div is='common-datas-info-id'
|
|
95
|
+
v-if="getPropByPath(row,item.key)"
|
|
96
|
+
:user-id="JSON.stringify(getPropByPath(row,item.key))"
|
|
97
|
+
:base-data-info='true'></div>
|
|
98
|
+
<span v-else>--</span>
|
|
99
|
+
</template>
|
|
100
|
+
<!-- 处理时间 -->
|
|
101
|
+
<template v-else-if="item.type==='time'">
|
|
102
|
+
<span v-if='getPropByPath(row,item.key)'>{{getPropByPath(row,item.key).replace('T', ' ').slice(0,19)}}</span>
|
|
103
|
+
<span v-else>--</span>
|
|
104
|
+
</template>
|
|
105
|
+
<!-- 其他 -->
|
|
106
|
+
<span v-else>{{getPropByPath(row,item.key)}}</span>
|
|
107
|
+
</slot>
|
|
108
|
+
|
|
109
|
+
</template>
|
|
110
|
+
<template slot-scope="{column,$index}"
|
|
111
|
+
slot="header">
|
|
112
|
+
<slot :name="'header_'+item.key"
|
|
113
|
+
:column="column"
|
|
114
|
+
:$index="$index">{{item.title}}</slot>
|
|
115
|
+
</template>
|
|
116
|
+
</el-table-column>
|
|
117
|
+
</template>
|
|
118
|
+
|
|
119
|
+
</el-table>
|
|
120
|
+
</article>
|
|
121
|
+
<footer v-if="!hidePage">
|
|
122
|
+
<el-row>
|
|
123
|
+
<el-col :span="24"
|
|
124
|
+
name="footer">
|
|
125
|
+
|
|
126
|
+
<slot name="footerLeft"></slot>
|
|
127
|
+
|
|
128
|
+
<el-col :span="12">
|
|
129
|
+
<!-- <p style="width:90px;float:left">共{{data.length}}条</p> -->
|
|
130
|
+
<PageInfo :hide-on-single-page="pagination&&pagination.hideOnSinglePage"
|
|
131
|
+
:small="pagination&&pagination.small"
|
|
132
|
+
@onchange="(e)=>$emit('onchange',e)"
|
|
133
|
+
:page-sizes="pagination&&pagination.pageSizes"
|
|
134
|
+
:page-info="state.pageInfo"></PageInfo>
|
|
135
|
+
</el-col>
|
|
136
|
+
</el-col>
|
|
137
|
+
|
|
138
|
+
</el-row>
|
|
139
|
+
</footer>
|
|
140
|
+
</div>
|
|
141
|
+
</template>
|
|
142
|
+
<script lang='ts'>
|
|
143
|
+
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
144
|
+
import { _axios } from "vue-kst-auth";
|
|
145
|
+
import { Column, PageInfoType } from "@/packages/type";
|
|
146
|
+
import PageInfo from "@/packages/PageInfo/index.vue";
|
|
147
|
+
interface State {
|
|
148
|
+
pageInfo: PageInfoType;
|
|
149
|
+
loading: boolean;
|
|
150
|
+
}
|
|
151
|
+
@Component({
|
|
152
|
+
name: "HtTable",
|
|
153
|
+
components: {
|
|
154
|
+
PageInfo,
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
export default class HtTable extends Vue {
|
|
158
|
+
/** 默认的table头 */
|
|
159
|
+
@Prop() columns!: Column[];
|
|
160
|
+
@Prop() data!: any[];
|
|
161
|
+
/** 序号对应的名称 */
|
|
162
|
+
@Prop() keyName?: string;
|
|
163
|
+
/** 是否隐藏分页 */
|
|
164
|
+
@Prop() hidePage!: boolean;
|
|
165
|
+
/** 是否启用复选框 */
|
|
166
|
+
@Prop() checked!: boolean;
|
|
167
|
+
/** 仅对 type=selection 的列有效,类型为 Boolean,为 true 则会在数据更新之后保留之前选中的数据(需指定 row-key) */
|
|
168
|
+
@Prop() reserveSelection!: boolean;
|
|
169
|
+
@Prop() height?: string | number;
|
|
170
|
+
@Prop() maxHeight?: string | number;
|
|
171
|
+
@Prop() rowKey?: string;
|
|
172
|
+
@Prop() stripe?: boolean;
|
|
173
|
+
@Prop() border?: boolean;
|
|
174
|
+
@Prop() size?: "medium" | "small" | "mini";
|
|
175
|
+
@Prop() fit?: boolean;
|
|
176
|
+
@Prop() showHeader?: boolean;
|
|
177
|
+
@Prop() rowClassName?: any;
|
|
178
|
+
/** 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 */
|
|
179
|
+
@Prop() selectable?: any;
|
|
180
|
+
@Prop() currentRowKey?: string | number;
|
|
181
|
+
@Prop() highlightCurrentRow?: boolean;
|
|
182
|
+
@Prop() rowStyle?: any;
|
|
183
|
+
@Prop() hideOrder?: boolean;
|
|
184
|
+
@Prop() pageInfo?: PageInfoType;
|
|
185
|
+
@Prop() emptyText?: string | number;
|
|
186
|
+
/** 分页的所有额外信息通过此参数传递 */
|
|
187
|
+
@Prop() pagination?: any;
|
|
188
|
+
state: State = {
|
|
189
|
+
loading: false,
|
|
190
|
+
pageInfo: {
|
|
191
|
+
currentPage: 1,
|
|
192
|
+
pageSize: 10,
|
|
193
|
+
skipCount: 0,
|
|
194
|
+
totalCount: 0,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
created() {
|
|
198
|
+
// console.log("this", this.$props);
|
|
199
|
+
this.setPageInfo(this.pageInfo);
|
|
200
|
+
}
|
|
201
|
+
getPropByPath(obj: any, path: string, strict: boolean) {
|
|
202
|
+
let tempObj = obj;
|
|
203
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
204
|
+
path = path.replace(/^\./, "");
|
|
205
|
+
|
|
206
|
+
const keyArr = path.split(".");
|
|
207
|
+
let i = 0;
|
|
208
|
+
for (let len = keyArr.length; i < len - 1; ++i) {
|
|
209
|
+
if (!tempObj && !strict) break;
|
|
210
|
+
const key = keyArr[i];
|
|
211
|
+
if (key in tempObj) {
|
|
212
|
+
tempObj = tempObj[key];
|
|
213
|
+
} else {
|
|
214
|
+
if (strict) {
|
|
215
|
+
throw new Error("please transfer a valid prop path to form item!");
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// return {
|
|
221
|
+
// o: tempObj,
|
|
222
|
+
// k: keyArr[i],
|
|
223
|
+
// v: tempObj ? tempObj[keyArr[i]] : null,
|
|
224
|
+
// };
|
|
225
|
+
return tempObj ? tempObj[keyArr[i]] : null;
|
|
226
|
+
}
|
|
227
|
+
/** 遍历循环展示row数据 */
|
|
228
|
+
showValue(row: any, key: string) {
|
|
229
|
+
if (key) {
|
|
230
|
+
if (key.includes(".")) {
|
|
231
|
+
//存在多级的情况
|
|
232
|
+
//console.log("eval", key, eval(row[key]));
|
|
233
|
+
// const arrKey = key.split(".");
|
|
234
|
+
// let data = row;
|
|
235
|
+
// arrKey.forEach((item) => {
|
|
236
|
+
// if (data[item]) {
|
|
237
|
+
// data = data[item];
|
|
238
|
+
// } else {
|
|
239
|
+
// data = "";
|
|
240
|
+
// }
|
|
241
|
+
// });
|
|
242
|
+
return "";
|
|
243
|
+
} else {
|
|
244
|
+
//如果不存在多级数据
|
|
245
|
+
return row[key];
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
return "";
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** 监听 */
|
|
252
|
+
@Watch("pageInfo")
|
|
253
|
+
setPageInfo(val?: PageInfoType) {
|
|
254
|
+
if (val) {
|
|
255
|
+
const pageInfo: PageInfoType = val;
|
|
256
|
+
this.state.pageInfo = {
|
|
257
|
+
currentPage: Number(pageInfo.currentPage),
|
|
258
|
+
pageSize: Number(pageInfo.pageSize),
|
|
259
|
+
skipCount: Number(pageInfo.skipCount),
|
|
260
|
+
totalCount: Number(pageInfo.totalCount),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
</script>
|
|
266
|
+
<style lang='scss' scoped></style>
|
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
* @Author: hutao
|
|
6
6
|
* @Date: 2021-11-11 11:23:24
|
|
7
7
|
* @LastEditors: hutao
|
|
8
|
-
* @LastEditTime: 2021-12-
|
|
8
|
+
* @LastEditTime: 2021-12-14 16:06:12
|
|
9
9
|
-->
|
|
10
10
|
<template>
|
|
11
11
|
<div v-loading="state.loading">
|
|
12
12
|
<article>
|
|
13
|
-
|
|
14
13
|
<el-table ref="comTable"
|
|
15
14
|
:height="height"
|
|
16
15
|
:max-height="maxHeight"
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
type='selection'>
|
|
50
49
|
</el-table-column>
|
|
51
50
|
<el-table-column v-if="!hideOrder"
|
|
52
|
-
label="序号"
|
|
51
|
+
:label="keyName===undefined?'序号':keyName"
|
|
53
52
|
:align="'center'"
|
|
54
53
|
width="55">
|
|
55
54
|
<template slot="header">
|
|
@@ -68,8 +67,8 @@
|
|
|
68
67
|
:header-align="item.headerAlign"
|
|
69
68
|
:column-key="item.columnKey"
|
|
70
69
|
:class-name="item.className"
|
|
71
|
-
:show-overflow-tooltip="true"
|
|
72
70
|
:prop="item.key"
|
|
71
|
+
:show-overflow-tooltip="item.type==='common'||item.type==='org'||item.type==='userId'?false:(item.showOverflowTooltip===false?false:true)"
|
|
73
72
|
:sortable="item.sortable"
|
|
74
73
|
:sort-method="item.sortMethod"
|
|
75
74
|
:sort-orders="item.sortOrders"
|
|
@@ -89,6 +88,18 @@
|
|
|
89
88
|
type="tag"></common-org-info>
|
|
90
89
|
<span v-else>--</span>
|
|
91
90
|
</template>
|
|
91
|
+
<template v-else-if="item.type==='common'">
|
|
92
|
+
<div v-if="getPropByPath(row,item.key)"
|
|
93
|
+
is='common-datas-info-id'
|
|
94
|
+
:user-id="item.commonType['userId']?getPropByPath(row,item.key):'[]'"
|
|
95
|
+
:department-id="item.commonType['departmentId']?getPropByPath(row,item.key):'[]'"
|
|
96
|
+
:role-id="item.commonType['roleId']?getPropByPath(row,item.key):'[]'"
|
|
97
|
+
:base-data-id="item.commonType['baseDataId']?getPropByPath(row,item.key):''"
|
|
98
|
+
:base-data-value="item.commonType['baseDataValue']?getPropByPath(row,item.key):''"
|
|
99
|
+
:base-data-name="item.commonType['baseDataName']?getPropByPath(row,item.key):''"
|
|
100
|
+
:base-data-info='true'></div>
|
|
101
|
+
<span v-else>--</span>
|
|
102
|
+
</template>
|
|
92
103
|
<!-- 处理部门人员 -->
|
|
93
104
|
<template v-else-if="item.type==='userId'">
|
|
94
105
|
<div is='common-datas-info-id'
|
|
@@ -107,6 +118,7 @@
|
|
|
107
118
|
</slot>
|
|
108
119
|
|
|
109
120
|
</template>
|
|
121
|
+
<!-- 处理重定义table头相关信息 header_key -->
|
|
110
122
|
<template slot-scope="{column,$index}"
|
|
111
123
|
slot="header">
|
|
112
124
|
<slot :name="'header_'+item.key"
|
|
@@ -119,8 +131,11 @@
|
|
|
119
131
|
</el-table>
|
|
120
132
|
</article>
|
|
121
133
|
<footer v-if="!hidePage">
|
|
122
|
-
<el-row>
|
|
123
|
-
|
|
134
|
+
<el-row name="footer">
|
|
135
|
+
<!-- 此处建议使用el-col -->
|
|
136
|
+
<slot name="footerLeft"></slot>
|
|
137
|
+
|
|
138
|
+
<el-col :span="12">
|
|
124
139
|
<!-- <p style="width:90px;float:left">共{{data.length}}条</p> -->
|
|
125
140
|
<PageInfo :hide-on-single-page="pagination&&pagination.hideOnSinglePage"
|
|
126
141
|
:small="pagination&&pagination.small"
|
|
@@ -128,6 +143,7 @@
|
|
|
128
143
|
:page-sizes="pagination&&pagination.pageSizes"
|
|
129
144
|
:page-info="state.pageInfo"></PageInfo>
|
|
130
145
|
</el-col>
|
|
146
|
+
|
|
131
147
|
</el-row>
|
|
132
148
|
</footer>
|
|
133
149
|
</div>
|
|
@@ -151,6 +167,8 @@ export default class HtTable extends Vue {
|
|
|
151
167
|
/** 默认的table头 */
|
|
152
168
|
@Prop() columns!: Column[];
|
|
153
169
|
@Prop() data!: any[];
|
|
170
|
+
/** 序号对应的名称 */
|
|
171
|
+
@Prop() keyName?: string;
|
|
154
172
|
/** 是否隐藏分页 */
|
|
155
173
|
@Prop() hidePage!: boolean;
|
|
156
174
|
/** 是否启用复选框 */
|
|
@@ -186,7 +204,6 @@ export default class HtTable extends Vue {
|
|
|
186
204
|
},
|
|
187
205
|
};
|
|
188
206
|
created() {
|
|
189
|
-
// console.log("this", this.$props);
|
|
190
207
|
this.setPageInfo(this.pageInfo);
|
|
191
208
|
}
|
|
192
209
|
getPropByPath(obj: any, path: string, strict: boolean) {
|
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-13 15:31:13
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -67,7 +67,10 @@ export interface Column {
|
|
|
67
67
|
/** 是否隐藏当前列 */
|
|
68
68
|
hide?: boolean;
|
|
69
69
|
/** 通过type展示相应的数据 用户id|部门id|时间格式化*/
|
|
70
|
-
type?: 'userId' | 'org' | 'time'
|
|
70
|
+
type?: 'userId' | 'org' | 'time' | 'common',
|
|
71
|
+
/** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
|
|
72
|
+
commonType?: 'userId' | 'departmentId' | 'baseDataId' | 'roleId' | 'baseDataName' | 'baseDataValue',
|
|
73
|
+
showOverflowTooltip?: boolean,
|
|
71
74
|
}
|
|
72
75
|
export interface PageInfoType {
|
|
73
76
|
currentPage: number;
|
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-13 15:02:01
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
<el-tag>{{row.age}}</el-tag>
|
|
20
20
|
</div>
|
|
21
21
|
<div slot="header_name">测试名字</div>
|
|
22
|
+
|
|
22
23
|
<!-- <div slot="header_age"
|
|
23
24
|
slot-scope="{column,$index}">
|
|
24
25
|
<el-tag>年龄{{$index}}</el-tag>
|