basicInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <div id="treedom4">
  3. <div style="position: relative">
  4. <div class="nav" id="topLine">
  5. <div class="nav-cont" v-for="(item, index) in navList" :key="index">
  6. <img :src="cylinder" alt="" class="nav-img" />
  7. <div>{{ item.attr_name }}</div>
  8. <div class="describe-text">{{ `(${item.attr_desc})` }}</div>
  9. </div>
  10. </div>
  11. </div>
  12. <div class="wrapper">
  13. <div class="grid">
  14. <div class="col fluid" style="margin-left: 20px" id="leftLine">
  15. <div>
  16. <div class="title">M1 (一)</div>
  17. <div>
  18. <span class="decrip">SDFDSF:</span
  19. ><span class="decrip-item">SDFSFF</span>
  20. </div>
  21. </div>
  22. <div class="child-item">
  23. <div class="ldevice">LDevice</div>
  24. <div>
  25. <img :src="legislation" alt="" />
  26. <div class="img-title">SVLD_PROT</div>
  27. <div class="decrip-child">(录波LD)</div>
  28. </div>
  29. <div>
  30. <img :src="legislation" alt="" />
  31. <div class="img-title">SVLD_PROT</div>
  32. </div>
  33. <div>
  34. <img :src="legislation" alt="" />
  35. <div class="img-title">SVLD_PROT</div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="col main-middle" id="middleLine"></div>
  40. <div class="col fluid" style="margin-right: 20px" id="rightLine">
  41. <div>
  42. <div class="title">M1 (一)</div>
  43. <div>
  44. <span class="decrip">SDFDSF:</span
  45. ><span class="decrip-item">SDFSFF</span>
  46. </div>
  47. </div>
  48. <div class="child-item">
  49. <div class="ldevice">LDevice</div>
  50. <div>
  51. <img :src="legislation" alt="" />
  52. <div class="img-title">SVLD_PROT</div>
  53. <div class="decrip-child">(录波LD)</div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="main-bottom" id="bottomLine">
  59. <div v-if="titleName && titleName.length > 0">
  60. <div class="title">
  61. {{ `${titleName[0].name}(${titleName[0].desc})` }}
  62. </div>
  63. <div class="attr-desc">
  64. <div>
  65. <span class="decrip">MAC-Address:</span>
  66. <span class="decrip-item" v-if="!moBottom.address">无</span>
  67. <span v-else>{{ moBottom.address }}</span>
  68. </div>
  69. <div>
  70. <span class="decrip">VLAN-PRIORITY:</span>
  71. <span class="decrip-item" v-if="!moBottom.priority">无</span>
  72. <span v-else>{{ moBottom.priority }}</span>
  73. </div>
  74. <div>
  75. <span class="decrip">APPID:</span>
  76. <span class="decrip-item" v-if="!moBottom.APPID">无</span>
  77. <span v-else>{{ moBottom.APPID }}</span>
  78. </div>
  79. <div>
  80. <span class="decrip">VLAN-ID:</span>
  81. <span class="decrip-item" v-if="!moBottom.vlanId">无</span>
  82. <span v-else>{{ moBottom.vlanId }}</span>
  83. </div>
  84. </div>
  85. <div v-if="mainList" style="margin-bottom: 10px">
  86. <span
  87. v-for="(item, index) in mainList[titleName[0].name].list"
  88. :key="index"
  89. class="circel"
  90. @click="clickCircel(item)"
  91. >{{ index + 1 }}</span
  92. >
  93. </div>
  94. </div>
  95. <div class="child-item" v-if="titleName && titleName.length > 0">
  96. <div class="ldevice">LDevice</div>
  97. <div>
  98. <img :src="legislation" alt="" />
  99. <div class="img-title">SVLD_PROT</div>
  100. <div class="decrip-child">(录波LD)</div>
  101. </div>
  102. <div>
  103. <img :src="legislation" alt="" />
  104. <div class="img-title">SVLD_PROT</div>
  105. </div>
  106. <div>
  107. <img :src="legislation" alt="" />
  108. <div class="img-title">SVLD_PROT</div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div id="wrappers"></div>
  114. </div>
  115. </template>
  116. <script setup>
  117. import { defineProps, onMounted, ref, inject, nextTick, watch } from "vue";
  118. import legislation from "@/assets/image/instruct/legislation.png";
  119. import cylinder from "@/assets/image/instruct/cylinder.png";
  120. import { getNodeList, getNetworkInfo } from "@/api/iedNetwork";
  121. import LeaderLine from "../../../../public/leader-line.min.js";
  122. import AnimEvent from "../../../../public/anim-event.min.js";
  123. import { CloseBold } from "@element-plus/icons-vue";
  124. const props = defineProps({
  125. checkData: {
  126. type: Object,
  127. default: () => {},
  128. },
  129. isOpen: {
  130. type: Boolean,
  131. default: false,
  132. },
  133. });
  134. const scdIdValue = inject("scdId");
  135. const navList = ref(null); //最头部的数据
  136. const mainTitle = ref(null); //每个方框的标题
  137. const moBottom = ref(null); //底部方框所展示的MAC-Address等desc
  138. const moLeft = ref(null); //左侧方框所展示的MAC-Address等desc
  139. const moRight = ref(null); //右侧方框所展示的MAC-Address等desc
  140. const getNav = async () => {
  141. const navRes = await getNodeList({
  142. scd_id: scdIdValue,
  143. pagesize: 10000,
  144. ied_name: props.checkData.ied_name,
  145. name: "DataSet",
  146. });
  147. navList.value = navRes.data;
  148. };
  149. const getMainTitle = async () => {
  150. const mainRes = await getNodeList({
  151. scd_id: scdIdValue,
  152. pagesize: 10000,
  153. ied_name: props.checkData.ied_name,
  154. name: "AccessPoint",
  155. });
  156. mainTitle.value = mainRes.data;
  157. };
  158. const mainList = ref({});
  159. const titleName = ref([]);
  160. //几个方框的数据
  161. const getMainList = async () => {
  162. mainList.value = {};
  163. titleName.value = [];
  164. const newarr = [];
  165. const infoRes = await getNetworkInfo({
  166. scd_id: scdIdValue,
  167. ied_name: props.checkData.ied_name,
  168. });
  169. //处理分类数据
  170. for (let i = 0; i < infoRes.data.length; i++) {
  171. if (infoRes.data[i].address_json != "") {
  172. infoRes.data[i].address_json.replace("MAC-Address", "address");
  173. infoRes.data[i].address_json.replace("VLAN-PRIORITY", "priority");
  174. infoRes.data[i].address_json.replace("VLAN-ID", "vlanId");
  175. infoRes.data[i].address_json = JSON.parse(infoRes.data[i].address_json);
  176. }
  177. let item = infoRes.data[i];
  178. const key = item.ap_name;
  179. newarr.push(key);
  180. if (mainList.value[key] == null) {
  181. mainList.value[key] = {
  182. name: key,
  183. list: [item],
  184. };
  185. } else {
  186. mainList.value[key].list.push(item);
  187. }
  188. }
  189. const newarr2 = [...new Set(newarr)];
  190. //处理表头描述
  191. if (newarr2 && mainTitle.value) {
  192. newarr2.map((item) => {
  193. const descObj = mainTitle.value.find((key) => key.attr_name == item);
  194. if (descObj) {
  195. titleName.value.push({ name: item, desc: descObj.attr_desc });
  196. }
  197. });
  198. }
  199. if (titleName.value.length > 0 && mainList.value) {
  200. moBottom.value =
  201. mainList.value[titleName.value[0].name].list[0].address_json;
  202. console.log("address_json", moBottom.value);
  203. console.log("first", titleName.value, mainList.value);
  204. }
  205. };
  206. //弹窗打开后使得线条在指定区域中
  207. const hiddenLine2 = () => {
  208. const elmWrapper = document.getElementById("wrappers");
  209. // 移动 line
  210. document.body.querySelectorAll("body .leader-line").forEach((node) => {
  211. elmWrapper.appendChild(node);
  212. });
  213. elmWrapper.style.transform = "none";
  214. var rectWrapper = elmWrapper.getBoundingClientRect();
  215. elmWrapper.style.transform = `translate(${
  216. (rectWrapper.left + window.scrollY) * -1
  217. }px, ${(rectWrapper.top + window.scrollX) * -1}px)`;
  218. };
  219. const leaderLines = ref([]); //控制线条显示
  220. //滚动时重定位线条
  221. const newPositionLine2 = () => {
  222. document.getElementById("treedom4").addEventListener(
  223. "scroll",
  224. AnimEvent.add(() => {
  225. leaderLines.value.forEach((line) => {
  226. if (line) {
  227. hiddenLine2();
  228. line.position();
  229. line.positionByWindowResize = false;
  230. }
  231. });
  232. //中间展示图片的
  233. }),
  234. false
  235. );
  236. };
  237. const getLine = () => {
  238. const topDom = document.getElementById("topLine");
  239. const leftDom = document.getElementById("leftLine");
  240. const rightDom = document.getElementById("rightLine");
  241. const bottomDom = document.getElementById("bottomLine");
  242. const middlDom = document.getElementById("middleLine");
  243. let lineStyle = {
  244. color: "#134BEA",
  245. size: 2,
  246. path: "straight",
  247. endPlug: "disc",
  248. startPlug: "disc",
  249. middleLabel: LeaderLine.captionLabel("AccessPoint", {
  250. fontSize: 10,
  251. color: "#7F8EB2",
  252. }),
  253. };
  254. let lineStyleTop = {
  255. ...lineStyle,
  256. middleLabel: LeaderLine.captionLabel({
  257. text: "DataSet",
  258. fontSize: 10,
  259. color: "#7F8EB2",
  260. }),
  261. };
  262. let lineStyleright = {
  263. ...lineStyle,
  264. middleLabel: LeaderLine.captionLabel("AccessPoint", {
  265. fontSize: 10,
  266. color: "#7F8EB2",
  267. }),
  268. };
  269. let lineStylebottom = {
  270. ...lineStyle,
  271. middleLabel: LeaderLine.captionLabel({
  272. text: "AccessPoint",
  273. fontSize: 10,
  274. color: "#7F8EB2",
  275. }),
  276. };
  277. leaderLines.value.push(new LeaderLine(middlDom, topDom, lineStyleTop)); //上面和中间连线
  278. leaderLines.value.push(new LeaderLine(middlDom, rightDom, lineStyleright));
  279. leaderLines.value.push(new LeaderLine(middlDom, bottomDom, lineStylebottom));
  280. leaderLines.value.push(new LeaderLine(leftDom, middlDom, lineStyle));
  281. newPositionLine2();
  282. hiddenLine2();
  283. };
  284. //点击数字
  285. const clickCircel = (item) => {
  286. const data = JSON.stringify(item.address_json);
  287. // data.replace("MAC-Address", "address");
  288. // data.replace("VLAN-PRIORITY", "priority");
  289. // data.replace("VLAN-ID", "vlanId");
  290. moBottom.value = JSON.parse(data);
  291. };
  292. onMounted(() => {
  293. getNav();
  294. getMainTitle();
  295. getMainList();
  296. nextTick(() => {
  297. getLine();
  298. });
  299. });
  300. watch(
  301. () => props.isOpen,
  302. (newValue) => {
  303. nextTick(() => {
  304. if (!newValue) {
  305. removeLine2();
  306. leaderLines.value = [];
  307. } else {
  308. getLine();
  309. }
  310. });
  311. }
  312. );
  313. watch(
  314. () => props.checkData,
  315. (newValue) => {
  316. getNav();
  317. getMainTitle();
  318. getMainList();
  319. nextTick(() => {
  320. getLine();
  321. });
  322. }
  323. );
  324. const removeLine2 = () => {
  325. const elmWrapper = document.getElementById("wrappers");
  326. document.body.querySelectorAll("body .leader-line").forEach((node) => {
  327. elmWrapper.removeChild(node);
  328. });
  329. };
  330. </script>
  331. <style scoped lang="scss">
  332. #treedom4 {
  333. height: 72vh;
  334. overflow-y: auto;
  335. }
  336. .wrapper {
  337. position: relative;
  338. }
  339. .nav {
  340. height: 160px;
  341. background: #f3f5fa;
  342. overflow-y: auto;
  343. border: 2px dashed #a3ade0;
  344. display: flex;
  345. justify-content: start;
  346. flex-wrap: wrap;
  347. position: relative;
  348. margin: 16px;
  349. .nav-img {
  350. width: 30px;
  351. height: 30px;
  352. }
  353. .nav-cont {
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. margin: 8px 0;
  358. flex-basis: 14%;
  359. .describe-text {
  360. color: #134bea;
  361. }
  362. }
  363. }
  364. .main-bottom,
  365. .fluid {
  366. border: 2px dashed #a3ade0;
  367. display: flex;
  368. flex-direction: column;
  369. max-width: 36%;
  370. img {
  371. width: 40px;
  372. height: 40px;
  373. }
  374. .title {
  375. font-size: 16px;
  376. font-weight: bold;
  377. margin: 12px 0;
  378. text-align: center;
  379. }
  380. .attr-desc {
  381. margin: 10px;
  382. }
  383. .decrip {
  384. color: #7484ab;
  385. font-size: 14px;
  386. margin-right: 15px;
  387. width: 130px;
  388. display: inline-block;
  389. }
  390. .decrip-child {
  391. color: #7484ab;
  392. font-size: 14px;
  393. }
  394. .decrip-item {
  395. font-weight: bold;
  396. font-size: 14px;
  397. }
  398. .child-item {
  399. display: flex;
  400. margin: 12px;
  401. flex-wrap: wrap;
  402. border: 1px solid #5182ff;
  403. position: relative;
  404. & > div {
  405. margin: 8px;
  406. }
  407. .ldevice {
  408. position: absolute;
  409. top: -20px;
  410. left: -10px;
  411. padding: 0 4px;
  412. background: #5182ff;
  413. color: white;
  414. border-radius: 10px;
  415. }
  416. }
  417. .img-title {
  418. color: #134bea;
  419. }
  420. }
  421. .circel {
  422. color: #7c58a8;
  423. padding: 0rem 0.4rem;
  424. border: 1px solid #606c93;
  425. border-radius: 1rem;
  426. margin-left: 0.5rem;
  427. cursor: pointer;
  428. }
  429. .Image {
  430. width: 193px;
  431. height: 150px;
  432. }
  433. /* 设置网格布局相关的样式 */
  434. .grid {
  435. display: flex;
  436. flex-wrap: nowrap;
  437. justify-content: space-between;
  438. align-items: center;
  439. margin-top: 50px;
  440. }
  441. .grid > .col {
  442. box-sizing: border-box;
  443. // padding: 10px;
  444. }
  445. /* 设置fixed2样式 */
  446. .main-middle {
  447. width: 160px;
  448. height: 160px;
  449. background: #fff url("~@/assets/image/instruct/network_slices.png") no-repeat
  450. center;
  451. background-size: 160px;
  452. }
  453. /* 设置fluid样式 */
  454. .fluid {
  455. flex-grow: 1;
  456. background-color: #f7f8f8;
  457. }
  458. .main-bottom {
  459. position: absolute;
  460. left: 50%;
  461. transform: translateX(-50%);
  462. margin-top: 40px;
  463. }
  464. </style>