Browse Source

前端ui调整

pixel 5 years ago
parent
commit
ef433ef430

+ 0 - 19
QMPlusServer/controller/api/sys_api.go

@@ -60,25 +60,6 @@ type AuthAndPathIn struct {
 	ApiIds      []uint `json:"apiIds"`
 }
 
-// @Tags SysApi
-// @Summary 创建api和角色关系
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body api.AuthAndPathIn true "创建api和角色关系"
-// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
-// @Router /api/setAuthAndApi [post]
-func SetAuthAndApi(c *gin.Context) {
-	var authAndPathIn AuthAndPathIn
-	_ = c.BindJSON(&authAndPathIn)
-	err := new(sysModel.SysApiAuthority).SetAuthAndApi(authAndPathIn.AuthorityId, authAndPathIn.ApiIds)
-	if err != nil {
-		servers.ReportFormat(c, false, fmt.Sprintf("添加失败:%v", err), gin.H{})
-	} else {
-		servers.ReportFormat(c, true, "添加成功", gin.H{})
-	}
-}
-
 //条件搜索后端看此api
 
 // @Tags SysApi

+ 0 - 20
QMPlusServer/controller/api/sys_authority.go

@@ -89,23 +89,3 @@ type GetAuthorityId struct {
 	AuthorityId string `json:"authorityId"`
 }
 
-// @Tags authority
-// @Summary 获取本角色所有有权限的apiId
-// @Security ApiKeyAuth
-// @accept application/json
-// @Produce application/json
-// @Param data body api.GetAuthorityId true "获取本角色所有有权限的apiId"
-// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
-// @Router /authority/getAuthAndApi [post]
-func GetAuthAndApi(c *gin.Context){
-	var idInfo GetAuthorityId
-	_ = c.BindJSON(&idInfo)
-	err,apis := new(sysModel.SysApiAuthority).GetAuthAndApi(idInfo.AuthorityId)
-	if err != nil {
-		servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{})
-	} else {
-		servers.ReportFormat(c, true, "获取数据成功", gin.H{
-			"apis": apis,
-		})
-	}
-}

+ 0 - 1
QMPlusServer/init/registTable/regist_table.go

@@ -12,7 +12,6 @@ func RegistTable(db *gorm.DB) {
 		sysModel.SysAuthority{},
 		sysModel.SysMenu{},
 		sysModel.SysApi{},
-		sysModel.SysApiAuthority{},
 		sysModel.SysBaseMenu{},
 		dbModel.ExaFileUploadAndDownload{},
 		sysModel.SysWorkflow{},

+ 1 - 1
QMPlusServer/model/sysModel/sys_api.go

@@ -27,7 +27,7 @@ func (a *SysApi) CreateApi() (err error) {
 
 func (a *SysApi) DeleteApi() (err error) {
 	err = qmsql.DEFAULTDB.Delete(a).Error
-	err = qmsql.DEFAULTDB.Where("api_id = ?", a.ID).Unscoped().Delete(&SysApiAuthority{}).Error
+	new(CasbinModel).clearCasbin(1,a.Path)
 	return err
 }
 

+ 0 - 35
QMPlusServer/model/sysModel/sys_api_authority.go

@@ -1,35 +0,0 @@
-package sysModel
-
-import (
-	"github.com/jinzhu/gorm"
-	"main/init/qmsql"
-)
-
-type SysApiAuthority struct {
-	gorm.Model
-	AuthorityId string
-	Authority   SysAuthority `gorm:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId"` //其实没有关联的必要
-	ApiId       uint
-	Api         SysApi
-}
-
-//创建角色api关联关系
-func (a *SysApiAuthority) SetAuthAndApi(authId string, apisid []uint) (err error) {
-	for _, v := range apisid {
-		err = qmsql.DEFAULTDB.Create(&SysApiAuthority{AuthorityId: authId, ApiId: v}).Error
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-// 获取角色api关联关系
-func (a *SysApiAuthority) GetAuthAndApi(authId string) (err error,apiIds []uint) {
-	var apis []SysApiAuthority
-	err = qmsql.DEFAULTDB.Where("authority_id = ?", authId).Find(&apis).Error
-	for _, v := range apis {
-		apiIds = append(apiIds,v.ApiId)
-	}
-	return nil,apiIds
-}

+ 0 - 2
QMPlusServer/router/sys_api.go

@@ -11,12 +11,10 @@ func InitApiRouter(Router *gin.Engine)(R gin.IRoutes) {
 	{
 		ApiRouter.POST("createApi", api.CreateApi)  //创建Api
 		ApiRouter.POST("deleteApi", api.DeleteApi)  //删除Api
-		ApiRouter.POST("setAuthAndApi",api.SetAuthAndApi) // 设置api和角色关系
 		ApiRouter.POST("getApiList",api.GetApiList)  //获取Api列表
 		ApiRouter.POST("getApiById",api.GetApiById)  //获取单条Api消息
 		ApiRouter.POST("updataApi",api.UpdataApi)   //更新api
 		ApiRouter.POST("getAllApis",api.GetAllApis) // 获取所有api
-		ApiRouter.POST("getAuthAndApi",api.GetAuthAndApi) // 获取api和auth关系
 	}
 	return ApiRouter
 }

+ 11 - 3
QMPlusVuePage/src/view/layout/aside/index.vue

@@ -4,20 +4,23 @@
       <i class="el-icon-arrow-right" v-if="isCollapse"></i>
       <i class="el-icon-arrow-left" v-else></i>
     </div>
-    <el-scrollbar style="height:calc(100vh - 52px)">
-      <transition name="el-zoom-in-top">
+    <el-scrollbar style="height:calc(100vh - 60px)">
+       
         <el-menu
+          :collapse-transition="true"
           :class="['el-menu-vertical',!isCollapse&&'noCollapse']"
           :collapse="isCollapse"
           :default-active="active"
           @select="selectMenuItem"
           unique-opened
+          background-color="#0F3D5F"
+          text-color="#bbb"
+          active-text-color="#fff"
         >
           <template v-for="item in asyncRouters[0].children">
             <aside-component :key="item.name" :routerInfo="item" v-if="!item.hidden" />
           </template>
         </el-menu>
-      </transition>
     </el-scrollbar>
   </div>
 </template>
@@ -58,6 +61,11 @@ export default {
 </script>
 
 <style lang="scss">
+.el-scrollbar{
+  .el-scrollbar__view{
+    height: 100%;
+  }
+}
 .menu-info {
   .menu-contorl {
     line-height: 52px;

+ 60 - 36
QMPlusVuePage/src/view/layout/index.vue

@@ -1,34 +1,36 @@
 <template>
   <el-container class="layout-cont">
-    <el-header class="header-cont">
-      <h1 class="fl-left left-box">
-        <img :src="require('@/assets/logo.png')" height="40" width="40">
-        Gin-Vue-Admin</h1>
-      <div class="fl-right right-box">
-        <el-dropdown>
-          <span class="el-dropdown-link">
-            <img :src="userInfo.headerImg" height="30" width="30" />
-            {{userInfo.nickName}}
-            <i class="el-icon-arrow-down"></i>
-          </span>
-          <el-dropdown-menu class="dropdown-group" slot="dropdown">
-            <el-dropdown-item>
-              <span>更多信息
-                <el-badge is-dot />
-              </span>
-            </el-dropdown-item>
-            <el-dropdown-item @click.native="toPerson" icon="el-icon-s-custom">个人信息</el-dropdown-item>            
-            <el-dropdown-item @click.native="LoginOut" icon="el-icon-table-lamp"> 登 出 </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
-      </div>
-    </el-header>
     <el-container>
       <el-aside class="main-cont main-left">
+        <h1 class="admin-title" :class="isCollapse&&'collapse'">
+          <img :src="require('@/assets/logo.png')" height="40" width="40" />
+          Gin-Vue-Admin
+        </h1>
         <Aside class="aside" />
       </el-aside>
       <!-- 分块滑动功能 -->
       <el-main class="main-cont main-right">
+        <el-header class="header-cont">
+          <div class="fl-right right-box">
+            <el-dropdown>
+              <span class="el-dropdown-link">
+                <img :src="userInfo.headerImg" height="30" width="30" />
+                {{userInfo.nickName}}
+                <i class="el-icon-arrow-down"></i>
+              </span>
+              <el-dropdown-menu class="dropdown-group" slot="dropdown">
+                <el-dropdown-item>
+                  <span>
+                    更多信息
+                    <el-badge is-dot />
+                  </span>
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="toPerson" icon="el-icon-s-custom">个人信息</el-dropdown-item>
+                <el-dropdown-item @click.native="LoginOut" icon="el-icon-table-lamp">登 出</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </div>
+        </el-header>
         <!-- 当前面包屑用路由自动生成可根据需求修改 -->
         <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
           <el-breadcrumb-item
@@ -50,17 +52,21 @@ import Aside from '@/view/layout/aside'
 import { mapGetters, mapMutations } from 'vuex'
 export default {
   name: 'Layout',
+  data(){
+    return{
+      isCollapse:false
+    }
+  },
   components: {
     Aside
   },
   methods: {
-    
     ...mapMutations('user', ['LoginOut']),
     totalCollapse() {
       this.$bus.emit('totalCollapse')
     },
-    toPerson(){
-      this.$router.push({name:"person"})
+    toPerson() {
+      this.$router.push({ name: 'person' })
     }
   },
   computed: {
@@ -71,6 +77,15 @@ export default {
     matched() {
       return this.$route.matched
     }
+  },
+  created(){
+    this.$bus.on('totalCollapse', () => {
+      this.isCollapse = !this.isCollapse
+      console.log(this.isCollapse)
+    })
+  },
+  beforeDestroy() {
+    this.$bus.off('totalCollapse')
   }
 }
 </script>
@@ -88,12 +103,6 @@ $mainHight: calc(100vh - 52px);
   padding-bottom: 17px;
 }
 .layout-cont {
-  .left-box{
-    vertical-align: middle;
-    img{
-      vertical-align: middle;
-    }
-  }
   .right-box {
     text-align: center;
     vertical-align: middle;
@@ -126,7 +135,6 @@ $mainHight: calc(100vh - 52px);
     &.el-main {
       overflow: auto;
       padding: 0px 10px;
-      margin: 0px 0px 0px 12px;
       background: #fff;
     }
     height: $mainHight !important;
@@ -153,19 +161,35 @@ $mainHight: calc(100vh - 52px);
     }
 
     .el-menu-vertical {
-      height: calc(100vh - 69px) !important;
+      height: calc(100vh - 60px) !important;
       visibility: auto;
-      &.noCollapse {
+      &:not(.el-menu--collapse) {
         width: 250px;
       }
     }
+
     &::-webkit-scrollbar {
       display: none;
     }
     &.main-left {
       width: auto !important;
+      .admin-title {
+        padding-left: 10px;
+        font-size: 18px;
+        vertical-align: middle;
+        width: 240px;
+        background:#0F3D5F;
+        color: #fff;
+        img {
+          vertical-align: middle;
+        }
+        height: 60px;
+        line-height: 60px;
+        &.collapse{
+          width: 53px;
+        }
+      }
     }
-    background: blueviolet;
   }
 }
 </style>