bri-components 1.5.22 → 1.6.1

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.
Files changed (154) hide show
  1. package/README.md +83 -83
  2. package/lib/styles/bundle.css +12 -12
  3. package/lib/styles/font/fontello.svg +31 -31
  4. package/package.json +127 -125
  5. package/src/components/Error/Error403.vue +42 -42
  6. package/src/components/Error/Error404.vue +40 -40
  7. package/src/components/Error/Error500.vue +51 -51
  8. package/src/components/Error/error.less +162 -162
  9. package/src/components/Error/errorBack.vue +40 -40
  10. package/src/components/controls/DshControlInput.vue +195 -195
  11. package/src/components/controls/base/BriUpload/BriUpload.vue +435 -434
  12. package/src/components/controls/base/BriUpload/BriUploadImage.vue +430 -377
  13. package/src/components/controls/base/BriUpload/uploadList.vue +738 -727
  14. package/src/components/controls/base/BriUpload/uploadMixin.js +453 -446
  15. package/src/components/controls/base/DshCascader/DshCascader.vue +215 -215
  16. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
  17. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
  18. package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +141 -141
  19. package/src/components/controls/base/DshCascader/components/cascaderTree.vue +151 -151
  20. package/src/components/controls/base/DshCoordinates.vue +587 -585
  21. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  22. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  23. package/src/components/controls/base/DshDivider.vue +201 -201
  24. package/src/components/controls/base/DshEditor.vue +274 -274
  25. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  26. package/src/components/controls/base/DshInput/DshInput.vue +260 -260
  27. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  28. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  29. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  30. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  31. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  32. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  33. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  34. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  35. package/src/components/controls/base/DshSelect/DshSelectAll.vue +269 -269
  36. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  37. package/src/components/controls/control.less +324 -324
  38. package/src/components/controls/controlMap.js +117 -117
  39. package/src/components/controls/extra/DshColor.vue +81 -81
  40. package/src/components/controls/extra/DshThemeColor.vue +100 -100
  41. package/src/components/controls/extra/DshThemeIcon.vue +122 -122
  42. package/src/components/controls/mixins/cascaderMixin.js +325 -325
  43. package/src/components/controls/mixins/cascaderPickerMixin.js +227 -227
  44. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  45. package/src/components/controls/mixins/controlMixin.js +393 -393
  46. package/src/components/controls/mixins/dateMixin.js +149 -149
  47. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  48. package/src/components/controls/mixins/numberMixin.js +112 -112
  49. package/src/components/controls/mixins/selectMixin.js +233 -233
  50. package/src/components/controls/mixins/switchMixin.js +87 -87
  51. package/src/components/controls/mixins/userAndDepartMixin.js +260 -260
  52. package/src/components/controls/senior/DshLabels.vue +333 -333
  53. package/src/components/controls/senior/DshPackage.vue +57 -57
  54. package/src/components/controls/senior/cascaderTable.vue +213 -213
  55. package/src/components/controls/senior/correlation.vue +135 -135
  56. package/src/components/controls/senior/flatTable.vue +138 -138
  57. package/src/components/controls/senior/selectDepartments.vue +397 -399
  58. package/src/components/controls/senior/selectUsers/departMenu.vue +296 -293
  59. package/src/components/controls/senior/selectUsers/selectUsers.vue +712 -712
  60. package/src/components/controls/special/DshBack.vue +42 -42
  61. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  62. package/src/components/form/DshAdvSearch.vue +510 -510
  63. package/src/components/form/DshDefaultSearch.vue +260 -260
  64. package/src/components/form/DshForm.vue +494 -494
  65. package/src/components/form/searchMixin.js +376 -376
  66. package/src/components/list/BriCard.vue +95 -95
  67. package/src/components/list/BriTable.vue +205 -205
  68. package/src/components/list/BriTree.vue +529 -529
  69. package/src/components/list/BriTreeItem.vue +163 -163
  70. package/src/components/list/DshBox/DshBox.vue +219 -219
  71. package/src/components/list/DshBox/DshCard.vue +446 -446
  72. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  73. package/src/components/list/DshBox/DshList.vue +404 -404
  74. package/src/components/list/DshBox/DshPanel.vue +669 -669
  75. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  76. package/src/components/list/DshBox/DshTable.vue +239 -239
  77. package/src/components/list/DshCascaderTable.vue +115 -115
  78. package/src/components/list/DshFlatTable.vue +334 -337
  79. package/src/components/list/DshPage.vue +194 -194
  80. package/src/components/list/DshTreeTable.vue +113 -113
  81. package/src/components/list/common/importModal.vue +243 -243
  82. package/src/components/list/common/quoteListModal.vue +206 -206
  83. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  84. package/src/components/list/mixins/DshFlatTableMixin.js +509 -509
  85. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  86. package/src/components/list/mixins/tableBaseMixin.js +1653 -1653
  87. package/src/components/list/mixins/treeTableBaseMixin.js +145 -145
  88. package/src/components/other/BriAvatar.vue +166 -166
  89. package/src/components/other/BriCode.vue +125 -125
  90. package/src/components/other/BriCollapseTree.vue +207 -207
  91. package/src/components/other/BriGantt.vue +1087 -1087
  92. package/src/components/other/BriIframe.vue +116 -116
  93. package/src/components/other/BriLoading.vue +171 -171
  94. package/src/components/other/BriSvg.vue +27 -27
  95. package/src/components/other/DshColorPanel.vue +128 -128
  96. package/src/components/other/DshMenuNav.vue +188 -188
  97. package/src/components/other/DshVideoPlayer.vue +184 -0
  98. package/src/components/small/BriButton.vue +71 -71
  99. package/src/components/small/BriDrawer.vue +169 -169
  100. package/src/components/small/BriTooltip.vue +87 -87
  101. package/src/components/small/DshBtnModal.vue +68 -68
  102. package/src/components/small/DshButtons.vue +324 -324
  103. package/src/components/small/DshDropdown.vue +225 -225
  104. package/src/components/small/DshIcons.vue +59 -59
  105. package/src/components/small/DshListRender.js +21 -21
  106. package/src/components/small/DshModal.vue +160 -160
  107. package/src/components/small/DshSteps.vue +141 -141
  108. package/src/components/small/DshTabs.vue +598 -598
  109. package/src/components/small/DshTabsSet.vue +309 -309
  110. package/src/components/small/DshTags.vue +251 -251
  111. package/src/components/small/DshTitle.vue +50 -50
  112. package/src/components/small/render.js +20 -20
  113. package/src/components/unit/DshFormUnit.vue +398 -398
  114. package/src/components/unit/DshListUnit.vue +115 -115
  115. package/src/components/unit/unitMixin.js +86 -86
  116. package/src/data/index.js +4 -4
  117. package/src/index.js +287 -285
  118. package/src/styles/bundle.css +12 -12
  119. package/src/styles/components/BriButton.less +307 -307
  120. package/src/styles/components/BriTable.less +344 -344
  121. package/src/styles/components/DshModal.less +257 -257
  122. package/src/styles/components/index.less +3 -3
  123. package/src/styles/global/animate.less +11 -11
  124. package/src/styles/global/base.less +45 -45
  125. package/src/styles/global/box.less +186 -186
  126. package/src/styles/global/control.less +122 -122
  127. package/src/styles/global/flex.less +282 -282
  128. package/src/styles/global/global.less +8 -8
  129. package/src/styles/global/text.less +59 -59
  130. package/src/styles/global/variables.less +85 -85
  131. package/src/styles/iconfont/iconfont.css +254 -254
  132. package/src/styles/iconfont/iconfont.json +422 -422
  133. package/src/styles/iconfont/iconfont.svg +137 -137
  134. package/src/styles/index.less +26 -26
  135. package/src/styles/reset-easytable.less +21 -21
  136. package/src/styles/reset-iview-controls.less +145 -145
  137. package/src/styles/reset-iview-other.less +49 -49
  138. package/src/styles/reset-iview-variables.less +43 -43
  139. package/src/styles/reset.less +45 -45
  140. package/src/utils/index.js +3 -5
  141. package/lib/0.bri-components.min.js +0 -1
  142. package/lib/1.bri-components.min.js +0 -1
  143. package/lib/10.bri-components.min.js +0 -1
  144. package/lib/11.bri-components.min.js +0 -1
  145. package/lib/2.bri-components.min.js +0 -1
  146. package/lib/3.bri-components.min.js +0 -1
  147. package/lib/4.bri-components.min.js +0 -1
  148. package/lib/5.bri-components.min.js +0 -1
  149. package/lib/6.bri-components.min.js +0 -1
  150. package/lib/7.bri-components.min.js +0 -1
  151. package/lib/8.bri-components.min.js +0 -1
  152. package/lib/9.bri-components.min.js +0 -1
  153. package/lib/bri-components.min.js +0 -18
  154. package/src/utils/table.js +0 -175
@@ -1,509 +1,509 @@
1
- export default {
2
- mixins: [],
3
- components: {},
4
- props: {
5
- // 使用多选列
6
- useSelection: {
7
- type: Boolean,
8
- default: false
9
- }
10
- },
11
- data () {
12
- return {
13
- isUseDescSort: false,
14
- pageMode: "small",
15
- pagePropsObj: {
16
- page: 1,
17
- pagesize: 10,
18
- pagesizeOpts: [10, 20, 30, 50, 80, 100]
19
- }
20
- };
21
- },
22
- computed: {
23
- selfBasePropsObj () {
24
- return {
25
- _isUseDescSort: false, // 是否使用使用倒序
26
- _mergeRowColKeys: [], // 合并行的列
27
- _pagesize: 10 // 列表的分页条数
28
- };
29
- },
30
- // 是不是合并行表格
31
- isMergeRowTable () {
32
- return !!this.mergeRowColKeys.length;
33
- },
34
- mergeRowColKeys () {
35
- const mergeRowColKeys = this.selfPropsObj._mergeRowColKeys || []; // 配置端有问题,高级依赖时值成undefined了
36
- return this.selfColumns
37
- .filter(colItem => mergeRowColKeys.includes(colItem._key))
38
- .map(colItem => colItem._key);
39
- },
40
- // 一级合并列keys(一级合并列:左侧第一合并列和右侧和并列)
41
- firstMergeRowColKeys () {
42
- if (this.isMergeRowTable) {
43
- const firstNormalIndex = this.selfColumns.findIndex(colItem => !this.mergeRowColKeys.includes(colItem._key));
44
-
45
- // -1代表无普通单元格,0代表第一列就是普通单元格
46
- return [-1, 0].includes(firstNormalIndex)
47
- ? this.mergeRowColKeys
48
- : [
49
- this.mergeRowColKeys[0],
50
- ...this.selfColumns
51
- .filter((colItem, colIndex) => colIndex > firstNormalIndex && this.mergeRowColKeys.includes(colItem._key))
52
- .map(colItem => colItem._key)
53
- ];
54
- } else {
55
- return [];
56
- }
57
- },
58
- notFirstMergeRowColKeys () {
59
- return this.mergeRowColKeys.filter(colKey => !this.firstMergeRowColKeys.includes(colKey));
60
- },
61
- // 替换tableBaseMixin里的
62
- searchTitle () {
63
- return `${this.isSearching ? "筛选" : "全部"}数据${this.isMergeRowTable ? `,共 ${this.totalNum}条;` : ";"}`;
64
- },
65
-
66
- /* --- 列字段 --- */
67
- showColumns () {
68
- return [
69
- ...(this.useSelection === true ? [this.selectionColumn] : []),
70
- ...(this.useIndex === true ? [this.indexColumn] : []),
71
- ...this.$transformToColumns(this.showContentColumns),
72
- ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
73
- ];
74
- },
75
- indexColumn () {
76
- return {
77
- title: "序号",
78
- _key: "__index__",
79
- key: "__index__",
80
- field: "__index__",
81
- width: 76,
82
- align: "center",
83
- fixed: "left",
84
- renderBodyCell: ({ row, rowIndex, column }, h) => {
85
- return [
86
- h("div", this.isMergeRowTable ? rowIndex + 1 : row.__index__),
87
-
88
- // 添加符
89
- ...this.operationIconRender(h, { row, rowIndex, column })
90
- ];
91
- }
92
- };
93
- },
94
-
95
- /* --- 数据 --- */
96
- rowspanMap () {
97
- return this.tableDataObj.rowspanMap || {};
98
- },
99
- allListData () {
100
- this.data.forEach((row) => {
101
- this.fixRowData(row);
102
- });
103
- this.initFlag = false;
104
-
105
- return this.isMergeRowTable
106
- ? this.data
107
- : this.isUseDescSort
108
- ? [...this.data].reverse()
109
- : this.data;
110
- },
111
- // 全部数据(或筛选出的数据)
112
- showListData () {
113
- return this.allListData
114
- .filter(row =>
115
- this.isSearching
116
- ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
117
- : true
118
- )
119
- .map((row, rowIndex) => {
120
- row.__index__ = rowIndex + 1;
121
- return row;
122
- });
123
- },
124
- selfShowListData () {
125
- return this.isMergeRowTable
126
- ? this.showListData
127
- : this.curPageShowListData;
128
- },
129
- // 替换tableBaseMixin里的
130
- changedCols () {
131
- return this.selfShowListData.reduce((totalCols, row) => {
132
- return [
133
- ...new Set([...totalCols, ...(row.__changed__ || []).map(item => item.fieldKey)])
134
- ];
135
- }, []);
136
- },
137
- footerData () {
138
- return this.isSearching
139
- ? []
140
- : this.useSummary && this.allListData.length
141
- ? [
142
- this.contentColumns.reduce((obj, column) => {
143
- return {
144
- ...obj,
145
- [column._key]: column._type === "number" && column._summaryType
146
- ? this.$calNumList(
147
- this.allListData.map(rowItem => rowItem[column._key]),
148
- column._summaryType,
149
- { ...column, _defaultDigit: 2 }
150
- )
151
- : (obj[column._key] || "--")
152
- };
153
- }, {
154
- _id: this.$ObjectID().str,
155
- __index__: "汇总",
156
- __operation__: "——"
157
- })
158
- ]
159
- : [];
160
- },
161
-
162
- allListMap () {
163
- return this.$arrToMap(this.allListData, "_id");
164
- },
165
- // 全部数据 或 筛选时符合条件的数据 -当前页的
166
- curPageShowListData () {
167
- const page = this.pagePropsObj.page;
168
- const pagesize = this.pagePropsObj.pagesize;
169
-
170
- return page >= 1
171
- ? page > this.totalPage
172
- ? this.showListData.slice(-(this.showListData.length % pagesize || pagesize))
173
- : this.showListData.slice((page - 1) * pagesize, page * pagesize)
174
- : [];
175
- },
176
- // 全部数据 或 筛选时符合条件的数据 -共多少分(!!!最小为1)
177
- totalPage () {
178
- return (
179
- this.totalNum % this.pagePropsObj.pagesize > 0
180
- ? Math.ceil(this.totalNum / this.pagePropsObj.pagesize)
181
- : this.totalNum / this.pagePropsObj.pagesize
182
- ) || 1;
183
- }
184
- },
185
- created () {
186
- this.flatTableMixinInit();
187
- },
188
- methods: {
189
- flatTableMixinInit () {
190
- this.selfReset();
191
- },
192
- // 自身的重置
193
- selfReset () {
194
- this.isUseDescSort = this.selfPropsObj._isUseDescSort;
195
- this.pagePropsObj.pagesize = this.selfPropsObj._pagesize || this.selfBasePropsObj._pagesize;
196
- this.initRowspan();
197
- },
198
-
199
- // 也供外部使用 -转到最后一条数据所在的分页
200
- goLastDataPage () {
201
- if (this.isUseDescSort) {
202
- if (this.pagePropsObj.page !== 1) {
203
- this.changePage(1);
204
- }
205
- } else {
206
- if (this.pagePropsObj.page !== this.totalPage) {
207
- this.changePage(this.totalPage);
208
- }
209
- }
210
- },
211
- // 也供外部使用 -删除数据时,更正this.pagePropsObj.page
212
- fixCurPage () {
213
- if (this.pagePropsObj.page > this.totalPage) {
214
- this.changePage(this.totalPage);
215
- }
216
- },
217
- // 暂未供外部使用 -判断是否要转到下一页(在本页最后一条上插入一行时,要转到下一页)
218
- goNextPage (rowIndex) {
219
- if (rowIndex + 1 === this.pagePropsObj.pagesize) {
220
- this.changePage(this.pagePropsObj.page + 1);
221
- }
222
- },
223
-
224
- // 切换正倒序
225
- changeDescSort () {
226
- this.isUseDescSort = !this.isUseDescSort;
227
- this.changePage(1);
228
- },
229
- // 切换分页
230
- changePage (page) {
231
- this.pagePropsObj.page = page || 1;
232
- this.loadingFunc();
233
- },
234
- // 切换分页条数
235
- changePageSize (pagesize) {
236
- this.pagePropsObj.page = 1;
237
- this.pagePropsObj.pagesize = pagesize;
238
- this.loadingFunc();
239
- },
240
-
241
- // 点击 -添加行
242
- clickCreate (operationItem, row, rowIndex, column) {
243
- const curColKey = column ? column._key : undefined;
244
- const list = this.data;
245
- const newRow = this.getNewRowData();
246
-
247
- // 处理单元格合并相关
248
- if (this.isMergeRowTable) {
249
- // 非底部按钮添加时
250
- if (row) {
251
- // 寻找对应的行数据 -当前列是合并列会寻找,普通列不用找(就是row)
252
- if (this.mergeRowColKeys.includes(curColKey) && this.rowspanMap[this.getMixKey(row, column)] > 1) {
253
- const newList = this.allListData.slice(rowIndex + 1); // 从下一行开始截取
254
- const nextRowIndex = newList.findIndex(rowItem => this.rowspanMap[this.getMixKey(rowItem, column)] > 0); // 寻找该单元格值开始不一样的行
255
- // nextRowIndex为-1,代表最后一行
256
- row = nextRowIndex < 0
257
- ? newList[newList.length - 1]
258
- : newList[nextRowIndex - 1];
259
- rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
260
- }
261
-
262
- // 寻找要复制值的列
263
- // 当前列:一级合并列,不复制值;
264
- if (this.firstMergeRowColKeys.includes(curColKey)) {
265
- this.mergeRowColKeys.forEach(colKey => {
266
- this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
267
- });
268
- }
269
- // 当前列:普通合并列(非一级合并列)-该列之前的合并列和一级合并列复制值给新的行;非合并列-全部复制值给新的行
270
- else {
271
- const notFirstCopyColKeys = this.notFirstMergeRowColKeys.includes(curColKey)
272
- ? this.notFirstMergeRowColKeys.filter((colKey, colIndex, list) => colIndex < list.findIndex(colKey => colKey === curColKey))
273
- : this.notFirstMergeRowColKeys;
274
- const noCopyColKeys = this.notFirstMergeRowColKeys.includes(curColKey)
275
- ? this.notFirstMergeRowColKeys.filter((colKey, colIndex, list) => colIndex >= list.findIndex(colKey => colKey === curColKey))
276
- : [];
277
- const copyColKeys = notFirstCopyColKeys.concat(this.firstMergeRowColKeys);
278
-
279
- // 复制值
280
- copyColKeys.reduce((obj, colKey, colIndex) => {
281
- return Object.assign(obj, {
282
- [colKey]: this.$deepCopy(row[colKey])
283
- });
284
- }, newRow);
285
-
286
- // rowspan记录
287
- copyColKeys.forEach(colKey => {
288
- // 合并的单元格更新rowspan记录
289
- const fistMergeRow = this.rowspanMap[this.getMixKey(row, { _key: colKey })] === 0
290
- ? list.slice(0, rowIndex).findLast(rowItem => this.rowspanMap[this.getMixKey(rowItem, { _key: colKey })] > 1)
291
- : row;
292
- this.rowspanMap[this.getMixKey(fistMergeRow, { _key: colKey })] = this.rowspanMap[this.getMixKey(fistMergeRow, { _key: colKey })] + 1;
293
-
294
- // 新增的单元格做rowspan记录
295
- this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 0;
296
- });
297
- noCopyColKeys.forEach(colKey => {
298
- this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
299
- });
300
- }
301
- }
302
- // 底部按钮添加时
303
- else {
304
- this.mergeRowColKeys.forEach(colKey => {
305
- this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
306
- });
307
- }
308
- }
309
-
310
- const newRowIndex = row
311
- ? list.findIndex(rowItem => rowItem._id === row._id) + 1
312
- : list.length;
313
-
314
- if (this.isMergeRowTable) {
315
- list.splice(newRowIndex, 0, newRow);
316
- } else {
317
- if (this.isUseDescSort) {
318
- if (row) {
319
- list.splice(newRowIndex - 1, 0, newRow);
320
- this.goNextPage(rowIndex);
321
- } else {
322
- list.splice(newRowIndex, 0, newRow);
323
- this.goLastDataPage();
324
- }
325
- } else {
326
- if (row) {
327
- list.splice(newRowIndex, 0, newRow);
328
- this.goNextPage(rowIndex);
329
- } else {
330
- list.splice(newRowIndex, 0, newRow);
331
- this.goLastDataPage();
332
- }
333
- }
334
- }
335
-
336
- this.changeSelect();
337
- this.change("createRow", newRow, newRowIndex, null);
338
- },
339
- // 点击 -删除行
340
- clickDelete (operationItem, row, rowIndex) {
341
- this.$Modal.confirm({
342
- title: "提示",
343
- content: "确定删除吗?",
344
- onOk: () => {
345
- const list = this.data;
346
-
347
- // 处理单元格合并相关
348
- if (this.isMergeRowTable) {
349
- this.mergeRowColKeys.forEach(colKey => {
350
- const column = { _key: colKey };
351
- const rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
352
-
353
- // 当前单元格合并了下面的 -把合并数减去1给下一单元格
354
- if (this.rowspanMap[this.getMixKey(row, column)] > 1) {
355
- const nextRow = list[rowIndex + 1];
356
- this.rowspanMap[this.getMixKey(nextRow, column)] = this.rowspanMap[this.getMixKey(row, column)] - 1;
357
- }
358
- // 当前单元格被上面的合并了 -最上面的合并单元格合并数减去1
359
- else if (this.rowspanMap[this.getMixKey(row, column)] === 0) {
360
- const fistMergeRow = list.slice(0, rowIndex).findLast(rowItem => this.rowspanMap[this.getMixKey(rowItem, column)] > 1);
361
- this.rowspanMap[this.getMixKey(fistMergeRow, column)] = this.rowspanMap[this.getMixKey(fistMergeRow, column)] - 1;
362
- }
363
- // 当前单元格单独存在(无合并)
364
- else if (this.rowspanMap[this.getMixKey(row, column)] === 1) {
365
- // 无处理
366
- }
367
-
368
- // 清除被删除单元格的rowspan记录
369
- delete this.rowspanMap[this.getMixKey(row, column)];
370
- });
371
- }
372
-
373
- const listIndex = list.findIndex(rowItem => rowItem._id === row._id);
374
- list.splice(listIndex, 1);
375
- this.fixCurPage();
376
-
377
- this.change("deleteRow", row, rowIndex, null);
378
- }
379
- });
380
- },
381
- quickChangeVal (operationItem, row, rowIndex, column, params) {
382
- if (["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
383
- this.dealRuleRecord(row, column);
384
- this.dealSameRowsVal({ row, rowIndex, column });
385
-
386
- this.change("quickChangeVal", row, rowIndex, column, ...params);
387
- }
388
- },
389
- changeVal (operationItem, row, rowIndex, column, params) {
390
- if (!["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
391
- this.dealRuleRecord(row, column);
392
- this.dealSameRowsVal({ row, rowIndex, column });
393
-
394
- this.change("changeVal", row, rowIndex, column, ...params);
395
- }
396
- },
397
-
398
- bodyCellSpan ({ row, rowIndex, column }) {
399
- return {
400
- rowspan: this.mergeRowColKeys.includes(column._key)
401
- ? this.isSearching
402
- ? this.getRowspan({ row, rowIndex, column })
403
- : this.getRealRowspan({ row, rowIndex, column })
404
- : 1,
405
- colspan: 1
406
- };
407
- },
408
- // 加工单元格对应的配置
409
- getSelfResetCol ({ row, rowIndex, column }) {
410
- return this.mergeRowColKeys.includes(column._key)
411
- ? {
412
- _heightAuto: true
413
- }
414
- : {};
415
- },
416
-
417
- /* ----------- 方法 ---------- */
418
- fixSelfRowData (row) {
419
- if (this.initFlag) {
420
- // 每条数据都补充全所有字段值(赋一个默认的空值)
421
- this.selfColumns.forEach((colItem) => {
422
- // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
423
- if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
424
- this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
425
- }
426
- });
427
- }
428
- },
429
- // 初始化合并单元格的rowspan
430
- initRowspan () {
431
- if (this.isMergeRowTable) {
432
- this.$set(this.tableDataObj, "rowspanMap", this.tableDataObj.rowspanMap || {});
433
-
434
- // TODO: 待删除
435
- Object.entries(this.rowspanMap).forEach(arr => {
436
- if (arr[0].includes("dsh")) {
437
- this.rowspanMap[arr[0].split("dsh").join("--")] = this.rowspanMap[arr[1]];
438
- delete this.rowspanMap[arr[0]];
439
- }
440
- });
441
-
442
- this.allListData.forEach((rowItem, rowIndex) => {
443
- this.mergeRowColKeys.forEach(colKey => {
444
- const column = { _key: colKey };
445
-
446
- // 新增页 -行的_id被置换,rowspanMap也要相应置换,还要清除rowspanMap里和默认行老_id相关的
447
- const oldId = this.idRecordMap[rowItem._id];
448
- const oldRow = { ...rowItem, _id: oldId };
449
- if (oldId && ![undefined, null].includes(this.rowspanMap[this.getMixKey(oldRow, column)])) {
450
- this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: oldRow, rowIndex, column });
451
- delete this.rowspanMap[this.getMixKey(oldRow, column)];
452
- } else {
453
- this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: rowItem, rowIndex, column });
454
- }
455
- });
456
- });
457
-
458
- // 清除rowspanMap无用的(针对来回改mergeRowColKeys)
459
- Object.entries(this.rowspanMap).forEach(arr => {
460
- const keyArr = arr[0].split("--");
461
- const id = keyArr[0];
462
- const colKey = keyArr.slice(1).join("--");
463
- if (!this.allListMap[id] || !this.mergeRowColKeys.includes(colKey)) {
464
- delete this.rowspanMap[arr[0]];
465
- }
466
- });
467
- }
468
- },
469
- // 获取合并单元格真实的rowspan
470
- getRealRowspan ({ row, rowIndex, column }) {
471
- return ![undefined, null].includes(this.rowspanMap[this.getMixKey(row, column)])
472
- ? this.rowspanMap[this.getMixKey(row, column)]
473
- : this.getRowspan({ row, rowIndex, column }, this.allListData);
474
- },
475
- // 计算rowspan
476
- getRowspan ({ row, rowIndex, column }, list = this.showListData) {
477
- let rowspan = 1;
478
- rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
479
-
480
- // 合并单元格的列走这
481
- if (this.mergeRowColKeys.includes(column._key)) {
482
- rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
483
-
484
- // 代表显示出来的行
485
- if (rowIndex > -1) {
486
- if (rowIndex !== 0 && this.isCompareSame(column, row, list[rowIndex - 1])) {
487
- rowspan = 0;
488
- } else {
489
- const newList = list.slice(rowIndex + 1);
490
- const newIndex = newList.findIndex(rowItem => !this.isCompareSame(column, row, rowItem));
491
- rowspan = 1 + (newIndex === -1 ? newList.length : newIndex);
492
- }
493
- }
494
- }
495
-
496
- return rowspan;
497
- },
498
- // 合并单元格的行,某列的值全部跟着修改
499
- dealSameRowsVal ({ row, rowIndex, column }, list = this.allListData) {
500
- if (this.mergeRowColKeys.includes(column._key) && this.rowspanMap[this.getMixKey(row, column)] > 1) {
501
- const indexInAll = list.findIndex(dataItem => dataItem._id === row._id);
502
- list.slice(indexInAll + 1, indexInAll + this.rowspanMap[this.getMixKey(row, column)])
503
- .forEach(rowItem => {
504
- rowItem[column._key] = this.$deepCopy(row[column._key]);
505
- });
506
- }
507
- }
508
- }
509
- };
1
+ export default {
2
+ mixins: [],
3
+ components: {},
4
+ props: {
5
+ // 使用多选列
6
+ useSelection: {
7
+ type: Boolean,
8
+ default: false
9
+ }
10
+ },
11
+ data () {
12
+ return {
13
+ isUseDescSort: false,
14
+ pageMode: "small",
15
+ pagePropsObj: {
16
+ page: 1,
17
+ pagesize: 10,
18
+ pagesizeOpts: [10, 20, 30, 50, 80, 100]
19
+ }
20
+ };
21
+ },
22
+ computed: {
23
+ selfBasePropsObj () {
24
+ return {
25
+ _isUseDescSort: false, // 是否使用使用倒序
26
+ _mergeRowColKeys: [], // 合并行的列
27
+ _pagesize: 10 // 列表的分页条数
28
+ };
29
+ },
30
+ // 是不是合并行表格
31
+ isMergeRowTable () {
32
+ return !!this.mergeRowColKeys.length;
33
+ },
34
+ mergeRowColKeys () {
35
+ const mergeRowColKeys = this.selfPropsObj._mergeRowColKeys || []; // 配置端有问题,高级依赖时值成undefined了
36
+ return this.selfColumns
37
+ .filter(colItem => mergeRowColKeys.includes(colItem._key))
38
+ .map(colItem => colItem._key);
39
+ },
40
+ // 一级合并列keys(一级合并列:左侧第一合并列和右侧和并列)
41
+ firstMergeRowColKeys () {
42
+ if (this.isMergeRowTable) {
43
+ const firstNormalIndex = this.selfColumns.findIndex(colItem => !this.mergeRowColKeys.includes(colItem._key));
44
+
45
+ // -1代表无普通单元格,0代表第一列就是普通单元格
46
+ return [-1, 0].includes(firstNormalIndex)
47
+ ? this.mergeRowColKeys
48
+ : [
49
+ this.mergeRowColKeys[0],
50
+ ...this.selfColumns
51
+ .filter((colItem, colIndex) => colIndex > firstNormalIndex && this.mergeRowColKeys.includes(colItem._key))
52
+ .map(colItem => colItem._key)
53
+ ];
54
+ } else {
55
+ return [];
56
+ }
57
+ },
58
+ notFirstMergeRowColKeys () {
59
+ return this.mergeRowColKeys.filter(colKey => !this.firstMergeRowColKeys.includes(colKey));
60
+ },
61
+ // 替换tableBaseMixin里的
62
+ searchTitle () {
63
+ return `${this.isSearching ? "筛选" : "全部"}数据${this.isMergeRowTable ? `,共 ${this.totalNum}条;` : ";"}`;
64
+ },
65
+
66
+ /* --- 列字段 --- */
67
+ showColumns () {
68
+ return [
69
+ ...(this.useSelection === true ? [this.selectionColumn] : []),
70
+ ...(this.useIndex === true ? [this.indexColumn] : []),
71
+ ...this.$transformToColumns(this.showContentColumns),
72
+ ...(!this.isSearching && this.rowOperationList.length ? [this.operationColumn] : [])
73
+ ];
74
+ },
75
+ indexColumn () {
76
+ return {
77
+ title: "序号",
78
+ _key: "__index__",
79
+ key: "__index__",
80
+ field: "__index__",
81
+ width: 76,
82
+ align: "center",
83
+ fixed: "left",
84
+ renderBodyCell: ({ row, rowIndex, column }, h) => {
85
+ return [
86
+ h("div", this.isMergeRowTable ? rowIndex + 1 : row.__index__),
87
+
88
+ // 添加符
89
+ ...this.operationIconRender(h, { row, rowIndex, column })
90
+ ];
91
+ }
92
+ };
93
+ },
94
+
95
+ /* --- 数据 --- */
96
+ rowspanMap () {
97
+ return this.tableDataObj.rowspanMap || {};
98
+ },
99
+ allListData () {
100
+ this.data.forEach((row) => {
101
+ this.fixRowData(row);
102
+ });
103
+ this.initFlag = false;
104
+
105
+ return this.isMergeRowTable
106
+ ? this.data
107
+ : this.isUseDescSort
108
+ ? [...this.data].reverse()
109
+ : this.data;
110
+ },
111
+ // 全部数据(或筛选出的数据)
112
+ showListData () {
113
+ return this.allListData
114
+ .filter(row =>
115
+ this.isSearching
116
+ ? this.$isAdvRelyAccord(this.finalTableAdvSearch, row)
117
+ : true
118
+ )
119
+ .map((row, rowIndex) => {
120
+ row.__index__ = rowIndex + 1;
121
+ return row;
122
+ });
123
+ },
124
+ selfShowListData () {
125
+ return this.isMergeRowTable
126
+ ? this.showListData
127
+ : this.curPageShowListData;
128
+ },
129
+ // 替换tableBaseMixin里的
130
+ changedCols () {
131
+ return this.selfShowListData.reduce((totalCols, row) => {
132
+ return [
133
+ ...new Set([...totalCols, ...(row.__changed__ || []).map(item => item.fieldKey)])
134
+ ];
135
+ }, []);
136
+ },
137
+ footerData () {
138
+ return this.isSearching
139
+ ? []
140
+ : this.useSummary && this.allListData.length
141
+ ? [
142
+ this.contentColumns.reduce((obj, column) => {
143
+ return {
144
+ ...obj,
145
+ [column._key]: column._type === "number" && column._summaryType
146
+ ? this.$calNumList(
147
+ this.allListData.map(rowItem => rowItem[column._key]),
148
+ column._summaryType,
149
+ { ...column, _defaultDigit: 2 }
150
+ )
151
+ : (obj[column._key] || "--")
152
+ };
153
+ }, {
154
+ _id: this.$ObjectID().str,
155
+ __index__: "汇总",
156
+ __operation__: "——"
157
+ })
158
+ ]
159
+ : [];
160
+ },
161
+
162
+ allListMap () {
163
+ return this.$arrToMap(this.allListData, "_id");
164
+ },
165
+ // 全部数据 或 筛选时符合条件的数据 -当前页的
166
+ curPageShowListData () {
167
+ const page = this.pagePropsObj.page;
168
+ const pagesize = this.pagePropsObj.pagesize;
169
+
170
+ return page >= 1
171
+ ? page > this.totalPage
172
+ ? this.showListData.slice(-(this.showListData.length % pagesize || pagesize))
173
+ : this.showListData.slice((page - 1) * pagesize, page * pagesize)
174
+ : [];
175
+ },
176
+ // 全部数据 或 筛选时符合条件的数据 -共多少分(!!!最小为1)
177
+ totalPage () {
178
+ return (
179
+ this.totalNum % this.pagePropsObj.pagesize > 0
180
+ ? Math.ceil(this.totalNum / this.pagePropsObj.pagesize)
181
+ : this.totalNum / this.pagePropsObj.pagesize
182
+ ) || 1;
183
+ }
184
+ },
185
+ created () {
186
+ this.flatTableMixinInit();
187
+ },
188
+ methods: {
189
+ flatTableMixinInit () {
190
+ this.selfReset();
191
+ },
192
+ // 自身的重置
193
+ selfReset () {
194
+ this.isUseDescSort = this.selfPropsObj._isUseDescSort;
195
+ this.pagePropsObj.pagesize = this.selfPropsObj._pagesize || this.selfBasePropsObj._pagesize;
196
+ this.initRowspan();
197
+ },
198
+
199
+ // 也供外部使用 -转到最后一条数据所在的分页
200
+ goLastDataPage () {
201
+ if (this.isUseDescSort) {
202
+ if (this.pagePropsObj.page !== 1) {
203
+ this.changePage(1);
204
+ }
205
+ } else {
206
+ if (this.pagePropsObj.page !== this.totalPage) {
207
+ this.changePage(this.totalPage);
208
+ }
209
+ }
210
+ },
211
+ // 也供外部使用 -删除数据时,更正this.pagePropsObj.page
212
+ fixCurPage () {
213
+ if (this.pagePropsObj.page > this.totalPage) {
214
+ this.changePage(this.totalPage);
215
+ }
216
+ },
217
+ // 暂未供外部使用 -判断是否要转到下一页(在本页最后一条上插入一行时,要转到下一页)
218
+ goNextPage (rowIndex) {
219
+ if (rowIndex + 1 === this.pagePropsObj.pagesize) {
220
+ this.changePage(this.pagePropsObj.page + 1);
221
+ }
222
+ },
223
+
224
+ // 切换正倒序
225
+ changeDescSort () {
226
+ this.isUseDescSort = !this.isUseDescSort;
227
+ this.changePage(1);
228
+ },
229
+ // 切换分页
230
+ changePage (page) {
231
+ this.pagePropsObj.page = page || 1;
232
+ this.loadingFunc();
233
+ },
234
+ // 切换分页条数
235
+ changePageSize (pagesize) {
236
+ this.pagePropsObj.page = 1;
237
+ this.pagePropsObj.pagesize = pagesize;
238
+ this.loadingFunc();
239
+ },
240
+
241
+ // 点击 -添加行
242
+ clickCreate (operationItem, row, rowIndex, column) {
243
+ const curColKey = column ? column._key : undefined;
244
+ const list = this.data;
245
+ const newRow = this.getNewRowData();
246
+
247
+ // 处理单元格合并相关
248
+ if (this.isMergeRowTable) {
249
+ // 非底部按钮添加时
250
+ if (row) {
251
+ // 寻找对应的行数据 -当前列是合并列会寻找,普通列不用找(就是row)
252
+ if (this.mergeRowColKeys.includes(curColKey) && this.rowspanMap[this.getMixKey(row, column)] > 1) {
253
+ const newList = this.allListData.slice(rowIndex + 1); // 从下一行开始截取
254
+ const nextRowIndex = newList.findIndex(rowItem => this.rowspanMap[this.getMixKey(rowItem, column)] > 0); // 寻找该单元格值开始不一样的行
255
+ // nextRowIndex为-1,代表最后一行
256
+ row = nextRowIndex < 0
257
+ ? newList[newList.length - 1]
258
+ : newList[nextRowIndex - 1];
259
+ rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
260
+ }
261
+
262
+ // 寻找要复制值的列
263
+ // 当前列:一级合并列,不复制值;
264
+ if (this.firstMergeRowColKeys.includes(curColKey)) {
265
+ this.mergeRowColKeys.forEach(colKey => {
266
+ this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
267
+ });
268
+ }
269
+ // 当前列:普通合并列(非一级合并列)-该列之前的合并列和一级合并列复制值给新的行;非合并列-全部复制值给新的行
270
+ else {
271
+ const notFirstCopyColKeys = this.notFirstMergeRowColKeys.includes(curColKey)
272
+ ? this.notFirstMergeRowColKeys.filter((colKey, colIndex, list) => colIndex < list.findIndex(colKey => colKey === curColKey))
273
+ : this.notFirstMergeRowColKeys;
274
+ const noCopyColKeys = this.notFirstMergeRowColKeys.includes(curColKey)
275
+ ? this.notFirstMergeRowColKeys.filter((colKey, colIndex, list) => colIndex >= list.findIndex(colKey => colKey === curColKey))
276
+ : [];
277
+ const copyColKeys = notFirstCopyColKeys.concat(this.firstMergeRowColKeys);
278
+
279
+ // 复制值
280
+ copyColKeys.reduce((obj, colKey, colIndex) => {
281
+ return Object.assign(obj, {
282
+ [colKey]: this.$deepCopy(row[colKey])
283
+ });
284
+ }, newRow);
285
+
286
+ // rowspan记录
287
+ copyColKeys.forEach(colKey => {
288
+ // 合并的单元格更新rowspan记录
289
+ const fistMergeRow = this.rowspanMap[this.getMixKey(row, { _key: colKey })] === 0
290
+ ? list.slice(0, rowIndex).findLast(rowItem => this.rowspanMap[this.getMixKey(rowItem, { _key: colKey })] > 1)
291
+ : row;
292
+ this.rowspanMap[this.getMixKey(fistMergeRow, { _key: colKey })] = this.rowspanMap[this.getMixKey(fistMergeRow, { _key: colKey })] + 1;
293
+
294
+ // 新增的单元格做rowspan记录
295
+ this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 0;
296
+ });
297
+ noCopyColKeys.forEach(colKey => {
298
+ this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
299
+ });
300
+ }
301
+ }
302
+ // 底部按钮添加时
303
+ else {
304
+ this.mergeRowColKeys.forEach(colKey => {
305
+ this.rowspanMap[this.getMixKey(newRow, { _key: colKey })] = 1;
306
+ });
307
+ }
308
+ }
309
+
310
+ const newRowIndex = row
311
+ ? list.findIndex(rowItem => rowItem._id === row._id) + 1
312
+ : list.length;
313
+
314
+ if (this.isMergeRowTable) {
315
+ list.splice(newRowIndex, 0, newRow);
316
+ } else {
317
+ if (this.isUseDescSort) {
318
+ if (row) {
319
+ list.splice(newRowIndex - 1, 0, newRow);
320
+ this.goNextPage(rowIndex);
321
+ } else {
322
+ list.splice(newRowIndex, 0, newRow);
323
+ this.goLastDataPage();
324
+ }
325
+ } else {
326
+ if (row) {
327
+ list.splice(newRowIndex, 0, newRow);
328
+ this.goNextPage(rowIndex);
329
+ } else {
330
+ list.splice(newRowIndex, 0, newRow);
331
+ this.goLastDataPage();
332
+ }
333
+ }
334
+ }
335
+
336
+ this.changeSelect();
337
+ this.change("createRow", newRow, newRowIndex, null);
338
+ },
339
+ // 点击 -删除行
340
+ clickDelete (operationItem, row, rowIndex) {
341
+ this.$Modal.confirm({
342
+ title: "提示",
343
+ content: "确定删除吗?",
344
+ onOk: () => {
345
+ const list = this.data;
346
+
347
+ // 处理单元格合并相关
348
+ if (this.isMergeRowTable) {
349
+ this.mergeRowColKeys.forEach(colKey => {
350
+ const column = { _key: colKey };
351
+ const rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
352
+
353
+ // 当前单元格合并了下面的 -把合并数减去1给下一单元格
354
+ if (this.rowspanMap[this.getMixKey(row, column)] > 1) {
355
+ const nextRow = list[rowIndex + 1];
356
+ this.rowspanMap[this.getMixKey(nextRow, column)] = this.rowspanMap[this.getMixKey(row, column)] - 1;
357
+ }
358
+ // 当前单元格被上面的合并了 -最上面的合并单元格合并数减去1
359
+ else if (this.rowspanMap[this.getMixKey(row, column)] === 0) {
360
+ const fistMergeRow = list.slice(0, rowIndex).findLast(rowItem => this.rowspanMap[this.getMixKey(rowItem, column)] > 1);
361
+ this.rowspanMap[this.getMixKey(fistMergeRow, column)] = this.rowspanMap[this.getMixKey(fistMergeRow, column)] - 1;
362
+ }
363
+ // 当前单元格单独存在(无合并)
364
+ else if (this.rowspanMap[this.getMixKey(row, column)] === 1) {
365
+ // 无处理
366
+ }
367
+
368
+ // 清除被删除单元格的rowspan记录
369
+ delete this.rowspanMap[this.getMixKey(row, column)];
370
+ });
371
+ }
372
+
373
+ const listIndex = list.findIndex(rowItem => rowItem._id === row._id);
374
+ list.splice(listIndex, 1);
375
+ this.fixCurPage();
376
+
377
+ this.change("deleteRow", row, rowIndex, null);
378
+ }
379
+ });
380
+ },
381
+ quickChangeVal (operationItem, row, rowIndex, column, params) {
382
+ if (["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
383
+ this.dealRuleRecord(row, column);
384
+ this.dealSameRowsVal({ row, rowIndex, column });
385
+
386
+ this.change("quickChangeVal", row, rowIndex, column, ...params);
387
+ }
388
+ },
389
+ changeVal (operationItem, row, rowIndex, column, params) {
390
+ if (!["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
391
+ this.dealRuleRecord(row, column);
392
+ this.dealSameRowsVal({ row, rowIndex, column });
393
+
394
+ this.change("changeVal", row, rowIndex, column, ...params);
395
+ }
396
+ },
397
+
398
+ bodyCellSpan ({ row, rowIndex, column }) {
399
+ return {
400
+ rowspan: this.mergeRowColKeys.includes(column._key)
401
+ ? this.isSearching
402
+ ? this.getRowspan({ row, rowIndex, column })
403
+ : this.getRealRowspan({ row, rowIndex, column })
404
+ : 1,
405
+ colspan: 1
406
+ };
407
+ },
408
+ // 加工单元格对应的配置
409
+ getSelfResetCol ({ row, rowIndex, column }) {
410
+ return this.mergeRowColKeys.includes(column._key)
411
+ ? {
412
+ _heightAuto: true
413
+ }
414
+ : {};
415
+ },
416
+
417
+ /* ----------- 方法 ---------- */
418
+ fixSelfRowData (row) {
419
+ if (this.initFlag) {
420
+ // 每条数据都补充全所有字段值(赋一个默认的空值)
421
+ this.selfColumns.forEach((colItem) => {
422
+ // 不用row[colItem._key] === undefined判断,是因为后端给的空值不可靠,多选的有时候都能给null
423
+ if (!Object.prototype.hasOwnProperty.call(row, colItem._key) && this.$isEmptyData(row[colItem._key])) {
424
+ this.$set(row, colItem._key, this.$deepCopy(this.dftInitValMap[colItem._type]));
425
+ }
426
+ });
427
+ }
428
+ },
429
+ // 初始化合并单元格的rowspan
430
+ initRowspan () {
431
+ if (this.isMergeRowTable) {
432
+ this.$set(this.tableDataObj, "rowspanMap", this.tableDataObj.rowspanMap || {});
433
+
434
+ // TODO: 待删除
435
+ Object.entries(this.rowspanMap).forEach(arr => {
436
+ if (arr[0].includes("dsh")) {
437
+ this.rowspanMap[arr[0].split("dsh").join("--")] = this.rowspanMap[arr[1]];
438
+ delete this.rowspanMap[arr[0]];
439
+ }
440
+ });
441
+
442
+ this.allListData.forEach((rowItem, rowIndex) => {
443
+ this.mergeRowColKeys.forEach(colKey => {
444
+ const column = { _key: colKey };
445
+
446
+ // 新增页 -行的_id被置换,rowspanMap也要相应置换,还要清除rowspanMap里和默认行老_id相关的
447
+ const oldId = this.idRecordMap[rowItem._id];
448
+ const oldRow = { ...rowItem, _id: oldId };
449
+ if (oldId && ![undefined, null].includes(this.rowspanMap[this.getMixKey(oldRow, column)])) {
450
+ this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: oldRow, rowIndex, column });
451
+ delete this.rowspanMap[this.getMixKey(oldRow, column)];
452
+ } else {
453
+ this.rowspanMap[this.getMixKey(rowItem, column)] = this.getRealRowspan({ row: rowItem, rowIndex, column });
454
+ }
455
+ });
456
+ });
457
+
458
+ // 清除rowspanMap无用的(针对来回改mergeRowColKeys)
459
+ Object.entries(this.rowspanMap).forEach(arr => {
460
+ const keyArr = arr[0].split("--");
461
+ const id = keyArr[0];
462
+ const colKey = keyArr.slice(1).join("--");
463
+ if (!this.allListMap[id] || !this.mergeRowColKeys.includes(colKey)) {
464
+ delete this.rowspanMap[arr[0]];
465
+ }
466
+ });
467
+ }
468
+ },
469
+ // 获取合并单元格真实的rowspan
470
+ getRealRowspan ({ row, rowIndex, column }) {
471
+ return ![undefined, null].includes(this.rowspanMap[this.getMixKey(row, column)])
472
+ ? this.rowspanMap[this.getMixKey(row, column)]
473
+ : this.getRowspan({ row, rowIndex, column }, this.allListData);
474
+ },
475
+ // 计算rowspan
476
+ getRowspan ({ row, rowIndex, column }, list = this.showListData) {
477
+ let rowspan = 1;
478
+ rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
479
+
480
+ // 合并单元格的列走这
481
+ if (this.mergeRowColKeys.includes(column._key)) {
482
+ rowIndex = list.findIndex(dataItem => dataItem._id === row._id);
483
+
484
+ // 代表显示出来的行
485
+ if (rowIndex > -1) {
486
+ if (rowIndex !== 0 && this.isCompareSame(column, row, list[rowIndex - 1])) {
487
+ rowspan = 0;
488
+ } else {
489
+ const newList = list.slice(rowIndex + 1);
490
+ const newIndex = newList.findIndex(rowItem => !this.isCompareSame(column, row, rowItem));
491
+ rowspan = 1 + (newIndex === -1 ? newList.length : newIndex);
492
+ }
493
+ }
494
+ }
495
+
496
+ return rowspan;
497
+ },
498
+ // 合并单元格的行,某列的值全部跟着修改
499
+ dealSameRowsVal ({ row, rowIndex, column }, list = this.allListData) {
500
+ if (this.mergeRowColKeys.includes(column._key) && this.rowspanMap[this.getMixKey(row, column)] > 1) {
501
+ const indexInAll = list.findIndex(dataItem => dataItem._id === row._id);
502
+ list.slice(indexInAll + 1, indexInAll + this.rowspanMap[this.getMixKey(row, column)])
503
+ .forEach(rowItem => {
504
+ rowItem[column._key] = this.$deepCopy(row[column._key]);
505
+ });
506
+ }
507
+ }
508
+ }
509
+ };