Home.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <el-row class="container">
  3. <el-col :span="24" class="header">
  4. <el-col :span="10" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'">
  5. {{collapsed?'':sysName}}
  6. </el-col>
  7. <el-col :span="10">
  8. <div class="tools" @click.prevent="collapse">
  9. <i class="fa fa-align-justify"></i>
  10. </div>
  11. </el-col>
  12. <el-col :span="4" class="userinfo">
  13. <el-dropdown trigger="hover">
  14. <span class="el-dropdown-link userinfo-inner"><img src="../assets/image/userHead.jpg" /> {{sysUserName}}</span>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item @click.native="reset">修改密码</el-dropdown-item>
  17. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. </el-col>
  21. </el-col>
  22. <el-col :span="24" class="main">
  23. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  24. <!--导航菜单-->
  25. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" @open="handleopen" @close="handleclose" @select="handleselect" unique-opened router v-if="!collapsed">
  26. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  27. <el-submenu :index="index+''" v-if="!item.leaf">
  28. <template slot="title"><i :class="item.iconCls"></i><span class="itemName">{{item.name}}</span></template>
  29. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">{{child.name}}</el-menu-item>
  30. </el-submenu>
  31. <el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path"><i :class="item.iconCls"></i>{{item.children[0].name}}</el-menu-item>
  32. </template>
  33. </el-menu>
  34. <!--导航菜单-折叠后-->
  35. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  36. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  37. <template v-if="!item.leaf">
  38. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)"><i :class="item.iconCls"></i></div>
  39. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  40. <li v-for="child in item.children" v-if="!child.hidden" :key="child.path" class="el-menu-item" style="padding-left: 40px;" :class="$route.path==child.path?'is-active':''" @click="$router.push(child.path)">{{child.name}}</li>
  41. </ul>
  42. </template>
  43. <template v-else>
  44. <li class="el-submenu">
  45. <div class="el-submenu__title el-menu-item" style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;" :class="$route.path==item.children[0].path?'is-active':''" @click="$router.push(item.children[0].path)"><i :class="item.iconCls"></i></div>
  46. </li>
  47. </template>
  48. </li>
  49. </ul>
  50. </aside>
  51. <section class="content-container">
  52. <div class="grid-content bg-purple-light">
  53. <!-- <el-col :span="24" class="breadcrumb-container">
  54. <strong class="title">{{$route.name}}</strong>
  55. <el-breadcrumb separator="/" class="breadcrumb-inner">
  56. <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
  57. {{ item.name }}
  58. </el-breadcrumb-item>
  59. </el-breadcrumb>
  60. </el-col> -->
  61. <el-col :span="24" class="content-wrapper">
  62. <transition name="fade" mode="out-in">
  63. <router-view></router-view>
  64. </transition>
  65. </el-col>
  66. </div>
  67. <!--修改密码-->
  68. <el-dialog title="修改密码" v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass='customWidth'>
  69. <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
  70. <el-form-item label="新密码" prop="password">
  71. <el-input v-model="addForm.password" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
  72. </el-form-item>
  73. </el-form>
  74. <div slot="footer" class="dialog-footer">
  75. <el-button @click.native="editPassWord = false">取消</el-button>
  76. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
  77. </div>
  78. </el-dialog>
  79. </section>
  80. </el-col>
  81. </el-row>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. sysName:'云塑网后台管理系统',
  88. collapsed:false,
  89. sysUserName: '',
  90. form: {
  91. name: '',
  92. region: '',
  93. date1: '',
  94. date2: '',
  95. delivery: false,
  96. type: [],
  97. resource: '',
  98. desc: ''
  99. },
  100. editPassWord: false,
  101. editLoading: false,
  102. addForm: {
  103. password: ''
  104. },
  105. passRule: {
  106. password: [
  107. { required: true, message: '请输入新密码', trigger: 'blur' }
  108. ]
  109. }
  110. }
  111. },
  112. methods: {
  113. onSubmit() {
  114. },
  115. handleopen() {
  116. },
  117. handleclose() {
  118. },
  119. handleselect: function (a, b) {
  120. },
  121. //退出登录
  122. logout: function () {
  123. var _this = this;
  124. this.$confirm('确认退出吗?', '提示', {
  125. //type: 'warning'
  126. }).then(() => {
  127. sessionStorage.removeItem('user');
  128. _this.$router.push('/login');
  129. });
  130. },
  131. //折叠导航栏
  132. collapse:function(){
  133. this.collapsed=!this.collapsed;
  134. },
  135. showMenu(i,status){
  136. this.$refs.menuCollapsed.getElementsByClassName('submenu-hook-'+i)[0].style.display=status?'block':'none';
  137. },
  138. reset() {
  139. this.editPassWord = true;
  140. this.addForm.id = JSON.parse(sessionStorage.getItem('user')).id;
  141. this.addForm.account = JSON.parse(sessionStorage.getItem('user')).account;
  142. },
  143. resetPwd(){
  144. this.$refs.addForm.validate((valid) => {
  145. if (valid) {
  146. this.editLoading = true;
  147. this.http.post(this.port.pwd.resetPwd, this.addForm , res => {
  148. this.editLoading = false;
  149. this.editPassWord = false;
  150. if (res.code == "ok") {
  151. this.$message({
  152. message: '修改成功,请重新登录',
  153. type: 'success'
  154. });
  155. this.$router.push('/login');
  156. } else {
  157. this.$message({
  158. message: res.msg,
  159. type: 'error'
  160. });
  161. }
  162. }, error => {
  163. this.editLoading = false;
  164. this.editPassWord = false;
  165. this.$message({
  166. message: error,
  167. type: 'error'
  168. });
  169. })
  170. }
  171. });
  172. }
  173. },
  174. mounted() {
  175. var user = sessionStorage.getItem('user');
  176. if (user) {
  177. user = JSON.parse(user);
  178. this.sysUserName = user.username || '';
  179. } else {
  180. this.$router.push('/login');
  181. }
  182. }
  183. }
  184. </script>
  185. <style scoped lang="scss">
  186. @import '~scss_vars';
  187. .el-menu-vertical-demo i {
  188. margin-right: 10px;
  189. }
  190. .container {
  191. position: absolute;
  192. top: 0px;
  193. bottom: 0px;
  194. width: 100%;
  195. .header {
  196. height: 60px;
  197. line-height: 60px;
  198. background: $color-primary;
  199. color:#fff;
  200. .userinfo {
  201. text-align: right;
  202. padding-right: 35px;
  203. float: right;
  204. .userinfo-inner {
  205. cursor: pointer;
  206. color:#fff;
  207. img {
  208. width: 40px;
  209. height: 40px;
  210. border-radius: 20px;
  211. margin: 10px 10px 10px 10px;
  212. // float: right;
  213. float: left;
  214. }
  215. }
  216. }
  217. .logo {
  218. //width:230px;
  219. height:60px;
  220. font-size: 21px;
  221. padding-left:20px;
  222. padding-right:20px;
  223. border-color: rgba(238,241,146,0.3);
  224. border-right-width: 1px;
  225. border-right-style: solid;
  226. img {
  227. width: 40px;
  228. float: left;
  229. margin: 10px 10px 10px 18px;
  230. }
  231. .txt {
  232. color:#fff;
  233. }
  234. }
  235. .logo-width{
  236. width:230px;
  237. }
  238. .logo-collapse-width{
  239. width:60px
  240. }
  241. .tools{
  242. padding: 0px 23px;
  243. width:14px;
  244. height: 60px;
  245. line-height: 60px;
  246. cursor: pointer;
  247. }
  248. }
  249. .main {
  250. display: flex;
  251. // background: #324057;
  252. position: absolute;
  253. top: 60px;
  254. bottom: 0px;
  255. overflow: hidden;
  256. aside {
  257. flex:0 0 230px;
  258. width: 230px;
  259. // position: absolute;
  260. // top: 0px;
  261. // bottom: 0px;
  262. .el-menu{
  263. height: 100%;
  264. }
  265. .collapsed{
  266. width:60px;
  267. .item{
  268. position: relative;
  269. }
  270. .submenu{
  271. position:absolute;
  272. top:0px;
  273. left:60px;
  274. z-index:99999;
  275. height:auto;
  276. display:none;
  277. }
  278. }
  279. }
  280. .menu-collapsed{
  281. flex:0 0 60px;
  282. width: 60px;
  283. }
  284. .menu-expanded{
  285. flex:0 0 230px;
  286. width: 230px;
  287. }
  288. .content-container {
  289. // background: #f8f8f8;
  290. //f1f2f7
  291. flex:1;
  292. // position: absolute;
  293. // right: 0px;
  294. // top: 0px;
  295. // bottom: 0px;
  296. // left: 230px;
  297. // overflow-y: scroll;
  298. padding: 20px;
  299. .breadcrumb-container {
  300. //margin-bottom: 15px;
  301. .title {
  302. width: 200px;
  303. float: left;
  304. color: #475669;
  305. }
  306. .breadcrumb-inner {
  307. float: right;
  308. }
  309. }
  310. .content-wrapper {
  311. background-color: #fff;
  312. box-sizing: border-box;
  313. }
  314. }
  315. }
  316. }
  317. </style>