| | |
| | | }); |
| | | }, |
| | | /** |
| | | * 查询电源的ACDC信息 |
| | | * @param id 电源的id |
| | | * @returns {AxiosPromise} |
| | | */ |
| | | getACDCData(id) { |
| | | return axios({ |
| | | method: 'post', |
| | | url: 'PowerACDCDataAction_power_getDataByDevId', |
| | | data: 'json=' + JSON.stringify({ |
| | | powerDeviceId: id |
| | | }), |
| | | }); |
| | | }, |
| | | /** |
| | | * 查询电源实时告警 |
| | | * @param data |
| | | * @returns {AxiosPromise} |
| | | */ |
| | | getAlarmData(data) { |
| | | return axios({ |
| | | method: 'post', |
| | | url: 'PowerAlarmAction_power_getAllPage', |
| | | data: 'json=' + JSON.stringify(data), |
| | | }); |
| | | }, |
| | | /** |
| | | * 查询已经存在的机房站点 |
| | | * @param {[Object]} data 电源设备ID |
| | | */ |
| | |
| | | import axios from 'axios'; |
| | | if(process.env.NODE_ENV == 'dev') { |
| | | // 跨域请求 |
| | | axios.defaults.baseURL = 'http://localhost:8919/fg/'; |
| | | axios.defaults.baseURL = 'https://localhost:8443/fg/'; |
| | | axios.defaults.withCredentials = true; // 保持请求头 |
| | | } |
| | | |
| | |
| | | let rs = JSON.parse(res.data.result); |
| | | if (rs.code == 1) { |
| | | let data = rs.data[0]; |
| | | console.log(data); |
| | | let totalDiscSpace = data.total_disc_space; |
| | | // 设置服务器磁盘信息 |
| | | let disc_spance_percent = totalDiscSpace?((data.total_disc_space - data.free_disc_space) * 100 /totalDiscSpace ).toFixed(0):0; |
| | |
| | | </el-table-column> |
| | | <el-table-column prop="cztime" fixed="right" width="257px" align="center" label="操作"> |
| | | <template slot-scope="scope"> |
| | | <el-button :disabled="!isCanConfirm" type="primary" size="mini" @click="okAlarm(scope.row,1,'确认')">确认告警</el-button> |
| | | <el-button :disabled="!isCanQuit" type="success" size="mini" @click="okAlarm(scope.row,0,'取消')">取消确认</el-button> |
| | | <el-button :disabled="!isCanConfirm" type="primary" size="mini" @click="okAlarm(scope.row,1,'确认')">确认告警 |
| | | </el-button> |
| | | <el-button :disabled="!isCanQuit" type="success" size="mini" @click="okAlarm(scope.row,0,'取消')">取消确认 |
| | | </el-button> |
| | | <el-button :disabled="!isCanDel" type="danger" size="mini" @click="delteTim(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | <!-- 底部分页 --> |
| | | <div class="flex-page-footer" slot="footer"> |
| | | <div class="el-pagination-btns"> |
| | | <el-button type="primary" round size="mini" icon="el-icon-search" @click="searchData">查询</el-button> |
| | | <el-button type="primary" round size="mini" icon="el-icon-search" @click="startSearchData">查询</el-button> |
| | | <el-button type="primary" round size="mini" icon="el-icon-wallet" @click="exportFile">导出</el-button> |
| | | </div> |
| | | <el-pagination class="pagess" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryInfo.pagenum" |
| | | :page-sizes="[10, 20, 30, 50, 100]" :page-size="queryInfo.pagesize" layout="total, sizes, prev, pager, next, jumper" |
| | | <el-pagination class="pagess" @size-change="handleSizeChange" @current-change="handleCurrentChange" |
| | | :current-page="queryInfo.pagenum" |
| | | :page-sizes="[10, 20, 30, 50, 100]" :page-size="queryInfo.pagesize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="total"></el-pagination> |
| | | <!-- <el-button type="primary" round size="mini" icon="el-icon-wallet">全部选中</el-button> --> |
| | | </div> |
| | |
| | | // 引入导出表格 |
| | | import {export_json_to_excel} from '../../assets/js/excel/Export2Excel.js' |
| | | import { checkboxs,estateFn } from '../../assets/js/alarmAdmian/powerInfoData' |
| | | |
| | | export default { |
| | | data() { |
| | | let permits = this.$store.state.user.permits; |
| | |
| | | let isCanQuit = isHasPermit('batt_alm_clear_permit', permits); |
| | | let isCanDel = isHasPermit('batt_alm_delete_permit', permits); |
| | | return { |
| | | timer: new Timeout(), |
| | | isCanConfirm: isCanConfirm, |
| | | isCanQuit: isCanQuit, |
| | | isCanDel: isCanDel, |
| | |
| | | this.searchProvince();//查询省 |
| | | }, |
| | | methods: { |
| | | startSearchData() { |
| | | this.timer.start(()=>{ |
| | | this.$axios.all([this.searchData()]).then(res=>{ |
| | | this.timer.open(); |
| | | }).catch(error=>{ |
| | | this.timer.open(); |
| | | console.log(error); |
| | | }); |
| | | }, 4000); |
| | | }, |
| | | searchData() { |
| | | // 初始化WebSocket |
| | | this.close(); |
| | | this.initSocket(); |
| | | }, |
| | | initSocket() { |
| | | // 未被初始化初始化 |
| | | if(!this.isOpen) { |
| | | const wsUri = getWsUrl("", 55001); |
| | | this.socket = new WebSocket(wsUri); |
| | | this.socket.onmessage = this.onMessage; |
| | | this.socket.onopen = this.onOpen; |
| | | this.socket.onerror = this.onError; |
| | | this.socket.onclose = this.close; |
| | | } |
| | | }, |
| | | onMessage(res) { |
| | | let rs = JSON.parse(res.data); |
| | | this.$apis.dataMager.powerMager.getAlarmData(this.paramsData()).then(res=>{ |
| | | let rs = JSON.parse(res.data.result); |
| | | if (rs.code == 1 && rs.data && rs.data.obj.length > 0) { |
| | | this.total=rs.data.totalSize; |
| | | this.table.datas = rs.data.obj.map(function(item){ |
| | |
| | | this.total=0; |
| | | this.table.datas = []; |
| | | } |
| | | }, |
| | | onOpen() { |
| | | // 标识正在运行 |
| | | this.isOpen = true; |
| | | |
| | | let obj = { |
| | | userId:'1', |
| | | pageInfo:{ |
| | | pageNum:this.queryInfo.pagenum, |
| | | pageSize:this.queryInfo.pagesize |
| | | } |
| | | } |
| | | // 向后台发送请求数据 |
| | | this.socket.send(JSON.stringify(this.paramsData())); |
| | | }, |
| | | onError() { |
| | | console.log('链接失败') |
| | | }, |
| | | close() { |
| | | // 关闭websocket |
| | | if (this.isOpen) { |
| | | // 打印关闭信息 |
| | | console.log("关闭电源实时告警WebSocket"); |
| | | this.isOpen = false; |
| | | this.socket.close(); |
| | | } |
| | | }).catch(error=>{ |
| | | this.total = 0; |
| | | this.table.datas = []; |
| | | console.log(error); |
| | | }) |
| | | }, |
| | | // 构造查询条件 |
| | | paramsData:function(){ |
| | |
| | | // 重置分页信息 |
| | | this.queryInfo.pagenum = 1; |
| | | // 查询数据 |
| | | this.searchData(); |
| | | this.startSearchData(); |
| | | }, |
| | | searchProvince() { // 查询省 |
| | | // this.loading = this.$layer.loading(1); |
| | |
| | | value: '' |
| | | }]; |
| | | // 查询数据 |
| | | this.initSocket(); |
| | | this.startSearchData(); |
| | | return; |
| | | } |
| | | |
| | |
| | | this.filters.data.home = data; |
| | | |
| | | // 查询数据 |
| | | this.searchData(true); |
| | | this.startSearchData(true); |
| | | }); |
| | | }, |
| | | // 数据处理 |
| | |
| | | } |
| | | return -1; |
| | | }, |
| | | |
| | | |
| | | |
| | | // 导出表格 |
| | |
| | | type: 'success', |
| | | message:'删除成功!' |
| | | }); |
| | | vm.searchData(); |
| | | vm.startSearchData(); |
| | | }else{ |
| | | vm.$message({ |
| | | type: 'error', |
| | |
| | | type: 'success', |
| | | message: msg + '告警成功!' |
| | | }); |
| | | vm.searchData(); |
| | | vm.startSearchData(); |
| | | } |
| | | }).catch(err=>{ |
| | | this.$message({ |
| | |
| | | handleSizeChange(newSize) { |
| | | this.queryInfo.pagesize = newSize; |
| | | /*console.log(`每页 ${val} 条`); */ |
| | | this.searchData(); |
| | | this.startSearchData(); |
| | | }, |
| | | handleCurrentChange(newPage) { |
| | | this.queryInfo.pagenum = newPage; |
| | | /*console.log(`当前页: ${val}`); */ |
| | | this.searchData(); |
| | | this.startSearchData(); |
| | | }, |
| | | }, |
| | | destroyed() { |
| | | window.onresize = null; |
| | | this.close(); |
| | | this.timer.stop(); |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | } |
| | | |
| | | /* 过滤条件 */ |
| | | |
| | | .tdOne { |
| | | width: 30%; |
| | | |
| | | .inputOne { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | |
| | | li { |
| | | display: block; |
| | | width: 22%; |
| | |
| | | line-height: 1rem; |
| | | } |
| | | } |
| | | |
| | | .inputTwo{ |
| | | li { |
| | | width: 30%; |
| | |
| | | import AnalogTabPane from "@/pages/dataMager/components/AnalogTabPane"; |
| | | import WarnTabPane from "@/pages/dataMager/components/WarnTabPane"; |
| | | import StateTabPane from "@/pages/dataMager/components/StateTabPane"; |
| | | import IsolatingDeviceTabPane from "@/pages/dataMager/components/IsolatingDeviceTabPane"; |
| | | import ChargerStatusTabPane from "@/pages/dataMager/components/ChargerStatusTabPane"; |
| | | import {getPowerInfo} from "@/pages/dataMager/js"; |
| | | import {getWsUrl} from "@/assets/js/tools"; |
| | | import {Timeout} from "@/assets/js/tools"; |
| | | import ContentBox from "@/components/ContentBox"; |
| | | |
| | | export default { |
| | | components: { |
| | | ContentBox, |
| | | // ChargerStatusTabPane, |
| | | // IsolatingDeviceTabPane, |
| | | StateTabPane, |
| | | WarnTabPane, |
| | | AnalogTabPane, |
| | | }, |
| | | data() { |
| | | return { |
| | | timer: new Timeout(), |
| | | acTabs: 'analog', |
| | | info: getPowerInfo(), |
| | | socket: "", |
| | |
| | | }, |
| | | methods: { |
| | | getPowerInfo(powerDeviceId) { |
| | | this.powerInfo = powerDeviceId; |
| | | this.powerInfo.powerDeviceId = powerDeviceId; |
| | | this.$apis.dataMager.powerMager.getInfoById({ |
| | | powerDeviceId: powerDeviceId |
| | | }).then(res => { |
| | |
| | | stationName5: "", |
| | | }; |
| | | } |
| | | // 初始化WebSocket |
| | | this.close(); |
| | | this.initSocket(); |
| | | // 启动查询 |
| | | this.startSearch(); |
| | | }).catch(error => { |
| | | console.log(error); |
| | | }); |
| | |
| | | break; |
| | | } |
| | | }, |
| | | initSocket() { |
| | | let isInit = this.acTabs == "analog" || this.acTabs == "warn" || this.acTabs == "state"; |
| | | if (isInit) { |
| | | // 未被初始化初始化 |
| | | if (!this.isOpen) { |
| | | const wsUri = getWsUrl("websocket/powerACDCData", 55000); |
| | | this.socket = new WebSocket(wsUri); |
| | | this.socket.onmessage = this.onMessage; |
| | | this.socket.onopen = this.onOpen; |
| | | this.socket.onerror = this.onError; |
| | | this.socket.onclose = this.close; |
| | | } |
| | | startSearch() { |
| | | this.timer.start(()=>{ |
| | | this.$axios.all([this.searchPowerACDCInfo()]).then(()=>{ |
| | | // 启动循环 |
| | | this.timer.open(); |
| | | }).catch(error=>{ |
| | | // 启动循环 |
| | | this.timer.open(); |
| | | }); |
| | | }, 4000); |
| | | }, |
| | | searchPowerACDCInfo() { |
| | | this.$apis.dataMager.powerMager.getACDCData(this.powerInfo.powerDeviceId).then(res=>{ |
| | | let rs = JSON.parse(res.data.result); |
| | | if (rs.code == 1 && rs.data.length != 0) { |
| | | this.info = rs.data[0]; |
| | | } else { |
| | | this.close(); |
| | | this.info = getPowerInfo(); |
| | | } |
| | | }).catch(error=>{ |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | onMessage(res) { |
| | | let rs = JSON.parse(res.data); |
| | |
| | | this.info = rs.data[0]; |
| | | } else { |
| | | this.info = getPowerInfo(); |
| | | } |
| | | }, |
| | | onOpen() { |
| | | // 标识正在运行 |
| | | this.isOpen = true; |
| | | // 向后台发送请求数据 |
| | | this.socket.send(this.powerInfo.powerDeviceId); |
| | | }, |
| | | onError() { |
| | | |
| | | }, |
| | | close() { |
| | | // 关闭websocket |
| | | if (this.isOpen) { |
| | | // 打印关闭信息 |
| | | console.log("关闭电源实时监控WebSocket"); |
| | | this.isOpen = false; |
| | | this.socket.close(); |
| | | } |
| | | }, |
| | | }, |
| | |
| | | destroyed() { |
| | | // 关闭监听 |
| | | window.removeEventListener('resize', this.resize); |
| | | this.close(); |
| | | // 关闭计时器 |
| | | this.timer.stop(); |
| | | } |
| | | } |
| | | </script> |