LeftMenu.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <div class="menu-container">
  3. <div ref="searchBoxRef" class="search-box">
  4. <input v-model="searchState.searchText" class="input" @keyup.enter="changeSearchText" />
  5. <div v-show="searchState.showList" class="search-content">
  6. <div class="search-title">全局搜索</div>
  7. <div class="search-sub-content">
  8. <div class="search-header">
  9. <div class="header-left">
  10. <i class="icon-position1" />
  11. <div class="text1">地址</div>
  12. </div>
  13. </div>
  14. <div class="search-list">
  15. <div class="scroll">
  16. <div v-for="(item, index) in searchState.resultList" :key="index" class="list-item" @click="selectSearchMarker(item)">
  17. <i class="icon1" />
  18. <div class="text1" :title="item.name">{{ item.name }}</div>
  19. <!-- <div class="text2">{{ item.address }}</div>-->
  20. </div>
  21. <div v-show="searchState.showList && searchState.resultList.length === 0" style="text-align: center">无数据</div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="search-sub-content">
  26. <div class="search-header">
  27. <div class="header-left">
  28. <i class="icon-layer" />
  29. <div class="text1">图层</div>
  30. </div>
  31. </div>
  32. <div class="search-list" style="height: 160px">
  33. <div class="scroll" style="height: 150px">
  34. <div
  35. v-for="(item, index) in searchState.layerList"
  36. :key="index"
  37. class="list-item"
  38. style="margin-top: 5px"
  39. @click="selectSearchMarker(item)"
  40. >
  41. <div class="tag">{{ item.dict_label }}</div>
  42. <div class="text1" :title="item.name">{{ item.name }}</div>
  43. </div>
  44. <div v-show="searchState.showList && searchState.layerList.length === 0" style="text-align: center">无数据</div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="search-sub-content">
  49. <div class="search-header">
  50. <div class="header-left">
  51. <i class="icon-video" />
  52. <div class="text1">视频</div>
  53. </div>
  54. </div>
  55. <div class="search-list" style="height: 150px">
  56. <div class="scroll" style="height: 140px">
  57. <div v-for="(item, index) in searchState.videoList" :key="index" class="list-item2" style="margin-top: 5px">
  58. <div class="text1" :title="item.name" @click="handleShowDialog(item)">{{ item.name }}</div>
  59. <div class="tags">
  60. <div v-for="(item2, index2) in item.tag_info" :key="index2" class="tag">{{ item2.dict_label }}</div>
  61. </div>
  62. </div>
  63. <div v-show="searchState.showList && searchState.videoList.length === 0" style="text-align: center">无数据</div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <div class="menu-box">
  70. <div class="menu-btn" @click="changExpand">
  71. <div class="gradient-text">{{ menuState.isExpand ? '收起' : '展开' }}</div>
  72. </div>
  73. <Transition>
  74. <div v-show="menuState.isExpand" class="menu-box2">
  75. <div class="menu-header">
  76. <div
  77. v-for="(item, index) in menuData"
  78. :key="index"
  79. :class="menuState.activeIndex === index ? 'menu-item active' : 'menu-item'"
  80. @click="changeActive(index)"
  81. >
  82. <div class="gradient-text text">{{ item.name }}</div>
  83. </div>
  84. </div>
  85. <div class="menu-content">
  86. <div v-for="(item, index) in menuData[menuState.activeIndex]?.children" :key="index" class="content-box">
  87. <div class="box-header">
  88. <div v-if="item.name === '防风防汛'" class="icon1" style="width: 24px; height: 26px"></div>
  89. <div v-if="item.name === '危化品安全监测' || item.name === '危险化工品'" class="icon2" style="width: 23px; height: 26px"></div>
  90. <div v-if="item.name === '其他'" class="icon3" style="width: 26px; height: 26px"></div>
  91. <div v-if="item.name === '水情监测'" class="icon4" style="width: 29px; height: 26px"></div>
  92. <div v-if="item.name === '自然灾害监测'" class="icon5" style="width: 25px; height: 26px"></div>
  93. <div>{{ item.name }}</div>
  94. <div :class="item.show ? 'expand-icon down-icon' : 'expand-icon up-icon'" @click="changeBoxShow(item)"></div>
  95. </div>
  96. <Transition>
  97. <div v-show="item.show" class="box-content">
  98. <div
  99. v-for="(item2, index2) in item.children"
  100. :key="index2"
  101. :class="item2.checked ? 'box-item box-item-active' : 'box-item'"
  102. @click="handleClick(item2)"
  103. >
  104. <div :class="item2.checked ? 'checked-box checked' : 'checked-box'"></div>
  105. {{ item2.name }}
  106. </div>
  107. </div>
  108. </Transition>
  109. </div>
  110. </div>
  111. </div>
  112. </Transition>
  113. </div>
  114. <Dialog
  115. v-if="showDialog"
  116. v-model="showDialog"
  117. type="lg"
  118. header-type="header2"
  119. title="视频"
  120. height="720px"
  121. :get-tag-id="videoMonitorData.video_code"
  122. hide-footer
  123. >
  124. <div style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center">
  125. <HKVideo :dot_data="videoMonitorData" />
  126. </div>
  127. </Dialog>
  128. </div>
  129. </template>
  130. <script lang="ts" setup>
  131. import { getPointInfoComprehensiveSearch } from '@/api/globalMap';
  132. import { listMenu2 } from '@/api/system/menu';
  133. import { deepClone } from '@/utils';
  134. import { onClickOutside } from '@vueuse/core';
  135. const emits = defineEmits(['switchMap', 'clickMenu', 'selectSearchMarker']);
  136. const getPlaceSearch = inject('getPlaceSearch');
  137. // 左侧菜单
  138. let menuData = ref([]);
  139. const searchState = reactive({
  140. searchText: '',
  141. showList: false,
  142. resultList: [],
  143. layerList: [],
  144. videoList: []
  145. });
  146. let showDialog = ref(false);
  147. let videoMonitorData = ref({});
  148. let searchBoxRef = ref();
  149. onClickOutside(searchBoxRef, (event) => {
  150. searchState.showList = false;
  151. });
  152. const changeSearchText = () => {
  153. if (!searchState.searchText) {
  154. searchState.showList = false;
  155. return;
  156. } else {
  157. console.log('搜索值:', searchState.searchText);
  158. getPointInfoComprehensiveSearch({
  159. keyword: searchState.searchText
  160. }).then((res) => {
  161. searchState.showList = true;
  162. searchState.layerList = res.data.point_data;
  163. searchState.videoList = res.data.video_data;
  164. });
  165. getPlaceSearch().search(searchState.searchText, (status, result) => {
  166. if (!!result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
  167. let arr = [];
  168. const pois = result.poiList.pois;
  169. arr = pois.map((item) => {
  170. return {
  171. dataType: 'search',
  172. name: item.name,
  173. address: item.address,
  174. longitude: item.location.lng,
  175. latitude: item.location.lat
  176. };
  177. });
  178. searchState.resultList = arr;
  179. }
  180. });
  181. }
  182. };
  183. // 点击搜索结果,添加标注
  184. const selectSearchMarker = (item) => {
  185. searchState.showList = false;
  186. emits('selectSearchMarker', item);
  187. };
  188. const menuState = reactive({
  189. // 是否展开菜单
  190. isExpand: true,
  191. activeIndex: 0
  192. });
  193. // 展示收起整个菜单
  194. const changExpand = () => {
  195. menuState.isExpand = !menuState.isExpand;
  196. };
  197. // 切换tab
  198. const changeActive = (index) => {
  199. menuState.activeIndex = index;
  200. };
  201. // 菜单内容展开收缩
  202. const changeBoxShow = (item) => {
  203. item.show = !item.show;
  204. };
  205. // 处理菜单点击事件
  206. const handleClick = (item) => {
  207. item.checked = !item.checked;
  208. emits('clickMenu', item, menuData.value);
  209. };
  210. const initData = () => {
  211. listMenu2().then((res: any) => {
  212. const data = res.data ? res.data[0]?.children : [];
  213. data.forEach((item) => {
  214. item.show = true;
  215. item.name = item.meta?.title;
  216. item.children?.forEach((item2) => {
  217. item2.show = true;
  218. item2.name = item2.meta?.title;
  219. item2.children?.forEach((item3) => {
  220. item3.name = item3.meta?.title;
  221. if (item3.component === '2' && !!item3.path) {
  222. item3.checked = false;
  223. }
  224. });
  225. });
  226. });
  227. menuData.value = data;
  228. console.log(menuData.value);
  229. });
  230. };
  231. const setMenuChange = (item, flag) => {
  232. for (let i = 0; i < menuData.value.length; i++) {
  233. if (item.meta.title === menuData.value[i].meta.title) {
  234. menuData.value[i].checked = flag;
  235. break;
  236. } else if (!!menuData.value[i].children) {
  237. const res = setChild(menuData.value[i].children, item, flag);
  238. if (!!res) {
  239. break;
  240. }
  241. }
  242. }
  243. };
  244. const setChild = (data, item, flag) => {
  245. let res = false;
  246. for (let i = 0; i < data.length; i++) {
  247. if (item.meta.title === data[i].meta.title) {
  248. data[i].checked = flag;
  249. break;
  250. } else if (!!data[i].children) {
  251. res = setChild(data[i].children, item, flag);
  252. if (!!res) {
  253. break;
  254. }
  255. }
  256. }
  257. return res;
  258. };
  259. const handleShowDialog = (row) => {
  260. showDialog.value = false;
  261. nextTick(() => {
  262. const data = deepClone(row);
  263. data.video_code = data.id;
  264. videoMonitorData.value = data;
  265. showDialog.value = true;
  266. });
  267. };
  268. onMounted(() => {
  269. initData();
  270. });
  271. defineExpose({ setMenuChange });
  272. </script>
  273. <style lang="scss" scoped>
  274. .search-box {
  275. width: 260px;
  276. height: 33px;
  277. padding: 0 10px;
  278. background: url('@/assets/images/menu/search.png') no-repeat;
  279. background-size: 100% 100%;
  280. position: relative;
  281. margin: 0 auto;
  282. .input {
  283. border: none;
  284. outline: none;
  285. color: #fff;
  286. width: calc(100% - 20px);
  287. margin-left: 22px;
  288. height: 33px;
  289. font-size: 14px;
  290. background-color: transparent;
  291. }
  292. .search-content {
  293. position: absolute;
  294. top: 30px;
  295. left: -12px;
  296. //width: 260px;
  297. //height: 613px;
  298. width: 285px;
  299. height: 672px;
  300. background: url('@/assets/images/map/box1.png') no-repeat;
  301. background-size: 100% 100%;
  302. color: #ffffff;
  303. z-index: 9;
  304. padding: 10px 6px;
  305. .search-title {
  306. color: transparent;
  307. background-image: linear-gradient(to bottom, #fff 50%, #a6d3e1 100%);
  308. -webkit-background-clip: text;
  309. background-clip: text;
  310. display: inline-block;
  311. font-family: 'YouSheBiaoTiHei';
  312. font-size: 18px;
  313. line-height: 36px;
  314. padding: 0 9px;
  315. }
  316. .search-sub-content {
  317. width: 100%;
  318. .search-header {
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. width: 379px;
  323. height: 39px;
  324. background: url('@/assets/images/map/titleBox3.png') no-repeat;
  325. background-size: 100% 100%;
  326. padding-left: 10px;
  327. padding-bottom: 16px;
  328. .header-left {
  329. display: flex;
  330. align-items: center;
  331. .icon-position1 {
  332. display: inline-block;
  333. width: 52px;
  334. height: 55px;
  335. background: url('@/assets/images/map/position.png') no-repeat;
  336. background-size: 100% 100%;
  337. }
  338. .icon-layer {
  339. display: inline-block;
  340. width: 55px;
  341. height: 51px;
  342. background: url('@/assets/images/map/layer.png') no-repeat;
  343. background-size: 100% 100%;
  344. }
  345. .icon-video {
  346. display: inline-block;
  347. width: 53px;
  348. height: 53px;
  349. background: url('@/assets/images/map/video.png') no-repeat;
  350. background-size: 100% 100%;
  351. }
  352. .text1 {
  353. margin-left: -12px;
  354. font-size: 16px;
  355. }
  356. }
  357. }
  358. }
  359. .search-list {
  360. width: 260px;
  361. height: 190px;
  362. padding-bottom: 10px;
  363. background: url('@/assets/images/map/base.png') no-repeat center bottom;
  364. background-size: 260px 49px;
  365. .scroll {
  366. height: 180px;
  367. overflow-y: auto;
  368. }
  369. .list-item,
  370. .list-item2 {
  371. display: flex;
  372. align-items: center;
  373. cursor: pointer;
  374. margin-top: -11px;
  375. .icon1 {
  376. display: inline-block;
  377. width: 53px;
  378. height: 56px;
  379. background: url('@/assets/images/map/position2.png') no-repeat;
  380. background-size: 100% 100%;
  381. flex-shrink: 0;
  382. }
  383. .tag {
  384. width: 126px;
  385. height: 26px;
  386. background: url('@/assets/images/map/tag.png') no-repeat;
  387. background-size: 100% 100%;
  388. flex-shrink: 0;
  389. color: #ffffff;
  390. font-size: 14px;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. }
  395. .text1 {
  396. margin-left: 5px;
  397. font-size: 14px;
  398. display: -webkit-box;
  399. -webkit-box-orient: vertical;
  400. -webkit-line-clamp: 2;
  401. overflow: hidden;
  402. text-overflow: ellipsis;
  403. white-space: normal; /* 或者使用 nowrap,取决于你的布局需求 */
  404. }
  405. }
  406. .list-item2 {
  407. flex-direction: column;
  408. align-items: unset;
  409. .tags {
  410. display: flex;
  411. flex-wrap: wrap;
  412. .tag {
  413. margin-top: 5px;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. .menu-box {
  421. width: 280px;
  422. height: 551px;
  423. margin-top: 10px;
  424. color: #fff;
  425. position: relative;
  426. .menu-box2 {
  427. width: 280px;
  428. height: 551px;
  429. background: url('@/assets/images/menu/menu.png') no-repeat;
  430. background-size: 100% 100%;
  431. padding: 10px 20px 10px 24px;
  432. }
  433. .menu-btn {
  434. position: absolute;
  435. top: -5px;
  436. left: 50%;
  437. transform: translateX(-50%);
  438. letter-spacing: 5px;
  439. font-size: 16px;
  440. cursor: pointer;
  441. width: 125px;
  442. height: 20px;
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. background: url('@/assets/images/menu/btn.png') no-repeat;
  447. background-size: 100% 100%;
  448. }
  449. .menu-header {
  450. display: flex;
  451. margin-top: 15px;
  452. height: 28px;
  453. .menu-item {
  454. width: 87px;
  455. height: 20px;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. cursor: pointer;
  460. &:hover {
  461. position: relative;
  462. background: url('@/assets/images/menu/menuActive.png') no-repeat bottom center;
  463. background-size: 100% 100%;
  464. }
  465. .text {
  466. font-size: 14px;
  467. }
  468. }
  469. .active {
  470. background: url('@/assets/images/menu/menuActive.png') no-repeat bottom center;
  471. background-size: 100% 100%;
  472. }
  473. }
  474. .menu-content {
  475. margin: 0 0 0 -6px;
  476. height: 488px;
  477. overflow-y: auto;
  478. overflow-x: hidden;
  479. .content-box {
  480. padding: 0 5px;
  481. width: 250px;
  482. background: url('@/assets/images/menu/menuContent.png') no-repeat;
  483. background-size: 100% 100%;
  484. .box-header {
  485. height: 36px;
  486. display: flex;
  487. align-items: center;
  488. justify-content: center;
  489. position: relative;
  490. font-size: 14px;
  491. font-weight: 500;
  492. position: relative;
  493. &::after {
  494. position: absolute;
  495. bottom: 0;
  496. left: 0;
  497. content: '';
  498. width: 100%;
  499. height: 3px;
  500. background-color: rgba(142, 189, 241, 0.3);
  501. }
  502. .icon1 {
  503. background-image: url('@/assets/images/menu/icon1.png');
  504. background-size: 100% 100%;
  505. }
  506. .icon2 {
  507. background-image: url('@/assets/images/menu/icon2.png');
  508. background-size: 100% 100%;
  509. }
  510. .icon3 {
  511. background-image: url('@/assets/images/menu/icon3.png');
  512. background-size: 100% 100%;
  513. }
  514. .icon4 {
  515. background-image: url('@/assets/images/menu/icon4.png');
  516. background-size: 100% 100%;
  517. }
  518. .icon5 {
  519. background-image: url('@/assets/images/menu/icon5.png');
  520. background-size: 100% 100%;
  521. }
  522. .expand-icon {
  523. position: absolute;
  524. top: 50%;
  525. right: 30px;
  526. transform: translateY(-50%);
  527. cursor: pointer;
  528. width: 11px;
  529. height: 6px;
  530. }
  531. .down-icon {
  532. background: url('@/assets/images/menu/down.png') no-repeat;
  533. background-size: 100% 100%;
  534. }
  535. .up-icon {
  536. background: url('@/assets/images/menu/up.png') no-repeat;
  537. background-size: 100% 100%;
  538. }
  539. }
  540. .box-content {
  541. display: flex;
  542. align-items: center;
  543. flex-wrap: wrap;
  544. padding: 5px 3px;
  545. overflow: hidden;
  546. .box-item-active {
  547. text-shadow: 0px 0px 4px #0766d6;
  548. }
  549. .box-item {
  550. padding: 7px 4px;
  551. cursor: pointer;
  552. font-size: 14px;
  553. font-family: 'PingFang SC', sans-serif;
  554. display: flex;
  555. align-items: center;
  556. &:hover {
  557. text-shadow: 0px 0px 8px #0766d6;
  558. }
  559. .checked-box {
  560. width: 10px;
  561. height: 10px;
  562. background: url('@/assets/images/menu/checked-box.png') no-repeat;
  563. background-size: 100% 100%;
  564. margin-right: 4px;
  565. }
  566. .checked {
  567. background: url('@/assets/images/menu/checked-box2.png') no-repeat;
  568. background-size: 100% 100%;
  569. }
  570. }
  571. }
  572. }
  573. }
  574. }
  575. /* 切换动画 */
  576. .v-enter-active,
  577. .v-leave-active {
  578. transition: opacity 0.5s ease;
  579. }
  580. .v-enter-from,
  581. .v-leave-to {
  582. opacity: 0;
  583. }
  584. </style>