7bdc3051 by xiaomiao

角色管理模块角色权限处理

1 parent 46dbc9d4
......@@ -10,22 +10,27 @@ import {
} from './manageApi'
/** 角色管理开始 */
// 获取角色列表 by categoryId
// 获取角色列表 categoryId
export const getRolesById = categoryId => {
const conditionGroup = {
conditions: [
{
property: 'category',
value: categoryId,
value:categoryId,
operator: 'EQ'
}
],
queryRelation: 'AND'
}
const params = getParams(conditionGroup)
const params = getParams(conditionGroup);
console.log(api.roles,params);
return getAction(api.roles, params)
}
// 人员列表
export const getUserRoles = (id) => {
return getAction(`${api.userRoles}/${id}/users`)
}
// 更新人员
export const updateUser = (id, data) => {
return putAction(`${api.userRoles}/${id}/users`, data)
}
......
......@@ -20,14 +20,6 @@
</el-col>
<el-col :span="12">
<el-form-item label="角色类型:" prop="roleType">
<!-- <el-select v-model="dialogForm.roleType.value" placeholder="角色类型">
<el-option
v-for="item in roleTypeOptions"
:key="item.value"
:label="item.name"
:value="item.value">
</el-option>
</el-select> -->
<el-input
v-model="dialogForm.roleType"
clearable
......@@ -66,7 +58,7 @@
<script>
import Dialog from "@/components/Dialog/";
import { api, httpAction } from '@/api/manageApi'
export default {
components: {
Dialog
......@@ -104,55 +96,57 @@ export default {
if (valid) {
try {
const params = {
category: this.menuType,
category: 2,
description: this.dialogForm.roleTextArea,
name: this.dialogForm.roleName,
sort: this.sort,
type: this.dialogForm.roleType
}
console.log("this.roleId",this.roleId);
if (this.roleId) {
// params.id = this.roleId
// httpAction(`${api.roles}/${params.id}`, params, 'post').then(
// (res) => {
// if (res.status === 1) {
// this.$message.success({
// message: '修改成功',
// showClose: true
// })
// this.dialogForm = {
// roleName: '',
// roleType: ''
// }
// this.showAddEditDialog = val
// this.$emit('ok', this.menuType)
// } else {
// this.$message.error({
// message: res.message,
// showClose: true
// })
// }
// }
// )
params.id = this.roleId
console.log("修改",params.id,params);
httpAction(`${api.roles}/${params.id}`, params, 'post').then(
(res) => {
if (res.status === 1) {
this.$message.success({
message: '修改成功',
showClose: true
})
this.dialogForm = {
roleName: '',
roleType: ''
}
this.showAddEditDialog = val
this.$emit('ok', this.menuType)
} else {
this.$message.error({
message: res.message,
showClose: true
})
}
}
)
} else {
// httpAction(api.roles, params, 'post').then((res) => {
// if (res.status === 1) {
// this.$message.success({
// message: '新增成功',
// showClose: true
// })
// this.dialogForm = {
// roleName: '',
// roleType: ''
// }
// this.showAddEditDialog = val
// this.$emit('ok', this.menuType)
// } else {
// this.$message.error({
// message: res.message,
// showClose: true
// })
// }
// })
httpAction(api.roles, params, 'post').then((res) => {
if (res.status === 1) {
this.$message.success({
message: '新增成功',
showClose: true
})
this.dialogForm = {
roleName: '',
roleType: ''
}
this.showAddEditDialog = val
this.$emit('ok', this.menuType)
} else {
this.$message.error({
message: res.message,
showClose: true
})
}
})
}
} catch (e) {
console.error(e)
......@@ -162,6 +156,7 @@ export default {
},
// 取消事件
handleCloseDialog() {
this.$refs.form.resetFields()
this.dialogForm = {
roleName: '',
roleType: ''
......
......@@ -7,7 +7,7 @@
</el-form-item>
<el-row class="mb-5">
<el-col :span="2" class="btnColRight">
<btn nativeType="cx" @click="handleAdd">增加角色</btn>
<btn nativeType="cx" @click="handleAddEdit">增加角色</btn>
</el-col>
</el-row>
</el-form>
......@@ -41,7 +41,7 @@ import {
import { getRolesById, getUserRoles } from "@/api/Rolemanagement";
import data from "./data";
import sjsbTask from "@/api/sjsbTask.js";
import { api, getAction } from "@/api/manageApi";
import { api, getAction,deleteAction } from "@/api/manageApi";
import tableMixin from "@/mixins/tableMixin.js";
import EditDialog from "./edit-dialog.vue";
import Roleslistdiglog from "./roleslistdiglog.vue";
......@@ -58,6 +58,7 @@ export default {
waitMemberList: [],
keyList: [],
listdata: [],
tableUrl: api.roles,
form: {
job_name: "",
currentPage: 1,
......@@ -140,7 +141,10 @@ export default {
render: (h, scope) => {
return (
<div>
<el-tooltip class="item" effect="dark" disabled={scope.row.type !== 'Everyone'} content="没有点击的权限" placement="top">
<span>
<el-button
disabled={scope.row.type === 'Everyone'}
type="text"
size="mini"
icon="el-icon-video-pause"
......@@ -150,27 +154,39 @@ export default {
>
人员
</el-button>
</span>
</el-tooltip>
<el-tooltip class="item" effect="dark" disabled={scope.row.category !== 1} content="系统内置角色 不允许修改" placement="top">
<span>
<el-button
disabled={scope.row.category === 1}
type="text"
size="mini"
icon="el-icon-edit"
onClick={() => {
this.handleEdit(scope.row);
this.handleAddEdit(scope.row);
}}
>
修改
</el-button>
</span>
</el-tooltip>
<el-tooltip class="item" effect="dark" disabled={scope.row.category !== 1} content="系统内置角色 不允许删除" placement="top">
<span>
<el-button
type="text"
disabled={scope.row.category === 1}
size="mini"
icon="el-icon-delete"
style="color:#F56C6C"
// style="color:#F56C6C"
onClick={() => {
this.handleDel(scope.row);
this.handleDelete(scope.row.id, scope.row.name);
}}
>
删除
</el-button>
</span>
</el-tooltip>
</div>
);
},
......@@ -192,15 +208,29 @@ export default {
methods: {
// 获取角色列表
getTableData() {
getRolesById()
let Builtinrole=[]
let Publicrole=[]
getRolesById(1)
.then((res) => {
console.log("res.content", res.content);
Builtinrole = res.content;
getRolesById(2)
.then((res) => {
this.listdata = res.content;
console.log("res.content", res.content);
Publicrole = res.content;
this.listdata = Builtinrole.concat(Publicrole);
this.listdata = judgeSort(this.listdata);
})
.catch((e) => console.error(e));
},
})
.catch((e) => console.error(e));
},
// 人员配置
getUserList(row) {
const params = {};
const queryOptions = {
......@@ -238,7 +268,7 @@ export default {
});
}
this.$refs.rolesForm.adds(this.waitMemberList,row.id);
this.$refs.rolesForm.adds(this.waitMemberList, row.id);
} else {
this.$message.error({ message: res.message, showClose: true });
}
......@@ -246,28 +276,19 @@ export default {
this.$refs.rolesForm.title = "人员配置";
} else this.$message.error({ message: res.message, showClose: true });
});
},
// 新增角色
handleAdd() {
// this.$refs.addEditDialog.roleId = value.id
// this.roleSort = value.sort ? value.sort : 0
this.$refs.addEditDialog.showAddEditDialog = true;
this.$refs.addEditDialog.dialogTitle = "新增";
},
// 修改角色
handleEdit(row) {
this.$refs.addEditDialog.roleId = row.id;
this.roleSort = row.sort ? row.sort : 0;
if (row.id) {
this.$refs.addEditDialog.dialogForm.roleName = row.name;
this.$refs.addEditDialog.dialogForm.roleType = row.type;
this.$refs.addEditDialog.dialogForm.roleTextArea = row.description;
// 新增、修改角色
handleAddEdit(value) {
this.$refs.addEditDialog.menuType = this.menuType;
this.$refs.addEditDialog.roleId = value.id;
this.roleSort = value.sort ? value.sort : 0;
if (value.id) {
this.$refs.addEditDialog.dialogForm.roleName = value.name;
this.$refs.addEditDialog.dialogForm.roleType = value.type;
this.$refs.addEditDialog.dialogForm.roleTextArea = value.description;
}
this.$refs.addEditDialog.showAddEditDialog = true;
this.$refs.addEditDialog.dialogTitle = "修改";
this.$refs.addEditDialog.dialogTitle = value.id ? "修改" : "新增";
},
// 上移下移
moveUpward(index, row) {
......@@ -284,39 +305,45 @@ export default {
},
// 删除
handleDel(row) {
this.$confirm("此操将进行删除操作, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
handleDelete: function(id, content = '') {
this.$confirm(
`<div class="customer-message-wrapper">
<h5 class="title">您确认要执行该操作用于以下信息:</h5>
<p class="content" aria-controls="${content}">${content}
</p>
<p class="result">执行后,数据将
<span >无法恢复</span>
</p>
</div>`,
'执行确认',
{
dangerouslyUseHTMLString: true,
customClass: 'customer-delete',
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
.then(() => {
sjsbTask
.sjsbTaskRemove(row.id)
.then((res) => {
if ((res.code = 200)) {
this.$message({
type: "success",
message: res.message,
});
// this.featchData();
if (!this.tableUrl) {
this.$message.error({
message: '请设置tableUrl属性为接口地址!',
showClose: true
})
return
}
const url = this.tableUrl + '/' + id
deleteAction(url).then(res => {
if (res.status === 1) {
this.$message.success({ message: res.message, showClose: true })
this.loadDataS(this.subcode)
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
.catch((error) => {
this.$alert(error, "提示", {
confirmButtonText: "确定",
type: "error",
});
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消",
});
});
.catch(() => {})
},
},
};
</script>
......
......@@ -27,6 +27,7 @@
<script>
import Dialog from "@/components/Dialog/";
import { updateUser } from "@/api/Rolemanagement";
export default {
name: "",
components: { Dialog },
......@@ -72,7 +73,7 @@ export default {
],
data: [],
// 角色id
roleId:""
roleId: "",
},
multipleSelection: [],
};
......@@ -82,11 +83,12 @@ export default {
created() {},
mounted() {},
methods: {
adds(a,roleId) {
this.roleId=roleId
// 人员配置根据selectStatus字段确定已选人员
adds(a, rid) {
this.roleId = rid;
this.visible = true;
console.log("a",a);
this.tableData.data=a
console.log("a", a);
this.tableData.data = a;
this.tableData.data.forEach((item, index) => {
if (item.selectStatus === 0) {
this.$nextTick(() => {
......@@ -103,14 +105,22 @@ export default {
},
// 保存
handleSaveMember() {
let arrlist= this.tableData.data.filter((item) => {
return item.selectStatus==0
})
const idList = arrlist.map((item) => {
return item.id
})
const idList = this.multipleSelection.map((item) => {
return item.id;
});
console.log("this.roleId",this.roleId,idList);
updateUser(this.roleId, idList).then((res) => {
console.log("res",res);
if (res.status === 1) {
this.$message.success({ message: "保存成功", showClose: true });
this.visible = false;
// this.$emit("setUsers", this.roleId);
// this.resetMemberConfig();
} else this.$message.error({ message: res.message, showClose: true });
});
},
handleSelectionChange(val) {
console.log("val", val);
this.multipleSelection = val;
},
},
......
......@@ -186,29 +186,11 @@ export default {
},
};
},
created() {
this.featchData();
},
methods: {
// 添加索引
// addIndexes (data = this.tableData.data, isAdd = true) {
// data.forEach((item, index) => {
// if (index == 0) {
// item.codeShow = true;
// item.nameShow = false;
// item.normcodeShow = false;
// item.normnameShow = false;
// } else {
// item.codeShow = false;
// item.nameShow = false;
// item.normcodeShow = false;
// item.normnameShow = false;
// }
// if (isAdd) {
// item.index = index + 1;
// }
// if (item.children) {
// this.addIndexes(item.children, false);
// }
// });
// },
handleAdd() {
this.taskData = null;
this.$refs.dialogForm.add();
......