Commit a296df13 by lixiaomin

修改角色

parent 3bc9783f
......@@ -78,67 +78,24 @@
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="roleList"
@selection-change="handleSelectionChange"
>
<el-table-column label="角色编号" prop="roleId" width="120" />
<el-table-column
label="角色名称"
prop="roleName"
:show-overflow-tooltip="true"
width="150"
/>
<el-table-column
label="权限字符"
prop="roleKey"
:show-overflow-tooltip="true"
width="150"
/>
<el-table-column label="显示顺序" prop="roleSort" width="100" />
<el-table-column label="状态" align="center" width="100">
<el-table v-loading="loading" :data="roleList" >
<el-table-column label="角色名称" >
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
<a @click="handleUpdate(scope.row)" style="color: blue">{{ scope.row.roleName }}</a>
</template>
</el-table-column>
<el-table-column label="备注" prop="remark"/>
<el-table-column label="人员数量" prop="userCount" />
<el-table-column label="创建时间" prop="createTime" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:role:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:role:remove']"
>删除</el-button >
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']">删除</el-button>
<el-button size="mini" v-if="scope.row.status != 0" type="text" icon="el-icon-update" @click="handleStatusChange(scope.row)" v-hasPermi="['system:role:update']">启用</el-button>
<el-button size="mini" v-if="scope.row.status == 0" type="text" icon="el-icon-update" @click="handleStatusChange(scope.row)" v-hasPermi="['system:role:update']">停用</el-button>
</template>
</el-table-column>
</el-table>
......@@ -235,29 +192,6 @@ export default {
deptNodeAll: false,
// 日期范围
dateRange: [],
// 数据范围选项
dataScopeOptions: [
{
value: "1",
label: "全部数据权限",
},
{
value: "2",
label: "自定数据权限",
},
{
value: "3",
label: "本部门数据权限",
},
{
value: "4",
label: "本部门及以下数据权限",
},
{
value: "5",
label: "仅本人数据权限",
},
],
// 菜单列表
menuOptions: [],
// 部门列表
......@@ -312,29 +246,30 @@ export default {
});
},
/** 查询部门树结构 */
getDeptTreeselect() {
deptTreeselect().then((response) => {
this.deptOptions = response.data;
});
},
// getDeptTreeselect() {
// deptTreeselect().then((response) => {
// this.deptOptions = response.data;
// });
// },
// 所有菜单节点数据
getMenuAllCheckedKeys() {
// 目前被选中的菜单节点
let checkedKeys = this.$refs.menu.getCheckedKeys();
console.log("checkedKeys",checkedKeys);
// 半选中的菜单节点
let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys();
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
return checkedKeys;
},
// 所有部门节点数据
getDeptAllCheckedKeys() {
// 目前被选中的部门节点
let checkedKeys = this.$refs.dept.getCheckedKeys();
// 半选中的部门节点
let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
return checkedKeys;
},
// getDeptAllCheckedKeys() {
// // 目前被选中的部门节点
// let checkedKeys = this.$refs.dept.getCheckedKeys();
// // 半选中的部门节点
// let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
// checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
// return checkedKeys;
// },
/** 根据角色ID查询菜单树结构 */
getRoleMenuTreeselect(roleId) {
return roleMenuTreeselect(roleId).then((response) => {
......@@ -343,25 +278,35 @@ export default {
});
},
/** 根据角色ID查询部门树结构 */
getRoleDeptTreeselect(roleId) {
return roleDeptTreeselect(roleId).then((response) => {
this.deptOptions = response.depts;
return response;
});
},
// getRoleDeptTreeselect(roleId) {
// return roleDeptTreeselect(roleId).then((response) => {
// this.deptOptions = response.depts;
// return response;
// });
// },
// 角色状态修改
handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用";
let text = "";
let tag="";
if(row.status=='0'){
text="停用";
tag="1";
}else if(row.status=='1'){
text="启用";
tag="0";
}
this.$modal
.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?')
.confirm('确认要' + text + '' + row.roleName + '角色吗?')
.then(function () {
return changeRoleStatus(row.roleId, row.status);
return changeRoleStatus(row.roleId, tag);
})
.then(() => {
this.$modal.msgSuccess(text + "成功");
.then((response) => {
if(response.code=="200"){
this.$modal.msgSuccess(text + "成功");
this.getList();
}
})
.catch(function () {
row.status = row.status === "0" ? "1" : "0";
});
},
// 取消按钮
......@@ -370,10 +315,10 @@ export default {
this.reset();
},
// 取消按钮(数据权限)
cancelDataScope() {
this.openDataScope = false;
this.reset();
},
// cancelDataScope() {
// this.openDataScope = false;
// this.reset();
// },
// 表单重置
reset() {
if (this.$refs.menu != undefined) {
......@@ -408,25 +353,25 @@ export default {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.roleId);
this.single = selection.length != 1;
this.multiple = !selection.length;
},
// 更多操作触发
handleCommand(command, row) {
switch (command) {
case "handleDataScope":
this.handleDataScope(row);
break;
case "handleAuthUser":
this.handleAuthUser(row);
break;
default:
break;
}
},
// // 多选框选中数据
// handleSelectionChange(selection) {
// this.ids = selection.map((item) => item.roleId);
// this.single = selection.length != 1;
// this.multiple = !selection.length;
// },
// // 更多操作触发
// handleCommand(command, row) {
// switch (command) {
// case "handleDataScope":
// this.handleDataScope(row);
// break;
// case "handleAuthUser":
// this.handleAuthUser(row);
// break;
// default:
// break;
// }
// },
// 树权限(展开/折叠)
handleCheckedTreeExpand(value, type) {
if (type == "menu") {
......@@ -441,22 +386,22 @@ export default {
}
}
},
// 树权限(全选/全不选)
handleCheckedTreeNodeAll(value, type) {
if (type == "menu") {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []);
} else if (type == "dept") {
this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []);
}
},
// 树权限(父子联动)
handleCheckedTreeConnect(value, type) {
if (type == "menu") {
this.form.menuCheckStrictly = value ? true : false;
} else if (type == "dept") {
this.form.deptCheckStrictly = value ? true : false;
}
},
// // 树权限(全选/全不选)
// handleCheckedTreeNodeAll(value, type) {
// if (type == "menu") {
// this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []);
// } else if (type == "dept") {
// this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []);
// }
// },
// // 树权限(父子联动)
// handleCheckedTreeConnect(value, type) {
// if (type == "menu") {
// this.form.menuCheckStrictly = value ? true : false;
// } else if (type == "dept") {
// this.form.deptCheckStrictly = value ? true : false;
// }
// },
/** 新增按钮操作 */
handleAdd() {
this.reset();
......@@ -491,26 +436,26 @@ export default {
this.$refs.dept.setCheckedKeys([]);
}
},
/** 分配数据权限操作 */
handleDataScope(row) {
this.reset();
const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
getRole(row.roleId).then((response) => {
this.form = response.data;
this.openDataScope = true;
this.$nextTick(() => {
roleDeptTreeselect.then((res) => {
this.$refs.dept.setCheckedKeys(res.checkedKeys);
});
});
this.title = "分配数据权限";
});
},
// /** 分配数据权限操作 */
// handleDataScope(row) {
// this.reset();
// const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
// getRole(row.roleId).then((response) => {
// this.form = response.data;
// this.openDataScope = true;
// this.$nextTick(() => {
// roleDeptTreeselect.then((res) => {
// this.$refs.dept.setCheckedKeys(res.checkedKeys);
// });
// });
// this.title = "分配数据权限";
// });
// },
/** 分配用户操作 */
handleAuthUser: function (row) {
const roleId = row.roleId;
this.$router.push("/system/role-auth/user/" + roleId);
},
// handleAuthUser: function (row) {
// const roleId = row.roleId;
// this.$router.push("/system/role-auth/user/" + roleId);
// },
/** 提交按钮 */
submitForm: function () {
this.$refs["form"].validate((valid) => {
......@@ -534,16 +479,16 @@ export default {
});
},
/** 提交按钮(数据权限) */
submitDataScope: function () {
if (this.form.roleId != undefined) {
this.form.deptIds = this.getDeptAllCheckedKeys();
dataScope(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.openDataScope = false;
this.getList();
});
}
},
// submitDataScope: function () {
// if (this.form.roleId != undefined) {
// this.form.deptIds = this.getDeptAllCheckedKeys();
// dataScope(this.form).then((response) => {
// this.$modal.msgSuccess("修改成功");
// this.openDataScope = false;
// this.getList();
// });
// }
// },
/** 删除按钮操作 */
handleDelete(row) {
const roleIds = row.roleId || this.ids;
......@@ -557,17 +502,8 @@ export default {
this.$modal.msgSuccess("删除成功");
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download(
"system/role/export",
{
...this.queryParams,
},
`role_${new Date().getTime()}.xlsx`
);
},
}
},
};
</script>
......
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