Commit 4d970a83 authored by zhangwenshuai's avatar zhangwenshuai

update

parent a57bc415
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
width: 2px; width: 2px;
z-index: 4; z-index: 4;
background: transparent; background: transparent;
user-select: none;
&.hovered { &.hovered {
background: #aaa; background: #aaa;
} }
......
...@@ -157,6 +157,8 @@ const DragFixed = (props: any) => { ...@@ -157,6 +157,8 @@ const DragFixed = (props: any) => {
onMouseLeave={onMouseLeaveWrap} onMouseLeave={onMouseLeaveWrap}
> >
<ResizableBox <ResizableBox
width={2}
height={1}
handle={ handle={
<span <span
id="leftFixedHandle" id="leftFixedHandle"
......
...@@ -3,4 +3,7 @@ ...@@ -3,4 +3,7 @@
.sortedWrap { .sortedWrap {
width: 100%; width: 100%;
height: 100%; height: 100%;
&.sortedAble {
cursor: grab;
}
} }
import React, { useCallback, useRef } from 'react'; import React, { useCallback, useRef } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import s from './DragSorted.less'; 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 DragSorted = (props: any) => {
const { const {
...@@ -14,8 +14,9 @@ const DragSorted = (props: any) => { ...@@ -14,8 +14,9 @@ const DragSorted = (props: any) => {
onDragSorted, onDragSorted,
columns, columns,
cachedFeAttr, cachedFeAttr,
position,
} = props; } = props;
if (!canSorted) { if (!canSorted || position === 'left' || position === 'right') {
return <div className={s.sortedWrap}>{props.children}</div>; return <div className={s.sortedWrap}>{props.children}</div>;
} }
// 长按计时器 // 长按计时器
...@@ -241,7 +242,7 @@ const DragSorted = (props: any) => { ...@@ -241,7 +242,7 @@ const DragSorted = (props: any) => {
return ( return (
<div <div
className={classNames('draggableColumn', s.sortedWrap)} className={classNames('draggableColumn', s.sortedWrap, s.sortedAble)}
onMouseDown={onMouseDown} onMouseDown={onMouseDown}
onMouseUp={onMouseUp} onMouseUp={onMouseUp}
data-column-name={columnName} data-column-name={columnName}
......
...@@ -163,6 +163,8 @@ const DragFixed = (props: any) => { ...@@ -163,6 +163,8 @@ const DragFixed = (props: any) => {
onMouseLeave={onMouseLeaveWrap} onMouseLeave={onMouseLeaveWrap}
> >
<ResizableBox <ResizableBox
width={2}
height={1}
handle={ handle={
<span <span
id="rightFixedHandle" id="rightFixedHandle"
......
...@@ -281,6 +281,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -281,6 +281,7 @@ export default class AirTable extends Component<TableProps, TableState> {
cachedFeAttr={cachedFeAttr} cachedFeAttr={cachedFeAttr}
tableId={tableId} tableId={tableId}
columns={formatColumns} columns={formatColumns}
position={position}
> >
<Column <Column
columnType={String(columnType)} columnType={String(columnType)}
...@@ -482,6 +483,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -482,6 +483,7 @@ export default class AirTable extends Component<TableProps, TableState> {
height={headerHeight} height={headerHeight}
cellRenderer={this.renderHeaderCell.bind(this, { cellRenderer={this.renderHeaderCell.bind(this, {
showColumns: leftColumns, showColumns: leftColumns,
position: 'left',
})} })}
/> />
</div> </div>
...@@ -572,6 +574,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -572,6 +574,7 @@ export default class AirTable extends Component<TableProps, TableState> {
scrollLeft={scrollLeft} scrollLeft={scrollLeft}
cellRenderer={this.renderHeaderCell.bind(this, { cellRenderer={this.renderHeaderCell.bind(this, {
showColumns, showColumns,
position: 'center',
})} })}
/> />
</div> </div>
......
...@@ -70,18 +70,30 @@ export const getLeftWidth = ( ...@@ -70,18 +70,30 @@ export const getLeftWidth = (
// 格式化列数据(添加缓存的前端属性) // 格式化列数据(添加缓存的前端属性)
export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean, tableId: number | string) => { export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean, tableId: number | string) => {
if (cachedFeAttr) { if (cachedFeAttr) {
const cachedCols = getCache({ tableId }); let shouldSave = false;
let cachedCols = getCache({ tableId });
if (cachedCols) { if (cachedCols) {
columns = columns.map((item: any) => { 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 { return {
...item, ...item,
...cachedCols[item.columnName], ...cachedCols[item.columnName],
}; };
}); });
} else { } else {
const data: any = {}; cachedCols = {};
columns.map((item: any) => { columns.map((item: any) => {
data[item.columnName] = { cachedCols[item.columnName] = {
columnName: item.columnName, columnName: item.columnName,
width: item.width, width: item.width,
align: item.align, align: item.align,
...@@ -91,9 +103,12 @@ export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean, ...@@ -91,9 +103,12 @@ export const getFormatColumns = (columns: ColumnProps[], cachedFeAttr: boolean,
}; };
}); });
if (columns.length > 0) { if (columns.length > 0) {
saveCache({ tableId, data }); shouldSave = true;
} }
} }
if (shouldSave) {
saveCache({ tableId, data: cachedCols });
}
} }
columns.sort((a, b) => { columns.sort((a, b) => {
return a.orderNo - b.orderNo; 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