<template>
  <!-- header公共组件 -->
  <div class="headerContainer">
    <div class="logo">
      <img :src="logoImgUrl" />
    </div>
    <h2 class="title">
      <slot name="headerWelcome">{{ welcomeTxt }}</slot>
    </h2>
    <ul class="infoContainer">
      <li>
        <a @click="logOutAction">退出</a>
      </li>
      <li>
        <slot name="postName">{{ userInfo.postName }}</slot>
      </li>
      <li>
        <slot name="deptName">{{ userInfo.deptName }}</slot>
      </li>
      <li>
        <slot name="code">{{ userInfo.code }}</slot>
      </li>
      <li>
        <slot name="name">{{ userInfo.name }}</slot>
      </li>
    </ul>
  </div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { headerProps, headerEmits } from "./header";
import axiosHttp from "../../../utils/axiosHttp.js";
// logo
import defaultLogo from "./img/zzui-header-logo.png";

defineOptions({
  name: "ZHeader",
});

// define 组件参数
const props = defineProps(headerProps);
// define 组件回调事件
const emits = defineEmits(headerEmits);

//退出登录事件
const logOutAction = (): void => {
  if (props.logOutDisabled) {
    emits("handleLogOut");
  } else {
    axiosHttp.http(
      {
        url: "/staffPortal/account/logout",
      },
      (res) => {},
      (res) => {},
      (res) => {}
    );
  }
};
</script>

<style lang="scss" scoped>
@import "./css/reset.scss";
$Color_default_white: #fff;
/* 头部导航 */
.headerContainer {
  z-index: 5;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  float: left;
  overflow: hidden;
  background-color: v-bind(bgColor);
  box-shadow: 0 0 8px #00000014;
  .logo {
    position: relative;
    float: left;
    margin-left: 20px;
    margin-top: 10px;
    z-index: 11;
    cursor: pointer;
    img {
      margin-top: 0 !important;
      height: 40px;
    }
  }
  h2 {
    width: auto;
    height: 60px;
    line-height: 60px;
    position: absolute;
    left: 0;
    right: 0;
    font-size: 18px;
    text-align: center;
    font-weight: normal;
    z-index: 1;
    color: v-bind(fontColor);
  }
  .title {
    color: v-bind(fontColor);
  }
  .infoContainer {
    width: auto;
    height: 60px;
    line-height: 60px;
    position: absolute;
    right: 30px;
    z-index: 3;
    li {
      width: auto;
      float: right;
      margin-left: 20px;
      font-size: 14px;
      color: v-bind(fontColor);
      height: 60px;
      line-height: 60px;
      a {
        position: relative;
        color: #a9a9a9 !important;
        padding-left: 15px;
        height: 60px;
        line-height: 60px;
        cursor: pointer;
        &::before {
          content: "";
          width: 2px;
          height: 16px;
          background-color: $Color_default_white;
          position: absolute;
          top: 2px;
          right: 42px;
        }
        &:hover {
          text-decoration: underline;
          color: #b01f24 !important;
        }
      }
    }
  }
}
</style>
