|
@@ -18,8 +18,14 @@
|
|
|
:index="indexMethod"
|
|
|
></el-table-column>
|
|
|
<el-table-column prop="name" label="角色名称"></el-table-column>
|
|
|
- <el-table-column class-name="action-column" label="操作" width="120px">
|
|
|
+ <el-table-column class-name="action-column" label="操作" width="220px">
|
|
|
<template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ :class="scope.row.defaultRole ? 'btn-danger' : 'btn-primary'"
|
|
|
+ type="text"
|
|
|
+ @click="toSetDefaultRole(scope.row)"
|
|
|
+ >{{ scope.row.defaultRole ? "取消为内置角色" : "设置为内置角色" }}
|
|
|
+ </el-button>
|
|
|
<el-button
|
|
|
v-if="!scope.row.defaultRole"
|
|
|
class="btn-primary"
|
|
@@ -27,6 +33,13 @@
|
|
|
@click="toEdit(scope.row)"
|
|
|
>编辑</el-button
|
|
|
>
|
|
|
+ <el-button
|
|
|
+ v-if="!scope.row.defaultRole"
|
|
|
+ class="btn-danger"
|
|
|
+ type="text"
|
|
|
+ @click="toDelete(scope.row)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -42,7 +55,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { ABLE_TYPE } from "@/constants/enumerate";
|
|
|
-import { userRoleListPage } from "../api";
|
|
|
+import { userRoleListPage, setRoleDefault } from "../api";
|
|
|
+import { deleteRole } from "../../base/api";
|
|
|
import ModifySystemRole from "../components/ModifySystemRole";
|
|
|
|
|
|
export default {
|
|
@@ -78,6 +92,33 @@ export default {
|
|
|
toAdd() {
|
|
|
this.curRole = {};
|
|
|
this.$refs.ModifySystemRole.open();
|
|
|
+ },
|
|
|
+ toSetDefaultRole(row) {
|
|
|
+ const action = row.defaultRole ? "取消" : "设置";
|
|
|
+ this.$confirm(`确定要${action}角色【${row.name}】为内置角色吗?`, "提示", {
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ const defaultRole = !row.defaultRole;
|
|
|
+ await setRoleDefault({
|
|
|
+ id: row.id,
|
|
|
+ defaultRole
|
|
|
+ });
|
|
|
+ row.defaultRole = defaultRole;
|
|
|
+ this.$message.success("操作成功!");
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ toDelete(row) {
|
|
|
+ this.$confirm(`确定要删除角色【${row.name}】吗?`, "提示", {
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(async () => {
|
|
|
+ await deleteRole([row.id]);
|
|
|
+ this.$message.success("删除成功!");
|
|
|
+ this.deletePageLastItem();
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
}
|
|
|
}
|
|
|
};
|