Home.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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. {{msgTypeTxt[scope.row.type]}}
  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="indate" 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. msgTypeTxt:["审批未通过","有新任务啦","任务有新进展"],
  164. editInformation: false,
  165. editPassWord: false,
  166. editLoading: false,
  167. editLoading2: false,
  168. addForm: {
  169. id: "",
  170. originPassword: "",
  171. newPassword: ""
  172. },
  173. editInfoForm: {
  174. id: "",
  175. username: "",
  176. mobile: "",
  177. companyName: ""
  178. },
  179. passRule: {
  180. originPassword: [{ required: true, message: "请输入原密码", trigger: "blur" }],
  181. newPassword: [{ required: true, message: "请输入新密码", trigger: "blur" }],
  182. username: [{ required: true, message: "请输入姓名", trigger: "blur" }]
  183. },
  184. //时间
  185. activeDate: new Date(),
  186. timer: null,
  187. remainingTime: '',
  188. drawer: false,
  189. tableHeight: 0,
  190. popoverData: [],
  191. num: 0,
  192. };
  193. },
  194. methods: {
  195. //退出登录
  196. logout: function() {
  197. var _this = this;
  198. this.$confirm("确认退出吗?", "提示", {
  199. //type: 'warning'
  200. }).then(() => {
  201. sessionStorage.removeItem("user");
  202. location.reload();
  203. _this.$router.push("/login");
  204. });
  205. },
  206. //折叠导航栏
  207. collapse: function() {
  208. this.collapsed = !this.collapsed;
  209. sessionStorage.collapsed = this.collapsed;
  210. },
  211. showMenu(i, status) {
  212. this.$refs.menuCollapsed.getElementsByClassName(
  213. "submenu-hook-" + i
  214. )[0].style.display = status ? "block" : "none";
  215. },
  216. //打开编辑信息界面
  217. editInfoOpen() {
  218. this.editInformation = true;
  219. this.editInfoForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  220. this.editInfoForm.username = JSON.parse(
  221. sessionStorage.getItem("user")
  222. ).username;
  223. this.editInfoForm.mobile = JSON.parse(
  224. sessionStorage.getItem("user")
  225. ).account;
  226. this.editInfoForm.companyName = JSON.parse(
  227. sessionStorage.getItem("user")
  228. ).companyName;
  229. },
  230. //编辑信息
  231. editInfo() {
  232. this.$refs.editInfoForm.validate(valid => {
  233. if (valid) {
  234. this.editLoading2 = true;
  235. this.http.post(
  236. this.port.pwd.resetPwd,
  237. { id: this.editInfoForm.id, username: this.editInfoForm.username },
  238. res => {
  239. this.editLoading2 = false;
  240. this.editInformation = false;
  241. if (res.code == "ok") {
  242. this.$message({
  243. message: "修改成功",
  244. type: "success"
  245. });
  246. //读取并覆盖session storage
  247. var userObject = JSON.parse(sessionStorage.getItem("user"));
  248. userObject.username = this.editInfoForm.username;
  249. sessionStorage.setItem("user", JSON.stringify(userObject));
  250. this.sysUserName = this.editInfoForm.username;
  251. } else {
  252. this.$message({
  253. message: res.msg,
  254. type: "error"
  255. });
  256. }
  257. },
  258. error => {
  259. this.editLoading2 = false;
  260. this.editInformation = false;
  261. this.$message({
  262. message: error,
  263. type: "error"
  264. });
  265. }
  266. );
  267. }
  268. });
  269. },
  270. reset() {
  271. this.editPassWord = true;
  272. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  273. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  274. },
  275. resetPwd() {
  276. this.$refs.addForm.validate(valid => {
  277. if (valid) {
  278. this.editLoading = true;
  279. this.http.post( this.port.manage.editPassword, this.addForm,
  280. res => {
  281. this.editLoading = false;
  282. this.editPassWord = false;
  283. if (res.code == "ok") {
  284. this.$message({
  285. message: "修改成功,请重新登录",
  286. type: "success"
  287. });
  288. this.$router.push("/login");
  289. } else {
  290. this.$message({
  291. message: res.msg,
  292. type: "error"
  293. });
  294. }
  295. },
  296. error => {
  297. this.editLoading = false;
  298. this.editPassWord = false;
  299. this.$message({
  300. message: error,
  301. type: "error"
  302. });
  303. });
  304. }
  305. });
  306. },
  307. setTime() {
  308. var d = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'd');
  309. var h = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'h');
  310. var m = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'm');
  311. var s = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 's');
  312. this.remainingTime = d+'天'+h+'时'+m+'分'+s+'秒';
  313. },
  314. // 加载消息
  315. loadNotice() {
  316. this.http.post( this.port.manage.msgList, {},
  317. res => {
  318. if (res.code == "ok") {
  319. var list = res.data;
  320. this.popoverData = res.data;
  321. var num = 0;
  322. for(var i in list) {
  323. if(list[i].checked != 1) {
  324. num ++;
  325. }
  326. }
  327. this.num = num;
  328. } else {
  329. this.$message({
  330. message: res.msg,
  331. type: "error"
  332. });
  333. }
  334. },
  335. error => {
  336. this.$message({
  337. message: error,
  338. type: "error"
  339. });
  340. });
  341. },
  342. //点击消息的跳转
  343. locationHerf(id, date, type) {
  344. this.http.post( this.port.manage.check, { id: id },
  345. res => {
  346. if (res.code == "ok") {
  347. this.loadNotice();
  348. if (type == 0) {
  349. //审批未通过的消息
  350. sessionStorage.msg = date;
  351. sessionStorage.from = 1;
  352. //本页面再点的话强制转移一下
  353. var currentRoute = this.$route.path.split("/");
  354. if (currentRoute[1] == "daily") {
  355. this.$router.go(0);
  356. return false;
  357. }
  358. this.$router.push("/daily");
  359. this.drawer = true;
  360. } else if (type == 1) {
  361. //1- 有新任务待执行
  362. this.$router.push("/projectInside/"+date);
  363. this.drawer = false;
  364. } else if (type == 2) {
  365. //2- 任务有新进展
  366. this.$router.push("/projectInside/"+date);
  367. this.drawer = false;
  368. }
  369. } else {
  370. this.$message({
  371. message: res.msg,
  372. type: "error"
  373. });
  374. }
  375. },
  376. error => {
  377. this.$message({
  378. message: error,
  379. type: "error"
  380. });
  381. });
  382. },
  383. },
  384. mounted() {
  385. let height = window.innerHeight;
  386. this.tableHeight = height - 15;
  387. const that = this;
  388. window.onresize = function temp() {
  389. that.tableHeight = window.innerHeight - 15;
  390. };
  391. if (this.user) {
  392. var user = JSON.parse(this.user);
  393. this.user = user;
  394. this.sysUserName = user.name || "";
  395. this.loadNotice();
  396. if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
  397. this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
  398. } else {
  399. this.remainingTime = "已过期";
  400. clearInterval(this.timer);
  401. }
  402. } else {
  403. this.$router.push("/login");
  404. }
  405. },
  406. };
  407. </script>
  408. <style scoped lang="scss">
  409. .el-menu-vertical-demo i {
  410. margin-right: 10px;
  411. }
  412. .container {
  413. position: absolute;
  414. top: 0px;
  415. bottom: 0px;
  416. width: 100%;
  417. .header {
  418. height: 60px;
  419. line-height: 60px;
  420. background: #20a0ff;
  421. color: #fff;
  422. .userinfo {
  423. text-align: right;
  424. padding-right: 35px;
  425. float: right;
  426. .userinfo-inner {
  427. cursor: pointer;
  428. color: #fff;
  429. img {
  430. width: 40px;
  431. height: 40px;
  432. border-radius: 20px;
  433. margin: 10px 10px 10px 10px;
  434. float: left;
  435. }
  436. }
  437. .itemNew {
  438. height: 25px;
  439. margin: 0 0 0 10px;
  440. i {
  441. vertical-align: top;
  442. }
  443. }
  444. }
  445. .logo {
  446. height: 60px;
  447. font-size: 21px;
  448. padding-left: 20px;
  449. padding-right: 20px;
  450. border-color: rgba(238, 241, 146, 0.3);
  451. border-right-width: 1px;
  452. border-right-style: solid;
  453. img {
  454. width: 40px;
  455. float: left;
  456. margin: 10px 10px 10px 18px;
  457. }
  458. img.headImg {
  459. margin: 0;
  460. width: 40px;
  461. height: 40px;
  462. margin: 10px 0 0 10px;
  463. }
  464. .logo-sys {
  465. height: 100%;
  466. line-height: 100%;
  467. img.headImg {
  468. width: 40px;
  469. height: 40px;
  470. margin: 10px 0 0 10px;
  471. vertical-align: middle;
  472. }
  473. span {
  474. display: inline-block;
  475. height: 100%;
  476. line-height: 100%;
  477. margin-left: 15px;
  478. margin: 20px 0 0 15px;
  479. vertical-align: middle;
  480. }
  481. }
  482. .txt {
  483. color: #fff;
  484. }
  485. }
  486. .logo-width {
  487. width: 230px;
  488. }
  489. .logo-collapse-width {
  490. width: 60px;
  491. }
  492. .tools {
  493. padding: 0px 23px;
  494. width: 14px;
  495. height: 60px;
  496. line-height: 60px;
  497. cursor: pointer;
  498. }
  499. }
  500. .main {
  501. display: flex;
  502. position: absolute;
  503. top: 60px;
  504. bottom: 0px;
  505. overflow: hidden;
  506. aside {
  507. flex: 0 0 230px;
  508. width: 230px;
  509. .el-menu {
  510. height: 100%;
  511. }
  512. .collapsed {
  513. width: 60px;
  514. .item {
  515. position: relative;
  516. }
  517. .submenu {
  518. position: absolute;
  519. top: 0px;
  520. left: 60px;
  521. z-index: 99999;
  522. height: auto;
  523. display: none;
  524. box-shadow: 5px 5px 10px #ddd;
  525. }
  526. }
  527. }
  528. .menu-collapsed {
  529. flex: 0 0 60px;
  530. width: 60px;
  531. }
  532. .menu-expanded {
  533. flex: 0 0 230px;
  534. width: 230px;
  535. }
  536. .content-container {
  537. flex: 1;
  538. width: 80%;
  539. overflow-y: auto;
  540. .breadcrumb-container {
  541. .title {
  542. width: 200px;
  543. float: left;
  544. color: #475669;
  545. }
  546. .breadcrumb-inner {
  547. float: right;
  548. }
  549. }
  550. .content-wrapper {
  551. background-color: #fff;
  552. box-sizing: border-box;
  553. }
  554. }
  555. }
  556. }
  557. .popover-item {
  558. padding: 10px;
  559. border-bottom: 1px #eee solid;
  560. }
  561. .popover-item > div > p {
  562. margin: 0;
  563. line-height: 18px;
  564. }
  565. .popover-title {
  566. color: #409eff;
  567. padding-bottom: 8px;
  568. }
  569. .popover-type {
  570. color: #aaa;
  571. font-size: 8px;
  572. float: right;
  573. }
  574. .popover-button {
  575. font-weight: 900;
  576. padding: 10px;
  577. text-align: center;
  578. cursor: pointer;
  579. }
  580. .isRead {
  581. color: #999 !important;
  582. }
  583. </style>