rt-sim-training-client/src/views/trainRoom/operateMenu.vue

83 lines
2.4 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div class="jointRoomMenu">
<pop-menu ref="popMenu" :menu="menu"></pop-menu>
</div>
</template>
<script>
import PopMenu from '@/components/PopMenu';
import { DeviceMenu } from '@/scripts/ConstDic';
import { putJointTrainingUserkicked } from '@/api/chat';
export default {
name: 'TrainingOperateMenu',
components: {
PopMenu,
},
props: {
point: {
type: Object,
required: true
},
clickUserId: {
type: String,
required: true
}
},
data() {
return {
menu: [],
menuShow: [
{
label: '踢出房间',
handler: this.kicked
},
],
userId: '',
}
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.JointRoom)) {
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
}
}
},
mounted() {
this.userId = this.$store.state.user.id;
this.closeEvent();
},
methods: {
closeEvent() {
let self = this;
window.onclick = function (e) {
self.doClose();
}
},
doShow(point) {
this.closeEvent();
if (this.userId != this.clickUserId) {
this.menu = this.menuShow;
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.resetShowPosition(point);
}
} else {
this.menu = [];
}
},
doClose() {
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.close();
}
},
async kicked() {
try {
let res = await putJointTrainingUserkicked(this.clickUserId, this.$route.query.group);
} catch (error) { }
}
}
}
</script>