123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- <template>
- <div class="menu-container">
- <div ref="searchBoxRef" class="search-box">
- <input v-model="searchState.searchText" class="input" @keyup.enter="changeSearchText" />
- <div v-show="searchState.showList" class="search-content">
- <div class="search-title">全局搜索</div>
- <div class="search-sub-content">
- <div class="search-header">
- <div class="header-left">
- <i class="icon-position1" />
- <div class="text1">地址</div>
- </div>
- </div>
- <div class="search-list">
- <div class="scroll">
- <div v-for="(item, index) in searchState.resultList" :key="index" class="list-item" @click="selectSearchMarker(item)">
- <i class="icon1" />
- <div class="text1" :title="item.name">{{ item.name }}</div>
- <!-- <div class="text2">{{ item.address }}</div>-->
- </div>
- <div v-show="searchState.showList && searchState.resultList.length === 0" style="text-align: center">无数据</div>
- </div>
- </div>
- </div>
- <div class="search-sub-content">
- <div class="search-header">
- <div class="header-left">
- <i class="icon-layer" />
- <div class="text1">图层</div>
- </div>
- </div>
- <div class="search-list" style="height: 160px">
- <div class="scroll" style="height: 150px">
- <div
- v-for="(item, index) in searchState.layerList"
- :key="index"
- class="list-item"
- style="margin-top: 5px"
- @click="selectSearchMarker(item)"
- >
- <div class="tag">{{ item.dict_label }}</div>
- <div class="text1" :title="item.name">{{ item.name }}</div>
- </div>
- <div v-show="searchState.showList && searchState.layerList.length === 0" style="text-align: center">无数据</div>
- </div>
- </div>
- </div>
- <div class="search-sub-content">
- <div class="search-header">
- <div class="header-left">
- <i class="icon-video" />
- <div class="text1">视频</div>
- </div>
- </div>
- <div class="search-list" style="height: 150px">
- <div class="scroll" style="height: 140px">
- <div v-for="(item, index) in searchState.videoList" :key="index" class="list-item2" style="margin-top: 5px">
- <div class="text1" :title="item.name" @click="handleShowDialog(item)">{{ item.name }}</div>
- <div class="tags">
- <div v-for="(item2, index2) in item.tag_info" :key="index2" class="tag">{{ item2.dict_label }}</div>
- </div>
- </div>
- <div v-show="searchState.showList && searchState.videoList.length === 0" style="text-align: center">无数据</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="menu-box">
- <div class="menu-btn" @click="changExpand">
- <div class="gradient-text">{{ menuState.isExpand ? '收起' : '展开' }}</div>
- </div>
- <Transition>
- <div v-show="menuState.isExpand" class="menu-box2">
- <div class="menu-header">
- <div
- v-for="(item, index) in menuData"
- :key="index"
- :class="menuState.activeIndex === index ? 'menu-item active' : 'menu-item'"
- @click="changeActive(index)"
- >
- <div class="gradient-text text">{{ item.name }}</div>
- </div>
- </div>
- <div class="menu-content">
- <div v-for="(item, index) in menuData[menuState.activeIndex]?.children" :key="index" class="content-box">
- <div class="box-header">
- <div v-if="item.name === '防风防汛'" class="icon1" style="width: 24px; height: 26px"></div>
- <div v-if="item.name === '危化品安全监测' || item.name === '危险化工品'" class="icon2" style="width: 23px; height: 26px"></div>
- <div v-if="item.name === '其他'" class="icon3" style="width: 26px; height: 26px"></div>
- <div v-if="item.name === '水情监测'" class="icon4" style="width: 29px; height: 26px"></div>
- <div v-if="item.name === '自然灾害监测'" class="icon5" style="width: 25px; height: 26px"></div>
- <div>{{ item.name }}</div>
- <div :class="item.show ? 'expand-icon down-icon' : 'expand-icon up-icon'" @click="changeBoxShow(item)"></div>
- </div>
- <Transition>
- <div v-show="item.show" class="box-content">
- <div
- v-for="(item2, index2) in item.children"
- :key="index2"
- :class="item2.checked ? 'box-item box-item-active' : 'box-item'"
- @click="handleClick(item2)"
- >
- <div :class="item2.checked ? 'checked-box checked' : 'checked-box'"></div>
- {{ item2.name }}
- </div>
- </div>
- </Transition>
- </div>
- </div>
- </div>
- </Transition>
- </div>
- <Dialog
- v-if="showDialog"
- v-model="showDialog"
- type="lg"
- header-type="header2"
- title="视频"
- height="720px"
- :get-tag-id="videoMonitorData.video_code"
- hide-footer
- >
- <div style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center">
- <HKVideo :dot_data="videoMonitorData" />
- </div>
- </Dialog>
- </div>
- </template>
- <script lang="ts" setup>
- import { getPointInfoComprehensiveSearch } from '@/api/globalMap';
- import { listMenu2 } from '@/api/system/menu';
- import { deepClone } from '@/utils';
- import { onClickOutside } from '@vueuse/core';
- const emits = defineEmits(['switchMap', 'clickMenu', 'selectSearchMarker']);
- const getPlaceSearch = inject('getPlaceSearch');
- // 左侧菜单
- let menuData = ref([]);
- const searchState = reactive({
- searchText: '',
- showList: false,
- resultList: [],
- layerList: [],
- videoList: []
- });
- let showDialog = ref(false);
- let videoMonitorData = ref({});
- let searchBoxRef = ref();
- onClickOutside(searchBoxRef, (event) => {
- searchState.showList = false;
- });
- const changeSearchText = () => {
- if (!searchState.searchText) {
- searchState.showList = false;
- return;
- } else {
- console.log('搜索值:', searchState.searchText);
- getPointInfoComprehensiveSearch({
- keyword: searchState.searchText
- }).then((res) => {
- searchState.showList = true;
- searchState.layerList = res.data.point_data;
- searchState.videoList = res.data.video_data;
- });
- getPlaceSearch().search(searchState.searchText, (status, result) => {
- if (!!result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
- let arr = [];
- const pois = result.poiList.pois;
- arr = pois.map((item) => {
- return {
- dataType: 'search',
- name: item.name,
- address: item.address,
- longitude: item.location.lng,
- latitude: item.location.lat
- };
- });
- searchState.resultList = arr;
- }
- });
- }
- };
- // 点击搜索结果,添加标注
- const selectSearchMarker = (item) => {
- searchState.showList = false;
- emits('selectSearchMarker', item);
- };
- const menuState = reactive({
- // 是否展开菜单
- isExpand: true,
- activeIndex: 0
- });
- // 展示收起整个菜单
- const changExpand = () => {
- menuState.isExpand = !menuState.isExpand;
- };
- // 切换tab
- const changeActive = (index) => {
- menuState.activeIndex = index;
- };
- // 菜单内容展开收缩
- const changeBoxShow = (item) => {
- item.show = !item.show;
- };
- // 处理菜单点击事件
- const handleClick = (item) => {
- item.checked = !item.checked;
- emits('clickMenu', item, menuData.value);
- };
- const initData = () => {
- listMenu2().then((res: any) => {
- const data = res.data ? res.data[0]?.children : [];
- data.forEach((item) => {
- item.show = true;
- item.name = item.meta?.title;
- item.children?.forEach((item2) => {
- item2.show = true;
- item2.name = item2.meta?.title;
- item2.children?.forEach((item3) => {
- item3.name = item3.meta?.title;
- if (item3.component === '2' && !!item3.path) {
- item3.checked = false;
- }
- });
- });
- });
- menuData.value = data;
- console.log(menuData.value);
- });
- };
- const setMenuChange = (item, flag) => {
- for (let i = 0; i < menuData.value.length; i++) {
- if (item.meta.title === menuData.value[i].meta.title) {
- menuData.value[i].checked = flag;
- break;
- } else if (!!menuData.value[i].children) {
- const res = setChild(menuData.value[i].children, item, flag);
- if (!!res) {
- break;
- }
- }
- }
- };
- const setChild = (data, item, flag) => {
- let res = false;
- for (let i = 0; i < data.length; i++) {
- if (item.meta.title === data[i].meta.title) {
- data[i].checked = flag;
- break;
- } else if (!!data[i].children) {
- res = setChild(data[i].children, item, flag);
- if (!!res) {
- break;
- }
- }
- }
- return res;
- };
- const handleShowDialog = (row) => {
- showDialog.value = false;
- nextTick(() => {
- const data = deepClone(row);
- data.video_code = data.id;
- videoMonitorData.value = data;
- showDialog.value = true;
- });
- };
- onMounted(() => {
- initData();
- });
- defineExpose({ setMenuChange });
- </script>
- <style lang="scss" scoped>
- .search-box {
- width: 260px;
- height: 33px;
- padding: 0 10px;
- background: url('@/assets/images/menu/search.png') no-repeat;
- background-size: 100% 100%;
- position: relative;
- margin: 0 auto;
- .input {
- border: none;
- outline: none;
- color: #fff;
- width: calc(100% - 20px);
- margin-left: 22px;
- height: 33px;
- font-size: 14px;
- background-color: transparent;
- }
- .search-content {
- position: absolute;
- top: 30px;
- left: -12px;
- //width: 260px;
- //height: 613px;
- width: 285px;
- height: 672px;
- background: url('@/assets/images/map/box1.png') no-repeat;
- background-size: 100% 100%;
- color: #ffffff;
- z-index: 9;
- padding: 10px 6px;
- .search-title {
- color: transparent;
- background-image: linear-gradient(to bottom, #fff 50%, #a6d3e1 100%);
- -webkit-background-clip: text;
- background-clip: text;
- display: inline-block;
- font-family: 'YouSheBiaoTiHei';
- font-size: 18px;
- line-height: 36px;
- padding: 0 9px;
- }
- .search-sub-content {
- width: 100%;
- .search-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 379px;
- height: 39px;
- background: url('@/assets/images/map/titleBox3.png') no-repeat;
- background-size: 100% 100%;
- padding-left: 10px;
- padding-bottom: 16px;
- .header-left {
- display: flex;
- align-items: center;
- .icon-position1 {
- display: inline-block;
- width: 52px;
- height: 55px;
- background: url('@/assets/images/map/position.png') no-repeat;
- background-size: 100% 100%;
- }
- .icon-layer {
- display: inline-block;
- width: 55px;
- height: 51px;
- background: url('@/assets/images/map/layer.png') no-repeat;
- background-size: 100% 100%;
- }
- .icon-video {
- display: inline-block;
- width: 53px;
- height: 53px;
- background: url('@/assets/images/map/video.png') no-repeat;
- background-size: 100% 100%;
- }
- .text1 {
- margin-left: -12px;
- font-size: 16px;
- }
- }
- }
- }
- .search-list {
- width: 260px;
- height: 190px;
- padding-bottom: 10px;
- background: url('@/assets/images/map/base.png') no-repeat center bottom;
- background-size: 260px 49px;
- .scroll {
- height: 180px;
- overflow-y: auto;
- }
- .list-item,
- .list-item2 {
- display: flex;
- align-items: center;
- cursor: pointer;
- margin-top: -11px;
- .icon1 {
- display: inline-block;
- width: 53px;
- height: 56px;
- background: url('@/assets/images/map/position2.png') no-repeat;
- background-size: 100% 100%;
- flex-shrink: 0;
- }
- .tag {
- width: 126px;
- height: 26px;
- background: url('@/assets/images/map/tag.png') no-repeat;
- background-size: 100% 100%;
- flex-shrink: 0;
- color: #ffffff;
- font-size: 14px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .text1 {
- margin-left: 5px;
- font-size: 14px;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: normal; /* 或者使用 nowrap,取决于你的布局需求 */
- }
- }
- .list-item2 {
- flex-direction: column;
- align-items: unset;
- .tags {
- display: flex;
- flex-wrap: wrap;
- .tag {
- margin-top: 5px;
- }
- }
- }
- }
- }
- }
- .menu-box {
- width: 280px;
- height: 551px;
- margin-top: 10px;
- color: #fff;
- position: relative;
- .menu-box2 {
- width: 280px;
- height: 551px;
- background: url('@/assets/images/menu/menu.png') no-repeat;
- background-size: 100% 100%;
- padding: 10px 20px 10px 24px;
- }
- .menu-btn {
- position: absolute;
- top: -5px;
- left: 50%;
- transform: translateX(-50%);
- letter-spacing: 5px;
- font-size: 16px;
- cursor: pointer;
- width: 125px;
- height: 20px;
- display: flex;
- justify-content: center;
- align-items: center;
- background: url('@/assets/images/menu/btn.png') no-repeat;
- background-size: 100% 100%;
- }
- .menu-header {
- display: flex;
- margin-top: 15px;
- height: 28px;
- .menu-item {
- width: 87px;
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- &:hover {
- position: relative;
- background: url('@/assets/images/menu/menuActive.png') no-repeat bottom center;
- background-size: 100% 100%;
- }
- .text {
- font-size: 14px;
- }
- }
- .active {
- background: url('@/assets/images/menu/menuActive.png') no-repeat bottom center;
- background-size: 100% 100%;
- }
- }
- .menu-content {
- margin: 0 0 0 -6px;
- height: 488px;
- overflow-y: auto;
- overflow-x: hidden;
- .content-box {
- padding: 0 5px;
- width: 250px;
- background: url('@/assets/images/menu/menuContent.png') no-repeat;
- background-size: 100% 100%;
- .box-header {
- height: 36px;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- font-size: 14px;
- font-weight: 500;
- position: relative;
- &::after {
- position: absolute;
- bottom: 0;
- left: 0;
- content: '';
- width: 100%;
- height: 3px;
- background-color: rgba(142, 189, 241, 0.3);
- }
- .icon1 {
- background-image: url('@/assets/images/menu/icon1.png');
- background-size: 100% 100%;
- }
- .icon2 {
- background-image: url('@/assets/images/menu/icon2.png');
- background-size: 100% 100%;
- }
- .icon3 {
- background-image: url('@/assets/images/menu/icon3.png');
- background-size: 100% 100%;
- }
- .icon4 {
- background-image: url('@/assets/images/menu/icon4.png');
- background-size: 100% 100%;
- }
- .icon5 {
- background-image: url('@/assets/images/menu/icon5.png');
- background-size: 100% 100%;
- }
- .expand-icon {
- position: absolute;
- top: 50%;
- right: 30px;
- transform: translateY(-50%);
- cursor: pointer;
- width: 11px;
- height: 6px;
- }
- .down-icon {
- background: url('@/assets/images/menu/down.png') no-repeat;
- background-size: 100% 100%;
- }
- .up-icon {
- background: url('@/assets/images/menu/up.png') no-repeat;
- background-size: 100% 100%;
- }
- }
- .box-content {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- padding: 5px 3px;
- overflow: hidden;
- .box-item-active {
- text-shadow: 0px 0px 4px #0766d6;
- }
- .box-item {
- padding: 7px 4px;
- cursor: pointer;
- font-size: 14px;
- font-family: 'PingFang SC', sans-serif;
- display: flex;
- align-items: center;
- &:hover {
- text-shadow: 0px 0px 8px #0766d6;
- }
- .checked-box {
- width: 10px;
- height: 10px;
- background: url('@/assets/images/menu/checked-box.png') no-repeat;
- background-size: 100% 100%;
- margin-right: 4px;
- }
- .checked {
- background: url('@/assets/images/menu/checked-box2.png') no-repeat;
- background-size: 100% 100%;
- }
- }
- }
- }
- }
- }
- /* 切换动画 */
- .v-enter-active,
- .v-leave-active {
- transition: opacity 0.5s ease;
- }
- .v-enter-from,
- .v-leave-to {
- opacity: 0;
- }
- </style>
|