123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <template>
- <el-container class="layout-cont">
- <el-container :class="[isSider?'openside':'hideside',isMobile ? 'mobile': '']">
- <el-row :class="[isShadowBg?'shadowBg':'']" @click.native="changeShadow()"></el-row>
- <el-aside class="main-cont main-left">
- <div class="tilte">
- <img alt class="logoimg" src="~@/assets/nav_logo.png" />
- <h2 class="tit-text" v-if="isSider">Gin-Vue-Admin</h2>
- </div>
- <Aside class="aside" />
- </el-aside>
- <!-- 分块滑动功能 -->
- <el-main class="main-cont main-right">
- <transition :duration="{ enter: 800, leave: 100 }" mode="out-in" name="el-fade-in-linear">
- <div
- :style="{width: `calc(100% - ${isMobile?'0px':isCollapse?'54px':'220px'})`}"
- class="topfix"
- >
- <el-header class="header-cont">
- <div @click="totalCollapse" class="menu-total">
- <i class="el-icon-s-unfold" v-if="isCollapse"></i>
- <i class="el-icon-s-fold" v-else></i>
- </div>
- <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
- <el-breadcrumb-item
- :key="item.path"
- v-for="item in matched.slice(1,matched.length)"
- >{{item.meta.title}}</el-breadcrumb-item>
- </el-breadcrumb>
- <div class="fl-right right-box">
- <Search />
- <Screenfull class="screenfull"></Screenfull>
- <el-dropdown>
- <span class="header-avatar">
- 欢迎您,<CustomPic/>
- <span style="margin-left: 5px">{{userInfo.nickName}}</span>
- <i class="el-icon-arrow-down"></i>
- </span>
- <el-dropdown-menu class="dropdown-group" slot="dropdown">
- <el-dropdown-item>
- <span>
- 更多信息
- <el-badge is-dot />
- </span>
- </el-dropdown-item>
- <el-dropdown-item @click.native="showPassword=true" icon="el-icon-s-custom">修改密码</el-dropdown-item>
- <el-dropdown-item @click.native="toPerson" icon="el-icon-s-custom">个人信息</el-dropdown-item>
- <el-dropdown-item @click.native="LoginOut" icon="el-icon-table-lamp">登 出</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </el-header>
- <!-- 当前面包屑用路由自动生成可根据需求修改 -->
- <!--
- :to="{ path: item.path }" 暂时注释不用-->
- <HistoryComponent />
- </div>
- </transition>
- <transition mode="out-in" name="el-fade-in-linear">
- <keep-alive>
- <router-view class="admin-box" v-if="$route.meta.keepAlive"></router-view>
- </keep-alive>
- </transition>
- <transition mode="out-in" name="el-fade-in-linear">
- <router-view class="admin-box" v-if="!$route.meta.keepAlive"></router-view>
- </transition>
- <BottomInfo />
- </el-main>
- </el-container>
- <el-dialog :visible.sync="showPassword" @close="clearPassword" title="修改密码" width="360px">
- <el-form :model="pwdModify" :rules="rules" label-width="80px" ref="modifyPwdForm">
- <el-form-item :minlength="6" label="原密码" prop="password">
- <el-input show-password v-model="pwdModify.password"></el-input>
- </el-form-item>
- <el-form-item :minlength="6" label="新密码" prop="newPassword">
- <el-input show-password v-model="pwdModify.newPassword"></el-input>
- </el-form-item>
- <el-form-item :minlength="6" label="确认密码" prop="confirmPassword">
- <el-input show-password v-model="pwdModify.confirmPassword"></el-input>
- </el-form-item>
- </el-form>
- <div class="dialog-footer" slot="footer">
- <el-button @click="showPassword=false">取 消</el-button>
- <el-button @click="savePassword" type="primary">确 定</el-button>
- </div>
- </el-dialog>
- </el-container>
- </template>
- <script>
- import Aside from '@/view/layout/aside'
- import HistoryComponent from '@/view/layout/aside/historyComponent/history'
- import Screenfull from '@/view/layout/screenfull'
- import Search from '@/view/layout/search/search'
- import BottomInfo from '@/view/layout/bottomInfo/bottomInfo'
- import { mapGetters, mapActions } from 'vuex'
- import { changePassword } from '@/api/user'
- import CustomPic from '@/components/customPic'
- export default {
- name: 'Layout',
- data() {
- return {
- show: false,
- isCollapse: false,
- isSider: true,
- isMobile: false,
- isShadowBg: false,
- showPassword: false,
- pwdModify: {},
- rules: {
- password: [
- { required: true, message: '请输入密码', trigger: 'blur' },
- { min: 6, message: '最少6个字符', trigger: 'blur' }
- ],
- newPassword: [
- { required: true, message: '请输入新密码', trigger: 'blur' },
- { min: 6, message: '最少6个字符', trigger: 'blur' }
- ],
- confirmPassword: [
- { required: true, message: '请输入确认密码', trigger: 'blur' },
- { min: 6, message: '最少6个字符', trigger: 'blur' },
- {
- validator: (rule, value, callback) => {
- if (value !== this.pwdModify.newPassword) {
- callback(new Error('两次密码不一致'))
- } else {
- callback()
- }
- },
- trigger: 'blur'
- }
- ]
- },
- value: ''
- }
- },
- components: {
- Aside,
- HistoryComponent,
- Screenfull,
- Search,
- BottomInfo,
- CustomPic
- },
- methods: {
- ...mapActions('user', ['LoginOut']),
- totalCollapse() {
- this.isCollapse = !this.isCollapse
- this.isSider = !this.isCollapse
- this.isShadowBg = !this.isCollapse
- this.$bus.emit('collapse', this.isCollapse)
- },
- toPerson() {
- this.$router.push({ name: 'person' })
- },
- changeShadow() {
- this.isShadowBg = !this.isShadowBg
- this.isSider = !!this.isCollapse
- this.totalCollapse()
- },
- savePassword() {
- this.$refs.modifyPwdForm.validate(valid => {
- if (valid) {
- changePassword({
- username: this.userInfo.userName,
- password: this.pwdModify.password,
- newPassword: this.pwdModify.newPassword
- }).then(() => {
- this.$message.success('修改密码成功!')
- this.showPassword = false
- })
- } else {
- return false
- }
- })
- },
- clearPassword() {
- this.pwdModify = {
- password: '',
- newPassword: '',
- confirmPassword: ''
- }
- this.$refs.modifyPwdForm.clearValidate()
- }
- },
- computed: {
- ...mapGetters('user', ['userInfo']),
- title() {
- return this.$route.meta.title || '当前页面'
- },
- matched() {
- return this.$route.matched
- }
- },
- mounted() {
- let screenWidth = document.body.clientWidth
- if (screenWidth < 1000) {
- this.isMobile = true
- this.isSider = false
- this.isCollapse = true
- } else if (screenWidth >= 1000 && screenWidth < 1200) {
- this.isMobile = false
- this.isSider = false
- this.isCollapse = true
- } else {
- this.isMobile = false
- this.isSider = true
- this.isCollapse = false
- }
- this.$bus.emit('collapse', this.isCollapse)
- this.$bus.emit('mobile', this.isMobile)
- window.onresize = () => {
- return (() => {
- let screenWidth = document.body.clientWidth
- if (screenWidth < 1000) {
- this.isMobile = true
- this.isSider = false
- this.isCollapse = true
- } else if (screenWidth >= 1000 && screenWidth < 1200) {
- this.isMobile = false
- this.isSider = false
- this.isCollapse = true
- } else {
- this.isMobile = false
- this.isSider = true
- this.isCollapse = false
- }
- this.$bus.emit('collapse', this.isCollapse)
- this.$bus.emit('mobile', this.isMobile)
- })()
- }
- }
- }
- </script>
- <style lang="scss">
- $headerHigh: 52px;
- $mainHight: 100vh;
- .dropdown-group {
- min-width: 100px;
- }
- .topfix {
- position: fixed;
- top: 0;
- box-sizing: border-box;
- z-index: 999;
- }
- .admin-box {
- min-height: calc(100vh - 240px);
- background-color: rgb(255, 255, 255);
- margin-top: 100px;
- }
- .el-scrollbar__wrap {
- padding-bottom: 17px;
- }
- .layout-cont {
- .right-box {
- text-align: center;
- vertical-align: middle;
- img {
- vertical-align: middle;
- border: 1px solid #ccc;
- border-radius: 6px;
- }
- }
- .header-cont {
- height: $headerHigh !important;
- background: #fff;
- box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
- line-height: $headerHigh;
- }
- .main-cont {
- .breadcrumb {
- line-height: 48px;
- display: inline-block;
- padding: 0 24px;
- // padding: 6px;
- // border-bottom: 1px solid #eee;
- }
- &.el-main {
- overflow: auto;
- background: #fff;
- // padding: 0px 10px;
- // background: #fff;
- }
- height: $mainHight !important;
- overflow: visible;
- position: relative;
- .menu-total {
- // z-index: 5;
- // position: absolute;
- // top: 10px;
- // right: -35px;
- margin-left: -10px;
- float: left;
- margin-top: 10px;
- width: 30px;
- height: 30px;
- line-height: 30px;
- font-size: 30px;
- // border: 0 solid #ffffff;
- // border-radius: 50%;
- // background: #fff;
- }
- .aside {
- overflow: auto;
- // background: #fff;
- &::-webkit-scrollbar {
- display: none;
- }
- }
- .el-menu-vertical {
- height: calc(100vh - 64px) !important;
- visibility: auto;
- &:not(.el-menu--collapse) {
- width: 220px;
- }
- }
- .el-menu--collapse {
- width: 54px;
- li {
- .el-tooltip,
- .el-submenu__title {
- padding: 0px 15px !important;
- }
- }
- }
- &::-webkit-scrollbar {
- display: none;
- }
- &.main-left {
- width: auto !important;
- }
- &.main-right {
- .admin-title {
- float: left;
- font-size: 16px;
- vertical-align: middle;
- margin-left: 20px;
- img {
- vertical-align: middle;
- }
- &.collapse {
- width: 53px;
- }
- }
- }
- }
- }
- .tilte {
- background: #001529;
- min-height: 64px;
- line-height: 64px;
- background: #002140;
- text-align: center;
- .logoimg {
- width: 30px;
- height: 30px;
- vertical-align: middle;
- background: #fff;
- border-radius: 50%;
- padding: 3px;
- }
- .tit-text {
- display: inline-block;
- color: #fff;
- font-weight: 600;
- font-size: 20px;
- vertical-align: middle;
- }
- }
- .screenfull {
- display: inline-block;
- }
- .header-avatar{
- display: flex;
- justify-content: center;
- align-items: center;
- }
- </style>
|