Skip to content

Commit 12e51a1

Browse files
fix: table stripe and adding height endless
1 parent 11e7cce commit 12e51a1

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/left-columns/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
& > .@{prefixCls}-row {
2929
display: flex;
3030
width: 100%;
31+
32+
&.stripe {
33+
background-color: #efefef;
34+
}
3135
}
3236

3337
& > .@{prefixCls}-header {

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/left-columns/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function LeftFixedColumnsInner<
6969
let maxCellHeight = 0;
7070
for (const element of (rowRef.current?.children || []) as HTMLDivElement[]) {
7171
if (element.children[0]) {
72-
const trueCellHeight = (element.children[0] as HTMLDivElement).offsetHeight;
72+
const trueCellHeight = (element.children[0] as HTMLDivElement).offsetHeight + 28;
7373
if (trueCellHeight > maxCellHeight) {
7474
maxCellHeight = trueCellHeight;
7575
}
@@ -82,7 +82,9 @@ function LeftFixedColumnsInner<
8282
const start = props.tableConfig.configs.showHeader ? 1 : 0;
8383
const subTableHeights: number[] = [];
8484
for (let i = start; i < rows.length; i++) {
85-
if (rows[i].className === 'jfe-drip-table-generator-workstation-table-row') {
85+
if (rows[i].className === 'jfe-drip-table-generator-workstation-table-row'
86+
|| rows[i].className === 'jfe-drip-table-generator-workstation-table-row stripe'
87+
) {
8688
if (rows[i + 1]?.className === 'subtable') {
8789
subTableHeights.push(rows[i + 1].offsetHeight);
8890
} else {
@@ -162,8 +164,13 @@ function LeftFixedColumnsInner<
162164
{props.tableConfig.configs.rowHeader && (
163165
<div style={{ width: '100%', height: props.rowHeaderHeights?.[rowIndex] || 0 }} />
164166
)}
165-
<div className="jfe-drip-table-generator-workstation-table-row" ref={rowRef} style={{ height: props.rowHeight }}>
166-
167+
<div
168+
className={classNames('jfe-drip-table-generator-workstation-table-row', {
169+
stripe: props.tableConfig.configs.stripe && rowIndex % 2 === 1,
170+
})}
171+
ref={rowRef}
172+
style={{ height: props.rowHeight }}
173+
>
167174
{props.tableConfig.hasSubTable && (
168175
<div
169176
className={classNames('jfe-drip-table-generator-workstation-table-tr-td operation-col', {

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/right-columns/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
& > .@{prefixCls}-row {
2929
display: flex;
3030
width: 100%;
31+
32+
&.stripe {
33+
background-color: #efefef;
34+
}
3135
}
3236

3337
& > .@{prefixCls}-header {

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/right-columns/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function RightFixedColumnsInner<
4848
let maxCellHeight = 0;
4949
for (const element of (rowRef.current?.children || []) as HTMLDivElement[]) {
5050
if (element.children[0]) {
51-
const trueCellHeight = (element.children[0] as HTMLDivElement).offsetHeight;
51+
const trueCellHeight = (element.children[0] as HTMLDivElement).offsetHeight + 28;
5252
if (trueCellHeight > maxCellHeight) {
5353
maxCellHeight = trueCellHeight;
5454
}
@@ -91,7 +91,13 @@ function RightFixedColumnsInner<
9191
{props.tableConfig.configs.rowHeader && (
9292
<div style={{ width: '100%', height: props.rowHeaderHeights?.[rowIndex] || 0 }} />
9393
)}
94-
<div className="jfe-drip-table-generator-workstation-table-row" ref={rowRef} style={{ height: props.rowHeight }}>
94+
<div
95+
className={classNames('jfe-drip-table-generator-workstation-table-row', {
96+
stripe: props.tableConfig.configs.stripe && rowIndex % 2 === 1,
97+
})}
98+
ref={rowRef}
99+
style={{ height: props.rowHeight }}
100+
>
95101
<TableSection
96102
{...props}
97103
record={record}

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/scroll-columns/index.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
& > .@{prefixCls}-row {
1919
display: flex;
2020
width: 100%;
21+
22+
&.stripe {
23+
background-color: #efefef;
24+
}
2125
}
2226

2327
& > .@{prefixCls}-header {

packages/drip-table-generator/src/layouts/table-workstation/editable-table/components/scroll-columns/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function ScrollableColumnsInner<
6363
const start = props.tableConfig.configs.showHeader ? 1 : 0;
6464
const rowHeaderHeights: number[] = [];
6565
for (let i = start; i < rows.length; i++) {
66-
if (rows[i].className === 'jfe-drip-table-generator-workstation-table-row') {
66+
if (rows[i].className === 'jfe-drip-table-generator-workstation-table-row'
67+
|| rows[i].className === 'jfe-drip-table-generator-workstation-table-row stripe'
68+
) {
6769
if (rows[i - 1]?.className === 'rowHeader') {
6870
rowHeaderHeights.push(rows[i - 1].offsetHeight);
6971
} else {
@@ -109,7 +111,13 @@ function ScrollableColumnsInner<
109111
configs={props.tableConfig.configs.rowHeader}
110112
/>
111113
)}
112-
<div className="jfe-drip-table-generator-workstation-table-row" ref={rowRef} style={{ height: props.rowHeight }}>
114+
<div
115+
className={classNames('jfe-drip-table-generator-workstation-table-row', {
116+
stripe: props.tableConfig.configs.stripe && rowIndex % 2 === 1,
117+
})}
118+
ref={rowRef}
119+
style={{ height: props.rowHeight }}
120+
>
113121
<TableSection
114122
{...props}
115123
record={record}

0 commit comments

Comments
 (0)