quanyawei
2023-10-11 8ecfcc670c6059b37833a95214896e4ad2463988
src/views/main/index.vue
@@ -154,27 +154,27 @@
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() {
@@ -196,66 +196,35 @@
      jingdu: 0,
      weidu: 0,
      options: [],
      newRegion: [],
      newRegion: []
    }
  },
  computed: {
    changeCity() {
      return this.$store.state.regionCode
    },
    }
  },
  watch: {
    searchText(newVal, oldVal) {
      // console.log(oldVal)
      // console.log(newVal)
      // defaultData是站点名,包含设备
      // this.openeds="['1','2','3']"
      this.openeds = []
      let ke = 1
      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)
        var arr = []
        for (var i = 0; i < this.defaultData.length; i++) {
          this.openeds.push((ke++).toString())
          for (var j = 0; j < this.defaultData[i].devices.length; j++) {
            if (this.defaultData[i].devices[j].name.indexOf(newVal) >= 0) {
              let a = []
              a = this.defaultData[i]
              a.devices = [this.defaultData[i].devices[j]]
              arr.push(a)
            }
            // 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
        }
        this.defaultData = arr
      }
      if (newVal === '') {
        this.defaultData = this.defaultDataMiddle
@@ -269,7 +238,7 @@
        // this.newRegion = newVal
        this.getRegionApi()
      }
    },
    }
  },
  beforeCreate() {
    // this.$store.state.regionCode = this.$route.params.cName
@@ -279,6 +248,7 @@
    this.getRegion()
  },
  methods: {
    // 百度经纬度转高德经纬度
    bd09togcj02(bd_lon, bd_lat) {
      var x_pi = (3.14159265358979324 * 3000.0) / 180.0
@@ -326,15 +296,15 @@
          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触发子组件重新请求五分钟接口功能
@@ -357,8 +327,8 @@
        method: 'get',
        params: {
          organizationId: this.organizationId,
          regionCode: this.$store.state.regionCode,
        },
          regionCode: this.$store.state.regionCode
        }
      })
        .then((res) => {
          console.log(res, '123')
@@ -415,8 +385,8 @@
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId,
        },
          organizationId: this.$store.state.orgId
        }
      })
        .then((res) => {
          // console.log('请求主页getMapPath成功')
@@ -426,19 +396,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
                })
              }
            }
@@ -449,7 +419,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')
@@ -461,7 +431,7 @@
    //       console.log('失败')
    //     })
    // }
  },
  }
}
</script>