twl 5 months ago
parent
commit
20a5eb3dfa
3 changed files with 42 additions and 11 deletions
  1. 27 6
      src/components/MapLegend.vue
  2. 14 5
      src/views/deck/IndexPage.vue
  3. 1 0
      src/views/deck/pages/Page_znfx.vue

+ 27 - 6
src/components/MapLegend.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="ml-legend" v-if="current">
+    {{data_legend[current].isOnAll}}--{{current}}
     <template v-if="data_legend[current].items">
       <div class="legend">
         <main>
@@ -35,7 +36,13 @@
 
 <script>
 import {layerControlNew} from "@/utils/map/AddLayer";
-
+const zhui =[
+  { name: '猪', img: require('@/assets/imgs/deck/page_znfx/zhu32.png'), isOn: true },
+  { name: '牛', img: require('@/assets/imgs/deck/page_znfx/niu32.png'), isOn: true },
+  { name: '羊', img: require('@/assets/imgs/deck/page_znfx/yang32.png'), isOn: true },
+  { name: '鸡', img: require('@/assets/imgs/deck/page_znfx/ji32.png'), isOn: true },
+  { name: '鸽', img: require('@/assets/imgs/deck/page_znfx/ge32.png'), isOn: true },
+]
 export default {
   name: 'MapLegend',
   props: ['checkedLayers'],
@@ -219,12 +226,16 @@ export default {
     }
   },
   methods: {
-    toggleLegend(item='all') {
+    toggleLegend(item='all',isTure) {
       // this.$emit('orgname',this.data_yzc)
       if(item==='all') {  //全部类别
-        this.data_legend[this.current].items.forEach(i => i.isOn = !this.data_legend[this.current].isOnAll)
-        this.data_legend[this.current].isOnAll = !this.data_legend[this.current].isOnAll
-        this.$bus.$emit('allAni',this.data_legend[this.current].isOnAll)
+        let isS = !this.data_legend[this.current]?.isOnAll
+        if (isTure!==undefined){
+          isS = isTure
+        }
+        this.data_legend[this.current]?.items.forEach(i => i.isOn = isS)
+        this.data_legend[this.current] && (this.data_legend[this.current].isOnAll = isS)
+        this.$bus.$emit('allAni',!isS)
       } else {  //细分类别
         console.log('888888888',item)
         this.data_legend[this.current].items.find(i => i.name===item.name).isOn = !item.isOn
@@ -236,7 +247,7 @@ export default {
       }
 
       let arr = []
-      for(let i of this.data_legend[this.current].items){
+      for(let i of this.data_legend[this.current]?.items){
         if(i.isOn){
           arr.push(i.name)
         }
@@ -259,6 +270,16 @@ export default {
       }
 
     },
+  },
+  mounted() {
+    if (!this.data_legend[this.current]?.isOnAll){
+      console.log('没有all',this.current)
+
+      this.toggleLegend('all',true)
+    }
+
+    // // this.toggleLegend('all')
+    console.log('lgend重新创建',this.current)
   }
 }
 </script>

+ 14 - 5
src/views/deck/IndexPage.vue

@@ -1,5 +1,6 @@
 <template>
   <div id="deck">
+
     <my-map @closeDrawTool="closeDrawTool" />
     <div class="header" v-show="$store.state.headerShow">
       <div class="h-left"></div>
@@ -12,7 +13,7 @@
           <img src="../../assets/imgs/deck/btn-znfx.png" alt="">
           <span>智能分析</span>
         </div>
-        <span class="hc-title">崇明数字农业智能管控系统·驾驶舱</span>
+        <span class="hc-title">崇明数字农业智能管控系统·驾驶舱    {{currentTabIndex}}</span>
         <div class="hc-btn" :class="{ 'highlight': subPanelShow === 'zhcj' }" @click="handleShowSubPanel('zhcj')">
           <img src="../../assets/imgs/deck/btn-zhcj.png" alt="">
           <span>智慧场景</span>
@@ -102,8 +103,7 @@
       </el-tree>
 
     </div>
-    <map-legend v-if="subPanelShow === 'znfx' || subPanelShow === 'zhcj' && !multiScreenMode"
-      :checked-layers="toolLayerChecked" />
+
     <!--    点查询-->
     <point-search :current-layer="listChecked.at(-1)" />
     <!--    卷帘对比-->
@@ -138,7 +138,7 @@
     </el-form>
 
     <div v-show="!multiScreenMode">
-      <page-znfx @findQjx="addQjxLayer" v-if="subPanelShow === 'znfx'" />
+      <page-znfx @findQjx="addQjxLayer"  @changeTabIndex="changeTabIndex" v-if="subPanelShow === 'znfx'" />
       <page-zhcj @findQjx="addQjxLayer" v-if="subPanelShow === 'zhcj'" />
       <page-ztgl v-if="currentMenu === '总体概览'" @changeLegend="changeLegend" />
       <page-nyxz v-if="layerStaShow.nydxz" />
@@ -304,7 +304,12 @@
     </div>
     <SearchBar v-if="searchShow" :point-search-show="pointSearchShow" :layer-tree-show="layerTreeShow" />
     <!--    v-show="!isZhgcLayerDetail"-->
-    <MapLegend :checked-layers="legendLayerArr" :class="{ 'to-left': currentMenu !== '总体概览' }" />
+
+
+
+    <map-legend :key="currentTabIndex"  v-if="subPanelShow === 'znfx' || subPanelShow === 'zhcj' && !multiScreenMode"
+                :checked-layers="toolLayerChecked" />
+    <MapLegend v-else :checked-layers="legendLayerArr" :key="currentTabIndex" :class="{ 'to-left': currentMenu !== '总体概览' }" />
     <vedio-loader :vedioUrl="vedioUrl" v-if="isVedioShow" @close="isVedioShow=false"/>
   </div>
 </template>
@@ -371,6 +376,7 @@ export default {
   },
   data() {
     return {
+      currentTabIndex:2,
       // 是不是高标准农田点击了标题
       isGbzntIsClickTitle:false,
       // isZhgcLayerDetail:false,
@@ -598,6 +604,9 @@ export default {
     }
   },
   methods: {
+    changeTabIndex(index){
+       this.currentTabIndex  =index * 100 +Math.random()
+    },
     ...mapActions({
       'changeAllTownArrASync':'changeAllTownArrASync'
     }),

+ 1 - 0
src/views/deck/pages/Page_znfx.vue

@@ -72,6 +72,7 @@ export default {
   watch: {
     currentPage: {
       handler(val) {
+        this.$emit('changeTabIndex',this.currentPage)
         this.$store.commit('changeHasRight', this.menuList.find(i=>i.id===val).hasRight)
         this.$store.commit('changeToolLayers', [])
         this.$store.commit('changePointSearchShow', false)