From 8315a86149b1318114690618bfce9513fbc75f5a Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Thu, 12 Oct 2023 10:29:21 +0800 Subject: [PATCH] fix:模糊搜索修改 --- src/views/main/index.vue | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/views/main/index.vue b/src/views/main/index.vue index e8bcd35..52d2d48 100644 --- a/src/views/main/index.vue +++ b/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) { -- Gitblit v1.8.0