Commit c1616bc1 authored by zhangwenshuai's avatar zhangwenshuai

修改固定列逻辑,暂时隐藏右侧固定

parent f9986a79
......@@ -106,25 +106,31 @@ const DragFixed = (props: any) => {
let leftFixedWidth = 0;
const fixedCol: any = {};
const fixedColOrder: any = [];
// 计算获取固定列
for (let i = 0; i < showColumns.length; i++) {
leftFixedWidth += showColumns[i].width || columnWidth;
if (leftFixedWidth <= Number(fixedWidthNum)) {
fixedCol[showColumns[i].columnName] = 1;
fixedColOrder.push(showColumns[i].columnName);
// 固定列修改排序到最前面
fixedCol[showColumns[i].columnName] = {
...showColumns[i],
fixed: 'left',
orderNo: i + 1,
};
} else {
break;
}
}
const newColumns: any = [];
let newColumns: any = [];
fixedColOrder.map((temp:any) => {
newColumns.push(fixedCol[temp]);
});
// 新的列数组包含刚固定的列(排在最前面)和原来的所有列,需要将后面重复的列剔除
newColumns = newColumns.concat(columns);
// 为固定列增加fixed属性
columns.map((item: any) => {
if (fixedCol[item.columnName] === 1) {
item.fixed = 'left';
} else {
if (!!item.showStatus && item.fixed === 'left') {
item.fixed = '';
}
}
const updateCache = (item: any) => {
// 缓存
if (cachedFeAttr) {
const cachedCols = getCache({ tableId });
......@@ -132,19 +138,38 @@ const DragFixed = (props: any) => {
cachedCols[item.columnName] = {
...cachedCols[item.columnName],
fixed: item.fixed,
orderNo: item.orderNo,
};
saveCache({ tableId, data: cachedCols });
}
}
newColumns.push(item);
};
const sortedColumns: any = [];
newColumns.map((item: any, i: number) => {
if (i >= fixedColOrder.length) {
// 除了新增加的固定列,之前的固定列都还原为未固定
if (item.fixed === 'left') {
item.fixed = '';
}
// 剔除重复列
if (!fixedCol[item.columnName]) {
// 重新排序
item.orderNo = sortedColumns.length + 1;
updateCache(item);
sortedColumns.push(item);
}
} else {
updateCache(item);
sortedColumns.push(item);
}
});
// 业务回调
if (typeof onDragFixed === 'function') {
onDragFixed(newColumns);
onDragFixed(sortedColumns);
}
// table回调
if (typeof onResizeStop === 'function') {
onResizeStop(newColumns);
onResizeStop(sortedColumns);
}
};
......
......@@ -539,7 +539,7 @@ export default class AirTable extends Component<TableProps, TableState> {
tableWidth={tableWidth}
showColumns={showColumns}
columnWidth={columnWidth}
columns={columns}
columns={formatColumns}
onResizeStart={this.onResizeStartLeftDragFixed}
onResizeStop={this.onResizeStopLeftDragFixed}
onDragFixed={onDragFixed}
......@@ -637,7 +637,7 @@ export default class AirTable extends Component<TableProps, TableState> {
}}
</AutoSizer>
</div>
{canFixed && (
{false && (
<RightDragFixed
tableId={tableId}
initLeft={tableWidth - rightWidth}
......@@ -645,7 +645,7 @@ export default class AirTable extends Component<TableProps, TableState> {
tableWidth={tableWidth}
showColumns={showColumns}
columnWidth={columnWidth}
columns={columns}
columns={formatColumns}
paddingRight={paddingRight}
onResizeStart={this.onResizeStartRightDragFixed}
onResizeStop={this.onResizeStopRightDragFixed}
......
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