Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
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
wangpeng
dinky
Commits
91120a64
Unverified
Commit
91120a64
authored
Nov 04, 2022
by
Licho
Committed by
GitHub
Nov 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: continuous click task item will open multiply tabs problem. (#1204)
parent
06e66f51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
29 deletions
+45
-29
index.tsx
dlink-web/src/components/Studio/StudioTree/index.tsx
+45
-29
No files found.
dlink-web/src/components/Studio/StudioTree/index.tsx
View file @
91120a64
...
...
@@ -63,8 +63,8 @@ type RightClickMenu = {
//将树形节点改为一维数组
const
generateList
=
(
data
:
any
,
list
:
any
[])
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
node
=
data
[
i
]
;
for
(
const
element
of
data
)
{
const
node
=
element
;
const
{
name
,
id
,
parentId
,
level
}
=
node
;
list
.
push
({
name
,
id
,
key
:
id
,
title
:
name
,
parentId
,
level
});
if
(
node
.
children
)
{
...
...
@@ -77,8 +77,8 @@ const generateList = (data: any, list: any[]) => {
// tree树 匹配方法
const
getParentKey
=
(
key
:
number
|
string
,
tree
:
any
):
any
=>
{
let
parentKey
;
for
(
let
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
const
node
=
tree
[
i
]
;
for
(
const
element
of
tree
)
{
const
node
=
element
;
if
(
node
.
children
)
{
if
(
node
.
children
.
some
((
item
:
any
)
=>
item
.
id
===
key
))
{
parentKey
=
node
.
id
;
...
...
@@ -140,8 +140,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const
expandList
:
any
[]
=
generateList
(
treeData
,
[]);
let
expandedKeys
:
any
=
expandList
.
map
((
item
:
any
)
=>
{
if
(
item
&&
item
.
name
.
indexOf
(
value
)
>
-
1
)
{
let
key
=
getParentKey
(
item
.
key
,
treeData
);
return
key
;
return
getParentKey
(
item
.
key
,
treeData
);
}
return
null
;
})
...
...
@@ -155,11 +154,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const
result
=
await
getCatalogueTreeData
();
let
data
=
result
.
datas
;
let
list
=
data
;
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
list
[
i
].
title
=
list
[
i
]
.
name
;
list
[
i
].
key
=
list
[
i
]
.
id
;
if
(
list
[
i
]
.
isLeaf
)
{
list
[
i
].
icon
=
getIcon
(
list
[
i
]
.
type
);
for
(
const
element
of
list
)
{
element
.
title
=
element
.
name
;
element
.
key
=
element
.
id
;
if
(
element
.
isLeaf
)
{
element
.
icon
=
getIcon
(
element
.
type
);
}
}
data
=
convertToTreeData
(
list
,
0
);
...
...
@@ -207,43 +206,56 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setIsUploadModalVisible
(
true
);
};
const
activeTabCall
=
(
node
:
TreeDataNode
)
=>
{
dispatch
&&
dispatch
({
type
:
"Studio/saveToolHeight"
,
payload
:
toolHeight
-
0.0001
,
});
dispatch
&&
dispatch
({
type
:
"Studio/changeActiveKey"
,
payload
:
node
.
taskId
,
});
};
const
checkInPans
=
(
node
:
TreeDataNode
)
=>
{
for
(
let
item
of
tabs
?.
panes
!
)
{
if
(
item
.
key
==
node
.
taskId
)
{
return
true
;
}
}
return
false
;
}
const
toOpen
=
(
node
:
TreeDataNode
|
undefined
)
=>
{
if
(
!
available
)
{
return
}
setAvailable
(
false
);
setTimeout
(()
=>
{
setAvailable
(
true
);
},
200
);
if
(
node
?.
isLeaf
&&
node
.
taskId
)
{
for
(
let
item
of
tabs
.
panes
)
{
if
(
item
.
key
==
node
.
taskId
)
{
dispatch
&&
dispatch
({
type
:
"Studio/saveToolHeight"
,
payload
:
toolHeight
-
0.0001
,
});
dispatch
&&
dispatch
({
type
:
"Studio/changeActiveKey"
,
payload
:
node
.
taskId
,
});
return
;
}
if
(
checkInPans
(
node
))
{
activeTabCall
(
node
);
return
;
}
const
result
=
getInfoById
(
'/api/task'
,
node
.
taskId
);
result
.
then
(
result
=>
{
let
newTabs
=
tabs
;
let
newPane
:
any
=
{
title
:
node
!
.
name
,
key
:
node
!
.
taskId
,
title
:
node
.
name
,
key
:
node
.
taskId
,
value
:
(
result
.
datas
.
statement
?
result
.
datas
.
statement
:
''
),
icon
:
node
!
.
icon
,
icon
:
node
.
icon
,
closable
:
true
,
path
:
node
!
.
path
,
path
:
node
.
path
,
task
:
{
session
:
''
,
maxRowNum
:
100
,
jobName
:
node
!
.
name
,
jobName
:
node
.
name
,
useResult
:
true
,
useChangeLog
:
false
,
useAutoCancel
:
false
,
...
...
@@ -258,7 +270,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
monaco
:
React
.
createRef
(),
metaStore
:
[]
};
newTabs
!
.
activeKey
=
node
!
.
taskId
;
newTabs
!
.
activeKey
=
node
.
taskId
;
if
(
checkInPans
(
node
))
{
return
;
}
newTabs
!
.
panes
!
.
push
(
newPane
);
dispatch
&&
dispatch
({
type
:
"Studio/saveTabs"
,
...
...
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