RegionTree.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div id="DeviceTree">
  3. <div class="page-header" style="margin-bottom: 1rem">
  4. <div class="page-title">行政区划</div>
  5. <div class="page-header-btn">
  6. <div style="display: inline;">
  7. <el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
  8. prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
  9. </div>
  10. </div>
  11. </div>
  12. <vue-easy-tree
  13. ref="veTree"
  14. node-key="id"
  15. height="72vh"
  16. style="height: 78vh"
  17. :loadNode="loadNode"
  18. :data="treeData"
  19. :props="props"
  20. ></vue-easy-tree>
  21. </div>
  22. </template>
  23. <script>
  24. import VueEasyTree from "@wchbrad/vue-easy-tree";
  25. let treeData = []
  26. export default {
  27. name: 'DeviceTree',
  28. components: {
  29. VueEasyTree
  30. },
  31. data() {
  32. return {
  33. props: {
  34. label: "name",
  35. },
  36. treeData: [],
  37. }
  38. },
  39. props: ['edit', 'clickEvent', 'contextMenuEvent'],
  40. created() {
  41. this.$axios({
  42. method: 'get',
  43. url: `/api/region/tree/list`,
  44. }).then((res)=> {
  45. if (res.data.code === 0) {
  46. this.treeData.push(res.data.data)
  47. }
  48. }).catch(function (error) {
  49. console.log(error);
  50. });
  51. },
  52. methods: {
  53. onClick(evt, treeId, treeNode) {
  54. },
  55. onCheck(evt, treeId, treeNode) {
  56. },
  57. handleCreated(ztreeObj) {
  58. },
  59. handleNodeClick(data, node, element) {
  60. let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
  61. if (typeof (this.clickEvent) == "function") {
  62. this.clickEvent(deviceNode.data.userData, data.userData, data.type === 2)
  63. }
  64. },
  65. handleContextMenu(event, data, node, element) {
  66. console.log("右键点击事件")
  67. let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
  68. if (typeof (this.contextMenuEvent) == "function") {
  69. this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
  70. }
  71. },
  72. loadNode: function (node, resolve) {
  73. console.log(node)
  74. if (node.level === 0) {
  75. } else {
  76. }
  77. },
  78. channelDataHandler: function (data, resolve) {
  79. if (data.length > 0) {
  80. let nodeList = []
  81. for (let i = 0; i < data.length; i++) {
  82. let item = data[i];
  83. let type = 3;
  84. if (item.id.length <= 10) {
  85. type = 2;
  86. } else {
  87. if (item.id.length > 14) {
  88. let channelType = item.id.substring(10, 13)
  89. console.log("channelType: " + channelType)
  90. if (channelType === '215' || channelType === '216') {
  91. type = 2;
  92. }
  93. console.log(type)
  94. if (item.basicData.ptzType === 1) { // 1-球机;2-半球;3-固定枪机;4-遥控枪机
  95. type = 4;
  96. } else if (item.basicData.ptzType === 2) {
  97. type = 5;
  98. } else if (item.basicData.ptzType === 3 || item.basicData.ptzType === 4) {
  99. type = 6;
  100. }
  101. } else {
  102. if (item.basicData.subCount > 0 || item.basicData.parental === 1) {
  103. type = 2;
  104. }
  105. }
  106. }
  107. let node = {
  108. name: item.name || item.basicData.channelId,
  109. isLeaf: type !== 2,
  110. id: item.id,
  111. deviceId: item.deviceId,
  112. type: type,
  113. online: item.basicData.status === 1,
  114. hasGPS: item.basicData.longitude * item.basicData.latitude !== 0,
  115. userData: item.basicData
  116. }
  117. nodeList.push(node);
  118. }
  119. resolve(nodeList)
  120. } else {
  121. resolve([])
  122. }
  123. },
  124. reset: function () {
  125. this.$forceUpdate();
  126. }
  127. },
  128. destroyed() {
  129. // if (this.jessibuca) {
  130. // this.jessibuca.destroy();
  131. // }
  132. // this.playing = false;
  133. // this.loaded = false;
  134. // this.performance = "";
  135. },
  136. }
  137. </script>
  138. <style>
  139. .device-tree-main-box {
  140. text-align: left;
  141. }
  142. .device-online {
  143. color: #252525;
  144. }
  145. .device-offline {
  146. color: #727272;
  147. }
  148. </style>