Browse Source

getCheckedMap

xicheng79 3 years ago
parent
commit
dbc7e5f8cb

+ 9 - 8
src/components/LayerSelector.vue

@@ -17,17 +17,17 @@
           v-model="checkMapList"
           @change="checkedMapsChange"
         >
-          <el-checkbox label="文化地图"></el-checkbox>
-          <el-checkbox label="在线地图"></el-checkbox>
+          <el-checkbox label="cdut">文化地图</el-checkbox>
+          <el-checkbox label="tiandi">在线地图</el-checkbox>
         </el-checkbox-group>
       </div>
 
       <div class='info-content' id="info-content" v-show="infomapShow">
         <el-checkbox-group v-model="checkTagList" @change="checkedTagsChange">
-          <el-checkbox label="最新通知"></el-checkbox>
-          <el-checkbox label="实时新闻"></el-checkbox>
-          <el-checkbox label="校园文化" disabled></el-checkbox>
-          <el-checkbox label="更多" ></el-checkbox>
+          <el-checkbox label="noticeLayer">最新通知</el-checkbox>
+          <el-checkbox label="reportLayer">实时新闻</el-checkbox>
+          <el-checkbox label="cultureLayer" disabled>校园文化</el-checkbox>
+          <el-checkbox label="otherLayer" >更多</el-checkbox>
         </el-checkbox-group>
       </div>
     </div>
@@ -42,8 +42,9 @@ export default {
     basemapShow: false,
     // 信息控件 可见性
     infomapShow: false,
-    checkMapList: ['文化地图', '在线地图'],
-    checkTagList: ['最新通知', '实时新闻', '校园文化', '更多']
+    // checkMapList: ['文化地图', '在线地图'],
+    checkMapList: ['cdut', 'tiandi'],
+    checkTagList: ['noticeLayer', 'reportLayer', 'cultureLayer', 'otherLayer']
   }),
 
   watch: {

+ 87 - 31
src/components/map.vue

@@ -99,7 +99,7 @@ import more from '../assets/icon/more.svg'
 import DrawShape from '../../static/js/startDrawShape'
 
 // card
-import phoneCard from './Card.vue'
+import phoneCard from './card.vue'
 
 // slogan
 import slogan from './slogan.vue'
@@ -166,6 +166,23 @@ export default {
           })
         })
       },
+
+      otherStyles: { // 更多 标注 样式
+        Point: new Style({
+          image: new Icon({
+            crossOrigin: 'anonymous',
+            src: more,
+            scale: 0.25
+          })
+        }),
+        LineString: new Style({
+          stroke: new Stroke({
+            color: '#f51a51',
+            width: 6
+          })
+        })
+      },
+
       // popup的overlay对象
       popup: null,
       popupData: { //  PC端 地图弹出框信息
@@ -202,19 +219,22 @@ export default {
       let leftTop = [104.134737921, 30.6924231322]
       let rightBottom = [104.155317192, 30.6466570878]
       rightBottom = this.getExtentFromPNG(leftTop, rightBottom)
-      // console.log('top:' + leftTop)
-      // console.log('bottom:' + rightBottom)
       leftTop = olProj.fromLonLat(leftTop)
       rightBottom = olProj.fromLonLat(rightBottom)
       // 根据设备的不同设置地图范围
       const MOBILE = [leftTop[0], rightBottom[1], rightBottom[0], leftTop[1]]
-      // const MOBILE = [11591641.84, 3587409, 11594985.96, 3594153.87]
-      const PC = [11589871, 3589520, 11599383, 3592463]
+      // const PC = [11591064, 3589994, 11595665, 3592078]
+      const PC = [11591064, 3589994, 11596565, 3592078]
       let extent = this.$store.state.isMobile ? MOBILE : PC
       let center = [
-        (leftTop[0] + rightBottom[0]) / 2,
-        (leftTop[1] + rightBottom[1]) / 2
+        (extent[0] + extent[2]) / 2,
+        (extent[1] + extent[3]) / 2
       ]
+      // let center = [
+      //   (leftTop[0] + rightBottom[0]) / 2,
+      //   (leftTop[1] + rightBottom[1]) / 2
+      // ]
+      let zoom = this.$store.state.isMobile ? 14.5 : 15.5
 
       map = new Map({
         target: 'mapview',
@@ -226,18 +246,18 @@ export default {
             source: new XYZ({
               url: 'http://t3.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=a7baca459fe5be059d34849072e84fd0'
             }),
-            visible: true,
-            nameCN: '在线地图'
+            visible: true
+            // nameCN: '在线地图'
           }),
           //  天地图 地图标注
           new TileLayer({
             class: 'basemap',
-            title: 'tiandi-label',
+            title: 'tiandi',
             source: new XYZ({
               url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=a7baca459fe5be059d34849072e84fd0'
             }),
-            visible: true,
-            nameCN: '天地图标注'
+            visible: true
+            // nameCN: '天地图标注'
           }),
           // 文化地图
           new TileLayer({
@@ -252,8 +272,8 @@ export default {
               },
               servertype: 'geoserver',
               transition: 0
-            }),
-            nameCN: '文化地图'
+            })
+            // nameCN: '文化地图'
           })
         ],
         interactions: defaultInteractions({
@@ -261,16 +281,16 @@ export default {
         }),
         view: new View({
           center: center,
-          zoom: 14.5,
+          zoom: zoom,
           extent: extent,
           maxZoom: 18.5
         }),
-        controls: control.defaults({
-          // zoom: false
-        })
-        // controls: control.defaults().extend([
-        //   new control.MousePosition()
-        // ])
+        // controls: control.defaults({
+        //   // zoom: false
+        // }),
+        controls: control.defaults().extend([
+          new control.MousePosition()
+        ])
       })
       map.updateSize()
     },
@@ -315,7 +335,7 @@ export default {
      * @description:构建popup覆盖层
      * @returns {void}
      */
-    initOverLay: function () {
+    initPopupOverLay: function () {
       var container = document.getElementById('pcPopup')
 
       this.popup = new Overlay({
@@ -349,13 +369,13 @@ export default {
         // 首次调用,创建图层
         layer = new VectorLayer({
           title: title,
+          class: 'layer',
           className: title,
           source: new VectorSource({
           })
         })
         map.addLayer(layer)
       }
-
       // GeoJSON格式转换为ol.feature格式,样式装载
       var geometry = msg.geometry
       var style
@@ -369,6 +389,9 @@ export default {
         case 'culture':
           style = this.cultureStyles
           break
+        case 'other':
+          style = this.otherStyles
+          break
       }
       var feature = this.GeoJSON_to_Feature(geometry, style)
 
@@ -627,9 +650,13 @@ export default {
             case 'culture':
               data = await that.loadCultureByID(id)
               break
+            case 'other':
+              data = await that.loadOthersByID(id)
+              break
           }
           that.printFeature('markLayer', data, type, true, true, true)
           that.isShow = true
+          bus.$emit('closeList')
         } else {
           that.closePopup()
         }
@@ -730,6 +757,28 @@ export default {
       return res
     },
 
+    /**
+     * @description:通过id 查询载入'其他'信息
+    */
+    loadOthersByID: async function (id) {
+      var that = this
+      var res
+
+      await this.$axios
+        .post('/others/detail', {
+          id: id
+        })
+        .then(response => {
+          that.popupData.info = response.data
+          that.popupData.type = '活动通知'
+          res = response.data
+
+          res = response.data
+        })
+
+      return res
+    },
+
     /**
      * @description:设置并聚焦到popup的显示位置
      * @param {ol.coordinate}坐标
@@ -843,12 +892,12 @@ export default {
     // 底图选择 和 消息选择 的图层切换
     getCheckedMap: function (checkMapList) {
       this.checkMapList = checkMapList
-      util.map.setMapVisible(map, checkMapList)
+      util.map.setMapVisible(map, checkMapList, 'basemap')
     },
 
     getCheckedTag: function (checkTagList) {
       this.checkTagList = checkTagList
-      // util.map.setMapVisible(map, checkTagList)
+      util.map.setMapVisible(map, checkTagList, 'layer')
     },
 
     /**
@@ -866,7 +915,7 @@ export default {
       function onMouseWheel (ev) {
         window.setTimeout(function () {
           let zoom = map.getView().getZoom()
-          // console.log('zoom:' + zoom)
+          console.log('zoom:' + zoom)
           if (zoom > 15.3) {
             // slogan[0].style.display = 'none'
             that.slogan.isShow = false
@@ -941,6 +990,12 @@ export default {
                 data = res
               })
             break
+          case 'other':
+            await that.loadOthersByID(id)
+              .then(res => {
+                data = res
+              })
+            break
         }
         that.printFeature('markLayer', data, msg.type, true, true, true)
 
@@ -955,9 +1010,13 @@ export default {
       bus.$on('refreshMap', () => {
         map.removeLayer(that.getLayerByTitle('noticeLayer'))
         map.removeLayer(that.getLayerByTitle('reportLayer'))
+        map.removeLayer(that.getLayerByTitle('cultureLayer'))
+        map.removeLayer(that.getLayerByTitle('otherLayer'))
         map.removeLayer(that.getLayerByTitle('markLayer'))
         that.loadRecentNotices(7)
         that.loadRecentReports(7)
+        that.loadCulture()
+        that.loadOthers()
         that.closePopup()
       })
 
@@ -973,20 +1032,18 @@ export default {
       })
     }
   },
-
   mounted () {
     this.initMap()
-    this.initOverLay()
+    this.initPopupOverLay()
     this.busOnAction()
     this.loadRecentReports(7)
     this.loadRecentNotices(7)
-    // this.loadOthers()
+    this.loadOthers()
     this.loadCulture()
     this.openCluster()
     this.mapClick()
     this.sloganListener()
   },
-
   watch: {
     drawType: function () {
       DrawShape.closeDrawShape()
@@ -999,7 +1056,6 @@ export default {
       }
     }
   },
-
   filters: {
     // 超过100位显示省略号
     ellipsis: function (value) {

+ 14 - 1
src/components/mobileBar.vue

@@ -228,6 +228,19 @@ export default {
           this.expandClass -= 1
           break
       }
+    },
+
+    /**
+     * @description: eventBus的bus.$on 触发事件汇总
+     */
+    busOnAction: function () {
+      var that = this
+
+      // 最小化列表
+      bus.$on('closeList', () => {
+        that.resetListener = false
+        that.expandClass = 0
+      })
     }
   },
   watch: {
@@ -310,7 +323,7 @@ export default {
     this.heightListener('mobilebarBox')
     this.getReportList()
     this.setSize()
-    // this.busOnAction()
+    this.busOnAction()
   }
 }
 </script>

+ 52 - 82
src/components/pcBar.vue

@@ -57,11 +57,25 @@
                 </b-list-group>
              </div>
             </b-tab>
+             <!-- 更多 -->
+            <b-tab>
+              <template v-slot:title>
+                <i class="fa fa-flag-o" aria-hidden="true"></i>
+                更多
+              </template>
+              <div>
+                <b-list-group class="listGroup" v-for="(item,index) in data.others" :key=index>
+                  <b-list-group-item href="#" @click.self="selectItem($event,index)">
+                    ● {{item.title|ellipsis}}
+                  </b-list-group-item>
+                </b-list-group>
+             </div>
+            </b-tab>
           </b-tabs>
       </b-list-group-item>
       <!-- footer -->
       <b-list-group-item id="footer" align='center'>
-        <b-button-group  style="background:rgb(255,255,255)" v-show="tabIndex !== 2 && $store.state.isLogin === true" >
+        <b-button-group  style="background:rgb(255,255,255)" v-show="$store.state.isLogin === true" >
           <b-button variant="outline-dark" title="添加记录"  @click="$bvModal.show('addModal')"><i class="fa fa-plus" aria-hidden="true"  ></i></b-button>
 
           <b-button variant="outline-dark" title="删除记录" v-show="toolShow.delete" @click="deleteItem()"><i class="fa fa-minus" aria-hidden="true"></i></b-button>
@@ -192,22 +206,9 @@
         </b-form-group>
 
         <b-form-group id="input-group-8" label="消息附属线:" label-for="input-8">
-          <!-- <b-form-select
-            id="input-8"
-            v-model="form.related"
-            :options="['111', '222']"
-          >
-           <template v-slot:first>
-              <option :value="null">自定义</option>
-            </template>
-          </b-form-select> -->
           <b-link @click="drawRelate">添加消息附属线</b-link>
         </b-form-group>
 
-        <!-- <b-form-group id="input-group-7" label="图片:" label-for="input-7">
-          <b-form-file v-model="form.img" class="mt-3" plain  multiple accept=".jpg, .png, .gif, .jpeg, .svg"></b-form-file>
-        </b-form-group> -->
-
         <b-button type="reset" variant="danger">重置</b-button>
         <b-button type="submit" variant="primary">提交</b-button>
       </b-form>
@@ -274,7 +275,7 @@ export default {
       // 地点选择输入
       places: [],
       // 类型选择输入
-      types: ['报道', '通知'],
+      types: ['报道', '通知', '文化', '更多'],
       //  预删除的消息id号
       deleteArr: [],
       // 消息发布的表单绑定数据
@@ -330,10 +331,6 @@ export default {
           that.data.notice = response.data
           // items备份
           that.colonData.notice = JSON.parse(JSON.stringify(that.data.notice))
-
-          // 重置控制目标
-          // that.selectedID = null
-          // that.selected = null
         })
     },
 
@@ -349,10 +346,6 @@ export default {
           that.data.report = response.data
           // items备份
           that.colonData.report = JSON.parse(JSON.stringify(that.data.report))
-
-          // 重置控制目标
-          // that.selectedID = null
-          // that.selected = null
         })
     },
 
@@ -367,10 +360,20 @@ export default {
           that.data.culture = response.data
           // items备份
           that.colonData.culture = JSON.parse(JSON.stringify(that.data.culture))
+        })
+    },
 
-          // 重置控制目标
-          // that.selectedID = null
-          // that.selected = null
+    /**
+     * @description:获取更多列表数据
+     */
+    getOthersList: function () {
+      var that = this
+      this.$axios
+        .get('/others/list')
+        .then(function (response) {
+          that.data.others = response.data
+          // items备份
+          that.colonData.others = JSON.parse(JSON.stringify(that.data.others))
         })
     },
 
@@ -526,7 +529,9 @@ export default {
      * @returns {void}
      */
     deleteItem: function () {
-      var items = this.tabIndex === 0 ? this.data.notice : this.data.report
+      // var items = this.tabIndex === 0 ? this.data.notice : this.data.report
+      var items = this.getSelectedItems()
+
       var itemsType = this.getSelectedType()
       // var itemsType = this.tabIndex === 0 ? 'notice' : 'report'
 
@@ -556,9 +561,10 @@ export default {
      * @returns {void}
      */
     printMapMarkByID: function () {
+      let that = this
       bus.$emit('printMapMark', {
-        type: this.getSelectedType(),
-        id: this.getSelectedItems()[this.selectedIndex].id
+        type: that.getSelectedType(),
+        id: that.getSelectedItems()[this.selectedIndex].id
       })
     },
 
@@ -578,6 +584,10 @@ export default {
           break
         case 2:
           item = data.culture
+          break
+        case 3:
+          item = data.others
+          break
       }
       return item
     },
@@ -597,6 +607,9 @@ export default {
         case 2:
           res = 'culture'
           break
+        case 3:
+          res = 'other'
+          break
         default:
           res = null
       }
@@ -648,52 +661,6 @@ export default {
       return isSuccess
     },
 
-    // /**
-    // * @description: loginModel提交(submit)事件
-    // * @returns {void}
-    //  */
-    // submit_loginModal: function (e) {
-    //   var that = this
-    //   this.postLoginForm()
-    //     .then(res => {
-    //       if (res) {
-    //         // 登陆成功,设置登陆状态
-    //         that.$store.commit('userLogin', {
-    //           name: res.name,
-    //           uid: res.uid
-    //         })
-
-    //         // 设置token到cookie
-    //         cookie.setCookie(res.token, 0.5, 'token')
-
-    //         // 隐藏modal
-    //         that.$bvModal.hide('loginModal')
-    //       } else {
-    //         that.login.isRight = false
-    //       }
-    //     })
-    // },
-
-    // /**
-    //  * @description:向后端提交登陆表单
-    //  * @returns {void}
-    //  */
-    // postLoginForm: async function () {
-    //   var response
-
-    //   await this.$axios
-    //     .post('admin/login', {
-    //       form: {
-    //         account: this.login.account,
-    //         password: this.login.password
-    //       }
-    //     })
-    //     .then(res => {
-    //       response = res.data
-    //     })
-    //   return response
-    // },
-
     /**
      * @description:刷新列表,地图
      * @returns {void}
@@ -701,6 +668,8 @@ export default {
     refresh: function () {
       this.getNoticeList()
       this.getReportList()
+      this.getCultureList()
+      this.getOthersList()
       bus.$emit('refreshMap')
     },
 
@@ -766,6 +735,7 @@ export default {
     this.getNoticeList()
     this.getReportList()
     this.getCultureList()
+    this.getOthersList()
     this.getKeyPoint()
     this.getSlogan()
   },
@@ -824,13 +794,13 @@ export default {
         this.toolShow.delete = false
       } else {
         this.toolShow.delete = true
-        switch (this.tabIndex) {
-          case 0:
-            bus.$emit('markerShow', {
-              type: this.tabIndex,
-              id: this.data[this.tabIndex]
-            })
-        }
+        // switch (this.tabIndex) {
+        //   case 0:
+        //     bus.$emit('markerShow', {
+        //       type: this.tabIndex,
+        //       id: this.data[this.tabIndex]
+        //     })
+        // }
       }
     },
 

+ 1 - 1
src/layouts/widgets/LoginCard.vue

@@ -1,4 +1,4 @@
- <!-- loginModal -->
+<!-- loginModal -->
 <template>
 <b-modal id="loginModal" title="登 陆">
     <template v-slot:modal-title>

+ 4 - 1
src/pages/home.vue

@@ -12,7 +12,7 @@
     <div class="box" v-else style="display:flex;">
       <!-- PC端 控制模块 -->
       <PC class="pc"></PC>
-        <!-- 地图模块 -->
+      <!-- 地图模块 -->
       <Map class="map"></Map>
     </div>
   </div>
@@ -45,9 +45,12 @@ export default {
 }
  .pc {
    height: 100%;
+   width:310px
  }
  .map {
    height: 100%;
+   flex: 1;
+   /* width: calc(100% - 310px); */
  }
  .mobile {
    position: absolute;

+ 6 - 4
src/util/map.js

@@ -19,15 +19,17 @@ const basemapChange = (name) => {
   }
 }
 
-// @description:设置图层可见性
+// @description:设置底图图层可见性
 // @param {Array} titles:装有图层title的数组
-const setMapVisible = (map, titles) => {
+// @param {String} className:所操作图层的类别
+const setMapVisible = (map, titles, className) => {
   var layers = map.getLayers().array_
   for (var i = 0; i < layers.length; i++) {
-    if (layers[i].values_.class !== 'basemap') {
+    console.log(layers[i].values_.class)
+    if (layers[i].values_.class !== className) {
       continue
     }
-    if (titles.indexOf(layers[i].values_.nameCN) > -1) {
+    if (titles.indexOf(layers[i].values_.title) > -1) {
       layers[i].setVisible(true)
     } else {
       layers[i].setVisible(false)