bri-components 1.4.75 → 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.75",
3
+ "version": "1.4.77",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -165,7 +165,7 @@
165
165
  },
166
166
  on: {
167
167
  click: (operationItem) => {
168
- this.$dshEmit(operationItem, params.row, params.row);
168
+ this.$dshEmit(operationItem, params.row, params.index);
169
169
  }
170
170
  },
171
171
  nativeOn: {
@@ -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,24 +471,9 @@ export default {
482
471
  return rowItem;
483
472
  });
484
473
  },
485
- // 全部数据 或 筛选时符合条件的数据 -当前页的
486
- curPageShowListData () {
487
- return this.pagePropsObj.page >= 1
488
- ? this.showListData.slice(
489
- (this.pagePropsObj.page - 1) * this.pagePropsObj.pagesize,
490
- this.pagePropsObj.page * this.pagePropsObj.pagesize
491
- )
492
- : [];
493
- },
494
474
  // 全部数据 或 筛选时符合条件的数据 -总数
495
475
  selfTotal () {
496
- return this.total || this.showListData.length;
497
- },
498
- // 全部数据 或 筛选时符合条件的数据 -共多少分页
499
- PageNum () {
500
- return this.selfTotal % this.pagePropsObj.pagesize > 0
501
- ? Math.ceil(this.selfTotal / this.pagePropsObj.pagesize)
502
- : Math.floor(this.selfTotal / this.pagePropsObj.pagesize);
476
+ return this.showListData.length;
503
477
  },
504
478
 
505
479
  parentDataId () {
@@ -512,11 +486,16 @@ export default {
512
486
  const initDftVal = this.initDftValMap[column._type];
513
487
 
514
488
  return Object.assign(obj, {
515
- [column._key]: this.$isEmptyData(dftInRowVal)
516
- ? this.$isEmptyData(dftVal)
489
+ [column._key]: dftInRowVal === undefined
490
+ ? dftVal === undefined
517
491
  ? initDftVal
518
492
  : dftVal
519
493
  : dftInRowVal
494
+ // [column._key]: this.$isEmptyData(dftInRowVal)
495
+ // ? this.$isEmptyData(dftVal)
496
+ // ? initDftVal
497
+ // : dftVal
498
+ // : dftInRowVal
520
499
  });
521
500
  }, {});
522
501
  },
@@ -602,6 +581,13 @@ export default {
602
581
  // clickHighlight: true,
603
582
  // stripe: true // 斑马纹
604
583
  // },
584
+ ...(
585
+ this.selfPropsObj.checkboxOption
586
+ ? {
587
+ checkboxOption: this.selfPropsObj.checkboxOption
588
+ }
589
+ : {}
590
+ ),
605
591
  maxHeight: this.contentHeight,
606
592
  // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
607
593
  columnHiddenOption: {
@@ -854,23 +840,8 @@ export default {
854
840
  }
855
841
  },
856
842
  // 列表选择项改变
857
- changeSelect (list) {
858
- this.$emit("changeSelect", list);
859
- },
860
- // 切换正倒序
861
- changeSort () {
862
- this.isUseDescSort = !this.isUseDescSort;
863
- this.changePage(1);
864
- },
865
- // 切换分页
866
- changePage (page) {
867
- this.pagePropsObj.page = page;
868
- this.loadingFunc();
869
- },
870
- // 切换分页条数
871
- changePageSize (pagesize) {
872
- this.pagePropsObj.page = 1;
873
- this.pagePropsObj.pagesize = pagesize;
843
+ changeSelect (...params) {
844
+ this.$emit("changeSelect", params[0].map(item => item._id), ...params);
874
845
  },
875
846
  loadingFunc () {
876
847
  this.isLoading = true;