Home.vue 21 KB

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