index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <el-row>
  3. <el-col :span="24">
  4. <el-card class="el-card-auto" style="min-height:350px">
  5. <div slot="header" class="clearfix">
  6. <span style="font-size: 20px;">我的应用</span>
  7. <!-- <el-button style="font-size: 20px;float: right; padding: 3px 0" type="text"
  8. @click="childMethod()">新建应用</el-button> -->
  9. </div>
  10. <el-tabs v-model="activeName" @tab-click="handleClick">
  11. <el-tab-pane v-for="item, index in appList" :label="item.name" :name="item.name" :key="index">
  12. <div class="app-item" v-for="(childItem, index) in item.children" :key="index" v-if="childItem.name!='企业管理' && childItem.name!='审批中心'" @click="handleSelect(childItem)"
  13. @mouseover="showContent = index" @mouseleave="showContent = null" v-loading.fullscreen.lock="fullscreenLoading">
  14. <svg-icon :icon-class="childItem.icon" style="width: 40px;height: 40px" />
  15. {{ childItem.name }}
  16. <div v-if="showContent == index" class="app-item-tools">
  17. <!-- <i slot="reference" class="el-icon-s-tools" @click.stop="editApp(childItem)"></i> -->
  18. </div>
  19. </div>
  20. </el-tab-pane>
  21. </el-tabs>
  22. </el-card>
  23. </el-col>
  24. </el-row>
  25. </template>
  26. <script>
  27. import {appList,getListByMenuId} from "@/api/home";
  28. import router from '@/router'
  29. import store from '@/store'
  30. export default {
  31. data() {
  32. return {
  33. fullscreenLoading:false,
  34. activeName: 'OA',
  35. showContent: null,
  36. appList: [
  37. // {
  38. // name: 'OA',
  39. // children: [
  40. // {
  41. // type: 1,
  42. // path: 'https://www.baidu.com/',
  43. // name: '自定义应用',
  44. // icon: 'zidingyi',
  45. // },
  46. // {
  47. // type: 3,
  48. // path: '/system/companyInfo',
  49. // name: '系统管理',
  50. // icon: 'chuchai',
  51. // },
  52. // {
  53. // type: 99,
  54. // path: '/oa/universal',
  55. // name: '通用审批',
  56. // icon: 'qingjia',
  57. // },
  58. // {
  59. // type: 1,
  60. // path: '/oa/entry',
  61. // name: '入职审批',
  62. // icon: 'qingjia',
  63. // },
  64. // {
  65. // type: 2,
  66. // path: '/oa/turnJust',
  67. // name: '转正申请',
  68. // icon: 'chuchai',
  69. // },
  70. // {
  71. // type: 3,
  72. // path: '/oa/renewal',
  73. // name: '续签申请',
  74. // icon: 'chuchai',
  75. // },
  76. // {
  77. // type: 4,
  78. // path: '/oa/staffQuit',
  79. // name: '离职申请',
  80. // icon: 'chuchai',
  81. // },
  82. // {
  83. // type: 4,
  84. // path: '/meeting/list',
  85. // name: '会议室管理',
  86. // icon: 'chuchai',
  87. // },
  88. // ],
  89. // },
  90. // {
  91. // name: '人事',
  92. // children: [],
  93. // },
  94. // {
  95. // name: '财务',
  96. // children: [],
  97. // },
  98. // {
  99. // name: 'CRM',
  100. // children: [],
  101. // },
  102. ]
  103. };
  104. },
  105. created(){
  106. this.getAppList();
  107. },
  108. methods: {
  109. getAppList() {
  110. appList().then(res => {
  111. let appDataList = [];
  112. res.data.map((item) => {
  113. // if (item.name != '其他') {
  114. appDataList.push(item);
  115. // }
  116. });
  117. this.appList = appDataList;
  118. })
  119. },
  120. childMethod() {
  121. this.$parent.openAppList();
  122. },
  123. //编辑应用
  124. editApp(item) {
  125. this.$parent.editApp(item);
  126. },
  127. // 菜单选择事件
  128. handleSelect(item) {
  129. console.log(item);
  130. let key = item.path;
  131. if(this.ishttp(key)){
  132. // http(s):// 路径新窗口打开
  133. window.open(key, "_blank");
  134. }else if(item.path.indexOf('oa') > -1){
  135. this.$router.push({ path: key });
  136. }else{
  137. this.fullscreenLoading = true;
  138. getListByMenuId(item.id).then(response => {
  139. let menuList =response.data;
  140. localStorage.setItem("parentId", item.parentId)
  141. localStorage.setItem("menus", JSON.stringify(menuList))
  142. store.dispatch('GenerateRoutes', menuList).then(accessRoutes => {
  143. console.log(accessRoutes);
  144. // 根据 roles 权限生成可访问的路由表
  145. router.addRoutes(accessRoutes) // 动态添加可访问路由表
  146. })
  147. setTimeout(() => {
  148. this.fullscreenLoading = false;
  149. this.$router.push({ path: item.component });
  150. }, 200);
  151. });
  152. }
  153. },
  154. handleClick(tab, event) {
  155. console.log(tab, event);
  156. },
  157. ishttp(url) {
  158. return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
  159. }
  160. },
  161. };
  162. </script>
  163. <style>
  164. /*去掉切换时el-tab-pane底部的蓝色下划线*/
  165. /* .el-tabs__active-bar {
  166. background-color: transparent !important;
  167. } */
  168. /*去掉tabs底部的下划线*/
  169. .el-tabs__nav-wrap::after {
  170. position: static !important;
  171. }
  172. .el-tabs__nav-wrap {
  173. padding: 0 30px !important;
  174. }
  175. </style>
  176. <style lang="scss">
  177. .el-icon-s-tools:hover {
  178. color: #00B899;
  179. }
  180. .typeTitle {
  181. font-size: 20px;
  182. font-weight: 400;
  183. color: #1f2f3d;
  184. margin-left: 10px;
  185. margin-bottom: 10px;
  186. }
  187. .el-card-auto {
  188. min-height: 100%;
  189. height: 100%;
  190. margin-bottom: 20px;
  191. }
  192. .el-card-auto>>>.el-card__body {
  193. height: 100%;
  194. }
  195. .el-tabs__item {
  196. font-size: 18px;
  197. font-weight: 500;
  198. }
  199. .app-item {
  200. display: flex;
  201. flex-flow: column;
  202. justify-content: center;
  203. align-items: center;
  204. float: left;
  205. width: 178px;
  206. height: 150px;
  207. color: #999093;
  208. margin: 10px 10px 10px 10px;
  209. border-radius: 5px;
  210. }
  211. .app-item {
  212. line-height: 50px;
  213. font-size: 18px;
  214. list-style: none;
  215. cursor: pointer;
  216. position: relative;
  217. transition: border-color 0.3s, background-color 0.3s, color 0.3s;
  218. box-sizing: border-box;
  219. white-space: nowrap;
  220. }
  221. .app-item-tools {
  222. color: #838892;
  223. cursor: pointer;
  224. font-size: 16px;
  225. line-height: 16px;
  226. position: absolute;
  227. right: 10px;
  228. top: 10px;
  229. }
  230. .app-item:hover,
  231. .app-item:focus {
  232. outline: none;
  233. background-color: #FFFFFF;
  234. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  235. }
  236. </style>