Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
liangzhen
/
framework-tools-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 07dca79f
authored
Apr 30, 2024
by
史敦盼
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sdp-v1'
2 parents
ea7fd6c3
a6e63745
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
306 additions
and
11 deletions
src/store/modules/graphData.js
src/views/dataMapping/index.vue
src/views/dataMapping/mixins/microservicesGraph.mixin.js
src/views/dataMapping/mixins/safeManagementGraph.mixin.js
src/store/modules/graphData.js
View file @
07dca79
...
...
@@ -6,6 +6,13 @@ const state = {
techFrameMiddleData
:
[],
techFrameRightData
:
{},
},
// 技术框架视图数据
safeManagementGraphData
:
{
safeTopData
:
{},
safeMidLeftData
:
{},
safeMidCenterData
:
{},
safeMidRightData
:
{},
safeBottomData
:
{},
},
// 安全管理体系视图
}
const
mutations
=
{
CHANGE_GRAPH_DATA
:
(
state
,
data
)
=>
{
...
...
@@ -17,6 +24,9 @@ const mutations = {
CHANGE_TECH_FRAME_DATA
:
(
state
,
data
)
=>
{
state
.
technicalFrameworkGraphData
=
data
},
CHANGE_SAFE_MANAGEMENT_DATA
:
(
state
,
data
)
=>
{
state
.
safeManagementGraphData
=
data
},
}
export
default
{
namespaced
:
true
,
...
...
src/views/dataMapping/index.vue
View file @
07dca79
...
...
@@ -4,7 +4,7 @@
* @Autor: pan
* @Date: 2024-04-23 11:30:05
* @LastEditors: pan
* @LastEditTime: 2024-04-30 1
1:19:44
* @LastEditTime: 2024-04-30 1
6:26:56
-->
<
template
>
<div
class=
"dataMapping w-100"
>
...
...
@@ -325,10 +325,53 @@ export default {
case
'4'
:
this
.
handleTechFrameGraph
()
break
case
'5'
:
this
.
handleSafeManageGraph
()
break
default
:
break
}
},
// 安全管理体系视图
handleSafeManageGraph
()
{
const
checkedNodes
=
this
.
$refs
.
tree
.
getCheckedNodes
()
let
parentNodes
=
checkedNodes
.
filter
((
v
)
=>
v
.
parentId
===
'0'
)
console
.
log
(
'e'
,
parentNodes
)
const
childNodes
=
checkedNodes
.
filter
((
v
)
=>
v
.
parentId
!==
'0'
)
this
.
handleGraphData
(
parentNodes
,
childNodes
)
const
layoutList
=
[{
name
:
'安全管理原则'
,
key
:
'safeTopData'
},{
name
:
'安全监督'
,
key
:
'safeMidLeftData'
},{
name
:
'安全管理'
,
key
:
'safeMidCenterData'
},
{
name
:
'制度规范'
,
key
:
'safeMidRightData'
},{
name
:
'工作机制'
,
key
:
'safeBottomData'
}]
let
graphData
=
{
safeTopData
:
{},
safeMidLeftData
:
{},
safeMidCenterData
:
{},
safeMidRightData
:
{},
safeBottomData
:
{}
}
layoutList
.
forEach
(
v
=>
{
const
idx
=
parentNodes
.
findIndex
(
v2
=>
v2
.
assetName
===
v
.
name
)
if
(
idx
!==
-
1
)
{
graphData
[
v
.
key
]
=
parentNodes
[
idx
];
}
})
this
.
$store
.
commit
(
'graphData/CHANGE_SAFE_MANAGEMENT_DATA'
,
graphData
)
this
.
$refs
[
'graph'
].
initSafeManagementGraph
()
console
.
log
(
'graphData'
,
graphData
,
parentNodes
)
},
// 数据主题视图
handleDataTopicGraph
()
{
const
checkedNodes
=
this
.
$refs
.
tree
.
getCheckedNodes
()
...
...
@@ -344,13 +387,13 @@ export default {
const
leftIdx
=
parentNodes
.
findIndex
(
v
=>
v
.
assetName
===
'安全防护'
)
let
techFrameLeftData
=
{}
if
(
leftIdx
!==
-
1
)
{
techFrameLeftData
=
parentNodes
.
splice
(
leftIdx
,
1
)[
0
];
techFrameLeftData
=
parentNodes
[
leftIdx
];
// parentNodes.splice(0, 0, leftElement);
}
const
rightIdx
=
parentNodes
.
findIndex
(
v
=>
v
.
assetName
===
'运行维护'
)
let
techFrameRightData
=
{}
if
(
rightIdx
!==
-
1
)
{
techFrameRightData
=
parentNodes
.
splice
(
rightIdx
,
1
)[
0
];
techFrameRightData
=
parentNodes
[
rightIdx
];
// parentNodes.splice(parentNodes.length, 0, rightElement);
}
// console.log('parentNodes4', parentNodes)
...
...
@@ -430,7 +473,7 @@ export default {
fnGetAutomaticGraphing
()
{
const
params
=
{
archiBelongId
:
this
.
activeName
,
//
parentAssetId: this.activeName === '3' ? '0' : undefined,
parentAssetId
:
this
.
activeName
===
'3'
?
'0'
:
undefined
,
}
getAutomaticGraphing
(
params
).
then
((
res
)
=>
{
if
(
res
.
code
==
200
)
{
...
...
@@ -444,8 +487,8 @@ export default {
},
handleNodeClick
(
data
)
{
const
node
=
this
.
$refs
.
tree
.
getNode
(
data
.
id
)
console
.
log
(
'data'
,
data
)
console
.
log
(
'node'
,
node
)
//
console.log('data', data)
//
console.log('node', node)
this
.
setNode
(
node
)
this
.
tableData
=
[...
this
.
$refs
.
tree
.
getCheckedNodes
(),
...
this
.
addData
]
if
(
!
this
.
tableData
.
length
)
{
...
...
src/views/dataMapping/mixins/microservicesGraph.mixin.js
View file @
07dca79
...
...
@@ -4,7 +4,7 @@
* @Autor: pan
* @Date: 2024-04-30 11:07:22
* @LastEditors: pan
* @LastEditTime: 2024-04-30 1
1:29:41
* @LastEditTime: 2024-04-30 1
4:14:49
*/
const
microservicesGraph
=
{
data
()
{
...
...
@@ -66,6 +66,7 @@ const microservicesGraph = {
maxWidthArr
.
push
(
currentItem
.
width
||
100
)
})
const
maxWidth
=
Math
.
max
(...
maxWidthArr
)
console
.
log
(
'maxWidth'
,
maxWidth
)
var
geometry
=
model
.
getGeometry
(
parent
.
children
[
0
])
let
maxHeightArr
=
[]
allCellData
.
forEach
((
v
,
i
)
=>
{
...
...
@@ -170,7 +171,7 @@ const microservicesGraph = {
},
// 计算cell的x坐标
microservicesGetItemX(item, idx) {
console.log('item', item, idx)
//
console.log('item', item, idx)
if (item.children) {
// return idx * (130 * 3) + 20
const col = (idx + 1) % 3
...
...
@@ -231,9 +232,11 @@ const microservicesGraph = {
for (let index = 0; index < list.length; index++) {
const v = list[index]
if (!v.children) {
// console.log('v', v)
let geometry = this.model.getGeometry(v)
geometry.height = 60
return
geometry.width += 20
// return
}
// console.log('v', v)
let geometry = this.model.getGeometry(v)
...
...
src/views/dataMapping/mixins/safeManagementGraph.mixin.js
View file @
07dca79
...
...
@@ -4,12 +4,47 @@
* @Autor: pan
* @Date: 2024-04-30 10:55:48
* @LastEditors: pan
* @LastEditTime: 2024-04-30 1
0:56:28
* @LastEditTime: 2024-04-30 1
7:53:31
*/
const
safeManagementGraph
=
{
computed
:
{
safeManagementData
()
{
return
this
.
$store
.
state
.
graphData
.
safeManagementGraphData
},
safeTopData
()
{
return
this
.
safeManagementData
.
safeTopData
},
safeMidLeftData
()
{
return
this
.
safeManagementData
.
safeMidLeftData
},
safeMidCenterData
()
{
return
this
.
safeManagementData
.
safeMidCenterData
},
safeMidRightData
()
{
return
this
.
safeManagementData
.
safeMidRightData
},
safeBottomData
()
{
return
this
.
safeManagementData
.
safeBottomData
},
hasSafeTop
()
{
return
Object
.
keys
(
this
.
safeTopData
).
length
},
hasSafeMidLeft
()
{
return
Object
.
keys
(
this
.
safeMidLeftData
).
length
},
hasSafeMidCenter
()
{
return
Object
.
keys
(
this
.
safeMidCenterData
).
length
},
hasSafeMidRight
()
{
return
Object
.
keys
(
this
.
safeMidRightData
).
length
},
hasSafeBottom
()
{
return
Object
.
keys
(
this
.
safeBottomData
).
length
},
},
methods
:
{
init
DataTopic
Graph
()
{
init
SafeManagement
Graph
()
{
const
parent
=
this
.
graph
.
getDefaultParent
()
this
.
graph
.
removeCells
(
this
.
graph
.
getChildVertices
(
parent
))
//清空画布
const
model
=
this
.
graph
.
getModel
()
...
...
@@ -21,6 +56,127 @@ const safeManagementGraph = {
try
{
//设置元素可编辑,不然无法自动布局
this
.
graph
.
setCellsLocked
(
false
)
// 顶部
if
(
this
.
hasSafeTop
)
{
const
topGraph
=
this
.
graph
.
insertVertex
(
parent
,
null
,
this
.
safeTopData
.
name
,
20
,
20
,
100
,
40
,
'html=1;fontColor=#000000;spacing=10;fillColor=#bdd7ee;labelPosition=center;verticalAlign=top;align=center;strokeColor=#000000;'
,
)
if
(
this
.
safeTopData
.
checkChildren
.
length
)
{
this
.
safeTopInsertVertex
(
topGraph
,
this
.
safeTopData
.
checkChildren
)
// 调整父节点宽高
let
geometry
=
model
.
getGeometry
(
topGraph
)
geometry
.
height
+=
20
geometry
.
width
+=
20
model
.
setGeometry
(
topGraph
,
geometry
)
}
}
// 中左
if
(
this
.
hasSafeMidLeft
)
{
let
midLeftY
=
20
+
this
.
getSafeModuleGeo
(
'height'
,
'安全管理原则'
)
const
midLeftGraph
=
this
.
graph
.
insertVertex
(
parent
,
null
,
this
.
safeMidLeftData
.
name
,
20
,
midLeftY
,
100
,
40
,
'html=1;fontColor=#000000;spacing=10;fillColor=#cbd4a8;labelPosition=center;verticalAlign=top;align=center;strokeColor=#000000;'
,
)
if
(
this
.
safeMidLeftData
.
checkChildren
.
length
)
{
this
.
safeMidLeftInsertVertex
(
midLeftGraph
,
this
.
safeMidLeftData
.
checkChildren
,
)
// 调整父节点宽高
let
geometry
=
model
.
getGeometry
(
midLeftGraph
)
geometry
.
height
+=
20
geometry
.
width
+=
20
model
.
setGeometry
(
midLeftGraph
,
geometry
)
}
}
// 中中
if
(
this
.
hasSafeMidCenter
)
{
const
midGraph
=
this
.
graph
.
insertVertex
(
parent
,
null
,
this
.
safeMidCenterData
.
name
,
20
+
this
.
getSafeModuleGeo
(
'width'
,
'安全监督'
),
20
+
this
.
getSafeModuleGeo
(
'height'
,
'安全管理原则'
),
100
,
40
,
'html=1;fontColor=#000000;spacing=10;fillColor=#f4ceae;labelPosition=center;verticalAlign=top;align=center;strokeColor=#000000;'
,
)
if
(
this
.
safeMidCenterData
.
checkChildren
.
length
)
{
this
.
safeMidInsertVertex
(
midGraph
,
this
.
safeMidCenterData
.
checkChildren
,
)
// 调整父节点宽高
let
geometry
=
model
.
getGeometry
(
midGraph
)
geometry
.
height
+=
20
geometry
.
width
+=
20
model
.
setGeometry
(
midGraph
,
geometry
)
}
}
// 中右
if
(
this
.
hasSafeMidRight
)
{
const
midRightX
=
20
+
this
.
getSafeModuleGeo
(
'width'
,
'安全监督'
)
+
this
.
getSafeModuleGeo
(
'width'
,
'安全管理'
)
const
midRightGraph
=
this
.
graph
.
insertVertex
(
parent
,
null
,
this
.
safeMidRightData
.
name
,
midRightX
,
20
+
this
.
getSafeModuleGeo
(
'height'
,
'安全管理原则'
),
100
,
40
,
'html=1;fontColor=#000000;spacing=10;fillColor=#cbd4a8;labelPosition=center;verticalAlign=top;align=center;strokeColor=#000000;'
,
)
if
(
this
.
safeMidRightData
.
checkChildren
.
length
)
{
this
.
safeMidLeftInsertVertex
(
midRightGraph
,
this
.
safeMidRightData
.
checkChildren
,
)
// 调整父节点宽高
let
geometry
=
model
.
getGeometry
(
midRightGraph
)
geometry
.
height
+=
20
geometry
.
width
+=
20
model
.
setGeometry
(
midRightGraph
,
geometry
)
}
}
// 下
if
(
this
.
hasSafeBottom
)
{
const
maxMidHeight
=
Math
.
max
(
this
.
getSafeModuleGeo
(
'height'
,
'安全监督'
),
this
.
getSafeModuleGeo
(
'height'
,
'安全管理'
),
this
.
getSafeModuleGeo
(
'height'
,
'制度规范'
))
const
bottomY
=
this
.
getSafeModuleGeo
(
'height'
,
'安全管理原则'
)
+
maxMidHeight
+
20
const
bottomGraph
=
this
.
graph
.
insertVertex
(
parent
,
null
,
this
.
safeBottomData
.
name
,
20
,
bottomY
,
100
,
40
,
'html=1;fontColor=#000000;spacing=10;fillColor=#fee599;labelPosition=center;verticalAlign=top;align=center;strokeColor=#000000;'
,
)
if
(
this
.
safeBottomData
.
checkChildren
.
length
)
{
this
.
safeTopInsertVertex
(
bottomGraph
,
this
.
safeBottomData
.
checkChildren
,
)
// 调整父节点宽高
let
geometry
=
model
.
getGeometry
(
bottomGraph
)
geometry
.
height
+=
20
geometry
.
width
+=
20
model
.
setGeometry
(
bottomGraph
,
geometry
)
}
}
}
finally
{
model
.
endUpdate
()
// 获取xml
...
...
@@ -29,6 +185,89 @@ const safeManagementGraph = {
// console.log('node', node)
}
},
/**
* @description: 获取上/中左/中右...宽度/高度
* @param {String} type 'width' or 'height'
* @param {String} moduleName '安全管理原则', '安全监督', '安全管理', '制度规范'
* @return {Number} 宽高值(加上了间距20)
* @author: pan
*/
getSafeModuleGeo
(
type
,
moduleName
)
{
const
parent
=
this
.
graph
.
getDefaultParent
()
const
midLeftGeo
=
parent
.
children
?.
find
(
(
v
)
=>
v
.
value
==
moduleName
,
)
??
{}
if
(
Object
.
keys
(
midLeftGeo
).
length
)
{
const
midLeftGeometry
=
this
.
model
.
getGeometry
(
midLeftGeo
)
return
midLeftGeometry
[
type
]
+
20
}
else
{
return
0
}
},
safeTopInsertVertex
(
node
,
list
)
{
if
(
list
&&
list
.
length
)
{
list
.
forEach
((
v
,
idx
)
=>
{
var
cell
=
this
.
graph
.
insertVertex
(
node
,
null
,
v
.
name
,
idx
*
110
+
20
,
30
,
v
.
checkChildren
?
null
:
100
,
v
.
checkChildren
?
null
:
40
,
`html=1;fontColor=#000000;whiteSpace=wrap;fillColor=#f7f7f7;labelPosition=center;verticalAlign=middle;align=center;strokeColor=#000000;`
,
)
// console.log('cell', cell)
if
(
v
.
checkChildren
&&
v
.
checkChildren
.
length
)
{
this
.
safeTopInsertVertex
(
cell
,
v
.
checkChildren
)
}
})
}
},
safeMidLeftInsertVertex
(
node
,
list
)
{
if
(
list
&&
list
.
length
)
{
list
.
forEach
((
v
,
idx
)
=>
{
this
.
graph
.
insertVertex
(
node
,
null
,
v
.
name
,
20
,
(
idx
+
1
)
*
50
,
v
.
checkChildren
?
null
:
100
,
v
.
checkChildren
?
null
:
40
,
`html=1;fontColor=#000000;whiteSpace=wrap;fillColor=#f7f7f7;labelPosition=center;verticalAlign=middle;align=center;strokeColor=#000000;`
,
)
})
}
},
safeMidInsertVertex
(
node
,
list
)
{
if
(
list
&&
list
.
length
)
{
list
.
forEach
((
v
,
idx
)
=>
{
this
.
graph
.
insertVertex
(
node
,
null
,
v
.
name
,
this
.
safeMidGetItemX
(
v
,
idx
),
this
.
safeMidGetItemY
(
v
,
idx
),
100
,
40
,
`html=1;fontColor=#000000;fillColor=#f7f7f7;labelPosition=center;verticalAlign=middle;align=center;strokeColor=#000000;`
,
)
})
}
},
safeMidGetItemX
(
item
,
idx
)
{
const
col
=
(
idx
+
1
)
%
2
return
col
>
0
?
20
:
140
},
safeMidGetItemY
(
item
,
idx
)
{
const
rows
=
Math
.
ceil
((
idx
+
1
)
/
2
)
if
(
rows
>
1
)
{
return
rows
*
40
+
(
rows
-
1
)
*
20
}
else
{
return
40
}
},
},
}
export
default
safeManagementGraph
Write
Preview
Markdown
is supported
Attach a file
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 post a comment