pixelqm
5 years ago
21 changed files with 502 additions and 39 deletions
-
29QMPlusServer/controller/api/authority.go
-
19QMPlusServer/model/dbModel/authority.go
-
1QMPlusServer/router/authority.go
-
5QMPlusVuePage/package-lock.json
-
1QMPlusVuePage/package.json
-
7QMPlusVuePage/src/App.vue
-
47QMPlusVuePage/src/api/authority.js
-
3QMPlusVuePage/src/main.js
-
2QMPlusVuePage/src/store/module/user.js
-
35QMPlusVuePage/src/style/base.scss
-
4QMPlusVuePage/src/utils/asyncRouter.js
-
18QMPlusVuePage/src/utils/bus.js
-
27QMPlusVuePage/src/view/dashbord/index.vue
-
2QMPlusVuePage/src/view/layout/aside/asideComponent/asyncSubmenu.vue
-
2QMPlusVuePage/src/view/layout/aside/asideComponent/menuItem.vue
-
40QMPlusVuePage/src/view/layout/aside/index.vue
-
77QMPlusVuePage/src/view/layout/index.vue
-
14QMPlusVuePage/src/view/superAdmin/api/api.vue
-
150QMPlusVuePage/src/view/superAdmin/authority/authority.vue
-
12QMPlusVuePage/src/view/superAdmin/index.vue
-
14QMPlusVuePage/src/view/superAdmin/menu/menu.vue
@ -0,0 +1,47 @@ |
|||
import service from '@/utils/request' |
|||
|
|||
// @Summary 用户登录
|
|||
// @Produce application/json
|
|||
// @Param {
|
|||
// page int
|
|||
// pageSize int
|
|||
// }
|
|||
// @Router /authority/getAuthorityList [post]
|
|||
export const getAuthorityList = (data) => { |
|||
return service({ |
|||
url: "/authority/getAuthorityList", |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
|
|||
// @Summary 删除角色
|
|||
// @Security ApiKeyAuth
|
|||
// @accept application/json
|
|||
// @Produce application/json
|
|||
// @Param data body {authorityId uint} true "删除角色"
|
|||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
|||
// @Router /authority/deleteAuthority [post]
|
|||
export const deleteAuthority = (data) => { |
|||
return service({ |
|||
url: "/authority/deleteAuthority", |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
|||
|
|||
// @Summary 创建角色
|
|||
// @Security ApiKeyAuth
|
|||
// @accept application/json
|
|||
// @Produce application/json
|
|||
// @Param data body api.CreateAuthorityPatams true "创建角色"
|
|||
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
|
|||
// @Router /authority/createAuthority [post]
|
|||
export const createAuthority = (data) => { |
|||
return service({ |
|||
url: "/authority/createAuthority", |
|||
method: 'post', |
|||
data |
|||
}) |
|||
} |
@ -0,0 +1,35 @@ |
|||
.clearflex { |
|||
*zoom: 1; |
|||
} |
|||
|
|||
.clearflex:after { |
|||
content: ''; |
|||
display: block; |
|||
height: 0; |
|||
visibility: hidden; |
|||
clear: both; |
|||
} |
|||
|
|||
.fl-left { |
|||
float: left; |
|||
} |
|||
|
|||
.fl-right { |
|||
float: right; |
|||
} |
|||
|
|||
.left-mg-xs { |
|||
margin-left: 6px; |
|||
} |
|||
|
|||
.left-mg-sm { |
|||
margin-left: 10px; |
|||
} |
|||
|
|||
.left-mg-md { |
|||
margin-left: 14px; |
|||
} |
|||
|
|||
.left-mg-lg { |
|||
margin-left: 18px; |
|||
} |
@ -1,7 +1,11 @@ |
|||
const _import = require('./_import') //获取组件的方法
|
|||
export const asyncRouterHandle = (asyncRouter) => { |
|||
asyncRouter.map(item => { |
|||
if (item.component) { |
|||
item.component = _import(item.component) |
|||
} else { |
|||
delete item['component'] |
|||
} |
|||
if (item.children) { |
|||
asyncRouterHandle(item.children) |
|||
} |
|||
|
@ -0,0 +1,18 @@ |
|||
const install = (Vue) => { |
|||
const Bus = new Vue({ |
|||
methods: { |
|||
emit(event, ...args) { |
|||
this.$emit(event, ...args) |
|||
}, |
|||
on(event, cb) { |
|||
this.$on(event, cb) |
|||
}, |
|||
off(event, cb) { |
|||
this.$off(event, cb) |
|||
} |
|||
}, |
|||
}) |
|||
Vue.prototype.$bus = Bus |
|||
} |
|||
|
|||
export default install |
@ -1,16 +1,33 @@ |
|||
<template> |
|||
<div> |
|||
Dashbord |
|||
<el-card class="box-card" shadow="hover"> |
|||
<div class="clearfix" slot="header"> |
|||
<span>用户信息</span> |
|||
</div> |
|||
<el-row> |
|||
<div class="fl-left left-mg-xs"> |
|||
<el-avatar :size="120" :src="userInfo.headerImg" shape="square"></el-avatar> |
|||
</div> |
|||
<div class="fl-left left-mg-lg"> |
|||
<div>用户ID:{{userInfo.uuid}}</div> |
|||
<div>用户昵称:{{userInfo.nickName}}</div> |
|||
<div>用户组:{{userInfo.authority.authorityName}}</div> |
|||
</div> |
|||
</el-row> |
|||
</el-card> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapGetters } from 'vuex' |
|||
export default { |
|||
name:"Dashbord" |
|||
|
|||
name: 'Dashbord', |
|||
computed: { |
|||
...mapGetters('user', ['userInfo']) |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
.box-card{ |
|||
width: 600px; |
|||
} |
|||
</style> |
@ -0,0 +1,14 @@ |
|||
<template> |
|||
<div> |
|||
新建api |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Api", |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
|
|||
</style> |
@ -0,0 +1,150 @@ |
|||
<template> |
|||
<div> |
|||
<div class="button-box clearflex"> |
|||
<el-button @click="addAuthority" type="primary">新增角色</el-button> |
|||
</div> |
|||
<el-table :data="tableData" border stripe> |
|||
<el-table-column label="角色id" min-width="180" prop="authorityId"></el-table-column> |
|||
<el-table-column label="角色名称" min-width="180" prop="authorityName"></el-table-column> |
|||
<el-table-column fixed="right" label="操作" width="100"> |
|||
<template slot-scope="scope"> |
|||
<el-button @click="deleteAuth(scope.row)" size="small" type="text">删除角色</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
<el-pagination |
|||
:current-page="page" |
|||
:page-size="pageSize" |
|||
:page-sizes="[10, 30, 50, 100]" |
|||
:style="{float:'right',padding:'20px'}" |
|||
:total="total" |
|||
@current-change="handleCurrentChange" |
|||
@size-change="handleSizeChange" |
|||
hide-on-single-page |
|||
layout="total, sizes, prev, pager, next, jumper" |
|||
></el-pagination> |
|||
|
|||
<el-dialog :visible.sync="dialogFormVisible" title="新增角色"> |
|||
<el-form :model="form"> |
|||
<el-form-item label="角色ID"> |
|||
<el-input autocomplete="off" v-model="form.authorityId"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="角色姓名"> |
|||
<el-input autocomplete="off" v-model="form.authorityName"></el-input> |
|||
</el-form-item> |
|||
</el-form> |
|||
<div class="dialog-footer" slot="footer"> |
|||
<el-button @click="closeDialog">取 消</el-button> |
|||
<el-button @click="enterDialog" type="primary">确 定</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { getAuthorityList, deleteAuthority, createAuthority } from '@/api/authority' |
|||
export default { |
|||
name: 'Authority', |
|||
data() { |
|||
return { |
|||
page: 1, |
|||
total: 10, |
|||
pageSize: 10, |
|||
tableData: [], |
|||
dialogFormVisible: false, |
|||
form:{ |
|||
authorityId:"", |
|||
authorityName:"" |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
handleSizeChange(val) { |
|||
this.pageSize = val |
|||
this.getAuthList() |
|||
}, |
|||
handleCurrentChange(val) { |
|||
this.page = val |
|||
this.getAuthList() |
|||
}, |
|||
deleteAuth(row) { |
|||
this.$confirm('此操作将永久删除该角色, 是否继续?', '提示', { |
|||
confirmButtonText: '确定', |
|||
cancelButtonText: '取消', |
|||
type: 'warning' |
|||
}) |
|||
.then(async () => { |
|||
try { |
|||
const res = await deleteAuthority({ authorityId: row.authorityId }) |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '删除成功!' |
|||
}) |
|||
this.getAuthList() |
|||
} catch (err) { |
|||
this.$message({ |
|||
type: 'error', |
|||
message: '删除失败!' + err |
|||
}) |
|||
} |
|||
}) |
|||
.catch(() => { |
|||
this.$message({ |
|||
type: 'info', |
|||
message: '已取消删除' |
|||
}) |
|||
}) |
|||
}, |
|||
initForm(){ |
|||
for(const key in this.form){ |
|||
this.form[key] = '' |
|||
} |
|||
}, |
|||
closeDialog(){ |
|||
this.initForm() |
|||
this.dialogFormVisible = false |
|||
}, |
|||
async enterDialog(){ |
|||
const res = await createAuthority(this.form) |
|||
if(res.success){ |
|||
this.$message({ |
|||
type: 'success', |
|||
message: '添加成功!' |
|||
}) |
|||
this.getAuthList() |
|||
this.closeDialog() |
|||
}else{ |
|||
this.$message({ |
|||
type: 'error', |
|||
message: '添加失败!' |
|||
}) |
|||
this.closeDialog() |
|||
} |
|||
this.initForm() |
|||
this.dialogFormVisible = false |
|||
}, |
|||
addAuthority() { |
|||
this.dialogFormVisible = true |
|||
}, |
|||
async getAuthList(page = this.page, pageSize = this.pageSize) { |
|||
try { |
|||
const table = await getAuthorityList({ page, pageSize }) |
|||
this.tableData = table.data.authList |
|||
} catch (err) { |
|||
console.log(err) |
|||
} |
|||
} |
|||
}, |
|||
created() { |
|||
this.getAuthList() |
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
.button-box { |
|||
padding: 10px 20px; |
|||
.el-button { |
|||
float: right; |
|||
} |
|||
} |
|||
</style> |
@ -0,0 +1,12 @@ |
|||
<template> |
|||
<router-view></router-view> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"superAdmin", |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
|
|||
</style> |
@ -0,0 +1,14 @@ |
|||
<template> |
|||
<div> |
|||
新建菜单 |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name:"Menus", |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
|
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue