diff --git a/components/apolloTable/component/DragFixed.less b/components/apolloTable/component/DragFixed.less index 5e5fc66e40ea0e230da79c74abb54b7a3d6d581a..e0ded1dc225f0c2dde5e19a73bfa0ccb6c7f8804 100644 --- a/components/apolloTable/component/DragFixed.less +++ b/components/apolloTable/component/DragFixed.less @@ -6,6 +6,7 @@ width: 2px; z-index: 4; background: transparent; + user-select: none; &.hovered { background: #aaa; } diff --git a/components/apolloTable/component/DragFixed.tsx b/components/apolloTable/component/DragFixed.tsx index 6a82e9001582996f27ee28b9beb4e8f862246972..e5c7f2ff742bb0e89b27ed089d620da2f602d24c 100644 --- a/components/apolloTable/component/DragFixed.tsx +++ b/components/apolloTable/component/DragFixed.tsx @@ -157,6 +157,8 @@ const DragFixed = (props: any) => { onMouseLeave={onMouseLeaveWrap} > { const { @@ -14,8 +14,9 @@ const DragSorted = (props: any) => { onDragSorted, columns, cachedFeAttr, + position, } = props; - if (!canSorted) { + if (!canSorted || position === 'left' || position === 'right') { return
{props.children}
; } // 长按计时器 @@ -241,7 +242,7 @@ const DragSorted = (props: any) => { return (
{ onMouseLeave={onMouseLeaveWrap} > { cachedFeAttr={cachedFeAttr} tableId={tableId} columns={formatColumns} + position={position} > { height={headerHeight} cellRenderer={this.renderHeaderCell.bind(this, { showColumns: leftColumns, + position: 'left', })} />
@@ -572,6 +574,7 @@ export default class AirTable extends Component { scrollLeft={scrollLeft} cellRenderer={this.renderHeaderCell.bind(this, { showColumns, + position: 'center', })} /> diff --git a/components/apolloTable/utils/memCols.ts b/components/apolloTable/utils/memCols.ts index bdb3279dee7fce243da69baa819c5ae906cd942f..0fa4cd30cb24c422d2a700d79eb965ad055510ae 100644 --- a/components/apolloTable/utils/memCols.ts +++ b/components/apolloTable/utils/memCols.ts @@ -70,18 +70,30 @@ export const getLeftWidth = ( // 格式化列数据(添加缓存的前端属性) export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean, tableId: number | string) => { if (cachedFeAttr) { - const cachedCols = getCache({ tableId }); + let shouldSave = false; + let cachedCols = getCache({ tableId }); if (cachedCols) { columns = columns.map((item: any) => { + if (!cachedCols[item.columnName]) { + shouldSave = true; + cachedCols[item.columnName] = { + columnName: item.columnName, + width: item.width, + align: item.align, + fixed: item.fixed, + hideScope: item.hideScope, + orderNo: item.orderNo, + }; + } return { ...item, ...cachedCols[item.columnName], }; }); } else { - const data: any = {}; + cachedCols = {}; columns.map((item: any) => { - data[item.columnName] = { + cachedCols[item.columnName] = { columnName: item.columnName, width: item.width, align: item.align, @@ -91,9 +103,12 @@ export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean, }; }); if (columns.length > 0) { - saveCache({ tableId, data }); + shouldSave = true; } } + if (shouldSave) { + saveCache({ tableId, data: cachedCols }); + } } columns.sort((a, b) => { return a.orderNo - b.orderNo;