Home.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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'" :style="collapsed?'padding:0':''">
  5. <img v-if="collapsed" class="headImg" src="../assets/image/head_logo.png" />
  6. <div v-else class="logo-sys">
  7. <img class="headImg" src="../assets/image/head_logo.png" />
  8. <span>{{sysName}}</span>
  9. </div>
  10. </el-col>
  11. <el-col :span="4">
  12. <div class="tools" @click.prevent="collapse" style="position: relative;">
  13. <i class="fa fa-align-justify"></i>
  14. <span style="position: absolute;width: 200px;left: 60px;">{{user.companyName}}</span>
  15. </div>
  16. </el-col>
  17. <el-col :span="10" class="userinfo">
  18. <el-dropdown trigger="hover" style="margin-right:30px;">
  19. <span class="el-dropdown-link userinfo-inner">
  20. <i class="el-icon-user" style="font-size:18px" ></i>
  21. 咨询客服
  22. </span>
  23. <el-dropdown-menu slot="dropdown">
  24. <el-dropdown-item >
  25. <div>
  26. <div>微信扫码</div>
  27. <img
  28. style="width: 120px; height: 120px"
  29. src="../assets/image/code.jpg" />
  30. </div>
  31. </el-dropdown-item>
  32. </el-dropdown-menu>
  33. </el-dropdown>
  34. 到期日期:{{remainingTime}}
  35. <el-badge class="itemNew" :value="num" :hidden="num == 0">
  36. <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1 @click="drawer = true"></i>
  37. </el-badge>
  38. <el-drawer title="消息中心" :visible.sync="drawer" direction="rtl" :with-header="false" size="30%">
  39. <el-table :data="popoverData" :height="tableHeight">
  40. <el-table-column property="type" label="消息中心" align="center">
  41. <template slot-scope="scope">
  42. <el-link type="primary" :underline="false" @click="locationHerf(scope.row.id,scope.row.content)">
  43. {{scope.row.type==0?"审批未通过":"审批通过"}}
  44. </el-link>
  45. </template>
  46. </el-table-column>
  47. <el-table-column property="type" label="状态" align="center">
  48. <template slot-scope="scope">
  49. <span v-if="scope.row.checked == 0" style="color:red">未读</span>
  50. <span v-else style="color:green">已读</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column property="content" label="时间" align="center"></el-table-column>
  54. </el-table>
  55. </el-drawer>
  56. <el-dropdown trigger="hover" style="margin-left:10px;">
  57. <span class="el-dropdown-link userinfo-inner">
  58. <img src="../assets/image/userHead.png" />
  59. {{sysUserName}}
  60. </span>
  61. <el-dropdown-menu slot="dropdown">
  62. <el-dropdown-item @click.native="reset">修改密码</el-dropdown-item>
  63. <!-- <el-dropdown-item @click.native="editInfoOpen">修改信息</el-dropdown-item> -->
  64. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  65. </el-dropdown-menu>
  66. </el-dropdown>
  67. </el-col>
  68. </el-col>
  69. <el-col :span="24" class="main">
  70. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  71. <!--导航菜单-->
  72. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" unique-opened router v-if="!collapsed">
  73. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  74. <el-submenu :index="index+''" v-if="!item.leaf">
  75. <template slot="title">
  76. <i :class="item.iconCls"></i>
  77. <span class="itemName">{{item.name}}</span>
  78. </template>
  79. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">{{child.name}}</el-menu-item>
  80. </el-submenu>
  81. <el-menu-item v-if="item.leaf && item.children.length > 0" :index="item.children[0].path">
  82. <i :class="item.iconCls"></i> {{item.children[0].name}}
  83. </el-menu-item>
  84. </template>
  85. </el-menu>
  86. <!--导航菜单-折叠后-->
  87. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  88. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  89. <template v-if="!item.leaf">
  90. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  91. <i :class="item.iconCls"></i>
  92. </div>
  93. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  94. <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>
  95. </ul>
  96. </template>
  97. <template v-else>
  98. <li class="el-submenu">
  99. <div class="el-submenu__title el-menu-item" :class="$route.path==item.children[0].path?'is-active':''" @click="$router.push(item.children[0].path)"
  100. style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;">
  101. <i :class="item.iconCls"></i>
  102. </div>
  103. </li>
  104. </template>
  105. </li>
  106. </ul>
  107. </aside>
  108. <section class="content-container">
  109. <div class="grid-content bg-purple-light">
  110. <el-col :span="24" class="content-wrapper">
  111. <transition name="fade" mode="out-in">
  112. <router-view></router-view>
  113. </transition>
  114. </el-col>
  115. </div>
  116. <!--修改密码-->
  117. <el-dialog title="修改密码" width='450px' v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
  118. <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
  119. <el-form-item label="原密码" prop="originPassword">
  120. <el-input v-model="addForm.originPassword" autocomplete="off" placeholder="请输入原密码" show-password></el-input>
  121. </el-form-item>
  122. <el-form-item label="新密码" prop="newPassword">
  123. <el-input v-model="addForm.newPassword" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
  124. </el-form-item>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button @click.native="editPassWord = false">取消</el-button>
  128. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
  129. </div>
  130. </el-dialog>
  131. <!--修改信息-->
  132. <el-dialog title="修改信息" width='450px' v-if="editInformation" :visible.sync="editInformation" :close-on-click-modal="false" customClass="customWidth">
  133. <el-form :model="editInfoForm" label-width="80px" :rules="passRule" ref="editInfoForm">
  134. <el-form-item label="姓名" prop="username">
  135. <el-input v-model="editInfoForm.username" autocomplete="off" placeholder="请输入姓名"></el-input>
  136. </el-form-item>
  137. </el-form>
  138. <el-form :model="editInfoForm" label-width="80px" :rules="passRule" ref="editInfoForm">
  139. <el-form-item label="手机号" prop="mobile">
  140. <el-input v-model="editInfoForm.mobile" autocomplete="off" placeholder="请输入手机号" :disabled="true"></el-input>
  141. </el-form-item>
  142. </el-form>
  143. <div slot="footer" class="dialog-footer">
  144. <el-button @click.native="editInformation = false">取消</el-button>
  145. <el-button type="primary" @click.native="editInfo" :loading="editLoading2">提交</el-button>
  146. </div>
  147. </el-dialog>
  148. </section>
  149. </el-col>
  150. </el-row>
  151. </template>
  152. <script>
  153. import util from "../common/js/util";
  154. export default {
  155. data() {
  156. return {
  157. helpImg: '../assets/image/userHead.png',
  158. user: sessionStorage.getItem("user"),
  159. sysName: "工时管家",
  160. collapsed: sessionStorage.collapsed!=null?(sessionStorage.collapsed=='true'?true:false):false,
  161. sysUserName: "",
  162. menu: [],
  163. editInformation: false,
  164. editPassWord: false,
  165. editLoading: false,
  166. editLoading2: false,
  167. addForm: {
  168. id: "",
  169. originPassword: "",
  170. newPassword: ""
  171. },
  172. editInfoForm: {
  173. id: "",
  174. username: "",
  175. mobile: "",
  176. companyName: ""
  177. },
  178. passRule: {
  179. originPassword: [{ required: true, message: "请输入原密码", trigger: "blur" }],
  180. newPassword: [{ required: true, message: "请输入新密码", trigger: "blur" }],
  181. username: [{ required: true, message: "请输入姓名", trigger: "blur" }]
  182. },
  183. //时间
  184. activeDate: new Date(),
  185. timer: null,
  186. remainingTime: '',
  187. drawer: false,
  188. tableHeight: 0,
  189. popoverData: [],
  190. num: 0,
  191. };
  192. },
  193. methods: {
  194. //退出登录
  195. logout: function() {
  196. var _this = this;
  197. this.$confirm("确认退出吗?", "提示", {
  198. //type: 'warning'
  199. }).then(() => {
  200. sessionStorage.removeItem("user");
  201. location.reload();
  202. _this.$router.push("/login");
  203. });
  204. },
  205. //折叠导航栏
  206. collapse: function() {
  207. this.collapsed = !this.collapsed;
  208. sessionStorage.collapsed = this.collapsed;
  209. },
  210. showMenu(i, status) {
  211. this.$refs.menuCollapsed.getElementsByClassName(
  212. "submenu-hook-" + i
  213. )[0].style.display = status ? "block" : "none";
  214. },
  215. //打开编辑信息界面
  216. editInfoOpen() {
  217. this.editInformation = true;
  218. this.editInfoForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  219. this.editInfoForm.username = JSON.parse(
  220. sessionStorage.getItem("user")
  221. ).username;
  222. this.editInfoForm.mobile = JSON.parse(
  223. sessionStorage.getItem("user")
  224. ).account;
  225. this.editInfoForm.companyName = JSON.parse(
  226. sessionStorage.getItem("user")
  227. ).companyName;
  228. },
  229. //编辑信息
  230. editInfo() {
  231. this.$refs.editInfoForm.validate(valid => {
  232. if (valid) {
  233. this.editLoading2 = true;
  234. this.http.post(
  235. this.port.pwd.resetPwd,
  236. { id: this.editInfoForm.id, username: this.editInfoForm.username },
  237. res => {
  238. this.editLoading2 = false;
  239. this.editInformation = false;
  240. if (res.code == "ok") {
  241. this.$message({
  242. message: "修改成功",
  243. type: "success"
  244. });
  245. //读取并覆盖session storage
  246. var userObject = JSON.parse(sessionStorage.getItem("user"));
  247. userObject.username = this.editInfoForm.username;
  248. sessionStorage.setItem("user", JSON.stringify(userObject));
  249. this.sysUserName = this.editInfoForm.username;
  250. } else {
  251. this.$message({
  252. message: res.msg,
  253. type: "error"
  254. });
  255. }
  256. },
  257. error => {
  258. this.editLoading2 = false;
  259. this.editInformation = false;
  260. this.$message({
  261. message: error,
  262. type: "error"
  263. });
  264. }
  265. );
  266. }
  267. });
  268. },
  269. reset() {
  270. this.editPassWord = true;
  271. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  272. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  273. },
  274. resetPwd() {
  275. this.$refs.addForm.validate(valid => {
  276. if (valid) {
  277. this.editLoading = true;
  278. this.http.post( this.port.manage.editPassword, this.addForm,
  279. res => {
  280. this.editLoading = false;
  281. this.editPassWord = false;
  282. if (res.code == "ok") {
  283. this.$message({
  284. message: "修改成功,请重新登录",
  285. type: "success"
  286. });
  287. this.$router.push("/login");
  288. } else {
  289. this.$message({
  290. message: res.msg,
  291. type: "error"
  292. });
  293. }
  294. },
  295. error => {
  296. this.editLoading = false;
  297. this.editPassWord = false;
  298. this.$message({
  299. message: error,
  300. type: "error"
  301. });
  302. });
  303. }
  304. });
  305. },
  306. setTime() {
  307. var d = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'd');
  308. var h = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'h');
  309. var m = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'm');
  310. var s = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 's');
  311. this.remainingTime = d+'天'+h+'时'+m+'分'+s+'秒';
  312. },
  313. // 加载消息
  314. loadNotice() {
  315. this.http.post( this.port.manage.msgList, {},
  316. res => {
  317. if (res.code == "ok") {
  318. var list = res.data;
  319. this.popoverData = res.data;
  320. var num = 0;
  321. for(var i in list) {
  322. if(list[i].checked != 1) {
  323. num ++;
  324. }
  325. }
  326. this.num = num;
  327. } else {
  328. this.$message({
  329. message: res.msg,
  330. type: "error"
  331. });
  332. }
  333. },
  334. error => {
  335. this.$message({
  336. message: error,
  337. type: "error"
  338. });
  339. });
  340. },
  341. //点击消息的跳转
  342. locationHerf(id, date) {
  343. this.http.post( this.port.manage.check, { id: id },
  344. res => {
  345. if (res.code == "ok") {
  346. this.loadNotice();
  347. sessionStorage.msg = date;
  348. sessionStorage.from = 1;
  349. //本页面再点的话强制转移一下
  350. var currentRoute = this.$route.path.split("/");
  351. if (currentRoute[1] == "daily") {
  352. this.$router.go(0);
  353. return false;
  354. }
  355. this.$router.push("/daily");
  356. this.drawer = true;
  357. } else {
  358. this.$message({
  359. message: res.msg,
  360. type: "error"
  361. });
  362. }
  363. },
  364. error => {
  365. this.$message({
  366. message: error,
  367. type: "error"
  368. });
  369. });
  370. },
  371. },
  372. mounted() {
  373. let height = window.innerHeight;
  374. this.tableHeight = height - 15;
  375. const that = this;
  376. window.onresize = function temp() {
  377. that.tableHeight = window.innerHeight - 15;
  378. };
  379. if (this.user) {
  380. var user = JSON.parse(this.user);
  381. this.user = user;
  382. this.sysUserName = user.name || "";
  383. this.loadNotice();
  384. if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
  385. this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
  386. } else {
  387. this.remainingTime = "已过期";
  388. clearInterval(this.timer);
  389. }
  390. } else {
  391. this.$router.push("/login");
  392. }
  393. },
  394. };
  395. </script>
  396. <style scoped lang="scss">
  397. .el-menu-vertical-demo i {
  398. margin-right: 10px;
  399. }
  400. .container {
  401. position: absolute;
  402. top: 0px;
  403. bottom: 0px;
  404. width: 100%;
  405. .header {
  406. height: 60px;
  407. line-height: 60px;
  408. background: #20a0ff;
  409. color: #fff;
  410. .userinfo {
  411. text-align: right;
  412. padding-right: 35px;
  413. float: right;
  414. .userinfo-inner {
  415. cursor: pointer;
  416. color: #fff;
  417. img {
  418. width: 40px;
  419. height: 40px;
  420. border-radius: 20px;
  421. margin: 10px 10px 10px 10px;
  422. float: left;
  423. }
  424. }
  425. .itemNew {
  426. height: 25px;
  427. margin: 0 0 0 10px;
  428. i {
  429. vertical-align: top;
  430. }
  431. }
  432. }
  433. .logo {
  434. height: 60px;
  435. font-size: 21px;
  436. padding-left: 20px;
  437. padding-right: 20px;
  438. border-color: rgba(238, 241, 146, 0.3);
  439. border-right-width: 1px;
  440. border-right-style: solid;
  441. img {
  442. width: 40px;
  443. float: left;
  444. margin: 10px 10px 10px 18px;
  445. }
  446. img.headImg {
  447. margin: 0;
  448. width: 40px;
  449. height: 40px;
  450. margin: 10px 0 0 10px;
  451. }
  452. .logo-sys {
  453. height: 100%;
  454. line-height: 100%;
  455. img.headImg {
  456. width: 40px;
  457. height: 40px;
  458. margin: 10px 0 0 10px;
  459. vertical-align: middle;
  460. }
  461. span {
  462. display: inline-block;
  463. height: 100%;
  464. line-height: 100%;
  465. margin-left: 15px;
  466. margin: 20px 0 0 15px;
  467. vertical-align: middle;
  468. }
  469. }
  470. .txt {
  471. color: #fff;
  472. }
  473. }
  474. .logo-width {
  475. width: 230px;
  476. }
  477. .logo-collapse-width {
  478. width: 60px;
  479. }
  480. .tools {
  481. padding: 0px 23px;
  482. width: 14px;
  483. height: 60px;
  484. line-height: 60px;
  485. cursor: pointer;
  486. }
  487. }
  488. .main {
  489. display: flex;
  490. position: absolute;
  491. top: 60px;
  492. bottom: 0px;
  493. overflow: hidden;
  494. aside {
  495. flex: 0 0 230px;
  496. width: 230px;
  497. .el-menu {
  498. height: 100%;
  499. }
  500. .collapsed {
  501. width: 60px;
  502. .item {
  503. position: relative;
  504. }
  505. .submenu {
  506. position: absolute;
  507. top: 0px;
  508. left: 60px;
  509. z-index: 99999;
  510. height: auto;
  511. display: none;
  512. box-shadow: 5px 5px 10px #ddd;
  513. }
  514. }
  515. }
  516. .menu-collapsed {
  517. flex: 0 0 60px;
  518. width: 60px;
  519. }
  520. .menu-expanded {
  521. flex: 0 0 230px;
  522. width: 230px;
  523. }
  524. .content-container {
  525. flex: 1;
  526. width: 80%;
  527. overflow-y: auto;
  528. .breadcrumb-container {
  529. .title {
  530. width: 200px;
  531. float: left;
  532. color: #475669;
  533. }
  534. .breadcrumb-inner {
  535. float: right;
  536. }
  537. }
  538. .content-wrapper {
  539. background-color: #fff;
  540. box-sizing: border-box;
  541. }
  542. }
  543. }
  544. }
  545. .popover-item {
  546. padding: 10px;
  547. border-bottom: 1px #eee solid;
  548. }
  549. .popover-item > div > p {
  550. margin: 0;
  551. line-height: 18px;
  552. }
  553. .popover-title {
  554. color: #409eff;
  555. padding-bottom: 8px;
  556. }
  557. .popover-type {
  558. color: #aaa;
  559. font-size: 8px;
  560. float: right;
  561. }
  562. .popover-button {
  563. font-weight: 900;
  564. padding: 10px;
  565. text-align: center;
  566. cursor: pointer;
  567. }
  568. .isRead {
  569. color: #999 !important;
  570. }
  571. </style>