Browse Source

管理员开启与关闭系统

Q-ABAB 1 year ago
parent
commit
a81e4e1d36

+ 0 - 1
src/App.vue

@@ -22,7 +22,6 @@ export default {
   methods: {
     homeExit() {
       window.location.href = "http://10.16.30.130/sso/caslogout.jsp";
-
     },
     // userLogin(){
     //   this.ajax.post(this.$store.state.api+'/userLogin',{

+ 3 - 3
src/config/config.js

@@ -1,6 +1,5 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
-import router from '@/router'
 
 Vue.use(Vuex)
 
@@ -13,13 +12,14 @@ const store = new Vuex.Store({
             username: "",
             type:2,
         },
+        systemState:1,
         nCount: 0,
         report: "",
         // api: 'https://pbl.cocorobo.cn/api/pbl/',
         // socket: "https://poll.cocorobo.cn",
         // socket: "http://localhost:1473",
-        // api: 'http://10.3.16.226:7003/api',
-        api:'http://10.16.30.130:7003/api',//服务器
+        api: 'http://10.3.16.226:7003/api',//qgt后端
+        // api:'http://10.16.30.130:7003/api',//服务器
         // api: 'http://127.0.0.1:7003/api',
         // api: 'http://10.3.13.84:7003/api',
 

+ 32 - 13
src/permission.js

@@ -15,7 +15,6 @@ function userLogin(callback){
         store.commit('update',['userInfo',res['data']]);
         callback()
         flag = true;
-
     }else{
       console.error("错误")
     }
@@ -24,8 +23,23 @@ function userLogin(callback){
   })
 }
 
+function getSystemState(to,callback){
+  ajax.get(store.state.api+'/getSystemState',{
+    uid:store.state.userInfo.userid
+  }).then(res=>{
+    let state = res['data'][0][0]['state'];
+    store.commit('update',['systemState',state]);
+    if(state!=0&&store.state.userInfo.type!=0&&to.name!='CloseWeb')return router.push('/CloseWeb');
+    if(state==0&&to.name=='CloseWeb')return router.push('/projectApplication');
+    callback(state);
+  }).catch(err=>{
+    console.log(err)
+  })
+}
+
 router.beforeEach(async(to, from, next) => {
     // set page title
+
     try {
         const response = await ajax.get('http://10.16.30.130/sso/api');
         console.log(response);
@@ -33,29 +47,34 @@ router.beforeEach(async(to, from, next) => {
         if (data && JSON.parse(data).uid) {
             setToken(JSON.parse(data).uid);
             userLogin(()=>{
-              next()
+              getSystemState(to,()=>{
+                next()
+              })
             });
 
         } else {
             // setToken('2021400203')//yym
-            // setToken("201901766");//qgt
+            setToken("201901766");//qgt
             // setToken("201901763");
             // setToken('1270')
-            // userLogin(()=>{
-            //   next()
-            // });
-            window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
+            userLogin(()=>{
+              getSystemState(to,()=>{
+                next()
+              })
+            });
+            // window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
         }
     } catch {
         // setToken('2021400203')//yym
-        // setToken("201901766");//qgt
+        setToken("201901766");//qgt
         // setToken("201901763");
         // setToken('1270')
-        // userLogin(()=>{
-        //   next()
-        // });
-        // next();
-        window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
+        userLogin(()=>{
+          getSystemState(to,()=>{
+            next()
+          })
+        });
+        // window.location.href = "http://10.16.30.130/sso/caslogin.jsp";
     }
     // determine whether the user has logged in
 

+ 13 - 0
src/router/index.js

@@ -45,6 +45,12 @@ const routes = [{
         meta: { isAuth: true,checkPower:true }
 
     },
+    {//管理员关闭页面
+        name:"CloseWeb",
+        path:"/CloseWeb",
+        component:()=>import('@/views/closeWeb.vue'),
+        meta: { isAuth: true,checkPower:false }
+    },
     {
         name: 'home',
         path: '/home',
@@ -204,6 +210,12 @@ const routes = [{
                 component:()=>import('@/views/projectApply/MakerSpaceApply.vue'),
                 meta:{isAuth:true,checkPower:false}
             },
+            {//系统管理
+                name:"system",
+                path:"/system",
+                component:()=>import('@/views/system'),
+                meta:{isAuth:true,checkPower:true}
+            },
         ]
     }
 ]
@@ -215,6 +227,7 @@ const router = new VueRouter({
 })
 
 router.beforeEach((to,from,next)=>{
+    // if(store.state.userInfo.type!=0&&store.state.systemState!=0&&to.name!='CloseWeb')router.push('/CloseWeb');
     if(to.meta.checkPower){
         if(store.state.userInfo.type==0){
             next();

+ 36 - 0
src/views/closeWeb.vue

@@ -0,0 +1,36 @@
+<template>
+    <div id="closeWeb">
+        <h1 class="closeMsg">管理员已关闭网站,请与管理员联系</h1>
+    </div>
+</template>
+
+<script>
+export default {
+        components:{
+
+          },
+        data() {
+          return {
+            closeWeb:false,
+            loading:false,
+          }
+        },
+        mounted(){
+
+        }
+      }
+</script>
+
+
+<style lang="less" scoped>
+#closeWeb{
+    width: 100%;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    .closeMsg{
+        margin-top: 40px;
+        color: gray;
+    }
+}
+</style>

+ 1 - 0
src/views/home.vue

@@ -72,6 +72,7 @@
             {id:8,label:"创业公司登记",power:true,goto:"/firm",icon:"iconfont icon-zuzhijiegou",group:[]},
             {id:9,label:"消息通知",power:false,goto:"/messageNotification",icon:"iconfont icon-xiaoxitongzhi3",group:[]},
             {id:10,label:"数据监测",power:true,goto:"/echarts",icon:"iconfont icon-qushi",group:[]},
+            {id:11,label:"系统管理",power:true,goto:"/system",icon:"el-icon-setting",group:[]},
           ]
         }
       },

+ 1 - 1
src/views/projectApply/components/MakerSpaceWordDetail.vue

@@ -1,7 +1,7 @@
 <template>
     <div id="MakerSpaceWordDetail" v-loading="loading">
         <MakerSpaceWord :wordData="wordData" v-if="state==0"/>
-        <MakerSpaceWordShow :wordData="wordData" v-if="state!=0"/>
+        <MakerSpaceWordShow :wordData="wordData" v-show="state!=0"/>
         <div>
             <el-button type="primary" @click="getWord">下载表格</el-button>
             <el-button type="primary" @click="test" v-if="state==0">立即修改</el-button>

+ 87 - 0
src/views/system.vue

@@ -0,0 +1,87 @@
+<template>
+    <!-- 消息通知 -->
+    <div id="system" v-loading="loading">
+      <div class="pAHeader">
+        <div class="pAHeader1">系统管理</div>
+      </div>
+      <hr>
+      <div id="SystemBtn">
+        <div class="setSystemBtn">
+            <span>关闭网站</span>
+            <el-switch
+              v-model="closeWeb"
+              @change="ChangeCloseWebState"
+              active-color="#13ce66"
+              inactive-color="#ff4949">
+            </el-switch>
+        </div>
+      </div>
+    </div>
+  </template>
+  
+  <script>
+      export default {
+        components:{
+
+          },
+        data() {
+          return {
+            closeWeb:false,
+            loading:false,
+          }
+        },
+        methods:{
+            ChangeCloseWebState(){
+                this.loading = true;
+                this.ajax.post(this.$store.state.api+'/setSystemState',{
+                    uid:this.$store.state.userInfo.userid,
+                    st:Number(this.closeWeb)
+                }).then(res=>{
+                    if(res['data']==1){
+                        this.$message.success(`更改系统状态成功`);
+                        this.getCloseData();
+                    }
+                }).catch(err=>{
+                    console.log(err);
+                })
+            },
+            getCloseData(){
+                this.loading = true;
+                this.ajax.get(this.$store.state.api+'/getSystemState',{
+                    uid:this.$store.state.userInfo.userid
+                }).then(res=>{
+                    let state = res['data'][0][0]['state'];
+                    //是否关闭网站
+                    this.closeWeb = Boolean(state);
+                    this.loading = false;
+                }).catch(err=>{
+                    console.log(err)
+                })
+            },
+        },
+        watch:{
+
+      },
+        mounted(){
+            this.getCloseData();
+        }
+        
+      }
+  </script>
+  
+  <style lang="less" scoped>
+  #system{
+    width: 100%;
+    height: 100%;
+    #SystemBtn{
+        margin-top: 40px;
+        width: 100%;
+        .setSystemBtn{
+            font-size: 18px;
+            span{
+                margin-right: 10px;
+            }
+        }
+    }
+  }
+  </style>