mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-30 15:19:32 +08:00
Feat: optimized code
This commit is contained in:
parent
6e47a5407e
commit
025e68b7b1
@ -102,6 +102,21 @@ const handleToUserConfig = (user: any) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
const fetchData = async () => {
|
||||
const res = await execute({
|
||||
params: {
|
||||
userName: operationForm.value.name,
|
||||
page: operationForm.value.currentPage,
|
||||
page_size: operationForm.value.pageSize
|
||||
}
|
||||
});
|
||||
data.value = res.value!;
|
||||
total.value = res.value?.total ?? 0;
|
||||
};
|
||||
|
||||
const reload = throttle(() => {
|
||||
fetchData();
|
||||
}, 2000);
|
||||
|
||||
const deleteUser = async (userList: string[]) => {
|
||||
const { execute } = deleteUserApi();
|
||||
@ -119,18 +134,6 @@ const handleDeleteUser = async (user: UserInfo) => {
|
||||
await deleteUser([user.uuid]);
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
const res = await execute({
|
||||
params: {
|
||||
userName: operationForm.value.name,
|
||||
page: operationForm.value.currentPage,
|
||||
page_size: operationForm.value.pageSize
|
||||
}
|
||||
});
|
||||
data.value = res.value!;
|
||||
total.value = res.value?.total ?? 0;
|
||||
};
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
if (selectedUsers.value.length === 0) {
|
||||
return message.warn(t("请选择要删除的用户"));
|
||||
@ -177,13 +180,11 @@ const newUserDialog = ref({
|
||||
return message.error(t("请正确填写表单"));
|
||||
|
||||
try {
|
||||
const res = await addUserExecute({
|
||||
await addUserExecute({
|
||||
data: newUserDialog.value.data
|
||||
});
|
||||
if (res.value === true) {
|
||||
message.success(t("新增用户成功"));
|
||||
newUserDialog.value.hidden();
|
||||
}
|
||||
message.success(t("新增用户成功"));
|
||||
newUserDialog.value.hidden();
|
||||
} catch (error: any) {
|
||||
message.error(t("新增用户失败:") + error.response.data.data);
|
||||
}
|
||||
@ -191,10 +192,6 @@ const newUserDialog = ref({
|
||||
}
|
||||
});
|
||||
|
||||
const reload = throttle(() => {
|
||||
fetchData();
|
||||
}, 2000);
|
||||
|
||||
onMounted(async () => {
|
||||
fetchData();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user