Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
submodule
Commits
c1616bc1
Commit
c1616bc1
authored
Dec 17, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改固定列逻辑,暂时隐藏右侧固定
parent
f9986a79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
16 deletions
+41
-16
DragFixed.tsx
components/apolloTable/component/DragFixed.tsx
+38
-13
Table.tsx
components/apolloTable/component/Table.tsx
+3
-3
No files found.
components/apolloTable/component/DragFixed.tsx
View file @
c1616bc1
...
@@ -106,25 +106,31 @@ const DragFixed = (props: any) => {
...
@@ -106,25 +106,31 @@ const DragFixed = (props: any) => {
let
leftFixedWidth
=
0
;
let
leftFixedWidth
=
0
;
const
fixedCol
:
any
=
{};
const
fixedCol
:
any
=
{};
const
fixedColOrder
:
any
=
[];
// 计算获取固定列
// 计算获取固定列
for
(
let
i
=
0
;
i
<
showColumns
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
showColumns
.
length
;
i
++
)
{
leftFixedWidth
+=
showColumns
[
i
].
width
||
columnWidth
;
leftFixedWidth
+=
showColumns
[
i
].
width
||
columnWidth
;
if
(
leftFixedWidth
<=
Number
(
fixedWidthNum
))
{
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
{
}
else
{
break
;
break
;
}
}
}
}
const
newColumns
:
any
=
[];
let
newColumns
:
any
=
[];
fixedColOrder
.
map
((
temp
:
any
)
=>
{
newColumns
.
push
(
fixedCol
[
temp
]);
});
// 新的列数组包含刚固定的列(排在最前面)和原来的所有列,需要将后面重复的列剔除
newColumns
=
newColumns
.
concat
(
columns
);
// 为固定列增加fixed属性
// 为固定列增加fixed属性
columns
.
map
((
item
:
any
)
=>
{
const
updateCache
=
(
item
:
any
)
=>
{
if
(
fixedCol
[
item
.
columnName
]
===
1
)
{
item
.
fixed
=
'left'
;
}
else
{
if
(
!!
item
.
showStatus
&&
item
.
fixed
===
'left'
)
{
item
.
fixed
=
''
;
}
}
// 缓存
// 缓存
if
(
cachedFeAttr
)
{
if
(
cachedFeAttr
)
{
const
cachedCols
=
getCache
({
tableId
});
const
cachedCols
=
getCache
({
tableId
});
...
@@ -132,19 +138,38 @@ const DragFixed = (props: any) => {
...
@@ -132,19 +138,38 @@ const DragFixed = (props: any) => {
cachedCols
[
item
.
columnName
]
=
{
cachedCols
[
item
.
columnName
]
=
{
...
cachedCols
[
item
.
columnName
],
...
cachedCols
[
item
.
columnName
],
fixed
:
item
.
fixed
,
fixed
:
item
.
fixed
,
orderNo
:
item
.
orderNo
,
};
};
saveCache
({
tableId
,
data
:
cachedCols
});
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'
)
{
if
(
typeof
onDragFixed
===
'function'
)
{
onDragFixed
(
new
Columns
);
onDragFixed
(
sorted
Columns
);
}
}
// table回调
// table回调
if
(
typeof
onResizeStop
===
'function'
)
{
if
(
typeof
onResizeStop
===
'function'
)
{
onResizeStop
(
new
Columns
);
onResizeStop
(
sorted
Columns
);
}
}
};
};
...
...
components/apolloTable/component/Table.tsx
View file @
c1616bc1
...
@@ -539,7 +539,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -539,7 +539,7 @@ export default class AirTable extends Component<TableProps, TableState> {
tableWidth=
{
tableWidth
}
tableWidth=
{
tableWidth
}
showColumns=
{
showColumns
}
showColumns=
{
showColumns
}
columnWidth=
{
columnWidth
}
columnWidth=
{
columnWidth
}
columns=
{
c
olumns
}
columns=
{
formatC
olumns
}
onResizeStart=
{
this
.
onResizeStartLeftDragFixed
}
onResizeStart=
{
this
.
onResizeStartLeftDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
onResizeStop=
{
this
.
onResizeStopLeftDragFixed
}
onDragFixed=
{
onDragFixed
}
onDragFixed=
{
onDragFixed
}
...
@@ -637,7 +637,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -637,7 +637,7 @@ export default class AirTable extends Component<TableProps, TableState> {
}
}
}
}
</
AutoSizer
>
</
AutoSizer
>
</
div
>
</
div
>
{
canFixed
&&
(
{
false
&&
(
<
RightDragFixed
<
RightDragFixed
tableId=
{
tableId
}
tableId=
{
tableId
}
initLeft=
{
tableWidth
-
rightWidth
}
initLeft=
{
tableWidth
-
rightWidth
}
...
@@ -645,7 +645,7 @@ export default class AirTable extends Component<TableProps, TableState> {
...
@@ -645,7 +645,7 @@ export default class AirTable extends Component<TableProps, TableState> {
tableWidth=
{
tableWidth
}
tableWidth=
{
tableWidth
}
showColumns=
{
showColumns
}
showColumns=
{
showColumns
}
columnWidth=
{
columnWidth
}
columnWidth=
{
columnWidth
}
columns=
{
c
olumns
}
columns=
{
formatC
olumns
}
paddingRight=
{
paddingRight
}
paddingRight=
{
paddingRight
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStart=
{
this
.
onResizeStartRightDragFixed
}
onResizeStop=
{
this
.
onResizeStopRightDragFixed
}
onResizeStop=
{
this
.
onResizeStopRightDragFixed
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment