e5b0ff8a by zhaoqian

G6部分整合

1 parent 29473d18
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
12 "lint": "vue-cli-service lint" 12 "lint": "vue-cli-service lint"
13 }, 13 },
14 "dependencies": { 14 "dependencies": {
15 "@antv/g6": "^4.0.2",
15 "axios": "^0.19.0", 16 "axios": "^0.19.0",
16 "core-js": "^2.6.5", 17 "core-js": "^2.6.5",
17 "e-icon-picker": "^1.0.7", 18 "e-icon-picker": "^1.0.7",
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
20 "element-ui": "^2.13.2", 21 "element-ui": "^2.13.2",
21 "file-saver": "^2.0.2", 22 "file-saver": "^2.0.2",
22 "form-making": "^1.2.9", 23 "form-making": "^1.2.9",
24 "insert-css": "^2.0.0",
23 "js-cookie": "^2.2.1", 25 "js-cookie": "^2.2.1",
24 "mockjs": "^1.1.0", 26 "mockjs": "^1.1.0",
25 "screenfull": "^5.0.2", 27 "screenfull": "^5.0.2",
......
1 import request from "@/plugin/axios";
2
3 /**
4 * 历史回溯
5 * @param data
6 * @constructor
7 */
8 export function getLshs(data) {
9 return request({
10 url: "/bg/fwsxbg/lshs",
11 method: "post",
12 data: data,
13 });
14 }
15
1 <template> 1 <template>
2 <div class="">历史回溯</div> 2 <div class="">历史回溯
3 <div id="mountNode"></div>
4 </div>
3 </template> 5 </template>
4 6
5 <script> 7 <script>
8
9 import G6 from '@antv/g6';
10 import insertCss from 'insert-css';
11 import { getLshs } from "./../../../../src/api/fwsxbg";
12
6 export default { 13 export default {
7 name:"", 14 name:"",
8 components:{}, 15 components:{},
9 props:{}, 16 props:{},
10 data(){ 17 data(){
18 insertCss(`
19 .g6-tooltip {
20 border-radius: 6px;
21 font-size: 12px;
22 color: #fff;
23 background-color: #000;
24 padding: 2px 8px;
25 text-align: center;
26 }
27 `);
11 return { 28 return {
29 data : {}
30 }
31 },
32 created(){
33
34 },
35 mounted(){
36 this.getLshsData();
37 },
38 methods: {
39 initG6() {
40 const data = this.data;
41 G6.registerNode(
42 'sql',
43 {
44 drawShape(cfg, group) {
45 const rect = group.addShape('rect', {
46 attrs: {
47 x: -75,
48 y: -25,
49 width: 150,
50 height: 50,
51 radius: 10,
52 stroke: '#5B8FF9',
53 fill: '#C6E5FF',
54 lineWidth: 1,
55 },
56 name: 'rect-shape',
57 });
58 if (cfg.name) {
59 group.addShape('text', {
60 attrs: {
61 text: cfg.name,
62 x: 0,
63 y: 0,
64 fill: '#00287E',
65 fontSize: 14,
66 textAlign: 'center',
67 textBaseline: 'middle',
68 fontWeight: 'bold',
69 },
70 name: 'text-shape',
71 });
72 }
73 return rect;
74 },
75 },
76 'single-node',
77 );
78
79 const container = document.getElementById('mountNode');
80
81 const graph = new G6.Graph({
82 container: 'mountNode',
83 width:1000,
84 height:800,
85 layout: {
86 type: 'dagre',
87 nodesepFunc: (d) => {
88 if (d.id === '3') {
89 return 500;
90 }
91 return 50;
92 },
93 ranksep: 70,
94 controlPoints: true,
95 },
96 defaultNode: {
97 type: 'sql',
98 },
99 defaultEdge: {
100 type: 'polyline',
101 style: {
102 radius: 20,
103 offset: 45,
104 endArrow: true,
105 lineWidth: 2,
106 stroke: '#C2C8D5',
107 },
108 },
109 nodeStateStyles: {
110 selected: {
111 stroke: '#d9d9d9',
112 fill: '#5394ef',
113 },
114 },
115
116 modes: {
117 default: [
118 'drag-canvas',
119 'zoom-canvas',
120 'click-select',
121 {
122 type: 'tooltip',
123 formatText(model) {
124 const cfg = model.conf;
125 const text = [];
126 cfg.forEach((row) => {
127 text.push(row.label + ':' + row.value + '<br>');
128 });
129 return text.join('\n');
130 },
131 offset: 30,
132 },
133 ],
134 },
135 fitView: true,
136 });
137
138 graph.data(data);
139 graph.render();
140
141 if (typeof window !== 'undefined')
142 window.onresize = () => {
143 if (!graph || graph.get('destroyed')) return;
144 if (!container || !container.scrollWidth || !container.scrollHeight) return;
145 graph.changeSize(container.scrollWidth, container.scrollHeight);
146 };
147
148 },
149
150 getLshsData(){
151 let _this = this;
152 const data = {
153 "bsm": "c0818d9e4286b35b8ee9b96d90b522aa",
154 "type": "zd"
155 };
156 getLshs(data).then((res)=>{
157 if(res.code===200){
158 _this.data=res.result;
159 this.initG6();
160 }
161 })
12 } 162 }
13 }, 163 },
14 created(){},
15 mounted(){},
16 methods:{},
17 computed: {}, 164 computed: {},
18 watch: {}, 165 watch: {},
19 } 166 }
20 </script> 167 </script>
21 <style scoped lang="less"> 168 <style scoped lang="less">
169
22 </style> 170 </style>
...\ No newline at end of file ...\ No newline at end of file
......