瀏覽代碼

大屏 左侧菜单

Hwf 9 月之前
父節點
當前提交
e0607d3bdc

+ 1 - 1
.env.development

@@ -5,7 +5,7 @@ VITE_APP_TITLE = 应急指挥一张图
 VITE_APP_ENV = 'development'
 
 # 开发环境
-VITE_APP_BASE_API = '/dev-api'
+VITE_APP_BASE_API = '/api'
 
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'

+ 1 - 1
src/api/globalMap/index.ts

@@ -4,7 +4,7 @@ import { MapQuery } from './type';
 // 加载粤政图服务
 export const getMapProduct = (serviceCode: string, params) => {
   return request({
-    url: '/api/oneShare/proxyHandler/gd/' + serviceCode,
+    url: '/api/oneShare/proxyHandler/mm/' + serviceCode,
     method: 'get',
     params: params
   });

+ 49 - 20
src/components/Map/index.vue

@@ -6,9 +6,9 @@
     <div class="right-tool">
       <!--快捷缩放-->
       <QuickZoom :step="mapState.zoom" :min-step="mapState.minZoom" :max-step="mapState.maxZoom" @change-step="setMapZoom" />
-      <div class="flex" style="margin-top: 5px;">
+      <div class="flex" style="margin-top: 5px">
         <div class="model-btn" @click="switchThreeDimensional">{{ mapState.isThreeDimensional ? '3D' : '2D' }}</div>
-        <div class="model-btn" @click="changeScaleControl" style="margin-left: 5px;">尺</div>
+        <div class="model-btn" style="margin-left: 5px" @click="changeScaleControl">尺</div>
       </div>
     </div>
   </div>
@@ -32,8 +32,17 @@ const mapState = reactive({
   // 是否显示比例尺
   showScale: true
 });
-let map, scale;
-
+let map, scale, nowLayer;
+watch(
+  () => props.activeMap,
+  (value, oldValue) => {
+    if (!['logical', 'vectorgraph'].includes(props.activeMap)) {
+      switchMap(props.activeMap);
+    } else {
+      map.removeLayer(nowLayer);
+    }
+  }
+);
 // 初始化事件
 const initMap = () => {
   AMapLoader.load({
@@ -57,9 +66,11 @@ const initMap = () => {
     });
     if (!['logical', 'vectorgraph'].includes(props.activeMap)) {
       switchMap(props.activeMap);
+    } else {
+      map.removeLayer();
     }
     scale = new AMap.Scale();
-    if(mapState.showScale) {
+    if (mapState.showScale) {
       map.addControl(scale);
     }
     map.on('zoomchange', zoomChangeHandler);
@@ -79,23 +90,37 @@ const switchMap = (type) => {
         REQUEST: 'GetCapabilities'
       }
     ];
+    // var satellite = new AMap.TileLayer.Satellite();
+    // map.addLayer(satellite);
+    // nowLayer = satellite;
   }
   // map.setFeatures([]);
-  // var wms = new AMap.TileLayer.WMTS({
-  //   url: 'http://t0.tianditu.gov.cn/img_c/wmts',
-  //   // url: 'http://10.181.7.236:9988/api/oneShare/proxyHandler/mm/' + queryParamsArr[0].serverCode,
-  //   // blend: true,
-  //   // tileSize: 256,
-  //   params: {
-  //     Layer: "img",
-  //     Version: "1.0.0",
-  //     Format: "tiles",
-  //     TileMatrixSet: "w",
-  //     STYLE: "default",
-  //     tk: 'd31190edaa4190af833234ab7b1a6f27'
-  //   }
-  // });
-  // wms.setMap(map);
+  console.log(queryParamsArr[0].serviceCode);
+  var wms = new AMap.TileLayer.WMTS({
+    // url: 'http://t0.tianditu.gov.cn/img_c/wmts',
+    url: 'http://10.181.7.236:9988/api/oneShare/proxyHandler/mm/' + queryParamsArr[0].serviceCode,
+    // blend: true,
+    // tileSize: 256,
+    params: {
+      // Layer: "img",
+      // Version: "1.0.0",
+      // Format: "tiles",
+      // TileMatrixSet: "w",
+      // STYLE: "default",
+      // tk: 'd31190edaa4190af833234ab7b1a6f27'
+      // SERVICE: 'WMTS',
+      // REQUEST: 'GetTile',
+      VERSION: '1.0.0',
+      LAYER: 'gds_2m_kj202401',
+      // STYLE: 'default',
+      // TILEMATRIXSET: 'default028mm',
+      // TILEMATRIX: '9',
+      // TILEROW: '97',
+      // TILECOL: '413',
+      FORMAT: 'image/jpgpng'
+    }
+  });
+  wms.setMap(map);
 };
 
 // 缩放级别变化
@@ -192,5 +217,9 @@ onUnmounted(() => {
   :deep(.amap-scale-edgeright) {
     left: 228px !important;
   }
+  :deep(.amap-logo),
+  :deep(.amap-copyright) {
+    display: none !important;
+  }
 }
 </style>

+ 226 - 0
src/views/globalMap/LeftMenu.vue

@@ -0,0 +1,226 @@
+<template>
+  <div class="menu-container">
+    <div class="search-box">
+      <el-icon color="#fff"><Search /></el-icon>
+      <input v-model="searchText" class="input" @change="changeSearchText" />
+    </div>
+    <div class="menu-box">
+      <div class="menu-btn" @click="changExpand">{{ menuState.isExpand ? '收起' : '展开' }}</div>
+      <Transition>
+        <div v-show="menuState.isExpand">
+          <div class="menu-header">
+            <div
+              v-for="(item, index) in menuState.menuData"
+              :key="index"
+              :class="menuState.activeIndex === index ? 'menu-item active' : 'menu-item'"
+              @click="changeActive(index)"
+            >
+              {{ item.label }}
+            </div>
+          </div>
+          <div class="menu-content">
+            <div v-for="(item, index) in menuState.menuData[menuState.activeIndex]?.childrens" :key="index" class="content-box">
+              <div class="box-header">
+                <div>{{ item.label }}</div>
+                <el-icon class="icon" color="#53aee6" size="24" @click="changeBoxShow(item)">
+                  <CaretBottom v-show="item.show" />
+                  <CaretTop v-show="!item.show" />
+                </el-icon>
+              </div>
+              <Transition>
+                <div v-show="item.show" class="box-content">
+                  <div v-for="(item2, index2) in item.childrens" :key="index2" class="box-item">{{ item2.label }}</div>
+                </div>
+              </Transition>
+            </div>
+          </div>
+        </div>
+      </Transition>
+    </div>
+  </div>
+</template>
+
+<script lang="ts" setup>
+interface Props {
+  activeMap: string;
+}
+const props = withDefaults(defineProps<Props>(), {});
+const emits = defineEmits(['swtichMap']);
+
+const searchText = ref('');
+const changeSearchText = () => {
+  console.log('搜索值:', searchText.value);
+};
+
+let menuState = reactive({
+  // 是否展开菜单
+  isExpand: true,
+  menuData: [],
+  activeIndex: 0
+});
+
+// 展示收起整个菜单
+const changExpand = () => {
+  menuState.isExpand = !menuState.isExpand;
+};
+
+// 切换tab
+const changeActive = (index) => {
+  menuState.activeIndex = index;
+};
+
+// 菜单内容展开收缩
+const changeBoxShow = (item) => {
+  item.show = !item.show;
+};
+
+const initData = () => {
+  const menuData = [
+    {
+      label: '监测预警',
+      childrens: [
+        {
+          label: '防风防汛',
+          childrens: [
+            { label: '卫星云图', url: '' },
+            { label: '雷达图', url: '' },
+            { label: '气温实况图', url: '' }
+          ]
+        },
+        {
+          label: '危化品安全监测',
+          childrens: [
+            { label: '重大风险源', url: '' },
+            { label: '危化企业', url: '' }
+          ]
+        }
+      ]
+    },
+    {
+      label: '基本信息',
+      childrens: [
+        {
+          label: '基本信息1',
+          childrens: [{ label: '信息', url: '' }]
+        }
+      ]
+    },
+    { label: '分析工具' }
+  ];
+  menuData.forEach((item) => {
+    item.childrens?.forEach((item2) => {
+      item2.show = true;
+    });
+  });
+  menuState.menuData = menuData;
+};
+
+onMounted(() => {
+  initData();
+});
+</script>
+
+<style lang="scss" scoped>
+.search-box {
+  border: 1px solid #2c4a76;
+  background: #042350;
+  width: 350px;
+  height: 45px;
+  padding: 0 10px;
+  display: flex;
+  align-items: center;
+  .input {
+    border: none;
+    outline: none;
+    background: #042350;
+    color: #fff;
+    width: 100%;
+  }
+}
+.menu-box {
+  width: 350px;
+  height: 70%;
+  background-color: #041d55;
+  margin-top: 10px;
+  color: #fff;
+  padding: 10px 20px;
+  position: relative;
+  border: 1px solid #12379b;
+  .menu-btn {
+    position: absolute;
+    top: -15px;
+    left: 50%;
+    transform: translateX(-50%);
+    border: 1px solid #12379b;
+    background-color: #041d55;
+    padding: 5px 15px;
+    font-size: 16px;
+    cursor: pointer;
+  }
+  .menu-header {
+    display: flex;
+    height: 35px;
+    line-height: 35px;
+    margin-top: 20px;
+    .menu-item {
+      flex: 1;
+      min-width: 100px;
+      height: 100%;
+      font-size: 18px;
+      cursor: pointer;
+      text-align: center;
+    }
+    .active {
+      background-color: #1d4e9c;
+    }
+  }
+  .menu-content {
+    .content-box {
+      width: 100%;
+      padding: 0 10px;
+      background-color: #062f5b;
+      margin-top: 10px;
+      .box-header {
+        height: 50px;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        position: relative;
+        border-bottom: 1px solid #83cbf3;
+        .icon {
+          position: absolute;
+          right: 30px;
+          top: 50%;
+          transform: translateY(-50%);
+          cursor: pointer;
+        }
+      }
+      .box-content {
+        display: flex;
+        align-items: center;
+        flex-wrap: wrap;
+        //padding: 20px 0;
+        overflow: hidden;
+        .box-item {
+          padding: 20px 15px;
+          cursor: pointer;
+          &:hover {
+            color: #b5dff0;
+          }
+        }
+      }
+    }
+  }
+}
+
+/* 切换动画 */
+.v-enter-active,
+.v-leave-active {
+  transition: opacity 0.5s ease;
+}
+
+.v-enter-from,
+.v-leave-to {
+  opacity: 0;
+}
+</style>

+ 1 - 0
src/views/globalMap/SwitchMapTool.vue

@@ -59,6 +59,7 @@ const handleExpand = () => {
     color: #fff;
     cursor: pointer;
     flex-shrink: 0;
+    font-size: 16px;
   }
   .switch-item {
     display: inline-block;

+ 0 - 18
src/views/globalMap/ToolBox.vue

@@ -1,18 +0,0 @@
-<template>
-  55
-</template>
-
-<script lang="ts" setup>
-import SwitchMapTool from '@/views/globalMap/SwitchMapTool.vue';
-interface Props {
-  activeMap: string;
-}
-
-const props = withDefaults(defineProps<Props>(), {});
-const emits = defineEmits(['swtichMap']);
-const swtichMap2 = (key) => {
-  emits('swtichMap', key);
-};
-</script>
-
-<style lang="scss" scoped></style>

+ 4 - 2
src/views/globalMap/index.vue

@@ -2,6 +2,8 @@
   <div class="global-map">
     <MapLogical v-if="activeMap === 'logical'" :mapData="logicalData" />
     <Map v-else :activeMap="activeMap"></Map>
+    <!--    左侧菜单-->
+    <LeftMenu style="position: absolute; top: 20px; left: 20px" />
     <SwitchMapTool :activeMap="activeMap" @swtichMap="swtichMap" class="tool-box" />
   </div>
 </template>
@@ -10,8 +12,8 @@
 import Map from '@/components/Map/index.vue';
 import MapLogical from '@/components/Map/MapLogical.vue';
 import { logicalData } from './data/mapData';
-import ToolBox from './ToolBox.vue';
-import SwitchMapTool from "@/views/globalMap/SwitchMapTool.vue";
+import SwitchMapTool from '@/views/globalMap/SwitchMapTool.vue';
+import LeftMenu from './LeftMenu.vue';
 
 const mapData = reactive(logicalData);
 let activeMap = ref('satellite');