work.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="work-layout">
  3. <top-nav></top-nav>
  4. <div :class="isCollapse ? 'small-main work-layout-main':'work-layout-main'">
  5. <div class="app-main-box">
  6. <el-menu router :default-active="$route.path" :collapse="isCollapse" :collapse-transition="false">
  7. <sub-menu :menuData="menuList" :menuIndex="1"></sub-menu>
  8. </el-menu>
  9. </div>
  10. <div class="app-main-button" @click="set">
  11. <i class="iconfont huifont-shezhi"></i>
  12. <div>设置后台</div>
  13. </div>
  14. <div class="work-layout-main-tag" @click="isCollapse = !isCollapse">
  15. <i :class="'iconfont '+ (isCollapse ? 'huifont-xiala-right':'huifont-xiala-left')"></i>
  16. </div>
  17. </div>
  18. <bread-crumb :class="isCollapse ? 'small-crumb':''" :key="crumbKey"></bread-crumb>
  19. <div :class="isCollapse ? 'small-content work-layout-content':'work-layout-content'">
  20. <transition name="slide-fade">
  21. <router-view :key="key" />
  22. </transition>
  23. </div>
  24. <div class="chat-box">
  25. <el-badge :value="badge" :hidden="!badge" class="item">
  26. <div class="chat" @click="visible = true">
  27. <i class="el-icon-s-comment"></i>
  28. </div>
  29. </el-badge>
  30. </div>
  31. <el-dialog :close-on-click-modal="false" title="聊天列表" :visible.sync="visible" width="900px"
  32. :append-to-body="true">
  33. <chat v-if="visible"></chat>
  34. </el-dialog>
  35. </div>
  36. </template>
  37. <script>
  38. import subMenu from './components/subMenu'
  39. import topNav from './components/topNav'
  40. import breadCrumb from './components/breadCrumb'
  41. import chat from './components/chat'
  42. import {
  43. mapGetters
  44. } from 'vuex';
  45. export default {
  46. data() {
  47. return {
  48. menuList: [],
  49. isCollapse: false,
  50. crumbKey: false,
  51. visible: false,
  52. chatData: [],
  53. badge: 0
  54. }
  55. },
  56. mounted() {
  57. this.init();
  58. },
  59. methods: {
  60. init() {
  61. this.menuList = this.$store.getters.menuData.filter(node => node.title !== '系统设置');
  62. this.$chat.getConversationList(data => {
  63. this.countNumber(data.data)
  64. });
  65. },
  66. countNumber(data) {
  67. let badge = 0;
  68. let list = data.filter(node => node.conversationId !== 'system');
  69. for (let i = 0; i < list.length; i++) {
  70. badge += list[i].unread
  71. }
  72. this.badge = badge;
  73. let systemData = data.filter(node => node.conversationId === 'system' && node.lastMessage.body.text ===
  74. '1');
  75. if (systemData.length === 0) return;
  76. if (!systemData[0].unread) return;
  77. let obj = JSON.parse(systemData[0].lastMessage.extra);
  78. let notify = this.$notify.info({
  79. title: this.$field.findTypeName('remindType', obj.type),
  80. message: obj.content,
  81. duration: 0,
  82. onClick: () => {
  83. notify.close();
  84. this.$router.push('/message');
  85. }
  86. });
  87. this.$chat.clearConversationUnread('system');
  88. },
  89. set() {
  90. let list = this.$store.getters.menuData.filter(node => node.title === '系统设置');
  91. if (list.length === 0) return this.$message.warning('您暂无系统设置权限');
  92. if (list[0].children.length === 0) return this.$message.warning('您暂无系统设置权限');
  93. this.$router.push(list[0].children[0].index);
  94. }
  95. },
  96. components: {
  97. subMenu,
  98. topNav,
  99. breadCrumb,
  100. chat
  101. },
  102. computed: {
  103. key() {
  104. let list = this.$store.getters.menuData.filter(node => node.title === '系统设置');
  105. if (this.$route.path.indexOf('/work/system') > -1) return list[0].children[0].index;
  106. return this.$route.path;
  107. },
  108. ...mapGetters(['menuData', 'chatList'])
  109. },
  110. watch: {
  111. menuData() {
  112. this.menuList = this.$store.getters.menuData.filter(node => node.title !== '系统设置');
  113. this.crumbKey = !this.crumbKey;
  114. },
  115. chatList() {
  116. this.countNumber(this.$store.getters.chatList || [])
  117. }
  118. },
  119. }
  120. </script>
  121. <style lang="scss">
  122. .work-layout {
  123. width: 100%;
  124. height: 100%;
  125. overflow: hidden;
  126. position: relative;
  127. background: $--background;
  128. .chat-box {
  129. position: fixed;
  130. bottom: 60px;
  131. right: 20px;
  132. font-size: 26px;
  133. cursor: pointer;
  134. z-index: 999;
  135. .chat {
  136. width: 50px;
  137. height: 50px;
  138. background: $--color-primary;
  139. color: #fff;
  140. border-radius: 50px;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. }
  145. }
  146. .work-layout-main {
  147. position: fixed;
  148. left: 0;
  149. top: 53px;
  150. width: 164px;
  151. bottom: 0;
  152. background: $--box-background;
  153. padding: 8px 8px 0px 8px;
  154. box-sizing: border-box;
  155. display: flex;
  156. flex-direction: column;
  157. transition: all 0.4s;
  158. z-index: 99;
  159. .app-main-button {
  160. border-top: 1px solid #374156;
  161. padding: 16px 13px;
  162. display: flex;
  163. cursor: pointer;
  164. margin-top: 12px;
  165. align-items: center;
  166. i.huifont-shezhi {
  167. font-size: 24px;
  168. margin-right: 7px;
  169. }
  170. div {
  171. flex: 1;
  172. width: 0;
  173. overflow: hidden;
  174. font-weight: 400;
  175. word-spacing: break-all;
  176. height: 20px;
  177. }
  178. }
  179. .menu-title {
  180. font-weight: 400;
  181. }
  182. .el-menu--collapse {
  183. .el-submenu__icon-arrow,
  184. .menu-title {
  185. display: none;
  186. }
  187. }
  188. .work-layout-main-tag {
  189. position: absolute;
  190. top: 0;
  191. right: -24px;
  192. width: 24px;
  193. height: 24px;
  194. background: rgba(255, 255, 255, 0.1);
  195. border-radius: 0px 24px 24px 0px;
  196. line-height: 24px;
  197. font-size: 12px;
  198. text-align: center;
  199. cursor: pointer;
  200. z-index: 99;
  201. }
  202. .app-main-box {
  203. flex: 1;
  204. height: 0;
  205. overflow-y: auto;
  206. overflow-x: hidden;
  207. -ms-overflow-style: none;
  208. /* 隐藏 IE 中的滚动条 */
  209. scrollbar-width: none;
  210. /* 隐藏 Firefox 中的滚动条 */
  211. }
  212. .app-main-box::-webkit-scrollbar {
  213. width: 0;
  214. /* 隐藏滚动条 */
  215. }
  216. .el-menu {
  217. width: 100%;
  218. height: 100%;
  219. background: $--box-background;
  220. border-right: none;
  221. .el-icon-arrow-down {
  222. font-family: "iconfont" !important;
  223. font-size: 16px;
  224. }
  225. .el-icon-arrow-down::before {
  226. content: "\e72d";
  227. }
  228. .el-menu-item,
  229. .el-submenu__title {
  230. border-radius: 5px;
  231. height: 48px;
  232. line-height: 46px;
  233. font-size: 14px;
  234. min-width: auto;
  235. color: $--color-common;
  236. margin: 3px 0;
  237. padding-right: 10px;
  238. i {
  239. color: $--color-common;
  240. }
  241. i.icon {
  242. font-size: 24px;
  243. margin-right: 8px;
  244. }
  245. &:hover,
  246. &.is-active,
  247. &:focus {
  248. background-color: $--color-primary;
  249. color: #fff;
  250. i,
  251. span {
  252. color: #fff;
  253. }
  254. }
  255. }
  256. .el-submenu__title {
  257. .el-submenu__icon-arrow {
  258. right: 10px;
  259. }
  260. }
  261. .menu-index-1 {
  262. .el-menu-item,
  263. .el-submenu__title {
  264. padding-left: 12px !important;
  265. }
  266. }
  267. .menu-index-2 {
  268. .el-menu-item,
  269. .el-submenu__title {
  270. padding-left: 40px !important;
  271. }
  272. }
  273. .menu-index-3 {
  274. .el-menu-item,
  275. .el-submenu__title {
  276. padding-left: 50px !important;
  277. }
  278. }
  279. .menu-index-3 {
  280. .el-menu-item,
  281. .el-submenu__title {
  282. padding-left: 60px !important;
  283. }
  284. }
  285. .menu-index-4 {
  286. .el-menu-item,
  287. .el-submenu__title {
  288. padding-left: 70px !important;
  289. }
  290. }
  291. .menu-index-5 {
  292. .el-menu-item,
  293. .el-submenu__title {
  294. padding-left: 80px !important;
  295. }
  296. }
  297. }
  298. }
  299. .small-main {
  300. width: 64px;
  301. padding: 8px 8px 0px 8px;
  302. }
  303. .work-layout-content {
  304. position: absolute;
  305. top: 89px;
  306. left: 176px;
  307. right: 12px;
  308. bottom: 12px;
  309. background: $--box-background;
  310. transition: left 0.4s;
  311. .slide-fade-enter-active {
  312. transition: all 0.1s ease;
  313. }
  314. .slide-fade-leave-active {
  315. transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
  316. }
  317. .slide-fade-enter,
  318. .slide-fade-leave-to {
  319. transform: translateX(10px);
  320. opacity: 0;
  321. }
  322. }
  323. .small-content {
  324. left: 76px;
  325. }
  326. .bread-crumb {
  327. position: absolute;
  328. top: 60px;
  329. left: 176px;
  330. right: 12px;
  331. transition: left 0.4s;
  332. z-index: 8;
  333. }
  334. .small-crumb {
  335. left: 76px;
  336. }
  337. }
  338. .el-menu--vertical {
  339. .el-menu--popup {
  340. min-width: 164px;
  341. }
  342. .el-menu {
  343. background: $--color-background;
  344. border-radius: 8px;
  345. .el-menu-item,
  346. .el-submenu__title {
  347. color: $--color-common;
  348. height: 48px;
  349. line-height: 48px;
  350. }
  351. .el-menu-item:hover,
  352. .el-menu-item:focus,
  353. .el-submenu__title:hover,
  354. .el-submenu__title:focus {
  355. background: $--color-background-hover;
  356. border-radius: 4px;
  357. }
  358. .menu-index-2 {
  359. padding: 0 8px;
  360. height: 48px;
  361. line-height: 48px;
  362. }
  363. }
  364. }
  365. </style>