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
4d970a83
Commit
4d970a83
authored
Aug 07, 2020
by
zhangwenshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
a57bc415
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
7 deletions
+34
-7
DragFixed.less
components/apolloTable/component/DragFixed.less
+1
-0
DragFixed.tsx
components/apolloTable/component/DragFixed.tsx
+2
-0
DragSorted.less
components/apolloTable/component/DragSorted.less
+3
-0
DragSorted.tsx
components/apolloTable/component/DragSorted.tsx
+4
-3
RightDragFixed.tsx
components/apolloTable/component/RightDragFixed.tsx
+2
-0
Table.tsx
components/apolloTable/component/Table.tsx
+3
-0
memCols.ts
components/apolloTable/utils/memCols.ts
+19
-4
No files found.
components/apolloTable/component/DragFixed.less
View file @
4d970a83
...
...
@@ -6,6 +6,7 @@
width: 2px;
z-index: 4;
background: transparent;
user-select: none;
&.hovered {
background: #aaa;
}
...
...
components/apolloTable/component/DragFixed.tsx
View file @
4d970a83
...
...
@@ -157,6 +157,8 @@ const DragFixed = (props: any) => {
onMouseLeave=
{
onMouseLeaveWrap
}
>
<
ResizableBox
width=
{
2
}
height=
{
1
}
handle=
{
<
span
id=
"leftFixedHandle"
...
...
components/apolloTable/component/DragSorted.less
View file @
4d970a83
...
...
@@ -3,4 +3,7 @@
.sortedWrap {
width: 100%;
height: 100%;
&.sortedAble {
cursor: grab;
}
}
components/apolloTable/component/DragSorted.tsx
View file @
4d970a83
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
}
...
...
components/apolloTable/component/RightDragFixed.tsx
View file @
4d970a83
...
...
@@ -163,6 +163,8 @@ const DragFixed = (props: any) => {
onMouseLeave=
{
onMouseLeaveWrap
}
>
<
ResizableBox
width=
{
2
}
height=
{
1
}
handle=
{
<
span
id=
"rightFixedHandle"
...
...
components/apolloTable/component/Table.tsx
View file @
4d970a83
...
...
@@ -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
>
...
...
components/apolloTable/utils/memCols.ts
View file @
4d970a83
...
...
@@ -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
{
c
onst
data
:
any
=
{};
c
achedCols
=
{};
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
)
{
s
aveCache
({
tableId
,
data
})
;
s
houldSave
=
true
;
}
}
if
(
shouldSave
)
{
saveCache
({
tableId
,
data
:
cachedCols
});
}
}
columns
.
sort
((
a
,
b
)
=>
{
return
a
.
orderNo
-
b
.
orderNo
;
...
...
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