htui-yllkbz 1.2.42 → 1.2.43
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 +239 -11
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +239 -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 -1
- package/src/packages/HtTable/index.vue +160 -3
- package/src/packages/type.ts +4 -1
- package/src/views/About.vue +3 -1
package/lib/htui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @Author: hutao
|
|
6
6
|
* @Date: 2021-11-11 11:23:24
|
|
7
7
|
* @LastEditors: hutao
|
|
8
|
-
* @LastEditTime: 2022-01-
|
|
8
|
+
* @LastEditTime: 2022-01-10 13:40:53
|
|
9
9
|
-->
|
|
10
10
|
<template>
|
|
11
11
|
<div v-loading="state.loading">
|
|
12
|
+
|
|
12
13
|
<article>
|
|
13
14
|
<el-table ref="comTable"
|
|
14
15
|
:height="height"
|
|
@@ -42,28 +43,39 @@
|
|
|
42
43
|
@cell-click="(row, column, cell, event)=>$emit('cell-click',row, column, cell, event)"
|
|
43
44
|
@cell-dblclick="(row, column, cell, event)=>$emit('cell-dblclick',row, column, cell, event)">
|
|
44
45
|
<el-table-column width="55"
|
|
46
|
+
:resizable="false"
|
|
45
47
|
v-if="checked"
|
|
46
48
|
:reserve-selection="reserveSelection"
|
|
47
49
|
:selectable="selectable"
|
|
48
50
|
type='selection'>
|
|
49
51
|
</el-table-column>
|
|
50
52
|
<el-table-column v-if="!hideOrder"
|
|
53
|
+
:resizable="false"
|
|
51
54
|
:label="keyName===undefined?'序号':keyName"
|
|
52
55
|
:align="'center'"
|
|
53
56
|
width="55">
|
|
54
57
|
<template slot="header">
|
|
55
|
-
<slot :name="'header_order'"
|
|
58
|
+
<slot :name="'header_order'">
|
|
59
|
+
<div @click="showFilterModel"
|
|
60
|
+
v-if="showFilter"
|
|
61
|
+
title="筛选排序">
|
|
62
|
+
<el-button type="text"><i class="el-icon-s-grid"></i></el-button>
|
|
63
|
+
</div>
|
|
64
|
+
<span v-else>{{keyName||'序号'}}</span>
|
|
65
|
+
|
|
66
|
+
</slot>
|
|
56
67
|
</template>
|
|
57
68
|
<template slot-scope="scope">
|
|
58
69
|
{{(state.pageInfo.currentPage-1)*state.pageInfo.pageSize+(scope.$index+1)}}
|
|
59
70
|
</template>
|
|
60
71
|
</el-table-column>
|
|
61
|
-
<template v-for="item in
|
|
72
|
+
<template v-for="item in showColumns">
|
|
62
73
|
<el-table-column :label="item.title"
|
|
63
74
|
:key='item.key'
|
|
64
75
|
:fixed="item.fixed"
|
|
65
76
|
:align="item.align"
|
|
66
77
|
v-if="!item.hide"
|
|
78
|
+
:resizable="item.resizable"
|
|
67
79
|
:header-align="item.headerAlign"
|
|
68
80
|
:column-key="item.columnKey"
|
|
69
81
|
:class-name="item.className"
|
|
@@ -160,6 +172,39 @@
|
|
|
160
172
|
|
|
161
173
|
</el-row>
|
|
162
174
|
</footer>
|
|
175
|
+
<!-- 详情弹框 -->
|
|
176
|
+
<el-dialog :visible.sync="state.visibleFilter"
|
|
177
|
+
title="属性设置"
|
|
178
|
+
:close-on-click-modal="true"
|
|
179
|
+
width="400px"
|
|
180
|
+
:center="true">
|
|
181
|
+
<div style='overflow:hidden;height:500px'>
|
|
182
|
+
<el-scrollbar style='height: calc(100% + 17px)'>
|
|
183
|
+
<el-tree :data="columns"
|
|
184
|
+
ref="tree"
|
|
185
|
+
show-checkbox
|
|
186
|
+
node-key="key"
|
|
187
|
+
:check-on-click-node="false"
|
|
188
|
+
@node-drag-start="handleDragStart"
|
|
189
|
+
@node-drag-enter="handleDragEnter"
|
|
190
|
+
@node-drag-leave="handleDragLeave"
|
|
191
|
+
@node-drag-over="handleDragOver"
|
|
192
|
+
@node-drag-end="handleDragEnd"
|
|
193
|
+
@node-drop="handleDrop"
|
|
194
|
+
:default-checked-keys="state.showColumnKeys"
|
|
195
|
+
@check-change="changeColumns"
|
|
196
|
+
:allow-drag="allowDrag"
|
|
197
|
+
draggable
|
|
198
|
+
:allow-drop="allowDrop">
|
|
199
|
+
<span class="custom-tree-node"
|
|
200
|
+
slot-scope="{ node, data }">
|
|
201
|
+
<slot :name="'header_'+data.key"
|
|
202
|
+
:column="data">{{data.title}}</slot>
|
|
203
|
+
</span>
|
|
204
|
+
</el-tree>
|
|
205
|
+
</el-scrollbar>
|
|
206
|
+
</div>
|
|
207
|
+
</el-dialog>
|
|
163
208
|
</div>
|
|
164
209
|
</template>
|
|
165
210
|
<script lang='ts'>
|
|
@@ -169,6 +214,13 @@ import PageInfo from "@/packages/PageInfo/index.vue";
|
|
|
169
214
|
interface State {
|
|
170
215
|
pageInfo: PageInfoType;
|
|
171
216
|
loading: boolean;
|
|
217
|
+
/** 展示出来的列表名 */
|
|
218
|
+
showColumns: Column[];
|
|
219
|
+
showColumnKeys: string[];
|
|
220
|
+
/** 是否展示筛选框 */
|
|
221
|
+
visibleFilter: boolean;
|
|
222
|
+
/** 当前拖动的数据 */
|
|
223
|
+
currentColumn?: Column;
|
|
172
224
|
}
|
|
173
225
|
@Component({
|
|
174
226
|
name: "HtTable",
|
|
@@ -182,6 +234,10 @@ export default class HtTable extends Vue {
|
|
|
182
234
|
@Prop() data!: any[];
|
|
183
235
|
/** 序号对应的名称 */
|
|
184
236
|
@Prop() keyName?: string;
|
|
237
|
+
/** 是否增加筛选功能 */
|
|
238
|
+
@Prop() showFilter?: boolean;
|
|
239
|
+
/** table的唯一值用于table数据筛选 */
|
|
240
|
+
@Prop() uuId?: string;
|
|
185
241
|
/** 是否隐藏分页 */
|
|
186
242
|
@Prop() hidePage!: boolean;
|
|
187
243
|
/** 是否启用复选框 */
|
|
@@ -215,9 +271,84 @@ export default class HtTable extends Vue {
|
|
|
215
271
|
skipCount: 0,
|
|
216
272
|
totalCount: 0,
|
|
217
273
|
},
|
|
274
|
+
showColumns: [],
|
|
275
|
+
currentColumn: undefined,
|
|
276
|
+
visibleFilter: false,
|
|
277
|
+
showColumnKeys: [],
|
|
218
278
|
};
|
|
219
279
|
created() {
|
|
220
280
|
this.setPageInfo(this.pageInfo);
|
|
281
|
+
this.state.showColumns = this.columns;
|
|
282
|
+
if (this.uuId) {
|
|
283
|
+
//通过uuid获取缓存起来的header显示信息
|
|
284
|
+
const showKeys: string | null = window.localStorage.getItem(
|
|
285
|
+
"table_" + this.uuId
|
|
286
|
+
);
|
|
287
|
+
if (showKeys) {
|
|
288
|
+
this.state.showColumnKeys = JSON.parse(showKeys);
|
|
289
|
+
} else {
|
|
290
|
+
this.creatInitColumnKey();
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
this.creatInitColumnKey();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
creatInitColumnKey() {
|
|
297
|
+
this.state.showColumnKeys = this.columns.reduce((arr: string[], item) => {
|
|
298
|
+
arr.push(item.key);
|
|
299
|
+
return arr;
|
|
300
|
+
}, []);
|
|
301
|
+
}
|
|
302
|
+
changeColumns(node: any, checked: boolean) {
|
|
303
|
+
let { showColumnKeys } = this.state;
|
|
304
|
+
if (checked) {
|
|
305
|
+
showColumnKeys.push(node.key);
|
|
306
|
+
} else {
|
|
307
|
+
showColumnKeys = showColumnKeys.filter((item) => item !== node.key);
|
|
308
|
+
}
|
|
309
|
+
this.state.showColumnKeys = showColumnKeys;
|
|
310
|
+
}
|
|
311
|
+
handleDragStart(node: any) {
|
|
312
|
+
this.state.currentColumn = node.data;
|
|
313
|
+
}
|
|
314
|
+
handleDragEnter() {
|
|
315
|
+
// console.log("tree drag enter: ", dropNode.label);
|
|
316
|
+
}
|
|
317
|
+
handleDragLeave() {
|
|
318
|
+
//console.log("tree drag leave: ", dropNode.label);
|
|
319
|
+
}
|
|
320
|
+
handleDragOver() {
|
|
321
|
+
// console.log("tree drag over: ", dropNode.label);
|
|
322
|
+
}
|
|
323
|
+
handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
|
|
324
|
+
const { showColumns, currentColumn, showColumnKeys } = this.state;
|
|
325
|
+
// if ((dropType === "before" || dropType === "after") && currentColumn) {
|
|
326
|
+
// const data = showColumns.filter(
|
|
327
|
+
// (item) => item.key !== currentColumn?.key
|
|
328
|
+
// );
|
|
329
|
+
// const index = data.findIndex((item) => item.key === dropNode.data.key);
|
|
330
|
+
// dropType === "before"
|
|
331
|
+
// ? data.splice(index, 0, currentColumn)
|
|
332
|
+
// : data.splice(index + 1, 0, currentColumn);
|
|
333
|
+
// console.log("tree drag end: ", currentColumn, showColumnKeys);
|
|
334
|
+
if (currentColumn && showColumnKeys.includes(currentColumn.key)) {
|
|
335
|
+
setTimeout(() => {
|
|
336
|
+
(this.$refs.tree as any).setChecked(currentColumn, true);
|
|
337
|
+
}, 0);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// }
|
|
341
|
+
}
|
|
342
|
+
handleDrop() {
|
|
343
|
+
// console.log("tree drop: ", dropNode, dropType);
|
|
344
|
+
}
|
|
345
|
+
/** 节点是否被插入 */
|
|
346
|
+
allowDrop(draggingNode: any, dropNode: any, type: string) {
|
|
347
|
+
return type !== "inner";
|
|
348
|
+
}
|
|
349
|
+
/** 节点是否允许拖动 */
|
|
350
|
+
allowDrag(draggingNode: any) {
|
|
351
|
+
return !draggingNode.data.disabled;
|
|
221
352
|
}
|
|
222
353
|
/** 处理table里面根据字段获取对应的值 */
|
|
223
354
|
getPropByPath(obj: any, path: string, strict = true) {
|
|
@@ -246,6 +377,9 @@ export default class HtTable extends Vue {
|
|
|
246
377
|
// };
|
|
247
378
|
return tempObj ? tempObj[keyArr[i]] : null;
|
|
248
379
|
}
|
|
380
|
+
showFilterModel() {
|
|
381
|
+
this.state.visibleFilter = true;
|
|
382
|
+
}
|
|
249
383
|
/** 遍历循环展示row数据 */
|
|
250
384
|
showValue(row: any, key: string) {
|
|
251
385
|
if (key) {
|
|
@@ -270,6 +404,25 @@ export default class HtTable extends Vue {
|
|
|
270
404
|
return "";
|
|
271
405
|
}
|
|
272
406
|
}
|
|
407
|
+
/** 获取显示出来的table头信息 */
|
|
408
|
+
get showColumns() {
|
|
409
|
+
const { showColumnKeys, showColumns } = this.state;
|
|
410
|
+
let obj: any = {};
|
|
411
|
+
for (const key in showColumnKeys) {
|
|
412
|
+
obj = { ...obj, [showColumnKeys[key]]: true };
|
|
413
|
+
}
|
|
414
|
+
/** 缓存起来下次使用 --todo只做了显示没有做排序缓存 */
|
|
415
|
+
if (this.uuId) {
|
|
416
|
+
window.localStorage.setItem(
|
|
417
|
+
"table_" + this.uuId,
|
|
418
|
+
JSON.stringify(showColumnKeys)
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const data = showColumns.filter((item) => obj[item.key as string]);
|
|
423
|
+
return data;
|
|
424
|
+
}
|
|
425
|
+
|
|
273
426
|
/** 监听 */
|
|
274
427
|
@Watch("pageInfo")
|
|
275
428
|
setPageInfo(val?: PageInfoType) {
|
|
@@ -283,6 +436,10 @@ export default class HtTable extends Vue {
|
|
|
283
436
|
};
|
|
284
437
|
}
|
|
285
438
|
}
|
|
439
|
+
@Watch("columns")
|
|
440
|
+
setColumns(columns?: Column[]) {
|
|
441
|
+
this.state.showColumns = columns || [];
|
|
442
|
+
}
|
|
286
443
|
}
|
|
287
444
|
</script>
|
|
288
445
|
<style lang='scss' scoped></style>
|
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: 2022-01-
|
|
7
|
+
* @LastEditTime: 2022-01-10 09:32:46
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -53,6 +53,7 @@ export interface Column {
|
|
|
53
53
|
|
|
54
54
|
key: string;
|
|
55
55
|
title: string;
|
|
56
|
+
|
|
56
57
|
width?: number | string;
|
|
57
58
|
minWidth?: number | string;
|
|
58
59
|
fixed?: 'left' | 'rigth' | boolean;
|
|
@@ -73,6 +74,8 @@ export interface Column {
|
|
|
73
74
|
/** 只有当type='common'时候有效 数据类型个ca common里面的一样但不包括时间 时间使用time */
|
|
74
75
|
commonType?: 'userId' | 'departmentId' | 'baseDataId' | 'roleId' | 'baseDataName' | 'baseDataValue',
|
|
75
76
|
showOverflowTooltip?: boolean,
|
|
77
|
+
/** 筛选时候是否禁用 */
|
|
78
|
+
disabled?: boolean;
|
|
76
79
|
}
|
|
77
80
|
export interface PageInfoType {
|
|
78
81
|
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: 2022-01-
|
|
7
|
+
* @LastEditTime: 2022-01-10 09:32:22
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
@@ -89,6 +89,7 @@ export default class Index extends Vue {
|
|
|
89
89
|
age: 12,
|
|
90
90
|
sex: 0,
|
|
91
91
|
id: 1,
|
|
92
|
+
|
|
92
93
|
test: { title: "测试" },
|
|
93
94
|
time: "2022-01-20T00:00:00+08:00",
|
|
94
95
|
},
|
|
@@ -130,6 +131,7 @@ export default class Index extends Vue {
|
|
|
130
131
|
title: "姓名",
|
|
131
132
|
key: "test.title",
|
|
132
133
|
width: "300px",
|
|
134
|
+
disabled: true,
|
|
133
135
|
},
|
|
134
136
|
{
|
|
135
137
|
title: "姓额外名",
|