Commit 795c2e04 authored by wxk's avatar wxk

结构优化,解决详情页刷新问题

parent fa026470
<template> <template>
<div class="nav-left"> <div class="nav-left">
<el-menu <el-menu
:default-active="$route.path" :default-active="active"
class="el-menu-vertical-demo" class="el-menu-vertical-demo"
:router="true" :router="true"
@select="navClick"> @select="navClick">
<el-menu-item index="/monitor/home"> <el-menu-item index="home">
<span slot="title">首页</span> <span slot="title">首页</span>
</el-menu-item> </el-menu-item>
<el-submenu index="1"> <el-submenu index="1">
<template slot="title">网站监控</template> <template slot="title">网站监控</template>
<el-menu-item :index="'/monitor/' + index" v-for="(item, index) in platInfo" :key="item.platform">{{item.platform}}</el-menu-item> <el-menu-item :index="index+''" v-for="(item, index) in platInfo" :key="item.platform">{{item.platform}}</el-menu-item>
</el-submenu> </el-submenu>
<el-submenu index="2"> <el-submenu index="2">
<template slot="title">币种监控</template> <template slot="title">币种监控</template>
<el-menu-item index="/monitor/BTY">BTY</el-menu-item> <el-menu-item index="BTY">BTY</el-menu-item>
<el-menu-item index="/monitor/YCC">YCC</el-menu-item> <el-menu-item index="YCC">YCC</el-menu-item>
</el-submenu> </el-submenu>
</el-menu> </el-menu>
</div> </div>
...@@ -26,14 +26,23 @@ ...@@ -26,14 +26,23 @@
export default { export default {
data(){ data(){
return{ return{
active: ''
} }
}, },
props: ['platInfo'], props: ['platInfo'],
created() {
this.active = this.$route.params.name;
},
methods: { methods: {
navClick() { navClick() {
this.$router.push('/monitor/' + this.active)
Bus.$emit('navClick') Bus.$emit('navClick')
} }
},
watch: {
$route() {
this.active = this.$route.params.name;
}
} }
} }
</script> </script>
......
...@@ -27,7 +27,15 @@ export default new Router({ ...@@ -27,7 +27,15 @@ export default new Router({
path:":name", path:":name",
component: function(resolve){ component: function(resolve){
require(['../views/overview.vue'],resolve); require(['../views/overview.vue'],resolve);
} },
children: [
{
path: 'RobotDetail',
component: function(resolve){
require(['../views/RobotDetails.vue'],resolve);
},
}
]
} }
] ]
} }
......
...@@ -457,6 +457,7 @@ ...@@ -457,6 +457,7 @@
export default { export default {
data(){ data(){
return{ return{
robotDetailInfo: JSON.parse(sessionStorage.getItem('robotDetailInfo')),
robotInfo: {}, robotInfo: {},
username: localStorage.getItem('username'), username: localStorage.getItem('username'),
value1: true, value1: true,
...@@ -503,13 +504,14 @@ ...@@ -503,13 +504,14 @@
recordsLoading: false,//交易记录查询加载 recordsLoading: false,//交易记录查询加载
} }
}, },
props: ['robotDetailInfo','robotBankList'], props: ['robotBankList'],
created() { created() {
this.init(); this.init();
}, },
methods: { methods: {
//页面初始化 //页面初始化
init() { init() {
// this.robotDetailInfo = JSON.parse(sessionStorage.getItem('robotDetailInfo'));
this.getWalletInfo(); this.getWalletInfo();
this.getTransaction(); this.getTransaction();
this.getRecords(); this.getRecords();
...@@ -517,7 +519,8 @@ ...@@ -517,7 +519,8 @@
}, },
//返回上一页(关闭详情) //返回上一页(关闭详情)
closeDetails() { closeDetails() {
Bus.$emit('hideDetails') Bus.$emit('navClick');
this.$router.go(-1);
}, },
//查询当前机器人信息 //查询当前机器人信息
getCurrentRobot() { getCurrentRobot() {
...@@ -610,7 +613,9 @@ ...@@ -610,7 +613,9 @@
duration:'2000', duration:'2000',
}); });
this.Loading = false; this.Loading = false;
this.init(); setTimeout(()=>{
this.init();
},500)
}else{ }else{
this.Loading = false; this.Loading = false;
this.$notify({ this.$notify({
......
<template> <template>
<div class="overview"> <div class="overview">
<div v-show="!robotDetails"> <div v-if="$route.path.split('/').pop() !== 'RobotDetail'">
<div class="overview-title"> <div class="overview-title">
<span>机器人监控</span> <span>机器人监控</span>
</div> </div>
...@@ -130,10 +130,10 @@ ...@@ -130,10 +130,10 @@
</ul> </ul>
<p v-if="robotList === null" class="no-data">暂无数据</p> <p v-if="robotList === null" class="no-data">暂无数据</p>
</div> </div>
<robot-details v-if="robotDetails" :robotDetailInfo="robotDetailInfo" :robotBankList="robotBankList"></robot-details> <router-view :robotBankList="robotBankList"></router-view>
<!--<robot-details v-if="robotDetails" :robotDetailInfo="robotDetailInfo" :robotBankList="robotBankList"></robot-details>-->
</div> </div>
</template> </template>
<script> <script>
import RobotDetails from './RobotDetails' import RobotDetails from './RobotDetails'
import Bus from '../assets/js/bus' import Bus from '../assets/js/bus'
...@@ -144,7 +144,6 @@ ...@@ -144,7 +144,6 @@
return { return {
platform: '',//导航选中的交易所 platform: '',//导航选中的交易所
value1: true, //是否开启机器人 value1: true, //是否开启机器人
robotDetails: false, //是否查看机器人详情
robotStatus: '', //机器人状态 robotStatus: '', //机器人状态
robotStatusList: [],//状态预警信息 robotStatusList: [],//状态预警信息
RobotListParams: { RobotListParams: {
...@@ -184,7 +183,6 @@ ...@@ -184,7 +183,6 @@
created() { created() {
this.init(); this.init();
Bus.$on('navClick', ()=> { Bus.$on('navClick', ()=> {
this.robotDetails = false;
this.robotStatus = ''; this.robotStatus = '';
this.subtitle = '所有机器人'; this.subtitle = '所有机器人';
this.checkAll = false; //交易所筛选 this.checkAll = false; //交易所筛选
...@@ -204,9 +202,6 @@ ...@@ -204,9 +202,6 @@
this.init(); this.init();
},0) },0)
}); });
Bus.$on('hideDetails',()=>{
this.robotDetails = false;
})
}, },
methods: { methods: {
init() { init() {
...@@ -332,8 +327,10 @@ ...@@ -332,8 +327,10 @@
this.getRobotList(ListParams); this.getRobotList(ListParams);
}, },
showDetails(index) { showDetails(index) {
this.robotDetails = true; // console.log(this.$route.path);
this.robotDetailInfo = this.robotList[index]; // this.RobotDetails = true;
sessionStorage.setItem('robotDetailInfo', JSON.stringify(this.robotList[index]));
this.$router.push(this.$route.path+'/RobotDetail');
// console.log(this.robotDetailInfo) // console.log(this.robotDetailInfo)
}, },
clickSwitch(val) { clickSwitch(val) {
......
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