13306d1e by lihua

修复关系网样式问题

1 parent 5443d7b4
...@@ -392,7 +392,7 @@ export const getMetaStandardField = (guid) => request({ ...@@ -392,7 +392,7 @@ export const getMetaStandardField = (guid) => request({
392 392
393 /** 根据元数据标准展示字段去获取未展示的详情信息 */ 393 /** 根据元数据标准展示字段去获取未展示的详情信息 */
394 export const getMetaStandardFieldDetail = (guid) => request({ 394 export const getMetaStandardFieldDetail = (guid) => request({
395 url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/data/detail?guid=${guid}`, 395 url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/data/convert-detail?guid=${guid}`,
396 method: 'get' 396 method: 'get'
397 }) 397 })
398 398
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
4 <div class="title">{{ detailInfoLabel }}</div> 4 <div class="title">{{ detailInfoLabel }}</div>
5 <div class="row" v-for="item in Object.keys(detailInfo)"> 5 <div class="row" v-for="item in Object.keys(detailInfo)">
6 <span>{{ item + ':' }}</span> 6 <span>{{ item + ':' }}</span>
7 <span>{{ detailInfo[item] == null ? '-' : detailInfo[item] }}</span> 7 <span>{{ detailInfo[item] == null ? '-' : detailInfo[item] }}</span>
8 </div> 8 </div>
9 </div> 9 </div>
10 </div> 10 </div>
...@@ -51,11 +51,11 @@ const containerRef = ref(); ...@@ -51,11 +51,11 @@ const containerRef = ref();
51 51
52 const graphRef = ref(); 52 const graphRef = ref();
53 53
54 const resizeObserver = ref();
55
56 watch(() => props.treeData, (val) => { 54 watch(() => props.treeData, (val) => {
57 if (!graphRef.value && val?.guid) { 55 if (!graphRef.value && val?.guid) {
58 initGraph(); 56 nextTick(() => {
57 initGraph();
58 })
59 return; 59 return;
60 } 60 }
61 if (!graphRef.value) { 61 if (!graphRef.value) {
...@@ -82,7 +82,7 @@ watch(() => props.treeData, (val) => { ...@@ -82,7 +82,7 @@ watch(() => props.treeData, (val) => {
82 82
83 const renderGraph = (graph: any, lineageData: any) => { 83 const renderGraph = (graph: any, lineageData: any) => {
84 if (!graph || !lineageData) return; 84 if (!graph || !lineageData) return;
85 graph.setMinZoom(0.5); 85 graph.setMinZoom(0.7);
86 graph.setMaxZoom(1); 86 graph.setMaxZoom(1);
87 graph.data(lineageData); 87 graph.data(lineageData);
88 graph.render(); 88 graph.render();
...@@ -120,7 +120,7 @@ const detectLanguage = (text) => { ...@@ -120,7 +120,7 @@ const detectLanguage = (text) => {
120 120
121 const handleLabelLength = (label: string) => { 121 const handleLabelLength = (label: string) => {
122 if (detectLanguage(label) == 'English') { 122 if (detectLanguage(label) == 'English') {
123 return label?.length > maxEnglishCount.value ? label.slice(0, maxEnglishCount.value) + '...' : label; 123 return label?.length > maxEnglishCount.value ? label.slice(0, maxEnglishCount.value) + '...' : label;
124 } 124 }
125 return label?.length > maxChineseCount.value ? label.slice(0, maxChineseCount.value) + '...' : label; 125 return label?.length > maxChineseCount.value ? label.slice(0, maxChineseCount.value) + '...' : label;
126 }; 126 };
...@@ -230,11 +230,12 @@ const initGraph = () => { ...@@ -230,11 +230,12 @@ const initGraph = () => {
230 container: container, 230 container: container,
231 width, 231 width,
232 height, 232 height,
233 // animate: false,
233 plugins: [contextMenu, tooltip.value], 234 plugins: [contextMenu, tooltip.value],
234 fitCenter: true, 235 fitCenter: true,
235 fitView: true, 236 fitView: true,
236 fitViewPadding: 40, 237 fitViewPadding: 40,
237 minZoom: 0.5, 238 minZoom: 0.7,
238 maxZoom: 1, 239 maxZoom: 1,
239 modes: { 240 modes: {
240 default: [ 241 default: [
...@@ -286,7 +287,7 @@ const initGraph = () => { ...@@ -286,7 +287,7 @@ const initGraph = () => {
286 return 16; 287 return 16;
287 }, 288 },
288 getVGap: function getVGap() { 289 getVGap: function getVGap() {
289 return 30; 290 return 25;
290 }, 291 },
291 getHGap: function getHGap() { 292 getHGap: function getHGap() {
292 return 120; 293 return 120;
...@@ -336,7 +337,7 @@ onMounted(() => { ...@@ -336,7 +337,7 @@ onMounted(() => {
336 }) 337 })
337 338
338 const observeResize = () => { 339 const observeResize = () => {
339 resizeObserver.value = new ResizeObserver(() => { 340 window.addEventListener('resize', (e) => {
340 let domWidth = document.documentElement.clientWidth; 341 let domWidth = document.documentElement.clientWidth;
341 if (lastSelectNode.value) { 342 if (lastSelectNode.value) {
342 tooltip1Ref.value.style.display = 'none'; 343 tooltip1Ref.value.style.display = 'none';
...@@ -363,7 +364,7 @@ const observeResize = () => { ...@@ -363,7 +364,7 @@ const observeResize = () => {
363 return; 364 return;
364 } 365 }
365 graphRef.value.changeSize(width, height); 366 graphRef.value.changeSize(width, height);
366 graphRef.value.setMinZoom(0.5); 367 graphRef.value.setMinZoom(0.7);
367 graphRef.value.setMaxZoom(1); 368 graphRef.value.setMaxZoom(1);
368 graphRef.value.fitView(40, { direction: 'both' }); 369 graphRef.value.fitView(40, { direction: 'both' });
369 graphRef.value.fitCenter(); 370 graphRef.value.fitCenter();
...@@ -379,14 +380,13 @@ const observeResize = () => { ...@@ -379,14 +380,13 @@ const observeResize = () => {
379 return; 380 return;
380 } 381 }
381 graphRef.value.changeSize(width, height); 382 graphRef.value.changeSize(width, height);
382 graphRef.value.setMinZoom(0.5); 383 graphRef.value.setMinZoom(0.7);
383 graphRef.value.setMaxZoom(1); 384 graphRef.value.setMaxZoom(1);
384 graphRef.value.fitView(40, { direction: 'both' }); 385 graphRef.value.fitView(40, { direction: 'both' });
385 graphRef.value.fitCenter(); 386 graphRef.value.fitCenter();
386 graphRef.value.setMinZoom(0.5); 387 graphRef.value.setMinZoom(0.5);
387 graphRef.value.setMaxZoom(5); 388 graphRef.value.setMaxZoom(5);
388 }); 389 });
389 resizeObserver.value.observe(containerRef.value);
390 } 390 }
391 391
392 392
......
...@@ -81,7 +81,7 @@ const getSankeyDataList = () => { ...@@ -81,7 +81,7 @@ const getSankeyDataList = () => {
81 81
82 const handleNodeItemClick = (graph, nodeItem) => { 82 const handleNodeItemClick = (graph, nodeItem) => {
83 const nodeId = nodeItem.get('id'); 83 const nodeId = nodeItem.get('id');
84 const parentData = graph.findDataById(nodeId); 84 let parentData = graph.findDataById(nodeId);
85 if (!parentData.children) { 85 if (!parentData.children) {
86 parentData.children = []; 86 parentData.children = [];
87 } 87 }
...@@ -89,10 +89,15 @@ const handleNodeItemClick = (graph, nodeItem) => { ...@@ -89,10 +89,15 @@ const handleNodeItemClick = (graph, nodeItem) => {
89 ElMessage.warning('没有可展开的下级字段'); 89 ElMessage.warning('没有可展开的下级字段');
90 return; 90 return;
91 } 91 }
92 // graph.updateConfig({ animate: false });
93 // graph.refresh();
94 nodeItem.getModel().collapsed = false;
95 parentData.collapsed = false;
92 graphDataLoading.value = true; 96 graphDataLoading.value = true;
93 getMetaStandardField(nodeId).then((res: any) => { 97 getMetaStandardField(nodeId).then((res: any) => {
94 graphDataLoading.value = false; 98 graphDataLoading.value = false;
95 if (res?.code == proxy.$passCode) { 99 if (res?.code == proxy.$passCode) {
100 parentData = graph.findDataById(nodeId);
96 const data = res.data || []; 101 const data = res.data || [];
97 parentData.children = []; 102 parentData.children = [];
98 if (!data?.length) { 103 if (!data?.length) {
...@@ -103,13 +108,27 @@ const handleNodeItemClick = (graph, nodeItem) => { ...@@ -103,13 +108,27 @@ const handleNodeItemClick = (graph, nodeItem) => {
103 data.forEach(d => { 108 data.forEach(d => {
104 parentData.children.push(d); 109 parentData.children.push(d);
105 }) 110 })
111 parentData.isLoading = false;
112 nodeItem.getModel().collapsed = false;
106 parentData.collapsed = false; 113 parentData.collapsed = false;
114 graph.updateItem(nodeItem, {
115 ...nodeItem.getModel(),
116 collapsed: false
117 });
118 graph.layout();
107 setTimeout(() => { 119 setTimeout(() => {
108 parentData.isLoading = false; 120 // graph.updateConfig({ animate: true });
121 // graph.refresh();
122 graph.updateItem(nodeItem, {
123 ...nodeItem.getModel(),
124 collapsed: false
125 });
126 graph.setMinZoom(1);
109 graph.setMaxZoom(1); 127 graph.setMaxZoom(1);
110 graph.changeData(graphTreeData.value); 128 graph.layout();
129 graph.setMinZoom(0.5);
111 graph.setMaxZoom(5); 130 graph.setMaxZoom(5);
112 }, 100); 131 }, 500);
113 } else { 132 } else {
114 parentData.isLoading = false; 133 parentData.isLoading = false;
115 ElMessage.error(res.msg); 134 ElMessage.error(res.msg);
...@@ -123,7 +142,22 @@ onBeforeMount(() => { ...@@ -123,7 +142,22 @@ onBeforeMount(() => {
123 graphDataLoading.value = false; 142 graphDataLoading.value = false;
124 if (res?.code == proxy.$passCode) { 143 if (res?.code == proxy.$passCode) {
125 const data = res.data || []; 144 const data = res.data || [];
126 graphTreeData.value = data?.[0] || {}; 145 let resultData = data?.[0] || {};
146 if (!resultData?.children?.length && resultData.isHaveData == 'Y') {
147 graphDataLoading.value = true;
148 getMetaStandardField(resultData.guid).then((res: any) => {
149 graphDataLoading.value = false;
150 if (res?.code == proxy.$passCode) {
151 resultData.children = res.data || [];
152 graphTreeData.value = resultData;
153 } else {
154 graphTreeData.value = resultData;
155 ElMessage.error(res.msg);
156 }
157 });
158 } else {
159 graphTreeData.value = resultData;
160 }
127 } else { 161 } else {
128 ElMessage.error(res.msg); 162 ElMessage.error(res.msg);
129 } 163 }
......
...@@ -191,13 +191,20 @@ const handleNodeItemClick = (graph, nodeItem) => { ...@@ -191,13 +191,20 @@ const handleNodeItemClick = (graph, nodeItem) => {
191 data.forEach(d => { 191 data.forEach(d => {
192 parentData.children.push(d); 192 parentData.children.push(d);
193 }) 193 })
194 parentData.isLoading = false;
194 parentData.collapsed = false; 195 parentData.collapsed = false;
196 graph.layout();
195 setTimeout(() => { 197 setTimeout(() => {
196 parentData.isLoading = false; 198 graph.updateItem(nodeItem, {
199 ...nodeItem.getModel(),
200 collapsed: false
201 });
202 graph.setMinZoom(1);
197 graph.setMaxZoom(1); 203 graph.setMaxZoom(1);
198 graph.changeData(lastClickNode.value); 204 graph.layout();
205 graph.setMinZoom(0.5);
199 graph.setMaxZoom(5); 206 graph.setMaxZoom(5);
200 }, 100); 207 }, 500);
201 } else { 208 } else {
202 parentData.isLoading = false; 209 parentData.isLoading = false;
203 ElMessage.error(res.msg); 210 ElMessage.error(res.msg);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!