hanbaoshan
2020-10-15 5d3fe5712f60fec872870e0b1a3162c72466ab05
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
128
129
130
131
132
<template>
  <div class="cloud">
    <div class="inner">
      <div class="rect">
        <div
          class="node"
          v-for="(item,index) in insideNodes"
          :key="item.id"
          :style="{top:36*(index+1)+'px',left:60*(index+1)+'px'}"
        >
          <span class="node-icon">
            <!-- <img :src="nodeIcons[item.workType]" alt=""> -->
          </span>
          <span class="node-name">{{item.nodeName}}</span>
        </div>
      </div>
    </div>
    <div class="outer">
      <div
        class="node"
        v-for="(item,index) in insideNodes"
        :key="item.id"
        :style="{top:36*(index+1)+'px',left:80*(index+1)+'px'}"
      >
        <span class="node-icon">
          <!-- <img :src="nodeIcons[item.workType]" alt=""> -->
        </span>
        <span class="node-name">{{item.nodeName}}</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'cloudNode',
  props: {
    nodes: Array
  },
  data () {
    return {
 
      nodeIcons: [],
      mockData: [
        {
          cluster_id: "b6132bfe-d3af-4710-ba89-436f614c2f46",
          hardwareType: "01",
          id: "DSVAD010120190622",
          node_id: "DSVAD010120190622",
          node_ip: "192.168.20.10:30190",
          nodeName: "开发20.10-1",
          role: 'pc'
        },
        {
          cluster_id: "b6132bfe-d3af-4710-ba89-436f614c2f",
          hardwareType: "02",
          id: "DSVAD010120190623",
          node_id: "DSVAD010120190623",
          node_ip: "192.168.20.10:30190",
          nodeName: "开发测试20.10-1",
          role: 'master'
        },
        {
          cluster_id: "b6132bfe-d3af-4710-ba89-436f614c2g",
          hardwareType: "03",
          id: "DSVAD010120190624",
          node_id: "DSVAD010120190624",
          node_ip: "192.168.20.10:30190",
          nodeName: "测试20.10-1",
          role: 'pc'
        },
        {
          cluster_id: "b6132bfe-d3af-4710-ba89-436f614c2h",
          hardwareType: "03",
          id: "DSVAD010120190625",
          node_id: "DSVAD010120190625",
          node_ip: "192.168.20.10:30190",
          nodeName: "测试20.101-1",
          role: 'server'
        },
      ]
    }
  },
  computed: {
    cloudPic () {
      return '/images/settings/cloud.png'
    },
    insideNodes () {
      //return this.nodes.filter(item=>item.hardwareType=='01'||item.hardwareType=='02');
      return this.mockData.filter(item => item.hardwareType == '01' || item.hardwareType == '02');
    },
    outsideNodes () {
      //return this.nodes.filter(item=>item.hardwareType=='03');
      return this.mockData.filter(item => item.hardwareType == '03');
    }
  }
}
</script>
<style lang="scss">
.cloud {
  width: 100%;
  height: 500px;
  display: flex;
  .inner {
    background: url('/images/settings/cloud.png') no-repeat;
    background-size: 100%;
    width: 50%;
    .rect {
      margin: 100px;
      background: cornflowerblue;
      position: relative;
      .node {
        position: absolute;
        .node-icon {
          width: 40px;
          height: 40px;
        }
        .node-name {
          font-size: 14px;
          color: #333;
        }
      }
    }
  }
  .outer {
    width: 50%;
    position: relative;
    .node {
      position: absolute;
    }
  }
}
</style>