index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <div class="navbar_right">
  3. <div id="userinfo" class="userinfobox">
  4. <div class="topbox">
  5. <div class="imgbox">
  6. <img v-if="imageUrl != ''" :src="imageUrl" />
  7. <img v-else src="../../assets/images/mrtx.png" />
  8. </div>
  9. <div class="usename">
  10. <p class="myp">{{ userName }}</p>
  11. <p class="myp">{{ userInfo.personnelName }}</p>
  12. </div>
  13. </div>
  14. <div class="compbox">
  15. <p class="comp">公司: {{ userInfo.depotName }}</p>
  16. <p class="comp">所属部门: {{ this.$store.state.departmentName }}</p>
  17. <p class="comp">职位: {{ this.$store.state.ppost }}</p>
  18. </div>
  19. </div>
  20. <div></div>
  21. <div class="div_left" @mouseleave="cancelinfo" @mouseenter="getinfo">
  22. <img class="imgboxone" v-if="imageUrl != ''" :src="imageUrl" />
  23. <img class="imgboxone" v-else src="../../assets/images/mrtx.png" />
  24. 欢迎登录,
  25. <span style="color: #fff">{{ userName }}</span>
  26. </div>
  27. <div class="div_right">
  28. <!-- 安卓二维码下载图标 -->
  29. <div
  30. class="androidQR"
  31. style="
  32. padding-top: 5px;
  33. line-height: 64px;
  34. float: left;
  35. position: relative;
  36. "
  37. >
  38. <span class="shouji"></span>
  39. <!-- <img src="../../assets/images/手机_h.png" alt /> -->
  40. <div class="androidQR_nr">
  41. <div class="arrow"></div>
  42. <img
  43. class="img-app"
  44. src="@/assets/images/QRcode.png"
  45. width="120px"
  46. height="120px"
  47. />
  48. <!-- <span class="text">下载Android App</span> -->
  49. </div>
  50. </div>
  51. <div
  52. style="
  53. padding-top: 5px;
  54. height: 64px;
  55. line-height: 64px;
  56. float: left;
  57. position: relative;
  58. "
  59. @click="goDban()"
  60. >
  61. <el-tooltip
  62. class="item"
  63. effect="dark"
  64. content="待办"
  65. placement="bottom"
  66. >
  67. <span class="daiban"></span>
  68. </el-tooltip>
  69. <div class="daiBan_div" v-if="pendingCount > 0 && pendingCount < 100">
  70. {{ pendingCount }}
  71. </div>
  72. <div class="daiBan_divn" v-if="pendingCount > 99">99+</div>
  73. </div>
  74. <div
  75. style="
  76. padding-top: 5px;
  77. height: 64px;
  78. line-height: 64px;
  79. float: left;
  80. position: relative;
  81. "
  82. @click="informFn()"
  83. >
  84. <el-tooltip
  85. class="item"
  86. effect="dark"
  87. content="通知"
  88. placement="bottom"
  89. >
  90. <span class="tongzhi"></span>
  91. </el-tooltip>
  92. <div class="news_div" v-if="informNum > 0 && informNum < 100">
  93. {{ informNum }}
  94. </div>
  95. <div class="news_divn" v-if="informNum > 99">99+</div>
  96. <!-- <div class="news_div">{{ informNum }}</div> -->
  97. </div>
  98. <div
  99. style="
  100. padding-top: 5px;
  101. height: 64px;
  102. line-height: 64px;
  103. float: left;
  104. position: relative;
  105. "
  106. @click="editPassword()"
  107. >
  108. <el-tooltip
  109. class="item"
  110. effect="dark"
  111. content="修改密码"
  112. placement="bottom"
  113. >
  114. <span class="xgmm"></span>
  115. </el-tooltip>
  116. </div>
  117. <div
  118. style="
  119. padding-top: 5px;
  120. height: 64px;
  121. line-height: 64px;
  122. float: left;
  123. position: relative;
  124. "
  125. >
  126. <el-tooltip
  127. class="item"
  128. effect="dark"
  129. content="退出"
  130. placement="bottom"
  131. >
  132. <span class="logout" @click="loginOut()"></span>
  133. </el-tooltip>
  134. </div>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import {
  140. getToken,
  141. setToken,
  142. removeToken,
  143. getUser,
  144. setUser,
  145. removeUser,
  146. } from "@/utils/auth"
  147. import { informList } from "@/api/home"
  148. import { pending } from "@/api/daiBan/index"
  149. import { processed } from "@/api/daiBan/index"
  150. import { getfilebyname } from "@/api/system/organizationalStructure/personnel"
  151. import { closenewWebSocket,newWebSocket } from '@/api/sendMessageSocket'
  152. export default {
  153. data() {
  154. return {
  155. userName: "",
  156. informNum: 0,
  157. //待办数量
  158. pendingCount: this.$store.state.pendingCount,
  159. // pendingCount:0,
  160. proCount: 0,
  161. //待处理计时器
  162. pendingTime: null,
  163. homeType: "",
  164. userinfohover: "",
  165. userInfo: "",
  166. imageUrl: "",
  167. }
  168. },
  169. created() {
  170. this.userName = JSON.parse(getUser()).uname
  171. this.getInformListUnreadNum()
  172. this.homeType = JSON.parse(getUser()).homeType
  173. this.userInfo = JSON.parse(localStorage.getItem("userInfo"))
  174. if (this.userInfo.pheadPortrait != "") {
  175. getfilebyname(this.userInfo.pheadPortrait).then((res) => {
  176. this.imageUrl = window.URL.createObjectURL(res)
  177. })
  178. } else {
  179. this.imageUrl = ""
  180. }
  181. },
  182. computed: {
  183. PendingCount() {
  184. return this.$store.state.pendingCount
  185. },
  186. listeninformNum() {
  187. return this.$store.state.informNum
  188. },
  189. MessageData() {
  190. return this.$store.state.messageData
  191. },
  192. },
  193. watch: {
  194. PendingCount: function (val) {
  195. this.pendingCount = val
  196. console.log(this.pendingCount, " this.pendingCount ...")
  197. },
  198. listeninformNum: function (val) {
  199. this.informNum = val
  200. },
  201. MessageData(val) {
  202. console.log(val, "MessageData.....")
  203. this.getPending()
  204. if (
  205. this.$route.path .indexOf("/inform/unreadinform") != -1 ||
  206. this.$route.path .indexOf("/daiban/pending") != -1 ||
  207. this.$route.path .indexOf("/reservesManagement/mechanicalVentilation")!= -1
  208. ) {
  209. this.$router.go(0)
  210. }
  211. console.log(this.$route.path, "this.$route.path")
  212. },
  213. },
  214. mounted() {
  215. console.log("abscd")
  216. // this.pendingTime = setInterval(() => {
  217. // this.getPending()
  218. // }, 3000)
  219. var uid=JSON.parse(getUser()).uid
  220. // 调用websocket
  221. newWebSocket(uid)
  222. this.getPending()
  223. this.getProcessed()
  224. // this.socketApi.setCallback(this.receivedMsg)
  225. },
  226. //页面销毁
  227. // beforeDestroy() {
  228. // window.clearInterval(this.pendingTime)
  229. // },
  230. methods: {
  231. // receivedMsg(msg){
  232. // console.log(msg,">>>>>>>>>????????");
  233. // this.$store.commit({
  234. // type: "changependingCount",
  235. // pendingCount: this.$store.state.pendingCount,
  236. // })
  237. // },
  238. cancelinfo() {
  239. document.getElementById("userinfo").style.display = "none"
  240. },
  241. getinfo() {
  242. document.getElementById("userinfo").style.display = "block"
  243. },
  244. // 退出
  245. async loginOut() {
  246. await this.$store.dispatch("user/logout")
  247. // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  248. this.$router.push(`/login`)
  249. closenewWebSocket(JSON.parse(getUser()).uid)
  250. removeToken()
  251. removeUser()
  252. sessionStorage.clear()
  253. localStorage.clear()
  254. },
  255. //待办
  256. goDban() {
  257. console.log("染回")
  258. let userInfo = JSON.parse(getUser())
  259. let homeType = userInfo.homeType
  260. if (homeType == 1) {
  261. this.$router.push({ path: "/dashboard/daiban/pending" }) //分公司
  262. } else if (homeType == 2) {
  263. this.$router.push({ path: "/dashboard/daiban/pending" })
  264. } else if (homeType == 3) {
  265. this.$router.push({ path: "/home/daiban/initiated" }) //员工
  266. }
  267. // this.$router.push({ path: "/daiban/initiated" })
  268. },
  269. getInformListUnreadNum() {
  270. let data = {
  271. pageIndex: 1,
  272. pageSize: 10,
  273. condition: JSON.stringify({ readStatus: false }),
  274. }
  275. informList(data).then((res) => {
  276. if (res.code == 200) {
  277. this.informNum = res.data.total
  278. } else {
  279. this.$message.error(res.msg)
  280. }
  281. })
  282. },
  283. informFn() {
  284. let userInfo = JSON.parse(getUser())
  285. let homeType = userInfo.homeType
  286. if (homeType == 1) {
  287. this.$router.push({ path: "/dashboard/inform/unreadinform" }) //分公司
  288. } else if (homeType == 2) {
  289. this.$router.push({ path: "/dashboard/inform/unreadinform" })
  290. } else if (homeType == 3) {
  291. this.$router.push({ path: "/home/inform/unreadinform" }) //员工
  292. }
  293. // this.$router.push({ path: "/inform/unreadinform" })
  294. },
  295. editPassword() {
  296. let userInfo = JSON.parse(getUser())
  297. let homeType = userInfo.homeType
  298. if (homeType == 1) {
  299. this.$router.push({ path: "/dashboard/editPassword" }) //分公司
  300. } else if (homeType == 2) {
  301. this.$router.push({ path: "/dashboard/editPassword" })
  302. } else if (homeType == 3) {
  303. this.$router.push({ path: "/home/editPassword" }) //员工
  304. }
  305. // this.$router.push({ path: "/editPassword" })
  306. },
  307. //待处理列表数据
  308. getPending() {
  309. var condition = {
  310. userId: JSON.parse(getUser()).uid,
  311. }
  312. condition = JSON.stringify(condition)
  313. var data = {
  314. pageIndex: 1,
  315. pageSize: 10,
  316. condition: condition,
  317. }
  318. pending(data).then((res) => {
  319. if (res.code == 200) {
  320. this.$store.commit({
  321. type: "changependingCount",
  322. pendingCount: res.data.total,
  323. })
  324. }
  325. })
  326. },
  327. //已处理列表数据
  328. getProcessed() {
  329. var condition = {
  330. userId: JSON.parse(getUser()).uid,
  331. }
  332. // console.log(condition, "condition.....")
  333. condition = JSON.stringify(condition)
  334. var data = {
  335. pageIndex: 1,
  336. pageSize: 10,
  337. condition: condition,
  338. }
  339. processed(data).then((res) => {
  340. if (res.code == 200) {
  341. this.$store.commit({
  342. type: "changeproCount",
  343. proCount: res.data.total,
  344. })
  345. }
  346. })
  347. },
  348. },
  349. }
  350. </script>
  351. <style lang="scss" scoped>
  352. .navbar_right {
  353. float: right;
  354. margin-right: 20px;
  355. line-height: 64px;
  356. height: 64px;
  357. .userinfobox {
  358. font-size: 14px;
  359. width: 240px;
  360. height: 161px;
  361. background-color: #ffffff;
  362. display: none;
  363. position: fixed;
  364. right: 160px;
  365. top: 55px;
  366. z-index: 999;
  367. border-radius: 10px;
  368. box-shadow: 1px 1px 10px #000402;
  369. padding: 15px;
  370. .topbox {
  371. width: 100%;
  372. height: 46px;
  373. .imgbox {
  374. width: 46px;
  375. height: 45px;
  376. float: left;
  377. // background-color: pink;
  378. border-radius: 50%;
  379. img {
  380. width: 46px;
  381. height: 45px;
  382. border-radius: 50%;
  383. }
  384. }
  385. .usename {
  386. float: left;
  387. width: 160px;
  388. height: 45px;
  389. padding-left: 10px;
  390. .myp {
  391. margin: 0;
  392. height: 20px;
  393. line-height: 20px;
  394. color: #037d41;
  395. font-weight: 700;
  396. }
  397. }
  398. }
  399. .compbox {
  400. width: 220px;
  401. height: 100px;
  402. .comp {
  403. margin: 0;
  404. height: 30px;
  405. line-height: 30px;
  406. font-size: 12px;
  407. color: #555555;
  408. font-weight: 700;
  409. }
  410. }
  411. }
  412. .div_left {
  413. cursor: pointer;
  414. float: left;
  415. font-size: 14px;
  416. margin-right: 20px;
  417. line-height: 64px;
  418. font-weight: 500;
  419. .imgboxone {
  420. width: 28px;
  421. height: 27px;
  422. vertical-align: middle;
  423. border-radius: 50%;
  424. // display: inline-block;
  425. }
  426. }
  427. .div_right {
  428. cursor: pointer;
  429. float: left;
  430. height: 100%;
  431. line-height: 64px;
  432. img {
  433. // width: 25px;
  434. vertical-align: middle;
  435. margin-right: 15px;
  436. }
  437. // 下载app二维码显示
  438. .androidQR {
  439. text-align: center;
  440. position: relative;
  441. .androidQR_nr {
  442. width: 120px;
  443. height: 120px;
  444. padding: 10px 10px 0 10px;
  445. position: absolute;
  446. left: -49px;
  447. top: 58px;
  448. background: #fff;
  449. z-index: 5;
  450. display: none;
  451. .arrow {
  452. width: 0;
  453. height: 0;
  454. border-bottom: 10px solid #fff;
  455. border-left: 10px solid transparent;
  456. border-right: 10px solid transparent;
  457. position: absolute;
  458. left: 50px;
  459. top: -10px;
  460. }
  461. .img-app {
  462. height: 100px;
  463. width: 100px;
  464. }
  465. .text {
  466. color: black;
  467. font-size: 12px;
  468. }
  469. }
  470. }
  471. .androidQR:hover {
  472. .androidQR_nr {
  473. display: block;
  474. }
  475. }
  476. .shouji {
  477. width: 21px;
  478. height: 20px;
  479. margin-right: 15px;
  480. display: inline-block;
  481. background: url("../../assets/images/手机(1).png") no-repeat center;
  482. }
  483. .shouji:hover {
  484. background: url("../../assets/images/手机_h.png") no-repeat center;
  485. }
  486. .daiban {
  487. width: 21px;
  488. height: 20px;
  489. margin-right: 15px;
  490. display: inline-block;
  491. background: url("../../assets/images/db.png") no-repeat center;
  492. }
  493. .daiban:hover {
  494. background: url("../../assets/images/dbh.png") no-repeat center;
  495. }
  496. .tongzhi {
  497. width: 21px;
  498. height: 20px;
  499. margin-right: 15px;
  500. display: inline-block;
  501. background: url("../../assets/images/ntz.png") no-repeat center;
  502. }
  503. .tongzhi:hover {
  504. background: url("../../assets/images/ntzh.png") no-repeat center;
  505. }
  506. .xgmm {
  507. width: 21px;
  508. height: 20px;
  509. margin-right: 15px;
  510. display: inline-block;
  511. background: url("../../assets/images/sz.png") no-repeat center;
  512. }
  513. .xgmm:hover {
  514. background: url("../../assets/images/szh.png") no-repeat center;
  515. }
  516. .logout {
  517. width: 21px;
  518. height: 20px;
  519. margin-right: 15px;
  520. display: inline-block;
  521. background: url("../../assets/images/tc.png") no-repeat center;
  522. }
  523. .logout:hover {
  524. background: url("../../assets/images/tch.png") no-repeat center;
  525. }
  526. .daiBan_div,
  527. .news_div {
  528. width: 16px;
  529. height: 15px;
  530. color: #fff;
  531. border-radius: 50%;
  532. background: red;
  533. position: absolute;
  534. left: 14px;
  535. top: 8px;
  536. font-size: 8px;
  537. text-align: center;
  538. line-height: 15px;
  539. }
  540. .daiBan_divn,
  541. .news_divn {
  542. width: 25px;
  543. height: 15px;
  544. color: #fff;
  545. border-radius: 30%;
  546. background: red;
  547. position: absolute;
  548. left: 14px;
  549. top: 8px;
  550. font-size: 8px;
  551. text-align: center;
  552. line-height: 15px;
  553. }
  554. }
  555. }
  556. </style>