Commit ef4b9e38 authored by neogcg's avatar neogcg

export

parent 5f828a3b
No preview for this file type
<template>
<div id="app">
<router-view />
<audio controls="controls" id="my_audio" src="./assets/audio/alarm.mp3" style="display:none;" hidden="hidden" />
<div class="tips" v-if="tflag">
<audio
controls="controls"
id="my_audio"
src="./assets/audio/alarm.mp3"
style="display: none"
hidden="hidden"
/>
<!-- <div class="tips" v-if="tflag">
<p>提示</p>
<span>有一条新告警</span>
</div>
</div> -->
</div>
</template>
<script>
import { receiveMessage } from '@/utils/websocket'
import socket from '@/utils/websocket'
import { mapState } from 'vuex'
import EventBus from '@/utils/bus'
import { receiveMessage } from "@/utils/websocket";
import socket from "@/utils/websocket";
import { mapState } from "vuex";
import EventBus from "@/utils/bus";
export default {
name: 'App',
name: "App",
data() {
return {
websocket: null,
tflag: false,
}
};
},
computed: {
...mapState("user", ['userBaseInfo']),
...mapState("user", ["userBaseInfo"]),
userId() {
return this.userBaseInfo.userId
}
return this.userBaseInfo.userId;
},
},
methods: {
receiveMessage,
closeWebsocket() {
if (this.websocket) {
this.websocket.close()
this.websocket.close();
}
},
},
mounted() {
this.websocket = socket({
onmessage: this.receiveMessage
})
EventBus.$on('dialogAlarm', (data) => {
onmessage: this.receiveMessage,
});
EventBus.$on("dialogAlarm", (data) => {
// 接收消息之后 声音弹窗显示
this.tflag = data
this.tflag = data;
setTimeout(() => {
this.tflag = false
}, 3000)
})
this.tflag = false;
}, 3000);
});
// EventBus.$on("cancelWS", () => {
// this.websocket.close();
// });
// EventBus.$on("wsOpen", () => {
// this.websocket.onopen();
// });
},
watch: {
userId: {
immediate: true,
handler(newV) {
if (newV) {
this.closeWebsocket()
this.closeWebsocket();
this.websocket = socket({
onmessage: this.receiveMessage
})
}
}
onmessage: this.receiveMessage,
});
}
},
}
},
},
};
</script>
<style lang="scss" scoped>
#app {
......@@ -75,7 +87,7 @@ export default {
// background-color: #bed5ff !important;
// }
}
.tips{
.tips {
width: 400px;
height: 80px;
background: #fff;
......@@ -84,7 +96,7 @@ export default {
padding: 0 20px 20px 20px;
position: absolute;
text-align: center;
top:calc(50% - 40px);
left:calc(50% - 200px)
top: calc(50% - 40px);
left: calc(50% - 200px);
}
</style>
......@@ -27,7 +27,7 @@ import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Sidebar from './Sidebar/index.vue'
import { logout } from '@/api/user'
import EventBus from '@/utils/bus'
export default {
data() {
let timer
......@@ -57,8 +57,11 @@ export default {
logout().then(() => {
this.$store.dispatch('user/logout')
this.$router.push(`/login`)
// EventBus.$emit('cancelWS')
})
},
// 获取当前时间函数
timeFormate (timeStamp) {
let year = new Date(timeStamp).getFullYear()
......
......@@ -34,12 +34,14 @@ export const constantRoutes = [
{
path: '/login',
component: () => import('@/views/login/index'),
meta:{title:"登录"},
hidden: true
},
{
path: '/404',
component: () => import('@/views/404'),
meta:{title:"404"},
hidden: true
},
......
......@@ -45,6 +45,7 @@ const actions = {
getInfo({type: 0}).then(res => {
if (!res) return
commit('SET_BASEINFO', res)
console.log(res);
})
},
......
......@@ -2,6 +2,7 @@ import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import socket from "@/utils/websocket";
import Vue from 'vue'
// create an axios instance
......
......@@ -5,9 +5,10 @@ import EventBus from '@/utils/bus'
export default function socket(handlerOptions) {
let {
onmessage,
onopen
onopen,
// socketUrl
} = handlerOptions
let socketUrl = 'ws://8.142.143.40:8885/websocket/1'
let socketUrl = 'ws://8.142.143.40:8885/websocket/1/1'
let websocket
if ("WebSocket" in window) {
websocket = new WebSocket(socketUrl)
......@@ -21,13 +22,10 @@ export default function socket(handlerOptions) {
console.info("Websocket服务器连接错误")
}
window.onbeforeunload = function() {
websocket.close()
}
//连接成功建立的回调方法
websocket.onopen = function() {
console.info("Websocket连接成功")
console.log(websocket.readyState);
heart.start()
onopen && onopen()
}
......@@ -45,7 +43,6 @@ export default function socket(handlerOptions) {
}
return websocket
}
function heartCheck(websocket) {
return {
timeout: 15000,
......@@ -56,8 +53,10 @@ function heartCheck(websocket) {
},
start: function() {
this.timeoutObj = setInterval(function() {
// if(websocket.readyState==1){
websocket.send("HeartBeat")
console.info("Websocket发送心跳:HeartBeat")
// }
}, this.timeout)
},
}
......
......@@ -171,6 +171,7 @@ import { cableTimeList, cableConfirm, cableCancel } from "../api";
import { exportLeakyCable } from "@/api/export";
import search from "@/views/monitor/leakageCable/components/search.vue";
import download from "@/utils/download";
import socket from "@/utils/websocket";
export default {
data() {
return {
......@@ -200,6 +201,7 @@ export default {
],
isQuery: false,
searchOption: {},
wsUrl: "ws://8.142.143.40:8885/websocket/1/1",
};
},
components: { search },
......@@ -278,30 +280,31 @@ export default {
},
computed: {
getWsMsg:{
get(){
return this.$store.state.websocket.webSocketMsg
},
set(a){
this.$store.state.websocket.webSocketMsg=a
}
},
// getWsMsg:{
// get(){
// return this.$store.state.websocket.webSocketMsg
// },
// set(a){
// this.$store.state.websocket.webSocketMsg=a
// }
// },
},
watch: {
getWsMsg: {
handler(newVal) {
this.getWsMsg=!!newVal
console.log(newVal);
// alert("接收到webSocket推送" + newVal);
},
},
// getWsMsg: {
// handler(newVal) {
// this.getWsMsg=!!newVal
// console.log(newVal);
// // alert("接收到webSocket推送" + newVal);
// },
// },
},
mounted() {
this.getTableData();
},
created(){
this.$ws.createWS("2")
// socket({socketUrl:this.wsUrl});
}
};
</script>
......
......@@ -134,6 +134,7 @@ import { deviceList, deviceConfirm, deviceCancel } from "../api";
import { exportConnet } from "@/api/export";
import search from "@/views/monitor/equipment/components/search.vue";
import download from "@/utils/download";
import socket from "@/utils/websocket";
export default {
data() {
return {
......@@ -163,6 +164,7 @@ export default {
],
isQuery: false,
searchOption: {},
wsUrl: "ws://8.142.143.40:8885/websocket/1/2",
};
},
components: { search },
......@@ -255,6 +257,7 @@ export default {
},
created(){
// socket({socketUrl:this.wsUrl});
}
};
......
......@@ -79,7 +79,7 @@
<script>
import { login } from "@/api/user"
import { setToken } from "@/utils/auth"
import EventBus from '@/utils/bus'
export default {
name: "Login",
data() {
......@@ -160,6 +160,8 @@ export default {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.toLogin()
// EventBus.$emit('wsOpen')
} else {
console.log("error submit!!");
return false;
......
......@@ -206,11 +206,11 @@ export default {
},
exportData() {
fsulist({size:this.total}).then((res) => {
let list = res.records || [];
this.exids = list.map((i) => i.id);
// fsulist({size:this.total}).then((res) => {
// let list = res.records || [];
// this.exids = list.map((i) => i.id);
});
// });
exportFsu({ ids: this.exids }).then((res) => {
download(res, "vnd.ms-excel", `FSU表.xls`);
});
......@@ -240,6 +240,7 @@ export default {
let list = res.records || [];
this.tableData = list;
this.total = res.total;
this.exids = list.map((i) => i.id);
if (this.istrue == 1) {
if (this.tableData.length != 0) {
......
......@@ -131,9 +131,6 @@
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column
prop="leakyCableDescribe"
label="漏缆描述"
......@@ -158,7 +155,6 @@
<el-table-column prop="fsuName" label="所在FSU" align="center" />
<el-table-column prop="equipName" label="所在监测设备" align="center" />
<el-table-column
prop="action"
label="详细信息"
......@@ -267,11 +263,6 @@ export default {
},
exportData() {
leakyCablelist({size:this.total}).then((res) => {
let list = res.records || [];
this.exids = list.map((i) => i.id);
});
exportLeaky({ ids: this.exids }).then((res) => {
download(res, "vnd.ms-excel", `漏缆表.xls`);
});
......@@ -301,7 +292,7 @@ export default {
let list = res.records || [];
this.tableData = list;
this.total = res.total;
this.exids = list.map((i) => i.id);
if (this.istrue == 1) {
if (this.tableData.length) {
successAlert("查询成功");
......@@ -352,7 +343,7 @@ function formInit(data = {}) {
monitor: "",
leakyCableCode: "",
leakyCableDescribe: "",
siteName:"",
siteName: "",
leakyCableMode: "",
current: 1,
size: 10,
......
......@@ -217,11 +217,6 @@ export default {
},
exportData() {
monitorEquiplist({size:this.total}).then((res) => {
let list = res.records || [];
this.exids = list.map((i) => i.id);
});
exportMonitorEquip({ ids: this.exids }).then((res) => {
download(res, "vnd.ms-excel", `监测设备表.xls`);
});
......@@ -251,7 +246,7 @@ export default {
let list = res.records || [];
this.tableData = list;
this.total = res.total;
this.exids = list.map((i) => i.id);
if (this.istrue == 1) {
if (this.tableData.length) {
successAlert("查询成功");
......@@ -288,7 +283,6 @@ export default {
};
function formInit(data = {}) {
return {
wayId: "",
parentId: "",
ip: "",
......
......@@ -170,11 +170,6 @@ export default {
},
exportData() {
railWaylist({size:this.total}).then((res) => {
let list = res.records || [];
this.exids = list.map((i) => i.id);
});
exportRailWay({ ids: this.exids }).then((res) => {
download(res, "vnd.ms-excel", `铁路线表.xls`);
});
......@@ -204,7 +199,7 @@ export default {
let list = res.records || [];
this.tableData = list;
this.total = res.total;
this.exids = list.map((i) => i.id);
if (this.istrue == 1) {
if (this.tableData.length) {
successAlert("查询成功");
......
......@@ -169,10 +169,6 @@ export default {
this.siteForm = formInit();
},
exportData() {
sitelist({ size: this.total }).then((res) => {
let list = res.records || [];
this.exids = list.map((i) => i.id);
});
exportSite({ ids: this.exids }).then((res) => {
download(res, "vnd.ms-excel", `站点表.xls`);
});
......@@ -200,6 +196,7 @@ export default {
let list = res.records || [];
this.tableData = list;
this.total = res.total;
this.exids = list.map((i) => i.id);
if (this.istrue == 1) {
if (this.tableData.length) {
successAlert("查询成功");
......
......@@ -21,15 +21,15 @@
:header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
>
<el-table-column prop="userName" label="用户名" align="center" />
<el-table-column prop="operateTypeValue" label="操作类别" align="center" />
<el-table-column prop="operateObj" label="操作对象" align="center" />
<el-table-column prop="operateTypeName" label="操作类别" align="center" />
<el-table-column prop="operateObjName" label="操作对象" align="center" />
<el-table-column prop="objectName" label="对象名称" align="center" />
<el-table-column
prop="operateContent"
label="操作内容"
align="center"
/>
<el-table-column prop="operateResultValue" label="操作结果" align="center" />
<el-table-column prop="operateResultName" label="操作结果" align="center" />
<el-table-column prop="creationTime" label="操作时间" align="center" />
</el-table>
<Pagination
......
......@@ -12,7 +12,7 @@ const port = process.env.port || process.env.npm_config_port || 8886 // dev port
const rewriteDefaultConfig = {
changeOrigin: true,
target: 'http://8.142.143.40:8886',
// target: 'http://192.168.0.111:8886',
// target: 'http://192.168.0.123:8886',
// ws: true,
headers: {
referer: 'laddercloud.cn'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment