forked from JointCloud/JCC-RIP
roleList userList
This commit is contained in:
parent
6d9831fdfa
commit
68944a452b
|
@ -7,3 +7,36 @@ export function fetchAllRoleList() {
|
|||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 角色列表
|
||||
export function getRoleList(params) {
|
||||
return request({
|
||||
url: '/role/getRoles',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export function createRole(data) {
|
||||
return request({
|
||||
url: '/role/addRole',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateRole(data) {
|
||||
return request({
|
||||
url: '/role/editRole',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteRole(data) {
|
||||
return request({
|
||||
url: '/role/deleteRole',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
|
@ -26,3 +26,35 @@ export function getUserList(params) {
|
|||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export function updateUserStatus(data) {
|
||||
return request({
|
||||
url: '/user/switchStatus',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteAdmin(params) {
|
||||
return request({
|
||||
url: '/user/deleteUser',
|
||||
method: 'delete',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function createAdmin(data) {
|
||||
return request({
|
||||
url: '/user/addUser',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateAdmin(id, data) {
|
||||
return request({
|
||||
url: '/user/editUser',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
|
@ -9,76 +9,13 @@ export function logout() {
|
|||
})
|
||||
}
|
||||
|
||||
export function createAdmin(data) {
|
||||
return request({
|
||||
url: preUrl + '/admin/register',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateAdmin(id, data) {
|
||||
return request({
|
||||
url: preUrl + '/admin/update/' + id,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateUserStatus(id, params) {
|
||||
return request({
|
||||
url: preUrl + '/admin/updateStatus/' + id,
|
||||
method: 'put',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteAdmin(id) {
|
||||
return request({
|
||||
url: preUrl + '/admin/delete/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function getRoleByAdmin(id) {
|
||||
return request({
|
||||
url: preUrl + '/admin/role/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function allocRole(data) {
|
||||
return request({
|
||||
url: preUrl + '/admin/role/update',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 角色列表
|
||||
export function getRoleList(params) {
|
||||
return request({
|
||||
url: preUrl + '/role/list',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
export function createRole(data) {
|
||||
return request({
|
||||
url: preUrl + '/role/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateRole(id, data) {
|
||||
return request({
|
||||
url: preUrl + '/role/update/' + id,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// export function allocRole(data) {
|
||||
// return request({
|
||||
// url: preUrl + '/admin/role/update',
|
||||
// method: 'put',
|
||||
// data: data
|
||||
// })
|
||||
// }
|
||||
|
||||
export function updateRoleStatus(id, params) {
|
||||
return request({
|
||||
|
@ -88,14 +25,6 @@ export function updateRoleStatus(id, params) {
|
|||
})
|
||||
}
|
||||
|
||||
export function deleteRole(data) {
|
||||
return request({
|
||||
url: preUrl + '/role/delete',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function listMenuByRole(roleId) {
|
||||
return request({
|
||||
url: preUrl + '/role/listMenu/' + roleId,
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
class="multipleTable"
|
||||
:columns="columns"
|
||||
:get-list-action="getRoleList"
|
||||
:pagination="true"
|
||||
page-key="pageNum"
|
||||
limit-key="pageSize"
|
||||
list-key="data"
|
||||
tooltip-effect="dark"
|
||||
>
|
||||
<template v-slot:filterBtns>
|
||||
|
@ -41,8 +39,8 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="是否启用:">
|
||||
<el-radio-group v-model="role.status">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
<el-radio :label="true">是</el-radio>
|
||||
<el-radio :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
@ -105,7 +103,8 @@
|
|||
|
||||
<script>
|
||||
import List from '@/components/list'
|
||||
import { getRoleList, createRole, updateRole, updateRoleStatus, deleteRole, fetchTreeList, listMenuByRole, allocMenu, fetchAllResourceList, listAllCate, allocResource, listResourceByRole } from '@/api/top-menu/permissionManagement'
|
||||
import { createRole, updateRole, deleteRole, getRoleList } from '@/api/authority/role'
|
||||
import { updateRoleStatus, fetchTreeList, listMenuByRole, allocMenu, fetchAllResourceList, listAllCate, allocResource, listResourceByRole } from '@/api/top-menu/permissionManagement'
|
||||
|
||||
// import { newEval } from '@/utils'
|
||||
import moment from 'moment'
|
||||
|
@ -114,7 +113,7 @@ const defaultRole = {
|
|||
name: null,
|
||||
description: null,
|
||||
adminCount: 0,
|
||||
status: 1
|
||||
status: true
|
||||
}
|
||||
export default {
|
||||
components: { List },
|
||||
|
@ -131,13 +130,11 @@ export default {
|
|||
{ prop: 'id', label: '编号', sortable: true },
|
||||
{ prop: 'name', label: '角色名称', sortable: true },
|
||||
{ prop: 'description', label: '描述', sortable: true },
|
||||
{ prop: 'adminCount', label: '用户数', sortable: true },
|
||||
{ prop: 'createTime', label: '添加时间', sortable: true, formatter: (row) => { return <span>{this.formatDate(row.createTime)}</span> } },
|
||||
{ prop: 'status', label: '是否启用', formatter: (row) => {
|
||||
return <el-switch
|
||||
onChange={() => this.handleStatusChange(row)}
|
||||
activeValue={1}
|
||||
inactiveValue={0}
|
||||
activeValue={true}
|
||||
inactiveValue={false}
|
||||
value={row.status}>
|
||||
</el-switch>
|
||||
} },
|
||||
|
@ -146,7 +143,7 @@ export default {
|
|||
return <div>
|
||||
<el-button type='text' onClick={() => this.handleSelectMenu(index, row)}> 分配菜单 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleSelectResource(index, row)}> 分配资源 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleUpdate(index, row)}> 编辑 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleUpdate(row)}> 编辑 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleDelete(index, row)}> 删除 </el-button>
|
||||
</div>
|
||||
}
|
||||
|
@ -180,7 +177,7 @@ export default {
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
updateRoleStatus(row.id, { status: !row.status ? 1 : 0 }).then(response => {
|
||||
updateRoleStatus(row.id, { status: !row.status }).then(response => {
|
||||
this.$refs.multipleTable.getList()
|
||||
this.$message({
|
||||
type: 'success',
|
||||
|
@ -214,10 +211,11 @@ export default {
|
|||
})
|
||||
})
|
||||
},
|
||||
handleUpdate(index, row) {
|
||||
handleUpdate(row) {
|
||||
this.dialogVisible = true
|
||||
this.isEdit = true
|
||||
this.role = Object.assign({}, row)
|
||||
this.role.menus = undefined
|
||||
},
|
||||
handleDialogConfirm() {
|
||||
this.$confirm('是否要确认?', '提示', {
|
||||
|
@ -226,7 +224,7 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
if (this.isEdit) {
|
||||
updateRole(this.role.id, this.role).then(response => {
|
||||
updateRole(this.role).then(response => {
|
||||
this.$message({
|
||||
message: '修改成功!',
|
||||
type: 'success'
|
||||
|
|
|
@ -28,30 +28,35 @@
|
|||
label-width="150px"
|
||||
size="small"
|
||||
>
|
||||
<el-form-item label="帐号:">
|
||||
<el-form-item label="用户名:">
|
||||
<el-input v-model="admin.username" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名:">
|
||||
<el-input v-model="admin.nickName" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱:">
|
||||
<el-input v-model="admin.email" style="width: 250px" />
|
||||
<el-form-item label="昵称:">
|
||||
<el-input v-model="admin.nickname" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密码:">
|
||||
<el-input v-model="admin.password" type="password" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注:">
|
||||
<el-input
|
||||
v-model="admin.note"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
style="width: 250px"
|
||||
<el-form-item label="角色:">
|
||||
<el-select v-model="allocRoleIds" placeholder="请选择" size="small" style="width: 250px">
|
||||
<el-option
|
||||
v-for="item in allRoleList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机:">
|
||||
<el-input v-model="admin.phone" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱:">
|
||||
<el-input v-model="admin.email" style="width: 250px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否启用:">
|
||||
<el-radio-group v-model="admin.status">
|
||||
<el-radio :label="1">是</el-radio>
|
||||
<el-radio :label="0">否</el-radio>
|
||||
<el-radio :label="true">是</el-radio>
|
||||
<el-radio :label="false">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
@ -60,33 +65,24 @@
|
|||
<el-button type="primary" size="small" @click="handleDialogConfirm()">{{ $t("message.confirm") }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
<!-- <el-dialog
|
||||
:close-on-click-modal="false"
|
||||
title="分配角色"
|
||||
:visible.sync="allocDialogVisible"
|
||||
width="30%"
|
||||
>
|
||||
<el-select v-model="allocRoleIds" placeholder="请选择" size="small" style="width: 80%">
|
||||
<el-option
|
||||
v-for="item in allRoleList"
|
||||
:key="item.ID"
|
||||
:label="item.name"
|
||||
:value="item.ID"
|
||||
/>
|
||||
</el-select>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="allocDialogVisible = false">{{ $t("message.cancel") }}</el-button>
|
||||
<el-button type="primary" size="small" @click="handleAllocDialogConfirm()">{{ $t("message.confirm") }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-dialog> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import List from '@/components/list'
|
||||
import { createAdmin, updateAdmin, updateUserStatus, deleteAdmin, getRoleByAdmin, allocRole } from '@/api/top-menu/permissionManagement'
|
||||
import { getUserList } from '@/api/authority/user'
|
||||
import { fetchAllRoleList } from '@/api/authority/role'
|
||||
import { updateAdmin, createAdmin, getUserList, deleteAdmin, updateUserStatus } from '@/api/authority/user'
|
||||
import { getRoleList, fetchAllRoleList } from '@/api/authority/role'
|
||||
|
||||
// import { newEval } from '@/utils'
|
||||
import moment from 'moment'
|
||||
|
@ -114,16 +110,17 @@ export default {
|
|||
allocAdminId: null,
|
||||
columns: [
|
||||
{ prop: 'id', label: '编号', sortable: true },
|
||||
{ prop: 'username', label: '帐号', sortable: true },
|
||||
{ prop: 'nickName', label: '姓名', sortable: true },
|
||||
{ prop: 'email', label: '邮箱', sortable: true },
|
||||
{ prop: 'username', label: '用户名' },
|
||||
{ prop: 'nickname', label: '昵称' },
|
||||
{ prop: 'roleName', label: '角色' },
|
||||
{ prop: 'email', label: '邮箱' },
|
||||
{ prop: 'phone', label: '手机号' },
|
||||
{ prop: 'createTime', label: '添加时间', sortable: true, formatter: (row) => { return <span>{this.formatDate(row.createTime)}</span> } },
|
||||
{ prop: 'loginTime', label: '最后登录', sortable: true, formatter: (row) => { return <span>{this.formatDate(row.loginTime)}</span> } },
|
||||
{ prop: 'status', label: '是否启用', formatter: (row) => {
|
||||
return <el-switch
|
||||
onChange={() => this.handleStatusChange(row)}
|
||||
activeValue={1}
|
||||
inactiveValue={0}
|
||||
activeValue={true}
|
||||
inactiveValue={false}
|
||||
value={row.status}>
|
||||
</el-switch>
|
||||
} },
|
||||
|
@ -131,8 +128,8 @@ export default {
|
|||
prop: 'more', label: '更多操作', formatter: (row, index) => {
|
||||
return <div>
|
||||
<el-button type='text' onClick={() => this.handleSelectRole(index, row)}> 分配角色 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleUpdate(index, row)}> 编辑 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleDelete(index, row)}> 删除 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleUpdate(row)}> 编辑 </el-button>
|
||||
<el-button type='text' onClick={() => this.handleDelete(row.id)}> 删除 </el-button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +154,7 @@ export default {
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
updateUserStatus(row.id, { status: !row.status ? 1 : 0 }).then(response => {
|
||||
updateUserStatus({ id: row.id, status: !row.status }).then(response => {
|
||||
this.$refs.multipleTable.getList()
|
||||
this.$message({
|
||||
type: 'success',
|
||||
|
@ -172,13 +169,13 @@ export default {
|
|||
this.$refs.multipleTable.getList()
|
||||
})
|
||||
},
|
||||
handleDelete(index, row) {
|
||||
handleDelete(id) {
|
||||
this.$confirm('是否要删除该用户?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
deleteAdmin(row.id).then(response => {
|
||||
deleteAdmin({ id }).then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
|
@ -187,7 +184,7 @@ export default {
|
|||
})
|
||||
})
|
||||
},
|
||||
handleUpdate(index, row) {
|
||||
handleUpdate(row) {
|
||||
this.dialogVisible = true
|
||||
this.isEdit = true
|
||||
this.admin = Object.assign({}, row)
|
||||
|
@ -219,24 +216,24 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
handleAllocDialogConfirm() {
|
||||
this.$confirm('是否要确认?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const params = new FormData()
|
||||
params.append('adminId', this.allocAdminId)
|
||||
params.append('roleIds', this.allocRoleIds)
|
||||
allocRole(params).then(response => {
|
||||
this.$message({
|
||||
message: '分配成功!',
|
||||
type: 'success'
|
||||
})
|
||||
this.allocDialogVisible = false
|
||||
})
|
||||
})
|
||||
},
|
||||
// handleAllocDialogConfirm() {
|
||||
// this.$confirm('是否要确认?', '提示', {
|
||||
// confirmButtonText: '确定',
|
||||
// cancelButtonText: '取消',
|
||||
// type: 'warning'
|
||||
// }).then(() => {
|
||||
// const params = new FormData()
|
||||
// params.append('adminId', this.allocAdminId)
|
||||
// params.append('roleIds', this.allocRoleIds)
|
||||
// allocRole(params).then(response => {
|
||||
// this.$message({
|
||||
// message: '分配成功!',
|
||||
// type: 'success'
|
||||
// })
|
||||
// this.allocDialogVisible = false
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
handleSelectRole(index, row) {
|
||||
this.allocAdminId = row.id
|
||||
this.allocDialogVisible = true
|
||||
|
@ -248,7 +245,7 @@ export default {
|
|||
})
|
||||
},
|
||||
getRoleListByAdmin(adminId) {
|
||||
getRoleByAdmin(adminId).then(response => {
|
||||
getRoleList(adminId).then(response => {
|
||||
const allocRoleList = response.data
|
||||
this.allocRoleIds = []
|
||||
if (allocRoleList != null && allocRoleList.length > 0) {
|
||||
|
|
|
@ -78,6 +78,30 @@ module.exports = {
|
|||
target: 'https://gwkfxaifjwcy.test.jointcloud.net:443/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/role': {
|
||||
ws: false,
|
||||
target: 'https://gwkfxaifjwcy.test.jointcloud.net:443/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/api': {
|
||||
ws: false,
|
||||
target: 'https://gwkfxaifjwcy.test.jointcloud.net:443/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/auth': {
|
||||
ws: false,
|
||||
target: 'https://gwkfxaifjwcy.test.jointcloud.net:443/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'^/opl': {
|
||||
ws: false,
|
||||
target: 'https://gwkfxaifjwcy.test.jointcloud.net:443/',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
}
|
||||
// before: require('./mock/mock-server.js')
|
||||
|
|
Loading…
Reference in New Issue