Commit ada345f6 authored by 徐一鸣's avatar 徐一鸣

权限管理接口调试

parent e515b59c
......@@ -62,6 +62,7 @@
:current-page="currentPage"
@size-change="changePageSize"
@current-change="changeCurrentPage"
style="margin-top: 20px;"
></list-pagination>
</div>
</div>
......@@ -111,10 +112,10 @@ export default {
showListFilter: false,
filter: {},
searchValue: "",
pageSize: 10,
pageSize: 15,
currentPage: 1,
timer: null,
pageSizes: [10, 50, 100],
pageSizes: [15, 50, 100],
}),
methods: {
searchAction(value) {
......
......@@ -49,7 +49,7 @@ export default {
data: () => ({}),
computed: {
totalPages() {
return Math.ceil(this.total / this.pageSize);
return Math.ceil(this.total / this.pageSize) || 1;
},
preDisabled() {
return this.currentPage === 1;
......
......@@ -4,12 +4,12 @@
<i class="el-icon-close"></i>
</a>
<div class="organization_card-icon">
<el-avatar shape="square" :size="56" fit="cover" :src="data.img" />
<el-avatar shape="square" :size="56" fit="cover" :src="data.picture_path" />
</div>
<div class="organization_card-info">
<p
class="organization_card-name text_clip"
v-text="data.name"
v-text="data.department_name"
@click="intoDetail"
></p>
</div>
......@@ -18,21 +18,21 @@
<i class="el-icon-setting"></i>
<span>业务系统数</span>
</span>
<span class="text_clip" v-text="data.system_count"></span>
<span class="text_clip" v-text="data.systemUser"></span>
</p>
<p class="organization_card-text">
<span>
<i class="el-icon-user"></i>
<span>组织管理员</span>
</span>
<span class="text_clip" v-text="data.organization_manager"></span>
<span class="text_clip" v-text="data.orgAdmin"></span>
</p>
<p class="organization_card-text">
<span>
<i class="el-icon-time"></i>
<span>创建时间</span>
</span>
<span class="text_clip" v-text="data.time"></span>
<span class="text_clip" v-text="data.create_date"></span>
</p>
</div>
</template>
......
......@@ -58,5 +58,6 @@ export default {
flex-wrap: wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
}
</style>
<template>
<div class="organization_list">
<apass-list
@list-action="listAction"
@list-action="initDatas"
search-placeholder="请输入关键字"
:list-total="listTotal"
>
......@@ -20,7 +20,7 @@
<p class="organization_info" slot="header-center">
<img :src="require('@/assets/imgs/title_ic_zuzhi.png')" />
<span>当前组织总数:</span>
<span>8</span>
<span v-text="listTotal"></span>
</p>
<organization-list
slot="list"
......@@ -33,7 +33,7 @@
<apass-dialog
ref="dialog"
msg="确认删除该组织吗?"
@submit="dialogSubmit"
:submit="dialogSubmit"
></apass-dialog>
</div>
</template>
......@@ -46,128 +46,57 @@ import apassDialog from "@/components/apass-dialog";
export default {
components: { apassList, organizationList, apassDialog },
data: () => ({
listTotal: 300,
listData: [
{
id: 1000001,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "贵阳市公安局",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000002,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "语音识别",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000003,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000004,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000005,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000006,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000007,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 100000,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000009,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
{
id: 1000010,
img:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
name: "轨迹绘制",
system_count: 6,
organization_manager: 3,
time: "2019-04-11 12:50:30",
},
],
roleData: [
{
name: "超级管理员",
description: "拥有所有权限",
},
{
name: "组织管理员",
description: "拥有对应组织的权限",
},
{
name: "普通用户",
description: "普通权限用户",
},
{
name: "普通用户-开发者",
description: "基于普通用户多一些开发的选项",
},
],
showDialog: false,
listTotal: 0,
listData: [],
deleteItem: null,
tempFilter: null,
}),
methods: {
listAction(value) {
console.log(value);
initDatas(filters) {
this.tempFilter = filters;
this.$http
.get("/apaas/backmgt/department/list", {
params: {
page: filters.page,
limit: filters.size,
},
})
.then(({ data }) => {
// console.log(data);
this.listTotal = data.total;
this.listData = data.data;
})
.catch((error) => {
console.log(error);
});
},
deleteAction(item) {
this.deleteItem = item;
this.$refs.dialog.show();
},
dialogSubmit() {
console.log("dialog submit");
this.$http
.delete("/apaas/backmgt/department", {
params: {
department_id: this.deleteItem.department_id,
},
})
.then(({ data }) => {
// console.log(data);
this.$message({
message: `已删除${this.deleteItem.department_name}.`,
type: "success",
});
this.deleteItem = null;
this.initDatas(this.tempFilter);
})
.catch((error) => {
this.$message({
message: `删除${this.deleteItem.department_name}失败`,
type: "warning",
});
});
},
},
};
......
......@@ -10,52 +10,54 @@
<el-breadcrumb-item to="/authority/users">用户管理</el-breadcrumb-item>
<el-breadcrumb-item>权限审批</el-breadcrumb-item>
</el-breadcrumb>
<el-table slot="list" :border="false" :data="listData">
<el-table-column label="" width="40"></el-table-column>
<el-table-column label="账号" width="160">
<template slot-scope="scope">
<span v-text="scope.row.account"></span>
</template>
</el-table-column>
<el-table-column label="业务系统名称">
<template slot-scope="scope">
<span v-text="scope.row.name"></span>
</template>
</el-table-column>
<el-table-column label="用户类型" align="center" width="240">
<template slot-scope="scope">
<span v-text="scope.row.role"></span>
</template>
</el-table-column>
<el-table-column label="用户所属组织">
<template slot-scope="scope">
<span v-text="scope.row.organization"></span>
</template>
</el-table-column>
<el-table-column label="用户状态" align="center" width="160">
<template slot-scope="scope">
<span v-text="scope.row.state === 0 ? '禁用' : '启用'"></span>
</template>
</el-table-column>
<el-table-column label="申请时间" align="center" width="200">
<template slot-scope="scope">
<span v-text="scope.row.update_time"></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="300">
<template slot-scope="scope">
<div class="row_action">
<a class="btn" @click="permissionAction(scope.row)">
通过
</a>
<span class="interval_line">|</span>
<a class="btn warn" @click="permissionAction(scope.row, false)">
拒绝
</a>
</div>
</template>
</el-table-column>
</el-table>
<div class="apass_table" slot="list">
<el-table :border="false" :data="listData">
<el-table-column label="" width="40"></el-table-column>
<el-table-column label="账号" width="160">
<template slot-scope="scope">
<span v-text="scope.row.account"></span>
</template>
</el-table-column>
<el-table-column label="业务系统名称">
<template slot-scope="scope">
<span v-text="scope.row.name"></span>
</template>
</el-table-column>
<el-table-column label="用户类型" align="center" width="240">
<template slot-scope="scope">
<span v-text="scope.row.role"></span>
</template>
</el-table-column>
<el-table-column label="用户所属组织">
<template slot-scope="scope">
<span v-text="scope.row.organization"></span>
</template>
</el-table-column>
<el-table-column label="用户状态" align="center" width="160">
<template slot-scope="scope">
<span v-text="scope.row.state === 0 ? '禁用' : '启用'"></span>
</template>
</el-table-column>
<el-table-column label="申请时间" align="center" width="200">
<template slot-scope="scope">
<span v-text="scope.row.update_time"></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="300">
<template slot-scope="scope">
<div class="row_action">
<a class="btn" @click="permissionAction(scope.row)">
通过
</a>
<span class="interval_line">|</span>
<a class="btn warn" @click="permissionAction(scope.row, false)">
拒绝
</a>
</div>
</template>
</el-table-column>
</el-table>
</div>
</apass-list>
</div>
</template>
......
<template>
<div class="roles_list">
<apass-list
@list-action="listAction"
@list-action="initDatas"
search-placeholder="请输入关键字"
:list-header="listHeader"
:list-data="listData"
......@@ -39,22 +39,39 @@ export default {
msg: "",
submit: null,
},
listTotal: 300,
listTotal: 0,
listHeader: [],
listData: [],
tempFilter: null,
}),
methods: {
listAction(value) {
console.log(value);
initDatas(filters) {
this.tempFilter = filters;
this.$http
.get(`/apaas/backmgt/role/list`, {
params: {
search: filters.keyword,
page: filters.page,
limit: filters.size,
},
})
.then(({ data }) => {
this.listTotal = data.total;
this.listData = data.data;
})
.catch((error) => {
console.log(error);
});
},
showDialog() {
this.$refs.dialog.show();
},
editItem(item) {
this.$router.push(`/authority/roles/edit/${item.id}`);
this.$router.push(`/authority/roles/edit/${item.role_id}`);
},
allotItem(item) {
this.$router.push(`/authority/roles/allot/${item.id}`);
this.$router.push(`/authority/roles/allot/${item.role_id}`);
},
deleteItem(item) {
this.dialogInfo.title = "";
......@@ -62,7 +79,21 @@ export default {
this.dialogInfo.cancelText = "";
this.dialogInfo.sunbmitText = "";
this.dialogInfo.submit = () => {
console.log("deleteItem - " + item.name);
this.$http
.delete(`/apaas/backmgt/role/id/${item.role_id}`)
.then(({ data }) => {
this.$message({
message: `已删除${item.role_name}.`,
type: "success",
});
this.initDatas(this.tempFilter);
})
.catch((error) => {
this.$message({
message: `删除${this.deleteItem.role_name}失败`,
type: "warning",
});
});
};
this.showDialog();
},
......@@ -71,20 +102,18 @@ export default {
this.listHeader = [
{
label: "角色类型",
prop: "name",
prop: "role_name",
type: "button",
callback: this.editItem,
},
{
label: "创建人",
prop: "creator",
type: "",
prop: "create_user",
align: "center",
},
{
label: "创建日期",
prop: "create_date",
type: "",
align: "center",
},
{
......@@ -99,43 +128,12 @@ export default {
},
{
label: "删除",
class: "warn",
callback: this.deleteItem,
},
],
},
];
this.listData = [
{
id: 0,
name: "普通用户",
creator: "谢飞",
create_date: "2020-04-27 13:24:19",
},
{
id: 1,
name: "组织管理员",
creator: "谢飞",
create_date: "2020-04-27 13:24:19",
},
{
id: 2,
name: "超级管理员",
creator: "谢飞",
create_date: "2020-04-27 13:24:19",
},
{
id: 3,
name: "普通用户-开发者",
creator: "谢飞",
create_date: "2020-04-27 13:24:19",
},
{
id: 4,
name: "测试用户",
creator: "谢飞",
create_date: "2020-04-27 13:24:19",
},
];
},
};
</script>
......
<template>
<div class="user_roles">
<apass-list
search-placeholder="请输入关键字"
:list-total="roleTotal"
@list-action="listAction"
>
<el-breadcrumb separator="/" slot="breadcrumb">
<el-breadcrumb-item to="/authority">权限管理</el-breadcrumb-item>
<el-breadcrumb-item to="/authority/users">用户管理</el-breadcrumb-item>
<el-breadcrumb-item>分配角色</el-breadcrumb-item>
</el-breadcrumb>
<template slot="header-left">
<el-button type="primary" @click="setUserRoles">
保存
</el-button>
</template>
<div class="apass_table" slot="list">
<el-table class="user_roles_table" :border="false" :data="roleData">
<el-table-column width="60" align="right">
<template slot-scope="scope">
<el-checkbox
v-model="scope.row.selected"
@change="updateRoles"
></el-checkbox>
</template>
</el-table-column>
<el-table-column label="角色">
<template slot-scope="scope">
<span v-text="scope.row.role_name"></span>
</template>
</el-table-column>
<el-table-column label="说明">
<template slot-scope="scope">
<span v-text="scope.row.detail"></span>
</template>
</el-table-column>
</el-table>
</div>
</apass-list>
</div>
</template>
<script>
import apassList from "@/components/apass-list";
export default {
components: { apassList },
data: () => ({
roleTotal: 0,
roleData: [],
showDialog: false,
roles: null,
}),
computed: {
roleIds() {
return this.roleData.map((item) => item.role_id);
},
},
methods: {
listAction(filters) {
// console.log(filters);
if (this.roles === null) {
this.getUserRoles(() => {
this.getRoles(filters);
});
} else {
this.getRoles(filters);
}
},
getRoles(filters) {
this.$http
.get(`/apaas/backmgt/role/list`, {
params: {
search: filters.keyword,
page: filters.page,
limit: filters.size,
},
})
.then(({ data }) => {
data.data.forEach((item) => {
item.selected = this.roles.indexOf(item.role_id) > -1;
});
this.roleTotal = data.total;
this.roleData = data.data;
})
.catch((error) => {
console.log(error);
});
},
getUserRoles(callback) {
this.$http
.get(`/apaas/backmgt/user/roles/${this.$route.params.id}`)
.then(({ data }) => {
this.roles = data.data.map((item) => item.role_id);
// console.log(this.roles);
typeof callback === "function" && callback();
})
.catch((error) => {
console.log(error);
});
},
updateRoles() {
this.roles = this.roles
.filter((item) => {
return this.roleIds.indexOf(item) === -1;
})
.concat(
this.roleData
.filter((item) => {
return item.selected;
})
.map((item) => {
return item.role_id;
})
);
// console.log(this.roles);
},
setUserRoles() {
if (this.roles.length > 0) {
this.$http
.post(`/apaas/backmgt/user/addRole`, {
user_id: this.$route.params.id,
role_id: this.roles,
})
.then(({ data }) => {
this.$message({
message: `分配角色成功.`,
type: "success",
});
this.$router.push("/authority/users");
})
.catch((error) => {
this.$message({
message: "分配角色失败.",
type: "warning",
});
});
} else {
this.$message({
message: "用户角色不能为空!",
type: "warning",
});
}
},
},
};
</script>
<style scoped>
.user_roles {
height: 100%;
}
</style>
......@@ -22,22 +22,28 @@
<el-table-column label="" width="40"></el-table-column>
<el-table-column label="账号" width="160">
<template slot-scope="scope">
<span v-text="scope.row.account"></span>
<span v-text="scope.row.user_id"></span>
</template>
</el-table-column>
<el-table-column label="业务系统名称">
<template slot-scope="scope">
<span v-text="scope.row.name"></span>
<span v-text="scope.row.user_name"></span>
</template>
</el-table-column>
<el-table-column label="用户类型" align="center" width="160">
<template slot-scope="scope">
<span v-text="scope.row.role"></span>
<span
v-text="
['-', '超级管理员', '组织管理员', '普通用户', '开发者'][
scope.row.is_admin || 0
]
"
></span>
</template>
</el-table-column>
<el-table-column label="所属组织">
<template slot-scope="scope">
<span v-text="scope.row.organization"></span>
<span v-text="scope.row.department"></span>
</template>
</el-table-column>
<el-table-column label="账号状态" align="center" width="240">
......@@ -47,7 +53,7 @@
</el-table-column>
<el-table-column label="上次操作修改时间" align="center" width="200">
<template slot-scope="scope">
<span v-text="scope.row.update_time"></span>
<span v-text="scope.row.update_date"></span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="300">
......@@ -56,13 +62,18 @@
<a
class="btn"
@click="
$router.push(`/authority/users/detail/${scope.row.id}`)
$router.push(`/authority/users/detail/${scope.row.user_id}`)
"
>
详情
</a>
<span class="interval_line">|</span>
<a class="btn" @click="setRole(scope.row)">
<a
class="btn"
@click="
$router.push(`/authority/users/roles/${scope.row.user_id}`)
"
>
分配角色
</a>
<span class="interval_line">|</span>
......@@ -79,33 +90,6 @@
</el-table>
</div>
</apass-list>
<apass-dialog
ref="dialog"
width="590px"
title="分配角色"
@submit="dialogSubmit"
>
<el-table
slot="content"
:border="false"
:data="roleData"
@selection-change="dialogSelectionChange"
>
<el-table-column type="selection" width="60" align="right">
</el-table-column>
<el-table-column label="角色">
<template slot-scope="scope">
<span v-text="scope.row.name"></span>
</template>
</el-table-column>
<el-table-column label="说明">
<template slot-scope="scope">
<span v-text="scope.row.description"></span>
</template>
</el-table-column>
</el-table>
</apass-dialog>
</div>
</template>
......@@ -116,94 +100,27 @@ import apassDialog from "@/components/apass-dialog";
export default {
components: { apassList, apassDialog },
data: () => ({
listTotal: 300,
listData: [
{
id: "012344",
account: "012344",
name: "贵阳机关事务大数据平台",
role: "普通用户",
organization: "贵阳市水利局",
state: 0,
update_time: "2020-04-27 13:24:19",
},
{
id: "012345",
account: "012345",
name: "贵州省水利厅",
role: "普通用户",
organization: "贵阳市水利局",
state: 1,
update_time: "2020-04-27 13:24:19",
},
{
id: "012346",
account: "012346",
name: "贵州省公安厅",
role: "普通用户",
organization: "贵阳市水利局",
state: 1,
update_time: "2020-04-27 13:24:19",
},
{
id: "012347",
account: "012347",
name: "贵阳机关事务大数据平台",
role: "普通用户",
organization: "贵阳市水利局",
state: 1,
update_time: "2020-04-27 13:24:19",
},
{
id: "012348",
account: "012348",
name: "长兴县应急指挥平台",
role: "普通用户",
organization: "贵阳市水利局",
state: 1,
update_time: "2020-04-27 13:24:19",
},
],
roleData: [
{
name: "超级管理员",
description: "拥有所有权限",
},
{
name: "组织管理员",
description: "拥有对应组织的权限",
},
{
name: "普通用户",
description: "普通权限用户",
},
{
name: "普通用户-开发者",
description: "基于普通用户多一些开发的选项",
},
],
listTotal: 0,
listData: [],
showDialog: false,
tempFilter: null,
}),
methods: {
initDatas(filter) {
// console.log(filter);
initDatas(filters) {
this.tempFilter = filters;
this.$http
.get("/apaas/backmgt/user/list", {
params: {
keyword: filter.keyword,
limit: filter.page,
page: filter.size,
user_id: "ym",
user_name: "",
department_id: "",
state: 1,
search: filters.keyword,
page: filters.page,
limit: filters.size,
},
})
.then(({ data }) => {
console.log(data);
// this.listTotal = data.data.total;
// this.listData = data.data.data;
// console.log(data.data);
this.listTotal = data.total;
this.listData = data.data;
})
.catch((error) => {
console.log(error);
......@@ -211,17 +128,10 @@ export default {
},
setRole(item) {
console.log("setRole " + item.name);
this.$refs.dialog.show();
},
setState(item) {
console.log("setState " + item.name);
},
dialogSelectionChange(values) {
console.log(values);
},
dialogSubmit() {
console.log("dialog submit");
},
},
};
</script>
......
......@@ -481,6 +481,7 @@ export default {
actionList: [
{
label: "删除",
class: "warn",
callback: this.deleteItem,
},
],
......
......@@ -269,6 +269,11 @@ export default new Router({
name: "users",
component: () => import("@/pages/authority/users"),
},
{
path: "/authority/users/roles/:id", // 分配角色
name: "userRoles",
component: () => import("@/pages/authority/userRoles"),
},
{
path: "/authority/users/add", // 用户管理-新增
name: "usersadd",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment