提交 4a0c0af0 authored 作者: hejie's avatar hejie

feat: 对接系统管理-角色管理模块

上级 e221f9f6
...@@ -31,8 +31,8 @@ export const getRoleList = (data?: object) => { ...@@ -31,8 +31,8 @@ export const getRoleList = (data?: object) => {
}; };
// 系统管理-删除角色 // 系统管理-删除角色
export const deleteRole = (data?: { id: string }) => { export const deleteRole = (id: string) => {
return http.request<Result>("post", "/api/role/delete-role", { data }); return http.request<Result>("post", `/api/role/delete-role/${id}`);
}; };
// 系统管理-添加角色 // 系统管理-添加角色
export const addRole = (data?: object) => { export const addRole = (data?: object) => {
...@@ -40,5 +40,5 @@ export const addRole = (data?: object) => { ...@@ -40,5 +40,5 @@ export const addRole = (data?: object) => {
}; };
// 系统管理-修改角色 // 系统管理-修改角色
export const updateRole = (data?: object) => { export const updateRole = (data?: object) => {
return http.request<Result>("post", "/api/role/update-role", { data }); return http.request<Result>("post", "/api/role/modify-role", { data });
}; };
...@@ -66,7 +66,7 @@ const { locale, translationCh, translationEn } = useTranslationLang(); ...@@ -66,7 +66,7 @@ const { locale, translationCh, translationEn } = useTranslationLang();
const ruleForm = reactive({ const ruleForm = reactive({
username: "zhangxiaoming", username: "zhangxiaoming",
password: "string", password: "123456",
verifyCode: "" verifyCode: ""
}); });
......
...@@ -10,7 +10,7 @@ import type { FormItemProps } from "../utils/types"; ...@@ -10,7 +10,7 @@ import type { FormItemProps } from "../utils/types";
import type { PaginationProps } from "@pureadmin/table"; import type { PaginationProps } from "@pureadmin/table";
import { getKeyList, deviceDetection } from "@pureadmin/utils"; import { getKeyList, deviceDetection } from "@pureadmin/utils";
import { getRoleMenu, getRoleMenuIds } from "@/api/system"; import { getRoleMenu, getRoleMenuIds } from "@/api/system";
import { getRoleList, addRole, updateRole } from "@/api/role"; import { getRoleList, addRole, updateRole, deleteRole } from "@/api/role";
import { type Ref, reactive, ref, onMounted, h, toRaw, watch } from "vue"; import { type Ref, reactive, ref, onMounted, h, toRaw, watch } from "vue";
export function useRole(treeRef: Ref) { export function useRole(treeRef: Ref) {
...@@ -105,7 +105,7 @@ export function useRole(treeRef: Ref) { ...@@ -105,7 +105,7 @@ export function useRole(treeRef: Ref) {
// ]; // ];
// }); // });
function onChange({ row, index }) { function onChange({ row }) {
ElMessageBox.confirm( ElMessageBox.confirm(
`确认要<strong>${ `确认要<strong>${
row.status === 0 ? "停用" : "启用" row.status === 0 ? "停用" : "启用"
...@@ -122,25 +122,42 @@ export function useRole(treeRef: Ref) { ...@@ -122,25 +122,42 @@ export function useRole(treeRef: Ref) {
} }
) )
.then(() => { .then(() => {
switchLoadMap.value[index] = Object.assign( // 调用修改接口,修改角色状态
{}, const params = {
switchLoadMap.value[index], id: row.id,
status: row.status
};
// 实际开发先调用修改接口,再进行下面操作
updateRole(params).then(res => {
if (res.code === "0") {
message(
`角色名称为${row.name}${row.status === 0 ? "停用" : "启用"}成功`,
{ {
loading: true type: "success"
} }
); );
setTimeout(() => {
switchLoadMap.value[index] = Object.assign(
{},
switchLoadMap.value[index],
{
loading: false
} }
);
message(`已${row.status === 0 ? "停用" : "启用"}${row.name}`, {
type: "success"
}); });
}, 300);
// switchLoadMap.value[index] = Object.assign(
// {},
// switchLoadMap.value[index],
// {
// loading: true
// }
// );
// setTimeout(() => {
// switchLoadMap.value[index] = Object.assign(
// {},
// switchLoadMap.value[index],
// {
// loading: false
// }
// );
// message(`已${row.status === 0 ? "停用" : "启用"}${row.name}`, {
// type: "success"
// });
// }, 300);
}) })
.catch(() => { .catch(() => {
row.status === 0 ? (row.status = 1) : (row.status = 0); row.status === 0 ? (row.status = 1) : (row.status = 0);
...@@ -148,7 +165,29 @@ export function useRole(treeRef: Ref) { ...@@ -148,7 +165,29 @@ export function useRole(treeRef: Ref) {
} }
function handleDelete(row) { function handleDelete(row) {
message(`您删除了角色名称为${row.name}的这条数据`, { type: "success" }); // 删除角色
ElMessageBox.confirm(
`确认要删除角色名称为<strong style='color:var(--el-color-primary)'>${
row.name
}</strong>吗?`,
"系统提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
dangerouslyUseHTMLString: true,
draggable: true
}
)
.then(() => {
deleteRole(row.id).then(res => {
if (res.code === "0") {
message(`角色名称为${row.name}的删除成功`, { type: "success" });
onSearch();
}
});
})
.catch(() => {});
onSearch(); onSearch();
} }
...@@ -228,11 +267,13 @@ export function useRole(treeRef: Ref) { ...@@ -228,11 +267,13 @@ export function useRole(treeRef: Ref) {
} else { } else {
// 实际开发先调用修改接口,再进行下面操作 // 实际开发先调用修改接口,再进行下面操作
// chores(); // chores();
// 把id加到参数里
curData.id = row.id;
updateRole(curData).then(res => { updateRole(curData).then(res => {
if (res.code === "0") { if (res.code === "0") {
message(`角色名称为${curData.name}的新增成功`, { // message(`角色名称为${curData.name}的新增成功`, {
type: "success" // type: "success"
}); // });
// 实际开发先调用新增接口,再进行下面操作 // 实际开发先调用新增接口,再进行下面操作
chores(); chores();
} }
......
...@@ -7,6 +7,7 @@ interface FormItemProps { ...@@ -7,6 +7,7 @@ interface FormItemProps {
code: string; code: string;
/** 备注 */ /** 备注 */
remark: string; remark: string;
id?: string;
} }
interface FormProps { interface FormProps {
formInline: FormItemProps; formInline: FormItemProps;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论