bri-components 1.4.93 → 1.4.94

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