Home.vue 26 KB

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