Home.vue 26 KB

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