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
766e3f5c
Commit
766e3f5c
authored
May 20, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
行展开
parent
e8a8d0e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+27
-7
test-table.tsx
src/view/Manage/VirtualTable/test-table.tsx
+8
-6
No files found.
src/view/Manage/Model/Component/ModelTable.jsx
View file @
766e3f5c
...
...
@@ -99,7 +99,7 @@ const ModelNameColumn = (props) => {
const
ModelTable
=
(
props
)
=>
{
const
{
data
,
onChange
,
onItemAction
,
onSelect
,
onHistory
,
catalogId
,
keyword
,
onAutoCreateTable
,
offset
=
null
,
modelId
=
null
,
modelPid
=
null
,
view
,
selectModelerIds
,
onSubSelect
,
modelState
,
user
}
=
props
;
const
{
data
,
onChange
,
onItemAction
,
onSelect
,
onHistory
,
catalogId
,
keyword
,
onAutoCreateTable
,
offset
=
null
,
modelId
=
null
,
modelPid
=
null
,
view
,
selectModelerIds
,
onSubSelect
,
modelState
,
user
,
dataMap
,
onDataMapChange
,
globalSelectRows
}
=
props
;
const
MENU_ID
=
(((
modelId
||
''
)
!==
''
)
?
`model-table-contextmenu-
${
modelId
}
`
:
'model-table-contextmenu'
);
...
...
@@ -112,6 +112,7 @@ const ModelTable = (props) => {
const
[
subSelectedRowKeys
,
setSubSelectedRowKeys
]
=
useState
([]);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
subData
,
setSubData
]
=
useState
([]);
const
[
subDataMap
,
setSubDataMap
]
=
useState
(
new
Map
());
const
cols
=
[
{
...
...
@@ -220,8 +221,8 @@ const ModelTable = (props) => {
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
anchorId
=
getQueryParam
(
AnchorId
,
props
.
location
.
search
);
const
anchorTimestamp
=
getQueryParam
(
AnchorTimestamp
,
props
.
location
.
search
);
const
anchorId
=
getQueryParam
(
AnchorId
,
props
?.
location
?
.
search
);
const
anchorTimestamp
=
getQueryParam
(
AnchorTimestamp
,
props
?.
location
?
.
search
);
const
shouldScrollRef
=
useRef
(
false
);
...
...
@@ -265,7 +266,17 @@ const ModelTable = (props) => {
setPagination
({...
pagination
,
pageNum
:
1
});
}
}
else
{
getCheckoutDataModel
();
if
(
dataMap
.
has
(
modelId
))
{
setSubData
([
dataMap
.
get
(
modelId
)]);
}
else
{
getCheckoutDataModel
();
}
if
(
globalSelectRows
.
indexOf
(
modelId
)
!==
-
1
)
{
setSelectedRowKeys
([
modelId
]);
}
else
{
setSelectedRowKeys
([]);
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
catalogId
,
keyword
,
offset
,
modelState
]);
...
...
@@ -315,6 +326,7 @@ const ModelTable = (props) => {
},
callback
:
data
=>
{
setSubData
(
data
?[
data
]:[]);
onDataMapChange
&&
onDataMapChange
(
modelId
,
data
);
},
error
:
()
=>
{
...
...
@@ -428,7 +440,7 @@ const ModelTable = (props) => {
setSelectedRowKeys
(
keys
);
if
((
modelId
||
''
)
!==
''
)
{
onSubSelect
&&
onSubSelect
(
keys
,
subData
[
0
].
i
d
);
onSubSelect
&&
onSubSelect
(
keys
,
modelI
d
);
}
else
{
onSelect
&&
onSelect
([...
subSelectedRowKeys
,
...
keys
]);
}
...
...
@@ -443,10 +455,15 @@ const ModelTable = (props) => {
onSelect
&&
onSelect
([...
newSubSelectedRowKeys
,
...
selectedRowKeys
]);
}
else
{
const
newSubSelectedRowKeys
=
[...
subSelectedRowKeys
,
id
];
setSubSelectedRowKeys
(
newSubSelectedRowKeys
);
onSelect
&&
onSelect
([...
newSubSelectedRowKeys
,
...
selectedRowKeys
]);
}
}
const
onSubDataMapChange
=
(
id
,
value
)
=>
{
subDataMap
.
set
(
id
,
value
);
}
const
classes
=
classnames
(
'model-table'
,
{
'model-table-sub'
:
modelId
});
...
...
@@ -469,7 +486,10 @@ const ModelTable = (props) => {
<
ModelTable
modelId=
{
row
?.
checkedOutId
}
modelPid=
{
row
?.
id
}
globalSelectRows=
{
[...
subSelectedRowKeys
,
...
selectedRowKeys
]
}
dataMap=
{
subDataMap
}
onSubSelect=
{
onSubSelectChange
}
onDataMapChange=
{
onSubDataMapChange
}
{
...
props
}
/>
</
div
>
...
...
@@ -578,8 +598,8 @@ const ModelTable = (props) => {
contextMenu=
{
{
menu
:
onMenuRender
}
}
//
expandRow={expandRow}
selectedRows=
{
modelId
?
subSelectedRowKeys
:
selectedRowKeys
}
expandRow=
{
expandRow
}
selectedRows=
{
selectedRowKeys
}
onSelectedRowsChange=
{
onSelectChange
}
getComparator=
{
getComparator
}
/>
...
...
src/view/Manage/VirtualTable/test-table.tsx
View file @
766e3f5c
...
...
@@ -70,6 +70,7 @@ export function getExpandingCol<Row extends RowData, SR>({ colSpan, expand, expa
expand
?:
(
pid
:
string
,
row
:
Row
)
=>
React
.
ReactElement
expandable
?:
(
row
:
Row
)
=>
Boolean
})
{
console
.
log
(
'span'
,
colSpan
());
const
col
:
Column
<
Row
,
SR
>
=
{
key
:
'expanded'
,
name
:
''
,
...
...
@@ -137,7 +138,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
rows
.
splice
(
indexes
[
0
]
+
1
,
1
);
// 删除下一行
}
else
{
rows
.
splice
(
indexes
[
0
]
+
1
,
0
,
{
// 插入下一行
id
:
nanoid
()
,
__type__
:
RowType
.
Detail
,
__pid__
:
row
.
id
,
__row__
:
row
,
id
:
`
${
row
.
id
}
-detail`
,
__type__
:
RowType
.
Detail
,
__pid__
:
row
.
id
,
__row__
:
row
,
});
}
}
else
if
(
row
.
__action__
===
RowAction
.
Select
)
{
...
...
@@ -181,18 +182,18 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
const
cols
=
useMemo
(()
=>
{
if
(
expandRow
&&
checkable
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
{
...
SelectColumn
,
key
:
'select'
,
frozen
:
false
},
getExpandingCol
<
Row
,
SR
>
({
colSpan
:
()
=>
col
s
.
length
,
expand
:
expandRow
,
expandable
:
rowExpandable
colSpan
:
()
=>
col
umns
.
length
+
1
,
expand
:
expandRow
,
expandable
:
rowExpandable
}),
{
...
SelectColumn
,
key
:
'select'
,
frozen
:
false
},
//
{ ...SelectColumn, key: 'select', frozen: false },
...
columns
,
]
return
cols
}
else
if
(
expandRow
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
getExpandingCol
<
Row
,
SR
>
({
colSpan
:
()
=>
col
s
.
length
,
expand
:
expandRow
,
expandable
:
rowExpandable
colSpan
:
()
=>
col
umns
.
length
+
1
,
expand
:
expandRow
,
expandable
:
rowExpandable
}),
...
columns
,
...
...
@@ -200,7 +201,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
return
cols
}
else
if
(
checkable
)
{
const
cols
:
readonly
Column
<
Row
,
SR
>
[]
=
[
{
...
SelectColumn
,
key
:
'select'
,
frozen
:
false
},
{
...
SelectColumn
,
frozen
:
false
},
...
columns
,
]
return
cols
...
...
@@ -271,6 +272,7 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
selectedRows=
{
new
Set
(
selectedRows
||
[])
}
onSelectedRowsChange=
{
(
values
:
Set
<
any
>
)
=>
{
console
.
log
(
'values'
,
values
);
onSelectedRowsChange
&&
onSelectedRowsChange
(
Array
.
from
(
values
));
}
}
// 滚动
...
...
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