CEES-manage/src/views/cees/student/Student.api.ts

101 lines
2.4 KiB
TypeScript
Raw Normal View History

import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
2025-03-03 18:23:57 +08:00
const { createConfirm } = useMessage();
enum Api {
list = '/cees/student/list',
save = '/cees/student/add',
edit = '/cees/student/edit',
2025-03-03 18:23:57 +08:00
deleteOne = '/cees/student/delete',
deleteBatch = '/cees/student/deleteBatch',
importExcel = '/cees/student/importExcel',
exportXls = '/cees/student/exportXls',
2025-03-06 14:39:23 +08:00
updateGroupUser = '/cees/ceesGroup/updateGroupUser',
batchGroup = '/cees/student/batchGroup',
2025-03-03 18:23:57 +08:00
}
2025-03-06 14:39:23 +08:00
//获取分组
export const getGroup = () =>
defHttp.get({ url: '/cees/ceesGroup/list' }).then((res) => {
2025-03-06 14:39:23 +08:00
return res.records;
});
2025-03-03 18:23:57 +08:00
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
2025-03-03 18:23:57 +08:00
/**
*
*/
export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
2025-03-03 18:23:57 +08:00
handleSuccess();
});
};
2025-03-03 18:23:57 +08:00
/**
*
* @param params
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
2025-03-03 18:23:57 +08:00
handleSuccess();
});
},
2025-03-03 18:23:57 +08:00
});
};
/**
*
* @param params
*/
export const batchGroup = (params, handleSuccess) => {
console.log('params', params);
createConfirm({
iconType: 'warning',
title: '确认分组',
content: '是否分组选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.post({ url: Api.batchGroup, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
2025-03-06 14:39:23 +08:00
//更新分组中间表
export const updateGroupUser = (params) => {
return defHttp.post({ url: Api.updateGroupUser, params });
};
2025-03-03 18:23:57 +08:00
/**
*
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
2025-03-06 14:39:23 +08:00
// 更新分组中间表
const groupUserParams = {
userId: params.userId,
groupId: params.groupId,
};
2025-03-06 14:39:23 +08:00
updateGroupUser(groupUserParams);
return defHttp.post({ url: url, params });
};