Commit 4d970a83 authored by zhangwenshuai's avatar zhangwenshuai

update

parent a57bc415
......@@ -6,6 +6,7 @@
width: 2px;
z-index: 4;
background: transparent;
user-select: none;
&.hovered {
background: #aaa;
}
......
......@@ -157,6 +157,8 @@ const DragFixed = (props: any) => {
onMouseLeave={onMouseLeaveWrap}
>
<ResizableBox
width={2}
height={1}
handle={
<span
id="leftFixedHandle"
......
......@@ -3,4 +3,7 @@
.sortedWrap {
width: 100%;
height: 100%;
&.sortedAble {
cursor: grab;
}
}
import React, { useCallback, useRef } from 'react';
import classNames from 'classnames';
import s from './DragSorted.less';
import { getCache, saveCache } from '@/submodule/components/apolloTable/utils/cache';
import { getCache, saveCache } from '../utils/cache';
const DragSorted = (props: any) => {
const {
......@@ -14,8 +14,9 @@ const DragSorted = (props: any) => {
onDragSorted,
columns,
cachedFeAttr,
position,
} = props;
if (!canSorted) {
if (!canSorted || position === 'left' || position === 'right') {
return <div className={s.sortedWrap}>{props.children}</div>;
}
// 长按计时器
......@@ -241,7 +242,7 @@ const DragSorted = (props: any) => {
return (
<div
className={classNames('draggableColumn', s.sortedWrap)}
className={classNames('draggableColumn', s.sortedWrap, s.sortedAble)}
onMouseDown={onMouseDown}
onMouseUp={onMouseUp}
data-column-name={columnName}
......
......@@ -163,6 +163,8 @@ const DragFixed = (props: any) => {
onMouseLeave={onMouseLeaveWrap}
>
<ResizableBox
width={2}
height={1}
handle={
<span
id="rightFixedHandle"
......
......@@ -281,6 +281,7 @@ export default class AirTable extends Component<TableProps, TableState> {
cachedFeAttr={cachedFeAttr}
tableId={tableId}
columns={formatColumns}
position={position}
>
<Column
columnType={String(columnType)}
......@@ -482,6 +483,7 @@ export default class AirTable extends Component<TableProps, TableState> {
height={headerHeight}
cellRenderer={this.renderHeaderCell.bind(this, {
showColumns: leftColumns,
position: 'left',
})}
/>
</div>
......@@ -572,6 +574,7 @@ export default class AirTable extends Component<TableProps, TableState> {
scrollLeft={scrollLeft}
cellRenderer={this.renderHeaderCell.bind(this, {
showColumns,
position: 'center',
})}
/>
</div>
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment