<template>
  <el-container class="app-container" direction="vertical">
    <vue-progress-bar></vue-progress-bar>
    <Header/>
    <el-container>
      <Aside/>
      <Container/>
    </el-container>

    <el-dialog append-to-body title="系统提示" :visible.sync="$store.state.base.loginTimeout" width="400px">
      <LoginRe/>
    </el-dialog>
    <el-dialog append-to-body title="修改密码" :visible.sync="$store.state.base.loginChangePwd" width="360px">
      <ChangePw @cancel="$store.state.base.loginChangePwd=false"></ChangePw>
    </el-dialog>

  </el-container>
</template>
<script>
  import {Loading} from "element-ui";
  import ChangePw from "@/module/sysm/ChangePw";
  import Container from "@/views/layout/Container";
  import Aside from "@/views/layout/Aside";
  import Header from "@/views/layout/Header";
  import CacheService from "../service/module/CacheService";
  import config from "@/config.js";

  export default {
    components: {Container, Aside, Header, ChangePw},
    data() {
      return {
        changepwd: false
      };
    },
    async mounted() {
      let loading = Loading.service({
        lock: true,
        text: "系统初始化...",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      try {
        let data = await this.$store.dispatch("base/getLoginInfo");
        if (config.needLogin && data.respCode === config.respCode.timeout) {
          this.$router.replace("/login");
        }
        CacheService.repairWith(data.ttocpic, data.tversion);
        CacheService.repairWith(data.ctocpic, data.cversion);
        if (config.init) {
          config.init(this);
          delete config["init"];
        }
      } finally {
        loading.close();
      }
    }
  };
</script>


