HomeView.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div id="home">
  3. <div id="Header">
  4. <div class="loginForm" v-if="isLogin">
  5. <span style="color: white">用户名:</span>
  6. <span style="color: white">{{ $store.getters.getUserName || '未登录' }}</span>
  7. <el-link type="warning" :underline="false" class="logout" @click="logout"> 退出登录</el-link>
  8. </div>
  9. <div class="loginForm" v-else>
  10. <span class="formLabel">用户名:</span>
  11. <input class="formInput" type="text" v-model="loginForm.userName" placeholder="请输入用户名"/>
  12. &nbsp;&nbsp;
  13. <span class="formLabel">密&nbsp;&nbsp;码:</span>
  14. <input class="formInput" type="password" v-model="loginForm.password" placeholder="请输入密码"/>
  15. &nbsp;&nbsp;
  16. <el-button type="warning" @click="login" size="small">登录</el-button>
  17. </div>
  18. <div class="title">
  19. <img :src="titleImg"/>
  20. </div>
  21. </div>
  22. <div id="Menu" :style="{height: contentHeight+'px'}">
  23. <div id="Tags">
  24. <el-menu
  25. :default-active="activeIndex"
  26. class="el-menu-demo"
  27. mode="horizontal"
  28. background-color="#6162f2"
  29. text-color="white"
  30. active-text-color="#ffc01c"
  31. @select="handleMenuClick"
  32. >
  33. <el-menu-item index="1" >综合展示</el-menu-item>
  34. <el-menu-item index="2" v-if="isLogin && pageShow['DTB-DATAMANAGE']">数据管理</el-menu-item>
  35. <el-menu-item index="3" v-if="isLogin && pageShow['DTB-DATAPUBLISH']">数据发布</el-menu-item>
  36. <el-menu-item index="4" v-if="isLogin && pageShow['DTB-PLUGINMANAGE']">插件管理</el-menu-item>
  37. <el-menu-item index="5" v-if="isLogin && pageShow['DTB-SYSTEMMANAGE']">系统管理</el-menu-item>
  38. </el-menu>
  39. </div>
  40. <div class="content">
  41. <!--<HomeIndex :auth="pageShow['DTB-HOMEINDEX']" v-if="activeIndex==1"/>-->
  42. <HomeIndex :auth="true" v-if="activeIndex==1"/>
  43. <DataManage v-if="activeIndex==2"/>
  44. <DataPublish v-if="activeIndex==3"/>
  45. <PluginManage v-if="activeIndex==4"/>
  46. <SystemManage v-if="activeIndex==5"/>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import {defineAsyncComponent} from "vue";
  53. import loginApi from "@/api/login";
  54. import elementResizeDetectorMaker from "element-resize-detector";
  55. import titleImg from "@/assets/img/title.png"
  56. export default {
  57. name: 'homeIndex',
  58. components: {
  59. HomeIndex: defineAsyncComponent(() => import("@/components/home/HomeIndex.vue")),
  60. DataManage: defineAsyncComponent(() => import("@/components/home/DataManage.vue")),
  61. DataPublish: defineAsyncComponent(() => import("@/components/home/DataPublish.vue")),
  62. PluginManage: defineAsyncComponent(() => import("@/components/home/PluginManage.vue")),
  63. SystemManage: defineAsyncComponent(() => import("@/components/home/SystemManage.vue")),
  64. },
  65. data() {
  66. return {
  67. titleImg,
  68. activeIndex: '1',
  69. fullscreenLoading: null,
  70. contentHeight: '',
  71. isLogin: false,
  72. loginForm: {
  73. userName: 'user001',
  74. password: '1234567890',
  75. clientId: this.$constant.serviceId,
  76. },
  77. pageShow: {
  78. "DTB-HOMEINDEX": false, // 综合展示
  79. "DTB-DATAMANAGE": false, // 数据管理
  80. "DTB-DATAPUBLISH": false, // 数据发布
  81. "DTB-PLUGINMANAGE": false, // 插件管理
  82. "DTB-SYSTEMMANAGE": false, // 系统管理
  83. }
  84. }
  85. },
  86. created() {
  87. this.$root.$.appContext.config.globalProperties.judgeLogin = this.judgeLogin;
  88. },
  89. mounted() {
  90. this.judgeLogin();
  91. },
  92. methods: {
  93. judgeLogin() {
  94. let token = this.$store.getters.getToken;
  95. this.isLogin = token && token !== '';
  96. this.activeIndex = 1;
  97. if (this.isLogin) {
  98. this.updateAuth();
  99. }
  100. },
  101. updateAuth() {
  102. let app = this;
  103. let params = {
  104. serviceId: this.$constant.serviceId,
  105. type: app.$constant.authType
  106. }
  107. let keys = Object.keys(app.pageShow);
  108. loginApi.getUserPermissions(params).then(res=>{
  109. if (res.code === 200) {
  110. res.content.forEach(item => {
  111. if (keys.indexOf(item.permissionName)>-1) {
  112. app.pageShow[item.permissionName] = true;
  113. }
  114. })
  115. }
  116. })
  117. },
  118. handleMenuClick(val) {
  119. this.activeIndex = val;
  120. },
  121. login() {
  122. let app = this;
  123. if (!app.loginForm.userName || app.loginForm.userName==='') {
  124. app.$message({message: '请输入用户名', type: 'warning'});
  125. return;
  126. } else if (!app.loginForm.password || app.loginForm.password==='') {
  127. app.$message({message: '请输入密码', type: 'warning'});
  128. return;
  129. }
  130. app.$util.loading.handleLoading(true)
  131. loginApi.userLogin(app.loginForm).then(res => {
  132. app.$store.state.token = res.message
  133. app.$store.commit('setUserInfo', res.content);
  134. app.$store.commit('setToken', res.message);
  135. app.$util.loading.handleLoading(false);
  136. app.judgeLogin()
  137. }).catch(err => {
  138. app.$util.loading.handleLoading(false);
  139. app.judgeLogin();
  140. })
  141. },
  142. logout() {
  143. this.$util.loading.handleLoading(true);
  144. this.$store.commit('resetState', {});
  145. this.$util.loading.handleLoading(false);
  146. this.judgeLogin();
  147. },
  148. }
  149. }
  150. </script>
  151. <style scoped>
  152. .custom-loading .circular {
  153. margin-right: 6px;
  154. width: 18px;
  155. height: 18px;
  156. animation: loading-rotate 2s linear infinite;
  157. }
  158. .custom-loading .circular .path {
  159. animation: loading-dash 1.5s ease-in-out infinite;
  160. stroke-dasharray: 90, 150;
  161. stroke-dashoffset: 0;
  162. stroke-width: 2;
  163. stroke: var(--el-button-text-color);
  164. stroke-linecap: round;
  165. }
  166. #home {
  167. width: 100%;
  168. height: 100%;
  169. min-height: 100%;
  170. }
  171. #Header {
  172. /* background-image: linear-gradient(#90e2fc, white); */
  173. background-image: url('@/assets/img/header.png');
  174. background-size: 100% 100%;
  175. height: 18%;
  176. }
  177. #Header .title {
  178. height: 100%;
  179. padding: 3.5% 0 0 10%;
  180. }
  181. #Header .title img {
  182. width: 12%;
  183. }
  184. #Header .loginForm {
  185. float: right;
  186. /*width: 30%;*/
  187. /*float: right;*/
  188. margin-top: 1%;
  189. margin-right: 3%;
  190. /*color: white;*/
  191. }
  192. .loginForm .formLabel {
  193. display: inline-block;
  194. }
  195. .loginForm .formInput {
  196. margin-right: 5px;
  197. border-color: transparent;
  198. border-radius: 3px;
  199. height: 20px;
  200. color: white;
  201. padding-left: 6px;
  202. background: rgba(255, 255, 255, 0.3);
  203. }
  204. .loginForm .formInput:hover {
  205. background-color: rgba(255, 255, 255, 0.6);
  206. }
  207. .loginForm .formInput:focus {
  208. outline: 1px solid rgba(255, 255, 255, 0.6);
  209. }
  210. .logout {
  211. color: #e1e1e1;
  212. padding: 0 15px 5px
  213. }
  214. .logout:hover {
  215. color: orange;
  216. }
  217. .formLabel {
  218. color: white;
  219. }
  220. #Menu {
  221. height: 76%;
  222. overflow: visible;
  223. }
  224. #Tags {
  225. width: 100%;
  226. }
  227. .content {
  228. width: 80%;
  229. margin: 0 auto;
  230. /*padding-top: 1%;*/
  231. height: 95%;
  232. /*overflow: visible;*/
  233. }
  234. .el-menu-demo {
  235. align-items: center;
  236. justify-content: center;
  237. }
  238. .el-menu-item {
  239. font-size: 20px;
  240. font-weight: 600;
  241. margin: 0 5% !important;
  242. }
  243. .el-menu-item:focus {
  244. background-color: #6162f2 !important;
  245. }
  246. </style>
  247. <style>
  248. .el-dialog__body {
  249. padding-top: 10px;
  250. }
  251. </style>