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
e35e42f4
Commit
e35e42f4
authored
Nov 29, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anchor
parent
5c879afa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
9 deletions
+84
-9
index.js
src/util/index.js
+39
-0
ImportAction.jsx
src/view/Manage/Model/Component/ImportAction.jsx
+43
-7
ImportActionHeader.jsx
src/view/Manage/Model/Component/ImportActionHeader.jsx
+1
-1
ImportActionIndex.jsx
src/view/Manage/Model/Component/ImportActionIndex.jsx
+1
-1
No files found.
src/util/index.js
View file @
e35e42f4
...
...
@@ -509,3 +509,41 @@ export function getValidString(strs) {
}
}
}
function
getOffsetTop
(
element
,
container
)
{
if
(
!
element
.
getClientRects
().
length
)
{
return
0
;
}
const
rect
=
element
.
getBoundingClientRect
();
if
(
rect
.
width
||
rect
.
height
)
{
if
(
container
===
window
)
{
container
=
element
.
ownerDocument
?.
documentElement
;
return
rect
.
top
-
container
?.
clientTop
;
}
return
rect
.
top
-
container
?.
getBoundingClientRect
().
top
;
}
return
rect
.
top
;
}
export
function
getInternalCurrentAnchor
(
_linkIds
,
_offsetTop
=
0
,
_bounds
=
5
,
container
=
window
)
{
const
linkSections
:
Section
[]
=
[];
_linkIds
.
forEach
((
id
)
=>
{
const
target
=
document
.
getElementById
(
id
);
if
(
target
)
{
const
top
=
getOffsetTop
(
target
,
container
);
if
(
top
<
_offsetTop
+
_bounds
)
{
linkSections
.
push
({
id
,
top
});
}
}
});
console
.
log
(
'linkSections'
,
linkSections
);
if
(
linkSections
.
length
)
{
const
maxSection
=
linkSections
.
reduce
((
prev
,
curr
)
=>
(
curr
.
top
>
prev
.
top
?
curr
:
prev
));
return
maxSection
.
id
;
}
return
''
;
};
\ No newline at end of file
src/view/Manage/Model/Component/ImportAction.jsx
View file @
e35e42f4
...
...
@@ -6,7 +6,7 @@ import ImportActionHeader from './ImportActionHeader';
import
ImportActionInherited
from
'./ImportActionInherited'
;
import
{
ImportActionTable
}
from
'./ImportActionTable'
;
import
ImportActionIndex
from
'./ImportActionIndex'
;
import
{
getQueryParam
}
from
'../../../../util'
;
import
{
get
InternalCurrentAnchor
,
get
QueryParam
}
from
'../../../../util'
;
import
{
Action
}
from
'../../../../util/constant'
;
import
{
dispatch
}
from
'../../../../model'
;
...
...
@@ -23,9 +23,12 @@ const ImportAction = React.forwardRef((props, ref) => {
const
[
supportedIndextypes
,
setSupportedIndextypes
]
=
useState
([]);
const
[
validateReports
,
setValidateReports
]
=
useState
([]);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
container
,
setContainer
]
=
useState
();
const
[
activeValue
,
setActiveValue
]
=
useState
();
const
mountRef
=
useRef
(
true
);
const
modelerDataRef
=
useRef
(
null
);
const
animating
=
useRef
(
false
);
useImperativeHandle
(
ref
,
()
=>
({
isLoading
:
()
=>
{
...
...
@@ -106,6 +109,36 @@ const ImportAction = React.forwardRef((props, ref) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
constraint
])
React
.
useEffect
(()
=>
{
if
(
container
)
{
handleScroll
();
container
?.
addEventListener
(
'scroll'
,
handleScroll
);
return
()
=>
{
container
?.
removeEventListener
(
'scroll'
,
handleScroll
);
};
}
},
[
container
]);
const
handleScroll
=
React
.
useCallback
(()
=>
{
if
(
animating
.
current
)
{
animating
.
current
=
false
;
return
;
}
const
currentActiveLink
=
getInternalCurrentAnchor
(
[
'model-import-action-header'
,
'model-import-action-table'
,
'model-import-action-index'
,
],
0
,
5
,
container
);
setActiveValue
(
currentActiveLink
)
},
[
container
]);
const
getTemplates
=
()
=>
{
dispatch
({
type
:
'datamodel.getAllTemplates'
,
...
...
@@ -542,17 +575,20 @@ const ImportAction = React.forwardRef((props, ref) => {
{loading?'':'暂无权限'}
</div> : <div>
<div style={{ position: 'sticky', top: 0 }}>
<Tabs centered onChange={(val) => {
var targetElements = document.getElementsByClassName(val); // 找到目标元素
for (const element of targetElements) {
element?.scrollIntoView()
<Tabs activeKey={activeValue} centered onChange={(val) => {
setActiveValue(val);
var targetElement = document.getElementById(val); // 找到目标元素
if (targetElement) {
animating.current = true;
targetElement.scrollIntoView();
}
}} style={{ margin: 0 }}>
<Tabs.TabPane tab='基本信息' key="
1
" />
<Tabs.TabPane tab='基本信息' key="
model-import-action-header
" />
<Tabs.TabPane tab='数据表结构' key="model-import-action-table" />
<Tabs.TabPane tab='数据表索引' key="model-import-action-index" />
</Tabs>
</div>
<div style={{ height: 'calc(100vh - 44px - 64px - 82px)', overflow: 'auto', padding: '0 20px' }}>
<div
ref={setContainer}
style={{ height: 'calc(100vh - 44px - 64px - 82px)', overflow: 'auto', padding: '0 20px' }}>
<ImportActionHeader
form={form}
editable={action!=='detail'&&action!=='flow'&&action!=='detail-version'&&action!=='edit-inherited'}
...
...
src/view/Manage/Model/Component/ImportActionHeader.jsx
View file @
e35e42f4
...
...
@@ -305,7 +305,7 @@ const ImportActionHeader = (props) => {
}
return
(
<
div
className=
'model-import-action-header'
>
<
div
className=
'model-import-action-header'
id=
'model-import-action-header'
>
<
div
className=
'mb-3'
style=
{
{
...
...
src/view/Manage/Model/Component/ImportActionIndex.jsx
View file @
e35e42f4
...
...
@@ -840,7 +840,7 @@ const ImportActionIndex = (props) => {
}
return
(
<
div
className=
'model-import-action-index'
>
<
div
className=
'model-import-action-index'
id=
'model-import-action-index'
>
<
div
className=
'd-flex mb-3'
style=
{
{
justifyContent
:
'space-between'
}
}
>
<
Space
>
<
h2
style=
{
{
marginBottom
:
0
}
}
>
数据表索引
</
h2
>
...
...
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