Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
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
zhaochengxiang
szse
Commits
202a5949
Commit
202a5949
authored
May 24, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整虚拟table
parent
dbe5d4d9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
38 deletions
+35
-38
index.less
src/index.less
+4
-0
ExpandedModelTable.jsx
src/view/Manage/Model/Component/ExpandedModelTable.jsx
+0
-2
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+11
-9
index.less
src/view/Manage/VirtualTable/index.less
+0
-4
index.tsx
src/view/Manage/VirtualTable/index.tsx
+20
-23
No files found.
src/index.less
View file @
202a5949
...
...
@@ -215,6 +215,10 @@ tr.drop-over-upward td {
color: #5B5B5B;
}
.anchor {
background-color: #e7f7ff;
}
.m-common {
margin: 20px 15px;
}
...
...
src/view/Manage/Model/Component/ExpandedModelTable.jsx
View file @
202a5949
...
...
@@ -248,8 +248,6 @@ const ExpandedModelTable = (props) => {
useEffect
(()
=>
{
setSelectedRowKeys
(
checked
?[
id
]:[]);
console
.
log
(
'data map'
,
dataMap
);
if
(
dataMap
.
has
(
id
))
{
setData
([
dataMap
.
get
(
id
)]);
}
else
{
...
...
src/view/Manage/Model/Component/ModelTable.jsx
View file @
202a5949
...
...
@@ -357,7 +357,7 @@ const ModelTable = (props) => {
expandedDataMapRef
.
current
.
set
(
id
,
value
);
}
let
expand
Row
=
undefined
;
let
expand
able
=
undefined
;
let
needExpand
=
false
;
(
data
||
[]).
forEach
(
record
=>
{
if
(
record
?.
alreadyCheckedOut
)
{
...
...
@@ -366,9 +366,12 @@ const ModelTable = (props) => {
})
if
(
needExpand
)
{
expandRow
=
(
_pid
,
row
)
=>
{
if
(
!
row
?.
alreadyCheckedOut
)
return
null
;
expandable
=
{
expandedRowHeight
:
100
,
rowExpandable
:
(
row
)
=>
{
return
row
?.
alreadyCheckedOut
;
},
expandRowRender
:
(
row
)
=>
{
return
(
<
div
style=
{
{
padding
:
10
}
}
>
<
ExpandedModelTable
...
...
@@ -384,6 +387,7 @@ const ModelTable = (props) => {
)
}
}
}
const
handleItemClick
=
(
e
,
data
)
=>
{
const
{
key
,
item
}
=
data
;
...
...
@@ -480,15 +484,13 @@ const ModelTable = (props) => {
columns=
{
columns
}
rows=
{
data
||
[]
}
rowHeight=
{
51
}
expandedRowHeight=
{
100
}
rowExpandable=
{
(
row
)
=>
{
return
row
?.
alreadyCheckedOut
;
rowClassName=
{
(
row
)
=>
{
return
(
row
.
id
===
anchorId
)?
'anchor'
:
''
}
}
anchorId=
{
anchorId
}
expandable=
{
expandable
}
contextMenu=
{
{
menu
:
onMenuRender
}
}
expandRow=
{
expandRow
}
selectedRows=
{
selectedRowKeys
}
onSelectedRowsChange=
{
onSelectChange
}
getComparator=
{
getComparator
}
...
...
src/view/Manage/VirtualTable/index.less
deleted
100644 → 0
View file @
dbe5d4d9
.anchor {
background-color: #e7f7ff;
}
\ No newline at end of file
src/view/Manage/VirtualTable/index.tsx
View file @
202a5949
...
...
@@ -10,8 +10,6 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';
import
{
nanoid
}
from
'nanoid'
;
import
{
downNode
,
upNode
}
from
'./virtual-table-helper'
;
import
'./index.less'
;
export
enum
RowAction
{
None
,
Expand
,
Select
}
...
...
@@ -32,22 +30,23 @@ export interface RowData {
}
interface
Props
<
Row
>
{
gridRef
?:
React
.
RefObject
<
DataGridHandle
>
contextMenu
?:
{
id
:
string
menu
:
(
row
:
RowData
|
undefined
)
=>
ReactElement
}
checkable
:
Boolean
gridRef
?:
React
.
RefObject
<
DataGridHandle
>
// setRows?: (rows: any) => void
expandRow
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expandable
?:
{
expandedRowHeight
?:
number
rowExpandable
?:
(
row
:
Row
)
=>
Boolean
expandRowRender
?:
(
row
:
Row
)
=>
React
.
ReactElement
}
getComparator
?:
(
sortColumn
:
string
)
=>
(
a
:
Row
,
b
:
Row
)
=>
number
loadMoreRows
?:
(
length
:
number
)
=>
Promise
<
Row
[]
>
|
undefined
selectedRows
?:
Array
<
any
>
onSelectedRowsChange
?:
(
selectedRows
:
Array
<
any
>
)
=>
void
rowHeight
?:
number
expandedRowHeight
?:
number
anchorId
?:
string
rowClassName
?:
(
row
:
RowData
)
=>
string
}
const
CheckboxFormatter
=
forwardRef
<
HTMLInputElement
,
CheckboxFormatterProps
>
(
...
...
@@ -60,12 +59,11 @@ const CheckboxFormatter = forwardRef<HTMLInputElement, CheckboxFormatterProps>(
}
);
export
function
getExpandingCol
<
Row
extends
RowData
,
SR
>
({
colSpan
,
expand
,
expandable
}:
{
export
function
getExpandingCol
<
Row
extends
RowData
,
SR
>
({
colSpan
,
expand
Render
,
expandable
}:
{
colSpan
:
()
=>
number
expand
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expand
Render
?:
(
row
:
Row
)
=>
React
.
ReactElement
expandable
?:
(
row
:
Row
)
=>
Boolean
})
{
console
.
log
(
'span'
,
colSpan
());
const
col
:
Column
<
Row
,
SR
>
=
{
key
:
'expanded'
,
name
:
''
,
...
...
@@ -79,15 +77,15 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
},
formatter
({
row
,
isCellSelected
,
onRowChange
})
{
if
(
row
.
__type__
===
RowType
.
Detail
)
{
if
(
expand
)
{
return
expand
(
row
.
__pid__
!
,
row
.
__row__
)
if
(
expand
Render
)
{
return
expand
Render
(
row
.
__row__
)
}
return
(
<
div
>
{
row
.
__pid__
}
</
div
>
);
}
if
(
!
expandable
||
!
expandable
(
row
))
return
<></>
;
if
(
!
expandable
||
!
expandable
(
row
))
return
null
;
// 展开收起
return
(
...
...
@@ -111,12 +109,11 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
function
FC
<
Row
extends
RowData
,
SR
,
K
extends
React
.
Key
=
React
.
Key
>
(
props
:
DataGridProps
<
Row
,
SR
,
K
>
&
Props
<
Row
>
)
{
const
{
gridRef
,
expandRow
,
rowExpandable
,
expandable
,
getComparator
,
loadMoreRows
,
onSelectedRowsChange
,
contextMenu
,
columns
,
rows
,
checkable
,
selectedRows
,
rowHeight
=
45
,
expandedRowHeight
=
1000
,
anchorId
,
...
rest
}
=
props
contextMenu
,
columns
,
rows
,
checkable
,
selectedRows
,
rowHeight
=
45
,
rowClassName
,
...
rest
}
=
props
const
rowKeyGetter
=
(
row
:
Row
):
K
=>
{
return
row
.
id
as
K
;
...
...
@@ -174,19 +171,19 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
// 组装功能s列
const
cols
=
useMemo
(()
=>
{
if
(
expand
Row
&&
checkable
)
{
if
(
expand
able
&&
checkable
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
Row
,
SR
>
({
colSpan
:
()
=>
columns
.
length
+
2
,
expand
:
expandRow
,
expandable
:
rowExpandable
colSpan
:
()
=>
columns
.
length
+
2
,
expand
Render
:
expandable
.
expandRowRender
,
expandable
:
expandable
.
rowExpandable
}),
{
...
SelectColumn
,
key
:
'select'
,
frozen
:
false
},
...
columns
,
]
return
cols
}
else
if
(
expand
Row
)
{
}
else
if
(
expand
able
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
Row
,
SR
>
({
colSpan
:
()
=>
columns
.
length
+
1
,
expand
:
expandRow
,
expandable
:
rowExpandable
colSpan
:
()
=>
columns
.
length
+
1
,
expand
Render
:
expandable
.
expandRowRender
,
expandable
:
expandable
.
rowExpandable
}),
...
columns
,
]
...
...
@@ -202,7 +199,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
return
columns
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
columns
,
expand
Row
,
checkable
])
},
[
columns
,
expand
able
,
checkable
])
// 处理滚动
const
handleScroll
=
useCallback
((
event
:
React
.
UIEvent
<
HTMLDivElement
>
)
=>
{
...
...
@@ -231,7 +228,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
disable=
{
props
.
row
.
__type__
===
RowType
.
Detail
}
>
<
GridRow
className=
{
(
props
.
row
.
id
===
anchorId
)?
'anchor'
:
''
}
className=
{
rowClassName
(
props
.
row
)
}
id=
{
`row-${props.row.id}`
}
onContextMenu=
{
(
e
:
React
.
MouseEvent
)
=>
{
setContextItem
(
props
.
row
);
...
...
@@ -248,7 +245,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
onRowsChange=
{
onRowsChange
}
// headerRowHeight={45}
rowHeight=
{
(
args
)
=>
(
args
.
type
===
'ROW'
&&
args
.
row
.
__type__
===
RowType
.
Detail
?
expandedRowHeight
:
rowHeight
)
}
rowHeight=
{
(
args
)
=>
(
args
.
type
===
'ROW'
&&
args
.
row
.
__type__
===
RowType
.
Detail
?
(
expandable
.
expandedRowHeight
||
100
)
:
rowHeight
)
}
// defaultColumnOptions={{
// sortable: true,
...
...
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