lambo-design-bi 0.0.243 → 0.0.244
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div style="width: 100%">
|
|
3
3
|
<LamboPagingTableBi ref="table" :auto-search="false" :columns="columns" :dataUrl="widget.options.url"
|
|
4
|
-
:border="tableBorder" :show-table-option="true" :exportName="widget.name"
|
|
4
|
+
:border="tableBorder" :stripe="tableStripe" :show-table-option="true" :exportName="widget.name"
|
|
5
5
|
:height="tableHeight" :page-disable="widget.options.isPaging === '0'" :page-size="widget.options.pageSize"
|
|
6
6
|
:export-request-limit="200" :isSingleSelectModel="true" :showSummary="widget.options.isAllSum === '1'"
|
|
7
|
-
:summary-method="handleSummary" :highlightRow="isRowClick" @on-current-change="onCurrentChange"
|
|
7
|
+
:summary-method="handleSummary" :span-method="tableSpanMethod" :highlightRow="isRowClick" @on-current-change="onCurrentChange"
|
|
8
8
|
@on-data-load="onDataLoad" :searchParams="tableSearchParams" :show-right-context-menu="hasRightContextMenu">
|
|
9
9
|
<div slot="search"></div>
|
|
10
10
|
</LamboPagingTableBi>
|
|
@@ -57,7 +57,8 @@ export default {
|
|
|
57
57
|
previewFileName: '',
|
|
58
58
|
boxShow: false,
|
|
59
59
|
modelWidth: '78%',
|
|
60
|
-
tableBorder: true
|
|
60
|
+
tableBorder: true,
|
|
61
|
+
spanMap: {}
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
methods: {
|
|
@@ -82,6 +83,7 @@ export default {
|
|
|
82
83
|
onDataLoad(dataRes) {
|
|
83
84
|
console.log("onDataLoad dataRes:", dataRes)
|
|
84
85
|
const rows = dataRes && dataRes.data && dataRes.data.rows
|
|
86
|
+
this.rebuildSpanMap(rows)
|
|
85
87
|
if (this.isRowClick && rows && rows.length > 0) {
|
|
86
88
|
this.$nextTick(() => {
|
|
87
89
|
// 为了排到同一轮事件循环的后面,让 View UI 内部的 setTimeout 0 先跑完,不是为了延后时间多久
|
|
@@ -530,6 +532,71 @@ export default {
|
|
|
530
532
|
this.tableBorder = false
|
|
531
533
|
}
|
|
532
534
|
}
|
|
535
|
+
},
|
|
536
|
+
isSpanColumn(column) {
|
|
537
|
+
return column && (column.isSpan === true || column.isSpan === '1' || column.isSpan === 'true')
|
|
538
|
+
},
|
|
539
|
+
getSpanColumnKeys() {
|
|
540
|
+
const columns = this.columns || []
|
|
541
|
+
const keys = []
|
|
542
|
+
columns.forEach(column => {
|
|
543
|
+
if (this.isSpanColumn(column) && column.key) {
|
|
544
|
+
keys.push(column.key)
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
return keys
|
|
548
|
+
},
|
|
549
|
+
// 根据当前数据行重新计算每个合并列的合并跨度
|
|
550
|
+
// 结构:spanMap[colKey][rowIndex] = rowspan(0 表示该单元格被上一行合并掉)
|
|
551
|
+
rebuildSpanMap(rows) {
|
|
552
|
+
const dataRows = Array.isArray(rows) ? rows : []
|
|
553
|
+
const spanKeys = this.getSpanColumnKeys()
|
|
554
|
+
if (!spanKeys.length || !dataRows.length) {
|
|
555
|
+
this.spanMap = {}
|
|
556
|
+
return
|
|
557
|
+
}
|
|
558
|
+
const spanMap = {}
|
|
559
|
+
spanKeys.forEach(colKey => {
|
|
560
|
+
const colSpan = new Array(dataRows.length).fill(1)
|
|
561
|
+
let groupStart = 0
|
|
562
|
+
for (let i = 1; i < dataRows.length; i++) {
|
|
563
|
+
const prevValue = dataRows[groupStart] ? dataRows[groupStart][colKey] : undefined
|
|
564
|
+
const currValue = dataRows[i] ? dataRows[i][colKey] : undefined
|
|
565
|
+
if (this.isSameSpanValue(prevValue, currValue)) {
|
|
566
|
+
colSpan[groupStart] += 1
|
|
567
|
+
colSpan[i] = 0
|
|
568
|
+
} else {
|
|
569
|
+
groupStart = i
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
spanMap[colKey] = colSpan
|
|
573
|
+
})
|
|
574
|
+
this.spanMap = spanMap
|
|
575
|
+
},
|
|
576
|
+
isSameSpanValue(a, b) {
|
|
577
|
+
// 空值(null/undefined/空字符串)不参与合并,避免把缺失值错误地合并在一起
|
|
578
|
+
if (a === null || a === undefined || a === '') {
|
|
579
|
+
return false
|
|
580
|
+
}
|
|
581
|
+
if (b === null || b === undefined || b === '') {
|
|
582
|
+
return false
|
|
583
|
+
}
|
|
584
|
+
return a === b
|
|
585
|
+
},
|
|
586
|
+
tableSpanMethod({ column, rowIndex }) {
|
|
587
|
+
const colKey = column && column.key
|
|
588
|
+
if (!colKey) {
|
|
589
|
+
return [1, 1]
|
|
590
|
+
}
|
|
591
|
+
const colSpan = this.spanMap[colKey]
|
|
592
|
+
if (!colSpan) {
|
|
593
|
+
return [1, 1]
|
|
594
|
+
}
|
|
595
|
+
const rowspan = colSpan[rowIndex]
|
|
596
|
+
if (rowspan === 0) {
|
|
597
|
+
return [0, 0]
|
|
598
|
+
}
|
|
599
|
+
return [rowspan || 1, 1]
|
|
533
600
|
}
|
|
534
601
|
},
|
|
535
602
|
created() {
|
|
@@ -543,6 +610,14 @@ export default {
|
|
|
543
610
|
isRowClick() {
|
|
544
611
|
return this.widget.options.isRowClick === 1 || this.widget.options.isRowClick === '1'
|
|
545
612
|
},
|
|
613
|
+
hasSpanColumn() {
|
|
614
|
+
// 列配置中存在 isSpan 列则启用单元格合并
|
|
615
|
+
return (this.columns || []).some(column => this.isSpanColumn(column))
|
|
616
|
+
},
|
|
617
|
+
tableStripe() {
|
|
618
|
+
// 出现合并列时关闭斑马,避免合并块与 stripe 视觉冲突;普通表格保留原生斑马
|
|
619
|
+
return !this.hasSpanColumn
|
|
620
|
+
},
|
|
546
621
|
tableHeight() {
|
|
547
622
|
const tableHeight = this.widget && this.widget.options ? this.widget.options.tableHeight : ''
|
|
548
623
|
if (tableHeight === null || tableHeight === undefined) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<div class="ivu-number-info-title-lambo title-div" :class="{ 'isDrill': isDrill }" v-if="title" @click="drill">
|
|
5
5
|
<slot name="title">{{ title }}</slot>
|
|
6
6
|
<div class="cd-right-top">
|
|
7
|
-
<!-- <Icon type="ios-arrow-round-forward" /> -->
|
|
8
7
|
<Icon v-if="isDrill" type="ios-arrow-round-forward" />
|
|
9
8
|
|
|
10
9
|
<img class="badge-img" v-if="evaLevel == 'high'"
|