bri-components 1.4.76 → 1.4.77

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.4.76",
3
+ "version": "1.4.77",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -84,7 +84,7 @@
84
84
  <span
85
85
  class="DshFlatTable-sort"
86
86
  :style="{ color: appColor }"
87
- @click="changeSort()"
87
+ @click="changeDescSort()"
88
88
  >
89
89
  <dsh-icons
90
90
  class="DshFlatTable-sort-icons"
@@ -194,7 +194,7 @@
194
194
  <span
195
195
  class="DshFlatTable-sort"
196
196
  :style="{ color: appColor }"
197
- @click="changeSort()"
197
+ @click="changeDescSort()"
198
198
  >
199
199
  <dsh-icons
200
200
  class="DshFlatTable-sort-icons"
@@ -3,7 +3,15 @@ export default {
3
3
  components: {},
4
4
  props: {},
5
5
  data () {
6
- return {};
6
+ return {
7
+ isUseDescSort: false,
8
+ pageMode: "small",
9
+ pagePropsObj: {
10
+ page: 1,
11
+ pagesize: 10,
12
+ pagesizeOpts: [10, 20, 30, 50]
13
+ }
14
+ };
7
15
  },
8
16
  computed: {
9
17
  rowspanMap () {
@@ -11,14 +19,10 @@ export default {
11
19
  },
12
20
  selfBasePropsObj () {
13
21
  return {
22
+ _isUseDescSort: false, // 是否使用使用倒序
14
23
  _mergeRowColKeys: [] // 合并行的列
15
- // _isUseDescSort: false // 是否使用使用倒序
16
24
  };
17
25
  },
18
- // // 是否使用倒序
19
- // isUseDescSort () {
20
- // return this.selfPropsObj._isUseDescSort;
21
- // },
22
26
  mergeRowColKeys () {
23
27
  const mergeRowColKeys = this.selfPropsObj._mergeRowColKeys || []; // 配置端有问题,高级依赖时值成undefined了
24
28
  return this.selfColumns
@@ -75,6 +79,26 @@ export default {
75
79
  ? this.showListData
76
80
  : this.curPageShowListData;
77
81
  },
82
+ // 全部数据 或 筛选时符合条件的数据 -当前页的
83
+ curPageShowListData () {
84
+ return this.pagePropsObj.page >= 1
85
+ ? (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize >= this.showListData.length
86
+ ? this.showListData.slice(
87
+ (this.pagePropsObj.page - 2) * this.pagePropsObj.pagesize,
88
+ (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize
89
+ )
90
+ : this.showListData.slice(
91
+ (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
92
+ this.pagePropsObj.page * this.pagePropsObj.pagesize
93
+ )
94
+ : [];
95
+ },
96
+ // 全部数据 或 筛选时符合条件的数据 -共多少分页
97
+ PageNum () {
98
+ return this.selfTotal % this.pagePropsObj.pagesize > 0
99
+ ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
100
+ : Math.floor(this.selfTotal / this.pagePropsObj.pagesize);
101
+ },
78
102
  footerData () {
79
103
  return this.isSearching
80
104
  ? []
@@ -129,6 +153,7 @@ export default {
129
153
  }
130
154
  },
131
155
  created () {
156
+ this.isUseDescSort = this.selfPropsObj._isUseDescSort;
132
157
  this.initRowspan();
133
158
  },
134
159
  methods: {
@@ -136,45 +161,21 @@ export default {
136
161
  selfReset () {
137
162
  this.initRowspan();
138
163
  },
139
- // 初始化合并单元格的rowspan
140
- initRowspan () {
141
- if (this.isMergeRowTable) {
142
- this.$set(this.tableDataObj, "rowspanMap", this.tableDataObj.rowspanMap || {});
143
-
144
- // TODO: 待删除
145
- Object.entries(this.rowspanMap).forEach(arr => {
146
- if (arr[0].includes("dsh")) {
147
- this.rowspanMap[arr[0].split("dsh").join("--")] = this.rowspanMap[arr[1]];
148
- delete this.rowspanMap[arr[0]];
149
- }
150
- });
151
-
152
- this.allListData.forEach((rowItem, rowIndex) => {
153
- this.mergeRowColKeys.forEach(colKey => {
154
- const column = { _key: colKey };
155
-
156
- // 新增页 -行的_id被置换,rowspanMap也要相应置换,还要清除rowspanMap里和默认行老_id相关的
157
- const oldId = this.idRecordMap[rowItem._id];
158
- const oldRow = { ...rowItem, _id: oldId };
159
- if (oldId && ![undefined, null].includes(this.rowspanMap[this.getMixKey(oldRow, column)])) {
160
- this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: oldRow, rowIndex, column });
161
- delete this.rowspanMap[this.getMixKey(oldRow, column)];
162
- } else {
163
- this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: rowItem, rowIndex, column });
164
- }
165
- });
166
- });
167
164
 
168
- // 清除rowspanMap无用的(针对来回改mergeRowColKeys)
169
- Object.entries(this.rowspanMap).forEach(arr => {
170
- const keyArr = arr[0].split("--");
171
- const id = keyArr[0];
172
- const colKey = keyArr.slice(1).join("--");
173
- if (!this.allListMap[id] || !this.mergeRowColKeys.includes(colKey)) {
174
- delete this.rowspanMap[arr[0]];
175
- }
176
- });
177
- }
165
+ // 切换正倒序
166
+ changeDescSort () {
167
+ this.isUseDescSort = !this.isUseDescSort;
168
+ this.changePage(1);
169
+ },
170
+ // 切换分页
171
+ changePage (page) {
172
+ this.pagePropsObj.page = page;
173
+ this.loadingFunc();
174
+ },
175
+ // 切换分页条数
176
+ changePageSize (pagesize) {
177
+ this.pagePropsObj.page = 1;
178
+ this.pagePropsObj.pagesize = pagesize;
178
179
  },
179
180
 
180
181
  // 点击 -添加行
@@ -341,6 +342,46 @@ export default {
341
342
  },
342
343
 
343
344
  /* ----------- 方法 ---------- */
345
+ // 初始化合并单元格的rowspan
346
+ initRowspan () {
347
+ if (this.isMergeRowTable) {
348
+ this.$set(this.tableDataObj, "rowspanMap", this.tableDataObj.rowspanMap || {});
349
+
350
+ // TODO: 待删除
351
+ Object.entries(this.rowspanMap).forEach(arr => {
352
+ if (arr[0].includes("dsh")) {
353
+ this.rowspanMap[arr[0].split("dsh").join("--")] = this.rowspanMap[arr[1]];
354
+ delete this.rowspanMap[arr[0]];
355
+ }
356
+ });
357
+
358
+ this.allListData.forEach((rowItem, rowIndex) => {
359
+ this.mergeRowColKeys.forEach(colKey => {
360
+ const column = { _key: colKey };
361
+
362
+ // 新增页 -行的_id被置换,rowspanMap也要相应置换,还要清除rowspanMap里和默认行老_id相关的
363
+ const oldId = this.idRecordMap[rowItem._id];
364
+ const oldRow = { ...rowItem, _id: oldId };
365
+ if (oldId && ![undefined, null].includes(this.rowspanMap[this.getMixKey(oldRow, column)])) {
366
+ this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: oldRow, rowIndex, column });
367
+ delete this.rowspanMap[this.getMixKey(oldRow, column)];
368
+ } else {
369
+ this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: rowItem, rowIndex, column });
370
+ }
371
+ });
372
+ });
373
+
374
+ // 清除rowspanMap无用的(针对来回改mergeRowColKeys)
375
+ Object.entries(this.rowspanMap).forEach(arr => {
376
+ const keyArr = arr[0].split("--");
377
+ const id = keyArr[0];
378
+ const colKey = keyArr.slice(1).join("--");
379
+ if (!this.allListMap[id] || !this.mergeRowColKeys.includes(colKey)) {
380
+ delete this.rowspanMap[arr[0]];
381
+ }
382
+ });
383
+ }
384
+ },
344
385
  // 加工单元格对应的配置
345
386
  getSelfResetCol ({ row, rowIndex, column }) {
346
387
  return this.mergeRowColKeys.includes(column._key)
@@ -45,10 +45,6 @@ export default {
45
45
  }
46
46
  },
47
47
 
48
- total: {
49
- type: Number,
50
- default: 0
51
- },
52
48
  compareData: {
53
49
  type: Array,
54
50
  default () {
@@ -101,13 +97,6 @@ export default {
101
97
  },
102
98
 
103
99
  isLoading: false,
104
- isUseDescSort: false,
105
- pageMode: "small",
106
- pagePropsObj: {
107
- page: 1,
108
- pagesize: 10,
109
- pagesizeOpts: [10, 20, 30, 50]
110
- },
111
100
 
112
101
  dshRenderName: undefined,
113
102
  hideStatus: true,
@@ -482,29 +471,9 @@ export default {
482
471
  return rowItem;
483
472
  });
484
473
  },
485
- // 全部数据 或 筛选时符合条件的数据 -当前页的
486
- curPageShowListData () {
487
- return this.pagePropsObj.page >= 1
488
- ? (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize >= this.showListData.length
489
- ? this.showListData.slice(
490
- (this.pagePropsObj.page - 2) * this.pagePropsObj.pagesize,
491
- (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize
492
- )
493
- : this.showListData.slice(
494
- (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
495
- this.pagePropsObj.page * this.pagePropsObj.pagesize
496
- )
497
- : [];
498
- },
499
474
  // 全部数据 或 筛选时符合条件的数据 -总数
500
475
  selfTotal () {
501
- return this.total || this.showListData.length;
502
- },
503
- // 全部数据 或 筛选时符合条件的数据 -共多少分页
504
- PageNum () {
505
- return this.selfTotal % this.pagePropsObj.pagesize > 0
506
- ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
507
- : Math.floor(this.selfTotal / this.pagePropsObj.pagesize);
476
+ return this.showListData.length;
508
477
  },
509
478
 
510
479
  parentDataId () {
@@ -874,21 +843,6 @@ export default {
874
843
  changeSelect (...params) {
875
844
  this.$emit("changeSelect", params[0].map(item => item._id), ...params);
876
845
  },
877
- // 切换正倒序
878
- changeSort () {
879
- this.isUseDescSort = !this.isUseDescSort;
880
- this.changePage(1);
881
- },
882
- // 切换分页
883
- changePage (page) {
884
- this.pagePropsObj.page = page;
885
- this.loadingFunc();
886
- },
887
- // 切换分页条数
888
- changePageSize (pagesize) {
889
- this.pagePropsObj.page = 1;
890
- this.pagePropsObj.pagesize = pagesize;
891
- },
892
846
  loadingFunc () {
893
847
  this.isLoading = true;
894
848
  setTimeout(() => {