From 4231b4406ee43a42234ce47d41bcf4b94c48c138 Mon Sep 17 00:00:00 2001 From: whyczyk <525500596@qq.com> Date: 星期二, 10 八月 2021 15:42:37 +0800 Subject: [PATCH] 参数设置界面开发 --- src/components/site/siteList.vue | 145 +++++++++++++++++++++++++----------------------- 1 files changed, 75 insertions(+), 70 deletions(-) diff --git a/src/components/site/siteList.vue b/src/components/site/siteList.vue index 3a73b99..dcdfc60 100644 --- a/src/components/site/siteList.vue +++ b/src/components/site/siteList.vue @@ -4,7 +4,8 @@ <van-collapse-item v-for="(item,i) in dataList" :key="i" :title="item.label" :name="i"> <span> <ul> - <li v-for="(element,i) in item.list" class="group_name" @click="toRouter(element)">{{ element.BattGroupName }}</li> + <li v-for="(element,i) in item.list" class="group_name" @click="toRouter(element)" :key="i"> + {{ element.BattGroupName }}</li> </ul> </span> </van-collapse-item> @@ -19,102 +20,106 @@ </div> </template> <script> -import { searchStation,searchBattInfo } from "@/assets/js/api"; -export default { - data(){ - return { - finished: false, - dataList:[], - activeNames:[], - } - }, - mounted(){ - this.searchStation(); - }, - methods:{ - searchStation:function(){ - let self = this; + import { + searchStation, + searchBattInfo + } from "@/assets/js/api"; + export default { + data() { + return { + finished: false, + dataList: [], + activeNames: [], + } + }, + mounted() { + this.searchStation(); + }, + methods: { + searchStation: function () { + let self = this; searchStation({ - StationName1:"", - StationName2:"", - StationName5:"", - }).then((res)=>{ + StationName1: "", + StationName2: "", + StationName5: "", + }).then((res) => { let rs = JSON.parse(res.data.result); let data = []; - if(rs.code == 1) { + if (rs.code == 1) { data = rs.data; console.log(data) } // 鏍煎紡鍖栨暟鎹� this.formatData(data); }); - }, - formatData(data) { - let self = this; - let homeList = []; - // 閬嶅巻鏁版嵁鏋勯�犳爲鐘� - data.forEach((item,i)=>{ - let tmp = {}; - tmp.label = item.StationName1+"-"+item.StationName2+"-"+item.StationName5+"-"+item.StationName3; - tmp.key = item.FBSDeviceId+Math.random(); - tmp.id = item.FBSDeviceId; - tmp.data = item; - let index = this.checkValIsIn(tmp.label, homeList); - if(index == -1) { - tmp.list = []; - homeList.push(tmp); + }, + formatData(data) { + let self = this; + let homeList = []; + // 閬嶅巻鏁版嵁鏋勯�犳爲鐘� + data.forEach((item, i) => { + let tmp = {}; + tmp.label = item.StationName1 + "-" + item.StationName2 + "-" + item.StationName5 + "-" + + item.StationName3; + tmp.key = item.FBSDeviceId + Math.random(); + tmp.id = item.FBSDeviceId; + tmp.data = item; + let index = this.checkValIsIn(tmp.label, homeList); + if (index == -1) { + tmp.list = []; + homeList.push(tmp); + } + }); + self.dataList = homeList; + self.finished = true; + }, + checkValIsIn(val, arr) { + for (let i = 0; i < arr.length; i++) { + if (arr[i].label == val) { + return i; + } } - }); - self.dataList = homeList; - self.finished = true; - }, - checkValIsIn(val, arr) { - for(let i=0; i<arr.length; i++) { - if(arr[i].label == val) { - return i; - } - } - return -1; - }, - // 鏌ヨ鐢垫睜缁� - changeList(){ - let self = this; - self.$nextTick(()=>{ + return -1; + }, + // 鏌ヨ鐢垫睜缁� + changeList() { + let self = this; + self.$nextTick(() => { self.activeNames.forEach(item => { let arr = self.dataList[item].list; - if(arr.length<1){ + if (arr.length < 1) { console.log(self.dataList[item]) let objs = self.dataList[item].data; searchBattInfo({ - StationName1:objs.StationName1, - StationName2:objs.StationName2, - StationName5:objs.StationName5, - StationName3:objs.StationName3 - }).then(res=>{ + StationName1: objs.StationName1, + StationName2: objs.StationName2, + StationName5: objs.StationName5, + StationName3: objs.StationName3 + }).then(res => { let re = JSON.parse(res.data.result) - re.data.forEach(element => { - self.dataList[item].list.push(element); - }); + re.data.forEach(element => { + self.dataList[item].list.push(element); + }); }) } }); }) - - }, - // 璺宠浆 - toRouter(element){ - let self = this; + + }, + // 璺宠浆 + toRouter(element) { + let self = this; self.$router.push({ path: '/functionList', - query:element + query: element }) + } } - } -} + } </script> <style scoped> - .group_name{ + .group_name { margin-bottom: 14px; margin-left: 10px; } -- Gitblit v1.9.1