rt-sim-training-client/src/views/trainRoom/content-menu.vue

88 lines
2.3 KiB
Vue
Raw Normal View History

2019-11-08 18:17:34 +08:00
<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';
2020-03-16 15:29:26 +08:00
import { putJointTrainingUserkickedNew} from '@/api/jointTraining';
2019-11-08 18:17:34 +08:00
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;
2020-03-16 15:29:26 +08:00
},
drawWay() {
2020-03-27 13:52:14 +08:00
return this.$route.query.drawWay + '';
2019-11-08 18:17:34 +08:00
}
},
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 {
2020-03-27 13:52:14 +08:00
if (this.drawWay === 'true' ) {
2020-03-16 15:29:26 +08:00
await putJointTrainingUserkickedNew(this.clickUserId, this.$route.query.group);
} else {
await putJointTrainingUserkicked(this.clickUserId, this.$route.query.group);
}
2019-11-08 18:17:34 +08:00
} catch (error) {
console.error(error);
}
}
}
};
</script>