From 4d970a832ce6a11907a38a91cb492f7611c59adb Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Fri, 7 Aug 2020 18:23:04 +0800 Subject: [PATCH] update --- .../apolloTable/component/DragFixed.less | 1 + .../apolloTable/component/DragFixed.tsx | 2 ++ .../apolloTable/component/DragSorted.less | 3 +++ .../apolloTable/component/DragSorted.tsx | 7 +++--- .../apolloTable/component/RightDragFixed.tsx | 2 ++ components/apolloTable/component/Table.tsx | 3 +++ components/apolloTable/utils/memCols.ts | 23 +++++++++++++++---- 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/components/apolloTable/component/DragFixed.less b/components/apolloTable/component/DragFixed.less index 5e5fc66..e0ded1d 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 6a82e90..e5c7f2f 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 bdb3279..0fa4cd3 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; -- 2.21.0