jcspGIS.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <div class="jcsp-gis-page">
  3. <!-- 左侧浮动面板 -->
  4. <div class="side-panel">
  5. <div class="panel-header">
  6. <span class="panel-title">视频资源分布</span>
  7. </div>
  8. <!-- 图层筛选 -->
  9. <div class="panel-section">
  10. <div class="section-label">图层筛选</div>
  11. <div class="layer-list">
  12. <div class="layer-item" v-for="item in layerOptions" :key="item.value">
  13. <el-checkbox
  14. v-model="layerChecked[item.value]"
  15. @change="onLayerChange"
  16. >
  17. <span class="layer-dot" :style="{ background: item.color }"></span>
  18. {{ item.label }}
  19. </el-checkbox>
  20. </div>
  21. </div>
  22. </div>
  23. <!-- 视频统计 -->
  24. <div class="panel-section">
  25. <div class="section-label">视频统计</div>
  26. <div class="stats-row">
  27. <div class="stat-card">
  28. <div class="stat-value">{{ videoList.length }}</div>
  29. <div class="stat-text">总数</div>
  30. </div>
  31. <div class="stat-card stat-online">
  32. <div class="stat-value">{{ onlineCount }}</div>
  33. <div class="stat-text">在线</div>
  34. </div>
  35. <div class="stat-card stat-offline">
  36. <div class="stat-value">{{ offlineCount }}</div>
  37. <div class="stat-text">离线</div>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 搜索框 -->
  42. <div class="panel-section">
  43. <div class="section-label">快速定位</div>
  44. <el-input
  45. v-model="searchKey"
  46. placeholder="输入视频名称搜索"
  47. clearable
  48. prefix-icon="Search"
  49. @input="onSearch"
  50. />
  51. <div class="search-results" v-if="searchResults.length > 0">
  52. <div
  53. class="search-item"
  54. v-for="item in searchResults"
  55. :key="item.id"
  56. @click="locateVideo(item)"
  57. >
  58. <span class="layer-dot" :style="{ background: getTypeColor(item.type) }"></span>
  59. <span class="search-name">{{ item.name }}</span>
  60. <span class="search-status" :class="item.status === '在线' ? 'online' : 'offline'">
  61. {{ item.status }}
  62. </span>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 地图容器 -->
  68. <div id="jcspGISMap" class="map-container"></div>
  69. <!-- 视频弹窗 -->
  70. <el-dialog
  71. v-model="videoDialogVisible"
  72. :title="currentVideo.name"
  73. width="480px"
  74. :close-on-click-modal="false"
  75. class="video-dialog"
  76. @closed="onDialogClosed"
  77. >
  78. <div class="video-player" :class="{ offline: currentVideo.status === '离线' }">
  79. <div class="player-placeholder" v-if="currentVideo.status === '离线'">
  80. <el-icon :size="48"><VideoCamera /></el-icon>
  81. <span>设备离线,无法播放</span>
  82. </div>
  83. <div class="player-placeholder playing" v-else>
  84. <el-icon :size="48" class="play-icon"><VideoCamera /></el-icon>
  85. <span>实时监控画面</span>
  86. <div class="live-badge">LIVE</div>
  87. </div>
  88. </div>
  89. <div class="video-info">
  90. <div class="info-row">
  91. <span class="info-label">视频名称</span>
  92. <span class="info-value">{{ currentVideo.name }}</span>
  93. </div>
  94. <div class="info-row">
  95. <span class="info-label">设备类型</span>
  96. <span class="info-value">
  97. <span class="type-tag" :style="{ background: getTypeColor(currentVideo.type), color: '#fff' }">
  98. {{ getTypeLabel(currentVideo.type) }}
  99. </span>
  100. </span>
  101. </div>
  102. <div class="info-row">
  103. <span class="info-label">安装位置</span>
  104. <span class="info-value">{{ currentVideo.location }}</span>
  105. </div>
  106. <div class="info-row">
  107. <span class="info-label">在线状态</span>
  108. <span class="info-value" :class="currentVideo.status === '在线' ? 'status-online' : 'status-offline'">
  109. {{ currentVideo.status }}
  110. </span>
  111. </div>
  112. <div class="info-row">
  113. <span class="info-label">关联设备</span>
  114. <span class="info-value">{{ currentVideo.device }}</span>
  115. </div>
  116. </div>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script setup name="JcspGIS">
  121. import { ref, reactive, computed, onMounted, watch, nextTick } from 'vue'
  122. import { VideoCamera, Search } from '@element-plus/icons-vue'
  123. import locationIcon from '@/assets/images/location.png'
  124. // ==================== 图层配置 ====================
  125. const layerOptions = [
  126. { label: '积水点视频', value: 'jsd', color: '#409eff' },
  127. { label: '泵站视频', value: 'bz', color: '#67c23a' },
  128. { label: '下穿立交视频', value: 'xclj', color: '#e6a23c' },
  129. { label: '管网视频', value: 'gw', color: '#9b59b6' }
  130. ]
  131. const layerChecked = reactive({
  132. jsd: true,
  133. bz: true,
  134. xclj: true,
  135. gw: true
  136. })
  137. // ==================== 模拟视频数据(18个点位)====================
  138. const videoList = ref([
  139. { id: 1, name: '沅陵大桥积水点', type: 'jsd', lng: 110.396, lat: 28.468, status: '在线', location: '沅陵大桥南侧', device: 'WL-JSD-001' },
  140. { id: 2, name: '太常路积水点', type: 'jsd', lng: 110.382, lat: 28.459, status: '在线', location: '太常路与沅江路交汇', device: 'WL-JSD-002' },
  141. { id: 3, name: '沅江路积水点', type: 'jsd', lng: 110.403, lat: 28.447, status: '离线', location: '沅江路中段', device: 'WL-JSD-003' },
  142. { id: 4, name: '龙舟路积水点', type: 'jsd', lng: 110.388, lat: 28.436, status: '在线', location: '龙舟路与建设路交汇', device: 'WL-JSD-004' },
  143. { id: 5, name: '城东积水点', type: 'jsd', lng: 110.412, lat: 28.461, status: '在线', location: '城东开发区入口', device: 'WL-JSD-005' },
  144. { id: 6, name: '一号泵站', type: 'bz', lng: 110.391, lat: 28.465, status: '在线', location: '沅陵大桥西侧', device: 'WL-BZ-001' },
  145. { id: 7, name: '二号泵站', type: 'bz', lng: 110.378, lat: 28.451, status: '在线', location: '太常片区排水口', device: 'WL-BZ-002' },
  146. { id: 8, name: '三号泵站', type: 'bz', lng: 110.407, lat: 28.455, status: '离线', location: '沅江路东段', device: 'WL-BZ-003' },
  147. { id: 9, name: '四号泵站', type: 'bz', lng: 110.395, lat: 28.439, status: '在线', location: '城区排水枢纽', device: 'WL-BZ-004' },
  148. { id: 10, name: '五号泵站', type: 'bz', lng: 110.368, lat: 28.448, status: '在线', location: '沅水南岸排水站', device: 'WL-BZ-005' },
  149. { id: 11, name: '沅陵大桥下穿', type: 'xclj', lng: 110.398, lat: 28.463, status: '在线', location: '沅陵大桥下穿通道', device: 'WL-XC-001' },
  150. { id: 12, name: '太常路下穿', type: 'xclj', lng: 110.384, lat: 28.453, status: '在线', location: '太常路下穿隧道', device: 'WL-XC-002' },
  151. { id: 13, name: '建设路下穿', type: 'xclj', lng: 110.393, lat: 28.441, status: '离线', location: '建设路下穿通道', device: 'WL-XC-003' },
  152. { id: 14, name: '城东下穿立交', type: 'xclj', lng: 110.415, lat: 28.457, status: '在线', location: '城东立交桥下', device: 'WL-XC-004' },
  153. { id: 15, name: '主城区管网A段', type: 'gw', lng: 110.390, lat: 28.460, status: '在线', location: '主城区排水干管', device: 'WL-GW-001' },
  154. { id: 16, name: '太常片区管网', type: 'gw', lng: 110.376, lat: 28.446, status: '在线', location: '太常片区管网节点', device: 'WL-GW-002' },
  155. { id: 17, name: '沅江路管网', type: 'gw', lng: 110.405, lat: 28.449, status: '离线', location: '沅江路管网检测点', device: 'WL-GW-003' },
  156. { id: 18, name: '城东管网B段', type: 'gw', lng: 110.418, lat: 28.465, status: '在线', location: '城东管网检测井', device: 'WL-GW-004' }
  157. ])
  158. // ==================== 统计计算 ====================
  159. const onlineCount = computed(() => videoList.value.filter(v => v.status === '在线').length)
  160. const offlineCount = computed(() => videoList.value.filter(v => v.status === '离线').length)
  161. // ==================== 搜索功能 ====================
  162. const searchKey = ref('')
  163. const searchResults = ref([])
  164. function onSearch() {
  165. if (!searchKey.value.trim()) {
  166. searchResults.value = []
  167. return
  168. }
  169. const key = searchKey.value.trim().toLowerCase()
  170. searchResults.value = videoList.value.filter(v =>
  171. v.name.toLowerCase().includes(key) || v.location.toLowerCase().includes(key)
  172. )
  173. }
  174. function locateVideo(item) {
  175. if (mapInstance) {
  176. mapInstance.centerAndZoom(new BMapGL.Point(item.lng, item.lat), 17)
  177. // 触发对应标记的点击
  178. const label = markerMap.get(item.id)
  179. if (label) {
  180. // 打开视频弹窗
  181. openVideoDialog(item)
  182. }
  183. }
  184. searchResults.value = []
  185. searchKey.value = ''
  186. }
  187. // ==================== 工具方法 ====================
  188. function getTypeColor(type) {
  189. const map = { jsd: '#409eff', bz: '#67c23a', xclj: '#e6a23c', gw: '#9b59b6' }
  190. return map[type] || '#409eff'
  191. }
  192. function getTypeLabel(type) {
  193. const map = { jsd: '积水点视频', bz: '泵站视频', xclj: '下穿立交视频', gw: '管网视频' }
  194. return map[type] || '未知类型'
  195. }
  196. // ==================== 地图相关 ====================
  197. let mapInstance = null
  198. const markerMap = new Map() // id -> label
  199. function initMap() {
  200. const container = document.getElementById('jcspGISMap')
  201. if (!container || typeof BMapGL === 'undefined') {
  202. console.warn('BMapGL 未加载或容器不存在')
  203. return
  204. }
  205. try {
  206. mapInstance = new BMapGL.Map('jcspGISMap')
  207. const centerPoint = new BMapGL.Point(110.393, 28.452)
  208. mapInstance.centerAndZoom(centerPoint, 15)
  209. mapInstance.enableScrollWheelZoom(true)
  210. // 添加所有标记
  211. videoList.value.forEach(point => {
  212. addMapMarker(point)
  213. })
  214. } catch (e) {
  215. console.error('百度地图初始化失败:', e)
  216. }
  217. }
  218. function addMapMarker(point) {
  219. const color = getTypeColor(point.type)
  220. const typeLabel = getTypeLabel(point.type)
  221. const bPoint = new BMapGL.Point(point.lng, point.lat)
  222. const statusDot = point.status === '在线'
  223. ? '<span style="display:inline-block;width:6px;height:6px;border-radius:50%;background:#67c23a;margin-right:3px;vertical-align:middle;"></span>'
  224. : '<span style="display:inline-block;width:6px;height:6px;border-radius:50%;background:#f56c6c;margin-right:3px;vertical-align:middle;"></span>'
  225. const html = `<div style="text-align:center;cursor:pointer;">
  226. <div style="color:#fff;background:${color};border-radius:4px;padding:2px 8px;font-size:11px;white-space:nowrap;display:inline-block;margin-bottom:2px;box-shadow:0 1px 4px rgba(0,0,0,0.3);">
  227. ${statusDot}${point.name}
  228. </div>
  229. <div><img src="${locationIcon}" style="width:28px;height:28px;display:block;margin:0 auto;"/></div>
  230. </div>`
  231. const label = new BMapGL.Label(html, {
  232. position: bPoint,
  233. offset: new BMapGL.Size(-30, -50)
  234. })
  235. label.setStyle({
  236. border: 'none',
  237. background: 'transparent',
  238. padding: '0',
  239. zIndex: '10'
  240. })
  241. mapInstance.addOverlay(label)
  242. // 存储标记引用
  243. markerMap.set(point.id, label)
  244. // 点击标记打开视频弹窗
  245. label.addEventListener('click', function () {
  246. openVideoDialog(point)
  247. })
  248. }
  249. // ==================== 图层筛选 ====================
  250. function onLayerChange() {
  251. videoList.value.forEach(point => {
  252. const label = markerMap.get(point.id)
  253. if (!label) return
  254. const visible = layerChecked[point.type]
  255. label.show()
  256. if (!visible) {
  257. label.hide()
  258. }
  259. })
  260. }
  261. // ==================== 视频弹窗 ====================
  262. const videoDialogVisible = ref(false)
  263. const currentVideo = ref({})
  264. function openVideoDialog(point) {
  265. currentVideo.value = { ...point }
  266. videoDialogVisible.value = true
  267. }
  268. function onDialogClosed() {
  269. currentVideo.value = {}
  270. }
  271. // ==================== 生命周期 ====================
  272. onMounted(() => {
  273. nextTick(() => {
  274. initMap()
  275. })
  276. })
  277. </script>
  278. <style scoped>
  279. .jcsp-gis-page {
  280. position: relative;
  281. width: 100%;
  282. height: calc(100vh - 84px);
  283. overflow: hidden;
  284. }
  285. .map-container {
  286. width: 100%;
  287. height: 100%;
  288. }
  289. /* ==================== 左侧浮动面板 ==================== */
  290. .side-panel {
  291. position: absolute;
  292. top: 16px;
  293. left: 16px;
  294. width: 280px;
  295. background: rgba(20, 30, 48, 0.92);
  296. border-radius: 8px;
  297. z-index: 100;
  298. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  299. padding: 0;
  300. max-height: calc(100% - 32px);
  301. overflow-y: auto;
  302. }
  303. .side-panel::-webkit-scrollbar {
  304. width: 4px;
  305. }
  306. .side-panel::-webkit-scrollbar-thumb {
  307. background: rgba(255, 255, 255, 0.2);
  308. border-radius: 2px;
  309. }
  310. .panel-header {
  311. padding: 16px 18px 12px;
  312. border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  313. }
  314. .panel-title {
  315. font-size: 16px;
  316. font-weight: 600;
  317. color: #fff;
  318. letter-spacing: 1px;
  319. }
  320. .panel-section {
  321. padding: 14px 18px;
  322. border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  323. }
  324. .panel-section:last-child {
  325. border-bottom: none;
  326. }
  327. .section-label {
  328. font-size: 12px;
  329. color: rgba(255, 255, 255, 0.5);
  330. margin-bottom: 10px;
  331. text-transform: uppercase;
  332. letter-spacing: 1px;
  333. }
  334. /* 图层列表 */
  335. .layer-list {
  336. display: flex;
  337. flex-direction: column;
  338. gap: 6px;
  339. }
  340. .layer-item :deep(.el-checkbox) {
  341. color: rgba(255, 255, 255, 0.85);
  342. height: auto;
  343. }
  344. .layer-item :deep(.el-checkbox__label) {
  345. color: rgba(255, 255, 255, 0.85);
  346. font-size: 13px;
  347. display: inline-flex;
  348. align-items: center;
  349. gap: 4px;
  350. }
  351. .layer-item :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
  352. background: #409eff;
  353. border-color: #409eff;
  354. }
  355. .layer-dot {
  356. display: inline-block;
  357. width: 10px;
  358. height: 10px;
  359. border-radius: 50%;
  360. margin-right: 2px;
  361. vertical-align: middle;
  362. }
  363. /* 统计卡片 */
  364. .stats-row {
  365. display: flex;
  366. gap: 10px;
  367. }
  368. .stat-card {
  369. flex: 1;
  370. background: rgba(255, 255, 255, 0.08);
  371. border-radius: 6px;
  372. padding: 10px 8px;
  373. text-align: center;
  374. }
  375. .stat-card.stat-online {
  376. background: rgba(103, 194, 58, 0.15);
  377. }
  378. .stat-card.stat-offline {
  379. background: rgba(245, 108, 108, 0.15);
  380. }
  381. .stat-value {
  382. font-size: 22px;
  383. font-weight: 700;
  384. color: #fff;
  385. line-height: 1.2;
  386. }
  387. .stat-online .stat-value {
  388. color: #67c23a;
  389. }
  390. .stat-offline .stat-value {
  391. color: #f56c6c;
  392. }
  393. .stat-text {
  394. font-size: 11px;
  395. color: rgba(255, 255, 255, 0.5);
  396. margin-top: 4px;
  397. }
  398. /* 搜索 */
  399. .side-panel :deep(.el-input__wrapper) {
  400. background: rgba(255, 255, 255, 0.08);
  401. box-shadow: none;
  402. border: 1px solid rgba(255, 255, 255, 0.12);
  403. }
  404. .side-panel :deep(.el-input__inner) {
  405. color: #fff;
  406. font-size: 13px;
  407. }
  408. .side-panel :deep(.el-input__inner::placeholder) {
  409. color: rgba(255, 255, 255, 0.35);
  410. }
  411. .side-panel :deep(.el-input__prefix .el-icon) {
  412. color: rgba(255, 255, 255, 0.4);
  413. }
  414. .search-results {
  415. margin-top: 8px;
  416. max-height: 200px;
  417. overflow-y: auto;
  418. border-radius: 4px;
  419. }
  420. .search-results::-webkit-scrollbar {
  421. width: 3px;
  422. }
  423. .search-results::-webkit-scrollbar-thumb {
  424. background: rgba(255, 255, 255, 0.15);
  425. border-radius: 2px;
  426. }
  427. .search-item {
  428. display: flex;
  429. align-items: center;
  430. padding: 7px 10px;
  431. cursor: pointer;
  432. border-radius: 4px;
  433. transition: background 0.15s;
  434. }
  435. .search-item:hover {
  436. background: rgba(255, 255, 255, 0.1);
  437. }
  438. .search-name {
  439. flex: 1;
  440. font-size: 12px;
  441. color: rgba(255, 255, 255, 0.85);
  442. margin-left: 6px;
  443. overflow: hidden;
  444. text-overflow: ellipsis;
  445. white-space: nowrap;
  446. }
  447. .search-status {
  448. font-size: 11px;
  449. padding: 1px 6px;
  450. border-radius: 3px;
  451. }
  452. .search-status.online {
  453. color: #67c23a;
  454. background: rgba(103, 194, 58, 0.15);
  455. }
  456. .search-status.offline {
  457. color: #f56c6c;
  458. background: rgba(245, 108, 108, 0.15);
  459. }
  460. /* ==================== 视频弹窗样式 ==================== */
  461. .video-dialog :deep(.el-dialog) {
  462. border-radius: 10px;
  463. overflow: hidden;
  464. }
  465. .video-dialog :deep(.el-dialog__header) {
  466. background: #1a1a2e;
  467. padding: 14px 20px;
  468. margin: 0;
  469. }
  470. .video-dialog :deep(.el-dialog__title) {
  471. color: #fff;
  472. font-size: 15px;
  473. }
  474. .video-dialog :deep(.el-dialog__headerbtn .el-dialog__close) {
  475. color: rgba(255, 255, 255, 0.6);
  476. }
  477. .video-dialog :deep(.el-dialog__body) {
  478. padding: 0;
  479. }
  480. .video-player {
  481. width: 100%;
  482. height: 300px;
  483. background: #000;
  484. display: flex;
  485. align-items: center;
  486. justify-content: center;
  487. position: relative;
  488. }
  489. .player-placeholder {
  490. display: flex;
  491. flex-direction: column;
  492. align-items: center;
  493. gap: 12px;
  494. color: rgba(255, 255, 255, 0.3);
  495. font-size: 14px;
  496. }
  497. .player-placeholder.playing {
  498. color: rgba(255, 255, 255, 0.6);
  499. }
  500. .play-icon {
  501. color: #409eff;
  502. animation: pulse 2s infinite;
  503. }
  504. @keyframes pulse {
  505. 0%, 100% { opacity: 1; }
  506. 50% { opacity: 0.5; }
  507. }
  508. .live-badge {
  509. position: absolute;
  510. top: 12px;
  511. right: 12px;
  512. background: #f56c6c;
  513. color: #fff;
  514. font-size: 11px;
  515. font-weight: 700;
  516. padding: 2px 8px;
  517. border-radius: 3px;
  518. letter-spacing: 1px;
  519. animation: blink 1.5s infinite;
  520. }
  521. @keyframes blink {
  522. 0%, 100% { opacity: 1; }
  523. 50% { opacity: 0.4; }
  524. }
  525. .video-info {
  526. padding: 16px 20px;
  527. }
  528. .info-row {
  529. display: flex;
  530. align-items: center;
  531. padding: 8px 0;
  532. border-bottom: 1px solid #f0f0f0;
  533. }
  534. .info-row:last-child {
  535. border-bottom: none;
  536. }
  537. .info-label {
  538. width: 80px;
  539. flex-shrink: 0;
  540. font-size: 13px;
  541. color: #909399;
  542. }
  543. .info-value {
  544. font-size: 13px;
  545. color: #303133;
  546. }
  547. .type-tag {
  548. font-size: 11px;
  549. padding: 2px 8px;
  550. border-radius: 3px;
  551. }
  552. .status-online {
  553. color: #67c23a;
  554. font-weight: 500;
  555. }
  556. .status-offline {
  557. color: #f56c6c;
  558. font-weight: 500;
  559. }
  560. </style>