Przeglądaj źródła

工时管家——后台管理系统,动态路由,增加客户端下载、官网登录增加提示性文字

ZhouRuiTing 5 lat temu
rodzic
commit
0750d6b720

+ 6 - 2
fhKeeper/formulahousekeeper/inva_4_tivo/css/styles.css

@@ -835,14 +835,18 @@ input[type='checkbox'] {
 }
 
 .cards-1 .card-image {
-	max-width: 16rem;
+	max-width: 12rem;
 	margin-right: auto;
 	margin-bottom: 2rem;
 	margin-left: auto;
 }
 
+.card-image .img-fluid {
+	width: 120px;
+}
+
 .cards-1 .card-title {
-	margin-bottom: 0.5rem;
+	margin-bottom: 1.5rem;
 }
 
 .cards-1 .card-body {

+ 3 - 0
fhKeeper/formulahousekeeper/inva_4_tivo/download.html

@@ -92,6 +92,9 @@
                         </div>
                     </div>
                 </div>
+                <div class="col-lg-12" style="color: #aaa;">
+                    员工安装客户端,领导即可查看工作桌面远程监管
+                </div>
             </div>
         </div>
     </div>

+ 53 - 11
fhKeeper/formulahousekeeper/timesheet/src/main.js

@@ -1,20 +1,19 @@
 // import Vue from 'vue'
-import App from './App'
-import store from './vuex/store'
-import routes from './routes'
-
 // import VueRouter from 'vue-router'
 // Vue.use(VueRouter)
-
 // import ElementUI from 'element-ui'
 // Vue.use(ElementUI)
-
 // import Vuex from 'vuex'
 // Vue.use(Vuex)
+// import echarts from 'echarts'
+// import 'element-ui/lib/theme-chalk/index.css'
+
+import App from './App'
+import store from './vuex/store'
+// import routes from './routes'
 
 import http from './http'
 import port from './port'
-// import echarts from 'echarts'
 import $ from 'jquery'
 
 Vue.prototype.http = http
@@ -24,17 +23,19 @@ Vue.prototype.echarts = echarts
 import VueClipboard from 'vue-clipboard2'
 Vue.use(VueClipboard)
 
-// import 'element-ui/lib/theme-chalk/index.css'
 import 'font-awesome/css/font-awesome.min.css'
 import './assets/iconfont/iconfont.css'
 
-const router = new VueRouter({
-    routes
-})
+// const router = new VueRouter({
+//     routes
+// })
+import { staffRouter, manageRouter, fixedRouter } from './routes'
+import router from './routes'
 
 import NProgress from 'nprogress'
 import 'nprogress/nprogress.css'
 
+var addRouFlag = false
 router.beforeEach((to, from, next) => {
     NProgress.start();
     if (to.path == '/register') {
@@ -50,10 +51,51 @@ router.beforeEach((to, from, next) => {
     if (!user && to.path != '/login') {
         next({ path: '/login' })
     } else {
+        if (!addRouFlag) {
+            addRouFlag = true
+            if(user != null) {
+                if(user.role == 0) {
+                    var getRoutes = baseRoleGetRouters(staffRouter, 1);
+                    global.antRouter = fixedRouter.concat(getRoutes);
+                    router.options.routes = fixedRouter.concat(getRoutes);
+                    router.addRoutes(fixedRouter.concat(getRoutes));
+                    router.push({ path: to.path })
+                } else {
+                    var getRoutes = baseRoleGetRouters(manageRouter, 1);
+                    global.antRouter = fixedRouter.concat(getRoutes);
+                    router.options.routes = fixedRouter.concat(getRoutes);
+                    router.addRoutes(fixedRouter.concat(getRoutes));
+                    router.push({ path: to.path })
+                }
+            }
+        }
         next()
     }
 })
 
+function baseRoleGetRouters(allRoutes, roles) {
+    // allRoutes是动态路由表
+    // roles是取到的用户角色,数组
+    let rightRoutes = allRoutes.filter((route, index) => {
+        if (true) {
+            if (route.children && route.children.length) {
+                route.children = baseRoleGetRouters(route.children, roles)
+            }
+            return true
+        }
+        return false
+    })
+    return rightRoutes
+}
+
+function hasPermission(route, roles) {
+    if (route.meta && route.meta.roles) {
+        return roles.some(role => route.meta.roles.indexOf(role) >= 0)
+    } else {
+        return true
+    }
+}
+
 router.afterEach(() => {
     NProgress.done()
 })

+ 36 - 16
fhKeeper/formulahousekeeper/timesheet/src/routes.js

@@ -1,3 +1,6 @@
+import Vue from 'vue'
+import Router from 'vue-router'
+
 import Login from './views/Login.vue'
 import Register from './views/Register.vue'
 import NotFound from './views/404.vue'
@@ -22,10 +25,9 @@ import depDetail from './views/project/detailDep.vue'
 // 团队管理
 import team from './views/team/index.vue'
 
-// 系统管理
-import system from './views/system/index.vue'
+Vue.use(Router)
 
-let routes = [
+export const fixedRouter = [
     {
         path: '/login',
         component: Login,
@@ -37,7 +39,10 @@ let routes = [
         component: Register,
         name: '',
         hidden: true
-    },
+    }
+]
+
+export const manageRouter = [
     //工作桌面
     {
         path: '/',
@@ -85,17 +90,6 @@ let routes = [
             { path: '/team', component: team, name: '组织架构' },
         ]
     },
-    //系统管理
-    // {
-    //     path: '/',
-    //     component: Home,
-    //     name: '',
-    //     iconCls: 'fa fa-cog',
-    //     leaf: true,//只有一个节点
-    //     children: [
-    //         { path: '/system', component: system, name: '系统管理' },
-    //     ]
-    // },
     {
         path: '/404',
         component: NotFound,
@@ -109,4 +103,30 @@ let routes = [
     }
 ];
 
-export default routes;
+export const staffRouter = [
+    //工作报告
+    {
+        path: '/',
+        component: Home,
+        name: '工作报告',
+        iconCls: 'fa fa-sticky-note',
+        children: [
+            { path: '/daily', component: daily, name: '工作日报' },
+        ]
+    },
+    {
+        path: '/404',
+        component: NotFound,
+        name: '',
+        hidden: true
+    },
+    {
+        path: '*',
+        hidden: true,
+        redirect: { path: '/404' }
+    }
+];
+
+export default new Router({
+    routes: fixedRouter
+})

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/404.vue

@@ -19,7 +19,7 @@
 		},
 		methods: {
             back() {
-                this.$router.push('/map');
+                this.$router.push('/login');
             }
         },
         created() {

+ 3 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/Home.vue

@@ -128,6 +128,7 @@
                 sysName: "工时管家",
                 collapsed: sessionStorage.collapsed!=null?(sessionStorage.collapsed=='true'?true:false):false,
                 sysUserName: "",
+                menu: [],
 
                 editInformation: false,
                 editPassWord: false,
@@ -165,6 +166,7 @@
                     //type: 'warning'
                 }).then(() => {
                     sessionStorage.removeItem("user");
+                    location.reload();
                     _this.$router.push("/login");
                 });
             },
@@ -293,7 +295,6 @@
                 this.user = user;
                 this.sysUserName = user.name || "";
                 if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
-                    // this.setTime();
                     this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
                 } else {
                     this.remainingTime = "已过期";
@@ -302,7 +303,7 @@
             } else {
                 this.$router.push("/login");
             }
-        }
+        },
     };
 </script>
 

+ 7 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/Login.vue

@@ -23,7 +23,7 @@
                             <p><span style="color: #333">QQ:</span><span id="QQ">3052894409</span></p>
                         </div>
                     </el-link>
-                    <el-link type="primary" style="margin-right:5px;" :underline="false"><a style="color:#409EFF;text-decoration:none" href="http://gsgj.ttkuaiban.com/download.html" download="工时管家">客户端下载</a></el-link>
+                    <el-link type="primary" style="margin-right:5px;" :underline="false"><a style="color:#409EFF;text-decoration:none" href="http://gsgj.ttkuaiban.com/download.html" target="_blank">客户端下载</a></el-link>
                     <el-link type="primary" @click="jumpTo" :underline="false">企业注册</el-link>
                 </div>
             </el-form>
@@ -65,7 +65,12 @@
                             this.logining = false;
                             if (res.code == "ok") {
                                 sessionStorage.setItem('user', JSON.stringify(res.data));
-                                this.$router.push({ path: '/desktop' });
+                                if(res.data.role == 0) {
+                                    this.$router.push({ path: '/daily' });
+                                } else {
+                                    this.$router.push({ path: '/desktop' });
+                                }
+                                location.reload();
                             } else {
                                 this.$message({
                                     message: res.msg,

+ 3 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/desktop/index.vue

@@ -19,6 +19,9 @@
                         placeholder="选择日期"
                     ></el-date-picker>
                 </el-form-item>
+                <el-form-item style="float:right;">
+                    <el-link type="primary" :underline="false" href="http://gsgj.ttkuaiban.com/download.html" target="_blank">客户端下载</el-link>
+                </el-form-item>
             </el-form>
         </el-col>