bri-components 1.4.83 → 1.4.85

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.
@@ -20,25 +20,22 @@ export default {
20
20
  };
21
21
  },
22
22
  computed: {
23
- rowspanMap () {
24
- return this.tableDataObj.rowspanMap || {};
25
- },
26
23
  selfBasePropsObj () {
27
24
  return {
28
25
  _isUseDescSort: false, // 是否使用使用倒序
29
26
  _mergeRowColKeys: [] // 合并行的列
30
27
  };
31
28
  },
29
+ // 是不是合并行表格
30
+ isMergeRowTable () {
31
+ return !!this.mergeRowColKeys.length;
32
+ },
32
33
  mergeRowColKeys () {
33
34
  const mergeRowColKeys = this.selfPropsObj._mergeRowColKeys || []; // 配置端有问题,高级依赖时值成undefined了
34
35
  return this.selfColumns
35
36
  .filter(colItem => mergeRowColKeys.includes(colItem._key))
36
37
  .map(colItem => colItem._key);
37
38
  },
38
- // 是不是合并行表格
39
- isMergeRowTable () {
40
- return !!this.mergeRowColKeys.length;
41
- },
42
39
  // 一级合并列keys(一级合并列:左侧第一合并列和右侧和并列)
43
40
  firstMergeRowColKeys () {
44
41
  if (this.isMergeRowTable) {
@@ -60,14 +57,47 @@ export default {
60
57
  notFirstMergeRowColKeys () {
61
58
  return this.mergeRowColKeys.filter(colKey => !this.firstMergeRowColKeys.includes(colKey));
62
59
  },
63
- // 顶替tableBaseMixin里的
60
+ // 替换tableBaseMixin里的
64
61
  searchTitle () {
65
62
  return `${this.isSearching ? "筛选" : "全部"}数据${this.isMergeRowTable ? `,共 ${this.selfTotal}条;` : ";"}`;
66
63
  },
67
64
 
65
+ /* --- 列字段 --- */
66
+ showColumns () {
67
+ return [
68
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
69
+ ...(this.useIndex === true ? [this.indexColumn] : []),
70
+ ...this.$transformToColumns(this.showContentColumns),
71
+ ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
72
+ ];
73
+ },
74
+ indexColumn () {
75
+ return {
76
+ title: "序号",
77
+ _key: "__index__",
78
+ key: "__index__",
79
+ field: "__index__",
80
+ width: 76,
81
+ align: "center",
82
+ fixed: "left",
83
+ renderBodyCell: ({ row, rowIndex, column }, h) => {
84
+ return [
85
+ h("div", this.isMergeRowTable ? rowIndex + 1 : row.__index__),
86
+
87
+ // 添加符
88
+ ...this.operationIconRender(h, { row, rowIndex, column })
89
+ ];
90
+ }
91
+ };
92
+ },
93
+
94
+ /* --- 数据 --- */
95
+ rowspanMap () {
96
+ return this.tableDataObj.rowspanMap || {};
97
+ },
68
98
  allListData () {
69
- this.data.forEach(rowItem => {
70
- this.fixRowItem(rowItem);
99
+ this.data.forEach(row => {
100
+ this.fixRowData(row);
71
101
  });
72
102
  this.initFlag = false;
73
103
 
@@ -77,41 +107,30 @@ export default {
77
107
  ? [...this.data].reverse()
78
108
  : this.data;
79
109
  },
80
- allListMap () {
81
- return this.$arrToMap(this.allListData, "_id");
110
+ // 全部数据(或筛选出的数据)
111
+ showListData () {
112
+ return this.allListData
113
+ .filter(row =>
114
+ this.isSearching
115
+ ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
116
+ : true
117
+ )
118
+ .map((row, rowIndex) => {
119
+ row.__index__ = rowIndex + 1;
120
+ return row;
121
+ });
82
122
  },
83
123
  selfShowListData () {
84
124
  return this.isMergeRowTable
85
125
  ? this.showListData
86
126
  : this.curPageShowListData;
87
127
  },
88
- // 全部数据 或 筛选时符合条件的数据 -当前页的
89
- curPageShowListData () {
90
- return this.pagePropsObj.page >= 1
91
- ? (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize >= this.showListData.length
92
- ? this.showListData.slice(-(
93
- this.showListData.length % this.pagePropsObj.pagesize === 0
94
- ? this.pagePropsObj.pagesize
95
- : this.showListData.length % this.pagePropsObj.pagesize
96
- ))
97
- : this.showListData.slice(
98
- (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
99
- this.pagePropsObj.page * this.pagePropsObj.pagesize
100
- )
101
- : [];
102
- },
103
- // 全部数据 或 筛选时符合条件的数据 -共多少分页
104
- PageNum () {
105
- return this.selfTotal % this.pagePropsObj.pagesize > 0
106
- ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
107
- : Math.floor(this.selfTotal / this.pagePropsObj.pagesize);
108
- },
109
128
  footerData () {
110
129
  return this.isSearching
111
130
  ? []
112
131
  : this.useSummary && this.allListData.length
113
132
  ? [
114
- this.useFormColumns.reduce((obj, column) => {
133
+ this.contentColumns.reduce((obj, column) => {
115
134
  return {
116
135
  ...obj,
117
136
  [column._key]: column._type === "number" && column._summaryType
@@ -131,42 +150,53 @@ export default {
131
150
  : [];
132
151
  },
133
152
 
134
- showColumns () {
135
- return [
136
- ...(this.useSelection === true ? [this.selectionColumn] : []),
137
- ...(this.useIndex === true ? [this.indexColumn] : []),
138
- ...this.$transformToColumns(this.showContentColumns),
139
- ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
140
- ];
153
+ allListMap () {
154
+ return this.$arrToMap(this.allListData, "_id");
141
155
  },
142
- indexColumn () {
143
- return {
144
- title: "序号",
145
- _key: "__index__",
146
- key: "__index__",
147
- field: "__index__",
148
- width: 76,
149
- align: "center",
150
- fixed: "left",
151
- renderBodyCell: ({ row, rowIndex, column }, h) => {
152
- return [
153
- h("div", this.isMergeRowTable ? rowIndex + 1 : row.__index__),
154
-
155
- // 添加符
156
- ...this.operationIconRender(h, { row, rowIndex, column })
157
- ];
158
- }
159
- };
156
+ // 全部数据 筛选时符合条件的数据 -当前页的
157
+ curPageShowListData () {
158
+ return this.pagePropsObj.page >= 1
159
+ ? (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize >= this.showListData.length
160
+ ? this.showListData.slice(-(
161
+ this.showListData.length % this.pagePropsObj.pagesize === 0
162
+ ? this.pagePropsObj.pagesize
163
+ : this.showListData.length % this.pagePropsObj.pagesize
164
+ ))
165
+ : this.showListData.slice(
166
+ (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
167
+ this.pagePropsObj.page * this.pagePropsObj.pagesize
168
+ )
169
+ : [];
170
+ },
171
+ // 全部数据 或 筛选时符合条件的数据 -共多少分页
172
+ PageNum () {
173
+ return this.selfTotal % this.pagePropsObj.pagesize > 0
174
+ ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
175
+ : Math.floor(this.selfTotal / this.pagePropsObj.pagesize);
160
176
  }
161
177
  },
162
178
  created () {
163
- this.isUseDescSort = this.selfPropsObj._isUseDescSort;
164
- this.initRowspan();
179
+ this.selfInit();
165
180
  },
166
181
  methods: {
182
+ selfInit () {
183
+ this.isUseDescSort = this.selfPropsObj._isUseDescSort;
184
+ this.initRowspan();
185
+ },
167
186
  // 本身的初始化
168
187
  selfReset () {
169
- this.initRowspan();
188
+ this.selfInit();
189
+ },
190
+ fixSelfRowData (row) {
191
+ if (this.initFlag) {
192
+ // 每条数据都补充全所有字段值(赋一个默认的空值)
193
+ this.selfColumns.forEach((colItem) => {
194
+ // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
195
+ if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
196
+ this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
197
+ }
198
+ });
199
+ }
170
200
  },
171
201
 
172
202
  // 切换正倒序
@@ -335,7 +365,7 @@ export default {
335
365
  },
336
366
  quickChangeVal (operationItem, row, rowIndex, column, params) {
337
367
  if (["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
338
- this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
368
+ this.dealRuleRecord(row, column);
339
369
  this.dealSameRowsVal({ row, rowIndex, column });
340
370
 
341
371
  this.change("quickChangeVal", row, rowIndex, column, ...params);
@@ -343,13 +373,32 @@ export default {
343
373
  },
344
374
  changeVal (operationItem, row, rowIndex, column, params) {
345
375
  if (!["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
346
- this.$set(this.ruleRecordMap, this.getMixKey(row, column), { showRuleMessage: true });
376
+ this.dealRuleRecord(row, column);
347
377
  this.dealSameRowsVal({ row, rowIndex, column });
348
378
 
349
379
  this.change("changeVal", row, rowIndex, column, ...params);
350
380
  }
351
381
  },
352
382
 
383
+ bodyCellSpan ({ row, rowIndex, column }) {
384
+ return {
385
+ rowspan: this.mergeRowColKeys.includes(column._key)
386
+ ? this.isSearching
387
+ ? this.getRowspan({ row, rowIndex, column })
388
+ : this.getRealRowspan({ row, rowIndex, column })
389
+ : 1,
390
+ colspan: 1
391
+ };
392
+ },
393
+ // 加工单元格对应的配置
394
+ getSelfResetCol ({ row, rowIndex, column }) {
395
+ return this.mergeRowColKeys.includes(column._key)
396
+ ? {
397
+ _heightAuto: true
398
+ }
399
+ : {};
400
+ },
401
+
353
402
  /* ----------- 方法 ---------- */
354
403
  // 初始化合并单元格的rowspan
355
404
  initRowspan () {
@@ -391,24 +440,6 @@ export default {
391
440
  });
392
441
  }
393
442
  },
394
- // 加工单元格对应的配置
395
- getSelfResetCol ({ row, rowIndex, column }) {
396
- return this.mergeRowColKeys.includes(column._key)
397
- ? {
398
- _heightAuto: true
399
- }
400
- : {};
401
- },
402
- bodyCellSpan ({ row, rowIndex, column }) {
403
- return {
404
- rowspan: this.mergeRowColKeys.includes(column._key)
405
- ? this.isSearching
406
- ? this.getRowspan({ row, rowIndex, column })
407
- : this.getRealRowspan({ row, rowIndex, column })
408
- : 1,
409
- colspan: 1
410
- };
411
- },
412
443
  // 获取合并单元格真实的rowspan
413
444
  getRealRowspan ({ row, rowIndex, column }) {
414
445
  return ![undefined, null].includes(this.rowspanMap[this.getMixKey(row, column)])
@@ -438,12 +469,6 @@ export default {
438
469
 
439
470
  return rowspan;
440
471
  },
441
- // // 是都满足使用quickChange
442
- // isUseQuickChange ({ row, rowIndex, column }) {
443
- // return ["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type) &&
444
- // this.mergeRowColKeys.includes(column._key) &&
445
- // this.rowspanMap[this.getMixKey(row, column)] > 1;
446
- // },
447
472
  // 合并单元格的行,某列的值全部跟着修改
448
473
  dealSameRowsVal ({ row, rowIndex, column }, list = this.allListData) {
449
474
  if (this.mergeRowColKeys.includes(column._key) && this.rowspanMap[this.getMixKey(row, column)] > 1) {
@@ -12,40 +12,7 @@ export default {
12
12
  };
13
13
  },
14
14
 
15
- allTreeData () {
16
- return this.getCalcuedTree(this.data, this.selfColumns);
17
- },
18
- allListData () {
19
- return this.$getTreeFlatArr(this.allTreeData);
20
- },
21
- footerData () {
22
- return this.isSearching
23
- ? []
24
- : this.useSummary && this.allListData.length
25
- ? [
26
- this.useFormColumns.reduce((obj, column) => {
27
- return {
28
- ...obj,
29
- [column._key]: column._type === "number" && column._summaryType
30
- ? this.$calNumList(
31
- this.allListData
32
- .filter(rowItem => rowItem.level === 1)
33
- .map(rowItem => rowItem[column._key]),
34
- column._summaryType,
35
- { ...column, _defaultDigit: 2 }
36
- )
37
- : (obj[column._key] || "--")
38
- };
39
- }, {
40
- _id: this.$ObjectID().str,
41
- __treeIndex__: "汇总",
42
- __isExpand__: "-",
43
- __operation__: "——"
44
- })
45
- ]
46
- : [];
47
- },
48
-
15
+ /* --- 列字段 --- */
49
16
  showColumns () {
50
17
  return [
51
18
  this.expandColumn,
@@ -112,11 +79,53 @@ export default {
112
79
  ];
113
80
  }
114
81
  };
82
+ },
83
+
84
+ /* --- 数据 --- */
85
+ allTreeData () {
86
+ return this.getCalcuedTree(this.data, this.selfColumns);
87
+ },
88
+ allListData () {
89
+ return this.$getTreeFlatArr(this.allTreeData);
90
+ },
91
+ // 全部数据(或筛选出的数据)
92
+ showListData () {
93
+ return this.allListData.filter(row =>
94
+ this.isSearching
95
+ ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
96
+ : row.__isShow__
97
+ );
98
+ },
99
+ footerData () {
100
+ return this.isSearching
101
+ ? []
102
+ : this.useSummary && this.allListData.length
103
+ ? [
104
+ this.contentColumns.reduce((obj, column) => {
105
+ return {
106
+ ...obj,
107
+ [column._key]: column._type === "number" && column._summaryType
108
+ ? this.$calNumList(
109
+ this.allListData
110
+ .filter(row => row.level === 1)
111
+ .map(row => row[column._key]),
112
+ column._summaryType,
113
+ { ...column, _defaultDigit: 2 }
114
+ )
115
+ : (obj[column._key] || "--")
116
+ };
117
+ }, {
118
+ _id: this.$ObjectID().str,
119
+ __treeIndex__: "汇总",
120
+ __isExpand__: "-",
121
+ __operation__: "——"
122
+ })
123
+ ]
124
+ : [];
115
125
  }
116
126
  },
117
127
  created () { },
118
128
  methods: {
119
- /* ------ 工具方法 ------- */
120
129
  // 加工树形数据
121
130
  getCalcuedTree (treeData = [], cols = []) {
122
131
  const loop = (list = [], parentRow, levelNum = 1) =>
@@ -130,7 +139,7 @@ export default {
130
139
  else if (["upToDown"].includes(column._writeSort) && column._noLimitWrite !== true) {
131
140
  // 有父级且值为空的 值置空
132
141
  const val = parentRow && this.$isEmptyData(parentRow[column._key])
133
- ? this.$deepCopy(this.initDftValMap[column._type])
142
+ ? this.$deepCopy(this.dftInitValMap[column._type])
134
143
  : newRow[column._key];
135
144
 
136
145
  this.$set(newRow, column._key, val);
@@ -166,7 +175,7 @@ export default {
166
175
  else if (["downToUp"].includes(column._writeSort) && column._noLimitWrite !== true) {
167
176
  // 子行有空值的 值置空
168
177
  const val = newRow.children.some(sonRow => this.$isEmptyData(sonRow[column._key]))
169
- ? this.$deepCopy(this.initDftValMap[column._type])
178
+ ? this.$deepCopy(this.dftInitValMap[column._type])
170
179
  : newRow[column._key];
171
180
 
172
181
  this.$set(newRow, column._key, val);
@@ -193,12 +202,70 @@ export default {
193
202
  }, rowItem);
194
203
  }
195
204
 
196
- this.fixRowItem(rowItem, levelNum);
205
+ this.fixRowData(rowItem, levelNum);
197
206
  });
198
207
  loop(treeData);
199
208
 
200
209
  this.initFlag = false;
201
210
  return treeData;
211
+ },
212
+ fixSelfRowData (row, levelNum) {
213
+ if (this.initFlag) {
214
+ // 每条数据都补充全所有字段值(赋一个默认的空值)
215
+ this.selfColumns.forEach((colItem) => {
216
+ // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
217
+ if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
218
+ this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
219
+ }
220
+ });
221
+
222
+ row.level = row.level || levelNum; // TODO:修正数据level属性,后期可以删除
223
+ // 第一级的需要显示出来
224
+ if (row.level == 1) {
225
+ row.__isShow__ = true;
226
+ }
227
+ }
228
+ // 计算或其它重新传进来值时
229
+ else {
230
+ // 第一级的需要显示出来
231
+ if (row.level == 1) {
232
+ row.__isShow__ = Object.prototype.hasOwnProperty.call(row, "__isShow__") ? row.__isShow__ : true;
233
+ }
234
+ }
235
+ },
236
+
237
+ // 展开/隐藏节点
238
+ toggleExpand (row, bool = true) {
239
+ this.isExpandAction = true;
240
+ this.$set(row, "__isExpand__", bool);
241
+
242
+ this.toggleDescendantsShow(row, bool);
243
+ },
244
+ // 切换子孙后代的显示/隐藏
245
+ toggleDescendantsShow (row, bool) {
246
+ const loop = (row, isFirstSon) => {
247
+ if (row.children && row.children.length) {
248
+ row.children.forEach(subRow => {
249
+ if (isFirstSon) {
250
+ this.$set(subRow, "__isShow__", bool);
251
+ this.$set(subRow, "__isTmpShow__", bool);
252
+ } else {
253
+ this.$set(subRow, "__isShow__", bool ? !!subRow.__isTmpShow__ : false);
254
+ }
255
+
256
+ loop(subRow);
257
+ });
258
+ }
259
+ };
260
+
261
+ loop(row, true);
262
+ },
263
+ // getNewRowData时,额外补充的行相关的数据
264
+ getSelfNewRowData (level) {
265
+ return {
266
+ // __isExpand__: false, // 此行不用也行
267
+ // __isTmpShow__: true // 此行不用也行
268
+ };
202
269
  }
203
270
  }
204
271
  };