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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
28 deletions
+44
-28
index.tsx
dlink-web/src/components/Studio/StudioTree/index.tsx
+44
-28
No files found.
dlink-web/src/components/Studio/StudioTree/index.tsx
View file @
91120a64
...
@@ -63,8 +63,8 @@ type RightClickMenu = {
...
@@ -63,8 +63,8 @@ type RightClickMenu = {
//将树形节点改为一维数组
//将树形节点改为一维数组
const
generateList
=
(
data
:
any
,
list
:
any
[])
=>
{
const
generateList
=
(
data
:
any
,
list
:
any
[])
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
const
element
of
data
)
{
const
node
=
data
[
i
]
;
const
node
=
element
;
const
{
name
,
id
,
parentId
,
level
}
=
node
;
const
{
name
,
id
,
parentId
,
level
}
=
node
;
list
.
push
({
name
,
id
,
key
:
id
,
title
:
name
,
parentId
,
level
});
list
.
push
({
name
,
id
,
key
:
id
,
title
:
name
,
parentId
,
level
});
if
(
node
.
children
)
{
if
(
node
.
children
)
{
...
@@ -77,8 +77,8 @@ const generateList = (data: any, list: any[]) => {
...
@@ -77,8 +77,8 @@ const generateList = (data: any, list: any[]) => {
// tree树 匹配方法
// tree树 匹配方法
const
getParentKey
=
(
key
:
number
|
string
,
tree
:
any
):
any
=>
{
const
getParentKey
=
(
key
:
number
|
string
,
tree
:
any
):
any
=>
{
let
parentKey
;
let
parentKey
;
for
(
let
i
=
0
;
i
<
tree
.
length
;
i
++
)
{
for
(
const
element
of
tree
)
{
const
node
=
tree
[
i
]
;
const
node
=
element
;
if
(
node
.
children
)
{
if
(
node
.
children
)
{
if
(
node
.
children
.
some
((
item
:
any
)
=>
item
.
id
===
key
))
{
if
(
node
.
children
.
some
((
item
:
any
)
=>
item
.
id
===
key
))
{
parentKey
=
node
.
id
;
parentKey
=
node
.
id
;
...
@@ -140,8 +140,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -140,8 +140,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const
expandList
:
any
[]
=
generateList
(
treeData
,
[]);
const
expandList
:
any
[]
=
generateList
(
treeData
,
[]);
let
expandedKeys
:
any
=
expandList
.
map
((
item
:
any
)
=>
{
let
expandedKeys
:
any
=
expandList
.
map
((
item
:
any
)
=>
{
if
(
item
&&
item
.
name
.
indexOf
(
value
)
>
-
1
)
{
if
(
item
&&
item
.
name
.
indexOf
(
value
)
>
-
1
)
{
let
key
=
getParentKey
(
item
.
key
,
treeData
);
return
getParentKey
(
item
.
key
,
treeData
);
return
key
;
}
}
return
null
;
return
null
;
})
})
...
@@ -155,11 +154,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -155,11 +154,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
const
result
=
await
getCatalogueTreeData
();
const
result
=
await
getCatalogueTreeData
();
let
data
=
result
.
datas
;
let
data
=
result
.
datas
;
let
list
=
data
;
let
list
=
data
;
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
for
(
const
element
of
list
)
{
list
[
i
].
title
=
list
[
i
]
.
name
;
element
.
title
=
element
.
name
;
list
[
i
].
key
=
list
[
i
]
.
id
;
element
.
key
=
element
.
id
;
if
(
list
[
i
]
.
isLeaf
)
{
if
(
element
.
isLeaf
)
{
list
[
i
].
icon
=
getIcon
(
list
[
i
]
.
type
);
element
.
icon
=
getIcon
(
element
.
type
);
}
}
}
}
data
=
convertToTreeData
(
list
,
0
);
data
=
convertToTreeData
(
list
,
0
);
...
@@ -207,43 +206,56 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -207,43 +206,56 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
setIsUploadModalVisible
(
true
);
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
)
=>
{
const
toOpen
=
(
node
:
TreeDataNode
|
undefined
)
=>
{
if
(
!
available
)
{
if
(
!
available
)
{
return
return
}
}
setAvailable
(
false
);
setAvailable
(
false
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
setAvailable
(
true
);
setAvailable
(
true
);
},
200
);
},
200
);
if
(
node
?.
isLeaf
&&
node
.
taskId
)
{
if
(
node
?.
isLeaf
&&
node
.
taskId
)
{
for
(
let
item
of
tabs
.
panes
)
{
if
(
checkInPans
(
node
))
{
if
(
item
.
key
==
node
.
taskId
)
{
activeTabCall
(
node
);
dispatch
&&
dispatch
({
type
:
"Studio/saveToolHeight"
,
payload
:
toolHeight
-
0.0001
,
});
dispatch
&&
dispatch
({
type
:
"Studio/changeActiveKey"
,
payload
:
node
.
taskId
,
});
return
;
return
;
}
}
}
const
result
=
getInfoById
(
'/api/task'
,
node
.
taskId
);
const
result
=
getInfoById
(
'/api/task'
,
node
.
taskId
);
result
.
then
(
result
=>
{
result
.
then
(
result
=>
{
let
newTabs
=
tabs
;
let
newTabs
=
tabs
;
let
newPane
:
any
=
{
let
newPane
:
any
=
{
title
:
node
!
.
name
,
title
:
node
.
name
,
key
:
node
!
.
taskId
,
key
:
node
.
taskId
,
value
:
(
result
.
datas
.
statement
?
result
.
datas
.
statement
:
''
),
value
:
(
result
.
datas
.
statement
?
result
.
datas
.
statement
:
''
),
icon
:
node
!
.
icon
,
icon
:
node
.
icon
,
closable
:
true
,
closable
:
true
,
path
:
node
!
.
path
,
path
:
node
.
path
,
task
:
{
task
:
{
session
:
''
,
session
:
''
,
maxRowNum
:
100
,
maxRowNum
:
100
,
jobName
:
node
!
.
name
,
jobName
:
node
.
name
,
useResult
:
true
,
useResult
:
true
,
useChangeLog
:
false
,
useChangeLog
:
false
,
useAutoCancel
:
false
,
useAutoCancel
:
false
,
...
@@ -258,7 +270,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -258,7 +270,11 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
monaco
:
React
.
createRef
(),
monaco
:
React
.
createRef
(),
metaStore
:
[]
metaStore
:
[]
};
};
newTabs
!
.
activeKey
=
node
!
.
taskId
;
newTabs
!
.
activeKey
=
node
.
taskId
;
if
(
checkInPans
(
node
))
{
return
;
}
newTabs
!
.
panes
!
.
push
(
newPane
);
newTabs
!
.
panes
!
.
push
(
newPane
);
dispatch
&&
dispatch
({
dispatch
&&
dispatch
({
type
:
"Studio/saveTabs"
,
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