<template>
  <div id="detail">
    <el-row>
      <el-col :span="24" class="style">
        <el-col :span="24" class="top">
          <top></top>
        </el-col>
        <el-col :span="24" class="main">
          <div class="w_1200">
            <el-col :span="5" class="left">
              <el-col :span="24" class="top">
                <i class="el-icon-s-unfold"></i>
                <span>个人中心</span>
              </el-col>
              <el-col :span="24" class="menus">
                <!-- <el-col class="menuList" :span="24" v-for="(item, index) in menuList" :key="index">
                  <p @click="changeMenu(item.name, index)" :style="`color:${menuIndex == index ? menuColor : ''}`">
                    {{ item.name }}
                  </p>
                </el-col> -->
                <el-menu :default-active="num" @select="selectMenu" text-color="black" active-text-color="#044b79">
                  <el-menu-item index="1">
                    <template slot="title">
                      <span>基本信息</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="2">
                    <template slot="title">
                      <span>需求管理</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="3">
                    <template slot="title">
                      <span>信息管理</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="4">
                    <template slot="title">
                      <span>人员管理</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="5">
                    <template slot="title">
                      <span>部门管理</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="6">
                    <template slot="title">
                      <span>职务管理</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="7">
                    <template slot="title">
                      <span>修改密码</span>
                    </template>
                  </el-menu-item>
                  <el-menu-item index="8">
                    <template slot="title">
                      <span @click="logoutBtn()">退出登录</span>
                    </template>
                  </el-menu-item>
                </el-menu>
              </el-col>
            </el-col>
            <el-col :span="18" class="right">
              <span v-if="columnName == '基本信息'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>基本信息</span> </el-col>
                <pinfo></pinfo>
              </span>
              <span v-else-if="columnName == '需求管理'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>需求管理</span> </el-col>
              </span>
              <span v-else-if="columnName == '信息管理'">
                <el-col :span="24" class="infoTop" style="margin-bottom:0;"> <span>|</span><span>信息管理</span> </el-col>
                <el-col :span="24">
                  <infoAdmin></infoAdmin>
                </el-col>
              </span>
              <span v-else-if="columnName == '人员管理'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>人员管理</span> </el-col>
              </span>
              <span v-else-if="columnName == '部门管理'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>部门管理</span> </el-col>
              </span>
              <span v-else-if="columnName == '职务管理'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>职务管理</span> </el-col>
              </span>
              <span v-else-if="columnName == '修改密码'">
                <el-col :span="24" class="infoTop"> <span>|</span><span>修改密码</span> </el-col>
                <uppasswd></uppasswd>
              </span>
              <span v-else-if="columnName == '退出登录'">
                退出登录
              </span>
            </el-col>
          </div>
        </el-col>
        <el-col :span="24" class="foot">
          <div class="w_1200">
            <foot></foot>
          </div>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import top from '@/layout/common/top.vue';
import foot from '@/layout/common/foot.vue';
import infoAdmin from './parts/infoAdmin.vue';

import pinfo from '@/views/pcenter/pinfo.vue';
import uppasswd from '@/views/pcenter/uppasswd.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: login } = createNamespacedHelpers('login');
export default {
  name: 'detail',
  props: {},
  components: {
    top,
    foot,
    infoAdmin, //信息管理
    pinfo,
    uppasswd,
  },
  data: function() {
    return {
      columnName: '基本信息',
      num: '1',
    };
  },
  created() {
    this.selectMenu();
  },
  methods: {
    ...login({ logout: 'logout' }),
    // 选择栏目
    selectMenu(key) {
      if (key == 1) {
        this.columnName = '基本信息';
      } else if (key == 2) {
        this.columnName = '需求管理';
      } else if (key == 3) {
        this.columnName = '信息管理';
      } else if (key == 4) {
        this.columnName = '人员管理';
      } else if (key == 5) {
        this.columnName = '部门管理';
      } else if (key == 6) {
        this.columnName = '职务管理';
      } else if (key == 7) {
        this.columnName = '修改密码';
      } else if (key == 8) {
        this.columnName = '退出登录';
      }
    },
    // 点击选择菜单
    changeMenu(name, index) {
      this.menuIndex = index;
      this.columnName = name;
      this.menuColor = 'rgb(5,73,130)';
    },
    // 退出登录
    logoutBtn() {
      this.logout();
      this.$router.push({ path: '/' });
    },
  },
  computed: {
    ...mapState(['user']),
    pageTitle() {
      return `${this.$route.meta.title}`;
    },
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
};
</script>

<style lang="less" scoped>
.w_1200 {
  width: 1200px;
  margin: 0 auto;
}
.style {
  .menu {
    height: 70px;
    margin: 0 0 10px 0;
  }
  .main {
    min-height: 600px;
    margin: 0 0 10px 0;
    .left {
      min-height: 600px;
      background: #fff;
      margin: 0 10px 0 0;
      .top {
        height: 60px;
        line-height: 60px;
        background-color: #054982;
        color: #fff;
        font-size: 25px;
        font-weight: 600;
        letter-spacing: 2px;
        text-align: center;
      }
      /deep/.el-menu-item {
        height: 50px;
        line-height: 50px;
        text-align: center;
        border-bottom: 1px solid #ccc;
        span {
          font-size: 20px;
          font-weight: bold;
        }
      }
    }
    .right {
      width: 78%;
      min-height: 600px;
      background: #fff;
    }
  }
  .foot {
    height: 135px;
  }
}
.infoTop {
  height: 50px;
  border-bottom: 1px dashed #ccc;
  margin: 0 auto;
  margin-bottom: 20px;
  float: none;
  width: 98%;
  padding: 20px 0 5px 0;
}
.infoTop span {
  font-size: 20px;
  color: #005293;
  font-weight: bold;
  margin-right: 10px;
}
</style>
