Home.vue 27 KB

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