index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <script setup>
  2. import { ref } from 'vue';
  3. import { ElMessage, ElTooltip } from 'element-plus';
  4. // 井盖设备数据
  5. const manholeCovers = ref([]);
  6. // 加载井盖设备数据
  7. function loadManholeCovers() {
  8. // 假设这是从后端获取的数据
  9. const sampleData = [
  10. {
  11. id: 1,
  12. name: '井盖1',
  13. location: [800, 300], // 图像上的坐标
  14. status: 'normal',
  15. ownership: '市政公司A',
  16. terminalStatus: 'online',
  17. imageUrl: 'https://via.placeholder.com/150',
  18. },
  19. {
  20. id: 2,
  21. name: '井盖2',
  22. location: [700, 200], // 图像上的坐标
  23. status: 'abnormal',
  24. abnormalType: '倾斜',
  25. ownership: '市政公司B',
  26. terminalStatus: 'offline',
  27. imageUrl: 'https://via.placeholder.com/150',
  28. },
  29. ];
  30. manholeCovers.value = sampleData;
  31. }
  32. // 初始化
  33. loadManholeCovers();
  34. // 计算统计信息
  35. const totalCovers = computed(() => manholeCovers.value.length);
  36. const normalCovers = computed(() => manholeCovers.value.filter(cover => cover.status === 'normal').length);
  37. const abnormalCovers = computed(() => manholeCovers.value.filter(cover => cover.status === 'abnormal').length);
  38. const totalTerminals = computed(() => manholeCovers.value.length); // 每个井盖都有一个终端
  39. const onlineTerminals = computed(() => manholeCovers.value.filter(cover => cover.terminalStatus === 'online').length);
  40. const offlineTerminals = computed(() => manholeCovers.value.filter(cover => cover.terminalStatus === 'offline').length);
  41. // 批量下发离线维护任务
  42. function sendMaintenanceTasks() {
  43. // 模拟批量下发离线维护任务
  44. manholeCovers.value.forEach(cover => {
  45. if (cover.terminalStatus === 'offline') {
  46. cover.terminalStatus = 'maintenance'; // 设置为维护状态
  47. }
  48. });
  49. ElMessage.success('离线维护任务已成功下发!');
  50. }
  51. </script>
  52. <template>
  53. <div class="manhole-cover-overview">
  54. <div class="statistics-panel">
  55. <div>井盖设备总数: {{ totalCovers }}</div>
  56. <div>正常数: {{ normalCovers }}</div>
  57. <div>异常数: {{ abnormalCovers }}</div>
  58. <div>智能终端总数: {{ totalTerminals }}</div>
  59. <div>在线数: {{ onlineTerminals }}</div>
  60. <div>离线数: {{ offlineTerminals }}</div>
  61. <el-button type="primary" @click="sendMaintenanceTasks">批量下发离线维护任务</el-button>
  62. </div>
  63. <!-- 地图背景图 -->
  64. <img src="/map.jpg" alt="地图" class="map-image" />
  65. <!-- 井盖设备图标 -->
  66. <div
  67. v-for="(cover, index) in manholeCovers"
  68. :key="index"
  69. :class="['manhole-cover-icon', { 'status-normal': cover.status === 'normal', 'status-abnormal': cover.status === 'abnormal' }]"
  70. :style="{ left: `${cover.location[0]}px`, top: `${cover.location[1]}px` }"
  71. >
  72. <el-tooltip effect="dark" placement="top">
  73. <template #content>
  74. <div>
  75. <strong>{{ cover.name }}</strong><br>
  76. <span>位置: {{ cover.location.join(', ') }}</span><br>
  77. <span>状态: {{ cover.status === 'normal' ? '正常' : cover.abnormalType }}</span><br>
  78. <span>所属权属单位: {{ cover.ownership }}</span><br>
  79. <span>终端状态: {{ cover.terminalStatus === 'online' ? '在线' : '离线' }}</span><br>
  80. <img :src="cover.imageUrl" alt="井盖图片" width="100">
  81. </div>
  82. </template>
  83. <i class="el-icon-location"></i>
  84. </el-tooltip>
  85. </div>
  86. </div>
  87. </template>
  88. <style scoped>
  89. .manhole-cover-overview {
  90. position: relative;
  91. width: 100%;
  92. height: 500px;
  93. }
  94. .map-image {
  95. position: absolute;
  96. width: 100%;
  97. height: 100%;
  98. object-fit: cover;
  99. }
  100. .manhole-cover-icon {
  101. position: absolute;
  102. cursor: pointer;
  103. width: 30px;
  104. height: 30px;
  105. background-color: #f00;
  106. border-radius: 50%;
  107. }
  108. .status-normal {
  109. background-color: green;
  110. }
  111. .status-abnormal {
  112. background-color: red;
  113. }
  114. /* 为 Tooltip 添加样式 */
  115. .el-icon-location {
  116. display: block;
  117. width: 30px;
  118. height: 30px;
  119. line-height: 30px;
  120. text-align: center;
  121. color: white;
  122. font-size: 16px;
  123. }
  124. .statistics-panel {
  125. position: absolute;
  126. top: 10px;
  127. left: 0px;
  128. padding: 10px;
  129. background-color: #fff;
  130. border: 1px solid #ccc;
  131. border-radius: 5px;
  132. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  133. }
  134. </style>