rt-sim-training-client/src/views/trainRoom/content-menu.vue
2019-11-08 18:17:34 +08:00

80 lines
2.0 KiB
Vue

<template>
<div class="jointRoomMenu">
<pop-menu ref="popMenu" :menu="menu" />
</div>
</template>
<script>
import PopMenu from '@/components/PopMenu';
import { DeviceMenu } from '@/scripts/ConstDic';
import { putJointTrainingUserkicked } from '@/api/chat';
export default {
components: {
PopMenu
},
props: {
clickUserId: {
type: String,
default: ''
}
},
data() {
return {
menu: [{
label: this.$t('trainRoom.kickOutTheRoom'),
handler: this.kicked
}]
};
},
computed: {
userId() {
return this.$store.state.user ? this.$store.state.user.id : '';
},
position() {
return this.$store.state.menuOperation.menuPosition;
}
},
watch: {
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.JointRoom)) {
this.doShow();
} else {
this.doClose();
}
}
},
mounted() {
this.closeEvent();
},
methods: {
closeEvent() {
const self = this;
window.onclick = function (e) {
self.doClose();
};
},
doShow() {
this.closeEvent();
if (this.userId != this.clickUserId) {
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.resetShowPosition(this.position);
}
}
},
doClose() {
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.close();
}
},
async kicked() {
try {
await putJointTrainingUserkicked(this.clickUserId, this.$route.query.group);
} catch (error) {
console.error(error);
}
}
}
};
</script>