<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="watchBill">
              <el-menu-item index="/smoke/index/watchBill">
                <i class="el-icon-zhgl"></i>
                <span slot="title">值班表</span>
              </el-menu-item>
            </router-link>

            <router-link to="disposeSituation">
              <el-menu-item index="/smoke/index/disposeSituation">
                <i class="el-icon-qk"></i>
                <span slot="title">处置情况</span>
              </el-menu-item>
            </router-link>

            <router-link to="smokeWarn">
              <el-menu-item index="/smoke/index/smokeWarn">
                <i class="el-icon-mygj"></i>
                <span slot="title">冒烟告警</span>
              </el-menu-item>
            </router-link>

            <router-link to="systemSetup">
              <el-menu-item index="/smoke/index/systemSetup">
                <i class="el-icon-xtsz"></i>
                <span slot="title">系统设置</span>
              </el-menu-item>
            </router-link>

            <router-link to="broadcastContent">
              <el-menu-item index="/smoke/index/broadcastContent">
                <i class="el-icon-gb"></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/smoke-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>
