Home.vue 23 KB

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