Commit 11907e95 authored by co_dengxiongwen's avatar co_dengxiongwen

tj

parent 826ccb50
......@@ -2,11 +2,7 @@
<div id="app">
<router-view v-if="isRouterAlive" />
<div>
<div
v-for="(item, index) in showList"
:key="index"
v-if="index < 4 && ishowAlarm"
>
<div v-for="(item, index) in showList" :key="index" v-if="index < 4">
<div :class="'tip' + (index + 1)">
<div class="title">
<el-row :span="24">
......@@ -104,7 +100,6 @@ export default {
data() {
return {
is3DShow: false,
ishowAlarm: true,
dialogVisible: false,
isRouterAlive: true,
queryDetailVisible: false,
......@@ -117,10 +112,10 @@ export default {
watch: {},
computed: {},
mounted() {
//let token = util.cookies.get('token')
this.initWebSocket()
this.initWebSocket2()
this.getDateList()
this.getDateList2()
},
destroyed: function() {
this.websocketclose()
......@@ -169,24 +164,14 @@ export default {
},
//接收后端返回的数据
websocketonmessage(e) {
console.log('takeover:', sessionStorage.getItem('takeover'))
if (
sessionStorage.getItem('takeover') != undefined &&
sessionStorage.getItem('takeover') == 'true'
) {
this.ishowAlarm = false
} else {
this.ishowAlarm = true
}
// 在这里使用后端返回的数据,对数据进行处理渲染
// this.tipList = []
this.showList = []
if (
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') != undefined
sessionStorage.getItem('token') !== undefined
) {
// if (util.cookies.get('token') && util.cookies.get('token') != undefined) { //登录才能获取
// this.tipList = JSON.parse(e.data)
//登录才能获取
var alarmsInfo = JSON.parse(e.data)
//console.log(alarmsInfo, '-------')
if (alarmsInfo.status != 1) {
......@@ -206,7 +191,6 @@ export default {
}
}
this.tipList.push(alarmsInfo)
// this.sendMessage(alarmsInfo.resourceCode)
if (flag) {
var x = 0
var resourceCode = this.$store.state.d2admin.bjCode.resourceCode
......@@ -214,30 +198,19 @@ export default {
if (
resourceCode &&
resourceCode.split('+')[0] === alarmsInfo.resourceCode &&
resourceCode.split('+')[2] === alarmsInfo.lineId &&
resourceCode.split('+')[3] === alarmsInfo.stationId
resourceCode.split('+')[2] === alarmsInfo.stationId
) {
x =
Number(resourceCode.substring(resourceCode.indexOf('+') + 1)) +
1
this.$store.dispatch(
'd2admin/bjCode/set',
alarmsInfo.resourceCode +
'+' +
x +
'+' +
alarmsInfo.lineId +
'+' +
alarmsInfo.stationId
alarmsInfo.resourceCode + '+' + x + '+' + alarmsInfo.stationId
)
} else {
this.$store.dispatch(
'd2admin/bjCode/set',
alarmsInfo.resourceCode +
'+0+' +
alarmsInfo.lineId +
'+' +
alarmsInfo.stationId
alarmsInfo.resourceCode + '+0+' + alarmsInfo.stationId
)
}
}
......@@ -286,10 +259,6 @@ export default {
websocketclose(e) {
console.log('断开连接', e)
},
send() {
this.websock.send('1')
},
// ====================================
//初始化weosocket2
initWebSocket2() {
......@@ -332,12 +301,10 @@ export default {
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') != undefined
) {
var paramsInfo = JSON.parse(e.data)
console.log('paramsInfo:', paramsInfo)
// 集合
// this.$store.dispatch('d2admin/typeList/set', e.typeList)
//登录才能获取
// this.tipList = JSON.parse(e.data)
console.log('接管数据' + e.data)
this.$store.dispatch('d2admin/typeList/set', paramsInfo)
}
},
//连接建立失败重连
......@@ -349,24 +316,19 @@ export default {
websocketclose2(e) {
console.log('断开连接2', e)
},
send2() {
this.websock.send('2')
},
//登录后页面刷新的时候获取
getDateList() {
this.tipList = []
this.showList = []
if (
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') != undefined
sessionStorage.getItem('token') !== undefined
) {
this.$http({
url: this.$http.adornUrlAlarm('/alarmsInfo/queryList'),
method: 'post',
params: this.$http.adornParams({
status: 1,
stationId: localStorage.getItem('stationId')
status: 1
})
}).then((data) => {
if (data && data.code === 0) {
......@@ -384,15 +346,28 @@ export default {
if (this.showList) {
this.showList.sort(this.sortBy('occurrenceTime', true))
}
// console.log(this.tipList, '-------')
// console.log(this.showList, '-------')
//console.log(this.showList, '1----------1')
this.$store.dispatch('d2admin/toast/set', this.tipList.length)
}
})
}
},
getDateList2() {
if (
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') !== undefined
) {
this.$http({
url: this.$http.adornUrlAlarm('/kanban/getListParam'),
method: 'post',
params: this.$http.adornParams({})
}).then((data) => {
if (data && data.code === 0) {
console.log('typeList:', data.bean)
this.$store.dispatch('d2admin/typeList/set', data.bean)
}
})
}
},
/**数组根据数组对象中的某个属性值进行排序的方法
* 使用例子:newArray.sort(sortBy('number',false)) //表示根据number属性降序排列;若第二个参数不传递,默认表示升序排序
* @param attr 排序的属性 如number属性
......@@ -473,24 +448,6 @@ export default {
background-color: #b9c9e3 !important;
}
// 状态-点
// .danger,
// .success,
// .warning {
// width: 5px;
// height: 5px;
// border-radius: 100%;
// background: #ff3723;
// display: inline-block;
// vertical-align: middle;
// }
// .success {
// background: #42cd00;
// }
// .warning {
// background: #ffa101;
// }
// 弹出框
.el-dialog__title {
line-height: 24px;
......
......@@ -36,71 +36,72 @@
/* eslint-disable */
// 动态背景js
// require("particles.js");
import config from "./config/default";
import { mapActions } from "vuex";
import util from "@/libs/util.js";
import { getPermissions } from "@/util";
import config from './config/default'
import { mapActions } from 'vuex'
import util from '@/libs/util.js'
import { getPermissions } from '@/util'
const Base64 = require('js-base64').Base64
import httpRequest from '@/plugin/axios'
import bcrypt from '@/util/bcrypt.js'
export default {
data () {
data() {
return {
loginLoad:false,
loginLoad: false,
// 快速选择用户
dialogVisible: false,
users: [
{
name: "管理员",
username: "admin",
password: "admin"
name: '管理员',
username: 'admin',
password: 'admin'
},
{
name: "编辑",
username: "editor",
password: "editor"
name: '编辑',
username: 'editor',
password: 'editor'
},
{
name: "用户1",
username: "user1",
password: "user1"
name: '用户1',
username: 'user1',
password: 'user1'
}
],
// 表单
formLogin: {
username: "",
password: "",
username: '',
password: '',
remember: '',
uuid: "",
code: "qweqwe"
uuid: '',
code: 'qweqwe'
},
// 校验
rules: {
username: [
{ required: true, message: "请输入用户名", trigger: "blur" }
{ required: true, message: '请输入用户名', trigger: 'blur' }
],
password: [{ required: true, message: "请输入密码", trigger: "blur" }],
code: [{ required: true, message: "请输入验证码", trigger: "blur" }]
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
},
captchaPath: ""
};
captchaPath: ''
}
},
created () {
created() {
//this.getCookie();
let u = util.cookies.get("username")
let p = util.cookies.get("password")
if(u && p){
this.formLogin.username =bcrypt.decrypt(u);
this.formLogin.password = bcrypt.decrypt(p);
let u = util.cookies.get('username')
let p = util.cookies.get('password')
if (u && p) {
this.formLogin.username = bcrypt.decrypt(u)
this.formLogin.password = bcrypt.decrypt(p)
}
this.getCaptcha();
this.$parent.getDateList();
this.getCaptcha()
this.$parent.getDateList()
this.$parent.getDateList2()
},
mounted () {
mounted() {
// 初始化例子插件
//particlesJS("login", config);
},
beforeDestroy () {
beforeDestroy() {
// 销毁 particlesJS
// thanks https://github.com/d2-projects/d2-admin/issues/65
// ref https://github.com/VincentGarreau/particles.js/issues/63
......@@ -110,10 +111,9 @@ export default {
//}
},
methods: {
...mapActions("d2admin/account", ["login"]),
...mapActions('d2admin/account', ['login']),
...mapActions('d2admin/page', ['closeAll']),
// getType(){
// let type
// httpRequest({ url: httpRequest.adornUrl('/sysSystem/getSystem'), method: 'get' }).then((e) => {
......@@ -125,29 +125,29 @@ export default {
/**
* 获取uuid
*/
getUUID () {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
return (c === "x"
getUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
return (c === 'x'
? (Math.random() * 16) | 0
: "r&0x3" | "0x8"
).toString(16);
});
: 'r&0x3' | '0x8'
).toString(16)
})
},
// 获取验证码
getCaptcha () {
this.formLogin.uuid = this.getUUID();
getCaptcha() {
this.formLogin.uuid = this.getUUID()
this.captchaPath = this.$http.adornUrl(
`/captcha.jpg?uuid=${this.formLogin.uuid}`
);
)
},
/**
* @description 接收选择一个用户快速登录的事件
* @param {Object} user 用户信息
*/
handleUserBtnClick (user) {
this.formLogin.username = user.username;
this.formLogin.password = user.password;
this.submit();
handleUserBtnClick(user) {
this.formLogin.username = user.username
this.formLogin.password = user.password
this.submit()
},
/* setCookie(c_name, c_pwd, exdays) {
var exdate = new Date();
......@@ -180,19 +180,18 @@ export default {
* @description 提交表单
*/
// 提交登录信息
clearCookie: function () {
util.cookies.set("username", "");
util.cookies.set("password", "");
clearCookie: function() {
util.cookies.set('username', '')
util.cookies.set('password', '')
},
submit () {
submit() {
// 防止重复提交
if(this.loginLoad) return
if (this.loginLoad) return
// 登录关闭所有tab
this.closeAll()
let u = bcrypt.encrypt(this.formLogin.username.trim())
let p = bcrypt.encrypt(this.formLogin.password.trim())
this.$refs.loginForm.validate(valid => {
this.$refs.loginForm.validate((valid) => {
if (valid) {
// this.login({
// vm: this,
......@@ -205,28 +204,28 @@ export default {
// 获取数据列表
this.loginLoad = true
this.$http({
url: this.$http.authUrl("/oauth/token"),
method: "post",
url: this.$http.authUrl('/oauth/token'),
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
grant_type: "password",
grant_type: 'password',
username: u,
password: p,
scope: "all"
scope: 'all'
}
})
.then(data => {
.then((data) => {
if (data.access_token) {
// 登录
// 注意 这里的演示没有传验证码
// 具体需要传递的数据请自行修改代码
util.cookies.set("authorization", data.access_token);
util.cookies.set('authorization', data.access_token)
this.$http({
url: this.$http.adornUrl("/sys/login"),
method: "post",
url: this.$http.adornUrl('/sys/login'),
method: 'post',
data: {
uuid: this.formLogin.uuid,
username: u,
......@@ -234,7 +233,7 @@ export default {
captcha: this.formLogin.code
}
})
.then(res => {
.then((res) => {
if (res.msg == 'success') {
this.$message.success({
message: '登录成功',
......@@ -249,89 +248,96 @@ export default {
// util.cookies.set("token", res.token);
sessionStorage.setItem('uuid', res.uuid)
sessionStorage.setItem('token', res.token)
localStorage.setItem("userId",res.userId)
localStorage.setItem('userId', res.userId)
// 存储登陆用户权限信息
sessionStorage.setItem("permissions", res.permissions);
localStorage.setItem("sysSystem",res.sysSystem)
localStorage.setItem("sysSign",JSON.parse(res.sysSystem || '{}').code)
localStorage.setItem("stationId",JSON.parse(res.sysSystem || '{}').code)
localStorage.setItem("lineId",JSON.parse(res.sysSystem || '{}').lineId)
sessionStorage.setItem('permissions', res.permissions)
localStorage.setItem('sysSystem', res.sysSystem)
localStorage.setItem(
'sysSign',
JSON.parse(res.sysSystem || '{}').code
)
localStorage.setItem(
'stationId',
JSON.parse(res.sysSystem || '{}').code
)
localStorage.setItem(
'lineId',
JSON.parse(res.sysSystem || '{}').lineId
)
//设置被接管
let takeover = res.takeover
if(takeover && takeover.status === 1){
if (takeover && takeover.status === 1) {
// 弹出提示框
// this.$store.dispatch('d2admin/takeover/setTakeover', takeover)
} else if(takeover && takeover.status === 2 ){
sessionStorage.setItem('takeover',true)
} else if (takeover && takeover.status === 2) {
sessionStorage.setItem('takeover', true)
}
// 设置 vuex 用户信息
this.$store.dispatch(
"d2admin/user/set",
'd2admin/user/set',
{
name: this.formLogin.username,
userName:res.userName
userName: res.userName
},
{ root: true }
);
)
// 用户登录后从持久化数据加载一系列的设置
this.$store.dispatch("d2admin/account/load");
this.$store.dispatch('d2admin/account/load')
// 获取最新权限信息
getPermissions();
getPermissions()
// 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
const path = util.cookies.get("redirect");
const path = util.cookies.get('redirect')
// 根据是否存有重定向页面判断如何重定向
this.$http({
url: this.$http.adornUrl('/sys/menu/nav'),
method: "get"
}).then((e)=>{
let url=e.menuList[0].list[0].path
this.$router.replace({path:url})
method: 'get'
}).then((e) => {
let url = e.menuList[0].list[0].path
this.$router.replace({ path: url })
})
// this.$router.replace(path ? { path } : { name: "index" });
// 删除 cookie 中保存的重定向页面
util.cookies.remove("redirect");
util.cookies.remove('redirect')
if (this.formLogin.remember) {
//传入账号名,密码,和保存天数3个参数
//this.setCookie(this.formLogin.username, this.formLogin.password, 7);
util.cookies.set("username", u);
util.cookies.set("password", p);
util.cookies.set('username', u)
util.cookies.set('password', p)
} else {
console.log("清空Cookie");
console.log('清空Cookie')
//清空Cookie
this.clearCookie();
this.clearCookie()
}
this.$parent.getDateList();
this.$parent.getDateList()
this.$parent.getDateList2()
} else {
sessionStorage.removeItem("uuid")
sessionStorage.removeItem("token")
sessionStorage.removeItem('uuid')
sessionStorage.removeItem('token')
this.$message.danger('账号或密码错误')
}
})
.catch(err => {
.catch((err) => {
this.loginLoad = false
this.getCaptcha();
});
this.getCaptcha()
})
}
})
.catch(err => {
.catch((err) => {
this.loginLoad = false
this.getCaptcha();
});
this.getCaptcha()
})
} else {
// 登录表单校验失败
// this.$message.error("表单校验失败");
}
});
})
}
}
};
}
</script>
<style lang="scss" >
@import "./style.scss";
<style lang="scss">
@import './style.scss';
</style>
......@@ -39,119 +39,118 @@ export default {
mapId: '',
mapList: [],
dataList: [
{
name: '喷淋系统',
list: [
{
leftName: '喷淋系统',
rightName: '水流压力',
type: 'slyl',
value: '0.319mp',
scope: '参考值:0.2~0.8mp'
}
]
},
{
name: '喷淋系统',
list: [
{
leftName: '喷淋系统',
rightName: '一氧化碳',
type: 'co',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '湿度',
type: 'sd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '风速',
type: 'fs',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '风速',
type: 'fs',
value: '22.5℃',
scope: '参考值:0.0~50℃'
}
]
},
{
name: '喷淋系统',
list: [
{
leftName: '喷淋系统',
rightName: '风压',
type: 'fy',
value: '0.319mp',
scope: '参考值:0.2~0.8mp'
},
{
leftName: '喷淋系统',
rightName: '泵房温度',
type: 'wd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '水位高度',
type: 'swgd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '水位高度',
type: 'swgd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
}
]
},
{
name: '喷淋系统',
list: [
{
leftName: '喷淋系统',
rightName: '水流压力',
type: 'slyl',
value: '0.319mp',
scope: '参考值:0.2~0.8mp'
},
{
leftName: '喷淋系统',
rightName: '泵房温度',
type: 'wdh',
value: '60.5℃',
over: true,
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '水位高度',
type: 'swgd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
},
{
leftName: '喷淋系统',
rightName: '水位高度',
type: 'swgd',
value: '22.5℃',
scope: '参考值:0.0~50℃'
}
]
}
// {
// name: '喷淋系统',
// list: [
// {
// leftName: '喷淋系统',
// rightName: '水流压力',
// type: 'slyl',
// value: '0.319mp',
// scope: '参考值:0.2~0.8mp'
// }
// ]
// },
// {
// name: '喷淋系统',
// list: [
// {
// leftName: '喷淋系统',
// rightName: '一氧化碳',
// type: 'co',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '湿度',
// type: 'sd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '风速',
// type: 'fs',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '风速',
// type: 'fs',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// }
// ]
// },
// {
// name: '喷淋系统',
// list: [
// {
// leftName: '喷淋系统',
// rightName: '风压',
// type: 'fy',
// value: '0.319mp',
// scope: '参考值:0.2~0.8mp'
// },
// {
// leftName: '喷淋系统',
// rightName: '泵房温度',
// type: 'wd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '水位高度',
// type: 'swgd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '水位高度',
// type: 'swgd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// }
// ]
// },
// {
// name: '喷淋系统',
// list: [
// {
// leftName: '喷淋系统',
// rightName: '水流压力',
// type: 'slyl',
// value: '0.319mp',
// scope: '参考值:0.2~0.8mp'
// },
// {
// leftName: '喷淋系统',
// rightName: '泵房温度',
// type: 'wdh',
// value: '60.5℃',
// over: true,
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '水位高度',
// type: 'swgd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// },
// {
// leftName: '喷淋系统',
// rightName: '水位高度',
// type: 'swgd',
// value: '22.5℃',
// scope: '参考值:0.0~50℃'
// }
// ]
// }
]
}
},
......
......@@ -231,6 +231,7 @@ service.interceptors.response.use(
sessionStorage.removeItem('uuid')
if (this) {
this.$parent.getDateList()
this.$parent.getDateList2()
//清空接管提示框
// this.$store.dispatch('d2admin/takeover/setTakeover', null)
}
......
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