Home.vue 28 KB

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