<template>
  <el-dialog
    v-dialogDrag
    :title="title"
    :visible.sync="show"
    width="600px"
    :before-close="doClose"
    :z-index="2000"
    :modal="false"
    :close-on-click-modal="false"
  >
    <div style="height: 80px; line-height: 80px; font-size: 16px; padding-left: 10px;">{{ roomName }}邀请你加入综合演练！</div>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="handleJoin">确认</el-button>
      <el-button @click="dialogShow = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getjointTraining, putJointTrainingSimulationEntrance } from '@/api/chat';
import { getPublishMapInfo } from '@/api/jmap/map';
import { launchFullscreen } from '@/utils/screen';

export default {
	name: 'DeomonList',
	data() {
		return {
			dialogShow: false,
			group: '',
			roomName: '',
			state: '',
			mapId: ''
		};
	},
	computed: {
		show() {
			return this.dialogShow;
		},
		title() {
			return '综合演练快速入口';
		}
	},
	mounted() {
	},
	methods: {
		doShow(data) {
			this.roomName = data.creator.nickName;
			this.group = data.group;
			this.state = data.state;
			this.mapId = data.mapId;
			this.dialogShow = true;
		},
		doClose() {
			this.dialogShow = false;
		},
		async handleJoin() {
			if (this.state == '02') {
				launchFullscreen();
				await putJointTrainingSimulationEntrance(this.group);
				const rest = await getPublishMapInfo(this.mapId);
				const query = { skinStyle: rest.data.skinStyle, mapId: this.mapId, group: this.group };
				this.$router.push({ path: `/jointTraining`, query: query });
			} else if (this.state == '01') {
				const query = { group: this.group };
				this.$router.push({ path: `/trainroom`, query: query });
			}
			this.dialogShow = false;
			getjointTraining(this.group);
		}
	}
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    /deep/ {
        .el-dialog__body {
            padding: 0px 30px !important;
        }

        .el-tree-node.is-current>.el-tree-node__content {
            background-color: #e4e3e3 !important;
        }
    }
</style>
