MainPage.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <style lang="scss" scoped>
  2. .main-page{
  3. height: 100%;
  4. display: flex;
  5. }
  6. .left-menu{
  7. width: 60px;
  8. background-image: linear-gradient(185deg,#536080,#2e374d);
  9. text-align: center;
  10. position: relative;
  11. .head{
  12. width: 40px;
  13. height: 40px;
  14. background: #3C76FC;
  15. border: solid 2px #f8f9fa;
  16. border-radius: 50%;
  17. margin: 30px auto 10px;
  18. color:#f8f9fa;
  19. p{
  20. height: 100%;
  21. line-height: 36px;
  22. }
  23. }
  24. &>p{
  25. color: white;
  26. font-size: 15px;
  27. }
  28. ul{
  29. margin-top: 20px;
  30. li{
  31. cursor: pointer;
  32. .route-menu{
  33. display: inline-block;
  34. width: 100%;
  35. height: 100%;
  36. img{
  37. margin: 15px auto;
  38. width: 25px;
  39. opacity: 0.5;
  40. }
  41. &:hover,&.router-link-active{
  42. background: #3C76FC;
  43. img{
  44. opacity: 1;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. .right-content{
  52. width: calc(100% - 60px);
  53. .tool-bar{
  54. height: 60px;
  55. line-height: 60px;
  56. padding: 0 15px;
  57. border-bottom: solid 1px #DEE0E3;
  58. display: flex;
  59. &>div{
  60. flex: auto;
  61. span:first-child{
  62. margin-right: 20px;
  63. }
  64. span:nth-child(3){
  65. margin-left: 50px;
  66. }
  67. }
  68. &>p{
  69. font-size: 16px;
  70. }
  71. }
  72. .route-area{
  73. height: calc(100% - 60px);
  74. }
  75. }
  76. .seting-bt{
  77. color: white;
  78. font-size: 20px;
  79. position: absolute;
  80. left: 20px;
  81. bottom: 20px;
  82. cursor: pointer;
  83. }
  84. .dialog-style{
  85. /deep/ .el-dialog__body{
  86. height: 500px;
  87. padding: 10px 20px;
  88. overflow: auto;
  89. }
  90. p{
  91. font-size: 16px;
  92. margin-bottom: 15px;
  93. }
  94. }
  95. </style>
  96. <template>
  97. <div class="main-page">
  98. <div class="left-menu">
  99. <div class="head">
  100. <p>头像</p>
  101. </div>
  102. <p>{{$store.state.loginUser.name}}</p>
  103. <ul>
  104. <li v-for="item in list" :key="item.name">
  105. <router-link class="route-menu" :to="item.link">
  106. <img :src="item.src">
  107. </router-link>
  108. </li>
  109. </ul>
  110. <i class="el-icon-s-release seting-bt" @click="logout"></i>
  111. </div>
  112. <div class="right-content">
  113. <div class="tool-bar">
  114. <div>
  115. <span v-if="ableChangeUser">查看计划:{{$store.state.checkUser.name}}</span>
  116. <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>
  117. </div>
  118. <p>
  119. <label>年度总目标:{{currentPlan.name}}</label>
  120. </p>
  121. </div>
  122. <router-view class="route-area"></router-view>
  123. </div>
  124. <el-dialog
  125. class="dialog-style"
  126. title="切换成员"
  127. :visible.sync="personChange"
  128. width="500px">
  129. <p>查看:{{currentUser.name}}</p>
  130. <UserTree @chooseUser="chooseUser"></UserTree>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="personChange = false">取 消</el-button>
  133. <el-button type="primary" @click="changeCheckUser">确 定</el-button>
  134. </span>
  135. </el-dialog>
  136. </div>
  137. </template>
  138. <script>
  139. import { getCurrent } from '@/api/year';
  140. import { logout } from "@/api/login";
  141. import UserTree from "@/components/MainPage/Department/UserTree";
  142. export default {
  143. name: 'MainPage',
  144. components: {
  145. UserTree
  146. },
  147. data () {
  148. return {
  149. list:[
  150. // {
  151. // name: '待办',
  152. // src: require('@/images/icon/todo.png'),
  153. // link: '/app/mainPage/todo'
  154. // },
  155. {
  156. name: '年度计划',
  157. src: require('@/images/icon/year.png'),
  158. link: '/app/mainPage/year'
  159. },{
  160. name: '季度计划',
  161. src: require('@/images/icon/quarter.png'),
  162. link: '/app/mainPage/quarter'
  163. },{
  164. name: '月计划',
  165. src: require('@/images/icon/month.png'),
  166. link: '/app/mainPage/month'
  167. },{
  168. name: '人员',
  169. src: require('@/images/icon/person.png'),
  170. link: '/app/mainPage/department'
  171. }],
  172. personChange: false,
  173. currentPlan:{},
  174. currentUser: {}
  175. }
  176. },
  177. created() {
  178. this.getCurrent();
  179. },
  180. computed: {
  181. ableChangeUser() {
  182. return this.$route.name == 'Month'
  183. },
  184. },
  185. watch: {
  186. '$store.state.curPlanSin'(val){
  187. this.getCurrent();
  188. }
  189. },
  190. methods: {
  191. getCurrent(){
  192. let currentYear = new Date().getFullYear();
  193. getCurrent(currentYear).then((data) => {
  194. if(data.result){
  195. this.currentPlan = data.data;
  196. }
  197. })
  198. },
  199. chooseUser(val){
  200. this.currentUser = val;
  201. },
  202. changeCheckUser(){
  203. this.$store.dispatch('setCheckUser', this.currentUser);
  204. this.personChange = false;
  205. },
  206. logout() {
  207. logout()
  208. .then(res => {
  209. if (res && res.ok == "1") {
  210. this.$router.replace({path: '/login'});
  211. } else {
  212. this.$Message.error((res && res.msg) || "登出失败!");
  213. }
  214. })
  215. .catch(() => {
  216. this.$Message.error("登出失败!");
  217. });
  218. },
  219. }
  220. }
  221. </script>