Browse Source

前端页面布局修改,后台数据库结构变化,需要重新导入数据库才可使用

main
pixel 5 years ago
parent
commit
02bb58a3a0
  1. 2
      QMPlusServer/model/dbModel/exa_fileUploadAndDownload.go
  2. 13
      QMPlusServer/model/sysModel/sys_base_menu.go
  3. 4
      QMPlusServer/model/sysModel/sys_menu_authority.go
  4. 16
      QMPlusVuePage/src/App.vue
  5. 76
      QMPlusVuePage/src/view/layout/index.vue

2
QMPlusServer/model/dbModel/exa_fileUploadAndDownload.go

@ -21,7 +21,7 @@ func (f *ExaFileUploadAndDownload) Upload() error {
} }
func (f *ExaFileUploadAndDownload) DeleteFile() error { func (f *ExaFileUploadAndDownload) DeleteFile() error {
err := qmsql.DEFAULTDB.Where("id = ?", f.ID).Delete(f).Error
err := qmsql.DEFAULTDB.Where("id = ?", f.ID).Unscoped().Delete(f).Error
return err return err
} }

13
QMPlusServer/model/sysModel/sys_base_menu.go

@ -17,6 +17,7 @@ type SysBaseMenu struct {
Name string `json:"name"` Name string `json:"name"`
Hidden bool `json:"hidden"` Hidden bool `json:"hidden"`
Component string `json:"component"` Component string `json:"component"`
Sort string `json:"sort"`
Meta `json:"meta"` Meta `json:"meta"`
NickName string `json:"nickName"` NickName string `json:"nickName"`
Children []SysBaseMenu `json:"children"` Children []SysBaseMenu `json:"children"`
@ -53,9 +54,10 @@ func (b *SysBaseMenu) UpdataBaseMenu() (err error) {
upDataMap["component"] = b.Component upDataMap["component"] = b.Component
upDataMap["title"] = b.Title upDataMap["title"] = b.Title
upDataMap["icon"] = b.Icon upDataMap["icon"] = b.Icon
upDataMap["sort"] = b.Sort
err = qmsql.DEFAULTDB.Where("id = ?", b.ID).Find(&SysBaseMenu{}).Updates(upDataMap).Error err = qmsql.DEFAULTDB.Where("id = ?", b.ID).Find(&SysBaseMenu{}).Updates(upDataMap).Error
err1 := qmsql.DEFAULTDB.Where("menu_id = ?", b.ID).Find(&[]SysMenu{}).Updates(upDataMap).Error err1 := qmsql.DEFAULTDB.Where("menu_id = ?", b.ID).Find(&[]SysMenu{}).Updates(upDataMap).Error
fmt.Printf("菜单修改时候,关联菜单err:%v", err1)
fmt.Printf("菜单修改时候,关联菜单err1:%v,err:%v", err1, err)
return err return err
} }
@ -71,14 +73,17 @@ func (b *SysBaseMenu) GetInfoList(info modelInterface.PageInfo) (err error, list
return return
} else { } else {
var menuList []SysBaseMenu var menuList []SysBaseMenu
err = db.Find(&menuList).Error
err = db.Where("parent_id = 0").Order("sort", true).Find(&menuList).Error
for i := 0; i < len(menuList); i++ {
err = getBaseChildrenList(&menuList[i])
}
return err, menuList, total return err, menuList, total
} }
} }
//获取基础路由树 //获取基础路由树
func (m *SysBaseMenu) GetBaseMenuTree() (err error, menus []SysBaseMenu) { func (m *SysBaseMenu) GetBaseMenuTree() (err error, menus []SysBaseMenu) {
err = qmsql.DEFAULTDB.Where(" parent_id = ?", 0).Find(&menus).Error
err = qmsql.DEFAULTDB.Where(" parent_id = ?", 0).Order("sort", true).Find(&menus).Error
for i := 0; i < len(menus); i++ { for i := 0; i < len(menus); i++ {
err = getBaseChildrenList(&menus[i]) err = getBaseChildrenList(&menus[i])
} }
@ -86,7 +91,7 @@ func (m *SysBaseMenu) GetBaseMenuTree() (err error, menus []SysBaseMenu) {
} }
func getBaseChildrenList(menu *SysBaseMenu) (err error) { func getBaseChildrenList(menu *SysBaseMenu) (err error) {
err = qmsql.DEFAULTDB.Where("parent_id = ?", menu.ID).Find(&menu.Children).Error
err = qmsql.DEFAULTDB.Where("parent_id = ?", menu.ID).Order("sort", true).Find(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ { for i := 0; i < len(menu.Children); i++ {
err = getBaseChildrenList(&menu.Children[i]) err = getBaseChildrenList(&menu.Children[i])
} }

4
QMPlusServer/model/sysModel/sys_menu_authority.go

@ -43,7 +43,7 @@ func (m *SysMenu) GetMenuAuthority(authorityId string) (err error, menus []SysMe
//获取动态路由树 //获取动态路由树
func (m *SysMenu) GetMenuTree(authorityId string) (err error, menus []SysMenu) { func (m *SysMenu) GetMenuTree(authorityId string) (err error, menus []SysMenu) {
err = qmsql.DEFAULTDB.Where("authority_id = ? AND parent_id = ?", authorityId, 0).Find(&menus).Error
err = qmsql.DEFAULTDB.Where("authority_id = ? AND parent_id = ?", authorityId, 0).Order("sort", true).Find(&menus).Error
for i := 0; i < len(menus); i++ { for i := 0; i < len(menus); i++ {
err = getChildrenList(&menus[i]) err = getChildrenList(&menus[i])
} }
@ -51,7 +51,7 @@ func (m *SysMenu) GetMenuTree(authorityId string) (err error, menus []SysMenu) {
} }
func getChildrenList(menu *SysMenu) (err error) { func getChildrenList(menu *SysMenu) (err error) {
err = qmsql.DEFAULTDB.Where("authority_id = ? AND parent_id = ?", menu.AuthorityId, menu.MenuId).Find(&menu.Children).Error
err = qmsql.DEFAULTDB.Where("authority_id = ? AND parent_id = ?", menu.AuthorityId, menu.MenuId).Order("sort", true).Find(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ { for i := 0; i < len(menu.Children); i++ {
err = getChildrenList(&menu.Children[i]) err = getChildrenList(&menu.Children[i])
} }

16
QMPlusVuePage/src/App.vue

@ -5,22 +5,18 @@
</template> </template>
<script> <script>
export default { export default {
name: 'app', name: 'app',
components: {
},
components: {}
} }
</script> </script>
<style lang="scss"> <style lang="scss">
// //
@import '@/style/main.scss';
@import '@/style/base.scss';
#app{
@import '@/style/main.scss';
@import '@/style/base.scss';
#app {
background: #eee; background: #eee;
}
height: 100vh;
}
</style> </style>

76
QMPlusVuePage/src/view/layout/index.vue

@ -2,15 +2,16 @@
<el-container class="layout-cont"> <el-container class="layout-cont">
<el-container> <el-container>
<el-aside class="main-cont main-left"> <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" /> <Aside class="aside" />
</el-aside> </el-aside>
<!-- 分块滑动功能 --> <!-- 分块滑动功能 -->
<el-main class="main-cont main-right"> <el-main class="main-cont main-right">
<el-header class="header-cont"> <el-header class="header-cont">
<div @click="totalCollapse" class="menu-total">
<i class="el-icon-s-unfold" v-if="isCollapse"></i>
<i class="el-icon-s-fold" v-else></i>
</div>
<h1 class="admin-title">Gin-Vue-Admin</h1>
<div class="fl-right right-box"> <div class="fl-right right-box">
<el-dropdown> <el-dropdown>
<span class="el-dropdown-link"> <span class="el-dropdown-link">
@ -32,15 +33,16 @@
</div> </div>
</el-header> </el-header>
<!-- 当前面包屑用路由自动生成可根据需求修改 --> <!-- 当前面包屑用路由自动生成可根据需求修改 -->
<!--
:to="{ path: item.path }" 暂时注释不用-->
<el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right"> <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
<el-breadcrumb-item <el-breadcrumb-item
:key="item.path" :key="item.path"
:to="{ path: item.path }"
v-for="item in matched.slice(1,matched.length)" v-for="item in matched.slice(1,matched.length)"
>{{item.meta.title}}</el-breadcrumb-item> >{{item.meta.title}}</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<router-view></router-view>
<router-view class="admin-box"></router-view>
</transition> </transition>
</el-main> </el-main>
</el-container> </el-container>
@ -52,9 +54,9 @@ import Aside from '@/view/layout/aside'
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
export default { export default {
name: 'Layout', name: 'Layout',
data(){
return{
isCollapse:false
data() {
return {
isCollapse: false
} }
}, },
components: { components: {
@ -63,6 +65,7 @@ export default {
methods: { methods: {
...mapMutations('user', ['LoginOut']), ...mapMutations('user', ['LoginOut']),
totalCollapse() { totalCollapse() {
this.isCollapse = !this.isCollapse
this.$bus.emit('totalCollapse') this.$bus.emit('totalCollapse')
}, },
toPerson() { toPerson() {
@ -77,22 +80,13 @@ export default {
matched() { matched() {
return this.$route.matched return this.$route.matched
} }
},
created(){
this.$bus.on('totalCollapse', () => {
this.isCollapse = !this.isCollapse
console.log(this.isCollapse)
})
},
beforeDestroy() {
this.$bus.off('totalCollapse')
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
$headerHigh: 52px; $headerHigh: 52px;
$mainHight: calc(100vh - 52px);
$mainHight: 100vh;
.el-dropdown-link { .el-dropdown-link {
cursor: pointer; cursor: pointer;
} }
@ -122,7 +116,7 @@ $mainHight: calc(100vh - 52px);
.header-cont { .header-cont {
height: $headerHigh !important; height: $headerHigh !important;
background: #fff; background: #fff;
border-bottom: 1px solid #ccc;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
line-height: $headerHigh; line-height: $headerHigh;
} }
.main-cont { .main-cont {
@ -141,16 +135,20 @@ $mainHight: calc(100vh - 52px);
overflow: visible; overflow: visible;
position: relative; position: relative;
.menu-total { .menu-total {
z-index: 5;
position: absolute;
top: 50%;
margin-top: -10px;
line-height: 20px;
font-size: 20px;
border: 0 solid #ffffff;
border-radius: 50%;
right: -10px;
background: #fff;
// z-index: 5;
// position: absolute;
// top: 10px;
// right: -35px;
margin-left: -10px;
float: left;
margin-top: 10px;
width: 30px;
height: 30px;
line-height: 30px;
font-size: 30px;
// border: 0 solid #ffffff;
// border-radius: 50%;
// background: #fff;
} }
.aside { .aside {
overflow: auto; overflow: auto;
@ -161,10 +159,10 @@ $mainHight: calc(100vh - 52px);
} }
.el-menu-vertical { .el-menu-vertical {
height: calc(100vh - 60px) !important;
height: 100vh !important;
visibility: auto; visibility: auto;
&:not(.el-menu--collapse) { &:not(.el-menu--collapse) {
width: 250px;
width: 220px;
} }
} }
@ -173,19 +171,17 @@ $mainHight: calc(100vh - 52px);
} }
&.main-left { &.main-left {
width: auto !important; width: auto !important;
}
&.main-right {
.admin-title { .admin-title {
padding-left: 10px;
font-size: 18px;
float: left;
font-size: 16px;
vertical-align: middle; vertical-align: middle;
width: 240px;
background:#0F3D5F;
color: #fff;
margin-left: 20px;
img { img {
vertical-align: middle; vertical-align: middle;
} }
height: 60px;
line-height: 60px;
&.collapse{
&.collapse {
width: 53px; width: 53px;
} }
} }

Loading…
Cancel
Save