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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
53 deletions
+50
-53
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
+24
-22
index.less
src/view/Manage/VirtualTable/index.less
+0
-4
index.tsx
src/view/Manage/VirtualTable/index.tsx
+22
-25
No files found.
src/index.less
View file @
202a5949
...
@@ -215,6 +215,10 @@ tr.drop-over-upward td {
...
@@ -215,6 +215,10 @@ tr.drop-over-upward td {
color: #5B5B5B;
color: #5B5B5B;
}
}
.anchor {
background-color: #e7f7ff;
}
.m-common {
.m-common {
margin: 20px 15px;
margin: 20px 15px;
}
}
...
...
src/view/Manage/Model/Component/ExpandedModelTable.jsx
View file @
202a5949
...
@@ -248,8 +248,6 @@ const ExpandedModelTable = (props) => {
...
@@ -248,8 +248,6 @@ const ExpandedModelTable = (props) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
setSelectedRowKeys
(
checked
?[
id
]:[]);
setSelectedRowKeys
(
checked
?[
id
]:[]);
console
.
log
(
'data map'
,
dataMap
);
if
(
dataMap
.
has
(
id
))
{
if
(
dataMap
.
has
(
id
))
{
setData
([
dataMap
.
get
(
id
)]);
setData
([
dataMap
.
get
(
id
)]);
}
else
{
}
else
{
...
...
src/view/Manage/Model/Component/ModelTable.jsx
View file @
202a5949
...
@@ -357,7 +357,7 @@ const ModelTable = (props) => {
...
@@ -357,7 +357,7 @@ const ModelTable = (props) => {
expandedDataMapRef
.
current
.
set
(
id
,
value
);
expandedDataMapRef
.
current
.
set
(
id
,
value
);
}
}
let
expand
Row
=
undefined
;
let
expand
able
=
undefined
;
let
needExpand
=
false
;
let
needExpand
=
false
;
(
data
||
[]).
forEach
(
record
=>
{
(
data
||
[]).
forEach
(
record
=>
{
if
(
record
?.
alreadyCheckedOut
)
{
if
(
record
?.
alreadyCheckedOut
)
{
...
@@ -366,22 +366,26 @@ const ModelTable = (props) => {
...
@@ -366,22 +366,26 @@ const ModelTable = (props) => {
})
})
if
(
needExpand
)
{
if
(
needExpand
)
{
expandRow
=
(
_pid
,
row
)
=>
{
expandable
=
{
if
(
!
row
?.
alreadyCheckedOut
)
return
null
;
expandedRowHeight
:
100
,
rowExpandable
:
(
row
)
=>
{
return
(
return
row
?.
alreadyCheckedOut
;
<
div
style=
{
{
padding
:
10
}
}
>
},
<
ExpandedModelTable
expandRowRender
:
(
row
)
=>
{
id=
{
row
?.
checkedOutId
}
return
(
pid=
{
row
?.
id
}
<
div
style=
{
{
padding
:
10
}
}
>
checked=
{
expandedSelectedRowKeys
.
indexOf
(
row
?.
checkedOutId
)
!==-
1
}
<
ExpandedModelTable
dataMap=
{
expandedDataMapRef
.
current
}
id=
{
row
?.
checkedOutId
}
onExpandedSelect=
{
onExpandedTableSelectChange
}
pid=
{
row
?.
id
}
onExpandedChange=
{
onExpandedDataMapChange
}
checked=
{
expandedSelectedRowKeys
.
indexOf
(
row
?.
checkedOutId
)
!==-
1
}
{
...
props
}
dataMap=
{
expandedDataMapRef
.
current
}
/>
onExpandedSelect=
{
onExpandedTableSelectChange
}
</
div
>
onExpandedChange=
{
onExpandedDataMapChange
}
)
{
...
props
}
/>
</
div
>
)
}
}
}
}
}
...
@@ -480,15 +484,13 @@ const ModelTable = (props) => {
...
@@ -480,15 +484,13 @@ const ModelTable = (props) => {
columns=
{
columns
}
columns=
{
columns
}
rows=
{
data
||
[]
}
rows=
{
data
||
[]
}
rowHeight=
{
51
}
rowHeight=
{
51
}
expandedRowHeight=
{
100
}
rowClassName=
{
(
row
)
=>
{
rowExpandable=
{
(
row
)
=>
{
return
(
row
.
id
===
anchorId
)?
'anchor'
:
''
return
row
?.
alreadyCheckedOut
;
}
}
}
}
anchorId=
{
anchorId
}
expandable=
{
expandable
}
contextMenu=
{
{
contextMenu=
{
{
menu
:
onMenuRender
menu
:
onMenuRender
}
}
}
}
expandRow=
{
expandRow
}
selectedRows=
{
selectedRowKeys
}
selectedRows=
{
selectedRowKeys
}
onSelectedRowsChange=
{
onSelectChange
}
onSelectedRowsChange=
{
onSelectChange
}
getComparator=
{
getComparator
}
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';
...
@@ -10,8 +10,6 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';
import
{
nanoid
}
from
'nanoid'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
downNode
,
upNode
}
from
'./virtual-table-helper'
;
import
{
downNode
,
upNode
}
from
'./virtual-table-helper'
;
import
'./index.less'
;
export
enum
RowAction
{
export
enum
RowAction
{
None
,
Expand
,
Select
None
,
Expand
,
Select
}
}
...
@@ -32,22 +30,23 @@ export interface RowData {
...
@@ -32,22 +30,23 @@ export interface RowData {
}
}
interface
Props
<
Row
>
{
interface
Props
<
Row
>
{
gridRef
?:
React
.
RefObject
<
DataGridHandle
>
contextMenu
?:
{
contextMenu
?:
{
id
:
string
id
:
string
menu
:
(
row
:
RowData
|
undefined
)
=>
ReactElement
menu
:
(
row
:
RowData
|
undefined
)
=>
ReactElement
}
}
checkable
:
Boolean
checkable
:
Boolean
gridRef
?:
React
.
RefObject
<
DataGridHandle
>
expandable
?:
{
// setRows?: (rows: any) => void
expandedRowHeight
?:
number
expandRow
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
rowExpandable
?:
(
row
:
Row
)
=>
Boolean
rowExpandable
?:
(
row
:
Row
)
=>
Boolean
expandRowRender
?:
(
row
:
Row
)
=>
React
.
ReactElement
}
getComparator
?:
(
sortColumn
:
string
)
=>
(
a
:
Row
,
b
:
Row
)
=>
number
getComparator
?:
(
sortColumn
:
string
)
=>
(
a
:
Row
,
b
:
Row
)
=>
number
loadMoreRows
?:
(
length
:
number
)
=>
Promise
<
Row
[]
>
|
undefined
loadMoreRows
?:
(
length
:
number
)
=>
Promise
<
Row
[]
>
|
undefined
selectedRows
?:
Array
<
any
>
selectedRows
?:
Array
<
any
>
onSelectedRowsChange
?:
(
selectedRows
:
Array
<
any
>
)
=>
void
onSelectedRowsChange
?:
(
selectedRows
:
Array
<
any
>
)
=>
void
rowHeight
?:
number
rowHeight
?:
number
expandedRowHeight
?:
number
rowClassName
?:
(
row
:
RowData
)
=>
string
anchorId
?:
string
}
}
const
CheckboxFormatter
=
forwardRef
<
HTMLInputElement
,
CheckboxFormatterProps
>
(
const
CheckboxFormatter
=
forwardRef
<
HTMLInputElement
,
CheckboxFormatterProps
>
(
...
@@ -60,12 +59,11 @@ 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
colSpan
:
()
=>
number
expand
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expand
Render
?:
(
row
:
Row
)
=>
React
.
ReactElement
expandable
?:
(
row
:
Row
)
=>
Boolean
expandable
?:
(
row
:
Row
)
=>
Boolean
})
{
})
{
console
.
log
(
'span'
,
colSpan
());
const
col
:
Column
<
Row
,
SR
>
=
{
const
col
:
Column
<
Row
,
SR
>
=
{
key
:
'expanded'
,
key
:
'expanded'
,
name
:
''
,
name
:
''
,
...
@@ -79,15 +77,15 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
...
@@ -79,15 +77,15 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
},
},
formatter
({
row
,
isCellSelected
,
onRowChange
})
{
formatter
({
row
,
isCellSelected
,
onRowChange
})
{
if
(
row
.
__type__
===
RowType
.
Detail
)
{
if
(
row
.
__type__
===
RowType
.
Detail
)
{
if
(
expand
)
{
if
(
expand
Render
)
{
return
expand
(
row
.
__pid__
!
,
row
.
__row__
)
return
expand
Render
(
row
.
__row__
)
}
}
return
(
return
(
<
div
>
{
row
.
__pid__
}
</
div
>
<
div
>
{
row
.
__pid__
}
</
div
>
);
);
}
}
if
(
!
expandable
||
!
expandable
(
row
))
return
<></>
;
if
(
!
expandable
||
!
expandable
(
row
))
return
null
;
// 展开收起
// 展开收起
return
(
return
(
...
@@ -111,13 +109,12 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
...
@@ -111,13 +109,12 @@ 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
>
)
{
function
FC
<
Row
extends
RowData
,
SR
,
K
extends
React
.
Key
=
React
.
Key
>
(
props
:
DataGridProps
<
Row
,
SR
,
K
>
&
Props
<
Row
>
)
{
const
{
const
{
gridRef
,
gridRef
,
expandRow
,
expandable
,
rowExpandable
,
getComparator
,
getComparator
,
loadMoreRows
,
loadMoreRows
,
onSelectedRowsChange
,
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
=>
{
const
rowKeyGetter
=
(
row
:
Row
):
K
=>
{
return
row
.
id
as
K
;
return
row
.
id
as
K
;
}
}
...
@@ -174,19 +171,19 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -174,19 +171,19 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
// 组装功能s列
// 组装功能s列
const
cols
=
useMemo
(()
=>
{
const
cols
=
useMemo
(()
=>
{
if
(
expand
Row
&&
checkable
)
{
if
(
expand
able
&&
checkable
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
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
},
{
...
SelectColumn
,
key
:
'select'
,
frozen
:
false
},
...
columns
,
...
columns
,
]
]
return
cols
return
cols
}
else
if
(
expand
Row
)
{
}
else
if
(
expand
able
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
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
,
...
columns
,
]
]
...
@@ -202,7 +199,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -202,7 +199,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
return
columns
return
columns
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
columns
,
expand
Row
,
checkable
])
},
[
columns
,
expand
able
,
checkable
])
// 处理滚动
// 处理滚动
const
handleScroll
=
useCallback
((
event
:
React
.
UIEvent
<
HTMLDivElement
>
)
=>
{
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
...
@@ -231,7 +228,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
disable=
{
props
.
row
.
__type__
===
RowType
.
Detail
}
disable=
{
props
.
row
.
__type__
===
RowType
.
Detail
}
>
>
<
GridRow
<
GridRow
className=
{
(
props
.
row
.
id
===
anchorId
)?
'anchor'
:
''
}
className=
{
rowClassName
(
props
.
row
)
}
id=
{
`row-${props.row.id}`
}
id=
{
`row-${props.row.id}`
}
onContextMenu=
{
(
e
:
React
.
MouseEvent
)
=>
{
onContextMenu=
{
(
e
:
React
.
MouseEvent
)
=>
{
setContextItem
(
props
.
row
);
setContextItem
(
props
.
row
);
...
@@ -248,7 +245,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -248,7 +245,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
onRowsChange=
{
onRowsChange
}
onRowsChange=
{
onRowsChange
}
// headerRowHeight={45}
// 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={{
// defaultColumnOptions={{
// sortable: true,
// 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