Home.vue 13 KB

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