rt-sim-training-client/src/views/demonstration/deomonList/index.vue

162 lines
4.5 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<el-dialog
v-dialogDrag
2019-11-14 13:59:33 +08:00
v-dialogLoading="pageLoading"
:title="title"
:visible.sync="show"
width="600px"
:before-close="doClose"
:z-index="2000"
:modal="false"
:close-on-click-modal="false"
>
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: height+'px'}">
<el-tree
ref="tree"
2019-11-14 13:59:33 +08:00
node-key="group"
class="filter-tree"
2019-11-14 13:59:33 +08:00
default-expand-all
:data="trainingList"
:props="defaultProps"
:filter-node-method="filterNode"
:style="{height: height+'px'}"
>
2020-03-31 18:50:16 +08:00
<div slot-scope="{ node, data }" class="list-elem custom-tree-node">
2020-06-30 18:35:57 +08:00
<span v-if="data.state=='01'">{{ '['+data.map.name+']'+($t('global.trainingNotStart').replace('{name}', data.creator.nickname)) }}</span>
<span v-else>{{ '['+data.map.name+']'+($t('global.trainingHasStart').replace('{name}', data.creator.nickname)) }}</span>
2020-03-31 18:50:16 +08:00
<el-button
type="text"
size="mini"
@click="handleJoinRoom(data)"
>进入</el-button>
2019-11-14 13:59:33 +08:00
</div>
</el-tree>
</el-scrollbar>
2019-08-19 14:02:20 +08:00
<span
2019-08-19 20:27:23 +08:00
slot="footer"
2019-08-19 14:02:20 +08:00
class="dialog-footer"
>
2020-04-01 09:07:42 +08:00
<el-button v-loading="loading" type="primary" @click="handleJoin">{{ $t('global.joinNewRoom') }}</el-button>
2019-08-19 14:02:20 +08:00
<el-button @click="dialogShow = false">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
2019-07-26 13:32:43 +08:00
</template>
<script>
2020-06-30 18:35:57 +08:00
import { getSimulationListCantainUser } from '@/api/jointSimulation';
import { launchFullscreen } from '@/utils/screen';
import { getToken } from '@/utils/auth';
import { creatSubscribe, clearSubscribe, roomTopic} from '@/utils/stomp';
2019-07-26 13:32:43 +08:00
export default {
name: 'DeomonList',
data() {
return {
dialogShow: false,
height: 120,
trainingList: [],
defaultProps: {
label: 'roomName'
},
group: '',
2019-11-14 13:59:33 +08:00
loading: false,
pageLoading: false
};
},
computed: {
show() {
return this.dialogShow;
},
title() {
return this.$t('global.synthesisTrainingTitle');
},
isWatch() {
return true;
},
isjoin() {
return true;
}
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
async subscribe(group) {
if (!this.$store.state.socket.roomIsSubscribe) {
this.clearSubscribe(group);
const header = { group: group || '', 'X-Token': getToken() };
creatSubscribe(`${roomTopic}\/${group}`, header);
await this.$store.dispatch('socket/setRoomSubscribe', true);
}
},
async clearSubscribe(group) {
clearSubscribe(`${roomTopic}\/${group}`);
await this.$store.dispatch('socket/setRoomSubscribe', false);
},
2019-11-14 13:59:33 +08:00
async doShow() {
try {
2019-11-14 13:59:33 +08:00
this.pageLoading = true;
this.dialogShow = true;
this.loading = false;
2020-06-30 18:35:57 +08:00
this.trainingList = [];
const resp = await getSimulationListCantainUser();
if (resp.data) {
this.trainingList = resp.data;
}
2019-11-14 13:59:33 +08:00
} catch (e) {
console.error(e);
} finally {
this.pageLoading = false;
}
},
2019-11-14 13:59:33 +08:00
async doClose() {
this.dialogShow = false;
},
2020-03-31 18:50:16 +08:00
async handleJoinRoom(data) {
2019-11-14 13:59:33 +08:00
try {
2020-06-30 18:35:57 +08:00
launchFullscreen();
const query = { lineCode: data.map.lineCode, mapId: data.map.id, group: data.group};
this.$router.push({path:'/jointTrainingNew', query:query});
2019-11-14 13:59:33 +08:00
} catch (e) {
console.error(e);
} finally {
this.loading = false;
}
2020-03-31 18:50:16 +08:00
},
handleJoin() {
this.$emit('enterQcode');
this.dialogShow = false;
}
}
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
2020-06-30 18:35:57 +08:00
/deep/ {
.el-dialog__body {
padding: 0px 30px !important;
}
2019-07-26 13:32:43 +08:00
2020-06-30 18:35:57 +08:00
.el-tree {
overflow: auto !important;
2019-11-14 13:59:33 +08:00
.list-elem {
height: 30px;
line-height: 30px;
}
2020-06-30 18:35:57 +08:00
}
2019-07-26 13:32:43 +08:00
2020-06-30 18:35:57 +08:00
.el-tree-node.is-current>.el-tree-node__content {
background-color: #e4e3e3 !important;
}
}
2020-03-31 18:50:16 +08:00
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
</style>