<template>
  <el-row
    type="flex"
    class="container"
    justify="space-between"
  >
    <el-col
      :span="4"
      class="menu-left"
    >
      <el-row>
        <el-col
          :span="24"
          class="logo-col"
        >
          <div class="logo"></div>
        </el-col>
      </el-row>
      <el-row>
        <el-col
          :span="24"
          class="title-col"
        >
          <div class="title">靖安县智慧旅游数据上传后台</div>
        </el-col>
      </el-row>
      <el-row class="menu-row">
        <el-col :span="24">
          <el-menu
            router
            :default-active="$route.path"
            class="el-menu-vertical-demo"
            background-color="#1D3251"
            text-color="#fff"
            active-text-color="#fff"
          >
            <router-link to="zdhj">
              <el-menu-item index="/dist/index/zdhj">
                <i class="el-icon-cong"></i>
                <span slot="title">重点环节</span>
              </el-menu-item>
            </router-link>
            <router-link to="zdry">
              <el-menu-item index="/dist/index/zdry">
                <i class="el-icon-sbgl"></i>
                <span slot="title">重点人员</span>
              </el-menu-item>
            </router-link>
            <router-link to="zhtx">
              <el-menu-item index="/dist/index/zhtx">
                <i class="el-icon-yue"></i>
                <span slot="title">指挥体系</span>
              </el-menu-item>
            </router-link>
            <router-link to="yjcb">
              <el-menu-item index="/dist/index/yjcb">
                <i class="el-icon-sjdz"></i>
                <span slot="title">应急储备</span>
              </el-menu-item>
            </router-link>
            <router-link to="forms">
              <el-menu-item index="/dist/index/forms">
                <i class="el-icon-forms"></i>
                <span slot="title">报表</span>
              </el-menu-item>
            </router-link>
            <router-link to="zhgl">
              <el-menu-item index="/dist/index/zhgl">
                <i class="el-icon-zhgl"></i>
                <span slot="title">账号管理</span>
              </el-menu-item>
            </router-link>
          </el-menu>
        </el-col>
      </el-row>
      <div class="diwen"></div>
    </el-col>
    <el-col :span="20">
      <el-row>
        <el-col
          :span="24"
          class="right-top"
        >
          <div class="wecome-text">{{ userName }} 您好，欢迎登陆！</div>
          <div class="right-items">
            <div><a
                href="http://58.17.42.179:90/yiqing-explain"
                target="_blank"
              >帮助文档</a></div>
            <div class="tx"></div>
            <div class="shuxian"></div>
            <div
              class="logout-btn"
              @click="logout"
            ></div>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col
          :span="24"
          class="right-main"
        >
          <router-view @sonFun="indexFun"></router-view>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      userName: "",
      unic: "",
    };
  },
  created() {
    var statue = sessionStorage.getItem("uname");
    var token = sessionStorage.getItem("token");
    var unic = sessionStorage.getItem("unic");
    if (
      !statue ||
      typeof statue == "undefined" ||
      statue == "" ||
      statue == "null" ||
      !token ||
      typeof token == "undefined" ||
      token == "" ||
      token == "null"
    ) {
      this.$router.replace("/");
      return;
    } else {
      this.userName = statue;
      this.unic = unic;
    }
  },
  methods: {
    // 通过子组件更新昵称
    indexFun(param) {
      if (typeof param == "undefined" || !param) {
        this.unic = sessionStorage.getItem("unic");
      } else {
        this.unic = param;
      }
    },
    // 退出登陆
    logout() {
      var _this = this;
      this.$confirm("确认退出？", "提示", {
        confirmButtonText: "是，退出",
        cancelButtonText: "否，不退出",
        type: "warning",
      })
        .then((_) => {
          // console.log(_);
          sessionStorage.removeItem("uname");
          sessionStorage.removeItem("token");
          _this.$router.replace("/");
        })
        .catch((_) => {
          // console.log(_);
        });
    },
  },
};
</script>

<style scoped>
@import url("index.css");
</style>
