quanyawei
2024-04-11 39b58503e7fd4929a86c7b6accf8a582e02f077f
src/views/main/index.vue
@@ -1,8 +1,11 @@
<template>
  <div class="dashboard-container" style="height: 100%">
  <div
    class="dashboard-container"
    style="height: 100%"
  >
    <el-container style="height: 100%; border: 1px solid #eee">
      <el-aside
        v-if="this.$store.state.aside"
        v-if="$store.state.aside"
        width="260px"
        style="background-color: rgb(238, 241, 246)"
      >
@@ -42,7 +45,10 @@
            prefix-icon="el-icon-search"
          />
        </div>
        <el-menu :default-openeds="openeds" class="elwidth">
        <el-menu
          :default-openeds="openeds"
          class="elwidth"
        >
          <el-submenu
            v-for="(item, index) in defaultData"
            :key="index"
@@ -70,7 +76,7 @@
                  'circle-3': item.state == 3,
                  'circle-4': item.state == 4,
                  'circle-5': item.state == 5,
                  'circle-6': item.state == 6,
                  'circle-6': item.state >= 6,
                }"
              />
@@ -122,7 +128,7 @@
      <el-container>
        <!-- <Map :mpid="monitorPointId" :rc="regionCode" /> -->
        <compoment
          :is="this.$store.state.type"
          :is="$store.state.type"
          v-if="weidu && jingdu"
          ref="child"
          :weidu="weidu"
@@ -144,6 +150,7 @@
<script>
// import Cookies from 'js-cookie'
import '@/assets/icon/iconfont.css'
import _ from 'lodash'
// import $ from 'jquery'
import Map from '@/components/Wind/Map.vue'
import LineChart from '@/components/Echarts/LineChart'
@@ -154,30 +161,30 @@
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130],
  },
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}
export default {
  components: {
    Map,
    LineChart,
    Charts,
    ReportForm,
    ReportForm
    // vLineChart
  },
  data() {
  data () {
    return {
      openeds: [],
      searchText: '',
@@ -196,91 +203,65 @@
      jingdu: 0,
      weidu: 0,
      options: [],
      newRegion: [],
      newRegion: []
    }
  },
  computed: {
    changeCity() {
    changeCity () {
      return this.$store.state.regionCode
    },
    }
  },
  watch: {
    searchText(newVal, oldVal) {
      // console.log(oldVal)
    searchText (newVal, oldVal) {
      console.log(typeof (newVal))
      // console.log(newVal)
      // defaultData是站点名,包含设备
      // this.openeds="['1','2','3']"
      if (newVal !== oldVal) {
        // let that = this
        const newDefaultData = [
          {
            name: '',
            devices: [],
          },
        ]
        let ke = 1
        this.defaultData.forEach((v, k, a) => {
          for (let i = 0; i < v.devices.length; i++) {
            // console.log(v.devices[i].name)
            if (v.devices[i].name.match(newVal)) {
              // console.log(v)
              // console.log('匹配')
              this.openeds.push((ke++).toString())
              // return value.devices[i].name.match(newVal)
              newDefaultData[k].name = this.defaultData[k].name
              newDefaultData[k].devices.push(v.devices[i])
              // this.$set(newDefaultData[k], 'name', this.defaultData[k].name)
              // this.$set(newDefaultData[k], 'devices', v.devices[i])
              // console.log(newDefaultData)
            } else {
              // console.log('不匹配')
              // return value.name.match(newVal)
            }
            // console.log(newDefaultData)
          }
        })
        // const newDevices = this.defaultData.filter(value => {
        // const newDevices = this.defaultData.filter(value => {
        //   for (let i = 0; i < value.devices.length; i++) {
        //     console.log(value.devices[i].name)
        //     if (value.devices[i].name.match(newVal)) {
        //       console.log('匹配')
        //       this.openeds.push((ke++).toString())
        //       return value.devices[i].name.match(newVal)
        //       this.newDefaultData.push(value.devices[i].name.match(newVal))
        //     } else {
        //       console.log('不匹配')
        //       return value.name.match(newVal)
        //     }
        //   }
        // })
        // console.log(this.openeds)
        this.defaultData = newDefaultData
      }
      const copyData = _.cloneDeep(this.defaultDataMiddle)
      this.defaultData = copyData
      this.openeds = []
      const arr = []
      let ke = 1
      const jList = []
      if (newVal === '') {
        this.defaultData = this.defaultDataMiddle
        this.defaultData = copyData
        this.openeds = []
        return
      }
      if (newVal !== oldVal) {
        for (var i = 0; i < this.defaultData.length; i++) {
          for (var j = 0; j < this.defaultData[i].devices.length; j++) {
            if (this.defaultData[i].devices[j].name.indexOf(newVal.toUpperCase()) >= 0) {
              this.openeds.push((ke++).toString())
              jList.push(this.defaultData[i].devices[j])
            }
          }
          console.log(arr)
        }
        this.defaultData = jList
        console.log(this.defaultData)
      }
    },
    changeCity(newVal, oldVal) {
    changeCity (newVal, oldVal) {
      // console.log(newVal)
      if (newVal !== oldVal) {
        // this.$store.state.regionCode = newVal
        // this.newRegion = newVal
        this.getRegionApi()
      }
    },
    }
  },
  beforeCreate() {
  beforeCreate () {
    // this.$store.state.regionCode = this.$route.params.cName
  },
  created() {
  created () {
    this.getData()
    this.getRegion()
  },
  methods: {
    // 百度经纬度转高德经纬度
    bd09togcj02(bd_lon, bd_lat) {
    bd09togcj02 (bd_lon, bd_lat) {
      var x_pi = (3.14159265358979324 * 3000.0) / 180.0
      var x = bd_lon - 0.0065
      var y = bd_lat - 0.006
@@ -291,7 +272,7 @@
      return [gg_lat, gg_lng]
    },
    // 父组件点击站点列表子组件跳转地图方法
    jump(items) {
    jump (items) {
      console.log(items)
      this.jumpData = []
      // const newLL = this.bd09togcj02(items.longitude, items.latitude)
@@ -302,7 +283,8 @@
      this.$refs.child.jumpMap(this.jumpData)
    },
    // 跳转设备详情页
    deviceDetail(mac, item, items, indexs) {
    deviceDetail (mac, item, items, indexs) {
      // this.$message.warning('该功能优化中,暂不支持开放')
      // console.log('这是传输过去的值')
      // console.log(mac)
      // console.log(item)
@@ -325,19 +307,19 @@
          device: items,
          macName: mac,
          indexs: indexs,
          items: [items.latitude, items.longitude],
          items: [items.latitude, items.longitude]
        },
        query: {
          monitorPointInfo: JSON.stringify(item),
          device: JSON.stringify(items),
          macName: mac,
          indexs: indexs,
          items: [items.latitude, items.longitude],
        },
          items: [items.latitude, items.longitude]
        }
      })
    },
    // 改变regionCode触发子组件重新请求五分钟接口功能
    getRegionApi() {
    getRegionApi () {
      // console.log('执行getRegionApi')
      // console.log(this.newRegion[this.newRegion.length - 1])
      this.$store.state.regionCode = this.newRegion[this.newRegion.length - 1]
@@ -349,15 +331,15 @@
      console.log(this.jingdu, '经度')
    },
    // 请求左侧设备数据
    getData() {
    getData () {
      this.monitorPointIds = []
      this.$request({
        url: '/monitorPoint/queryMonitorPoints',
        url: '/monitorPoint/queryMonitorPointsState',
        method: 'get',
        params: {
          organizationId: this.organizationId,
          regionCode: this.$store.state.regionCode,
        },
          regionCode: this.$store.state.regionCode
        }
      })
        .then((res) => {
          console.log(res, '123')
@@ -409,13 +391,13 @@
          this.defaultData = []
        })
    },
    getRegion() {
    getRegion () {
      this.$request({
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId,
        },
          organizationId: this.$store.state.orgId
        }
      })
        .then((res) => {
          // console.log('请求主页getMapPath成功')
@@ -425,19 +407,19 @@
          for (let i = 0; i < data.length; i++) {
            this.options.push({
              value: data[i].provinceCode,
              label: data[i].provinceName,
              label: data[i].provinceName
            })
            this.options[i].children = []
            for (let j = 0; j < data[i].cities.length; j++) {
              this.options[i].children.push({
                value: data[i].cities[j].cityCode,
                label: data[i].cities[j].cityName,
                label: data[i].cities[j].cityName
              })
              this.options[i].children[j].children = []
              for (let k = 0; k < data[i].cities[j].areas.length; k++) {
                this.options[i].children[j].children.push({
                  value: data[i].cities[j].areas[k].areaCode,
                  label: data[i].cities[j].areas[k].areaName,
                  label: data[i].cities[j].areas[k].areaName
                })
              }
            }
@@ -448,7 +430,7 @@
          console.log(err)
        })
      // console.log('请求Region结束')
    },
    }
    // 请求地图数据
    // getMap() {
    //   axios.get('http://47.99.64.149:8080/screen_api_v2/screen/newMap-page?areaCode=130900&accountId=223')
@@ -460,7 +442,7 @@
    //       console.log('失败')
    //     })
    // }
  },
  }
}
</script>