mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 09:10:59 +00:00
refactor: 统一项目代码风格并修复多处类型与调用问题
本次提交包含多项优化: 1. 移除大量冗余的文件头注释与过时的from __future__导入 2. 将CRUD的list方法统一重命名为get_list保持接口一致 3. 修复前后端状态字段类型不匹配问题,将string类型status改为number 4. 修正前端文案错别字,将"代办事项"修正为标准写法 5. 更新sqlalchemy版本并调整依赖配置 6. 新增缓存工具类替代fastapi-cache2,重构缓存调用逻辑 7. 新增开源授权函生成相关工具与数据库字段支持 8. 为多个业务模块添加防重复提交loading状态 9. 修复邮件模型的外键关联缺失问题 10. 优化pdf生成工具的导入时机与文档注释
This commit is contained in:
@@ -36,7 +36,9 @@
|
||||
:perm-delete="['module_system:dept:delete']"
|
||||
:perm-patch="['module_system:dept:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
/>
|
||||
@@ -267,6 +269,9 @@ const deptOptions = ref<OptionType[]>([]);
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<DeptTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
async function loadDeptData() {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -378,6 +383,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } = use
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const opCtx = {
|
||||
onAddChild: (parentId: number) =>
|
||||
void handleOpenDialog("create", undefined, { parent_id: parentId }),
|
||||
@@ -513,7 +527,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -521,11 +535,14 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await DeptAPI.batchDept({ ids, status });
|
||||
await loadDeptData();
|
||||
await userStore.getUserInfo();
|
||||
} catch {
|
||||
// 用户取消或操作失败
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
:perm-delete="['module_system:dict_data:delete']"
|
||||
:perm-patch="['module_system:dict_data:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -369,6 +371,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<DictDataTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
const {
|
||||
columns,
|
||||
columnChecks,
|
||||
@@ -671,6 +676,15 @@ async function handleCloseDialog() {
|
||||
await resetForm();
|
||||
}
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleOpenDialog(type: "create" | "update" | "detail", id?: number) {
|
||||
dialogVisible.type = type;
|
||||
if (id) {
|
||||
@@ -786,7 +800,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -794,12 +808,15 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await DictAPI.batchDictData({ ids, status });
|
||||
await refreshData();
|
||||
dictStore.clearDictData();
|
||||
if (props.dictType) await dictStore.getDict([props.dictType]);
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
:perm-delete="['module_system:dict_type:delete']"
|
||||
:perm-patch="['module_system:dict_type:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -234,6 +236,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<DictTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
// ─── 对话框状态 ───
|
||||
const { dialogVisible } = useCrudDialog();
|
||||
|
||||
@@ -306,6 +311,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } = use
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const dictDialogFormItems = computed<FormItem[]>(() => [
|
||||
{
|
||||
label: "字典名称",
|
||||
@@ -548,7 +562,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -556,6 +570,7 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await DictAPI.batchDictType({ ids, status });
|
||||
await refreshData();
|
||||
dictStore.clearDictData();
|
||||
@@ -563,6 +578,8 @@ async function handleMoreClick(status: string) {
|
||||
if (dictTypes.length > 0) await dictStore.getDict(dictTypes);
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
:perm-delete="['module_system:notice:delete']"
|
||||
:perm-patch="['module_system:notice:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -284,6 +286,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<NoticeTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
// ─── 对话框状态 ───
|
||||
const { dialogVisible } = useCrudDialog();
|
||||
|
||||
@@ -382,6 +387,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } =
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const noticeDialogFormItems = computed<FormItem[]>(() => [
|
||||
{
|
||||
label: "标题",
|
||||
@@ -648,7 +662,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -656,11 +670,14 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await NoticeAPI.batchNotice({ ids, status });
|
||||
await refreshData();
|
||||
await noticeStore.getNotice();
|
||||
} catch {
|
||||
ElMessage.info("操作取消");
|
||||
// 用户取消或操作失败
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
:perm-export="['module_system:param:export']"
|
||||
:perm-delete="['module_system:param:delete']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
/>
|
||||
@@ -233,6 +234,8 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<ConfigTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
|
||||
// ─── 对话框状态 ───
|
||||
const { dialogVisible } = useCrudDialog();
|
||||
|
||||
@@ -308,6 +311,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } =
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const paramDialogFormItems = computed<FormItem[]>(() => [
|
||||
{
|
||||
label: "配置名称",
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
:perm-delete="['module_system:position:delete']"
|
||||
:perm-patch="['module_system:position:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -355,6 +357,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<PositionTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
const opCtx = {
|
||||
onDetail: (id: number) => void handleOpenDialog("detail", id),
|
||||
onEdit: (id: number) => void handleOpenDialog("update", id),
|
||||
@@ -528,6 +533,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } =
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const positionDialogFormItems = computed<FormItem[]>(() => [
|
||||
{
|
||||
label: "岗位名称",
|
||||
@@ -622,7 +636,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -630,11 +644,14 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await PositionAPI.batchPosition({ ids, status });
|
||||
await refreshData();
|
||||
await userStore.getUserInfo();
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
:perm-delete="['module_system:role:delete']"
|
||||
:perm-patch="['module_system:role:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -360,6 +362,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<RoleTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
const drawerVisible = ref(false);
|
||||
const checkedRole = ref({ id: 0, name: "" });
|
||||
|
||||
@@ -466,6 +471,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } = use
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const opCtx = {
|
||||
onPerm: handleOpenAssignPermDialog,
|
||||
onDetail: (id: number) => void handleOpenDialog("detail", id),
|
||||
@@ -659,7 +673,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -667,12 +681,15 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await RoleAPI.batchRole({ ids, status });
|
||||
await refreshData();
|
||||
const userStore = useUserStore();
|
||||
await userStore.getUserInfo();
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -53,7 +53,9 @@
|
||||
:perm-delete="['module_system:ticket:delete']"
|
||||
:perm-patch="['module_system:ticket:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
@@ -358,6 +360,9 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
const { selectedRows, selectedIds, batchDeleting, onTableSelectionChange } =
|
||||
useTableSelection<TicketTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
// ─── 对话框状态 ───
|
||||
const { dialogVisible } = useCrudDialog();
|
||||
|
||||
@@ -469,6 +474,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } = use
|
||||
},
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const ticketDialogFormItems = computed<FormItem[]>(() => [
|
||||
{
|
||||
label: "工单标题",
|
||||
@@ -753,7 +767,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -761,10 +775,13 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
moreLoading.value = true;
|
||||
await TicketAPI.batchTicket({ ids, status });
|
||||
await refreshData();
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -66,7 +66,9 @@
|
||||
:perm-patch="['module_system:user:patch']"
|
||||
:import-loading="uploadLoading"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@import="openImport"
|
||||
@export="openExport"
|
||||
@delete="handleBatchDelete"
|
||||
@@ -352,6 +354,8 @@ const dataFormRef = ref<InstanceType<typeof FaForm> | null>(null);
|
||||
const userFormRenderKey = ref(0);
|
||||
const submitLoading = ref(false);
|
||||
const uploadLoading = ref(false);
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
const deptFilterId = ref<string | number | undefined>(undefined);
|
||||
|
||||
const drawerSize = computed(() => (appStore.device === DeviceEnum.DESKTOP ? "450px" : "90%"));
|
||||
@@ -844,6 +848,15 @@ async function handleCloseDialog() {
|
||||
await resetForm();
|
||||
}
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleOpenDialog(type: "create" | "update" | "detail", id?: number) {
|
||||
dialogVisible.type = type;
|
||||
if (id) {
|
||||
@@ -944,7 +957,7 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
@@ -952,13 +965,13 @@ async function handleMoreClick(status: string) {
|
||||
}
|
||||
try {
|
||||
await confirmToggleStatus(status);
|
||||
batchDeleting.value = true;
|
||||
moreLoading.value = true;
|
||||
await UserAPI.batchUser({ ids, status });
|
||||
await refreshData();
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
batchDeleting.value = false;
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user