Home.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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, scope.row.type)">
  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, type) {
  343. this.http.post( this.port.manage.check, { id: id },
  344. res => {
  345. if (res.code == "ok") {
  346. this.loadNotice();
  347. if (type == 0) {
  348. //审批未通过的消息
  349. sessionStorage.msg = date;
  350. sessionStorage.from = 1;
  351. //本页面再点的话强制转移一下
  352. var currentRoute = this.$route.path.split("/");
  353. if (currentRoute[1] == "daily") {
  354. this.$router.go(0);
  355. return false;
  356. }
  357. this.$router.push("/daily");
  358. this.drawer = true;
  359. } else{
  360. //1- 有新任务待执行
  361. this.$router.push("/projectInside/"+date);
  362. this.drawer = false;
  363. }
  364. } else {
  365. this.$message({
  366. message: res.msg,
  367. type: "error"
  368. });
  369. }
  370. },
  371. error => {
  372. this.$message({
  373. message: error,
  374. type: "error"
  375. });
  376. });
  377. },
  378. },
  379. mounted() {
  380. let height = window.innerHeight;
  381. this.tableHeight = height - 15;
  382. const that = this;
  383. window.onresize = function temp() {
  384. that.tableHeight = window.innerHeight - 15;
  385. };
  386. if (this.user) {
  387. var user = JSON.parse(this.user);
  388. this.user = user;
  389. this.sysUserName = user.name || "";
  390. this.loadNotice();
  391. if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
  392. this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
  393. } else {
  394. this.remainingTime = "已过期";
  395. clearInterval(this.timer);
  396. }
  397. } else {
  398. this.$router.push("/login");
  399. }
  400. },
  401. };
  402. </script>
  403. <style scoped lang="scss">
  404. .el-menu-vertical-demo i {
  405. margin-right: 10px;
  406. }
  407. .container {
  408. position: absolute;
  409. top: 0px;
  410. bottom: 0px;
  411. width: 100%;
  412. .header {
  413. height: 60px;
  414. line-height: 60px;
  415. background: #20a0ff;
  416. color: #fff;
  417. .userinfo {
  418. text-align: right;
  419. padding-right: 35px;
  420. float: right;
  421. .userinfo-inner {
  422. cursor: pointer;
  423. color: #fff;
  424. img {
  425. width: 40px;
  426. height: 40px;
  427. border-radius: 20px;
  428. margin: 10px 10px 10px 10px;
  429. float: left;
  430. }
  431. }
  432. .itemNew {
  433. height: 25px;
  434. margin: 0 0 0 10px;
  435. i {
  436. vertical-align: top;
  437. }
  438. }
  439. }
  440. .logo {
  441. height: 60px;
  442. font-size: 21px;
  443. padding-left: 20px;
  444. padding-right: 20px;
  445. border-color: rgba(238, 241, 146, 0.3);
  446. border-right-width: 1px;
  447. border-right-style: solid;
  448. img {
  449. width: 40px;
  450. float: left;
  451. margin: 10px 10px 10px 18px;
  452. }
  453. img.headImg {
  454. margin: 0;
  455. width: 40px;
  456. height: 40px;
  457. margin: 10px 0 0 10px;
  458. }
  459. .logo-sys {
  460. height: 100%;
  461. line-height: 100%;
  462. img.headImg {
  463. width: 40px;
  464. height: 40px;
  465. margin: 10px 0 0 10px;
  466. vertical-align: middle;
  467. }
  468. span {
  469. display: inline-block;
  470. height: 100%;
  471. line-height: 100%;
  472. margin-left: 15px;
  473. margin: 20px 0 0 15px;
  474. vertical-align: middle;
  475. }
  476. }
  477. .txt {
  478. color: #fff;
  479. }
  480. }
  481. .logo-width {
  482. width: 230px;
  483. }
  484. .logo-collapse-width {
  485. width: 60px;
  486. }
  487. .tools {
  488. padding: 0px 23px;
  489. width: 14px;
  490. height: 60px;
  491. line-height: 60px;
  492. cursor: pointer;
  493. }
  494. }
  495. .main {
  496. display: flex;
  497. position: absolute;
  498. top: 60px;
  499. bottom: 0px;
  500. overflow: hidden;
  501. aside {
  502. flex: 0 0 230px;
  503. width: 230px;
  504. .el-menu {
  505. height: 100%;
  506. }
  507. .collapsed {
  508. width: 60px;
  509. .item {
  510. position: relative;
  511. }
  512. .submenu {
  513. position: absolute;
  514. top: 0px;
  515. left: 60px;
  516. z-index: 99999;
  517. height: auto;
  518. display: none;
  519. box-shadow: 5px 5px 10px #ddd;
  520. }
  521. }
  522. }
  523. .menu-collapsed {
  524. flex: 0 0 60px;
  525. width: 60px;
  526. }
  527. .menu-expanded {
  528. flex: 0 0 230px;
  529. width: 230px;
  530. }
  531. .content-container {
  532. flex: 1;
  533. width: 80%;
  534. overflow-y: auto;
  535. .breadcrumb-container {
  536. .title {
  537. width: 200px;
  538. float: left;
  539. color: #475669;
  540. }
  541. .breadcrumb-inner {
  542. float: right;
  543. }
  544. }
  545. .content-wrapper {
  546. background-color: #fff;
  547. box-sizing: border-box;
  548. }
  549. }
  550. }
  551. }
  552. .popover-item {
  553. padding: 10px;
  554. border-bottom: 1px #eee solid;
  555. }
  556. .popover-item > div > p {
  557. margin: 0;
  558. line-height: 18px;
  559. }
  560. .popover-title {
  561. color: #409eff;
  562. padding-bottom: 8px;
  563. }
  564. .popover-type {
  565. color: #aaa;
  566. font-size: 8px;
  567. float: right;
  568. }
  569. .popover-button {
  570. font-weight: 900;
  571. padding: 10px;
  572. text-align: center;
  573. cursor: pointer;
  574. }
  575. .isRead {
  576. color: #999 !important;
  577. }
  578. </style>