Home.vue 26 KB

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