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
286e5033
Commit
286e5033
authored
May 24, 2022
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整代码
parent
4925ac78
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
70 deletions
+31
-70
ExpandedModelTable.jsx
src/view/Manage/Model/Component/ExpandedModelTable.jsx
+26
-55
ModelTable.jsx
src/view/Manage/Model/Component/ModelTable.jsx
+0
-0
test-table.tsx
src/view/Manage/VirtualTable/test-table.tsx
+5
-15
No files found.
src/view/Manage/Model/Component/
Sub
ModelTable.jsx
→
src/view/Manage/Model/Component/
Expanded
ModelTable.jsx
View file @
286e5033
import
React
,
{
useState
,
useEffect
,
useRef
}
from
"react"
;
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
{
Tooltip
,
Modal
,
Pagination
,
Table
,
Typography
}
from
'antd'
;
import
{
Tooltip
,
Modal
,
Table
,
Typography
}
from
'antd'
;
import
{
DownOutlined
,
UpOutlined
}
from
'@ant-design/icons'
;
import
SmoothScroll
from
'smooth-scroll'
;
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
{
Resizable
}
from
'react-resizable'
;
import
{
Resizable
}
from
'react-resizable'
;
import
ResizeObserver
from
'rc-resize-observer'
;
import
ResizeObserver
from
'rc-resize-observer'
;
import
{
ContextMenu
,
ContextMenuTrigger
}
from
'react-contextmenu'
;
import
{
ContextMenu
,
ContextMenuTrigger
}
from
'react-contextmenu'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
nanoid
}
from
'nanoid'
;
import
{
createPortal
}
from
'react-dom'
;
import
{
createPortal
}
from
'react-dom'
;
import
{
MenuItem
,
SubMenu
}
from
'react-contextmenu'
;
import
{
MenuItem
}
from
'react-contextmenu'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
,
getQueryParam
,
paginate
,
isSzseEnv
,
formatDate
,
getDataModelerRole
}
from
'../../../../util'
;
import
{
showMessage
,
isSzseEnv
,
formatDate
,
getDataModelerRole
}
from
'../../../../util'
;
import
{
A
nchorId
,
AnchorTimestamp
,
A
ction
,
CatalogId
,
ModelerId
,
DataModelerRoleReader
}
from
'../../../../util/constant'
;
import
{
Action
,
CatalogId
,
ModelerId
,
DataModelerRoleReader
}
from
'../../../../util/constant'
;
// import Tag from "../../Tag";
// import Tag from "../../Tag";
import
'./ModelTable.less'
;
import
'./ModelTable.less'
;
import
'react-contexify/dist/ReactContexify.css'
;
const
{
Text
}
=
Typography
;
const
{
Text
}
=
Typography
;
const
{
Column
}
=
Table
;
const
{
Column
}
=
Table
;
...
@@ -128,17 +125,18 @@ const ResizeableHeaderCell = props => {
...
@@ -128,17 +125,18 @@ const ResizeableHeaderCell = props => {
);
);
};
};
const
Sub
ModelTable
=
(
props
)
=>
{
const
Expanded
ModelTable
=
(
props
)
=>
{
const
{
data
,
onChange
,
onItemAction
,
onSelect
,
onHistory
,
catalogId
,
keyword
,
onAutoCreateTable
,
offset
=
null
,
modelId
=
null
,
modelPid
=
null
,
view
,
selectModelerIds
,
onSubSelect
,
modelState
,
user
,
checked
,
dataMap
,
onDataMapChange
}
=
props
;
const
{
onChange
,
onItemAction
,
onHistory
,
onAutoCreateTable
,
onExpandedSelect
,
onExpandedChange
,
catalogId
,
keyword
,
id
=
null
,
pid
=
null
,
view
,
user
,
checked
,
dataMap
}
=
props
;
const
[
tableWidth
,
setTableWidth
]
=
useState
(
0
);
const
[
tableWidth
,
setTableWidth
]
=
useState
(
0
);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
([]);
const
[
subSelectedRowKeys
,
setSubSelectedRowKeys
]
=
useState
([]);
const
[
data
,
setData
]
=
useState
([]);
// const [ mouseEnterKey, setMouseEnterKey ] = useState(null);
const
[
sortRule
,
setSortRule
]
=
useState
(
null
);
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
filterData
,
setFilterData
]
=
useState
([]);
const
[
currentItem
,
setCurrentItem
]
=
useState
(
null
);
const
[
subData
,
setSubData
]
=
useState
([]);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
cols
=
[
const
cols
=
[
{
{
...
@@ -146,8 +144,6 @@ const SubModelTable = (props) => {
...
@@ -146,8 +144,6 @@ const SubModelTable = (props) => {
dataIndex
:
'name'
,
dataIndex
:
'name'
,
width
:
isSzseEnv
?
360
:
160
,
width
:
isSzseEnv
?
360
:
160
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
record
,
index
)
=>
{
render
:
(
text
,
record
,
index
)
=>
{
return
(<
ModelNameColumn
text=
{
text
}
record=
{
record
}
detailItem=
{
detailItem
}
/>);
return
(<
ModelNameColumn
text=
{
text
}
record=
{
record
}
detailItem=
{
detailItem
}
/>);
}
}
...
@@ -157,8 +153,6 @@ const SubModelTable = (props) => {
...
@@ -157,8 +153,6 @@ const SubModelTable = (props) => {
dataIndex
:
'cnName'
,
dataIndex
:
'cnName'
,
width
:
isSzseEnv
?
420
:
160
,
width
:
isSzseEnv
?
420
:
160
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
Tooltip
title=
{
text
||
''
}
>
<
Tooltip
title=
{
text
||
''
}
>
...
@@ -172,8 +166,6 @@ const SubModelTable = (props) => {
...
@@ -172,8 +166,6 @@ const SubModelTable = (props) => {
dataIndex
:
'state'
,
dataIndex
:
'state'
,
width
:
100
,
width
:
100
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
_
,
record
)
=>
{
render
:
(
_
,
record
)
=>
{
let
color
=
''
;
let
color
=
''
;
...
@@ -198,16 +190,12 @@ const SubModelTable = (props) => {
...
@@ -198,16 +190,12 @@ const SubModelTable = (props) => {
dataIndex
:
'editor'
,
dataIndex
:
'editor'
,
width
:
100
,
width
:
100
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
},
},
{
{
title
:
'版本号'
,
title
:
'版本号'
,
dataIndex
:
'modifiedTs'
,
dataIndex
:
'modifiedTs'
,
width
:
170
,
width
:
170
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
_
,
record
)
=>
{
render
:
(
_
,
record
)
=>
{
return
`V_
${
formatDate
(
record
.
modifiedTs
)}
`
;
return
`V_
${
formatDate
(
record
.
modifiedTs
)}
`
;
}
}
...
@@ -234,8 +222,6 @@ const SubModelTable = (props) => {
...
@@ -234,8 +222,6 @@ const SubModelTable = (props) => {
title
:
'模型描述'
,
title
:
'模型描述'
,
dataIndex
:
'remark'
,
dataIndex
:
'remark'
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
Tooltip
title=
{
text
||
''
}
overlayClassName=
'tooltip-common'
>
<
Tooltip
title=
{
text
||
''
}
overlayClassName=
'tooltip-common'
>
...
@@ -251,8 +237,6 @@ const SubModelTable = (props) => {
...
@@ -251,8 +237,6 @@ const SubModelTable = (props) => {
dataIndex
:
'path'
,
dataIndex
:
'path'
,
width
:
120
,
width
:
120
,
ellipsis
:
true
,
ellipsis
:
true
,
sorter
:
true
,
sortDirections
:
[
'ascend'
,
'descend'
],
render
:
(
text
,
_
,
__
)
=>
{
render
:
(
text
,
_
,
__
)
=>
{
return
(
return
(
<
Tooltip
title=
{
text
||
''
}
>
<
Tooltip
title=
{
text
||
''
}
>
...
@@ -262,21 +246,11 @@ const SubModelTable = (props) => {
...
@@ -262,21 +246,11 @@ const SubModelTable = (props) => {
}
}
};
};
const
[
columns
,
setColumns
]
=
useState
([]);
const
[
currentItem
,
setCurrentItem
]
=
useState
(
null
);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
anchorId
=
getQueryParam
(
AnchorId
,
props
.
location
.
search
);
const
anchorTimestamp
=
getQueryParam
(
AnchorTimestamp
,
props
.
location
.
search
);
const
shouldScrollRef
=
useRef
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
setSelectedRowKeys
(
checked
?[
modelI
d
]:[]);
setSelectedRowKeys
(
checked
?[
i
d
]:[]);
if
(
dataMap
.
has
(
modelI
d
))
{
if
(
dataMap
.
has
(
i
d
))
{
set
SubData
([
dataMap
.
get
(
modelI
d
)]);
set
Data
([
dataMap
.
get
(
i
d
)]);
}
else
{
}
else
{
getCheckoutDataModel
();
getCheckoutDataModel
();
}
}
...
@@ -311,14 +285,11 @@ const SubModelTable = (props) => {
...
@@ -311,14 +285,11 @@ const SubModelTable = (props) => {
dispatch
({
dispatch
({
type
:
'datamodel.getCheckoutDataModel'
,
type
:
'datamodel.getCheckoutDataModel'
,
payload
:
{
payload
:
{
id
:
modelP
id
id
:
p
id
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setSubData
(
data
?[
data
]:[]);
setData
(
data
?[
data
]:[]);
onDataMapChange
&&
onDataMapChange
(
modelId
,
data
);
onExpandedChange
&&
onExpandedChange
(
id
,
data
);
},
error
:
()
=>
{
}
}
})
})
}
}
...
@@ -386,9 +357,9 @@ const SubModelTable = (props) => {
...
@@ -386,9 +357,9 @@ const SubModelTable = (props) => {
onHistory
&&
onHistory
(
record
.
id
);
onHistory
&&
onHistory
(
record
.
id
);
}
}
const
onSelectChange
=
keys
=>
{
const
on
Expanded
SelectChange
=
keys
=>
{
setSelectedRowKeys
(
keys
);
setSelectedRowKeys
(
keys
);
on
SubSelect
&&
onSubSelect
(
keys
,
subD
ata
[
0
].
id
);
on
ExpandedSelect
&&
onExpandedSelect
(
keys
,
d
ata
[
0
].
id
);
};
};
const
handleResize
=
index
=>
(
e
,
{
size
})
=>
{
const
handleResize
=
index
=>
(
e
,
{
size
})
=>
{
...
@@ -404,12 +375,12 @@ const SubModelTable = (props) => {
...
@@ -404,12 +375,12 @@ const SubModelTable = (props) => {
const
rowSelection
=
{
const
rowSelection
=
{
selectedRowKeys
,
selectedRowKeys
,
onChange
:
onSelectChange
,
onChange
:
on
Expanded
SelectChange
,
hideSelectAll
:
true
,
hideSelectAll
:
true
,
};
};
const
classes
=
classnames
(
'model-table'
,
{
const
classes
=
classnames
(
'model-table'
,
{
'model-table-sub'
:
modelI
d
'model-table-sub'
:
i
d
});
});
const
handleItemClick
=
(
e
,
data
)
=>
{
const
handleItemClick
=
(
e
,
data
)
=>
{
...
@@ -499,7 +470,7 @@ const SubModelTable = (props) => {
...
@@ -499,7 +470,7 @@ const SubModelTable = (props) => {
}
}
}
}
columns=
{
mergedColumns
()
}
columns=
{
mergedColumns
()
}
rowKey=
{
'id'
}
rowKey=
{
'id'
}
dataSource=
{
subD
ata
||
[]
}
dataSource=
{
d
ata
||
[]
}
pagination=
{
false
}
pagination=
{
false
}
size=
'small'
size=
'small'
onRow=
{
(
record
,
index
)
=>
{
onRow=
{
(
record
,
index
)
=>
{
...
@@ -558,4 +529,4 @@ const SubModelTable = (props) => {
...
@@ -558,4 +529,4 @@ const SubModelTable = (props) => {
);
);
}
}
export
default
SubModelTable
;
export
default
ExpandedModelTable
;
\ No newline at end of file
\ No newline at end of file
src/view/Manage/Model/Component/ModelTable.jsx
View file @
286e5033
This diff is collapsed.
Click to expand it.
src/view/Manage/VirtualTable/test-table.tsx
View file @
286e5033
import
React
,
{
ReactElement
,
useCallback
,
useEffect
,
useMemo
,
use
Ref
,
use
State
,
forwardRef
}
from
'react'
;
import
React
,
{
ReactElement
,
useCallback
,
useEffect
,
useMemo
,
useState
,
forwardRef
}
from
'react'
;
import
{
createPortal
}
from
'react-dom'
;
import
{
createPortal
}
from
'react-dom'
;
import
{
ContextMenu
,
ContextMenuTrigger
}
from
'react-contextmenu'
;
import
{
ContextMenu
,
ContextMenuTrigger
}
from
'react-contextmenu'
;
import
DataGrid
,
{
Column
,
DataGridProps
,
Row
as
GridRow
,
RowsChangeData
,
S
electCellFormatter
,
S
ortColumn
,
SortIconProps
,
SelectColumn
}
from
'react-data-grid'
;
import
DataGrid
,
{
Column
,
DataGridProps
,
Row
as
GridRow
,
RowsChangeData
,
SortColumn
,
SortIconProps
,
SelectColumn
}
from
'react-data-grid'
;
import
type
{
RowRendererProps
,
DataGridHandle
,
CheckboxFormatterProps
}
from
'react-data-grid'
;
import
type
{
DataGridHandle
,
CheckboxFormatterProps
}
from
'react-data-grid'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
{
Checkbox
,
Empty
}
from
'antd'
;
import
{
Checkbox
,
Empty
}
from
'antd'
;
import
type
{
CheckboxChangeEvent
}
from
'antd/es/checkbox'
;
import
type
{
CheckboxChangeEvent
}
from
'antd/es/checkbox'
;
...
@@ -123,7 +123,6 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -123,7 +123,6 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
return
row
.
id
as
K
;
return
row
.
id
as
K
;
}
}
const
[
checkAll
,
setCheckAll
]
=
useState
(
false
)
const
[
contextItem
,
setContextItem
]
=
useState
<
RowData
|
undefined
>
(
undefined
)
const
[
contextItem
,
setContextItem
]
=
useState
<
RowData
|
undefined
>
(
undefined
)
// 初始化onRowsChange
// 初始化onRowsChange
...
@@ -164,11 +163,8 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -164,11 +163,8 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
}
}
return
0
;
return
0
;
})
})
setCheckAll
(
false
)
}
}
console
.
log
(
'new rows'
,
newRows
);
(
newRows
||
[]).
forEach
((
item
,
index
)
=>
{
(
newRows
||
[]).
forEach
((
item
,
index
)
=>
{
item
.
index
=
`
${
index
+
1
}
`
;
item
.
index
=
`
${
index
+
1
}
`
;
})
})
...
@@ -194,7 +190,6 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -194,7 +190,6 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
colSpan
:
()
=>
columns
.
length
+
1
,
expand
:
expandRow
,
expandable
:
rowExpandable
colSpan
:
()
=>
columns
.
length
+
1
,
expand
:
expandRow
,
expandable
:
rowExpandable
}),
}),
...
columns
,
...
columns
,
]
]
return
cols
return
cols
}
else
if
(
checkable
)
{
}
else
if
(
checkable
)
{
...
@@ -206,14 +201,9 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
...
@@ -206,14 +201,9 @@ function FC<Row extends RowData, SR, K extends React.Key = React.Key>(props: Dat
}
}
return
columns
return
columns
},
[
columns
,
expandRow
,
checkable
])
// 取得选中
//eslint-disable-next-line react-hooks/exhaustive-deps
const
getSelected
=
useCallback
(()
=>
{
},
[
columns
,
expandRow
,
checkable
])
const
selected
=
_rows
.
filter
((
item
)
=>
item
.
__selected__
===
true
).
map
(
item
=>
item
.
id
)
console
.
debug
(
'selected'
,
selected
,
selected
.
length
)
return
selected
},
[
_rows
])
// 处理滚动
// 处理滚动
const
handleScroll
=
useCallback
((
event
:
React
.
UIEvent
<
HTMLDivElement
>
)
=>
{
const
handleScroll
=
useCallback
((
event
:
React
.
UIEvent
<
HTMLDivElement
>
)
=>
{
...
...
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