LeftMenu.vue 16 KB

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