<template>
  <transition name="el-zoom-in-center">
    <div class="mapPaint">
      <div class="map-view">
        <iscs-plate ref="iscsPlate" @iscsChange="iscsChange" />
      </div>
      <div class="map-draft" :class="{'hide': draftShow}">
        <div class="btn_left_box" @click="clickRightBtn"><i :class="draftShow?'el-icon-arrow-right':'el-icon-arrow-left'" /></div>
        <iscs-operate v-if="iscsMode==='fas'" ref="iscsOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-bas-operate v-else-if="iscsMode==='bas'" ref="iscsBasOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-psd-operate v-else-if="iscsMode==='psd'" ref="iscsPsdOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-cctv-operate v-else-if="iscsMode==='cctv'" ref="iscsCctvOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-afc-operate v-else-if="iscsMode==='afc'" ref="iscsAfcOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-acs-operate v-else-if="iscsMode==='acs'" ref="iscsAcsOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-net-operate v-else-if="iscsMode==='netState'" ref="iscsNetOperate" @iscsChange="iscsChange" @handleSave="handleSave" />
        <iscs-automatic v-else-if="iscsMode==='afc02'" ref="" @iscsChange="iscsChange" @handleSave="handleSave" /> <!-- 自动售检票/门禁 -->
        <iscs-communication v-else-if="iscsMode==='communication02'" ref="" @iscsChange="iscsChange" @handleSave="handleSave" />  <!-- 通信 -->
        <iscs-fire-alarm v-else-if="iscsMode==='fas02'" ref="" @iscsChange="iscsChange" @handleSave="handleSave" />  <!-- 火灾报警系统 -->
        <iscs-power-monitoring v-else-if="iscsMode==='powerMonitoring02'" ref="" @iscsChange="iscsChange" @handleSave="handleSave" />  <!-- 电力监控系统 -->
        <iscs-signal-system v-else-if="iscsMode==='signalSystem02'" ref="" @iscsChange="iscsChange" @handleSave="handleSave" />  <!-- 信号系统 -->
      </div>
    </div>
  </transition>
</template>
<script>
import localStore from 'storejs';
import IscsPlate from '@/views/iscsSystem/index';
import IscsOperate from './iscsOperate/index';
import IscsBasOperate from './iscsBasOperate/index';
import IscsPsdOperate from './iscsPsdOperate/index';
import IscsCctvOperate from './iscsCctvOperate/index';
import IscsAfcOperate from './iscsAfcOperate/index';
import IscsAcsOperate from './iscsAcsOperate/index';
import IscsNetOperate from './IscsNetOperate/index';

import IscsAutomatic from './iscsAutomatic/index';
import IscsCommunication from './iscsCommunication/index';
import IscsFireAlarm from './iscsFireAlarm/index';
import IscsPowerMonitoring from './iscsPowerMonitoring/index';
import IscsSignalSystem from './iscsSignalSystem/index';

import { saveIscsElement } from '@/api/iscs';

export default {
    name: 'IscsView',
    components: {
        IscsPlate,
        IscsOperate,
        IscsBasOperate,
        IscsPsdOperate,
        IscsCctvOperate,
        IscsAfcOperate,
        IscsAcsOperate,
        IscsNetOperate,

        IscsAutomatic,
        IscsCommunication,
        IscsFireAlarm,
        IscsPowerMonitoring,
        IscsSignalSystem
    },
    data() {
        return {
            size: {
                width: this.$store.state.app.width - 521,
                height: this.$store.state.app.height - 60
            },
            widthLeft: Number(localStore.get('LeftWidth')) || 450,
            draftShow: false
        };
    },
    computed:{
        iscsMode() {
            return this.$route.query.mode;
        }
    },
    watch: {
        $route(val) {
            this.iscsChange(this.$route.query.mode, this.$route.query.system, this.$route.query.part);
        }
    },
    mounted() {
        this.$refs.iscsPlate.show(this.$route.query.mode, this.$route.query.system, this.$route.query.part);
        this.$refs.iscsPlate.drawIscsInit();
    },
    beforeDestroy() {

    },
    methods: {
        iscsChange(mode, system, part) {
            this.$refs.iscsPlate.show(mode, system, part);
            this.$refs.iscsPlate.drawIscsInit();
        },
        clickRightBtn() {
            this.draftShow = !this.draftShow;
        },
        handleSave(data) {
            const param = {
                graphData: data,
                lineCode: this.$route.query.lineCode,
                stationCode: '',
                system: this.$route.query.system,
                totalSystem: this.$route.query.mode,
                userInterface: this.$route.query.part
            };
            saveIscsElement(param).then(resp => {
                this.$message.success('ISCS数据保存成功！');
            }).catch(() => {
                this.$message.error('ISCS数据保存异常！');
            });
            // {
            // 	"graphData": "string",
            // 	"id": 0,
            // 	"lineCode": "string",
            // 	"stationCode": "string",
            // 	"system": "string",
            // 	"totalSystem": "string",
            // 	"userInterface": "string"
            // }
        }
    }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/mixin.scss";

    .map-draft{
		width: 470px;
		height: 100%;
		position: absolute;
		right: 0;
		transform: translateX(470px);
		transition: all 0.5s;
		background: #fff;
		z-index: 9;
		/deep/{
			.v-modal{
				opacity: 0;
			}
		}
		&.hide{
			transform: translateX(0);
		}
    }

    .map-view {
        float: left;
        width: 60%;
    }
    .mapPaint{
        height: 100%;
        overflow: hidden;
    }
	.btn_left_box{
		position: absolute;
		left: 0;
		top: 50%;
		padding: 8px 3px;
		background: #fff;
		z-index: 10;
		transform: translateX(-22px);
		cursor: pointer;
		border-radius: 5px 0 0 5px;
	}
</style>
