htui-yllkbz 1.2.56 → 1.3.0

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htui-yllkbz",
3
- "version": "1.2.56",
3
+ "version": "1.3.0",
4
4
  "typings": "types/index.d.ts",
5
5
  "main": "lib/htui.common.js",
6
6
  "style": "lib/htui.css",
@@ -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-13 16:12:46
8
+ * @LastEditTime: 2022-02-14 11:30:46
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
- :center="true">
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:40vh;margin-top:12px'>
213
- <el-scrollbar style='height: calc(40vh + 17px)'>
214
- <el-tree :data="columns"
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.showColumnKeys"
225
+ :default-checked-keys="state.checkedColumnKeys"
226
226
  @check-change="changeColumns"
227
227
  :allow-drag="allowDrag"
228
228
  draggable
@@ -230,11 +230,17 @@
230
230
  <span class="custom-tree-node"
231
231
  slot-scope="{ node, data }">
232
232
  <slot :name="'header_'+data.key"
233
- :column="data">{{data.title}}<span style="color:#C0C4CC">{{data.property?`(${data.property==='base'?'基础属性':'扩展属性'})`:''}}</span></slot>
233
+ :column="data">{{data.title}}<span style="color:#C0C4CC">{{data.property?`(${data.property})`:''}}</span></slot>
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.state.showColumns = this.columns;
355
+ //this.setColumns(this.columns);
342
356
  if (this.uuId) {
343
357
  //通过uuid获取缓存起来的header显示信息
344
- const showKeys: string | null = window.localStorage.getItem(
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 (showKeys) {
348
- this.state.showColumnKeys = JSON.parse(showKeys);
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
- creatInitColumnKey() {
357
- this.state.showColumnKeys = this.columns.reduce((arr: string[], item) => {
358
- arr.push(item.key);
359
- return arr;
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
- changeColumns(node: any, checked: boolean) {
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, showColumnKeys } = this.state;
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 && showColumnKeys.includes(currentColumn.key)) {
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,52 @@ 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
+ this.state.allColumns = this.getAllColumns;
496
+ const { allColumns, checkedColumnKeys } = this.state;
497
+ //对列表check复制
498
+ allColumns.forEach(
499
+ (item) => (item.checked = checkedColumnKeys.includes(item.key))
500
+ );
501
+ //将复选框选中行展示到列中 */
502
+ this.state.showColumnKeys = checkedColumnKeys;
503
+ //将列的顺序进行处理已经存储
504
+
505
+ if (this.uuId) {
506
+ window.localStorage.setItem(
507
+ "table_" + this.uuId,
508
+ JSON.stringify(allColumns)
509
+ );
510
+ }
511
+ this.state.showColumns = allColumns;
512
+ this.state.visibleFilter = false;
513
+ this.state.loading = false;
514
+ this.$nextTick(() => {
515
+ (this.$refs.comTable as any).doLayout();
516
+ // el-table加ref="multipleTable"
517
+ });
518
+ console.log("allColumns", allColumns, this.getAllColumns);
519
+ /** 自定义列回调 */
520
+ this.$emit("customColumn", allColumns);
447
521
  }
448
522
  /** 遍历循环展示row数据 */
449
523
  showValue(row: any, key: string) {
@@ -501,9 +575,47 @@ export default class HtTable extends Vue {
501
575
  };
502
576
  }
503
577
  }
578
+ get getAllColumns() {
579
+ const { allColumns } = this.state;
580
+ return allColumns.filter((item) => !item.hide);
581
+ }
504
582
  @Watch("columns")
505
583
  setColumns(columns?: Column[]) {
506
- this.state.showColumns = columns || [];
584
+ const { showColumns } = this.state;
585
+ /** 当前所有key */
586
+ let allKeys: any = {};
587
+ /** 新来的所有key */
588
+ let newKeys: any = {};
589
+ showColumns.forEach((item) => {
590
+ allKeys = { ...allKeys, [item.key]: true };
591
+ });
592
+ columns?.forEach((item) => {
593
+ newKeys = { ...newKeys, [item.key]: true };
594
+ });
595
+ /** 查找出所有的当前不存在的key */
596
+ const newColumns = columns?.filter((item) => !allKeys[item.key]);
597
+ /** 查找出当前已有的key */
598
+ const successColumns = showColumns?.filter((item) => newKeys[item.key]);
599
+ const tempColumns: Column[] = [];
600
+ const lastColumn: Column[] = [];
601
+ successColumns.forEach((item, index) => {
602
+ /** 去除操作列 */
603
+ if (item.key !== "handel") {
604
+ tempColumns.push(item);
605
+ } else {
606
+ lastColumn.push(item);
607
+ }
608
+ });
609
+ newColumns?.forEach((item, index) => {
610
+ /** 去除操作列 */
611
+ if (item.key !== "handel") {
612
+ tempColumns.push(item);
613
+ } else {
614
+ lastColumn.push(item);
615
+ }
616
+ });
617
+ /** 去除多余并且添加新增的 */
618
+ this.creatInitColumnKey([...tempColumns, ...lastColumn]);
507
619
  }
508
620
  }
509
621
  </script>
@@ -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-10 10:33:52
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
- /** 自定义列时候展示是否是基础属性还是扩展属性 */
80
- property?: 'base'|'extend';
79
+ /** 自定义列时候展示额外信息 */
80
+ property?: string;
81
+ /** 自定义列时候处理是否被选中 */
82
+ checked?: boolean;
81
83
  }
82
84
  export interface PageInfoType {
83
85
  currentPage: number;
@@ -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-13 16:11:09
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,