wangrong
2026-08-30 761e5c5fa871959f60e15c971c8d83f2b53d0af5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<script lang="ts" setup>
import { ref, reactive, nextTick } from 'vue'
import { XpackComponent } from '@/components/plugin'
import { cloneDeep } from 'lodash-es'
import {
  getDatasourceRelationship as getDatasourceRelation,
  getDatasetRelationship as getDatasetRelation
} from '@/api/relation/index'
const relationDrawer = ref(false)
const chartSize = reactive({
  height: 0,
  width: 0
})
const getChartSize = () => {
  const dom = document.querySelector('.relation-drawer_content')
  if (!dom) return
  Object.assign(chartSize, {
    height: dom.offsetHeight + 'px',
    width: dom.offsetWidth + 'px'
  })
}
 
const consanguinity = ref()
let resRef = null
const getDatasourceRelationship = id => {
  getDatasourceRelation(id)
    .then(res => {
      resRef = cloneDeep(res || {})
    })
    .finally(() => {
      tableLoading.value = false
      nextTick(() => {
        consanguinity.value.invokeMethod({
          methodName: 'getChartData',
          args: {
            info: current,
            res: resRef
          }
        })
      })
    })
}
const getDatasetRelationship = id => {
  getDatasetRelation(id)
    .then(res => {
      resRef = cloneDeep(res || {})
    })
    .finally(() => {
      tableLoading.value = false
      nextTick(() => {
        consanguinity.value.invokeMethod({
          methodName: 'getChartData',
          args: {
            info: current,
            res: resRef
          }
        })
      })
    })
}
 
const current = {
  queryType: '',
  num: '',
  label: ''
}
const tableLoading = ref(false)
const getChartData = obj => {
  Object.assign(current, obj || {})
  const { queryType, num } = current
  tableLoading.value = true
  relationDrawer.value = true
  nextTick(() => {
    getChartSize()
    switch (queryType) {
      case 'datasource':
        getDatasourceRelationship(num)
        break
      case 'dataset':
        getDatasetRelationship(num)
        break
      default:
        break
    }
  })
}
 
defineExpose({
  getChartData
})
</script>
 
<template>
  <el-drawer
    title="血缘关系图"
    v-model="relationDrawer"
    modal-class="de-relation-drawer"
    size="1200px"
    direction="rtl"
  >
    <div v-loading="tableLoading" class="relation-drawer_content">
      <XpackComponent
        ref="consanguinity"
        :chart-size="chartSize"
        :current="current"
        detailDisabled
        jsname="L21lbnUvc3lzdGVtL2Fzc29jaWF0aW9uL0NoYXJ0"
      />
    </div>
  </el-drawer>
</template>
 
<style lang="less">
.de-relation-drawer {
  .ed-drawer__body {
    padding-bottom: 24px;
  }
  .relation-drawer_content {
    border: 1px solid #dee0e3;
    width: 100%;
    height: 100%;
    background: #f5f6f7;
    border-radius: 4px;
    position: relative;
  }
}
</style>