Home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <el-row class="container">
  3. <el-col :span="24" class="header">
  4. <el-col
  5. :span="10"
  6. class="logo"
  7. :class="collapsed?'logo-collapse-width':'logo-width'"
  8. >{{collapsed?'':sysName}}</el-col>
  9. <el-col :span="10">
  10. <div class="tools" @click.prevent="collapse">
  11. <i class="fa fa-align-justify"></i>
  12. </div>
  13. </el-col>
  14. <el-col :span="4" class="userinfo">
  15. <el-badge is-dot class="itemNew">
  16. <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1></i>
  17. <!-- 消息中心 -->
  18. <el-popover ref="popover1" placement="bottom" width="400" trigger="hover">
  19. <div class="popover-main">消息盒子</div>
  20. <div class="popover-item" v-for="item in popoverData">
  21. <p class="popover-title">
  22. {{item.title}}
  23. <span class="popover-type">[{{item.type}}]</span>
  24. </p>
  25. <p>{{item.article}}</p>
  26. </div>
  27. <div class="popover-button">查看全部</div>
  28. </el-popover>
  29. </el-badge>
  30. <el-dropdown trigger="hover">
  31. <span class="el-dropdown-link userinfo-inner">
  32. <img src="../assets/image/userHead.jpg" />
  33. {{sysUserName}}
  34. </span>
  35. <el-dropdown-menu slot="dropdown">
  36. <el-dropdown-item @click.native="reset">修改密码</el-dropdown-item>
  37. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </el-col>
  41. </el-col>
  42. <el-col :span="24" class="main">
  43. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  44. <!--导航菜单-->
  45. <el-menu
  46. :default-active="$route.path"
  47. class="el-menu-vertical-demo"
  48. @open="handleopen"
  49. @close="handleclose"
  50. @select="handleselect"
  51. unique-opened
  52. router
  53. v-if="!collapsed"
  54. >
  55. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  56. <el-submenu :index="index+''" v-if="!item.leaf">
  57. <template slot="title">
  58. <i :class="item.iconCls"></i>
  59. <span class="itemName">{{item.name}}</span>
  60. </template>
  61. <el-menu-item
  62. v-for="child in item.children"
  63. :index="child.path"
  64. :key="child.path"
  65. v-if="!child.hidden"
  66. >{{child.name}}</el-menu-item>
  67. </el-submenu>
  68. <el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path">
  69. <i :class="item.iconCls"></i>
  70. {{item.children[0].name}}
  71. </el-menu-item>
  72. </template>
  73. </el-menu>
  74. <!--导航菜单-折叠后-->
  75. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  76. <li
  77. v-for="(item,index) in $router.options.routes"
  78. v-if="!item.hidden"
  79. class="el-submenu item"
  80. :style="{overflow:!item.leaf?'':'hidden'}"
  81. >
  82. <template v-if="!item.leaf">
  83. <div
  84. class="el-submenu__title"
  85. style="padding-left: 20px;"
  86. @mouseover="showMenu(index,true)"
  87. @mouseout="showMenu(index,false)"
  88. >
  89. <i :class="item.iconCls"></i>
  90. </div>
  91. <ul
  92. class="el-menu submenu"
  93. :class="'submenu-hook-'+index"
  94. @mouseover="showMenu(index,true)"
  95. @mouseout="showMenu(index,false)"
  96. >
  97. <li
  98. v-for="child in item.children"
  99. v-if="!child.hidden"
  100. :key="child.path"
  101. class="el-menu-item"
  102. style="padding-left: 40px;"
  103. :class="$route.path==child.path?'is-active':''"
  104. @click="$router.push(child.path)"
  105. >{{child.name}}</li>
  106. </ul>
  107. </template>
  108. <template v-else>
  109. <li class="el-submenu">
  110. <div
  111. class="el-submenu__title el-menu-item"
  112. style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;"
  113. :class="$route.path==item.children[0].path?'is-active':''"
  114. @click="$router.push(item.children[0].path)"
  115. >
  116. <i :class="item.iconCls"></i>
  117. </div>
  118. </li>
  119. </template>
  120. </li>
  121. </ul>
  122. </aside>
  123. <section class="content-container">
  124. <div class="grid-content bg-purple-light">
  125. <!-- <el-col :span="24" class="breadcrumb-container">
  126. <strong class="title">{{$route.name}}</strong>
  127. <el-breadcrumb separator="/" class="breadcrumb-inner">
  128. <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
  129. {{ item.name }}
  130. </el-breadcrumb-item>
  131. </el-breadcrumb>
  132. </el-col>-->
  133. <el-col :span="24" class="content-wrapper">
  134. <transition name="fade" mode="out-in">
  135. <router-view></router-view>
  136. </transition>
  137. </el-col>
  138. </div>
  139. <!--修改密码-->
  140. <el-dialog
  141. title="修改密码"
  142. v-if="editPassWord"
  143. :visible.sync="editPassWord"
  144. :close-on-click-modal="false"
  145. customClass="customWidth"
  146. >
  147. <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
  148. <el-form-item label="新密码" prop="password">
  149. <el-input
  150. v-model="addForm.password"
  151. autocomplete="off"
  152. placeholder="请输入新密码"
  153. show-password
  154. ></el-input>
  155. </el-form-item>
  156. </el-form>
  157. <div slot="footer" class="dialog-footer">
  158. <el-button @click.native="editPassWord = false">取消</el-button>
  159. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
  160. </div>
  161. </el-dialog>
  162. </section>
  163. </el-col>
  164. </el-row>
  165. </template>
  166. <script>
  167. export default {
  168. data() {
  169. return {
  170. user: sessionStorage.getItem("user"),
  171. sysName: "云塑网后台管理系统",
  172. collapsed: false,
  173. sysUserName: "",
  174. editPassWord: false,
  175. editLoading: false,
  176. addForm: {
  177. password: ""
  178. },
  179. passRule: {
  180. password: [{ required: true, message: "请输入新密码", trigger: "blur" }]
  181. },
  182. popoverData: [
  183. {
  184. title: "墨盒测试项目——零件文档",
  185. article: "模具开发人员:王有财已上传完毕,待您审核",
  186. type: "审批"
  187. },
  188. {
  189. title: "墨盒测试项目——零件文档",
  190. article: "您上传的文档未通过项目经理:张多金审批,请修改后重新上传",
  191. type: "审批"
  192. },
  193. {
  194. title: "墨盒测试项目——零件文档",
  195. article: "该模具需要保养,请前往处理",
  196. type: "保养"
  197. }
  198. ]
  199. };
  200. },
  201. methods: {
  202. onSubmit() {},
  203. handleopen() {},
  204. handleclose() {},
  205. handleselect: function(a, b) {},
  206. //退出登录
  207. logout: function() {
  208. var _this = this;
  209. this.$confirm("确认退出吗?", "提示", {
  210. //type: 'warning'
  211. }).then(() => {
  212. sessionStorage.removeItem("user");
  213. _this.$router.push("/login");
  214. });
  215. },
  216. //折叠导航栏
  217. collapse: function() {
  218. this.collapsed = !this.collapsed;
  219. },
  220. showMenu(i, status) {
  221. this.$refs.menuCollapsed.getElementsByClassName(
  222. "submenu-hook-" + i
  223. )[0].style.display = status ? "block" : "none";
  224. },
  225. reset() {
  226. this.editPassWord = true;
  227. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  228. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  229. },
  230. resetPwd() {
  231. this.$refs.addForm.validate(valid => {
  232. if (valid) {
  233. this.editLoading = true;
  234. this.http.post(
  235. this.port.pwd.resetPwd,
  236. this.addForm,
  237. res => {
  238. this.editLoading = false;
  239. this.editPassWord = false;
  240. if (res.code == "ok") {
  241. this.$message({
  242. message: "修改成功,请重新登录",
  243. type: "success"
  244. });
  245. this.$router.push("/login");
  246. } else {
  247. this.$message({
  248. message: res.msg,
  249. type: "error"
  250. });
  251. }
  252. },
  253. error => {
  254. this.editLoading = false;
  255. this.editPassWord = false;
  256. this.$message({
  257. message: error,
  258. type: "error"
  259. });
  260. }
  261. );
  262. }
  263. });
  264. }
  265. },
  266. mounted() {
  267. if (this.user) {
  268. var user = JSON.parse(this.user);
  269. this.user = user;
  270. this.sysUserName = user.username || "";
  271. } else {
  272. this.$router.push("/login");
  273. }
  274. }
  275. };
  276. </script>
  277. <style scoped lang="scss">
  278. @import "~scss_vars";
  279. .el-menu-vertical-demo i {
  280. margin-right: 10px;
  281. }
  282. .itemNew {
  283. height: 25px;
  284. margin-left: 15px;
  285. i {
  286. vertical-align: top;
  287. }
  288. }
  289. .container {
  290. position: absolute;
  291. top: 0px;
  292. bottom: 0px;
  293. width: 100%;
  294. .header {
  295. height: 60px;
  296. line-height: 60px;
  297. background: $color-primary;
  298. color: #fff;
  299. .userinfo {
  300. text-align: right;
  301. padding-right: 35px;
  302. float: right;
  303. .userinfo-inner {
  304. cursor: pointer;
  305. color: #fff;
  306. img {
  307. width: 40px;
  308. height: 40px;
  309. border-radius: 20px;
  310. margin: 10px 10px 10px 10px;
  311. // float: right;
  312. float: left;
  313. }
  314. }
  315. }
  316. .logo {
  317. //width:230px;
  318. height: 60px;
  319. font-size: 21px;
  320. padding-left: 20px;
  321. padding-right: 20px;
  322. border-color: rgba(238, 241, 146, 0.3);
  323. border-right-width: 1px;
  324. border-right-style: solid;
  325. img {
  326. width: 40px;
  327. float: left;
  328. margin: 10px 10px 10px 18px;
  329. }
  330. .txt {
  331. color: #fff;
  332. }
  333. }
  334. .logo-width {
  335. width: 230px;
  336. }
  337. .logo-collapse-width {
  338. width: 60px;
  339. }
  340. .tools {
  341. padding: 0px 23px;
  342. width: 14px;
  343. height: 60px;
  344. line-height: 60px;
  345. cursor: pointer;
  346. }
  347. }
  348. .main {
  349. display: flex;
  350. // background: #324057;
  351. position: absolute;
  352. top: 60px;
  353. bottom: 0px;
  354. overflow: hidden;
  355. aside {
  356. flex: 0 0 230px;
  357. width: 230px;
  358. // position: absolute;
  359. // top: 0px;
  360. // bottom: 0px;
  361. .el-menu {
  362. height: 100%;
  363. }
  364. .collapsed {
  365. width: 60px;
  366. .item {
  367. position: relative;
  368. }
  369. .submenu {
  370. position: absolute;
  371. top: 0px;
  372. left: 60px;
  373. z-index: 99999;
  374. height: auto;
  375. display: none;
  376. }
  377. }
  378. }
  379. .menu-collapsed {
  380. flex: 0 0 60px;
  381. width: 60px;
  382. }
  383. .menu-expanded {
  384. flex: 0 0 230px;
  385. width: 230px;
  386. }
  387. .content-container {
  388. // background: #f8f8f8;
  389. //f1f2f7
  390. flex: 1;
  391. width: 80%;
  392. // position: absolute;
  393. // right: 0px;
  394. // top: 0px;
  395. // bottom: 0px;
  396. // left: 230px;
  397. // overflow-y: scroll;
  398. padding: 20px;
  399. .breadcrumb-container {
  400. //margin-bottom: 15px;
  401. .title {
  402. width: 200px;
  403. float: left;
  404. color: #475669;
  405. }
  406. .breadcrumb-inner {
  407. float: right;
  408. }
  409. }
  410. .content-wrapper {
  411. background-color: #fff;
  412. box-sizing: border-box;
  413. }
  414. }
  415. }
  416. }
  417. .popover-main {
  418. font-weight: 700;
  419. padding-bottom: 12px;
  420. border-bottom: 1px grey solid;
  421. }
  422. .popover-title {
  423. color: blue;
  424. }
  425. .popover-type {
  426. color: black;
  427. float: right;
  428. }
  429. .popover-item {
  430. border-bottom: 1px grey solid;
  431. }
  432. .popover-button {
  433. font-weight: 700;
  434. padding-top: 12px;
  435. text-align: center;
  436. }
  437. </style>