Home.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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. :style="collapsed?'padding:0':''"
  9. >
  10. <img v-if="collapsed" class="headImg" src="../assets/image/head_logo.png" />
  11. <span v-else>{{sysName}}</span>
  12. </el-col>
  13. <el-col :span="10">
  14. <div class="tools" @click.prevent="collapse">
  15. <i class="fa fa-align-justify"></i>
  16. </div>
  17. </el-col>
  18. <el-col :span="6" class="userinfo">
  19. <el-badge :value="messageCount[0] == 0 ? false : messageCount[0]" class="itemNew">
  20. <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1></i>
  21. <!-- 消息中心 -->
  22. <el-popover
  23. ref="popover1"
  24. placement="bottom"
  25. width="400"
  26. trigger="hover"
  27. popper-class="popover-self"
  28. >
  29. <!-- 消息盒子中间部分 -->
  30. <el-tabs v-model="activePage" @tab-click="handleClick" stretch>
  31. <!-- 审批的页面 -->
  32. <el-tab-pane name="0">
  33. <span slot="label">
  34. <span v-if="messageCount[1] == 0">审批</span>
  35. <span v-else>审批({{messageCount[1]}})</span>
  36. </span>
  37. <div class="popover-item" v-if="popoverData.length == 0">暂无审批消息</div>
  38. <div class="popover-item" v-for="item in popoverData">
  39. <p class="popover-title">
  40. <span
  41. style="cursor: pointer;"
  42. @click="locationHerf(item.refId, item.noticeType)"
  43. >{{item.projectName}}</span>
  44. </p>
  45. <p>{{item.content}}</p>
  46. </div>
  47. </el-tab-pane>
  48. <!-- 警告的页面 -->
  49. <el-tab-pane name="1">
  50. <span slot="label">
  51. <span v-if="messageCount[2] == 0">警告</span>
  52. <span v-else>警告{{messageCount[2]}})</span>
  53. </span>
  54. <div class="popover-item" v-if="popoverData.length == 0">暂无警告消息</div>
  55. <div class="popover-item" v-for="item in popoverData">
  56. <p class="popover-title">
  57. <span
  58. style="cursor: pointer;"
  59. @click="locationHerf(item.refId, item.noticeType)"
  60. >{{item.projectName}}</span>
  61. </p>
  62. <p>{{item.content}}</p>
  63. </div>
  64. </el-tab-pane>
  65. <!-- 保养的页面 -->
  66. <el-tab-pane name="2">
  67. <span slot="label">
  68. <span v-if="messageCount[3] == 0">保养</span>
  69. <span v-else>保养{{messageCount[3]}})</span>
  70. </span>
  71. <div class="popover-item" v-if="popoverData.length == 0">暂无保养消息</div>
  72. <div class="popover-item" v-for="item in popoverData">
  73. <p class="popover-title">
  74. <span
  75. style="cursor: pointer;"
  76. @click="locationHerf(item.refId, item.noticeType)"
  77. >{{item.projectName}}</span>
  78. </p>
  79. <p>{{item.content}}</p>
  80. </div>
  81. </el-tab-pane>
  82. </el-tabs>
  83. <!-- 查看全部的按钮 -->
  84. <router-link :to="'/message'" tag="div" class="popover-button">查看全部</router-link>
  85. </el-popover>
  86. </el-badge>
  87. <el-dropdown trigger="hover">
  88. <span class="el-dropdown-link userinfo-inner">
  89. <img src="../assets/image/userHead.jpg" />
  90. {{sysUserName}}
  91. </span>
  92. <el-dropdown-menu slot="dropdown">
  93. <el-dropdown-item @click.native="reset">修改密码</el-dropdown-item>
  94. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  95. </el-dropdown-menu>
  96. </el-dropdown>
  97. </el-col>
  98. </el-col>
  99. <el-col :span="24" class="main">
  100. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  101. <!--导航菜单-->
  102. <el-menu
  103. :default-active="$route.path"
  104. class="el-menu-vertical-demo"
  105. @open="handleopen"
  106. @close="handleclose"
  107. @select="handleselect"
  108. unique-opened
  109. router
  110. v-if="!collapsed"
  111. >
  112. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  113. <el-submenu :index="index+''" v-if="!item.leaf">
  114. <template slot="title">
  115. <i :class="item.iconCls"></i>
  116. <span class="itemName">{{item.name}}</span>
  117. </template>
  118. <el-menu-item
  119. v-for="child in item.children"
  120. :index="child.path"
  121. :key="child.path"
  122. v-if="!child.hidden"
  123. >{{child.name}}</el-menu-item>
  124. </el-submenu>
  125. <el-menu-item
  126. v-if="item.leaf && item.children.length > 0"
  127. :index="item.children[0].path"
  128. >
  129. <i :class="item.iconCls"></i>
  130. {{item.children[0].name}}
  131. </el-menu-item>
  132. </template>
  133. </el-menu>
  134. <!--导航菜单-折叠后-->
  135. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  136. <li
  137. v-for="(item,index) in $router.options.routes"
  138. v-if="!item.hidden"
  139. class="el-submenu item"
  140. :style="{overflow:!item.leaf?'':'hidden'}"
  141. >
  142. <template v-if="!item.leaf">
  143. <div
  144. class="el-submenu__title"
  145. style="padding-left: 20px;"
  146. @mouseover="showMenu(index,true)"
  147. @mouseout="showMenu(index,false)"
  148. >
  149. <i :class="item.iconCls"></i>
  150. </div>
  151. <ul
  152. class="el-menu submenu"
  153. :class="'submenu-hook-'+index"
  154. @mouseover="showMenu(index,true)"
  155. @mouseout="showMenu(index,false)"
  156. >
  157. <li
  158. v-for="child in item.children"
  159. v-if="!child.hidden"
  160. :key="child.path"
  161. class="el-menu-item"
  162. style="padding-left: 40px;"
  163. :class="$route.path==child.path?'is-active':''"
  164. @click="$router.push(child.path)"
  165. >{{child.name}}</li>
  166. </ul>
  167. </template>
  168. <template v-else>
  169. <li class="el-submenu">
  170. <div
  171. class="el-submenu__title el-menu-item"
  172. style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;"
  173. :class="$route.path==item.children[0].path?'is-active':''"
  174. @click="$router.push(item.children[0].path)"
  175. >
  176. <i :class="item.iconCls"></i>
  177. </div>
  178. </li>
  179. </template>
  180. </li>
  181. </ul>
  182. </aside>
  183. <section class="content-container">
  184. <div class="grid-content bg-purple-light">
  185. <el-col :span="24" class="content-wrapper">
  186. <transition name="fade" mode="out-in">
  187. <router-view></router-view>
  188. </transition>
  189. </el-col>
  190. </div>
  191. <!--修改密码-->
  192. <el-dialog
  193. title="修改密码"
  194. v-if="editPassWord"
  195. :visible.sync="editPassWord"
  196. :close-on-click-modal="false"
  197. customClass="customWidth"
  198. >
  199. <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
  200. <el-form-item label="新密码" prop="password">
  201. <el-input
  202. v-model="addForm.password"
  203. autocomplete="off"
  204. placeholder="请输入新密码"
  205. show-password
  206. ></el-input>
  207. </el-form-item>
  208. </el-form>
  209. <div slot="footer" class="dialog-footer">
  210. <el-button @click.native="editPassWord = false">取消</el-button>
  211. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
  212. </div>
  213. </el-dialog>
  214. </section>
  215. </el-col>
  216. </el-row>
  217. </template>
  218. <script>
  219. export default {
  220. data() {
  221. return {
  222. user: sessionStorage.getItem("user"),
  223. sysName: "云塑网后台管理系统",
  224. collapsed: false,
  225. sysUserName: "",
  226. editPassWord: false,
  227. editLoading: false,
  228. addForm: {
  229. password: ""
  230. },
  231. passRule: {
  232. password: [{ required: true, message: "请输入新密码", trigger: "blur" }]
  233. },
  234. //消息数据
  235. popoverData: [],
  236. tips: false,
  237. activePage: 0,
  238. messageCount: [0, 0, 0, 0]
  239. };
  240. },
  241. methods: {
  242. onSubmit() {},
  243. handleopen() {},
  244. handleclose() {},
  245. handleselect: function(a, b) {},
  246. //退出登录
  247. logout: function() {
  248. var _this = this;
  249. this.$confirm("确认退出吗?", "提示", {
  250. //type: 'warning'
  251. }).then(() => {
  252. sessionStorage.removeItem("user");
  253. _this.$router.push("/login");
  254. });
  255. },
  256. //折叠导航栏
  257. collapse: function() {
  258. this.collapsed = !this.collapsed;
  259. },
  260. showMenu(i, status) {
  261. this.$refs.menuCollapsed.getElementsByClassName(
  262. "submenu-hook-" + i
  263. )[0].style.display = status ? "block" : "none";
  264. },
  265. reset() {
  266. this.editPassWord = true;
  267. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  268. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  269. },
  270. resetPwd() {
  271. this.$refs.addForm.validate(valid => {
  272. if (valid) {
  273. this.editLoading = true;
  274. this.http.post(
  275. this.port.pwd.resetPwd,
  276. this.addForm,
  277. res => {
  278. this.editLoading = false;
  279. this.editPassWord = false;
  280. if (res.code == "ok") {
  281. this.$message({
  282. message: "修改成功,请重新登录",
  283. type: "success"
  284. });
  285. this.$router.push("/login");
  286. } else {
  287. this.$message({
  288. message: res.msg,
  289. type: "error"
  290. });
  291. }
  292. },
  293. error => {
  294. this.editLoading = false;
  295. this.editPassWord = false;
  296. this.$message({
  297. message: error,
  298. type: "error"
  299. });
  300. }
  301. );
  302. }
  303. });
  304. },
  305. //读取消息提示
  306. loadNotice() {
  307. this.http.post(
  308. this.port.notice.list,
  309. {
  310. pageNum: 1,
  311. pageSize: 5
  312. },
  313. res => {
  314. if (res.code == "ok") {
  315. this.popoverData = res.data.list.list;
  316. this.tips = res.data.isRedPoint;
  317. } else {
  318. this.$message({
  319. message: res.msg,
  320. type: "error"
  321. });
  322. }
  323. },
  324. error => {
  325. this.$message({
  326. message: error,
  327. type: "error"
  328. });
  329. }
  330. );
  331. },
  332. //点击消息的跳转
  333. locationHerf(id, type) {
  334. this.http.post(
  335. this.port.notice.read,
  336. {
  337. id: id
  338. },
  339. res => {
  340. if (res.code == "ok") {
  341. } else {
  342. this.$message({
  343. message: res.msg,
  344. type: "error"
  345. });
  346. }
  347. },
  348. error => {
  349. this.$message({
  350. message: error,
  351. type: "error"
  352. });
  353. }
  354. );
  355. if (type == 0) {
  356. //审批 跳转到模具详情
  357. this.$router.push("/moldList/" + id);
  358. } else if (type == 1) {
  359. //警告 跳转到运行监测
  360. this.$router.push("/detection");
  361. } else if (type == 2) {
  362. //保养 跳转到运行监测详情
  363. this.$router.push("/detection/" + id);
  364. }
  365. },
  366. //检查是否要进行报废提示
  367. checkDiscardNotice() {
  368. this.http.post(
  369. this.port.mold.moldDiscardListGet,
  370. {},
  371. res => {
  372. if (res.code == "ok") {
  373. //说明有东西需要保养
  374. if (res.data.length > 0) {
  375. this.notify("报废");
  376. }
  377. } else {
  378. this.$message({
  379. message: res.msg,
  380. type: "error"
  381. });
  382. }
  383. },
  384. error => {
  385. this.editLoading = false;
  386. this.$message({
  387. message: error,
  388. type: "error"
  389. });
  390. }
  391. );
  392. },
  393. //检查是否要进行保养提示
  394. checkMaintainNotice() {
  395. this.http.post(
  396. this.port.mold.moldMaintainListGet,
  397. {},
  398. res => {
  399. if (res.code == "ok") {
  400. //说明有东西需要保养
  401. if (res.data.length > 0) {
  402. this.notify("保养");
  403. }
  404. } else {
  405. this.$message({
  406. message: res.msg,
  407. type: "error"
  408. });
  409. }
  410. },
  411. error => {
  412. this.editLoading = false;
  413. this.$message({
  414. message: error,
  415. type: "error"
  416. });
  417. }
  418. );
  419. },
  420. //右上角弹窗警告
  421. notify(action) {
  422. this.$notify({
  423. title: "有模具需要" + action,
  424. message: "请到消息列表中查看",
  425. type: "warning",
  426. duration: 0
  427. });
  428. },
  429. //标签页面切换时
  430. handleClick(tab, event) {
  431. this.activeTab = tab.name;
  432. // this.getOperationRecord(this.activeTab);//应该是取得对应的消息
  433. }
  434. },
  435. mounted() {
  436. //告警 保养的烦人弹窗警告 先不弹出了
  437. // this.checkMaintainNotice();
  438. // this.checkDiscardNotice();
  439. if (this.user) {
  440. var user = JSON.parse(this.user);
  441. this.user = user;
  442. this.sysUserName = user.username || "";
  443. this.loadNotice();
  444. } else {
  445. this.$router.push("/login");
  446. }
  447. }
  448. };
  449. </script>
  450. <style scoped lang="scss">
  451. @import "~scss_vars";
  452. .el-menu-vertical-demo i {
  453. margin-right: 10px;
  454. }
  455. .container .header .logo img.headImg {
  456. margin: 0;
  457. width: 40px;
  458. height: 40px;
  459. margin: 10px 0 0 10px;
  460. }
  461. .itemNew {
  462. height: 25px;
  463. margin-right: 25px;
  464. i {
  465. vertical-align: top;
  466. }
  467. }
  468. .container {
  469. position: absolute;
  470. top: 0px;
  471. bottom: 0px;
  472. width: 100%;
  473. .header {
  474. height: 60px;
  475. line-height: 60px;
  476. background: $color-primary;
  477. color: #fff;
  478. .userinfo {
  479. text-align: right;
  480. padding-right: 35px;
  481. float: right;
  482. .userinfo-inner {
  483. cursor: pointer;
  484. color: #fff;
  485. img {
  486. width: 40px;
  487. height: 40px;
  488. border-radius: 20px;
  489. margin: 10px 10px 10px 10px;
  490. // float: right;
  491. float: left;
  492. }
  493. }
  494. }
  495. .logo {
  496. //width:230px;
  497. height: 60px;
  498. font-size: 21px;
  499. padding-left: 20px;
  500. padding-right: 20px;
  501. border-color: rgba(238, 241, 146, 0.3);
  502. border-right-width: 1px;
  503. border-right-style: solid;
  504. img {
  505. width: 40px;
  506. float: left;
  507. margin: 10px 10px 10px 18px;
  508. }
  509. .txt {
  510. color: #fff;
  511. }
  512. }
  513. .logo-width {
  514. width: 230px;
  515. }
  516. .logo-collapse-width {
  517. width: 60px;
  518. }
  519. .tools {
  520. padding: 0px 23px;
  521. width: 14px;
  522. height: 60px;
  523. line-height: 60px;
  524. cursor: pointer;
  525. }
  526. }
  527. .main {
  528. display: flex;
  529. // background: #324057;
  530. position: absolute;
  531. top: 60px;
  532. bottom: 0px;
  533. overflow: hidden;
  534. aside {
  535. flex: 0 0 230px;
  536. width: 230px;
  537. // position: absolute;
  538. // top: 0px;
  539. // bottom: 0px;
  540. .el-menu {
  541. height: 100%;
  542. }
  543. .collapsed {
  544. width: 60px;
  545. .item {
  546. position: relative;
  547. }
  548. .submenu {
  549. position: absolute;
  550. top: 0px;
  551. left: 60px;
  552. z-index: 99999;
  553. height: auto;
  554. display: none;
  555. }
  556. }
  557. }
  558. .menu-collapsed {
  559. flex: 0 0 60px;
  560. width: 60px;
  561. }
  562. .menu-expanded {
  563. flex: 0 0 230px;
  564. width: 230px;
  565. }
  566. .content-container {
  567. // background: #f8f8f8;
  568. //f1f2f7
  569. flex: 1;
  570. width: 80%;
  571. // position: absolute;
  572. // right: 0px;
  573. // top: 0px;
  574. // bottom: 0px;
  575. // left: 230px;
  576. // overflow-y: scroll;
  577. padding: 20px;
  578. .breadcrumb-container {
  579. //margin-bottom: 15px;
  580. .title {
  581. width: 200px;
  582. float: left;
  583. color: #475669;
  584. }
  585. .breadcrumb-inner {
  586. float: right;
  587. }
  588. }
  589. .content-wrapper {
  590. background-color: #fff;
  591. box-sizing: border-box;
  592. }
  593. }
  594. }
  595. }
  596. .popover-item {
  597. padding: 10px;
  598. border-bottom: 1px #eee solid;
  599. }
  600. .popover-item > p {
  601. margin: 0;
  602. line-height: 18px;
  603. }
  604. .popover-title {
  605. color: #409eff;
  606. padding-bottom: 8px;
  607. }
  608. .popover-type {
  609. color: #aaa;
  610. font-size: 8px;
  611. float: right;
  612. }
  613. .popover-button {
  614. font-weight: 900;
  615. padding: 10px;
  616. text-align: center;
  617. cursor: pointer;
  618. }
  619. </style>