bri-components 1.3.66 → 1.3.68
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/senior/cascaderTable.vue +6 -4
- package/src/components/list/DshCascaderTable.vue +12 -919
- package/src/components/list/mixins/DshCascaderTableMixin.js +857 -0
- package/src/components/list/mixins/DshTreeTableMixin.js +1 -1
- package/src/components/list/mixins/tableBaseMixin.js +1 -1
|
@@ -22,166 +22,10 @@
|
|
|
22
22
|
}"
|
|
23
23
|
>
|
|
24
24
|
<!-- 表头 -->
|
|
25
|
-
<
|
|
26
|
-
<div class="DshCasTable-main-center-top-inner">
|
|
27
|
-
<table
|
|
28
|
-
class="table"
|
|
29
|
-
border="1"
|
|
30
|
-
cellspacing="0"
|
|
31
|
-
bordercolor="#E7EDF8"
|
|
32
|
-
>
|
|
33
|
-
<tbody>
|
|
34
|
-
<tr>
|
|
35
|
-
<th
|
|
36
|
-
v-for="(column, colIndex) in showColumns"
|
|
37
|
-
:key="column._id"
|
|
38
|
-
class="table-th bri-table-th"
|
|
39
|
-
:style="getThStyle(column, 'th')"
|
|
40
|
-
@click="$dispatchEvent(operationMap.clickTh, column)"
|
|
41
|
-
>
|
|
42
|
-
<dsh-render :render="getThRender(column)"></dsh-render>
|
|
43
|
-
|
|
44
|
-
<!-- 级联表头 的下拉 -->
|
|
45
|
-
<dsh-dropdown
|
|
46
|
-
v-if="
|
|
47
|
-
!isSearching &&
|
|
48
|
-
column.colType === 'tree' &&
|
|
49
|
-
column.level === treeColumns.length &&
|
|
50
|
-
$getOperationList(getTreeThBtns(column)).length
|
|
51
|
-
"
|
|
52
|
-
class="table-th-dropdown"
|
|
53
|
-
menuClass="table-th-dropdown-list"
|
|
54
|
-
trigger="hover"
|
|
55
|
-
:list="$getOperationList(getTreeThBtns(column))"
|
|
56
|
-
@click="$dispatchEvent($event, column, colIndex, showColumns)"
|
|
57
|
-
@click.native.stop="0"
|
|
58
|
-
>
|
|
59
|
-
<a href="javascript:void(0)">
|
|
60
|
-
<Icon
|
|
61
|
-
type="md-add-circle"
|
|
62
|
-
size="20"
|
|
63
|
-
/>
|
|
64
|
-
</a>
|
|
65
|
-
</dsh-dropdown>
|
|
66
|
-
</th>
|
|
67
|
-
</tr>
|
|
68
|
-
</tbody>
|
|
69
|
-
</table>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
25
|
+
<dsh-render :render="getTableHeadRender()"></dsh-render>
|
|
72
26
|
|
|
73
27
|
<!-- 数据行 -->
|
|
74
|
-
<
|
|
75
|
-
<div class="DshCasTable-main-center-list-inner">
|
|
76
|
-
<table
|
|
77
|
-
class="table"
|
|
78
|
-
border="1"
|
|
79
|
-
cellspacing="0"
|
|
80
|
-
bordercolor="#E7EDF8"
|
|
81
|
-
>
|
|
82
|
-
<tbody>
|
|
83
|
-
<template v-if="showListData.length">
|
|
84
|
-
<tr
|
|
85
|
-
v-for="(row, rowIndex) in showListData"
|
|
86
|
-
:key="row._id"
|
|
87
|
-
class="table-row"
|
|
88
|
-
>
|
|
89
|
-
<template v-for="column in rowColumnsArr[rowIndex]">
|
|
90
|
-
<!-- 树节点单元格、汇总单元格 -->
|
|
91
|
-
<td
|
|
92
|
-
v-if="['tree', 'summary'].includes(column.colType)"
|
|
93
|
-
:key="column._key"
|
|
94
|
-
:class="{
|
|
95
|
-
[`table-td-${column.colType}`]: true,
|
|
96
|
-
'bri-table-td': true , // 可以不要,为了position: relative,上面有
|
|
97
|
-
'bri-table-td-edit': canEdit
|
|
98
|
-
}"
|
|
99
|
-
:style="getTdStyle(column, row[column.nodeKey])"
|
|
100
|
-
:rowspan="getTdRowSpan(column, row[column.nodeKey || column._key])"
|
|
101
|
-
:colspan="getTdColSpan(column, row[column.nodeKey])"
|
|
102
|
-
@click="$dispatchEvent(operationMap.clickNode, column, row, row[column._key])"
|
|
103
|
-
>
|
|
104
|
-
<!-- 树节点单元格 -->
|
|
105
|
-
<template v-if="column.colType === 'tree'">
|
|
106
|
-
<!-- 编辑状态 -->
|
|
107
|
-
<Input
|
|
108
|
-
v-if="row[column._key].isEdit"
|
|
109
|
-
:ref="`${column._id}${row._id}`"
|
|
110
|
-
v-model="row[column._key].name"
|
|
111
|
-
class="textarea"
|
|
112
|
-
type="textarea"
|
|
113
|
-
:autosize="{
|
|
114
|
-
minRows: getTdRowSpan(column, row[column.nodeKey || column._key]) * 3 - 1,
|
|
115
|
-
maxRows: 100
|
|
116
|
-
}"
|
|
117
|
-
@on-blur="$dispatchEvent(operationMap.blurNode, column, row, row[column._key])"
|
|
118
|
-
@on-change="$dispatchEvent(operationMap.changeNode, column, row, row[column._key])"
|
|
119
|
-
/>
|
|
120
|
-
|
|
121
|
-
<!-- 查看状态 -->
|
|
122
|
-
<template v-else>
|
|
123
|
-
<bri-tooltip
|
|
124
|
-
:content="enterText(row[column._key].name)"
|
|
125
|
-
:transfer="true"
|
|
126
|
-
>
|
|
127
|
-
<span v-html="enterText(row[column._key].name)"></span>
|
|
128
|
-
</bri-tooltip>
|
|
129
|
-
|
|
130
|
-
<!-- 操作下拉 -->
|
|
131
|
-
<dsh-dropdown
|
|
132
|
-
v-if="!isSearching && $getOperationList(getTreeTdBtns(column, row, row[column._key])).length"
|
|
133
|
-
class="table-td-tree-dropdown"
|
|
134
|
-
menuClass="table-td-tree-dropdown-list"
|
|
135
|
-
trigger="hover"
|
|
136
|
-
:list="$getOperationList(getTreeTdBtns(column, row, row[column._key]))"
|
|
137
|
-
@click="$dispatchEvent($event, row, rowIndex, column)"
|
|
138
|
-
@click.native.stop="0"
|
|
139
|
-
>
|
|
140
|
-
<a href="javascript:void(0)">
|
|
141
|
-
<Icon
|
|
142
|
-
type="md-add-circle"
|
|
143
|
-
size="20"
|
|
144
|
-
/>
|
|
145
|
-
</a>
|
|
146
|
-
</dsh-dropdown>
|
|
147
|
-
</template>
|
|
148
|
-
</template>
|
|
149
|
-
|
|
150
|
-
<!-- 汇总单元格 -->
|
|
151
|
-
<template v-else-if="column.colType === 'summary'">
|
|
152
|
-
<span>{{ getSummaryVal(column, row[column.nodeKey]) }}</span>
|
|
153
|
-
</template>
|
|
154
|
-
</td>
|
|
155
|
-
|
|
156
|
-
<!-- 普通单元格 -->
|
|
157
|
-
<dsh-render
|
|
158
|
-
v-else
|
|
159
|
-
:key="column._key + 'data'"
|
|
160
|
-
:render="getTdRender(column, row, rowIndex)"
|
|
161
|
-
></dsh-render>
|
|
162
|
-
</template>
|
|
163
|
-
</tr>
|
|
164
|
-
</template>
|
|
165
|
-
|
|
166
|
-
<!-- 无数据 -->
|
|
167
|
-
<tr
|
|
168
|
-
v-else
|
|
169
|
-
class="table-nodata"
|
|
170
|
-
>
|
|
171
|
-
<td
|
|
172
|
-
:style="{
|
|
173
|
-
width: `${boxWidth}px`,
|
|
174
|
-
minWidth: `${boxWidth}px`,
|
|
175
|
-
maxWidth: `${boxWidth}px`,
|
|
176
|
-
}"
|
|
177
|
-
:rowspan="1"
|
|
178
|
-
:colspan="showColumns.length"
|
|
179
|
-
>暂无数据…</td>
|
|
180
|
-
</tr>
|
|
181
|
-
</tbody>
|
|
182
|
-
</table>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
28
|
+
<dsh-render :render="getTableBodyRender()"></dsh-render>
|
|
185
29
|
</div>
|
|
186
30
|
</div>
|
|
187
31
|
|
|
@@ -211,166 +55,10 @@
|
|
|
211
55
|
}"
|
|
212
56
|
>
|
|
213
57
|
<!-- 表头 -->
|
|
214
|
-
<
|
|
215
|
-
<div class="DshCasTable-main-center-top-inner">
|
|
216
|
-
<table
|
|
217
|
-
class="table"
|
|
218
|
-
border="1"
|
|
219
|
-
cellspacing="0"
|
|
220
|
-
bordercolor="#E7EDF8"
|
|
221
|
-
>
|
|
222
|
-
<tbody>
|
|
223
|
-
<tr>
|
|
224
|
-
<th
|
|
225
|
-
v-for="(column, colIndex) in showColumns"
|
|
226
|
-
:key="column._id"
|
|
227
|
-
class="table-th bri-table-th"
|
|
228
|
-
:style="getThStyle(column, 'th')"
|
|
229
|
-
@click="$dispatchEvent(operationMap.clickTh, column)"
|
|
230
|
-
>
|
|
231
|
-
<dsh-render :render="getThRender(column)"></dsh-render>
|
|
232
|
-
|
|
233
|
-
<!-- 级联表头 的下拉 -->
|
|
234
|
-
<dsh-dropdown
|
|
235
|
-
v-if="
|
|
236
|
-
!isSearching &&
|
|
237
|
-
column.colType === 'tree' &&
|
|
238
|
-
column.level === treeColumns.length &&
|
|
239
|
-
$getOperationList(getTreeThBtns(column)).length
|
|
240
|
-
"
|
|
241
|
-
class="table-th-dropdown"
|
|
242
|
-
menuClass="table-th-dropdown-list"
|
|
243
|
-
trigger="hover"
|
|
244
|
-
:list="$getOperationList(getTreeThBtns(column))"
|
|
245
|
-
@click="$dispatchEvent($event, column, colIndex, showColumns)"
|
|
246
|
-
@click.native.stop="0"
|
|
247
|
-
>
|
|
248
|
-
<a href="javascript:void(0)">
|
|
249
|
-
<Icon
|
|
250
|
-
type="md-add-circle"
|
|
251
|
-
size="20"
|
|
252
|
-
/>
|
|
253
|
-
</a>
|
|
254
|
-
</dsh-dropdown>
|
|
255
|
-
</th>
|
|
256
|
-
</tr>
|
|
257
|
-
</tbody>
|
|
258
|
-
</table>
|
|
259
|
-
</div>
|
|
260
|
-
</div>
|
|
58
|
+
<dsh-render :render="getTableHeadRender()"></dsh-render>
|
|
261
59
|
|
|
262
60
|
<!-- 数据行 -->
|
|
263
|
-
<
|
|
264
|
-
<div class="DshCasTable-main-center-list-inner">
|
|
265
|
-
<table
|
|
266
|
-
class="table"
|
|
267
|
-
border="1"
|
|
268
|
-
cellspacing="0"
|
|
269
|
-
bordercolor="#E7EDF8"
|
|
270
|
-
>
|
|
271
|
-
<tbody>
|
|
272
|
-
<template v-if="showListData.length">
|
|
273
|
-
<tr
|
|
274
|
-
v-for="(row, rowIndex) in showListData"
|
|
275
|
-
:key="row._id"
|
|
276
|
-
class="table-row"
|
|
277
|
-
>
|
|
278
|
-
<template v-for="column in rowColumnsArr[rowIndex]">
|
|
279
|
-
<!-- 树节点单元格、汇总单元格 -->
|
|
280
|
-
<td
|
|
281
|
-
v-if="['tree', 'summary'].includes(column.colType)"
|
|
282
|
-
:key="column._key"
|
|
283
|
-
:class="{
|
|
284
|
-
[`table-td-${column.colType}`]: true,
|
|
285
|
-
'bri-table-td': true , // 可以不要,为了position: relative,上面有
|
|
286
|
-
'bri-table-td-edit': canEdit
|
|
287
|
-
}"
|
|
288
|
-
:style="getTdStyle(column, row[column.nodeKey])"
|
|
289
|
-
:rowspan="getTdRowSpan(column, row[column.nodeKey || column._key])"
|
|
290
|
-
:colspan="getTdColSpan(column, row[column.nodeKey])"
|
|
291
|
-
@click="$dispatchEvent(operationMap.clickNode, column, row, row[column._key])"
|
|
292
|
-
>
|
|
293
|
-
<!-- 树节点单元格 -->
|
|
294
|
-
<template v-if="column.colType === 'tree'">
|
|
295
|
-
<!-- 编辑状态 -->
|
|
296
|
-
<Input
|
|
297
|
-
v-if="row[column._key].isEdit"
|
|
298
|
-
:ref="`${column._id}${row._id}`"
|
|
299
|
-
v-model="row[column._key].name"
|
|
300
|
-
class="textarea"
|
|
301
|
-
type="textarea"
|
|
302
|
-
:autosize="{
|
|
303
|
-
minRows: getTdRowSpan(column, row[column.nodeKey || column._key]) * 3 - 1,
|
|
304
|
-
maxRows: 100
|
|
305
|
-
}"
|
|
306
|
-
@on-blur="$dispatchEvent(operationMap.blurNode, column, row, row[column._key])"
|
|
307
|
-
@on-change="$dispatchEvent(operationMap.changeNode, column, row, row[column._key])"
|
|
308
|
-
/>
|
|
309
|
-
|
|
310
|
-
<!-- 查看状态 -->
|
|
311
|
-
<template v-else>
|
|
312
|
-
<bri-tooltip
|
|
313
|
-
:content="enterText(row[column._key].name)"
|
|
314
|
-
:transfer="true"
|
|
315
|
-
>
|
|
316
|
-
<span v-html="enterText(row[column._key].name)"></span>
|
|
317
|
-
</bri-tooltip>
|
|
318
|
-
|
|
319
|
-
<!-- 操作下拉 -->
|
|
320
|
-
<dsh-dropdown
|
|
321
|
-
v-if="!isSearching && $getOperationList(getTreeTdBtns(column, row, row[column._key])).length"
|
|
322
|
-
class="table-td-tree-dropdown"
|
|
323
|
-
menuClass="table-td-tree-dropdown-list"
|
|
324
|
-
trigger="hover"
|
|
325
|
-
:list="$getOperationList(getTreeTdBtns(column, row, row[column._key]))"
|
|
326
|
-
@click="$dispatchEvent($event, row, rowIndex, column)"
|
|
327
|
-
@click.native.stop="0"
|
|
328
|
-
>
|
|
329
|
-
<a href="javascript:void(0)">
|
|
330
|
-
<Icon
|
|
331
|
-
type="md-add-circle"
|
|
332
|
-
size="20"
|
|
333
|
-
/>
|
|
334
|
-
</a>
|
|
335
|
-
</dsh-dropdown>
|
|
336
|
-
</template>
|
|
337
|
-
</template>
|
|
338
|
-
|
|
339
|
-
<!-- 汇总单元格 -->
|
|
340
|
-
<template v-else-if="column.colType === 'summary'">
|
|
341
|
-
<span>{{ getSummaryVal(column, row[column.nodeKey]) }}</span>
|
|
342
|
-
</template>
|
|
343
|
-
</td>
|
|
344
|
-
|
|
345
|
-
<!-- 普通单元格 -->
|
|
346
|
-
<dsh-render
|
|
347
|
-
v-else
|
|
348
|
-
:key="column._key + 'data'"
|
|
349
|
-
:render="getTdRender(column, row, rowIndex)"
|
|
350
|
-
></dsh-render>
|
|
351
|
-
</template>
|
|
352
|
-
</tr>
|
|
353
|
-
</template>
|
|
354
|
-
|
|
355
|
-
<!-- 无数据 -->
|
|
356
|
-
<tr
|
|
357
|
-
v-else
|
|
358
|
-
class="table-nodata"
|
|
359
|
-
>
|
|
360
|
-
<td
|
|
361
|
-
:style="{
|
|
362
|
-
width: `${boxWidth}px`,
|
|
363
|
-
minWidth: `${boxWidth}px`,
|
|
364
|
-
maxWidth: `${boxWidth}px`,
|
|
365
|
-
}"
|
|
366
|
-
:rowspan="1"
|
|
367
|
-
:colspan="showColumns.length"
|
|
368
|
-
>暂无数据…</td>
|
|
369
|
-
</tr>
|
|
370
|
-
</tbody>
|
|
371
|
-
</table>
|
|
372
|
-
</div>
|
|
373
|
-
</div>
|
|
61
|
+
<dsh-render :render="getTableBodyRender()"></dsh-render>
|
|
374
62
|
</div>
|
|
375
63
|
</div>
|
|
376
64
|
</div>
|
|
@@ -380,617 +68,22 @@
|
|
|
380
68
|
|
|
381
69
|
<script>
|
|
382
70
|
import tableBaseMixin from "./mixins/tableBaseMixin.js";
|
|
71
|
+
import DshCascaderTableMixin from "./mixins/DshCascaderTableMixin.js";
|
|
383
72
|
|
|
384
73
|
export default {
|
|
385
74
|
name: "DshCascaderTable",
|
|
386
75
|
mixins: [
|
|
387
|
-
tableBaseMixin
|
|
76
|
+
tableBaseMixin,
|
|
77
|
+
DshCascaderTableMixin
|
|
388
78
|
],
|
|
389
79
|
components: {},
|
|
390
|
-
props: {
|
|
391
|
-
data: {
|
|
392
|
-
type: Object,
|
|
393
|
-
default () {
|
|
394
|
-
return {
|
|
395
|
-
tree: [],
|
|
396
|
-
list: [],
|
|
397
|
-
_treeForm: []
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
treeColumns: {
|
|
402
|
-
type: Array,
|
|
403
|
-
default () {
|
|
404
|
-
return [];
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
},
|
|
80
|
+
props: {},
|
|
408
81
|
data () {
|
|
409
|
-
return {
|
|
410
|
-
boxWidth: 0,
|
|
411
|
-
|
|
412
|
-
baseOperationMap: {
|
|
413
|
-
clickTh: {
|
|
414
|
-
name: "点击列的表头",
|
|
415
|
-
type: "clickTh",
|
|
416
|
-
event: "clickTh"
|
|
417
|
-
},
|
|
418
|
-
createCol: {
|
|
419
|
-
name: "添加一列",
|
|
420
|
-
type: "createCol",
|
|
421
|
-
icon: "md-add",
|
|
422
|
-
event: "createCol"
|
|
423
|
-
},
|
|
424
|
-
deleteCol: {
|
|
425
|
-
name: "删除该列",
|
|
426
|
-
type: "deleteCol",
|
|
427
|
-
icon: "md-trash",
|
|
428
|
-
color: "red",
|
|
429
|
-
event: "deleteCol"
|
|
430
|
-
},
|
|
431
|
-
|
|
432
|
-
clickNode: {
|
|
433
|
-
name: "点击节点",
|
|
434
|
-
type: "clickNode",
|
|
435
|
-
event: "clickNode"
|
|
436
|
-
},
|
|
437
|
-
blurNode: {
|
|
438
|
-
name: "节点失去焦点",
|
|
439
|
-
type: "blurNode",
|
|
440
|
-
event: "blurNode"
|
|
441
|
-
},
|
|
442
|
-
changeNode: {
|
|
443
|
-
name: "改变节点值",
|
|
444
|
-
type: "changeNode",
|
|
445
|
-
event: "changeNode"
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
createBrotherNode: {
|
|
449
|
-
name: "添加同级节点",
|
|
450
|
-
type: "createBrotherNode",
|
|
451
|
-
icon: "md-add",
|
|
452
|
-
event: "createBrotherNode"
|
|
453
|
-
},
|
|
454
|
-
createChildNode: {
|
|
455
|
-
name: "添加子节点",
|
|
456
|
-
type: "createChildNode",
|
|
457
|
-
icon: "md-add",
|
|
458
|
-
event: "createChildNode"
|
|
459
|
-
},
|
|
460
|
-
deleteSelfAndChildNodes: {
|
|
461
|
-
name: "删除该节点",
|
|
462
|
-
type: "deleteSelfAndChildNodes",
|
|
463
|
-
icon: "md-trash",
|
|
464
|
-
color: "red",
|
|
465
|
-
divided: true,
|
|
466
|
-
event: "deleteSelfAndChildNodes"
|
|
467
|
-
},
|
|
468
|
-
deleteChildNodes: {
|
|
469
|
-
name: "删除所有子节点",
|
|
470
|
-
type: "deleteChildNodes",
|
|
471
|
-
icon: "md-trash",
|
|
472
|
-
color: "red",
|
|
473
|
-
event: "deleteChildNodes"
|
|
474
|
-
},
|
|
475
|
-
clearNode: {
|
|
476
|
-
name: "清除该节点内容",
|
|
477
|
-
type: "clearNode",
|
|
478
|
-
icon: "md-trash",
|
|
479
|
-
divided: true,
|
|
480
|
-
event: "clearNode"
|
|
481
|
-
},
|
|
482
|
-
clearChildNodes: {
|
|
483
|
-
name: "清除所有子节点内容",
|
|
484
|
-
type: "clearChildNodes",
|
|
485
|
-
icon: "md-trash",
|
|
486
|
-
event: "clearChildNodes"
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
},
|
|
491
|
-
computed: {
|
|
492
|
-
selfPropsObj () {
|
|
493
|
-
return {
|
|
494
|
-
...this.commonPropsObj,
|
|
495
|
-
|
|
496
|
-
_contentHeight: this.propsObj._contentHeight || 400 // 表格最大高度
|
|
497
|
-
};
|
|
498
|
-
},
|
|
499
|
-
|
|
500
|
-
allTreeData () {
|
|
501
|
-
return this.getCalcuedTree();
|
|
502
|
-
},
|
|
503
|
-
allListData () {
|
|
504
|
-
return this.$getTreeFlatArr(this.data.tree, node => !(node.children && node.children.length));
|
|
505
|
-
},
|
|
506
|
-
showListData () {
|
|
507
|
-
return this.transformRows();
|
|
508
|
-
},
|
|
509
|
-
|
|
510
|
-
showColumns () {
|
|
511
|
-
return this.transformColumns(this.treeColumns);
|
|
512
|
-
},
|
|
513
|
-
// 供表格渲染行使用的columns的数组集合, 每一行columns不一样,组成二重数组
|
|
514
|
-
rowColumnsArr () {
|
|
515
|
-
return this.transformRowColumnsArr();
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
created () {
|
|
519
|
-
this.init();
|
|
520
|
-
},
|
|
521
|
-
mounted () {
|
|
522
|
-
setTimeout(() => {
|
|
523
|
-
this.$el.querySelector(".DshCasTable-main-center-list").addEventListener("scroll", (e) => {
|
|
524
|
-
this.$el.querySelector(".DshCasTable-main-center-top").scrollLeft = e.srcElement.scrollLeft;
|
|
525
|
-
}, false);
|
|
526
|
-
this.boxWidth = this.$refs.DshCascaderTable.clientWidth;
|
|
527
|
-
}, 0);
|
|
82
|
+
return {};
|
|
528
83
|
},
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
this.treeColumns.forEach((treeFormItem, treeFormIndex) => {
|
|
533
|
-
this.$set(treeFormItem, "level", treeFormIndex + 1);
|
|
534
|
-
this.$set(treeFormItem, "canDelete", true);
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
// 循环遍树,给根节点赋值
|
|
538
|
-
let loop = (nodes) => {
|
|
539
|
-
nodes.forEach(node => {
|
|
540
|
-
if (node.children.length) {
|
|
541
|
-
loop(node.children);
|
|
542
|
-
} else {
|
|
543
|
-
// 根节点下所有表格字段加上监测,注入到节点对象中,必须$set,牵扯_rely值再出现并没有检测
|
|
544
|
-
this.columns.forEach(subFormItem => {
|
|
545
|
-
this.$set(node, subFormItem._key, node[subFormItem._key]);
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
};
|
|
550
|
-
loop(this.data.tree);
|
|
551
|
-
},
|
|
552
|
-
|
|
553
|
-
// 点击表头
|
|
554
|
-
clickTh (operationItem, col) {
|
|
555
|
-
this.$emit("clickTh", col);
|
|
556
|
-
},
|
|
557
|
-
// 树形表头列 -添加
|
|
558
|
-
createCol (operationItem, col, colIndex, list) {
|
|
559
|
-
if (col.colType === "tree" && col.level === this.treeColumns.length) {
|
|
560
|
-
this.treeColumns.push({
|
|
561
|
-
_id: this.$ObjectID().str,
|
|
562
|
-
_key: this.$randomB36("Field"),
|
|
563
|
-
_type: "textarea",
|
|
564
|
-
_name: `${this.$numToChinese(this.treeColumns.length + 1)}级表头`,
|
|
565
|
-
level: this.treeColumns.length + 1,
|
|
566
|
-
canDelete: true,
|
|
567
|
-
_treeSubForm: []
|
|
568
|
-
});
|
|
569
|
-
this.data._treeForm = this.treeColumns;
|
|
570
|
-
|
|
571
|
-
this.change("createCol", col, null);
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
// 树形表头列 -删除
|
|
575
|
-
deleteCol (operationItem, col, colIndex, list) {
|
|
576
|
-
if (col.colType === "tree" && col.canDelete !== false) {
|
|
577
|
-
this.isDeleteColStatus = true; // isDeleteStatus不用在data中定义
|
|
578
|
-
this.treeColumns.pop();
|
|
579
|
-
this.data._treeForm = this.treeColumns;
|
|
580
|
-
|
|
581
|
-
this.change("deleteCol", col, null);
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
|
|
585
|
-
/* ----- 树节点事件 ------ */
|
|
586
|
-
// 点击节点
|
|
587
|
-
clickNode (operationItem, col, row, nodeData) {
|
|
588
|
-
if (col.colType === "tree") {
|
|
589
|
-
nodeData.isEdit = true;
|
|
590
|
-
this.$nextTick(() => {
|
|
591
|
-
this.$refs[`${col._id}${row._id}`][0] && this.$refs[`${col._id}${row._id}`][0].focus();
|
|
592
|
-
});
|
|
593
|
-
} else if (col.colType === "summary") {
|
|
594
|
-
this.$Modal.warning({
|
|
595
|
-
title: "该汇总单元格自动计算,不准手动输入!",
|
|
596
|
-
closable: true,
|
|
597
|
-
onOk: () => {},
|
|
598
|
-
onCancel: () => {}
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
// 节点失去焦点
|
|
603
|
-
blurNode (operationItem, col, row, nodeData) {
|
|
604
|
-
nodeData.isEdit = false;
|
|
605
|
-
},
|
|
606
|
-
// 改变节点名
|
|
607
|
-
changeNode (operationItem, col, row, nodeData) {
|
|
608
|
-
this.change("changeNode", col, row, nodeData);
|
|
609
|
-
},
|
|
610
|
-
|
|
611
|
-
/* ---- 节点操作 ----- */
|
|
612
|
-
// 添加同级节点
|
|
613
|
-
createBrotherNode (operationItem, row, rowIndex, col) {
|
|
614
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
615
|
-
let newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
616
|
-
nodeData.brotherList.splice(nodeData.index + 1, 0, newNode);
|
|
617
|
-
|
|
618
|
-
this.change("createBrotherNode", col, row, nodeData);
|
|
619
|
-
},
|
|
620
|
-
// 添加子节点
|
|
621
|
-
createChildNode (operationItem, row, rowIndex, col) {
|
|
622
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
623
|
-
let newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
624
|
-
nodeData.childList.splice(nodeData.childList.length, 0, newNode);
|
|
625
|
-
|
|
626
|
-
this.change("createChildNode", col, row, nodeData);
|
|
627
|
-
},
|
|
628
|
-
// 删除该节点
|
|
629
|
-
deleteSelfAndChildNodes (operationItem, row, rowIndex, col) {
|
|
630
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
631
|
-
nodeData.brotherList.splice(nodeData.index, 1);
|
|
632
|
-
// 此处应该判断子节点是否是最后一个,是的话就要添加一个一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
|
|
633
|
-
if (!nodeData.brotherList.length) {
|
|
634
|
-
let newNode = this.getNewNode(nodeData.level, nodeData.brotherList);
|
|
635
|
-
nodeData.brotherList.push(newNode);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
this.change("deleteSelfAndChildNodes", col, row, nodeData);
|
|
639
|
-
},
|
|
640
|
-
// 删除所有子节点
|
|
641
|
-
deleteChildNodes (operationItem, row, rowIndex, col) {
|
|
642
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
643
|
-
nodeData.childList.splice(0);
|
|
644
|
-
// 删除完应该添加一个子节点一直到叶子节点,不过现在只需要添加一个子节点,transforBriTreeData会捎带着处理了
|
|
645
|
-
let newNode = this.getNewNode(nodeData.level + 1, nodeData.childList);
|
|
646
|
-
nodeData.childList.push(newNode);
|
|
647
|
-
|
|
648
|
-
this.change("deleteChildNodes", col, row, nodeData);
|
|
649
|
-
},
|
|
650
|
-
// 清除该节点内容
|
|
651
|
-
clearNode (operationItem, row, rowIndex, col) {
|
|
652
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
653
|
-
nodeData.data.name = "";
|
|
654
|
-
|
|
655
|
-
this.change("clearNode", col, row, nodeData);
|
|
656
|
-
},
|
|
657
|
-
// 清除所有子节点内容
|
|
658
|
-
clearChildNodes (operationItem, row, rowIndex, col) {
|
|
659
|
-
let nodeData = this.getNodeData(row, rowIndex, col);
|
|
660
|
-
this.clearNodeToLeaf(nodeData.childList);
|
|
661
|
-
|
|
662
|
-
this.change("clearChildNodes", col, row, nodeData);
|
|
663
|
-
},
|
|
664
|
-
// 发生变动
|
|
665
|
-
change (...params) {
|
|
666
|
-
this.$emit("change", this.data, ...params);
|
|
667
|
-
},
|
|
668
|
-
|
|
669
|
-
/* ---- 工具方法 ---- */
|
|
670
|
-
// 合并表头
|
|
671
|
-
transformColumns (treeForm = this.treeColumns, subForm = this.contentColumns) {
|
|
672
|
-
return treeForm
|
|
673
|
-
.reduce((arr, treeFormItem, treeFormIndex) => {
|
|
674
|
-
return arr.concat(
|
|
675
|
-
{
|
|
676
|
-
...treeFormItem,
|
|
677
|
-
colType: "tree"
|
|
678
|
-
},
|
|
679
|
-
treeFormItem._treeSubForm.map(treeSubFormItem => (
|
|
680
|
-
{
|
|
681
|
-
...treeSubFormItem,
|
|
682
|
-
nodeKey: treeFormItem._key,
|
|
683
|
-
colType: "summary"
|
|
684
|
-
}
|
|
685
|
-
))
|
|
686
|
-
);
|
|
687
|
-
}, [])
|
|
688
|
-
.concat(
|
|
689
|
-
subForm.filter(subFormItem =>
|
|
690
|
-
this.hideStatus === true
|
|
691
|
-
? !this.hideColKeys.includes(subFormItem._key)
|
|
692
|
-
: true
|
|
693
|
-
).map(subFormItem => (
|
|
694
|
-
{
|
|
695
|
-
...subFormItem,
|
|
696
|
-
nodeKey: treeForm[treeForm.length - 1]._key,
|
|
697
|
-
colType: "data"
|
|
698
|
-
}
|
|
699
|
-
))
|
|
700
|
-
);
|
|
701
|
-
},
|
|
702
|
-
// 转化树数据
|
|
703
|
-
getCalcuedTree (treeForm = this.treeColumns, subForm = this.columns) {
|
|
704
|
-
treeForm.forEach((treeFormItem, treeFormIndex) => {
|
|
705
|
-
treeFormItem.canDelete = true; // 每次计算,重置一下
|
|
706
|
-
treeFormItem.level = treeFormIndex + 1; // treeColumns更新,缺少level
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
// 循环遍树节点
|
|
710
|
-
const loop = (nodes) => {
|
|
711
|
-
nodes.forEach(node => {
|
|
712
|
-
// 初始化树节点的数据,给节点加上一些属性并监测,注入到节点对象中
|
|
713
|
-
let curCol = treeForm[node.level - 1];
|
|
714
|
-
this.$setObj(node, {
|
|
715
|
-
_key: curCol._key,
|
|
716
|
-
level: curCol.level,
|
|
717
|
-
isEdit: false,
|
|
718
|
-
isLeaf: false,
|
|
719
|
-
total: 1
|
|
720
|
-
});
|
|
721
|
-
|
|
722
|
-
// 最后一列(根节点)
|
|
723
|
-
if (node.level === treeForm.length) {
|
|
724
|
-
// 处理删除了最后一列后,把根节点上的subForm属性值全部给上级节点
|
|
725
|
-
if (this.isDeleteColStatus) {
|
|
726
|
-
let subNode = node.children[0];
|
|
727
|
-
subForm.forEach(subFormItem => {
|
|
728
|
-
// 用$set也可以
|
|
729
|
-
node[subFormItem._key] = subNode[subFormItem._key];
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
node.children = [];
|
|
734
|
-
node.isLeaf = true;
|
|
735
|
-
}
|
|
736
|
-
// 非最后一列(最后一列前的列,非根节点),需继续向下循环
|
|
737
|
-
else {
|
|
738
|
-
// 判断是否能删除最后一列(1.判断条件:判断根节点列的前一列的所有节点 都必须只有一个子结点 2.canDelete放在表头treeForm最后一项,默认true)
|
|
739
|
-
if (node.level === treeForm.length - 1) {
|
|
740
|
-
if (node.children.length > 1) {
|
|
741
|
-
treeForm[node.level].canDelete = false;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// 非最后一列的 正常的非根节点
|
|
746
|
-
if (node.children.length) {
|
|
747
|
-
loop(node.children);
|
|
748
|
-
}
|
|
749
|
-
// 非最后一列的 新增的非根节点(此时是新增一列或新增非根节点行) -添加一个子节点,并把该节点上的subForm属性值全部给下级节点
|
|
750
|
-
// 特别提示:新增的是根节点行,不会走此处代码
|
|
751
|
-
else {
|
|
752
|
-
const newNode = this.getNewNode(node.level + 1, node.children);
|
|
753
|
-
subForm.forEach(subFormItem => {
|
|
754
|
-
// 用$set也可以
|
|
755
|
-
newNode[subFormItem._key] = node[subFormItem._key];
|
|
756
|
-
delete node[subFormItem._key];
|
|
757
|
-
});
|
|
758
|
-
node.children.push(newNode);
|
|
759
|
-
|
|
760
|
-
loop(node.children);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
};
|
|
765
|
-
loop(this.data.tree);
|
|
766
|
-
this.isDeleteColStatus = false;
|
|
767
|
-
|
|
768
|
-
return this.data.tree;
|
|
769
|
-
},
|
|
770
|
-
// 转化渲染使用的columns数组
|
|
771
|
-
transformRowColumnsArr (nodes = this.allTreeData, treeForm = this.treeColumns) {
|
|
772
|
-
let loop = (nodes, rowColumnsArr) => {
|
|
773
|
-
nodes = this.getFilteredNodes(nodes);
|
|
774
|
-
|
|
775
|
-
return nodes.reduce((rowColumnsArr, node, nodeIndex) => {
|
|
776
|
-
if (nodeIndex !== 0 || rowColumnsArr.length === 0) {
|
|
777
|
-
rowColumnsArr.push(this.transformColumns(treeForm.slice(node.level - 1)));
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
if (node.children.length) {
|
|
781
|
-
return loop(node.children, rowColumnsArr);
|
|
782
|
-
} else {
|
|
783
|
-
return rowColumnsArr;
|
|
784
|
-
}
|
|
785
|
-
}, rowColumnsArr);
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
return loop(nodes, []);
|
|
789
|
-
},
|
|
790
|
-
// 转化表格数据
|
|
791
|
-
transformRows (nodes = this.allTreeData, treeForm = this.treeColumns) {
|
|
792
|
-
const loop = (nodes, rows) => {
|
|
793
|
-
nodes = this.getFilteredNodes(nodes);
|
|
794
|
-
|
|
795
|
-
return nodes.reduce((rows, node, nodeIndex) => {
|
|
796
|
-
// 创建行,并把节点数据(对象类型)注入到行对象内
|
|
797
|
-
if (nodeIndex !== 0 || rows.length === 0) {
|
|
798
|
-
rows.push({ _id: this.$ObjectID().str });
|
|
799
|
-
}
|
|
800
|
-
const curCol = treeForm[node.level - 1];
|
|
801
|
-
const curRow = rows[rows.length - 1];
|
|
802
|
-
Object.assign(curRow, { [curCol._key]: node });
|
|
803
|
-
|
|
804
|
-
// 判断是否叶子节点,做对应操作
|
|
805
|
-
if (node.children.length) {
|
|
806
|
-
const oldLength = rows.length - 1;
|
|
807
|
-
const newRows = loop(node.children, rows);
|
|
808
|
-
node.total = newRows.length - oldLength;
|
|
809
|
-
return newRows;
|
|
810
|
-
} else {
|
|
811
|
-
return rows;
|
|
812
|
-
}
|
|
813
|
-
}, rows);
|
|
814
|
-
};
|
|
815
|
-
return loop(nodes, []);
|
|
816
|
-
},
|
|
817
|
-
getFilteredNodes (nodes) {
|
|
818
|
-
const loop = (nodes = []) => {
|
|
819
|
-
return nodes.filter(node => {
|
|
820
|
-
if (node.children && node.children.length) {
|
|
821
|
-
const children = loop(node.children);
|
|
822
|
-
return !!children.length;
|
|
823
|
-
} else {
|
|
824
|
-
return this.$isAdvRelyAccord(this.finalTableAdvSearch, node);
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
return loop(nodes);
|
|
830
|
-
},
|
|
831
|
-
|
|
832
|
-
// 清除节点到叶子节点
|
|
833
|
-
clearNodeToLeaf (list) {
|
|
834
|
-
let loop = (list) => {
|
|
835
|
-
list.forEach(item => {
|
|
836
|
-
item.name = "";
|
|
837
|
-
if (item.children.length) {
|
|
838
|
-
loop(item.children);
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
};
|
|
842
|
-
loop(list);
|
|
843
|
-
},
|
|
844
|
-
// 获取节点数据
|
|
845
|
-
getNodeData (row, rowIndex, col) {
|
|
846
|
-
let parentNode = this.getParentNode(row, rowIndex, col);
|
|
847
|
-
return {
|
|
848
|
-
level: col.level,
|
|
849
|
-
data: row[col._key],
|
|
850
|
-
childList: row[col._key].children,
|
|
851
|
-
brotherList: parentNode.children,
|
|
852
|
-
index: parentNode.children.findIndex(item => item._id === row[col._key]._id)
|
|
853
|
-
};
|
|
854
|
-
},
|
|
855
|
-
// 获取父节点数据
|
|
856
|
-
getParentNode (row, rowIndex, col, treeForm = this.treeColumns) {
|
|
857
|
-
if (col.level === 1) {
|
|
858
|
-
return {
|
|
859
|
-
children: this.allTreeData
|
|
860
|
-
};
|
|
861
|
-
} else {
|
|
862
|
-
let parentCol = treeForm[col.level - 2];
|
|
863
|
-
let loop = (row, rowIndex) => row[parentCol._key] || loop(this.showListData[rowIndex - 1], rowIndex - 1);
|
|
864
|
-
return loop(row, rowIndex);
|
|
865
|
-
}
|
|
866
|
-
},
|
|
867
|
-
// 获取节点数据
|
|
868
|
-
getNewNode (level, list) {
|
|
869
|
-
return {
|
|
870
|
-
...this.$deepCopy(this.selfRowDefault),
|
|
871
|
-
_id: this.$ObjectID().str,
|
|
872
|
-
name: `${this.$numToChinese(level)}级节点${list.length + 1}`,
|
|
873
|
-
level: level,
|
|
874
|
-
// isLeaf: true,
|
|
875
|
-
children: []
|
|
876
|
-
};
|
|
877
|
-
},
|
|
878
|
-
|
|
879
|
-
/* ----- 模板获值方法 ---- */
|
|
880
|
-
getThStyle (col, position) {
|
|
881
|
-
const boxColWidth = this.boxWidth / this.showColumns.length;
|
|
882
|
-
const defaultWidth = Math.max(boxColWidth, this.widthMap[col._type], (col._name ? col._name.length * 14 : 36) + (col._type === "reference" ? 200 : 26));
|
|
883
|
-
const width = col._width || defaultWidth;
|
|
884
|
-
|
|
885
|
-
const selfStyle = col.colType === "tree"
|
|
886
|
-
? {
|
|
887
|
-
textAlign: col._align || "left",
|
|
888
|
-
fontSize: "14px"
|
|
889
|
-
}
|
|
890
|
-
: col.colType === "summary"
|
|
891
|
-
? {
|
|
892
|
-
// backgroundColor: "#eeeeee",
|
|
893
|
-
textAlign: col._align || "right"
|
|
894
|
-
}
|
|
895
|
-
: {
|
|
896
|
-
textAlign: col._align || "left"
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
return {
|
|
900
|
-
width: `${width}px`,
|
|
901
|
-
minWidth: `${width}px`,
|
|
902
|
-
maxWidth: `${width}px`,
|
|
903
|
-
paddingTop: position === "th" && !this.headHeightAuto ? "10px" : undefined,
|
|
904
|
-
paddingBottom: position === "th" && !this.headHeightAuto ? "10px" : undefined,
|
|
905
|
-
"word-break": "break-all",
|
|
906
|
-
cursor: "pointer",
|
|
907
|
-
...selfStyle
|
|
908
|
-
};
|
|
909
|
-
},
|
|
910
|
-
getTdStyle (col, row) {
|
|
911
|
-
return {
|
|
912
|
-
...this.getThStyle(col),
|
|
913
|
-
backgroundColor: row ? "" : "#fff"
|
|
914
|
-
};
|
|
915
|
-
},
|
|
916
|
-
getTdRowSpan (col, row) {
|
|
917
|
-
return row.total || 1;
|
|
918
|
-
},
|
|
919
|
-
getTdColSpan (col, row) {
|
|
920
|
-
return 1;
|
|
921
|
-
},
|
|
922
|
-
getThRender (col) {
|
|
923
|
-
return (h) => this.$getHeadRender(h, col, {
|
|
924
|
-
showRequired: this.showRequired,
|
|
925
|
-
showDescription: this.showDescription,
|
|
926
|
-
headHeightAuto: this.headHeightAuto
|
|
927
|
-
});
|
|
928
|
-
},
|
|
929
|
-
getTdRender (col, row, rowIndex) {
|
|
930
|
-
return (h) => {
|
|
931
|
-
row = row[col.nodeKey];
|
|
932
|
-
|
|
933
|
-
return h(
|
|
934
|
-
"td",
|
|
935
|
-
{
|
|
936
|
-
class: this.tablePropsObj.cellStyleOption.bodyCellClass({ column: col, row, rowIndex }),
|
|
937
|
-
style: this.getTdStyle(col, row)
|
|
938
|
-
},
|
|
939
|
-
col ? col.renderBodyCell({ column: col, row, rowIndex }, h) : undefined
|
|
940
|
-
);
|
|
941
|
-
};
|
|
942
|
-
},
|
|
943
|
-
getSummaryVal (col, row) {
|
|
944
|
-
if (col._calField && col._operator) {
|
|
945
|
-
const calFieldFormItem = this.columns.find(item => item._key === col._calField);
|
|
946
|
-
|
|
947
|
-
if (calFieldFormItem) {
|
|
948
|
-
let loop = (nodes, arr) => {
|
|
949
|
-
return nodes.reduce((arr, node) => {
|
|
950
|
-
if (node.children.length) {
|
|
951
|
-
return loop(node.children, arr);
|
|
952
|
-
} else {
|
|
953
|
-
arr.push(node[col._calField] || 0);
|
|
954
|
-
return arr;
|
|
955
|
-
}
|
|
956
|
-
}, arr);
|
|
957
|
-
};
|
|
958
|
-
let list = loop(row.children, []);
|
|
959
|
-
|
|
960
|
-
return this.$calNumList(list, col._operator, calFieldFormItem);
|
|
961
|
-
} else {
|
|
962
|
-
return `来源列${col._calField}被删除`;
|
|
963
|
-
}
|
|
964
|
-
} else {
|
|
965
|
-
return !col._calField && !col._operator
|
|
966
|
-
? "未选择来源列和算法"
|
|
967
|
-
: !col._calField
|
|
968
|
-
? "未选择来源列"
|
|
969
|
-
: "未选择算法";
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
getTreeThBtns (col) {
|
|
973
|
-
return [
|
|
974
|
-
"createCol",
|
|
975
|
-
...(
|
|
976
|
-
col.level > 1 && col.canDelete === true
|
|
977
|
-
? ["deleteCol"]
|
|
978
|
-
: []
|
|
979
|
-
)
|
|
980
|
-
];
|
|
981
|
-
},
|
|
982
|
-
// 获得节点的 操作下拉列表
|
|
983
|
-
getTreeTdBtns (col, row, nodeData) {
|
|
984
|
-
return nodeData.children.length === 0
|
|
985
|
-
? ["createBrotherNode", "deleteSelfAndChildNodes", "clearNode"]
|
|
986
|
-
: ["createBrotherNode", "createChildNode", "deleteSelfAndChildNodes", "deleteChildNodes", "clearNode", "clearChildNodes"];
|
|
987
|
-
},
|
|
988
|
-
// 回车换行
|
|
989
|
-
enterText (val) {
|
|
990
|
-
let reg = new RegExp(/\n/g);
|
|
991
|
-
return val.replace(reg, "<br/>");
|
|
992
|
-
}
|
|
993
|
-
}
|
|
84
|
+
computed: {},
|
|
85
|
+
created () {},
|
|
86
|
+
methods: {}
|
|
994
87
|
};
|
|
995
88
|
</script>
|
|
996
89
|
|