报警管理页面设备下拉改为设备树

This commit is contained in:
xusd 2024-06-11 11:13:38 +08:00
parent 3e06c3c9ae
commit d700f40c64

View File

@ -1,10 +1,11 @@
<template> <template>
<view class="card-group"> <view class="card-group">
<u-tabs :list="tabList" @click="tabListClick"></u-tabs> <u-tabs :list="tabList" @click="tabListClick"></u-tabs>
<view class="search-container"> <u-popup :show="show" mode="bottom" :closeable = "closeable" @open= "openPopup" @close="closePopup">
<uni-data-select v-model="equipId" placeholder="请选择监测设备" :localdata="equipList" <ly-tree :tree-data="treeData" :ready="ready" node-key="id" :props="props"
@change="equipChange"></uni-data-select> :expandOnClickNode="expandOnClickNode" @node-click="handleNodeClick"></ly-tree>
</view> </u-popup>
<u-button @click="show = true">{{equipName}}</u-button>
<view class="card-group" v-if="total === 0"> <view class="card-group" v-if="total === 0">
<leruge-empty text="暂无数据" type="minus"></leruge-empty> <leruge-empty text="暂无数据" type="minus"></leruge-empty>
</view> </view>
@ -57,14 +58,30 @@
} from "@/api/alarm/alarm.js"; } from "@/api/alarm/alarm.js";
import { import {
listAllInfo listAllInfo,
getEquipTree
} from "@/api/equip/equip.js" } from "@/api/equip/equip.js"
export default { export default {
data() { data() {
return { return {
//
closeable: true,
//
show: false,
//
treeData: [],
ready: false,
props: function() {
return {
label: 'equipName',
children: 'childList'
}
},
expandOnClickNode: false,
flag: null, flag: null,
equipId: null, equipId: null,
equipName: "选择设备",
// //
finished: false, finished: false,
tipText: "正在加载...", tipText: "正在加载...",
@ -97,13 +114,26 @@
onShow() { onShow() {
this.alarmList = []; this.alarmList = [];
this.getAlarmList(); this.getAlarmList();
this.getEquipList(); // this.getEquipList();
}, },
// onLoad(opts) { // onLoad(opts) {
// this.flag = opts.flag; // this.flag = opts.flag;
// }, // },
methods: { methods: {
tabListClick(item){ openPopup(){
this.getEquipList();
},
closePopup(){
this.show = false;
},
handleNodeClick(obj) {
this.equipName = obj.label;
this.equipId = obj.key;
this.show = false;
this.alarmList = [];
this.getAlarmList();
},
tabListClick(item) {
this.finished = true; this.finished = true;
this.alarmList = [] this.alarmList = []
this.tabIndex = item.index; this.tabIndex = item.index;
@ -120,15 +150,26 @@
this.getAlarmList(); this.getAlarmList();
}, },
getEquipList() { getEquipList() {
listAllInfo().then((res) => { // listAllInfo().then((res) => {
const list = res.data; // const list = res.data;
list.forEach((item) => { // list.forEach((item) => {
const element = { // const element = {
value: item.id, // value: item.id,
text: item.equipName // text: item.equipName
} // }
this.equipList.push(element); // this.equipList.push(element);
}) // })
// })
this.ready = false;
this.treeData = [
{
"id":null,
"equipName": "所有设备"
}
];
getEquipTree(this.queryParams).then((res) => {
this.treeData = this.treeData.concat(res);
this.ready = true;
}) })
}, },
// //