htui-yllkbz 1.2.57 → 1.3.1

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.57",
3
+ "version": "1.3.1",
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: 2021-12-13 15:02:13
8
+ * @LastEditTime: 2022-02-15 10:14:46
9
9
  -->
10
10
  <template>
11
11
  <div v-loading="state.loading">
@@ -195,7 +195,6 @@ export default class HtTable extends Vue {
195
195
  },
196
196
  };
197
197
  created() {
198
- // console.log("this", this.$props);
199
198
  this.setPageInfo(this.pageInfo);
200
199
  }
201
200
  getPropByPath(obj: any, path: string, strict: boolean) {
@@ -224,30 +223,7 @@ export default class HtTable extends Vue {
224
223
  // };
225
224
  return tempObj ? tempObj[keyArr[i]] : null;
226
225
  }
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
- }
226
+
251
227
  /** 监听 */
252
228
  @Watch("pageInfo")
253
229
  setPageInfo(val?: PageInfoType) {
@@ -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-20 17:54:42
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
@@ -234,7 +234,14 @@
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
+ <el-button @click="resetColumn">重置</el-button>
244
+ </span>
238
245
  </el-dialog>
239
246
  <!-- 附件详情弹框 -->
240
247
  <el-dialog :visible.sync="state.visibleFile"
@@ -245,7 +252,7 @@
245
252
  :center="true">
246
253
  <p slot="title"
247
254
  style="font-weight:700;font-size:18px;float:left;margin:0">附件查看</p>
248
-
255
+
249
256
  <div style='overflow:hidden;height:calc(30vh)'>
250
257
  <el-scrollbar style='height: calc(100% + 17px)'>
251
258
  <HtUploadFiles :disabled="true"
@@ -265,7 +272,12 @@ interface State {
265
272
  loading: boolean;
266
273
  /** 展示出来的列表名 */
267
274
  showColumns: Column[];
275
+ /** 全部的列 */
276
+ allColumns: Column[];
277
+ /** 列表展示的列 */
268
278
  showColumnKeys: string[];
279
+ /** 自定义列表选中的列 */
280
+ checkedColumnKeys: string[];
269
281
  /** 是否展示筛选框 */
270
282
  visibleFilter: boolean;
271
283
  /** 是否展示附件 */
@@ -317,6 +329,7 @@ export default class HtTable extends Vue {
317
329
  @Prop() emptyText?: string | number;
318
330
  @Prop() headerRowStyle?: any;
319
331
  @Prop() headerRowClassName?: any;
332
+ @Prop() headerCellClassName?: any;
320
333
  @Prop() headerCellStyle?: any;
321
334
 
322
335
  /** 分页的所有额外信息通过此参数传递 */
@@ -331,48 +344,74 @@ export default class HtTable extends Vue {
331
344
  totalCount: 0,
332
345
  },
333
346
  showColumns: [],
347
+ allColumns: [],
334
348
  currentColumn: undefined,
335
349
  visibleFilter: false,
336
350
  visibleFile: false,
337
351
  showColumnKeys: [],
352
+ checkedColumnKeys: [],
338
353
  };
339
354
  created() {
340
355
  this.setPageInfo(this.pageInfo);
341
- this.state.showColumns = this.columns;
356
+ //this.setColumns(this.columns);
342
357
  if (this.uuId) {
343
358
  //通过uuid获取缓存起来的header显示信息
344
- const showKeys: string | null = window.localStorage.getItem(
359
+ //-todo
360
+ //---columns 要改变
361
+ //---showColumnKeys 要改变
362
+ //---排列顺序要改变 todo
363
+ const allColumns: string | null = window.localStorage.getItem(
345
364
  "table_" + this.uuId
346
365
  );
347
- if (showKeys) {
348
- this.state.showColumnKeys = JSON.parse(showKeys);
366
+ if (allColumns) {
367
+ this.state.allColumns = JSON.parse(allColumns);
368
+ this.state.showColumns = JSON.parse(allColumns);
369
+ this.getShowKeys(this.state.allColumns);
349
370
  } else {
350
- this.creatInitColumnKey();
371
+ this.creatInitColumnKey(this.columns || []);
351
372
  }
352
373
  } else {
353
- this.creatInitColumnKey();
374
+ this.creatInitColumnKey(this.columns || []);
375
+ }
376
+ }
377
+ resetColumn() {
378
+ this.creatInitColumnKey(this.columns || []);
379
+ if (this.uuId) {
380
+ window.localStorage.setItem(
381
+ "table_" + this.uuId,
382
+ JSON.stringify(this.columns || [])
383
+ );
354
384
  }
355
385
  }
356
- creatInitColumnKey() {
357
- this.state.showColumnKeys = this.columns.reduce((arr: string[], item) => {
358
- arr.push(item.key);
359
- return arr;
360
- }, []);
386
+ /** 获取展示的keys值 */
387
+ getShowKeys(data: Column[]) {
388
+ const arr: string[] = [];
389
+ data.forEach((item) => {
390
+ if (item.checked) {
391
+ arr.push(item.key);
392
+ }
393
+ });
394
+ this.state.showColumnKeys = arr;
395
+ }
396
+ /** 初始化columns */
397
+ creatInitColumnKey(columns: Column[]) {
398
+ this.state.allColumns = columns;
399
+ this.state.showColumns = columns;
400
+ this.state.allColumns.forEach((item) => {
401
+ item.checked = true;
402
+ });
403
+ this.$nextTick(() => {
404
+ (this.$refs.comTable as any).doLayout();
405
+ // el-table加ref="comTable"
406
+ });
407
+ this.getShowKeys(this.state.allColumns);
361
408
  }
362
409
  /** 展示附件信息 */
363
410
  showFiles(val = "") {
364
411
  this.state.files = val;
365
412
  this.state.visibleFile = true;
366
413
  }
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
- }
414
+
376
415
  handleDragStart(node: any) {
377
416
  this.state.currentColumn = node.data;
378
417
  }
@@ -386,7 +425,7 @@ export default class HtTable extends Vue {
386
425
  // console.log("tree drag over: ", dropNode.label);
387
426
  }
388
427
  handleDragEnd(draggingNode: any, dropNode: any, dropType: string) {
389
- const { showColumns, currentColumn, showColumnKeys } = this.state;
428
+ const { showColumns, currentColumn, checkedColumnKeys } = this.state;
390
429
  // if ((dropType === "before" || dropType === "after") && currentColumn) {
391
430
  // const data = showColumns.filter(
392
431
  // (item) => item.key !== currentColumn?.key
@@ -395,14 +434,12 @@ export default class HtTable extends Vue {
395
434
  // dropType === "before"
396
435
  // ? data.splice(index, 0, currentColumn)
397
436
  // : data.splice(index + 1, 0, currentColumn);
398
- // console.log("tree drag end: ", currentColumn, showColumnKeys);
399
- if (currentColumn && showColumnKeys.includes(currentColumn.key)) {
437
+
438
+ if (currentColumn && checkedColumnKeys.includes(currentColumn.key)) {
400
439
  setTimeout(() => {
401
440
  (this.$refs.tree as any).setChecked(currentColumn, true);
402
441
  }, 0);
403
442
  }
404
-
405
- // }
406
443
  }
407
444
  handleDrop() {
408
445
  // console.log("tree drop: ", dropNode, dropType);
@@ -442,33 +479,54 @@ export default class HtTable extends Vue {
442
479
  // };
443
480
  return tempObj ? tempObj[keyArr[i]] : null;
444
481
  }
482
+ /** 现在自定义列弹窗 */
445
483
  showFilterModel() {
446
484
  this.state.visibleFilter = true;
485
+ this.state.checkedColumnKeys = this.state.showColumnKeys;
486
+ this.state.allColumns = JSON.parse(JSON.stringify(this.state.showColumns));
447
487
  }
448
- /** 遍历循环展示row数据 */
449
- showValue(row: any, key: string) {
450
- if (key) {
451
- if (key.includes(".")) {
452
- //存在多级的情况
453
- //console.log("eval", key, eval(row[key]));
454
- // const arrKey = key.split(".");
455
- // let data = row;
456
- // arrKey.forEach((item) => {
457
- // if (data[item]) {
458
- // data = data[item];
459
- // } else {
460
- // data = "";
461
- // }
462
- // });
463
- return "";
464
- } else {
465
- //如果不存在多级数据
466
- return row[key];
467
- }
488
+ /** 自定义列表时候选中列 */
489
+ changeColumns(node: any, checked: boolean) {
490
+ let { checkedColumnKeys } = this.state;
491
+ if (checked) {
492
+ checkedColumnKeys.push(node.key);
468
493
  } else {
469
- return "";
494
+ checkedColumnKeys = checkedColumnKeys.filter((item) => item !== node.key);
470
495
  }
496
+ this.state.checkedColumnKeys = checkedColumnKeys;
471
497
  }
498
+ /** 自定义列排序的确定功能 */
499
+ confirmSortAndshow() {
500
+ this.state.loading = true;
501
+ this.state.showColumns = [];
502
+ this.state.allColumns = this.getAllColumns;
503
+ const { allColumns, checkedColumnKeys } = this.state;
504
+ //对列表check复制
505
+ allColumns.forEach(
506
+ (item) => (item.checked = checkedColumnKeys.includes(item.key))
507
+ );
508
+ //将复选框选中行展示到列中 */
509
+ this.state.showColumnKeys = checkedColumnKeys;
510
+ //将列的顺序进行处理已经存储
511
+
512
+ if (this.uuId) {
513
+ window.localStorage.setItem(
514
+ "table_" + this.uuId,
515
+ JSON.stringify(allColumns)
516
+ );
517
+ }
518
+ this.state.showColumns = allColumns;
519
+ this.state.visibleFilter = false;
520
+ this.state.loading = false;
521
+ this.$nextTick(() => {
522
+ (this.$refs.comTable as any).doLayout();
523
+ // el-table加ref="multipleTable"
524
+ });
525
+
526
+ /** 自定义列回调 */
527
+ this.$emit("customColumn", allColumns);
528
+ }
529
+
472
530
  /** 获取显示出来的table头信息 */
473
531
  get showColumns() {
474
532
  const { showColumnKeys, showColumns } = this.state;
@@ -501,9 +559,47 @@ export default class HtTable extends Vue {
501
559
  };
502
560
  }
503
561
  }
562
+ get getAllColumns() {
563
+ const { allColumns } = this.state;
564
+ return allColumns.filter((item) => !item.hide);
565
+ }
504
566
  @Watch("columns")
505
567
  setColumns(columns?: Column[]) {
506
- this.state.showColumns = columns || [];
568
+ const { showColumns } = this.state;
569
+ /** 当前所有key */
570
+ let allKeys: any = {};
571
+ /** 新来的所有key */
572
+ let newKeys: any = {};
573
+ showColumns.forEach((item) => {
574
+ allKeys = { ...allKeys, [item.key]: true };
575
+ });
576
+ columns?.forEach((item) => {
577
+ newKeys = { ...newKeys, [item.key]: true };
578
+ });
579
+ /** 查找出所有的当前不存在的key */
580
+ const newColumns = columns?.filter((item) => !allKeys[item.key]);
581
+ /** 查找出当前已有的key */
582
+ const successColumns = showColumns?.filter((item) => newKeys[item.key]);
583
+ const tempColumns: Column[] = [];
584
+ const lastColumn: Column[] = [];
585
+ successColumns.forEach((item, index) => {
586
+ /** 去除操作列 */
587
+ if (item.key !== "handel") {
588
+ tempColumns.push(item);
589
+ } else {
590
+ lastColumn.push(item);
591
+ }
592
+ });
593
+ newColumns?.forEach((item, index) => {
594
+ /** 去除操作列 */
595
+ if (item.key !== "handel") {
596
+ tempColumns.push(item);
597
+ } else {
598
+ lastColumn.push(item);
599
+ }
600
+ });
601
+ /** 去除多余并且添加新增的 */
602
+ this.creatInitColumnKey([...tempColumns, ...lastColumn]);
507
603
  }
508
604
  }
509
605
  </script>
@@ -4,7 +4,7 @@
4
4
  * @Author: hutao
5
5
  * @Date: 2022-02-11 14:26:23
6
6
  * @LastEditors: hutao
7
- * @LastEditTime: 2022-02-11 14:36:54
7
+ * @LastEditTime: 2022-02-15 10:14:00
8
8
  -->
9
9
  <!--
10
10
  * @Descripttion: 附件列表 ------没有搞完
@@ -135,7 +135,7 @@ export default class HtUploadFiles extends Vue {
135
135
  }
136
136
  /** 附件上传成功 */
137
137
  onSuccess(response: { fileToken: string }) {
138
- console.log("response, file, fileList", response.fileToken);
138
+ // console.log("response, file, fileList", response.fileToken);
139
139
  //this.state.files.push(response.fileToken);
140
140
  this.getFileInfo(response.fileToken);
141
141
  }
@@ -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
- /** 自定义列时候展示额外信息 */
79
+ /** 自定义列时候展示额外信息 */
80
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,