bri-components 1.3.92 → 1.3.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.3.92",
3
+ "version": "1.3.93",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "ali-oss": "^6.13.1",
34
34
  "axios": "^0.23.0",
35
- "bri-datas": "^1.1.65",
35
+ "bri-datas": "^1.1.94",
36
36
  "jshint": "^2.12.0",
37
37
  "jsonlint": "^1.6.3",
38
38
  "minio": "7.1.0",
@@ -112,6 +112,9 @@ export default {
112
112
  _contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
113
113
  };
114
114
  },
115
+ maxLevel () {
116
+ return this.selfPropsObj._maxLevel;
117
+ },
115
118
 
116
119
  allTreeData () {
117
120
  // console.log("allTreeData");
@@ -150,27 +153,6 @@ export default {
150
153
  this.$set(treeFormItem, "level", treeFormIndex + 1);
151
154
  this.$set(treeFormItem, "canDelete", true);
152
155
  });
153
-
154
- // 循环遍树,给根节点赋值
155
- const loop = (nodes = []) => {
156
- nodes.forEach(rowItem => {
157
- if (rowItem.children && rowItem.children.length) {
158
- loop(rowItem.children);
159
- } else {
160
- // 根节点下所有表格字段加上监测,注入到节点对象中,必须$set,牵扯_rely值再出现并没有检测
161
- this.selfColumns.forEach(subFormItem => {
162
- this.$set(rowItem, subFormItem._key, rowItem[subFormItem._key]);
163
- });
164
- }
165
-
166
- if (this.initFlag) {
167
- this.fixRowItem(rowItem);
168
- }
169
- });
170
- };
171
- loop(this.data);
172
-
173
- this.initFlag = false;
174
156
  },
175
157
 
176
158
  /* ----------- 操作 ---------- */
@@ -233,7 +215,6 @@ export default {
233
215
  this.change("changeNode", col, row, rowIndex);
234
216
  },
235
217
 
236
- /* ----------- ---------- */
237
218
  // 节点操作 -插入一行
238
219
  clickCreate (operationItem, row, rowIndex, col) {
239
220
  const nodeData = this.getNodeData(col, row, rowIndex);
@@ -413,14 +394,7 @@ export default {
413
394
  }),
414
395
 
415
396
  // 级联最末级表头的下拉
416
- (
417
- !this.isSearching &&
418
- column.colType === "tree" &&
419
- column.level === this.treeColumns.length &&
420
- this.$getOperationList(this.getTreeThBtns(column, colIndex)).length
421
- )
422
- ? this.getDropdownRender(h, "th", column, colIndex)
423
- : undefined
397
+ this.getDropdownRender(h, "th", column, colIndex)
424
398
  ]);
425
399
  };
426
400
  },
@@ -486,12 +460,7 @@ export default {
486
460
  ]),
487
461
 
488
462
  // 操作下拉
489
- (
490
- !this.isSearching &&
491
- this.$getOperationList(this.getTreeTdBtns(column, row, rowIndex)).length
492
- )
493
- ? this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
494
- : undefined
463
+ this.getDropdownRender(h, "td", column, undefined, row, rowIndex)
495
464
  ]
496
465
  // 汇总单元格
497
466
  : h("span", this.getSummaryTdVal(column, row, rowIndex))
@@ -515,45 +484,55 @@ export default {
515
484
  },
516
485
  // 下拉渲染函数
517
486
  getDropdownRender (h, position = "th", column, colIndex, row, rowIndex) {
518
- return h("dsh-dropdown", {
519
- class: "bri-table-dropdown",
520
- props: {
521
- menuClass: "bri-table-dropdown-list",
522
- trigger: "hover",
523
- list: position === "th"
524
- ? this.$getOperationList(this.getTreeThBtns(column, colIndex))
525
- : this.$getOperationList(this.getTreeTdBtns(column, row, rowIndex))
526
- },
527
- on: {
528
- click: (operationItem) => {
529
- position === "th"
530
- ? this.$dispatchEvent(operationItem, column, colIndex)
531
- : this.$dispatchEvent(operationItem, row, rowIndex, column);
532
- }
533
- },
534
- nativeOn: {
535
- click: (e) => {
536
- e.stopPropagation();
537
- }
538
- }
539
- }, [
540
- h("a", {
541
- style: {
542
- fontWeight: "500",
543
- color: this.appColor
487
+ const list = position === "th"
488
+ ? this.$getOperationList(this.getTreeThBtns(column, colIndex))
489
+ : this.$getOperationList(this.getTreeTdBtns(column, row, rowIndex));
490
+
491
+ return !this.isSearching &&
492
+ list.length &&
493
+ (
494
+ position === "th"
495
+ ? column.colType === "tree" && column.level === this.treeColumns.length
496
+ : true
497
+ )
498
+ ? h("dsh-dropdown", {
499
+ class: "bri-table-dropdown",
500
+ props: {
501
+ menuClass: "bri-table-dropdown-list",
502
+ trigger: "hover",
503
+ list: list
544
504
  },
545
- attrs: {
546
- href: "javascript:void(0)"
505
+ on: {
506
+ click: (operationItem) => {
507
+ position === "th"
508
+ ? this.$dispatchEvent(operationItem, column, colIndex)
509
+ : this.$dispatchEvent(operationItem, row, rowIndex, column);
510
+ }
511
+ },
512
+ nativeOn: {
513
+ click: (e) => {
514
+ e.stopPropagation();
515
+ }
547
516
  }
548
517
  }, [
549
- h("Icon", {
550
- props: {
551
- type: "md-arrow-dropdown-circle",
552
- size: "16"
518
+ h("a", {
519
+ style: {
520
+ fontWeight: "500",
521
+ color: this.appColor
522
+ },
523
+ attrs: {
524
+ href: "javascript:void(0)"
553
525
  }
554
- })
526
+ }, [
527
+ h("Icon", {
528
+ props: {
529
+ type: "md-arrow-dropdown-circle",
530
+ size: "16"
531
+ }
532
+ })
533
+ ])
555
534
  ])
556
- ]);
535
+ : undefined;
557
536
  },
558
537
 
559
538
  /* ----------- 方法 ---------- */
@@ -591,8 +570,8 @@ export default {
591
570
  // 表头 -树节点表头-获取下拉操作
592
571
  getTreeThBtns (col) {
593
572
  return [
594
- "createCol",
595
- ...(col.level > 1 && col.canDelete === true ? ["deleteCol"] : [])
573
+ ...(col.level <= this.maxLevel ? ["createCol"] : []), // 限制最大添加到几级
574
+ ...(col.level > 1 && col.canDelete === true ? ["deleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
596
575
  ];
597
576
  },
598
577
 
@@ -667,7 +646,13 @@ export default {
667
646
  name: `${this.$numToChinese(level)}级节点${list.length + 1}`,
668
647
  level: level,
669
648
  isLeaf: true,
670
- children: []
649
+ children: [],
650
+ // __old__: false,
651
+ __isDefault__: this.controlKey === "_default",
652
+ __isRendered__: true,
653
+ __isShow__: true,
654
+ __isTmpShow__: true,
655
+ __isSearchShow__: false
671
656
  };
672
657
  },
673
658
 
@@ -713,10 +698,10 @@ export default {
713
698
 
714
699
  // 循环遍树节点
715
700
  const loop = (nodes = []) => {
716
- nodes.forEach(node => {
701
+ nodes.forEach(rowItem => {
717
702
  // 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
718
- let curCol = treeForm[node.level - 1];
719
- this.$setObj(node, {
703
+ let curCol = treeForm[rowItem.level - 1];
704
+ this.$setObj(rowItem, {
720
705
  _key: curCol._key,
721
706
  level: curCol.level,
722
707
  isEdit: false,
@@ -725,51 +710,54 @@ export default {
725
710
  });
726
711
 
727
712
  // 最后一列(根节点)
728
- if (node.level === treeForm.length) {
713
+ if (rowItem.level === treeForm.length) {
729
714
  // 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
730
715
  if (this.isDeleteColStatus) {
731
- let subNode = node.children[0];
716
+ let subNode = rowItem.children[0];
732
717
  subForm.forEach(subFormItem => {
733
718
  // 用$set也可以
734
- node[subFormItem._key] = subNode[subFormItem._key];
719
+ rowItem[subFormItem._key] = subNode[subFormItem._key];
735
720
  });
736
721
  }
737
722
 
738
- node.children = [];
739
- node.isLeaf = true;
723
+ rowItem.children = [];
724
+ rowItem.isLeaf = true;
740
725
  }
741
726
  // 非最后一列(最后一列前的列,非根节点),需继续向下循环
742
727
  else {
743
728
  // 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
744
- if (node.level === treeForm.length - 1) {
745
- if (node.children.length > 1) {
746
- treeForm[node.level].canDelete = false;
729
+ if (rowItem.level === treeForm.length - 1) {
730
+ if (rowItem.children.length > 1) {
731
+ treeForm[rowItem.level].canDelete = false;
747
732
  }
748
733
  }
749
734
 
750
735
  // 非最后一列的 正常的非根节点
751
- if (node.children && node.children.length) {
752
- loop(node.children);
736
+ if (rowItem.children && rowItem.children.length) {
737
+ loop(rowItem.children);
753
738
  }
754
739
  // 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
755
740
  // 特别提示:新增的是根节点行,不会走此处代码
756
741
  else {
757
- const newNode = this.getNewNode(node.level + 1, node.children);
742
+ const newNode = this.getNewNode(rowItem.level + 1, rowItem.children);
758
743
  subForm.forEach(subFormItem => {
759
744
  // 用$set也可以
760
- newNode[subFormItem._key] = node[subFormItem._key];
761
- delete node[subFormItem._key];
745
+ newNode[subFormItem._key] = rowItem[subFormItem._key];
746
+ delete rowItem[subFormItem._key];
762
747
  });
763
- node.children.push(newNode);
748
+ rowItem.children.push(newNode);
764
749
 
765
- loop(node.children);
750
+ loop(rowItem.children);
766
751
  }
767
752
  }
753
+
754
+ this.fixRowItem(rowItem);
768
755
  });
769
756
  };
770
757
  loop(nodes);
771
- this.isDeleteColStatus = false;
772
758
 
759
+ this.isDeleteColStatus = false;
760
+ this.initFlag = false;
773
761
  return nodes;
774
762
  },
775
763
  // 转化渲染使用的columns数组
@@ -823,12 +811,20 @@ export default {
823
811
  },
824
812
  getFilteredNodes (nodes = []) {
825
813
  const loop = (nodes = []) => {
826
- return nodes.filter(node => {
827
- if (node.children && node.children.length) {
828
- const children = loop(node.children);
814
+ return nodes.filter(rowItem => {
815
+ if (rowItem.children && rowItem.children.length) {
816
+ const children = loop(rowItem.children);
829
817
  return !!children.length;
830
818
  } else {
831
- return this.$isAdvRelyAccord(this.finalTableAdvSearch, node);
819
+ const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, rowItem);
820
+ // 重置
821
+ rowItem.__isSearchShow__ = false;
822
+ if (bool) {
823
+ rowItem.__isRendered__ = true;
824
+ rowItem.__isSearchShow__ = true;
825
+ }
826
+
827
+ return bool;
832
828
  }
833
829
  });
834
830
  };
@@ -8,14 +8,7 @@ export default {
8
8
  computed: {
9
9
  allListData () {
10
10
  this.data.forEach(rowItem => {
11
- if (this.initFlag) {
12
- this.fixRowItem(rowItem);
13
- }
14
-
15
- rowItem.__isRendered__ = true;
16
- rowItem.__isShow__ = true;
17
- rowItem.__isTmpShow__ = true;
18
- rowItem.__isSearchShow__ = false;
11
+ this.fixRowItem(rowItem);
19
12
  });
20
13
 
21
14
  this.initFlag = false;
@@ -104,11 +97,12 @@ export default {
104
97
  ...this.$deepCopy(this.selfRowDefault),
105
98
  ...this.$deepCopy(mergeRowData),
106
99
  _id: this.$ObjectID().str,
100
+ // __old__: false,
101
+ __isDefault__: this.controlKey === "_default",
107
102
  __isRendered__: true,
108
103
  __isShow__: true,
109
104
  __isTmpShow__: true,
110
- __isSearchShow__: false,
111
- __isDefault__: this.controlKey === "_default"
105
+ __isSearchShow__: false
112
106
  };
113
107
  const list = this.data;
114
108
  const newRowIndex = row
@@ -129,6 +123,10 @@ export default {
129
123
  this.change("deleteRow", null, row, rowIndex);
130
124
  }
131
125
  });
126
+ },
127
+
128
+ change (eventType, col, row, rowIndex, ...params) {
129
+ this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
132
130
  }
133
131
  }
134
132
  };
@@ -6,8 +6,6 @@ export default {
6
6
  props: {},
7
7
  data () {
8
8
  return {
9
- // 除了__readonly__, __isDefault__, __old__, __isQuote__不处理
10
- deleteProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
11
9
  searchMode: "flat" // "flat", "tree"
12
10
  };
13
11
  },
@@ -168,11 +166,12 @@ export default {
168
166
  isLeaf: true,
169
167
  children: [],
170
168
  // __old__: false,
171
- __isExpand__: false,
169
+ __isDefault__: this.controlKey === "_default",
172
170
  __isRendered__: true,
173
171
  __isShow__: true,
174
- __isTmpShow__: false,
175
- __isSearchShow__: false
172
+ __isTmpShow__: true,
173
+ __isSearchShow__: false,
174
+ __isExpand__: false
176
175
  };
177
176
  const list = row
178
177
  ? this.getParentRow(row, this.data).children
@@ -193,11 +192,12 @@ export default {
193
192
  isLeaf: true,
194
193
  children: [],
195
194
  // __old__: false,
196
- __isExpand__: false,
195
+ __isDefault__: this.controlKey === "_default",
197
196
  __isRendered__: true,
198
197
  __isShow__: true,
199
- __isTmpShow__: false,
200
- __isSearchShow__: false
198
+ __isTmpShow__: true,
199
+ __isSearchShow__: false,
200
+ __isExpand__: false
201
201
  };
202
202
  const list = row.children;
203
203
  const newRowIndex = list.length;
@@ -221,6 +221,9 @@ export default {
221
221
  }
222
222
  });
223
223
  },
224
+ change (eventType, col, row, rowIndex, ...params) {
225
+ this.$emit("change", { tree: this.data, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
226
+ },
224
227
 
225
228
  /* ------ 工具方法 ------- */
226
229
  // 加工树形数据
@@ -299,26 +302,7 @@ export default {
299
302
  }, rowItem);
300
303
  }
301
304
 
302
- if (this.initFlag) {
303
- this.fixRowItem(rowItem);
304
-
305
- // 初次进来把前端存的状态值全部清除
306
- this.deleteProperties.forEach(property => {
307
- delete rowItem[property];
308
- });
309
- // rowItem.__isExpand__ = false;
310
- // rowItem.__isSearchShow__ = false;
311
- // 第一级的需要显示出来
312
- if (rowItem.level == 1) {
313
- rowItem.__isRendered__ = true;
314
- rowItem.__isShow__ = true;
315
- rowItem.__isTmpShow__ = true;
316
- } else {
317
- // rowItem.__isRendered__ = false;
318
- // rowItem.__isShow__ = false;
319
- // rowItem.__isTmpShow__ = false;
320
- }
321
- }
305
+ this.fixRowItem(rowItem);
322
306
  });
323
307
  loop(treeData);
324
308
 
@@ -64,6 +64,8 @@ export default {
64
64
  widthMap: this.$getModFieldPropertyMap("width"),
65
65
  initDftValMap: this.$getModFieldPropertyMap("initDefaultVal"),
66
66
 
67
+ saveProperties: ["__readonly__", "__isDefault__", "__old__", "__isQuote__"],
68
+ resetProperties: ["__treeIndex__", "__isExpand__", "__isRendered__", "__isShow__", "__isTmpShow__", "__isSearchShow__"],
67
69
  initFlag: true,
68
70
  showRuleMessage: false, // 进行全体校验
69
71
  ruleRecordMap: {}, // 单元格是否发生校验的记录映射
@@ -396,26 +398,26 @@ export default {
396
398
  .filter(id => !!id);
397
399
  },
398
400
  renderedListData () {
399
- return this.allListData.filter(row => {
401
+ return this.allListData.filter(rowItem => {
400
402
  if (this.isSearching) {
401
- const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, row);
403
+ const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, rowItem);
402
404
 
403
405
  // 重置
404
- row.__isSearchShow__ = false;
406
+ rowItem.__isSearchShow__ = false;
405
407
  if (bool) {
406
- row.__isRendered__ = true;
407
- row.__isSearchShow__ = true;
408
+ rowItem.__isRendered__ = true;
409
+ rowItem.__isSearchShow__ = true;
408
410
  }
409
411
  }
410
412
 
411
- return row.__isRendered__;
413
+ return rowItem.__isRendered__;
412
414
  });
413
415
  },
414
416
  showListData () {
415
- return this.renderedListData.filter(row =>
417
+ return this.renderedListData.filter(rowItem =>
416
418
  this.isSearching
417
- ? !!row.__isSearchShow__
418
- : !!row.__isShow__
419
+ ? !!rowItem.__isSearchShow__
420
+ : !!rowItem.__isShow__
419
421
  );
420
422
  },
421
423
  parentDataId () {
@@ -428,7 +430,7 @@ export default {
428
430
  const initDftVal = this.initDftValMap[column._type];
429
431
 
430
432
  return Object.assign(obj, {
431
- [column._key]: this.$isEmptyData(dftInRowVal)
433
+ [column._key]: dftInRowVal === undefined
432
434
  ? this.$isEmptyData(dftVal)
433
435
  ? initDftVal
434
436
  : dftVal
@@ -834,9 +836,6 @@ export default {
834
836
  this.$set(this.ruleRecordMap, `${row._id}dsh${col._key}`, { showRuleMessage: true });
835
837
  this.change("changeVal", col, row, rowIndex, ...params);
836
838
  },
837
- change (eventType, col, row, rowIndex, ...params) {
838
- this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, eventType, col, row, rowIndex, ...params);
839
- },
840
839
 
841
840
  /* ----------- 隐藏/显示字段 ---------- */
842
841
  toggleHideOrShow () {
@@ -1368,25 +1367,50 @@ export default {
1368
1367
  },
1369
1368
  // 初始化时 修复数据
1370
1369
  fixRowItem (row) {
1371
- // TODO:修正数据level属性,后期可以删除
1372
- if (["cascaderTable"].includes(this.controlType)) {
1373
- row.level = row.level || levelNum;
1374
- }
1370
+ if (this.initFlag) {
1371
+ // TODO:修正数据level属性,后期可以删除
1372
+ if (["cascaderTable"].includes(this.controlType)) {
1373
+ row.level = row.level || levelNum;
1374
+ }
1375
1375
 
1376
- if (row._id) {
1377
- if (this.defaultListDataIds.includes(row._id)) {
1378
- row.__isDefault__ = true;
1376
+ if (row._id) {
1377
+ if (this.defaultListDataIds.includes(row._id)) {
1378
+ row.__isDefault__ = true;
1379
1379
 
1380
- // 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
1380
+ // 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
1381
+ row._id = this.$ObjectID().str;
1382
+ }
1383
+ } else {
1381
1384
  row._id = this.$ObjectID().str;
1382
1385
  }
1383
- } else {
1384
- row._id = this.$ObjectID().str;
1385
- }
1386
1386
 
1387
- // 除了__readonly__, __isDefault__, __old__, __isQuote__不处理
1388
- row.__old__ = this.controlKey === "_default" ? false : !this.parentObj.__isCreate__; // 标记老数据
1389
- row.__isDefault__ = this.controlKey === "_default" ? true : !!row.__isDefault__; // 标记默认数据(配置端默认值)
1387
+ row.__old__ = this.controlKey === "_default" ? false : !this.parentObj.__isCreate__; // 标记老数据
1388
+ row.__isDefault__ = this.controlKey === "_default" ? true : !!row.__isDefault__; // 标记默认数据(配置端默认值)
1389
+
1390
+ // 初次进来 把关于展示的状态值全部清除
1391
+ this.resetProperties.forEach(property => {
1392
+ delete row[property];
1393
+ });
1394
+ if (["treeTable"].includes(this.inTableType)) {
1395
+ // row.__isExpand__ = false;
1396
+ // row.__isSearchShow__ = false;
1397
+ // 第一级的需要显示出来
1398
+ if (row.level == 1) {
1399
+ row.__isRendered__ = true;
1400
+ row.__isShow__ = true;
1401
+ row.__isTmpShow__ = true;
1402
+ } else {
1403
+ // row.__isRendered__ = false;
1404
+ // row.__isShow__ = false;
1405
+ // row.__isTmpShow__ = false;
1406
+ }
1407
+ } else {
1408
+ row.__isRendered__ = true;
1409
+ row.__isShow__ = true;
1410
+ row.__isTmpShow__ = true;
1411
+ row.__isSearchShow__ = false;
1412
+ }
1413
+ }
1390
1414
  }
1391
1415
  }
1392
1416
  };