<template>
  <div>
    <el-container style="background: ">
      <el-header style="background-color: #ccc; line-height: 50px">
        <div class="navs">
          <!-- <div class="maintitle">神豚医疗信息系统</div> -->
          <div style="">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 用户权限管理 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="organization-units">组织架构</el-dropdown-item>
                <el-dropdown-item command="role">角色管理</el-dropdown-item>
                <el-dropdown-item command="user-list">用户管理</el-dropdown-item>
                <el-dropdown-item command="audit-log">安全日志</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 基础字典 -->
          <div style="margin-left: 15px" class="basicdictionany">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 基础字典 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="guide-type">导引类别</el-dropdown-item>
                <el-dropdown-item command="medical-report-type">体检报告类别</el-dropdown-item>
                <el-dropdown-item command="sex">性别</el-dropdown-item>
                <el-dropdown-item command="marital-status">婚姻状况</el-dropdown-item>
                <el-dropdown-item command="nation">民族</el-dropdown-item>
                <el-dropdown-item command="birth-place">籍贯</el-dropdown-item>
                <el-dropdown-item command="result-status">结果状态</el-dropdown-item>
                <el-dropdown-item command="medical-type">体检类别</el-dropdown-item>
                <el-dropdown-item command="personnel-type">人员类别</el-dropdown-item>
                <el-dropdown-item command="device-type">仪器类别</el-dropdown-item>
                <el-dropdown-item command="sample-type">标本类型</el-dropdown-item>
                <el-dropdown-item command="unit">计量单位</el-dropdown-item>
                <el-dropdown-item command="diagnosis-postfix">诊断后缀</el-dropdown-item>
                <el-dropdown-item command="medical-conclusion-type">体检结论类别</el-dropdown-item>
                <el-dropdown-item command="medical-conclusion">体检结论</el-dropdown-item>
                <el-dropdown-item command="sample-container">标本容器</el-dropdown-item>
                <el-dropdown-item command="common-char-type">常用字符类别</el-dropdown-item>
                <el-dropdown-item command="common-char">常用字符</el-dropdown-item>
                <el-dropdown-item command="customer-org-type">客户单位类别</el-dropdown-item>
                <el-dropdown-item command="item-default-result">项目默认结果</el-dropdown-item>
                <el-dropdown-item command="diagnosis-level">诊断级别</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 收费设置 -->
          <div class="feesettings" style="margin-left: 20px">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 收费设置 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="invoice-item-type">发票项目类别</el-dropdown-item>
                <el-dropdown-item command="pay-mode">支付方式</el-dropdown-item>
                <el-dropdown-item command="cardType">会员卡类别</el-dropdown-item>
                <el-dropdown-item command="cardRegister">会员卡登记</el-dropdown-item>
                <el-dropdown-item command="cardBill">会员卡记账</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!--常用设置  -->
          <div class="commonsettings" style="margin-left: 20px">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 常用设置 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="item-type">项目类别</el-dropdown-item>
                <el-dropdown-item command="item">项目设置</el-dropdown-item>
                <el-dropdown-item command="asbitem">组合项目</el-dropdown-item>
                <el-dropdown-item command="sample-group">条码分组</el-dropdown-item>
                <!-- <el-dropdown-item
                  @click.native="$router.push({ path: '/reference-range' })"
                  >参考范围</el-dropdown-item
                > -->
                <!-- <el-dropdown-item
                  @click.native="
                    $router.push({ path: '/sex-hormone-reference-range' })
                  "
                  >性激素参考范围</el-dropdown-item
                > -->
                <el-dropdown-item command="diagnosis">诊断</el-dropdown-item>
                <el-dropdown-item command="diagnosis-template">诊断模板</el-dropdown-item>
                <el-dropdown-item command="item-result-template">项目结果模板</el-dropdown-item>
                <el-dropdown-item command="item-result-match">项目结果匹配</el-dropdown-item>
                <el-dropdown-item command="item-template">项目模板</el-dropdown-item>
                <el-dropdown-item command="medical-package">套餐</el-dropdown-item>
                <el-dropdown-item command="sys-parm-type">系统参数</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 体检登记 -->
          <div class="examinationregistration" style="margin-left: 15px">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 体检登记 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="customerOrg">体检单位设置</el-dropdown-item>
                <el-dropdown-item command="customerOrgGroup">单位分组设置</el-dropdown-item>
                <el-dropdown-item command="patientRegister">体检人员登记</el-dropdown-item>
                <el-dropdown-item command="personnelBatch">人员批量登记</el-dropdown-item>
                <el-dropdown-item command="patientRegisterSign">体检人员签到</el-dropdown-item>
                <el-dropdown-item command="patientRegisterRecover">体检表回收</el-dropdown-item>
                <el-dropdown-item command="patientRegisterRefuse">弃检登记</el-dropdown-item>
                <el-dropdown-item command="charge">体检收费</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!-- 体检 -->
          <div class="physicalexamination" style="margin-left: 15px">
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link"> 体检 </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="doctorCheck">体检医生诊台</el-dropdown-item>
                <el-dropdown-item command="sumDoctorCheck">总检医生诊台</el-dropdown-item>

              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <div class="btn">
            当前用户{{ user }}
            <!-- <i class="el-icon-arrow-down el-icon--right"></i> -->
            <el-dropdown>
              <span class="el-dropdown-link">
                操作 <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
                <el-dropdown-item @click.native="editpassword">修改密码</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </el-header>
      <!-- 修改密码弹框 -->
      <el-dialog title="修改密码" :visible.sync="dialogVisible" width="30%" :close-on-click-modal="false">
        <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px">
          <el-form-item label="旧密码" prop="oldPassWord">
            <el-input v-model="form.oldPassWord" autocomplete="new-password" show-password></el-input>
          </el-form-item>
          <el-form-item label="新密码" prop="newPassWord">
            <el-input v-model="form.newPassWord" autocomplete="new-password" show-password></el-input>
          </el-form-item>
          <el-form-item label="确认密码" prop="newPassWord">
            <el-input v-model="confirmpassword" type="password" autocomplete="new-password" show-password></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="determine">确 定</el-button>
        </span>
      </el-dialog>
      <el-container>
        <!-- <el-aside :width="isCollapse ? '64px' : '220px'">
          <el-menu
            style="height: 100%"
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            router
            active-text-color="#fff"
            :unique-opened="true"
            text-color="#000"
            @select="aa"
            :collapse="isCollapse"
            :collapse-transition="false"
          >
            <div class="collapseandunfoled" @click="isCollapse = !isCollapse">
              <i class="el-icon-s-operation"></i>
            </div>
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-document"></i>
                <span>用户权限管理</span>
              </template>
              <el-menu-item index="role">
                <i class="el-icon-menu"></i> <span slot="title">角色管理</span>
              </el-menu-item>
              <el-menu-item index="user-list">
                <i class="el-icon-menu"></i> <span slot="title">用户管理</span>
              </el-menu-item>
              <el-menu-item index="organization-units"
                ><i class="el-icon-menu"></i><span slot="title">组织架构</span>
              </el-menu-item>
              <el-menu-item index="audit-log">
                <i class="el-icon-menu"></i> <span slot="title">安全日志</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-s-tools"></i>
                <span>基础字典</span>
              </template>
              <el-menu-item index="guide-type"
                ><i class="el-icon-menu"></i>导引类别</el-menu-item
              >
              <el-menu-item index="medical-report-type"
                ><i class="el-icon-menu"></i>体检报告类别</el-menu-item
              >
              <el-menu-item index="sex"
                ><i class="el-icon-menu"></i>性别</el-menu-item
              >
              <el-menu-item index="marital-status"
                ><i class="el-icon-menu"></i>婚姻状况</el-menu-item
              >
              <el-menu-item index="nation"
                ><i class="el-icon-menu"></i>民族</el-menu-item
              >
              <el-menu-item index="birth-place"
                ><i class="el-icon-menu"></i>籍贯</el-menu-item
              >
              <el-menu-item index="result-status"
                ><i class="el-icon-menu"></i>结果状态</el-menu-item
              >
              <el-menu-item index="medical-type"
                ><i class="el-icon-menu"></i>体检类别</el-menu-item
              >
              <el-menu-item index="personnel-type"
                ><i class="el-icon-menu"></i>人员类别</el-menu-item
              >
              <el-menu-item index="device-type"
                ><i class="el-icon-menu"></i>仪器类别</el-menu-item
              >
              <el-menu-item index="sample-type"
                ><i class="el-icon-menu"></i>标本类型</el-menu-item
              >
              <el-menu-item index="unit"
                ><i class="el-icon-menu"></i>单位</el-menu-item
              >
              <el-menu-item index="diagnosis-postfix"
                ><i class="el-icon-menu"></i>诊断后缀</el-menu-item
              >
              <el-menu-item index="medical-conclusion-type"
                ><i class="el-icon-menu"></i>体检结论类别</el-menu-item
              >
              <el-menu-item index="medical-conclusion"
                ><i class="el-icon-menu"></i>体检结论</el-menu-item
              >
              <el-menu-item index="sample-container"
                ><i class="el-icon-menu"></i>标本容器</el-menu-item
              >
              <el-menu-item index="common-char-type"
                ><i class="el-icon-menu"></i>常用字符类别</el-menu-item
              >
              <el-menu-item index="common-char"
                ><i class="el-icon-menu"></i>常用字符</el-menu-item
              >
              <el-menu-item index="customer-org-type"
                ><i class="el-icon-menu"></i>客户单位类别</el-menu-item
              >
              <el-menu-item index="item-default-result"
                ><i class="el-icon-menu"></i>项目默认结果</el-menu-item
              >
              <el-menu-item index="diagnosis-level"
                ><i class="el-icon-menu"></i>诊断级别</el-menu-item
              >
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-tools"></i>
                <span>收费设置</span>
              </template>
              <el-menu-item index="invoice-item-type"
                ><i class="el-icon-menu"></i>发票项目类别</el-menu-item
              >
              <el-menu-item index="pay-mode"
                ><i class="el-icon-menu"></i>支付方式</el-menu-item
              >
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-tools"></i>
                <span>常用设置</span>
              </template>
              <el-menu-item index="item-type"
                ><i class="el-icon-menu"></i>项目类别</el-menu-item
              >
              <el-menu-item index="sample-group"
                ><i class="el-icon-menu"></i>条码分组</el-menu-item
              >
              <el-menu-item index="asbitem"
                ><i class="el-icon-menu"></i>组和项目</el-menu-item
              >
              <el-menu-item index="item"
                ><i class="el-icon-menu"></i>项目</el-menu-item
              >
              <el-menu-item index="reference-range"
                ><i class="el-icon-menu"></i>参考范围</el-menu-item
              >
              <el-menu-item index="sex-hormone-reference-range"
                ><i class="el-icon-menu"></i>性激素参考范围</el-menu-item
              >
              <el-menu-item index="diagnosis"
                ><i class="el-icon-menu"></i>诊断</el-menu-item
              >
              <el-menu-item index="diagnosis-template"
                ><i class="el-icon-menu"></i>诊断模板</el-menu-item
              >
              <el-menu-item index="item-result-template"
                ><i class="el-icon-menu"></i>项目结果模板</el-menu-item
              >
              <el-menu-item index="item-result-match"
                ><i class="el-icon-menu"></i>项目结果匹配</el-menu-item
              >
              <el-menu-item index="item-template"
                ><i class="el-icon-menu"></i>项目模板</el-menu-item
              >
              <el-menu-item index="medical-package"
                ><i class="el-icon-menu"></i>套餐</el-menu-item
              >
              <el-menu-item index="sys-parm-type"
                ><i class="el-icon-menu"></i>系统参数</el-menu-item
              >
            </el-submenu>
            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-document"></i>
                <span>体检登记</span>
              </template>
              <el-menu-item index="customerOrg">
                <i class="el-icon-menu"></i>
                <span slot="title">体检单位设置</span>
              </el-menu-item>
              <el-menu-item index="customerOrgGroup">
                <i class="el-icon-menu"></i>
                <span slot="title">单位分组设置</span>
              </el-menu-item>
              <el-menu-item index="patientRegister">
                <i class="el-icon-menu"></i>
                <span slot="title">体检人员登记</span>
              </el-menu-item>
              <el-menu-item index="patientRegisterSign">
                <i class="el-icon-menu"></i>
                <span slot="title">体检人员签到</span>
              </el-menu-item>
              <el-menu-item index="patientRegisterRecover">
                <i class="el-icon-menu"></i>
                <span slot="title">体检表回收</span>
              </el-menu-item>
              <el-menu-item index="patientRegisterRefuse">
                <i class="el-icon-menu"></i> <span slot="title">弃检登记</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="6">
              <template slot="title">
                <i class="el-icon-document"></i>
                <span>体检</span>
              </template>
              <el-menu-item index="doctorCheck">
                <i class="el-icon-menu"></i>
                <span slot="title">体检医生诊台</span>
              </el-menu-item>
              <el-menu-item index="sumDoctorCheck">
                <i class="el-icon-menu"></i>
                <span slot="title">总检医生诊台</span>
              </el-menu-item>              
            </el-submenu>
          </el-menu>
        </el-aside> -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
///api/app/item/in-filter
import router from "@/router";
import { postapi } from "@/api/api";
import { mapState } from "vuex";
export default {
  data() {
    return {
      index: 1,
      isCollapse: false,
      user: "",
      dialogVisible: false,
      password: "",
      form: {
        oldPassWord: "",
        newPassWord: "",
      },
      confirmpassword: "",
      rules: {
        oldPassWord: [
          { required: true, message: "请输入旧密码", trigger: "blur" },
        ],
        newPassWord: [
          { required: true, message: "请输入新密码", trigger: "blur" },
        ],
      },
    };
  },
  computed: {
    ...mapState(["changepassword", "router"]),
  },
  created() {
    this.password = this.changepassword;
    console.log(this.password);
    console.log(this.$store.state.changepassword, "ssssssssssss");
    this.user = localStorage.getItem("user");
  },
  methods: {
    handleCommand(command) {
      if (this.router.path != command) {
        this.router.path = command;
        this.$router.push({ path: command }).catch(() => { })
      }
    },
    //确定修改密码按钮
    determine() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          if (this.form.oldPassWord != this.password) {
            this.$message.warning("旧密码输入错误");
          } else if (this.confirmpassword != this.form.newPassWord) {
            this.$message.warning("二次输入的密码不一致");
          } else {
            postapi("/api/identity/users/updatepassword", this.form).then(
              (res) => {
                this.$message.success("修改成功");
                this.dialogVisible = false;
              }
            );
          }
        }
      });
    },
    //修改密码
    editpassword() {
      this.dialogVisible = true;
      console.log(this.password);
    },
    //退出登录
    logout() {
      // localStorage.removeItem("tokentype");
      // localStorage.removeItem("token");
      // localStorage.removeItem(['expires_in','tokentype','refresh_token','user','token'])
      localStorage.clear();
      this.$router.push({ path: "/login" });
    },
    aa(aa) {
      console.log(aa);
    },
  },
  components: { router },
};
</script>
<style scoped>
.el-dropdown-item {
  text-align: center;
}

.el-dropdown-menu {
  text-align: center;
  overflow: scroll;
  max-height: 500px;
  width: 150px;
  overflow-x: hidden;
  /* margin-left: 5%; */
}

.el-header {
  position: fixed;
  /* top:0;
  left: 0; */
  width: 100%;
  overflow: hidden;
  overflow: auto;
  z-index: 999;
}

.el-container {
  /* position: fixed; */
  width: 100%;
}

.el-dropdown-link {
  width: 100%;
  display: block;
  position: relative;
}

.el-menu {
  border-right: none;
}

.expandend {
  text-align: center;
  margin-right: 5%;
}

.navs {
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
  flex-flow: 1;
}

.maintitle {
  font-size: 20px;
  font-weight: 700;
}

.el-header {
  height: 70px;
}

.el-aside {
  /* height: calc(100vh, -70px); */
  height: calc(100vh - 0px);
  /* height: 100%; */
  height: 91.5vh;
  /* height: 100%; */
  /* height: calc(100vh, -0px); */
}

.el-main {
  margin-top: 60px;
  height: calc(100vh, -70px);
}

.el-menu-vertical-demo .el-menu {
  /* min-height: 100vh; */
  height: calc(100vh, -70px);
}

.btn {
  /* margin-left: 60%; */
  /* position: relative;
  right: -70%; */
  margin-left: auto;
}

.collapseandunfoled {
  text-align: center;
  line-height: 40px;
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
</style>
