bri-components 1.3.63 → 1.3.65

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.63",
3
+ "version": "1.3.65",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -186,6 +186,15 @@
186
186
  }
187
187
  },
188
188
  mounted () {},
189
- methods: {}
189
+ methods: {
190
+ // hidden columns
191
+ hideColumnsByKeys (keys = []) {
192
+ this.$refs["briTable"].hideColumnsByKeys(keys);
193
+ },
194
+ // show cloumns
195
+ showColumnsByKeys (keys = []) {
196
+ this.$refs["briTable"].showColumnsByKeys(keys);
197
+ }
198
+ }
190
199
  };
191
200
  </script>
@@ -11,6 +11,7 @@
11
11
 
12
12
  <!-- 表格 -->
13
13
  <bri-table
14
+ ref="briTable"
14
15
  class="DshFlatTable-main"
15
16
  :columns="showColumns"
16
17
  :data="renderedListData"
@@ -11,6 +11,7 @@
11
11
 
12
12
  <!-- 表格 -->
13
13
  <bri-table
14
+ ref="briTable"
14
15
  class="DshTreeTable-main"
15
16
  :columns="showColumns"
16
17
  :data="renderedListData"
@@ -138,12 +138,12 @@
138
138
  this.$https({
139
139
  url: {
140
140
  module: "sheet",
141
- name: "index"
141
+ name: "customFilter"
142
142
  },
143
143
  params: this.listParams,
144
144
  loadingName: "listPropsObj.isLoading",
145
145
  callback: data => {
146
- this.listData = data.list;
146
+ this.listData = data.list.slice(0, 50);
147
147
  this.curDataItem = this.listData[0];
148
148
  }
149
149
  });
@@ -13,13 +13,14 @@ export default {
13
13
 
14
14
  if (this.initFlag) {
15
15
  item.__old__ = true; // 标记老数据(initFlag不用在data中声明)
16
- item.__isRendered__ = true;
17
- item.__isShow__ = true;
18
- item.__isTmpShow__ = true;
19
- item.__isSearchShow__ = false;
20
16
  }
17
+ item.__isRendered__ = true;
18
+ item.__isShow__ = true;
19
+ item.__isTmpShow__ = true;
20
+ item.__isSearchShow__ = false;
21
21
  });
22
22
 
23
+ console.log(this.initFlag);
23
24
  this.initFlag = false;
24
25
  return this.data;
25
26
  },
@@ -48,32 +49,18 @@ export default {
48
49
  : [];
49
50
  },
50
51
 
51
- tablePropsObj () {
52
- return {
53
- maxHeight: this.contentHeight,
54
- cellStyleOption: {
55
- bodyCellClass: ({ column, row, rowIndex }) => {
56
- return "bri-table-td" +
57
- `${this.getRowCanEdit(row)
58
- ? " bri-table-td-edit"
59
- : ""
60
- }` +
61
- `${this.isSearching
62
- ? !row.__isSearchShow__
63
- ? " bri-table-td-hide"
64
- : ""
65
- : ""
66
- }`;
67
- }
68
- }
69
- };
70
- },
71
52
  showColumns () {
72
53
  return [
73
54
  ...(this.useSelection === true ? [this.selectionColumn] : []),
74
55
  ...(this.useIndex === true ? [this.indexColumn] : []),
75
56
  ...this.$transformToColumns(this.contentColumns),
76
- ...(this.$getOperationList(["canDelete"]).length ? [this.operationColumn] : [])
57
+ ...(
58
+ this.isSearching
59
+ ? []
60
+ : this.$getOperationList(["canDelete"]).length
61
+ ? [this.operationColumn]
62
+ : []
63
+ )
77
64
  ];
78
65
  },
79
66
  indexColumn () {
@@ -8,7 +8,6 @@ export default {
8
8
  isExpandAction: false,
9
9
 
10
10
  searchMode: "flat" // "flat", "tree"
11
-
12
11
  };
13
12
  },
14
13
  computed: {
@@ -62,11 +61,10 @@ export default {
62
61
  tablePropsObj () {
63
62
  return {
64
63
  maxHeight: this.contentHeight,
65
- // rowStyleOption: {
66
- // hoverHighlight: true,
67
- // clickHighlight: true,
68
- // stripe: true // 斑马纹
69
- // },
64
+ // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
65
+ columnHiddenOption: {
66
+ defaultHiddenColumnKeys: this.hideColKeys
67
+ },
70
68
  cellStyleOption: {
71
69
  bodyCellClass: ({ row, column, rowIndex }) => {
72
70
  return "bri-table-td" +
@@ -91,10 +89,6 @@ export default {
91
89
  : ""
92
90
  }`;
93
91
  }
94
- },
95
- // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
96
- columnHiddenOption: {
97
- defaultHiddenColumnKeys: []
98
92
  }
99
93
  };
100
94
  },
@@ -104,11 +98,13 @@ export default {
104
98
  this.expandColumn,
105
99
  ...(this.useIndex === true ? [this.indexColumn] : []),
106
100
  ...this.$transformToColumns(this.contentColumns),
107
- ...(this.isSearching
108
- ? []
109
- : this.$getOperationList(["canDelete"]).length
110
- ? [this.operationColumn]
111
- : [])
101
+ ...(
102
+ this.isSearching
103
+ ? []
104
+ : this.$getOperationList(["canDelete"]).length
105
+ ? [this.operationColumn]
106
+ : []
107
+ )
112
108
  ];
113
109
  },
114
110
  expandColumn () {
@@ -215,11 +211,6 @@ export default {
215
211
  };
216
212
  },
217
213
 
218
- // 筛选回调
219
- searchCb (conditions) {
220
- this.isExpandAction = false;
221
- this.dftAdvSearch.conditions = conditions;
222
- },
223
214
  // 展开/隐藏节点
224
215
  toggleExpand (row, bool = true) {
225
216
  this.isExpandAction = true;
@@ -67,6 +67,7 @@ export default {
67
67
  showRuleMessage: false, // 进行全体校验
68
68
  ruleRecordMap: {}, // 单元格是否发生校验的记录映射
69
69
 
70
+ hideStatus: true,
70
71
  dftAdvSearch: {
71
72
  logic: "and",
72
73
  conditions: []
@@ -90,6 +91,14 @@ export default {
90
91
  isEnlargeFlag: true, // 为重渲染膜态框内容而用
91
92
 
92
93
  topOperationMap: {
94
+ canHideOrShow: {
95
+ name: "显示/隐藏字段",
96
+ type: "canHideOrShow",
97
+ // icon: "md-share-alt",
98
+ size: "small",
99
+ btnType: "text",
100
+ event: "toggleHideOrShow"
101
+ },
93
102
  canQuote: {
94
103
  name: "引用",
95
104
  type: "canQuote",
@@ -186,9 +195,17 @@ export default {
186
195
  _disabledBtns: false, // 禁用增删按钮
187
196
  _disabledCreateBtn: false, // 置灰新增按钮,目前只内部使用,comp_web数据表配置页那块
188
197
  _disabledOldDataRow: false, // 置灰老数据行包含删除
198
+
199
+ _hideColKeys: [], // 隐藏/查看列字段的keys
200
+ _searchList: [], // 作为搜索的字段
201
+ _searchLabelWidth: 100, // 搜索的label宽度
202
+ _tableAdvSearch: {
203
+ logic: "and",
204
+ conditions: []
205
+ }, // 筛选默认值(cascaderTable和flatTable组件里默认值情使用时,以及modSetForm里,会重置_tableAdvSearch)
206
+
189
207
  _isImport: false, // 导入
190
208
  _isExport: false, // 导出
191
-
192
209
  _isQuote: false, // 引用
193
210
  _quoteDataCanEdit: false, // 引用的数据是否能编辑
194
211
  _quoteListFields: [], // 引用列表的显示字段
@@ -196,13 +213,6 @@ export default {
196
213
  logic: "and",
197
214
  conditions: []
198
215
  }, // 引用列表筛选条件
199
-
200
- _searchList: [], // 作为搜索的字段
201
- _searchLabelWidth: 100, // 搜索的label宽度
202
- _tableAdvSearch: {
203
- logic: "and",
204
- conditions: []
205
- }, // 筛选默认值(cascaderTable和flatTable组件里默认值情使用时,以及modSetForm里,会重置_tableAdvSearch)
206
216
  ...this.propsObj,
207
217
 
208
218
  _contentHeight: this.propsObj._contentHeight || 500 // 表格最大高度
@@ -249,6 +259,7 @@ export default {
249
259
  disabledOldDataRow () {
250
260
  return this.selfPropsObj._disabledOldDataRow;
251
261
  },
262
+
252
263
  isImport () {
253
264
  return this.selfPropsObj._isImport;
254
265
  },
@@ -268,6 +279,9 @@ export default {
268
279
  return this.$transformAdvSearch(this.selfPropsObj._quoteAdvSearch, this.allFormList, this.parentObj);
269
280
  },
270
281
 
282
+ hideColKeys () {
283
+ return this.selfPropsObj._hideColKeys || [];
284
+ },
271
285
  searchList () {
272
286
  return this.selfPropsObj._searchList || []; // 级联表切层级表时 值会undefined覆盖selfPropsObj默认的[]
273
287
  },
@@ -313,14 +327,16 @@ export default {
313
327
  return this.selfPropsObj._searchLabelWidth;
314
328
  },
315
329
  rowsNum () {
316
- return this.showListData.length;
330
+ return this.isSearching
331
+ ? this.showListData.length
332
+ : this.allListData.length;
317
333
  },
318
334
  rowsNumStr () {
319
335
  return `当前“${this.isSearching ? "筛选" : "全部"}”范围, 共 ${this.rowsNum} 行`;
320
336
  },
321
337
 
322
- showListData () {
323
- console.log("showListData");
338
+ renderedListData () {
339
+ console.log("renderedListData");
324
340
  return this.allListData.filter(row => {
325
341
  if (this.isSearching) {
326
342
  const bool = this.$isAdvRelyAccord(this.finalTableAdvSearch, row);
@@ -331,21 +347,17 @@ export default {
331
347
  row.__isRendered__ = true;
332
348
  row.__isSearchShow__ = true;
333
349
  }
334
-
335
- return bool;
336
- } else {
337
- return true;
338
350
  }
351
+
352
+ return row.__isRendered__;
339
353
  });
340
354
  },
341
- renderedListData () {
342
- console.log("renderedListData");
343
- return this.allListData.filter(row =>
344
- row.__isRendered__ || (
345
- this.isSearching
346
- ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
347
- : false
348
- )
355
+ showListData () {
356
+ console.log("showListData");
357
+ return this.renderedListData.filter(row =>
358
+ this.isSearching
359
+ ? !!row.__isSearchShow__
360
+ : !!row.__isShow__
349
361
  );
350
362
  },
351
363
  parentDataId () {
@@ -375,13 +387,28 @@ export default {
375
387
 
376
388
  tablePropsObj () {
377
389
  return {
390
+ // rowStyleOption: {
391
+ // hoverHighlight: true,
392
+ // clickHighlight: true,
393
+ // stripe: true // 斑马纹
394
+ // },
378
395
  maxHeight: this.contentHeight,
396
+ // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
397
+ columnHiddenOption: {
398
+ defaultHiddenColumnKeys: [...this.hideColKeys]
399
+ },
379
400
  cellStyleOption: {
380
401
  bodyCellClass: ({ column, row, rowIndex }) => {
381
402
  return "bri-table-td" +
382
403
  `${this.getRowCanEdit(row)
383
404
  ? " bri-table-td-edit"
384
405
  : ""
406
+ }` +
407
+ `${this.isSearching
408
+ ? !row.__isSearchShow__
409
+ ? " bri-table-td-hide"
410
+ : ""
411
+ : ""
385
412
  }`;
386
413
  }
387
414
  }
@@ -426,6 +453,7 @@ export default {
426
453
  return this.columns.filter(col => this.$isAdvRelyShow(col, this.allListData, this.parentObj, true));
427
454
  },
428
455
  contentColumns () {
456
+ console.log("contentColumns");
429
457
  return this.filterColumns.map(colItem => ({
430
458
  filter: undefined,
431
459
  sortBy: undefined,
@@ -555,6 +583,10 @@ export default {
555
583
  ...(this.topOperationMap || {}),
556
584
  ...(this.baseOperationMap || {}),
557
585
 
586
+ canHideOrShow: {
587
+ ...this.topOperationMap.canHideOrShow,
588
+ name: this.hideStatus ? "显示字段" : "隐藏字段"
589
+ },
558
590
  canCreate: {
559
591
  ...this.baseOperationMap.canCreate,
560
592
  disabled: !!this.disabledCreateBtn
@@ -568,6 +600,7 @@ export default {
568
600
  undefined,
569
601
  this.canEdit
570
602
  ? [
603
+ ...(this.hideColKeys.length ? ["canHideOrShow"] : []),
571
604
  ...(this.isQuote ? ["canQuote"] : []),
572
605
  ...(this.isImport ? ["canImport"] : []),
573
606
  ...(this.isExport ? ["canExport"] : []),
@@ -575,6 +608,7 @@ export default {
575
608
  ...(this.disabledBtns ? ["changeVal"] : this.baseOperationBtns)
576
609
  ]
577
610
  : [
611
+ ...(this.hideColKeys.length ? ["canHideOrShow"] : []),
578
612
  ...(this.isExport ? ["canExport"] : []),
579
613
  "canEnlarge"
580
614
  ]
@@ -634,6 +668,17 @@ export default {
634
668
  this.$emit("change", { list: this.allListData, rowDefault: this.rowDefault }, ...params);
635
669
  },
636
670
 
671
+ /* ----------- 隐藏/显示字段 ---------- */
672
+ toggleHideOrShow () {
673
+ if (this.hideStatus === true) {
674
+ this.$refs["briTable"].showColumnsByKeys(this.hideColKeys);
675
+ } else {
676
+ this.$refs["briTable"].hideColumnsByKeys(this.hideColKeys);
677
+ }
678
+
679
+ this.hideStatus = !this.hideStatus;
680
+ },
681
+
637
682
  /* ----------- 全屏 ---------- */
638
683
  // 打开全屏模态框
639
684
  clickEnlarge (operationItem) {