diff --git a/components/apolloTable/component/Cell.less b/components/apolloTable/component/Cell.less
index 83aead2eeec4ffc38f6abbb718b79908ab4938b6..201acac65dc04c8c108ecebd1ab9bcd09487c04c 100644
--- a/components/apolloTable/component/Cell.less
+++ b/components/apolloTable/component/Cell.less
@@ -10,27 +10,25 @@
height: 100%;
font-size: @textFontGen;
padding: 0 @paddingLg;
- &.hover {
- background: @tableHoverBgColor;
- .checkbox {
- display: block;
- &.hasNum {
- display: block;
- }
- }
- .num {
- display: block;
- &.hasCheckbox {
- display: none;
- }
- }
- .expand {
- visibility: visible;
- }
- }
- &.selected {
- box-shadow: inset 0 0 0 1px @primaryColor;
- }
+ //&.hover {
+ // background: @tableHoverBgColor;
+ // .checkbox {
+ // display: block;
+ // &.hasNum {
+ // display: block;
+ // }
+ // }
+ // .num {
+ // display: block;
+ // &.hasCheckbox {
+ // display: none;
+ // }
+ // }
+ // .expand {
+ // visibility: visible;
+ // }
+ //}
+
.num {
min-width: 30px;
max-width: 100px;
@@ -38,7 +36,7 @@
.icon {
width: 22px;
}
- &.checked{
+ &.checked {
display: none;
}
}
@@ -49,7 +47,7 @@
&.hasNum {
display: none;
}
- &.checked{
+ &.checked {
display: block;
}
}
@@ -94,3 +92,26 @@
background: #333333;
}
}
+&.selected {
+ box-shadow: inset 0 0 0 1px @primaryColor;
+}
+&.hover {
+ background: @tableHoverBgColor;
+ .detailCell {
+ .checkbox {
+ display: block;
+ &.hasNum {
+ display: block;
+ }
+ }
+ .num {
+ display: block;
+ &.hasCheckbox {
+ display: none;
+ }
+ }
+ .expand {
+ visibility: visible;
+ }
+ }
+}
diff --git a/components/apolloTable/component/Cell.tsx b/components/apolloTable/component/Cell.tsx
index c485a7eb031296418220ef0a74fde05174981c7d..dac0dd87d0e4a40d69e48a4e378aa959bbd7aa57 100644
--- a/components/apolloTable/component/Cell.tsx
+++ b/components/apolloTable/component/Cell.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useMemo, useState } from 'react';
+import React, { useEffect, useMemo, useState, useRef } from 'react';
import { Checkbox, message, Popover } from 'antd';
import classNames from 'classnames';
import _ from 'lodash';
@@ -33,10 +33,6 @@ const Cell = (props: CellProps) => {
rowSelection,
columns,
contentMenu,
- selectedCell,
- cellKey,
- changeSelectedCell,
- position = 'center',
} = props;
const {
columnType,
@@ -47,6 +43,7 @@ const Cell = (props: CellProps) => {
cellRenderProps,
readOnlyFlag,
} = columnConfig;
+ const cellUnit = useRef(null);
const [status, setStatus] = useState('detail');
useEffect(() => {
@@ -119,6 +116,7 @@ const Cell = (props: CellProps) => {
};
const selfRenderDetailCell = () => {
+ // 数据为空
let empty =
!cellData || cellData.length === 0 || (cellData.length === 1 && !cellData[0].text && !cellData[0].value);
let detailConfig;
@@ -138,7 +136,7 @@ const Cell = (props: CellProps) => {
const style: any = {};
const { current = 1, pageSize = 20 } = paginationConfig || {};
-
+ // 构造序号
const getIndex = () => {
// if (current === 1) {
// let src = '';
@@ -159,6 +157,7 @@ const Cell = (props: CellProps) => {
// }
return (current - 1) * pageSize + rowIndex + 1;
};
+ // 获取当前行在所选列表中的index
const getCheckedIndex = () => {
if (!rowSelection) {
return -1;
@@ -171,6 +170,7 @@ const Cell = (props: CellProps) => {
});
return index;
};
+ // 构造行复选框
const getCheckbox = () => {
const { selectedRows, onChange } = rowSelection;
const index = getCheckedIndex();
@@ -190,25 +190,43 @@ const Cell = (props: CellProps) => {
};
const { dynamicCellConfigDTO } = columnData;
-
const detail = (
{
// 不可编辑状态
if (!cellEditable || readOnlyFlag || (dynamicCellConfigDTO && dynamicCellConfigDTO.readonlyFlag)) {
return false;
}
- if (selectedCell === `${position}_${cellKey}`) {
+ // 获取当前节点的选中状态
+ const dom = cellUnit.current;
+ let selected = false;
+ if (dom && dom.getAttribute('data-selectedCell')) {
+ selected = dom.getAttribute('data-selectedCell') === '1';
+ }
+ if (selected) {
+ // 当前已选中,则进入编辑状态
setStatus('edit');
+ if (dom) {
+ // 给当前dom添加编辑状态
+ dom.setAttribute('data-editingCell', '1');
+ }
} else {
- changeSelectedCell && changeSelectedCell(`${position}_${cellKey}`);
+ // 否则进入选中状态
+ if (dom) {
+ // 先清除所有dom的选中状态及样式
+ const doms = document.querySelectorAll('.cellUnit');
+ if (doms) {
+ doms.forEach((item) => {
+ item.setAttribute('data-selectedCell', '0');
+ item.classList.remove(s.selected);
+ });
+ }
+ // 给当前dom添加选中状态
+ dom.setAttribute('data-selectedCell', '1');
+ // 给当前dom添加选中样式
+ dom.classList.add(s.selected);
+ }
}
}}
style={style}
@@ -324,7 +342,16 @@ const Cell = (props: CellProps) => {
};
return (
-
+
{status === 'detail' && selfRenderDetailCell()}
{status === 'edit' && selfRenderEditCell()}
diff --git a/components/apolloTable/component/Table.less b/components/apolloTable/component/Table.less
index db68117c384d435e308b1f4a37bb27d859fa5059..15c9a9fa732b9eb68ad4fd61e207ad82dddfbbac 100644
--- a/components/apolloTable/component/Table.less
+++ b/components/apolloTable/component/Table.less
@@ -33,6 +33,7 @@
position: absolute;
right: 0;
z-index: 1;
+ overflow: hidden;
}
:global(.ReactVirtualized__Grid__innerScrollContainer) {
overflow: unset !important;
diff --git a/components/apolloTable/component/Table.tsx b/components/apolloTable/component/Table.tsx
index 48351db2b5db847dee38ae23a4c64261b2438ddb..1c5483ef52e4da562049d8f73a69cf8a333c8a37 100644
--- a/components/apolloTable/component/Table.tsx
+++ b/components/apolloTable/component/Table.tsx
@@ -615,16 +615,16 @@ export default class AirTable extends Component
{
})}
/>
) : (
- columnCount > 0 &&
- !loading && (
-
- )
- )}
+ columnCount > 0 &&
+ !loading && (
+
+ )
+ )}
}
@@ -677,6 +677,7 @@ export default class AirTable extends Component {
position: 'absolute',
right: 0,
top: headerHeight,
+ marginRight: -scrollbarWidth,
}}
>
{
columns: showColumns,
showColumns: rightColumns,
})}
+ onScroll={(...arg: Array