Browse Source

修复以前的bug

lusa 3 years ago
parent
commit
a38e0a6d74
9 changed files with 340 additions and 279 deletions
  1. 245 245
      package-lock.json
  2. 3 4
      package.json
  3. 7 5
      src/components/header.vue
  4. 13 0
      src/components/menu.vue
  5. 2 3
      src/main.js
  6. 26 0
      src/store/index.js
  7. 42 21
      src/views/dashbord.vue
  8. 1 1
      src/views/index.vue
  9. 1 0
      src/views/login.vue

File diff suppressed because it is too large
+ 245 - 245
package-lock.json


+ 3 - 4
package.json

@@ -9,6 +9,7 @@
   },
   "dependencies": {
     "axios": "^0.19.0",
+    "babel-polyfill": "^6.26.0",
     "core-js": "^3.4.4",
     "echarts": "^4.6.0",
     "moment": "^2.24.0",
@@ -18,6 +19,7 @@
     "vue": "^2.6.10",
     "vue-awesome-swiper": "^3.1.3",
     "vue-router": "^3.1.3",
+    "vuex": "^3.0.1",
     "vuex-router-sync": "^5.0.0"
   },
   "devDependencies": {
@@ -30,10 +32,7 @@
     "less-loader": "^5.0.0",
     "vue-template-compiler": "^2.6.10"
   },
-  "eslintConfig": {
-
-
-  },
+  "eslintConfig": {},
   "browserslist": [
     "> 1%",
     "last 2 versions"

+ 7 - 5
src/components/header.vue

@@ -12,9 +12,8 @@
         </div>
         <div v-if="isShowMenu" class="userDetails">
             <img src="../assets/user.png" border="0" title="Name and privileges of currently logged user">
-            <span id="username">admin</span><small id="priv"> (Administrator)</small>
+            <span id="username">{{username}}</span>
             <a href="javascript://" @click="refreshBtn" title="Reloads the current page"><img src="../assets/refresh.png" border="0"> 刷新</a>
-            <a href="javascript://" id="printBtn" title="Prints the current page"><img src="../assets/print_1.png" border="0"> 打印</a>
             <a href="javascript://" @click="logoutBtn" id="logoutBtn" title="Logout"><img src="../assets/logout_1.png" border="0"> 登出</a>
         </div>
       </div>
@@ -32,19 +31,22 @@ export default {
     }
   },
   created(){
+
   },
+    computed:{
+        username(){
+            return sessionStorage.getItem('uesrname') || ''
+        }
+    },
     methods: {
         refreshBtn(){
             this.$emit('reload')
         },
         logoutBtn(){
-
             api.Get("/action/logout",{}).then(res =>{
                 sessionStorage.clear();
                 this.$router.push('/login')
             })
-
-
         }
     },
 

+ 13 - 0
src/components/menu.vue

@@ -20,7 +20,10 @@
                     </submenu>
                 </template>
             </template>
+            <div class="current-baled">当前模块:{{currentIndex}}</div>
         </Menu>
+
+
     </div>
 </template>
 
@@ -79,6 +82,11 @@
                 ]
             }
         },
+        computed:{
+            currentIndex(){
+                return this.$store.state.currentIndex
+            }
+        },
         watch: {
             $route: function () {
                 console.log( this.$route)
@@ -99,4 +107,9 @@
         margin-left: auto;
         margin-right: auto;
     }
+    .current-baled{
+        color:#1874ff;
+        float: right;
+        margin-right: 10px;
+    }
 </style>

+ 2 - 3
src/main.js

@@ -3,13 +3,12 @@ import App from './App.vue'
 import 'babel-polyfill'
 import router from './router'
 import echarts from 'echarts'
-import $ from 'jquery'
 Vue.prototype.$echarts = echarts
 Vue.config.productionTip = false
 import "./assets/css/app.scss"
 import ViewUI from 'view-design'
 import 'view-design/dist/styles/iview.css';
-
+import store from './store'
 import "./assets/css/iview_style_reset.scss"
 //
 require('./utils/eLang.js')
@@ -53,4 +52,4 @@ const popTip = function (el, title, icon, fn, type = 'ghost') {
 }
 window.popTip = popTip
 
-new Vue({ router, render: h => h(App), }).$mount('#app')
+new Vue({ router,store, render: h => h(App), }).$mount('#app')

+ 26 - 0
src/store/index.js

@@ -0,0 +1,26 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+
+
+
+Vue.use(Vuex);
+
+const store = new Vuex.Store({
+    state: {
+        // 状态
+        currentIndex: sessionStorage.getItem('currentIndex')
+    },
+    mutations: {
+        // 改变方法
+        setIndex(state, index){
+            sessionStorage.setItem('currentIndex', index)
+            state.currentIndex = index
+        }
+    },
+    actions: {
+
+    },
+
+});
+
+export default store;

+ 42 - 21
src/views/dashbord.vue

@@ -1,23 +1,19 @@
 <template>
 	<div class="dashbord-context">
-		<div class='dashboard_box'>
-			<h3 style="padding-left: 5px;" class="dashboard_box_h3"> <strong>总览</strong>
-				<span style="font-size: 12px;">总览网页提供设备和远程服务器的总体状态信息。</span>
-			</h3>
-		</div>
+
 		<div class="dashboard_box_sub">
 			<div class="sub_left">
 				<Row>
 					<Col span="24">
 					<div class="dashboard_chat">
 						<div class='dashboard_item_title' style='padding-left: 20px;margin-bottom: 10px'>
-							<Strong>使能机箱管理</Strong>
+							<Strong>XXX机箱</Strong>
 <!--							<i-switch class='switch' v-model="serMode" @on-change="change" />-->
 						</div>
 						<div class='model-contect'>
 							<ul>
 								<template v-for='(item, index) in serverList'>
-									<li :class="item.cardIndex == chassisInfo.curIndex ? 'active' : 'off'" @click="checkIndex(index)">
+									<li :class="index == currentIndex ? 'active' : 'off'" :style="getCursor(item.status)" @click="checkIndex(index, item.status)">
 										<img class="svg checked-card" id="svg1" src="../assets/checked-card.png">
 										<template v-if='item.status == 0'>
 											<span class="active_span off_span">Status</span>
@@ -39,7 +35,7 @@
 						</div>
 					</div>
 					</Col>
-					<Col span="24">
+                    <Col span="24">
                         <div class="dashboard_item">
                             <div class="dashboard_item_title">
                                 BMC设备信息
@@ -68,7 +64,7 @@
 
                             </div>
                         </div>
-					</Col>
+                    </Col>
 
 				</Row>
 			</div>
@@ -133,6 +129,8 @@
 
                             </div>
                         </div>
+
+
 					</Col>
 				</Row>
 			</div>
@@ -162,8 +160,8 @@ export default {
 				{
 					cardIndex: 2,
 					senserName: 'aa',
-					status: 0,
-					power: 0,
+					status: 1,
+					power: 1,
 					isError: false,
 					isOnline: 1,
 					isMainCard: false,
@@ -184,14 +182,27 @@ export default {
             sysInfo: {},
             chassisInfo: {},
             bladeInfo: {},
-            sensorsList: []
+            sensorsList: [],
 		}
 	},
     created() {},
     mounted()  {
         this.init();
+    },
+    computed:{
+	    currentIndex(){
+	        return this.$store.state.currentIndex
+        }
     },
 	methods: {
+        getCursor(status){
+            if(status == 1){
+                return {
+                    cursor: 'pointer'
+                }
+            }
+
+        },
         getImg(status){
             if(status == 1) {
                 return this.okImg
@@ -203,11 +214,11 @@ export default {
 
         },
 	    async init(){
-            this.getDeviceInfo()
-            this.getSysInfo()
-            await this.getChassisInfo()
-            this.getAllBladeInfo()
-            this.getAllSensorInfo()
+            await this.getAllBladeInfo()
+            await this.getDeviceInfo()
+            await this.getSysInfo()
+            // await this.getChassisInfo()
+            await this.getAllSensorInfo()
         },
 
         getDeviceInfo() {
@@ -216,8 +227,11 @@ export default {
                 200 == e.code && (t.deviceInfo = e.data)
             })
         },
-        checkIndex(index){
-            sessionStorage.setItem('currentIndex', index)
+        checkIndex(index, status){
+            if(!!!status) {
+                return
+            }
+            this.$store.commit('setIndex', index)
             this.init();
         },
         getSysInfo() {
@@ -244,10 +258,17 @@ export default {
             }))
 
         },
-        getAllBladeInfo: function() {
+        async getAllBladeInfo() {
             var t = this;
-            api.Get("/action/getAllBladeInfo", {}).then(res => {
+            await api.Get("/action/getAllBladeInfo", {}).then(res => {
                 if(200 == res.code){
+                    let i;
+                    for(i = 0; i < res.data.length; i ++ ){
+                        if(res.data[i].isChMC == 1) {
+                            this.currentIndex = i
+                            this.$store.commit('setIndex', i)
+                        }
+                    }
                     t.serverList = res.data
                 } else {
                     this.$Message.error(res.msg)

+ 1 - 1
src/views/index.vue

@@ -49,7 +49,7 @@
     }
 
     .content {
-        width: 1200px;
+        width: 1180px;
         margin: 10px auto;
         min-height: 800px;
         /*overflow-y: scroll;*/

+ 1 - 0
src/views/login.vue

@@ -66,6 +66,7 @@ export default {
               if (valid) {
                   let res = await api.Get('/action/login', this.formInline)
                   if(res.code == 200) {
+                      sessionStorage.setItem('uesrname', this.formInline.username)
                       this.$Message.success('登录成功!');
                       this.$router.push({path: this.$route.query.redirect || '/index/dashbord'}).catch((e) => {console.log(e)});
                   } else {

Some files were not shown because too many files changed in this diff