bri-components 1.3.98 → 1.4.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.
- package/package.json +1 -1
- package/src/components/controls/base/BriUpload/BriUpload.vue +17 -2
- package/src/components/controls/base/BriUpload/uploadList.vue +271 -56
- package/src/components/controls/base/DshSelect/DshCheckbox.vue +1 -1
- package/src/components/controls/base/DshSelect/DshSelect.vue +1 -1
- package/src/components/controls/mixins/controlMixin.js +29 -29
- package/src/components/controls/mixins/selectMixin.js +1 -1
- package/src/components/controls/senior/cascaderTable.vue +4 -2
- package/src/components/controls/senior/flatTable.vue +2 -0
- package/src/components/controls/senior/selectUsers/departMenu.vue +2 -1
- package/src/components/form/DshForm.vue +1 -1
- package/src/components/list/DshBox/DshCrossTable.vue +0 -3
- package/src/components/list/mixins/DshCascaderTableMixin.js +227 -332
- package/src/components/list/mixins/DshFlatTableMixin.js +44 -8
- package/src/components/list/mixins/DshTreeTableMixin.js +14 -14
- package/src/components/list/mixins/tableBaseMixin.js +209 -193
- package/src/components/list/mixins/treeTableBaseMixin.js +57 -20
- package/src/components/small/DshDropdown.vue +2 -1
- package/src/styles/components/list/BriTable.less +3 -2
|
@@ -2,16 +2,6 @@ export default {
|
|
|
2
2
|
mixins: [],
|
|
3
3
|
components: {},
|
|
4
4
|
props: {
|
|
5
|
-
tableDataObj: {
|
|
6
|
-
type: Object,
|
|
7
|
-
default () {
|
|
8
|
-
return {
|
|
9
|
-
tree: [],
|
|
10
|
-
list: [],
|
|
11
|
-
_treeForm: []
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
5
|
treeColumns: {
|
|
16
6
|
type: Array,
|
|
17
7
|
default () {
|
|
@@ -21,54 +11,44 @@ export default {
|
|
|
21
11
|
},
|
|
22
12
|
data () {
|
|
23
13
|
return {
|
|
24
|
-
boxWidth: 0
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
otherOperationMap: {
|
|
42
|
-
canChangeNode: {
|
|
43
|
-
name: "改变节点值",
|
|
44
|
-
type: "canChangeNode",
|
|
45
|
-
event: "changeNode"
|
|
46
|
-
},
|
|
47
|
-
canClickNode: {
|
|
48
|
-
name: "点击节点",
|
|
49
|
-
type: "canClickNode",
|
|
50
|
-
event: "clickNode"
|
|
51
|
-
},
|
|
52
|
-
canBlurNode: {
|
|
53
|
-
name: "节点失去焦点",
|
|
54
|
-
type: "canBlurNode",
|
|
55
|
-
event: "blurNode"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
14
|
+
boxWidth: 0
|
|
15
|
+
// baseOperationMap: {
|
|
16
|
+
// canCreateCol: {
|
|
17
|
+
// name: "添加一列",
|
|
18
|
+
// type: "canCreateCol",
|
|
19
|
+
// icon: "md-add",
|
|
20
|
+
// event: "clickCreateCol"
|
|
21
|
+
// },
|
|
22
|
+
// canDeleteCol: {
|
|
23
|
+
// name: "删除该列",
|
|
24
|
+
// type: "canDeleteCol",
|
|
25
|
+
// icon: "md-trash",
|
|
26
|
+
// color: "red",
|
|
27
|
+
// event: "clickDeleteCol"
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
58
30
|
};
|
|
59
31
|
},
|
|
60
32
|
computed: {
|
|
61
|
-
|
|
33
|
+
selfBasePropsObj () {
|
|
62
34
|
return {
|
|
35
|
+
...this.treeTableBasePropsObj,
|
|
63
36
|
_dftReadonlyTreeColKeys: [], // 默认的数据只读的表头列
|
|
64
37
|
_oldReadonlyTreeColKeys: [] // 保存的数据只读的表头列
|
|
65
38
|
};
|
|
66
39
|
},
|
|
67
40
|
dftReadonlyTreeColKeys () {
|
|
68
|
-
return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; //
|
|
41
|
+
return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
69
42
|
},
|
|
70
43
|
oldReadonlyTreeColKeys () {
|
|
71
|
-
return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; //
|
|
44
|
+
return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyTreeColKeys || []; // 配置端有问题,高级依赖时值成undefined了
|
|
45
|
+
},
|
|
46
|
+
// 替换tableBaseMixin里的
|
|
47
|
+
showCreateBtnColKeys () {
|
|
48
|
+
return [
|
|
49
|
+
...this.treeFormKeys,
|
|
50
|
+
...(this.selfPropsObj._showCreateBtnColKeys || [])
|
|
51
|
+
];
|
|
72
52
|
},
|
|
73
53
|
|
|
74
54
|
allTreeData () {
|
|
@@ -105,72 +85,34 @@ export default {
|
|
|
105
85
|
init () {
|
|
106
86
|
this.treeColumns.forEach((treeFormItem, treeFormIndex) => {
|
|
107
87
|
this.$set(treeFormItem, "level", treeFormIndex + 1);
|
|
108
|
-
this.$set(treeFormItem, "canDelete", true);
|
|
88
|
+
// this.$set(treeFormItem, "canDelete", true);
|
|
109
89
|
});
|
|
110
90
|
},
|
|
111
91
|
|
|
112
|
-
/* ----------- 操作 ---------- */
|
|
113
|
-
// 表头操作 -树形表头-添加一列
|
|
114
|
-
clickCreateCol (operationItem, col, colIndex) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.tableDataObj._treeForm = this.treeColumns;
|
|
92
|
+
// /* ----------- 操作 ---------- */
|
|
93
|
+
// // 表头操作 -树形表头-添加一列
|
|
94
|
+
// clickCreateCol (operationItem, col, colIndex) {
|
|
95
|
+
// this.treeColumns.push({
|
|
96
|
+
// _id: this.$ObjectID().str,
|
|
97
|
+
// _key: this.$randomB36("Field"),
|
|
98
|
+
// _type: "textarea",
|
|
99
|
+
// _name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
|
|
100
|
+
// level: this.treeColumns.length + 1,
|
|
101
|
+
// canDelete: true,
|
|
102
|
+
// _treeSubForm: []
|
|
103
|
+
// });
|
|
104
|
+
// this.tableDataObj._treeForm = this.treeColumns;
|
|
126
105
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.treeColumns.pop();
|
|
135
|
-
this.tableDataObj._treeForm = this.treeColumns;
|
|
106
|
+
// this.change("createCol", null, null, col);
|
|
107
|
+
// },
|
|
108
|
+
// // 表头操作 -树形表头-删除一列
|
|
109
|
+
// clickDeleteCol (operationItem, col, colIndex) {
|
|
110
|
+
// this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
|
|
111
|
+
// this.treeColumns.pop();
|
|
112
|
+
// this.tableDataObj._treeForm = this.treeColumns;
|
|
136
113
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
// 树形、汇总节点操作 -点击
|
|
142
|
-
clickNode (operationItem, row, rowIndex, col) {
|
|
143
|
-
if (col.colType === "tree") {
|
|
144
|
-
if (
|
|
145
|
-
(this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
|
|
146
|
-
(row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true) // 老数据行里某些列不可编辑
|
|
147
|
-
) {
|
|
148
|
-
row.isEdit = true;
|
|
149
|
-
this.$nextTick(() => {
|
|
150
|
-
this.$refs[`${col._id}${row._id}`] && this.$refs[`${col._id}${row._id}`].focus();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (col.colType === "summary") {
|
|
155
|
-
this.$Modal.warning({
|
|
156
|
-
title: "该汇总单元格自动计算,不准手动输入!",
|
|
157
|
-
closable: true,
|
|
158
|
-
onOk: () => { },
|
|
159
|
-
onCancel: () => { }
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
// 树形节点操作 -失去焦点
|
|
164
|
-
blurNode (operationItem, row, rowIndex, col) {
|
|
165
|
-
row.isEdit = false;
|
|
166
|
-
},
|
|
167
|
-
// 树形节点操作 -值改变
|
|
168
|
-
changeNode (operationItem, row, rowIndex, col) {
|
|
169
|
-
this.change("changeNode", row, rowIndex, col);
|
|
170
|
-
},
|
|
171
|
-
change (eventType, row, rowIndex, col, ...params) {
|
|
172
|
-
this.$emit("change", this.tableDataObj, eventType, col, row, rowIndex, ...params);
|
|
173
|
-
},
|
|
114
|
+
// this.change("deleteCol", null, null, col);
|
|
115
|
+
// },
|
|
174
116
|
|
|
175
117
|
/* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
|
|
176
118
|
// 表格表头渲染函数
|
|
@@ -196,19 +138,12 @@ export default {
|
|
|
196
138
|
"tr",
|
|
197
139
|
{},
|
|
198
140
|
this.showColumns.map((column, colIndex) => {
|
|
199
|
-
return h
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
this.thRender(h, { column, colIndex })
|
|
206
|
-
// h("dsh-render", {
|
|
207
|
-
// props: {
|
|
208
|
-
// render: this.thRender(h, { column, colIndex })
|
|
209
|
-
// }
|
|
210
|
-
// })
|
|
211
|
-
]);
|
|
141
|
+
return this.thRender(h, { column, colIndex });
|
|
142
|
+
// return h("dsh-render", {
|
|
143
|
+
// props: {
|
|
144
|
+
// render: this.thRender(h, { column, colIndex })
|
|
145
|
+
// }
|
|
146
|
+
// })
|
|
212
147
|
})
|
|
213
148
|
)
|
|
214
149
|
])
|
|
@@ -244,30 +179,20 @@ export default {
|
|
|
244
179
|
class: ""
|
|
245
180
|
},
|
|
246
181
|
this.rowColumnsArr[rowIndex].map(column => {
|
|
247
|
-
return
|
|
248
|
-
// 树节点单元格、汇总单元格
|
|
249
|
-
? this.treeTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column })
|
|
250
|
-
// 普通单元格
|
|
251
|
-
: this.contentTdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column });
|
|
182
|
+
return this.tdRender(h, { row: mixedRow[column.nodeKey || column._key], rowIndex, column });
|
|
252
183
|
})
|
|
253
184
|
);
|
|
254
185
|
})
|
|
255
186
|
// 无数据
|
|
256
|
-
: h(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
attrs: {
|
|
266
|
-
rowspan: 1,
|
|
267
|
-
colspan: this.showColumns.length
|
|
268
|
-
}
|
|
269
|
-
}, "暂无数据…")
|
|
270
|
-
])
|
|
187
|
+
: h(
|
|
188
|
+
"tr",
|
|
189
|
+
{
|
|
190
|
+
class: "bri-table-nodata"
|
|
191
|
+
},
|
|
192
|
+
[
|
|
193
|
+
this.emptyTdRender(h, {})
|
|
194
|
+
]
|
|
195
|
+
)
|
|
271
196
|
])
|
|
272
197
|
])
|
|
273
198
|
])
|
|
@@ -275,204 +200,141 @@ export default {
|
|
|
275
200
|
},
|
|
276
201
|
// 表头单元格渲染函数 (无法共用contentColumns的renderHeaderCell,因为级联老版表头的无renderHeaderCell)
|
|
277
202
|
thRender (h, { column, colIndex }) {
|
|
278
|
-
return h(
|
|
279
|
-
|
|
203
|
+
return h(
|
|
204
|
+
"th",
|
|
205
|
+
{
|
|
206
|
+
key: column._id,
|
|
207
|
+
class: "bri-table-th",
|
|
208
|
+
style: this.getThStyle(column)
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
this.contentThCellRender(h, { column, colIndex })
|
|
280
212
|
|
|
281
|
-
|
|
282
|
-
this.treeDropOperationRender(h, { column, colIndex }, "th")
|
|
213
|
+
// this.treeThDropOperationRender(h, { column, colIndex })
|
|
283
214
|
]);
|
|
284
215
|
},
|
|
285
|
-
|
|
286
|
-
treeTdRender (h, { row, rowIndex, column }) {
|
|
216
|
+
emptyTdRender (h, { row, rowIndex, column }) {
|
|
287
217
|
return h("td", {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
218
|
+
style: {
|
|
219
|
+
width: `${this.boxWidth}px`,
|
|
220
|
+
minWidth: `${this.boxWidth}px`,
|
|
221
|
+
maxWidth: `${this.boxWidth}px`
|
|
292
222
|
},
|
|
293
|
-
style: this.getTdStyle(row, rowIndex, column),
|
|
294
223
|
attrs: {
|
|
295
|
-
rowspan:
|
|
296
|
-
colspan: this.
|
|
297
|
-
},
|
|
298
|
-
on: {
|
|
299
|
-
click: () => {
|
|
300
|
-
this.$dispatchEvent(this.operationMap.canClickNode, row, rowIndex, column);
|
|
301
|
-
}
|
|
224
|
+
rowspan: 1,
|
|
225
|
+
colspan: this.showColumns.length
|
|
302
226
|
}
|
|
303
|
-
},
|
|
304
|
-
column.colType === "tree"
|
|
305
|
-
// 树节点单元格
|
|
306
|
-
? row.isEdit
|
|
307
|
-
// 编辑状态
|
|
308
|
-
? h("Input", {
|
|
309
|
-
ref: `${column._id}${row._id}`,
|
|
310
|
-
props: {
|
|
311
|
-
value: row.name,
|
|
312
|
-
type: "textarea",
|
|
313
|
-
autosize: {
|
|
314
|
-
minRows: this.getTdRowSpan(row, rowIndex, column) * 3 - 1,
|
|
315
|
-
maxRows: 100
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
on: {
|
|
319
|
-
input: val => {
|
|
320
|
-
row.name = val;
|
|
321
|
-
},
|
|
322
|
-
"on-blur": () => {
|
|
323
|
-
this.$dispatchEvent(this.operationMap.canBlurNode, row, rowIndex, column);
|
|
324
|
-
},
|
|
325
|
-
"on-change": () => {
|
|
326
|
-
this.$dispatchEvent(this.operationMap.canChangeNode, row, rowIndex, column);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
// 查看状态
|
|
331
|
-
: [
|
|
332
|
-
h("bri-tooltip", {
|
|
333
|
-
props: {
|
|
334
|
-
content: this.$transformEnterToBr(row.name),
|
|
335
|
-
transfer: true
|
|
336
|
-
}
|
|
337
|
-
}, [
|
|
338
|
-
h("span", {
|
|
339
|
-
domProps: {
|
|
340
|
-
innerHTML: this.$transformEnterToBr(row.name)
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
]),
|
|
344
|
-
|
|
345
|
-
// 操作下拉
|
|
346
|
-
this.treeDropOperationRender(h, { row, rowIndex, column }, "td")
|
|
347
|
-
]
|
|
348
|
-
// 汇总单元格
|
|
349
|
-
: h("span", this.getSummaryTdVal(row, rowIndex, column))
|
|
350
|
-
]);
|
|
227
|
+
}, "暂无数据…");
|
|
351
228
|
},
|
|
352
|
-
//
|
|
353
|
-
|
|
229
|
+
// 内容单元格渲染函数
|
|
230
|
+
tdRender (h, { row, rowIndex, column }) {
|
|
354
231
|
return h(
|
|
355
232
|
"td",
|
|
356
233
|
{
|
|
357
|
-
class: this.
|
|
234
|
+
class: this.bodyCellClass({ row, rowIndex, column }) +
|
|
235
|
+
`${["tree"].includes(column.colType) ? " bri-table-td-merge" : ""}`,
|
|
358
236
|
style: this.getTdStyle(row, rowIndex, column),
|
|
237
|
+
attrs: {
|
|
238
|
+
rowspan: this.getTdRowSpan(row, rowIndex, column),
|
|
239
|
+
colspan: this.getTdColSpan(row, rowIndex, column)
|
|
240
|
+
},
|
|
359
241
|
on: {
|
|
360
242
|
mouseenter: (event) => {
|
|
361
|
-
this.$set(this.hoverRecordMap, `${row._id}
|
|
243
|
+
this.$set(this.hoverRecordMap, `${row._id}`, true);
|
|
244
|
+
// this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, true);
|
|
362
245
|
},
|
|
363
246
|
mouseleave: (event) => {
|
|
364
|
-
this.$set(this.hoverRecordMap, `${row._id}
|
|
247
|
+
this.$set(this.hoverRecordMap, `${row._id}`, false);
|
|
248
|
+
// this.$set(this.hoverRecordMap, `${row._id}dsh${column._key}`, false);
|
|
365
249
|
}
|
|
366
250
|
}
|
|
367
251
|
},
|
|
368
|
-
|
|
252
|
+
column.colType === "summary"
|
|
253
|
+
? h("span", this.getSummaryTdVal(row, rowIndex, column))
|
|
254
|
+
: column.colType === "operation"
|
|
255
|
+
? this.operationTdCellRender(h, { row, rowIndex, column })
|
|
256
|
+
: this.contentTdCellRender(h, { row, rowIndex, column })
|
|
369
257
|
);
|
|
370
258
|
},
|
|
371
|
-
//
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"canCreate",
|
|
382
|
-
...(this.getRowBtnCanEdit(row, rowIndex) ? ["canDelete"] : [])
|
|
383
|
-
]
|
|
384
|
-
: [
|
|
385
|
-
"canCreate",
|
|
386
|
-
"canCreateChild",
|
|
387
|
-
...(this.getRowBtnCanEdit(row, rowIndex) ? ["canDelete", "canDeleteChilds"] : [])
|
|
388
|
-
]
|
|
389
|
-
);
|
|
259
|
+
// // 树形表头最末级列的下拉渲染函数
|
|
260
|
+
// treeThDropOperationRender (h, { column, colIndex }) {
|
|
261
|
+
// const list = this.$getOperationList(
|
|
262
|
+
// column.colType === "tree" && column.level === this.treeColumns.length
|
|
263
|
+
// ? [
|
|
264
|
+
// ...(column.level < this.maxLevel ? ["canCreateCol"] : []), // 限制最大添加到几级
|
|
265
|
+
// ...(column.canDelete === true ? ["canDeleteCol"] : []) // 只有一级和最后两级节点数不一致时,不能删
|
|
266
|
+
// ]
|
|
267
|
+
// : []
|
|
268
|
+
// );
|
|
390
269
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
size: "16"
|
|
431
|
-
}
|
|
432
|
-
})
|
|
433
|
-
])
|
|
434
|
-
])
|
|
435
|
-
: undefined;
|
|
436
|
-
},
|
|
270
|
+
// return !this.isSearching &&
|
|
271
|
+
// list.length
|
|
272
|
+
// ? h("dsh-dropdown", {
|
|
273
|
+
// class: "bri-table-dropdown",
|
|
274
|
+
// props: {
|
|
275
|
+
// menuClass: "bri-table-dropdown-list",
|
|
276
|
+
// trigger: "hover",
|
|
277
|
+
// list: list
|
|
278
|
+
// },
|
|
279
|
+
// on: {
|
|
280
|
+
// click: (operationItem) => {
|
|
281
|
+
// this.$dispatchEvent(operationItem, column, colIndex);
|
|
282
|
+
// }
|
|
283
|
+
// },
|
|
284
|
+
// nativeOn: {
|
|
285
|
+
// click: (e) => {
|
|
286
|
+
// e.stopPropagation();
|
|
287
|
+
// }
|
|
288
|
+
// }
|
|
289
|
+
// }, [
|
|
290
|
+
// h("a", {
|
|
291
|
+
// style: {
|
|
292
|
+
// fontWeight: "500",
|
|
293
|
+
// color: this.appColor
|
|
294
|
+
// },
|
|
295
|
+
// attrs: {
|
|
296
|
+
// href: "javascript:void(0)"
|
|
297
|
+
// }
|
|
298
|
+
// }, [
|
|
299
|
+
// h("Icon", {
|
|
300
|
+
// props: {
|
|
301
|
+
// type: "md-arrow-dropdown-circle",
|
|
302
|
+
// size: "16"
|
|
303
|
+
// }
|
|
304
|
+
// })
|
|
305
|
+
// ])
|
|
306
|
+
// ])
|
|
307
|
+
// : undefined;
|
|
308
|
+
// },
|
|
437
309
|
|
|
438
310
|
/* ----------- 方法 ---------- */
|
|
439
311
|
// 表头 -获取样式
|
|
440
|
-
getThStyle (col
|
|
312
|
+
getThStyle (col) {
|
|
313
|
+
const typeData = this.$modFieldMap[col._type] || {};
|
|
441
314
|
const boxColWidth = this.boxWidth / this.showColumns.length;
|
|
442
315
|
const calcWidth = (col._name ? col._name.length * 12 : 48) + (col._type === "reference" ? 200 : 32);
|
|
443
316
|
const dftWidth = Math.max(boxColWidth, this.widthMap[col._type], calcWidth);
|
|
444
317
|
const width = col._width || dftWidth;
|
|
445
318
|
|
|
446
|
-
const selfStyle = col.colType === "tree"
|
|
447
|
-
? {
|
|
448
|
-
textAlign: col._align || "left",
|
|
449
|
-
fontSize: "14px"
|
|
450
|
-
}
|
|
451
|
-
: col.colType === "summary"
|
|
452
|
-
? {
|
|
453
|
-
textAlign: col._align || "right"
|
|
454
|
-
}
|
|
455
|
-
: {
|
|
456
|
-
textAlign: col._align || "left"
|
|
457
|
-
};
|
|
458
|
-
|
|
459
319
|
return {
|
|
460
320
|
width: `${width}px`,
|
|
461
321
|
minWidth: `${width}px`,
|
|
462
322
|
maxWidth: `${width}px`,
|
|
463
|
-
paddingTop:
|
|
464
|
-
paddingBottom:
|
|
323
|
+
paddingTop: !this.headHeightAuto ? "10px" : undefined,
|
|
324
|
+
paddingBottom: !this.headHeightAuto ? "10px" : undefined,
|
|
325
|
+
textAlign: col._align || typeData.align,
|
|
465
326
|
"word-break": "break-all",
|
|
466
|
-
cursor: "pointer"
|
|
467
|
-
...selfStyle
|
|
327
|
+
cursor: "pointer"
|
|
468
328
|
};
|
|
469
329
|
},
|
|
470
330
|
|
|
471
331
|
// 单元格 -获取样式
|
|
472
332
|
getTdStyle (row, rowIndex, col) {
|
|
473
333
|
return {
|
|
474
|
-
...this.getThStyle(col
|
|
475
|
-
|
|
334
|
+
...this.getThStyle(col),
|
|
335
|
+
paddingTop: undefined,
|
|
336
|
+
paddingBottom: undefined,
|
|
337
|
+
backgroundColor: "#ffffff"
|
|
476
338
|
};
|
|
477
339
|
},
|
|
478
340
|
// 单元格 -获取行合并数
|
|
@@ -513,12 +375,29 @@ export default {
|
|
|
513
375
|
: "未选择算法";
|
|
514
376
|
}
|
|
515
377
|
},
|
|
378
|
+
// 列本身是否可编辑 -针对表头列
|
|
379
|
+
getTypeColCanEdit (row, rowIndex, col) {
|
|
380
|
+
return (this.getIsDftRow(row) ? !this.dftReadonlyTreeColKeys.includes(col._key) : true) && // 默认行的某列是否可编辑
|
|
381
|
+
(row.__old__ === true ? !this.oldReadonlyTreeColKeys.includes(col._key) : true); // 老数据行里某些列不可编辑
|
|
382
|
+
},
|
|
383
|
+
// getNewRowData时,额外补充的行相关的数据(针对层级属性的列)
|
|
384
|
+
getRowOtherDft (level, list) {
|
|
385
|
+
const column = this.treeForm[level - 1];
|
|
386
|
+
const dftVal = column._default;
|
|
387
|
+
const initDftVal = this.initDftValMap[column._type];
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
name: this.$isEmptyData(dftVal)
|
|
391
|
+
? initDftVal
|
|
392
|
+
: dftVal
|
|
393
|
+
};
|
|
394
|
+
},
|
|
516
395
|
|
|
517
396
|
/* ----------- 工具方法 ---------- */
|
|
518
397
|
// 合并表头
|
|
519
398
|
mergeColumns (treeForm = [], subForm = this.showContentColumns) {
|
|
520
|
-
return
|
|
521
|
-
.reduce((arr, treeFormItem
|
|
399
|
+
return [
|
|
400
|
+
...treeForm.reduce((arr, treeFormItem) => {
|
|
522
401
|
return arr.concat(
|
|
523
402
|
{
|
|
524
403
|
...treeFormItem,
|
|
@@ -532,68 +411,80 @@ export default {
|
|
|
532
411
|
}
|
|
533
412
|
))
|
|
534
413
|
);
|
|
535
|
-
}, [])
|
|
536
|
-
.
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
414
|
+
}, []),
|
|
415
|
+
...subForm.map(subFormItem => ({
|
|
416
|
+
...subFormItem,
|
|
417
|
+
nodeKey: treeForm[treeForm.length - 1]._key,
|
|
418
|
+
colType: "data"
|
|
419
|
+
})),
|
|
420
|
+
...(
|
|
421
|
+
!this.isSearching && this.$getOperationList(["canDelete"]).length
|
|
422
|
+
? [{
|
|
423
|
+
...this.operationColumn,
|
|
540
424
|
nodeKey: treeForm[treeForm.length - 1]._key,
|
|
541
|
-
colType: "
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
425
|
+
colType: "operation"
|
|
426
|
+
}]
|
|
427
|
+
: []
|
|
428
|
+
)
|
|
429
|
+
];
|
|
545
430
|
},
|
|
546
431
|
// 转化树数据
|
|
547
432
|
getCalcuedTree (nodes = [], treeForm = [], subForm = []) {
|
|
548
433
|
treeForm.forEach((treeFormItem, treeFormIndex) => {
|
|
549
|
-
treeFormItem.canDelete = true; // 每次计算,重置一下
|
|
434
|
+
// treeFormItem.canDelete = true; // 每次计算,重置一下
|
|
550
435
|
treeFormItem.level = treeFormIndex + 1; // treeColumns更新,缺少level
|
|
551
436
|
});
|
|
552
437
|
|
|
553
438
|
// 循环遍树节点
|
|
554
|
-
const loop = (nodes = []) => {
|
|
439
|
+
const loop = (nodes = [], parentNodes = []) => {
|
|
555
440
|
nodes.forEach(rowItem => {
|
|
556
441
|
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
557
442
|
let curCol = treeForm[rowItem.level - 1];
|
|
558
443
|
this.$setObj(rowItem, {
|
|
559
444
|
_key: curCol._key,
|
|
560
445
|
level: curCol.level,
|
|
561
|
-
isEdit: false,
|
|
562
446
|
isLeaf: false,
|
|
563
447
|
total: 1
|
|
564
448
|
});
|
|
565
449
|
|
|
566
450
|
// 最后一列(根节点)
|
|
567
451
|
if (rowItem.level === treeForm.length) {
|
|
568
|
-
// 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
|
|
569
|
-
if (this.isDeleteColStatus) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
452
|
+
// // 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
|
|
453
|
+
// if (this.isDeleteColStatus) {
|
|
454
|
+
// let subNode = rowItem.children[0];
|
|
455
|
+
// subForm.forEach(subFormItem => {
|
|
456
|
+
// // 用$set也可以
|
|
457
|
+
// rowItem[subFormItem._key] = subNode[subFormItem._key];
|
|
458
|
+
// });
|
|
459
|
+
// }
|
|
576
460
|
|
|
577
461
|
rowItem.children = [];
|
|
578
462
|
rowItem.isLeaf = true;
|
|
463
|
+
|
|
464
|
+
// TODO:特殊处理-叶子节点上注入对应表头列们的name值
|
|
465
|
+
const treeNodes = [...parentNodes, rowItem];
|
|
466
|
+
treeForm.forEach((treeFormItem, treeFormIndex) => {
|
|
467
|
+
rowItem[treeFormItem._key] = treeNodes[treeFormIndex].name;
|
|
468
|
+
});
|
|
579
469
|
}
|
|
580
470
|
// 非最后一列(最后一列前的列,非根节点),需继续向下循环
|
|
581
471
|
else {
|
|
582
|
-
// 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
|
|
583
|
-
if (rowItem.level === treeForm.length - 1) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
472
|
+
// // 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
|
|
473
|
+
// if (rowItem.level === treeForm.length - 1) {
|
|
474
|
+
// if (rowItem.children.length > 1) {
|
|
475
|
+
// treeForm[rowItem.level].canDelete = false;
|
|
476
|
+
// }
|
|
477
|
+
// }
|
|
588
478
|
|
|
589
479
|
// 非最后一列的 正常的非根节点
|
|
590
480
|
if (rowItem.children && rowItem.children.length) {
|
|
591
|
-
loop(rowItem.children);
|
|
481
|
+
loop(rowItem.children, [...parentNodes, rowItem]);
|
|
592
482
|
}
|
|
593
483
|
// 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
|
|
594
484
|
// 特别提示:新增的是根节点行,不会走此处代码
|
|
595
485
|
else {
|
|
596
486
|
const newNode = this.getNewRowData(rowItem.level + 1, rowItem.children);
|
|
487
|
+
|
|
597
488
|
subForm.forEach(subFormItem => {
|
|
598
489
|
// 用$set也可以
|
|
599
490
|
newNode[subFormItem._key] = rowItem[subFormItem._key];
|
|
@@ -601,7 +492,7 @@ export default {
|
|
|
601
492
|
});
|
|
602
493
|
rowItem.children.push(newNode);
|
|
603
494
|
|
|
604
|
-
loop(rowItem.children);
|
|
495
|
+
loop(rowItem.children, [...parentNodes, rowItem]);
|
|
605
496
|
}
|
|
606
497
|
}
|
|
607
498
|
|
|
@@ -616,7 +507,7 @@ export default {
|
|
|
616
507
|
},
|
|
617
508
|
// 转化渲染使用的columns数组
|
|
618
509
|
transformRowColumnsArr (nodes = [], treeForm = []) {
|
|
619
|
-
|
|
510
|
+
const loop = (nodes = [], rowColumnsArr = []) => {
|
|
620
511
|
nodes = this.getFilteredNodes(nodes);
|
|
621
512
|
|
|
622
513
|
return nodes.reduce((rowColumnsArr, node, nodeIndex) => {
|
|
@@ -634,11 +525,11 @@ export default {
|
|
|
634
525
|
}, rowColumnsArr);
|
|
635
526
|
};
|
|
636
527
|
|
|
637
|
-
return loop(nodes
|
|
528
|
+
return loop(nodes);
|
|
638
529
|
},
|
|
639
530
|
// 转化表格数据
|
|
640
531
|
transformRows (nodes = [], treeForm = []) {
|
|
641
|
-
const loop = (nodes, rows) => {
|
|
532
|
+
const loop = (nodes = [], rows = []) => {
|
|
642
533
|
nodes = this.getFilteredNodes(nodes);
|
|
643
534
|
|
|
644
535
|
return nodes.reduce((rows, node, nodeIndex) => {
|
|
@@ -661,12 +552,16 @@ export default {
|
|
|
661
552
|
}
|
|
662
553
|
}, rows);
|
|
663
554
|
};
|
|
664
|
-
return loop(nodes
|
|
555
|
+
return loop(nodes);
|
|
665
556
|
},
|
|
666
557
|
getFilteredNodes (nodes = []) {
|
|
667
558
|
const loop = (nodes = []) => {
|
|
668
559
|
return nodes.filter(rowItem => {
|
|
669
560
|
if (rowItem.children && rowItem.children.length) {
|
|
561
|
+
if (this.isSearching) {
|
|
562
|
+
rowItem.__isSearchShow__ = true;
|
|
563
|
+
}
|
|
564
|
+
|
|
670
565
|
const children = loop(rowItem.children);
|
|
671
566
|
return !!children.length;
|
|
672
567
|
} else {
|