fast(监控大屏): 监听大屏添加iframe监听方法,封装跳转方法,设备列表添加url参数识别,解决重复操作导航报错问题
This commit is contained in:
parent
14126d0793
commit
5eaf34ed1b
|
@ -2,7 +2,14 @@ import Vue from 'vue'
|
||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
const RouterPush = Router.prototype.push
|
||||||
|
Router.prototype.push = function push (to) {
|
||||||
|
return RouterPush.call(this, to).catch(err => err)
|
||||||
|
}
|
||||||
|
const RouterReplace = Router.prototype.replace
|
||||||
|
Router.prototype.replace = function replace (to) {
|
||||||
|
return RouterReplace.call(this, to).catch(err => err)
|
||||||
|
}
|
||||||
/* Layout */
|
/* Layout */
|
||||||
import Layout from '@/layout'
|
import Layout from '@/layout'
|
||||||
import ParentView from '@/components/ParentView';
|
import ParentView from '@/components/ParentView';
|
||||||
|
@ -305,5 +312,6 @@ export const constantRoutes = [
|
||||||
export default new Router({
|
export default new Router({
|
||||||
mode: 'history', // 去掉url中的#
|
mode: 'history', // 去掉url中的#
|
||||||
scrollBehavior: () => ({ y: 0 }),
|
scrollBehavior: () => ({ y: 0 }),
|
||||||
routes: constantRoutes
|
routes: constantRoutes,
|
||||||
|
ignoreDuplicates: true
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { debounce } from 'debounce'
|
||||||
export default {
|
export default {
|
||||||
name: "bigScreenIframe",
|
name: "bigScreenIframe",
|
||||||
data() {
|
data() {
|
||||||
|
@ -12,7 +13,8 @@ export default {
|
||||||
src: "https://goview.drgyen.cn/#/chart/preview/202409060982078",
|
src: "https://goview.drgyen.cn/#/chart/preview/202409060982078",
|
||||||
loading: true,
|
loading: true,
|
||||||
token: "",
|
token: "",
|
||||||
iframeRef: null
|
iframeRef: null,
|
||||||
|
userType: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -28,6 +30,7 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.token = this.getCookie("Admin-Token");
|
this.token = this.getCookie("Admin-Token");
|
||||||
|
this.userType = this.$store.getters.userType;
|
||||||
// this.src = process.env.VUE_APP_BIGSCREEN_PLATFORM_URL + "?token=" + this.token;
|
// this.src = process.env.VUE_APP_BIGSCREEN_PLATFORM_URL + "?token=" + this.token;
|
||||||
|
|
||||||
// document.getElementById('bigIframe').onload = function () {
|
// document.getElementById('bigIframe').onload = function () {
|
||||||
|
@ -37,10 +40,10 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.iframeRef = this.$refs.iframeRef;
|
this.iframeRef = this.$refs.iframeRef;
|
||||||
// window.addEventListener('message', this.receiveMsg, false);
|
window.addEventListener('message',this.receiveMsg, false);
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
// window.removeEventListener('message', this.receiveMsg, false);
|
window.removeEventListener('message', this.receiveMsg, false);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCookie(name) {
|
getCookie(name) {
|
||||||
|
@ -71,7 +74,40 @@ export default {
|
||||||
// },10000)
|
// },10000)
|
||||||
},
|
},
|
||||||
receiveMsg(e) {
|
receiveMsg(e) {
|
||||||
console.log("父页面-接收消息",e)
|
// e.data
|
||||||
|
// {type:'path',url:'/project/project?id=1'}
|
||||||
|
// {type:'pathType',typeName:'设备列表',query: { id: 123 }}
|
||||||
|
if (e.data.type === 'path') {
|
||||||
|
if(e.data.url){
|
||||||
|
this.$router.push(e.data.url);
|
||||||
|
}
|
||||||
|
}else if (e.data.type === 'pathType') {
|
||||||
|
if(e.data.typeName === '设备'){
|
||||||
|
if(this.userType === 'SYSTEM'){
|
||||||
|
this.$router.push({
|
||||||
|
path: '/device/device',
|
||||||
|
query: e.data.query
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
this.$router.push({
|
||||||
|
path: '/device_tenant/device_tenant',
|
||||||
|
query: e.data.query
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else if(e.data.typeName === '项目'){
|
||||||
|
if(this.userType === 'SYSTEM'){
|
||||||
|
this.$router.push({
|
||||||
|
path: '/project/project',
|
||||||
|
query: e.data.query
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
this.$router.push({
|
||||||
|
path: '/project_tenant/project_tenant',
|
||||||
|
query: e.data.query
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onIframeError() {
|
onIframeError() {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
|
@ -763,6 +763,9 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
console.log(this.$route);
|
console.log(this.$route);
|
||||||
|
if (this.$route.query.deviceState){
|
||||||
|
this.queryParams.deviceState = this.$route.query.deviceState;
|
||||||
|
}
|
||||||
this.init();
|
this.init();
|
||||||
this.getInProjectList();
|
this.getInProjectList();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue