htui-yllkbz 1.2.55 → 1.2.59
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 -124
- package/lib/htui.common.js.gz +0 -0
- package/lib/htui.umd.js +239 -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 +148 -36
- package/src/packages/type.ts +5 -1
- package/src/views/About.vue +5 -2
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-11
|
|
8
|
+
* @LastEditTime: 2022-02-14 11:20:36
|
|
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,13 +205,15 @@
|
|
|
205
205
|
title="属性设置"
|
|
206
206
|
:append-to-body="true"
|
|
207
207
|
:close-on-click-modal="true"
|
|
208
|
-
width="400px"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
width="400px">
|
|
209
|
+
<p slot="title"
|
|
210
|
+
style="font-weight:700;font-size:18px;float:left;margin:0">自定义列展示</p>
|
|
211
|
+
<div style='overflow:hidden;height:35vh;margin-top:12px'>
|
|
212
|
+
<el-scrollbar style='height: calc(35vh + 17px)'>
|
|
213
|
+
<el-tree :data="getAllColumns"
|
|
213
214
|
ref="tree"
|
|
214
215
|
show-checkbox
|
|
216
|
+
:expand-on-click-node="false"
|
|
215
217
|
node-key="key"
|
|
216
218
|
:check-on-click-node="false"
|
|
217
219
|
@node-drag-start="handleDragStart"
|
|
@@ -220,7 +222,7 @@
|
|
|
220
222
|
@node-drag-over="handleDragOver"
|
|
221
223
|
@node-drag-end="handleDragEnd"
|
|
222
224
|
@node-drop="handleDrop"
|
|
223
|
-
:default-checked-keys="state.
|
|
225
|
+
:default-checked-keys="state.checkedColumnKeys"
|
|
224
226
|
@check-change="changeColumns"
|
|
225
227
|
:allow-drag="allowDrag"
|
|
226
228
|
draggable
|
|
@@ -228,11 +230,17 @@
|
|
|
228
230
|
<span class="custom-tree-node"
|
|
229
231
|
slot-scope="{ node, data }">
|
|
230
232
|
<slot :name="'header_'+data.key"
|
|
231
|
-
:column="data">{{data.title}}</slot>
|
|
233
|
+
:column="data">{{data.title}}<span style="color:#C0C4CC">{{data.property?`(${data.property})`:''}}</span></slot>
|
|
232
234
|
</span>
|
|
233
235
|
</el-tree>
|
|
234
236
|
</el-scrollbar>
|
|
237
|
+
|
|
235
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>
|
|
236
244
|
</el-dialog>
|
|
237
245
|
<!-- 附件详情弹框 -->
|
|
238
246
|
<el-dialog :visible.sync="state.visibleFile"
|
|
@@ -242,8 +250,8 @@
|
|
|
242
250
|
width="400px"
|
|
243
251
|
:center="true">
|
|
244
252
|
<p slot="title"
|
|
245
|
-
style="font-weight:700;font-size:18px;float:left">附件查看</p>
|
|
246
|
-
|
|
253
|
+
style="font-weight:700;font-size:18px;float:left;margin:0">附件查看</p>
|
|
254
|
+
|
|
247
255
|
<div style='overflow:hidden;height:calc(30vh)'>
|
|
248
256
|
<el-scrollbar style='height: calc(100% + 17px)'>
|
|
249
257
|
<HtUploadFiles :disabled="true"
|
|
@@ -263,7 +271,12 @@ interface State {
|
|
|
263
271
|
loading: boolean;
|
|
264
272
|
/** 展示出来的列表名 */
|
|
265
273
|
showColumns: Column[];
|
|
274
|
+
/** 全部的列 */
|
|
275
|
+
allColumns: Column[];
|
|
276
|
+
/** 列表展示的列 */
|
|
266
277
|
showColumnKeys: string[];
|
|
278
|
+
/** 自定义列表选中的列 */
|
|
279
|
+
checkedColumnKeys: string[];
|
|
267
280
|
/** 是否展示筛选框 */
|
|
268
281
|
visibleFilter: boolean;
|
|
269
282
|
/** 是否展示附件 */
|
|
@@ -315,6 +328,7 @@ export default class HtTable extends Vue {
|
|
|
315
328
|
@Prop() emptyText?: string | number;
|
|
316
329
|
@Prop() headerRowStyle?: any;
|
|
317
330
|
@Prop() headerRowClassName?: any;
|
|
331
|
+
@Prop() headerCellClassName?: any;
|
|
318
332
|
@Prop() headerCellStyle?: any;
|
|
319
333
|
|
|
320
334
|
/** 分页的所有额外信息通过此参数传递 */
|
|
@@ -329,48 +343,65 @@ export default class HtTable extends Vue {
|
|
|
329
343
|
totalCount: 0,
|
|
330
344
|
},
|
|
331
345
|
showColumns: [],
|
|
346
|
+
allColumns: [],
|
|
332
347
|
currentColumn: undefined,
|
|
333
348
|
visibleFilter: false,
|
|
334
349
|
visibleFile: false,
|
|
335
350
|
showColumnKeys: [],
|
|
351
|
+
checkedColumnKeys: [],
|
|
336
352
|
};
|
|
337
353
|
created() {
|
|
338
354
|
this.setPageInfo(this.pageInfo);
|
|
339
|
-
this.
|
|
355
|
+
//this.setColumns(this.columns);
|
|
340
356
|
if (this.uuId) {
|
|
341
357
|
//通过uuid获取缓存起来的header显示信息
|
|
342
|
-
|
|
358
|
+
//-todo
|
|
359
|
+
//---columns 要改变
|
|
360
|
+
//---showColumnKeys 要改变
|
|
361
|
+
//---排列顺序要改变 todo
|
|
362
|
+
const allColumns: string | null = window.localStorage.getItem(
|
|
343
363
|
"table_" + this.uuId
|
|
344
364
|
);
|
|
345
|
-
if (
|
|
346
|
-
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);
|
|
347
369
|
} else {
|
|
348
|
-
this.creatInitColumnKey();
|
|
370
|
+
this.creatInitColumnKey(this.columns || []);
|
|
349
371
|
}
|
|
350
372
|
} else {
|
|
351
|
-
this.creatInitColumnKey();
|
|
373
|
+
this.creatInitColumnKey(this.columns || []);
|
|
352
374
|
}
|
|
353
375
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
+
// }, []);
|
|
359
398
|
}
|
|
360
399
|
/** 展示附件信息 */
|
|
361
400
|
showFiles(val = "") {
|
|
362
401
|
this.state.files = val;
|
|
363
402
|
this.state.visibleFile = true;
|
|
364
403
|
}
|
|
365
|
-
|
|
366
|
-
let { showColumnKeys } = this.state;
|
|
367
|
-
if (checked) {
|
|
368
|
-
showColumnKeys.push(node.key);
|
|
369
|
-
} else {
|
|
370
|
-
showColumnKeys = showColumnKeys.filter((item) => item !== node.key);
|
|
371
|
-
}
|
|
372
|
-
this.state.showColumnKeys = showColumnKeys;
|
|
373
|
-
}
|
|
404
|
+
|
|
374
405
|
handleDragStart(node: any) {
|
|
375
406
|
this.state.currentColumn = node.data;
|
|
376
407
|
}
|
|
@@ -384,7 +415,7 @@ export default class HtTable extends Vue {
|
|
|
384
415
|
// console.log("tree drag over: ", dropNode.label);
|
|
385
416
|
}
|
|
386
417
|
handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
|
|
387
|
-
const { showColumns, currentColumn,
|
|
418
|
+
const { showColumns, currentColumn, checkedColumnKeys } = this.state;
|
|
388
419
|
// if ((dropType === "before" || dropType === "after") && currentColumn) {
|
|
389
420
|
// const data = showColumns.filter(
|
|
390
421
|
// (item) => item.key !== currentColumn?.key
|
|
@@ -394,11 +425,12 @@ export default class HtTable extends Vue {
|
|
|
394
425
|
// ? data.splice(index, 0, currentColumn)
|
|
395
426
|
// : data.splice(index + 1, 0, currentColumn);
|
|
396
427
|
// console.log("tree drag end: ", currentColumn, showColumnKeys);
|
|
397
|
-
if (currentColumn &&
|
|
428
|
+
if (currentColumn && checkedColumnKeys.includes(currentColumn.key)) {
|
|
398
429
|
setTimeout(() => {
|
|
399
430
|
(this.$refs.tree as any).setChecked(currentColumn, true);
|
|
400
431
|
}, 0);
|
|
401
432
|
}
|
|
433
|
+
//console.log("handleDragEnd", this.columns);
|
|
402
434
|
|
|
403
435
|
// }
|
|
404
436
|
}
|
|
@@ -440,8 +472,50 @@ export default class HtTable extends Vue {
|
|
|
440
472
|
// };
|
|
441
473
|
return tempObj ? tempObj[keyArr[i]] : null;
|
|
442
474
|
}
|
|
475
|
+
/** 现在自定义列弹窗 */
|
|
443
476
|
showFilterModel() {
|
|
444
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
|
+
this.$nextTick(() => {
|
|
514
|
+
(this.$refs.comTable as any).doLayout();
|
|
515
|
+
// el-table加ref="multipleTable"
|
|
516
|
+
});
|
|
517
|
+
/** 自定义列回调 */
|
|
518
|
+
this.$emit("customColumn", allColumns);
|
|
445
519
|
}
|
|
446
520
|
/** 遍历循环展示row数据 */
|
|
447
521
|
showValue(row: any, key: string) {
|
|
@@ -499,9 +573,47 @@ export default class HtTable extends Vue {
|
|
|
499
573
|
};
|
|
500
574
|
}
|
|
501
575
|
}
|
|
576
|
+
get getAllColumns() {
|
|
577
|
+
const { allColumns } = this.state;
|
|
578
|
+
return allColumns.filter((item) => !item.hide);
|
|
579
|
+
}
|
|
502
580
|
@Watch("columns")
|
|
503
581
|
setColumns(columns?: Column[]) {
|
|
504
|
-
|
|
582
|
+
const { showColumns } = this.state;
|
|
583
|
+
/** 当前所有key */
|
|
584
|
+
let allKeys: any = {};
|
|
585
|
+
/** 新来的所有key */
|
|
586
|
+
let newKeys: any = {};
|
|
587
|
+
showColumns.forEach((item) => {
|
|
588
|
+
allKeys = { ...allKeys, [item.key]: true };
|
|
589
|
+
});
|
|
590
|
+
columns?.forEach((item) => {
|
|
591
|
+
newKeys = { ...newKeys, [item.key]: true };
|
|
592
|
+
});
|
|
593
|
+
/** 查找出所有的当前不存在的key */
|
|
594
|
+
const newColumns = columns?.filter((item) => !allKeys[item.key]);
|
|
595
|
+
/** 查找出当前已有的key */
|
|
596
|
+
const successColumns = showColumns?.filter((item) => newKeys[item.key]);
|
|
597
|
+
const tempColumns: Column[] = [];
|
|
598
|
+
const lastColumn: Column[] = [];
|
|
599
|
+
successColumns.forEach((item, index) => {
|
|
600
|
+
/** 去除操作列 */
|
|
601
|
+
if (item.key !== "handel") {
|
|
602
|
+
tempColumns.push(item);
|
|
603
|
+
} else {
|
|
604
|
+
lastColumn.push(item);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
newColumns?.forEach((item, index) => {
|
|
608
|
+
/** 去除操作列 */
|
|
609
|
+
if (item.key !== "handel") {
|
|
610
|
+
tempColumns.push(item);
|
|
611
|
+
} else {
|
|
612
|
+
lastColumn.push(item);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
/** 去除多余并且添加新增的 */
|
|
616
|
+
this.creatInitColumnKey([...tempColumns, ...lastColumn]);
|
|
505
617
|
}
|
|
506
618
|
}
|
|
507
619
|
</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,6 +76,10 @@ export interface Column {
|
|
|
76
76
|
showOverflowTooltip?: boolean;
|
|
77
77
|
/** 筛选时候是否禁用 */
|
|
78
78
|
disabled?: boolean;
|
|
79
|
+
/** 自定义列时候展示额外信息 */
|
|
80
|
+
property?: string;
|
|
81
|
+
/** 自定义列时候处理是否被选中 */
|
|
82
|
+
checked?: boolean;
|
|
79
83
|
}
|
|
80
84
|
export interface PageInfoType {
|
|
81
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,9 +30,10 @@
|
|
|
30
30
|
<div ref="ht-pdf">
|
|
31
31
|
<HtTable :data="state.data"
|
|
32
32
|
:height="200"
|
|
33
|
+
uuId="54598fs1okdsfsdfk2"
|
|
34
|
+
:showFilter="true"
|
|
33
35
|
:columns="state.columns">
|
|
34
36
|
|
|
35
|
-
<div slot="header_name">测试名字</div>
|
|
36
37
|
</HtTable>
|
|
37
38
|
</div>
|
|
38
39
|
<!-- <el-dropdown>
|
|
@@ -81,6 +82,7 @@ export default class Index extends Vue {
|
|
|
81
82
|
data: [
|
|
82
83
|
{
|
|
83
84
|
name: "胡涛",
|
|
85
|
+
|
|
84
86
|
age: 12,
|
|
85
87
|
sex: "e49961a4f385e5d341ce3a01ee674c90ea9e037b734228fe26753a01ee674c90,e49961a4f385e5d341ce3a01ee674c90ea9e037b734228fe26753a01ee674c90",
|
|
86
88
|
id: 1,
|
|
@@ -125,6 +127,7 @@ export default class Index extends Vue {
|
|
|
125
127
|
title: "姓名",
|
|
126
128
|
key: "test.title",
|
|
127
129
|
width: "300px",
|
|
130
|
+
property: "base",
|
|
128
131
|
disabled: true,
|
|
129
132
|
},
|
|
130
133
|
{
|