Commit a296df13 by lixiaomin

修改角色

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