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
3ef3fd80
Commit
3ef3fd80
authored
May 18, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加rowExpandable
parent
14a68e30
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
44 deletions
+27
-44
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+19
-41
test-table.tsx
src/view/Manage/VirtualTable/test-table.tsx
+8
-3
No files found.
src/view/Manage/Model/Component/ModelTable.jsx
View file @
3ef3fd80
...
@@ -450,44 +450,32 @@ const ModelTable = (props) => {
...
@@ -450,44 +450,32 @@ const ModelTable = (props) => {
'model-table-sub'
:
modelId
'model-table-sub'
:
modelId
});
});
let
expand
able
=
undefined
;
let
expand
Row
=
undefined
;
if
(
!
modelId
)
{
if
(
!
modelId
)
{
let
needExpand
=
false
;
let
needExpand
=
false
;
(
filterD
ata
||
[]).
forEach
(
record
=>
{
(
d
ata
||
[]).
forEach
(
record
=>
{
if
(
record
?.
alreadyCheckedOut
)
{
if
(
record
?.
alreadyCheckedOut
)
{
needExpand
=
true
;
needExpand
=
true
;
}
}
})
})
if
(
needExpand
)
{
if
(
needExpand
)
{
expandable
=
{
expandRow
=
(
_pid
,
row
)
=>
{
expandedRowRender
:
record
=>
<
ModelTable
if
(
!
row
?.
alreadyCheckedOut
)
return
null
;
modelId=
{
record
?.
checkedOutId
}
modelPid=
{
record
?.
id
}
return
(
onSubSelect=
{
onSubSelectChange
}
<
div
style=
{
{
padding
:
10
}
}
>
{
...
props
}
<
ModelTable
/>,
modelId=
{
row
?.
checkedOutId
}
expandIcon
:
({
expanded
,
onExpand
,
record
})
=>
{
modelPid=
{
row
?.
id
}
if
(
!
record
?.
alreadyCheckedOut
)
return
null
;
onSubSelect=
{
onSubSelectChange
}
{
...
props
}
return
expanded
?
<
UpOutlined
style=
{
{
fontSize
:
10
}
}
onClick=
{
e
=>
onExpand
(
record
,
e
)
}
/>
:
<
DownOutlined
style=
{
{
fontSize
:
10
}
}
onClick=
{
e
=>
onExpand
(
record
,
e
)
}
/>
/>
},
</
div
>
rowExpandable
:
record
=>
{
)
return
record
?.
alreadyCheckedOut
;
}
};
}
}
else
{
expandable
=
{
expandedRowRender
:
record
=>
<></>,
expandIcon
:
({
expanded
,
onExpand
,
record
})
=>
{
return
null
;
},
rowExpandable
:
record
=>
{
return
false
;
}
}
}
}
}
}
const
displayMenu
=
(
e
)
=>
{
const
displayMenu
=
(
e
)
=>
{
show
(
e
);
show
(
e
);
...
@@ -545,20 +533,10 @@ const ModelTable = (props) => {
...
@@ -545,20 +533,10 @@ const ModelTable = (props) => {
style=
{
{
blockSize
:
modelId
?
'95px'
:
'calc(100vh - 94px - 37px - 57px - 24px)'
}
}
style=
{
{
blockSize
:
modelId
?
'95px'
:
'calc(100vh - 94px - 37px - 57px - 24px)'
}
}
columns=
{
columns
}
columns=
{
columns
}
rows=
{
modelId
?(
subData
||
[]):(
data
||
[])
}
rows=
{
modelId
?(
subData
||
[]):(
data
||
[])
}
expandRow=
{
(
_pid
,
row
)
=>
{
rowExpandable=
{
(
row
)
=>
{
if
(
!
row
?.
alreadyCheckedOut
)
return
null
;
return
row
?.
alreadyCheckedOut
;
return
(
<
div
style=
{
{
padding
:
10
}
}
>
<
ModelTable
modelId=
{
row
?.
checkedOutId
}
modelPid=
{
row
?.
id
}
onSubSelect=
{
onSubSelectChange
}
{
...
props
}
/>
</
div
>
)
}
}
}
}
expandRow=
{
expandRow
}
getComparator=
{
getComparator
}
getComparator=
{
getComparator
}
/>
/>
<
RcMenu
id=
{
MENU_ID
}
>
<
RcMenu
id=
{
MENU_ID
}
>
...
...
src/view/Manage/VirtualTable/test-table.tsx
View file @
3ef3fd80
...
@@ -39,6 +39,7 @@ interface Props<Row> {
...
@@ -39,6 +39,7 @@ interface Props<Row> {
}
>
}
>
// setRows?: (rows: any) => void
// setRows?: (rows: any) => void
expandRow
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expandRow
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
rowExpandable
?:
(
row
:
Row
)
=>
Boolean
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
}
}
...
@@ -54,9 +55,10 @@ function RowRenderer<Row, SR>(id: string) {
...
@@ -54,9 +55,10 @@ function RowRenderer<Row, SR>(id: string) {
export
function
getExpandingCol
<
Row
extends
RowData
,
SR
>
({
colSpan
,
expand
}:
{
export
function
getExpandingCol
<
Row
extends
RowData
,
SR
>
({
colSpan
,
expand
,
expandable
}:
{
colSpan
:
()
=>
number
colSpan
:
()
=>
number
expand
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expand
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expandable
?:
(
row
:
Row
)
=>
Boolean
})
{
})
{
const
col
:
Column
<
Row
,
SR
>
=
{
const
col
:
Column
<
Row
,
SR
>
=
{
key
:
'expanded'
,
key
:
'expanded'
,
...
@@ -79,6 +81,8 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand }: {
...
@@ -79,6 +81,8 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand }: {
);
);
}
}
if
(
!
expandable
||
!
expandable
(
row
))
return
<></>;
// 展开收起
// 展开收起
return
(
return
(
<
div
style=
{
{
cursor
:
'pointer'
,
color
:
isCellSelected
?
'#777'
:
'#ccc'
}
}
<
div
style=
{
{
cursor
:
'pointer'
,
color
:
isCellSelected
?
'#777'
:
'#ccc'
}
}
...
@@ -92,7 +96,7 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand }: {
...
@@ -92,7 +96,7 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand }: {
>
>
{
row
.
__expanded__
?
'
\
u25BC'
:
'
\
u25B6'
}
{
row
.
__expanded__
?
'
\
u25BC'
:
'
\
u25B6'
}
</
div
>
</
div
>
);
);
}
}
}
}
return
col
return
col
...
@@ -140,6 +144,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -140,6 +144,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
const
{
const
{
gridRef
,
ctxRef
,
gridRef
,
ctxRef
,
expandRow
,
expandRow
,
rowExpandable
,
getComparator
,
getComparator
,
loadMoreRows
,
loadMoreRows
,
contextMenu
,
columns
,
rows
,
...
rest
}
=
props
contextMenu
,
columns
,
rows
,
...
rest
}
=
props
...
@@ -197,7 +202,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -197,7 +202,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
if
(
expandRow
)
{
if
(
expandRow
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
Row
,
SR
>
({
getExpandingCol
<
Row
,
SR
>
({
colSpan
:
()
=>
cols
.
length
,
expand
:
expandRow
colSpan
:
()
=>
cols
.
length
,
expand
:
expandRow
,
expandable
:
rowExpandable
}),
}),
getSelectCol
(()
=>
{
// 全选
getSelectCol
(()
=>
{
// 全选
const
rows
=
[]
const
rows
=
[]
...
...
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