Browse Source

设施管理,场站管理,维保动态接入数据

caner 2 years ago
parent
commit
3cb42c5f69
3 changed files with 53 additions and 50 deletions
  1. 18 21
      src/components/map/map.service.ts
  2. 10 4
      src/components/map/map.vue
  3. 25 25
      src/pages/views/home/index.vue

+ 18 - 21
src/components/map/map.service.ts

@@ -157,33 +157,30 @@ export default class MapService extends Service {
 
   // 初始化marks集合
   public _initMarks(key: string, checked: string[], item?: any) {
-    this.key = key
     this.marks[key] = {}
     for (let k = 0; k < checked.length; k++) {
       const el = checked[k]
       const icon = item.option.find((er: { value: string }) => er.value === el)?.icon
-      const newIcon = this.getIcon(icon)
+      const newIcon = this.getIcon(icon) || carIcon
       if (!this.marks[key][el]) this.marks[key][el] = {}
-      if (key === 'homePage' && el !== 'bus') {
-        // homePageMark
-        this.getMarkData(el).then((res) => {
-          // line 需要单独处理
-          if (!res.length) return
-          if (el === 'line') {
-            for (let j = 0; j < res.length; j++) {
-              const es = res[j]
-              const paths = es.child?.sort((a: { stationNo: number }, b: { stationNo: number }) => a.stationNo - b.stationNo).map((ec: { lon: string; lat: string }) => ([ +ec.lon, +ec.lat ]))
-              const color = this.colorRandom()
-              this.marks[this.key][el][es.paramId] = { markMap: this.addLine(paths, color) }
-            }
-          } else {
-            for (let z = 0; z < res.length; z++) {
-              const ez = res[z]
-              this.marks[this.key][el][ez.paramId] = { ...ez, markMap: this.addMark([ +ez.lon, +ez.lat ], newIcon) }
-            }
+      if (el === 'bus') continue
+      this.getMarkData(el).then((res) => {
+        // line 需要单独处理
+        if (!res.length) return
+        if (el === 'line') {
+          for (let j = 0; j < res.length; j++) {
+            const es = res[j]
+            const paths = es.child?.sort((a: { stationNo: number }, b: { stationNo: number }) => a.stationNo - b.stationNo).map((ec: { lon: string; lat: string }) => ([ +ec.lon, +ec.lat ]))
+            const color = this.colorRandom()
+            this.marks[key][el][es.paramId] = { markMap: this.addLine(paths, color) }
           }
-        })
-      }
+        } else {
+          for (let z = 0; z < res.length; z++) {
+            const ez = res[z]
+            this.marks[key][el][ez.paramId] = { ...ez, markMap: this.addMark([ +ez.lon, +ez.lat ], newIcon) }
+          }
+        }
+      })
     }
   }
 

+ 10 - 4
src/components/map/map.vue

@@ -46,7 +46,7 @@ const store = useStore()
 const mapService = new MapService()
 const props = withDefaults(defineProps<{
   zoom?: number,
-  Item?: { contrlSelect: { title: string, option: Any[], icon: string, checked:string[] }, key:string }
+  Item?: { contrlSelect: { title: string, option: Any[], icon: string, checked: string[] }, key: string }
 }>(), {
   zoom: 13,
   Item: () => ({
@@ -61,7 +61,7 @@ const emit = defineEmits<{(evt: 'update:contrlSelect', value: Any): void
 const checkBoxs = ref(props.Item.contrlSelect.checked)
 
 // checkBox勾选
-function checkBoxsChange(params:string[], mate:{actionType:string, value:string}) {
+function checkBoxsChange(params: string[], mate: { actionType: string, value: string }) {
   const { marks } = mapService
   console.log('勾选', marks[props.Item.key][mate.value])
   if (!Object.keys(marks[props.Item.key][mate.value]).length) return
@@ -106,13 +106,19 @@ watch(() => store.socektData, (v) => {
 
 // 菜单切换显示隐藏
 watch(() => props.Item.key, (v) => {
-  console.log('菜单切换需要重新初始化mark', v)
+  checkBoxs.value = props.Item.contrlSelect.checked
   const { marks } = mapService
+  // 添加marks
+  console.log('菜单切换需要重新初始化mark', v, marks, props)
+  if (!Object.keys(marks).includes(v)) {
+    mapService._initMarks(v, props.Item.contrlSelect.checked, props.Item.contrlSelect)
+  }
+  // 切换显示或者隐藏
   for (const k in marks) {
     for (const j in marks[k]) {
       if (Object.keys(marks[k][j]).length) {
         for (const z in marks[k][j]) {
-          if (k === props.Item.key) {
+          if (k === v) {
             marks[k][j][z].markMap.show()
           } else {
             marks[k][j][z].markMap.hide()

+ 25 - 25
src/pages/views/home/index.vue

@@ -186,16 +186,16 @@ const menus = [
       option: [
         {
           label: '维保场',
-          value: 1,
-          icon: ''
+          value: 'maintenanceStation',
+          icon: '43'
         },
         {
           label: '运维驿站',
-          value: 2,
-          icon: ''
+          value: 'operationStation',
+          icon: '43'
         }
       ],
-      checked: [ 1, 2 ]
+      checked: [ 'maintenanceStation', 'operationStation' ]
     }
   },
   {
@@ -215,31 +215,31 @@ const menus = [
       option: [
         {
           label: '车辆',
-          value: 1,
-          icon: ''
+          value: 'carInfo',
+          icon: '39'
         },
         {
           label: '电子站牌',
-          value: 2,
-          icon: ''
+          value: 'electronicStationSign',
+          icon: '43'
         },
         {
           label: '洗衣机',
-          value: 3,
-          icon: ''
+          value: 'carWasher',
+          icon: '43'
         },
         {
           label: '充电桩',
-          value: 4,
-          icon: ''
+          value: 'powerCharge',
+          icon: '42'
         },
         {
           label: '车载部件',
-          value: 5,
-          icon: ''
+          value: 'vehicleMountedComponents',
+          icon: '43'
         }
       ],
-      checked: [ 1, 2, 3, 4, 5 ]
+      checked: [ 'carInfo', 'electronicStationSign', 'carWasher', 'powerCharge', 'vehicleMountedComponents' ]
     }
   },
   {
@@ -264,26 +264,26 @@ const menus = [
       option: [
         {
           label: '枢纽站',
-          value: 1,
-          icon: ''
+          value: 'hubStation',
+          icon: '43'
         },
         {
           label: '首末站',
-          value: 2,
-          icon: ''
+          value: 'startEndStation',
+          icon: '43'
         },
         {
           label: '停保场',
-          value: 3,
-          icon: ''
+          value: 'parkingLot',
+          icon: '43'
         },
         {
           label: '维保站',
-          value: 4,
-          icon: ''
+          value: 'maintenanceStation',
+          icon: '43'
         }
       ],
-      checked: [ 1, 2, 3, 4 ]
+      checked: [ 'hubStation', 'startEndStation', 'parkingLot', 'maintenanceStation' ]
     }
   },
   {