quanyawei
2023-10-12 8315a86149b1318114690618bfce9513fbc75f5a
fix:模糊搜索修改
1 files modified
30 ■■■■■ changed files
src/views/main/index.vue 30 ●●●●● patch | view | raw | blame | history
src/views/main/index.vue
@@ -144,6 +144,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'
@@ -206,29 +207,32 @@
  },
  watch: {
    searchText(newVal, oldVal) {
      // console.log(oldVal)
      console.log(typeof (newVal))
      // console.log(newVal)
      // defaultData是站点名,包含设备
      const copyData = _.cloneDeep(this.defaultDataMiddle)
      this.openeds = []
      const arr = []
      let ke = 1
      const jList = []
      if (newVal === '') {
        this.defaultData = copyData
        this.openeds = []
        return
      }
      if (newVal !== oldVal) {
        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)
            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 = arr
      }
      if (newVal === '') {
        this.defaultData = this.defaultDataMiddle
        this.openeds = []
        this.defaultData = jList
        console.log(this.defaultData)
      }
    },
    changeCity(newVal, oldVal) {