123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <style lang="scss" scoped>
- .main-page{
- height: 100%;
- display: flex;
- }
- .left-menu{
- width: 60px;
- background-image: linear-gradient(185deg,#536080,#2e374d);
- text-align: center;
- position: relative;
- .head{
- width: 40px;
- height: 40px;
- background: #3C76FC;
- border: solid 2px #f8f9fa;
- border-radius: 50%;
- margin: 30px auto 10px;
- color:#f8f9fa;
- p{
- height: 100%;
- line-height: 36px;
- }
- }
- &>p{
- color: white;
- font-size: 15px;
- }
- ul{
- margin-top: 20px;
- li{
- cursor: pointer;
- .route-menu{
- display: inline-block;
- width: 100%;
- height: 100%;
- img{
- margin: 15px auto;
- width: 25px;
- opacity: 0.5;
- }
- &:hover,&.router-link-active{
- background: #3C76FC;
- img{
- opacity: 1;
- }
- }
- }
- }
- }
- }
- .right-content{
- width: calc(100% - 60px);
- .tool-bar{
- height: 60px;
- line-height: 60px;
- padding: 0 15px;
- border-bottom: solid 1px #DEE0E3;
- display: flex;
- &>div{
- flex: auto;
- span:first-child{
- margin-right: 20px;
- }
- span:nth-child(3){
- margin-left: 50px;
- }
- }
- &>p{
- font-size: 16px;
- }
- }
- .route-area{
- height: calc(100% - 60px);
- }
- }
- .seting-bt{
- color: white;
- font-size: 20px;
- position: absolute;
- left: 20px;
- bottom: 20px;
- cursor: pointer;
- }
- .dialog-style{
- /deep/ .el-dialog__body{
- height: 500px;
- padding: 10px 20px;
- overflow: auto;
- }
- p{
- font-size: 16px;
- margin-bottom: 15px;
- }
- }
- </style>
- <template>
- <div class="main-page">
- <div class="left-menu">
- <div class="head">
- <p>头像</p>
- </div>
- <p>{{$store.state.loginUser.name}}</p>
- <ul>
- <li v-for="item in list" :key="item.name">
- <router-link class="route-menu" :to="item.link">
- <img :src="item.src">
- </router-link>
- </li>
- </ul>
- <i class="el-icon-s-release seting-bt" @click="logout"></i>
- </div>
- <div class="right-content">
- <div class="tool-bar">
- <div>
- <span v-if="ableChangeUser">查看计划:{{$store.state.checkUser.name}}</span>
- <el-button type="primary" icon="el-icon-edit" circle v-if="ableChangeUser" @click="personChange = true;currentUser = JSON.parse(JSON.stringify($store.state.checkUser))"></el-button>
- </div>
- <p>
- <label>年度总目标:{{currentPlan.name}}</label>
- </p>
- </div>
- <router-view class="route-area"></router-view>
- </div>
- <el-dialog
- class="dialog-style"
- title="切换成员"
- :visible.sync="personChange"
- width="500px">
- <p>查看:{{currentUser.name}}</p>
- <UserTree @chooseUser="chooseUser"></UserTree>
- <span slot="footer" class="dialog-footer">
- <el-button @click="personChange = false">取 消</el-button>
- <el-button type="primary" @click="changeCheckUser">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getCurrent } from '@/api/year';
- import { logout } from "@/api/login";
- import UserTree from "@/components/MainPage/Department/UserTree";
- export default {
- name: 'MainPage',
- components: {
- UserTree
- },
- data () {
- return {
- list:[
-
-
-
-
-
- {
- name: '年度计划',
- src: require('@/images/icon/year.png'),
- link: '/app/mainPage/year'
- },{
- name: '季度计划',
- src: require('@/images/icon/quarter.png'),
- link: '/app/mainPage/quarter'
- },{
- name: '月计划',
- src: require('@/images/icon/month.png'),
- link: '/app/mainPage/month'
- },{
- name: '人员',
- src: require('@/images/icon/person.png'),
- link: '/app/mainPage/department'
- }],
- personChange: false,
- currentPlan:{},
- currentUser: {}
- }
- },
- created() {
- this.getCurrent();
- },
- computed: {
- ableChangeUser() {
- return this.$route.name == 'Month'
- },
- },
- watch: {
- '$store.state.curPlanSin'(val){
- this.getCurrent();
- }
- },
- methods: {
- getCurrent(){
- let currentYear = new Date().getFullYear();
- getCurrent(currentYear).then((data) => {
- if(data.result){
- this.currentPlan = data.data;
- }
- })
- },
- chooseUser(val){
- this.currentUser = val;
- },
- changeCheckUser(){
- this.$store.dispatch('setCheckUser', this.currentUser);
- this.personChange = false;
- },
- logout() {
- logout()
- .then(res => {
- if (res && res.ok == "1") {
- this.$router.replace({path: '/login'});
- } else {
- this.$Message.error((res && res.msg) || "登出失败!");
- }
- })
- .catch(() => {
- this.$Message.error("登出失败!");
- });
- },
- }
- }
- </script>
|