| | |
| | | <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> |
| | |
| | | </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; |
| | | } |