htui-yllkbz 1.2.57 → 1.2.58
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 +233 -124
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +233 -124
- 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 +141 -35
- package/src/packages/type.ts +4 -2
- package/src/views/About.vue +3 -3
package/lib/htui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @Author: hutao
|
|
6
6
|
* @Date: 2021-11-11 11:23:24
|
|
7
7
|
* @LastEditors: hutao
|
|
8
|
-
* @LastEditTime: 2022-02-
|
|
8
|
+
* @LastEditTime: 2022-02-14 11:07:24
|
|
9
9
|
-->
|
|
10
10
|
<template>
|
|
11
11
|
<div v-loading="state.loading"
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
{{(state.pageInfo.currentPage-1)*state.pageInfo.pageSize+(scope.$index+1)}}
|
|
74
74
|
</template>
|
|
75
75
|
</el-table-column>
|
|
76
|
-
<template v-for="item in showColumns">
|
|
76
|
+
<template v-for="(item,index) in state.showColumns">
|
|
77
77
|
<el-table-column :label="item.title"
|
|
78
|
-
:key='item.key'
|
|
78
|
+
:key='`${item.key}_${index}`'
|
|
79
79
|
:fixed="item.fixed"
|
|
80
80
|
:align="item.align"
|
|
81
|
-
v-if="!item.hide"
|
|
81
|
+
v-if="!item.hide&&item.checked"
|
|
82
82
|
:resizable="item.resizable"
|
|
83
83
|
:header-align="item.headerAlign"
|
|
84
84
|
:column-key="item.columnKey"
|
|
@@ -205,15 +205,15 @@
|
|
|
205
205
|
title="属性设置"
|
|
206
206
|
:append-to-body="true"
|
|
207
207
|
:close-on-click-modal="true"
|
|
208
|
-
width="400px"
|
|
209
|
-
|
|
210
|
-
<p slot="title"
|
|
208
|
+
width="400px">
|
|
209
|
+
<p slot="title"
|
|
211
210
|
style="font-weight:700;font-size:18px;float:left;margin:0">自定义列展示</p>
|
|
212
|
-
<div style='overflow:hidden;height:
|
|
213
|
-
<el-scrollbar style='height: calc(
|
|
214
|
-
<el-tree :data="
|
|
211
|
+
<div style='overflow:hidden;height:35vh;margin-top:12px'>
|
|
212
|
+
<el-scrollbar style='height: calc(35vh + 17px)'>
|
|
213
|
+
<el-tree :data="getAllColumns"
|
|
215
214
|
ref="tree"
|
|
216
215
|
show-checkbox
|
|
216
|
+
:expand-on-click-node="false"
|
|
217
217
|
node-key="key"
|
|
218
218
|
:check-on-click-node="false"
|
|
219
219
|
@node-drag-start="handleDragStart"
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
@node-drag-over="handleDragOver"
|
|
223
223
|
@node-drag-end="handleDragEnd"
|
|
224
224
|
@node-drop="handleDrop"
|
|
225
|
-
:default-checked-keys="state.
|
|
225
|
+
:default-checked-keys="state.checkedColumnKeys"
|
|
226
226
|
@check-change="changeColumns"
|
|
227
227
|
:allow-drag="allowDrag"
|
|
228
228
|
draggable
|
|
@@ -234,7 +234,13 @@
|
|
|
234
234
|
</span>
|
|
235
235
|
</el-tree>
|
|
236
236
|
</el-scrollbar>
|
|
237
|
+
|
|
237
238
|
</div>
|
|
239
|
+
<span slot="footer">
|
|
240
|
+
<el-button type="primary"
|
|
241
|
+
@click="confirmSortAndshow">确定</el-button>
|
|
242
|
+
<el-button @click="state.visibleFilter=false">取消</el-button>
|
|
243
|
+
</span>
|
|
238
244
|
</el-dialog>
|
|
239
245
|
<!-- 附件详情弹框 -->
|
|
240
246
|
<el-dialog :visible.sync="state.visibleFile"
|
|
@@ -245,7 +251,7 @@
|
|
|
245
251
|
:center="true">
|
|
246
252
|
<p slot="title"
|
|
247
253
|
style="font-weight:700;font-size:18px;float:left;margin:0">附件查看</p>
|
|
248
|
-
|
|
254
|
+
|
|
249
255
|
<div style='overflow:hidden;height:calc(30vh)'>
|
|
250
256
|
<el-scrollbar style='height: calc(100% + 17px)'>
|
|
251
257
|
<HtUploadFiles :disabled="true"
|
|
@@ -265,7 +271,12 @@ interface State {
|
|
|
265
271
|
loading: boolean;
|
|
266
272
|
/** 展示出来的列表名 */
|
|
267
273
|
showColumns: Column[];
|
|
274
|
+
/** 全部的列 */
|
|
275
|
+
allColumns: Column[];
|
|
276
|
+
/** 列表展示的列 */
|
|
268
277
|
showColumnKeys: string[];
|
|
278
|
+
/** 自定义列表选中的列 */
|
|
279
|
+
checkedColumnKeys: string[];
|
|
269
280
|
/** 是否展示筛选框 */
|
|
270
281
|
visibleFilter: boolean;
|
|
271
282
|
/** 是否展示附件 */
|
|
@@ -317,6 +328,7 @@ export default class HtTable extends Vue {
|
|
|
317
328
|
@Prop() emptyText?: string | number;
|
|
318
329
|
@Prop() headerRowStyle?: any;
|
|
319
330
|
@Prop() headerRowClassName?: any;
|
|
331
|
+
@Prop() headerCellClassName?: any;
|
|
320
332
|
@Prop() headerCellStyle?: any;
|
|
321
333
|
|
|
322
334
|
/** 分页的所有额外信息通过此参数传递 */
|
|
@@ -331,48 +343,65 @@ export default class HtTable extends Vue {
|
|
|
331
343
|
totalCount: 0,
|
|
332
344
|
},
|
|
333
345
|
showColumns: [],
|
|
346
|
+
allColumns: [],
|
|
334
347
|
currentColumn: undefined,
|
|
335
348
|
visibleFilter: false,
|
|
336
349
|
visibleFile: false,
|
|
337
350
|
showColumnKeys: [],
|
|
351
|
+
checkedColumnKeys: [],
|
|
338
352
|
};
|
|
339
353
|
created() {
|
|
340
354
|
this.setPageInfo(this.pageInfo);
|
|
341
|
-
this.
|
|
355
|
+
//this.setColumns(this.columns);
|
|
342
356
|
if (this.uuId) {
|
|
343
357
|
//通过uuid获取缓存起来的header显示信息
|
|
344
|
-
|
|
358
|
+
//-todo
|
|
359
|
+
//---columns 要改变
|
|
360
|
+
//---showColumnKeys 要改变
|
|
361
|
+
//---排列顺序要改变 todo
|
|
362
|
+
const allColumns: string | null = window.localStorage.getItem(
|
|
345
363
|
"table_" + this.uuId
|
|
346
364
|
);
|
|
347
|
-
if (
|
|
348
|
-
this.state.
|
|
365
|
+
if (allColumns) {
|
|
366
|
+
this.state.allColumns = JSON.parse(allColumns);
|
|
367
|
+
this.state.showColumns = JSON.parse(allColumns);
|
|
368
|
+
this.getShowKeys(this.state.allColumns);
|
|
349
369
|
} else {
|
|
350
|
-
this.creatInitColumnKey();
|
|
370
|
+
this.creatInitColumnKey(this.columns || []);
|
|
351
371
|
}
|
|
352
372
|
} else {
|
|
353
|
-
this.creatInitColumnKey();
|
|
373
|
+
this.creatInitColumnKey(this.columns || []);
|
|
354
374
|
}
|
|
355
375
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
376
|
+
/** 获取展示的keys值 */
|
|
377
|
+
getShowKeys(data: Column[]) {
|
|
378
|
+
const arr: string[] = [];
|
|
379
|
+
data.forEach((item) => {
|
|
380
|
+
if (item.checked) {
|
|
381
|
+
arr.push(item.key);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
this.state.showColumnKeys = arr;
|
|
385
|
+
}
|
|
386
|
+
/** 初始化columns */
|
|
387
|
+
creatInitColumnKey(columns: Column[]) {
|
|
388
|
+
this.state.allColumns = columns;
|
|
389
|
+
this.state.showColumns = columns;
|
|
390
|
+
this.state.allColumns.forEach((item) => {
|
|
391
|
+
item.checked = true;
|
|
392
|
+
});
|
|
393
|
+
this.getShowKeys(this.state.allColumns);
|
|
394
|
+
// this.state.showColumnKeys = this.columns.reduce((arr: string[], item) => {
|
|
395
|
+
// arr.push(item.key);
|
|
396
|
+
// return arr;
|
|
397
|
+
// }, []);
|
|
361
398
|
}
|
|
362
399
|
/** 展示附件信息 */
|
|
363
400
|
showFiles(val = "") {
|
|
364
401
|
this.state.files = val;
|
|
365
402
|
this.state.visibleFile = true;
|
|
366
403
|
}
|
|
367
|
-
|
|
368
|
-
let { showColumnKeys } = this.state;
|
|
369
|
-
if (checked) {
|
|
370
|
-
showColumnKeys.push(node.key);
|
|
371
|
-
} else {
|
|
372
|
-
showColumnKeys = showColumnKeys.filter((item) => item !== node.key);
|
|
373
|
-
}
|
|
374
|
-
this.state.showColumnKeys = showColumnKeys;
|
|
375
|
-
}
|
|
404
|
+
|
|
376
405
|
handleDragStart(node: any) {
|
|
377
406
|
this.state.currentColumn = node.data;
|
|
378
407
|
}
|
|
@@ -386,7 +415,7 @@ export default class HtTable extends Vue {
|
|
|
386
415
|
// console.log("tree drag over: ", dropNode.label);
|
|
387
416
|
}
|
|
388
417
|
handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
|
|
389
|
-
const { showColumns, currentColumn,
|
|
418
|
+
const { showColumns, currentColumn, checkedColumnKeys } = this.state;
|
|
390
419
|
// if ((dropType === "before" || dropType === "after") && currentColumn) {
|
|
391
420
|
// const data = showColumns.filter(
|
|
392
421
|
// (item) => item.key !== currentColumn?.key
|
|
@@ -396,11 +425,12 @@ export default class HtTable extends Vue {
|
|
|
396
425
|
// ? data.splice(index, 0, currentColumn)
|
|
397
426
|
// : data.splice(index + 1, 0, currentColumn);
|
|
398
427
|
// console.log("tree drag end: ", currentColumn, showColumnKeys);
|
|
399
|
-
if (currentColumn &&
|
|
428
|
+
if (currentColumn && checkedColumnKeys.includes(currentColumn.key)) {
|
|
400
429
|
setTimeout(() => {
|
|
401
430
|
(this.$refs.tree as any).setChecked(currentColumn, true);
|
|
402
431
|
}, 0);
|
|
403
432
|
}
|
|
433
|
+
//console.log("handleDragEnd", this.columns);
|
|
404
434
|
|
|
405
435
|
// }
|
|
406
436
|
}
|
|
@@ -442,8 +472,46 @@ export default class HtTable extends Vue {
|
|
|
442
472
|
// };
|
|
443
473
|
return tempObj ? tempObj[keyArr[i]] : null;
|
|
444
474
|
}
|
|
475
|
+
/** 现在自定义列弹窗 */
|
|
445
476
|
showFilterModel() {
|
|
446
477
|
this.state.visibleFilter = true;
|
|
478
|
+
this.state.checkedColumnKeys = this.state.showColumnKeys;
|
|
479
|
+
this.state.allColumns = JSON.parse(JSON.stringify(this.state.showColumns));
|
|
480
|
+
}
|
|
481
|
+
/** 自定义列表时候选中列 */
|
|
482
|
+
changeColumns(node: any, checked: boolean) {
|
|
483
|
+
let { checkedColumnKeys } = this.state;
|
|
484
|
+
if (checked) {
|
|
485
|
+
checkedColumnKeys.push(node.key);
|
|
486
|
+
} else {
|
|
487
|
+
checkedColumnKeys = checkedColumnKeys.filter((item) => item !== node.key);
|
|
488
|
+
}
|
|
489
|
+
this.state.checkedColumnKeys = checkedColumnKeys;
|
|
490
|
+
}
|
|
491
|
+
/** 自定义列排序的确定功能 */
|
|
492
|
+
confirmSortAndshow() {
|
|
493
|
+
this.state.loading = true;
|
|
494
|
+
this.state.showColumns = [];
|
|
495
|
+
const { allColumns, checkedColumnKeys } = this.state;
|
|
496
|
+
//对列表check复制
|
|
497
|
+
allColumns.forEach(
|
|
498
|
+
(item) => (item.checked = checkedColumnKeys.includes(item.key))
|
|
499
|
+
);
|
|
500
|
+
//将复选框选中行展示到列中 */
|
|
501
|
+
this.state.showColumnKeys = checkedColumnKeys;
|
|
502
|
+
//将列的顺序进行处理已经存储
|
|
503
|
+
|
|
504
|
+
if (this.uuId) {
|
|
505
|
+
window.localStorage.setItem(
|
|
506
|
+
"table_" + this.uuId,
|
|
507
|
+
JSON.stringify(allColumns)
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
this.state.showColumns = allColumns;
|
|
511
|
+
this.state.visibleFilter = false;
|
|
512
|
+
this.state.loading = false;
|
|
513
|
+
/** 自定义列回调 */
|
|
514
|
+
this.$emit("customColumn", allColumns);
|
|
447
515
|
}
|
|
448
516
|
/** 遍历循环展示row数据 */
|
|
449
517
|
showValue(row: any, key: string) {
|
|
@@ -501,9 +569,47 @@ export default class HtTable extends Vue {
|
|
|
501
569
|
};
|
|
502
570
|
}
|
|
503
571
|
}
|
|
572
|
+
get getAllColumns() {
|
|
573
|
+
const { allColumns } = this.state;
|
|
574
|
+
return allColumns.filter((item) => !item.hide);
|
|
575
|
+
}
|
|
504
576
|
@Watch("columns")
|
|
505
577
|
setColumns(columns?: Column[]) {
|
|
506
|
-
|
|
578
|
+
const { showColumns } = this.state;
|
|
579
|
+
/** 当前所有key */
|
|
580
|
+
let allKeys: any = {};
|
|
581
|
+
/** 新来的所有key */
|
|
582
|
+
let newKeys: any = {};
|
|
583
|
+
showColumns.forEach((item) => {
|
|
584
|
+
allKeys = { ...allKeys, [item.key]: true };
|
|
585
|
+
});
|
|
586
|
+
columns?.forEach((item) => {
|
|
587
|
+
newKeys = { ...newKeys, [item.key]: true };
|
|
588
|
+
});
|
|
589
|
+
/** 查找出所有的当前不存在的key */
|
|
590
|
+
const newColumns = columns?.filter((item) => !allKeys[item.key]);
|
|
591
|
+
/** 查找出当前已有的key */
|
|
592
|
+
const successColumns = showColumns?.filter((item) => newKeys[item.key]);
|
|
593
|
+
const tempColumns: Column[] = [];
|
|
594
|
+
const lastColumn: Column[] = [];
|
|
595
|
+
successColumns.forEach((item, index) => {
|
|
596
|
+
/** 去除操作列 */
|
|
597
|
+
if (item.key !== "handel") {
|
|
598
|
+
tempColumns.push(item);
|
|
599
|
+
} else {
|
|
600
|
+
lastColumn.push(item);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
newColumns?.forEach((item, index) => {
|
|
604
|
+
/** 去除操作列 */
|
|
605
|
+
if (item.key !== "handel") {
|
|
606
|
+
tempColumns.push(item);
|
|
607
|
+
} else {
|
|
608
|
+
lastColumn.push(item);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
/** 去除多余并且添加新增的 */
|
|
612
|
+
this.creatInitColumnKey([...tempColumns, ...lastColumn]);
|
|
507
613
|
}
|
|
508
614
|
}
|
|
509
615
|
</script>
|
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-02-
|
|
7
|
+
* @LastEditTime: 2022-02-14 09:39:55
|
|
8
8
|
*/
|
|
9
9
|
/** 初始的默认条数 */
|
|
10
10
|
export const defalutPageSize = 10
|
|
@@ -76,8 +76,10 @@ export interface Column {
|
|
|
76
76
|
showOverflowTooltip?: boolean;
|
|
77
77
|
/** 筛选时候是否禁用 */
|
|
78
78
|
disabled?: boolean;
|
|
79
|
-
|
|
79
|
+
/** 自定义列时候展示额外信息 */
|
|
80
80
|
property?: string;
|
|
81
|
+
/** 自定义列时候处理是否被选中 */
|
|
82
|
+
checked?: boolean;
|
|
81
83
|
}
|
|
82
84
|
export interface PageInfoType {
|
|
83
85
|
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-02-
|
|
7
|
+
* @LastEditTime: 2022-02-14 10:13:10
|
|
8
8
|
-->
|
|
9
9
|
<template>
|
|
10
10
|
<div>
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
<div ref="ht-pdf">
|
|
31
31
|
<HtTable :data="state.data"
|
|
32
32
|
:height="200"
|
|
33
|
+
uuId="54598fs1okdsfsdfk2"
|
|
33
34
|
:showFilter="true"
|
|
34
35
|
:columns="state.columns">
|
|
35
36
|
|
|
36
|
-
<div slot="header_name">测试名字</div>
|
|
37
37
|
</HtTable>
|
|
38
38
|
</div>
|
|
39
39
|
<!-- <el-dropdown>
|
|
@@ -82,7 +82,7 @@ export default class Index extends Vue {
|
|
|
82
82
|
data: [
|
|
83
83
|
{
|
|
84
84
|
name: "胡涛",
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
age: 12,
|
|
87
87
|
sex: "e49961a4f385e5d341ce3a01ee674c90ea9e037b734228fe26753a01ee674c90,e49961a4f385e5d341ce3a01ee674c90ea9e037b734228fe26753a01ee674c90",
|
|
88
88
|
id: 1,
|