mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 08:57:14 +08:00
优化:优化后端公共 CRUD 组件-修改接口,将 id 从请求体提取到路径变量,更符合 RESTful 风格
This commit is contained in:
@@ -40,8 +40,8 @@ export function addDept(req: DeptRecord) {
|
||||
return axios.post(BASE_URL, req);
|
||||
}
|
||||
|
||||
export function updateDept(req: DeptRecord) {
|
||||
return axios.put(BASE_URL, req);
|
||||
export function updateDept(req: DeptRecord, id: string) {
|
||||
return axios.put(`${BASE_URL}/${id}`, req);
|
||||
}
|
||||
|
||||
export function deleteDept(ids: string | Array<string>) {
|
||||
|
@@ -48,8 +48,8 @@ export function addMenu(req: MenuRecord) {
|
||||
return axios.post(BASE_URL, req);
|
||||
}
|
||||
|
||||
export function updateMenu(req: MenuRecord) {
|
||||
return axios.put(BASE_URL, req);
|
||||
export function updateMenu(req: MenuRecord, id: string) {
|
||||
return axios.put(`${BASE_URL}/${id}`, req);
|
||||
}
|
||||
|
||||
export function deleteMenu(ids: string | Array<string>) {
|
||||
|
@@ -50,8 +50,8 @@ export function addRole(req: RoleRecord) {
|
||||
return axios.post(BASE_URL, req);
|
||||
}
|
||||
|
||||
export function updateRole(req: RoleRecord) {
|
||||
return axios.put(BASE_URL, req);
|
||||
export function updateRole(req: RoleRecord, id: string) {
|
||||
return axios.put(`${BASE_URL}/${id}`, req);
|
||||
}
|
||||
|
||||
export function deleteRole(ids: string | Array<string>) {
|
||||
|
@@ -55,8 +55,8 @@ export function addUser(req: UserRecord) {
|
||||
return axios.post(BASE_URL, req);
|
||||
}
|
||||
|
||||
export function updateUser(req: UserRecord) {
|
||||
return axios.put(BASE_URL, req);
|
||||
export function updateUser(req: UserRecord, id: string) {
|
||||
return axios.put(`${BASE_URL}/${id}`, req);
|
||||
}
|
||||
|
||||
export function deleteUser(ids: string | Array<string>) {
|
||||
|
@@ -431,7 +431,7 @@
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
if (form.value.id !== undefined) {
|
||||
updateDept(form.value).then((res) => {
|
||||
updateDept(form.value, form.value.id).then((res) => {
|
||||
handleCancel();
|
||||
getList();
|
||||
proxy.$message.success(res.msg);
|
||||
@@ -559,14 +559,16 @@
|
||||
* @param record 记录信息
|
||||
*/
|
||||
const handleChangeStatus = (record: DeptRecord) => {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateDept(record)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
if (record.id) {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateDept(record, record.id)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -482,7 +482,7 @@
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
if (form.value.id !== undefined) {
|
||||
updateMenu(form.value).then((res) => {
|
||||
updateMenu(form.value, form.value.id).then((res) => {
|
||||
handleCancel();
|
||||
getList();
|
||||
proxy.$message.success(res.msg);
|
||||
@@ -596,14 +596,16 @@
|
||||
* @param record 记录信息
|
||||
*/
|
||||
const handleChangeStatus = (record: MenuRecord) => {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateMenu(record)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
if (record.id) {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateMenu(record, record.id)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -625,7 +625,7 @@
|
||||
if (form.value.id !== undefined) {
|
||||
form.value.menuIds = getMenuAllCheckedKeys();
|
||||
form.value.deptIds = getDeptAllCheckedKeys();
|
||||
updateRole(form.value).then((res) => {
|
||||
updateRole(form.value, form.value.id).then((res) => {
|
||||
handleCancel();
|
||||
getList();
|
||||
proxy.$message.success(res.msg);
|
||||
@@ -731,14 +731,16 @@
|
||||
* @param record 记录信息
|
||||
*/
|
||||
const handleChangeStatus = (record: RoleRecord) => {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateRole(record)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
if (record.id) {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateRole(record, record.id)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -695,7 +695,7 @@
|
||||
proxy.$refs.formRef.validate((valid: any) => {
|
||||
if (!valid) {
|
||||
if (form.value.id !== undefined) {
|
||||
updateUser(form.value).then((res) => {
|
||||
updateUser(form.value, form.value.id).then((res) => {
|
||||
handleCancel();
|
||||
getList();
|
||||
proxy.$message.success(res.msg);
|
||||
@@ -825,14 +825,16 @@
|
||||
* @param record 记录信息
|
||||
*/
|
||||
const handleChangeStatus = (record: UserRecord) => {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateUser(record)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
if (record.id) {
|
||||
const tip = record.status === 1 ? '启用' : '禁用';
|
||||
updateUser(record, record.id)
|
||||
.then(() => {
|
||||
proxy.$message.success(`${tip}成功`);
|
||||
})
|
||||
.catch(() => {
|
||||
record.status = record.status === 1 ? 2 : 1;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user