mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 17:14:21 +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,8 @@
|
||||
:perm-create="['module_platform:email:update']"
|
||||
:perm-delete="['module_platform:email:update']"
|
||||
:delete-loading="configBatchDeleting"
|
||||
@add="openConfigDialog('create')"
|
||||
:create-loading="configCreateLoading"
|
||||
@add="handleConfigAdd"
|
||||
@delete="handleConfigBatchDelete"
|
||||
/>
|
||||
</template>
|
||||
@@ -89,7 +90,8 @@
|
||||
:perm-create="['module_platform:email:update']"
|
||||
:perm-delete="['module_platform:email:update']"
|
||||
:delete-loading="templateBatchDeleting"
|
||||
@add="openTemplateDialog('create')"
|
||||
:create-loading="templateCreateLoading"
|
||||
@add="handleTemplateAdd"
|
||||
@delete="handleTemplateBatchDelete"
|
||||
/>
|
||||
</template>
|
||||
@@ -324,6 +326,8 @@ const {
|
||||
onTableSelectionChange: onConfigSelectionChange,
|
||||
} = useTableSelection<EmailConfigTable>();
|
||||
|
||||
const configCreateLoading = ref(false);
|
||||
|
||||
const {
|
||||
columns: configColumns,
|
||||
columnChecks: configColumnChecks,
|
||||
@@ -448,6 +452,8 @@ const {
|
||||
onTableSelectionChange: onTemplateSelectionChange,
|
||||
} = useTableSelection<EmailTemplateTable>();
|
||||
|
||||
const templateCreateLoading = ref(false);
|
||||
|
||||
const {
|
||||
columns: templateColumns,
|
||||
columnChecks: templateColumnChecks,
|
||||
@@ -699,6 +705,15 @@ const configDialogFormItems = computed<FormItem[]>(() => [
|
||||
},
|
||||
]);
|
||||
|
||||
async function handleConfigAdd() {
|
||||
configCreateLoading.value = true;
|
||||
try {
|
||||
await openConfigDialog("create");
|
||||
} finally {
|
||||
configCreateLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function openConfigDialog(type: "create" | "update", row?: EmailConfigTable) {
|
||||
configDialogVisible.type = type;
|
||||
editingConfigId.value = row?.id ?? null;
|
||||
@@ -832,6 +847,15 @@ const templateDialogFormItems = computed<FormItem[]>(() => [
|
||||
},
|
||||
]);
|
||||
|
||||
async function handleTemplateAdd() {
|
||||
templateCreateLoading.value = true;
|
||||
try {
|
||||
await openTemplateDialog("create");
|
||||
} finally {
|
||||
templateCreateLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function openTemplateDialog(type: "create" | "update", row?: EmailTemplateTable) {
|
||||
templateDialogVisible.type = type;
|
||||
editingTemplateId.value = row?.id ?? null;
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
:perm-delete="['module_platform:menu:delete']"
|
||||
:perm-patch="['module_platform:menu:patch']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
/>
|
||||
@@ -497,6 +499,8 @@ const selectedIds = computed(() =>
|
||||
);
|
||||
const batchDeleting = ref(false);
|
||||
const submitLoading = ref(false);
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
const menuOptions = ref<OptionType[]>([]);
|
||||
const fullMenuTree = ref<MenuTable[]>([]);
|
||||
@@ -1124,6 +1128,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,
|
||||
@@ -1222,13 +1235,13 @@ async function handleBatchDelete() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleMoreClick(status: string) {
|
||||
async function handleMoreClick(status: number) {
|
||||
const ids = selectedIds.value;
|
||||
if (!ids.length) {
|
||||
ElMessage.warning("请先选择要操作的数据");
|
||||
return;
|
||||
}
|
||||
ElMessageBox.confirm(`确认${status === "0" ? "启用" : "停用"}该项数据?`, "警告", {
|
||||
ElMessageBox.confirm(`确认${status === 0 ? "启用" : "停用"}该项数据?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
@@ -1239,10 +1252,13 @@ async function handleMoreClick(status: string) {
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
});
|
||||
moreLoading.value = true;
|
||||
await MenuAPI.batchMenu({ ids, status });
|
||||
await loadMenuData();
|
||||
} catch {
|
||||
// 用户取消
|
||||
} finally {
|
||||
moreLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
:perm-delete="['module_package:package:delete']"
|
||||
:perm-patch="['module_package:package:update']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
:more-loading="moreLoading"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
@more="handleMoreClick"
|
||||
/>
|
||||
@@ -279,6 +281,9 @@ const pkgSearchItems = computed<SearchFormItem[]>(() => [
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
const { selectedIds, batchDeleting, onTableSelectionChange } = useTableSelection<PackageTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
const moreLoading = ref(false);
|
||||
|
||||
const opCtx = {
|
||||
onDetail: (id: number) => void handleOpenDialog("detail", id),
|
||||
onEdit: (id: number) => void handleOpenDialog("update", id),
|
||||
@@ -591,6 +596,15 @@ const { submitLoading, handleCloseDialog, handleOpenDialog, handleSubmit } =
|
||||
onUpdateSuccess: refreshCreate,
|
||||
});
|
||||
|
||||
async function handleAdd() {
|
||||
createLoading.value = true;
|
||||
try {
|
||||
await handleOpenDialog("create");
|
||||
} finally {
|
||||
createLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deletePkgRow(id: number) {
|
||||
try {
|
||||
await confirmDelete();
|
||||
@@ -606,7 +620,7 @@ async function togglePkgStatus(row: PackageTable) {
|
||||
const newStatus = row.status === 0 ? 1 : 0;
|
||||
const label = newStatus === 0 ? "启用" : "禁用";
|
||||
try {
|
||||
await confirmToggleStatus(label);
|
||||
await confirmToggleStatus(newStatus);
|
||||
await PackageAPI.batchPackageStatus({ ids: [row.id!], status: Number(newStatus) });
|
||||
ElMessage.success(`${label}成功`);
|
||||
await refreshData();
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
:perm-create="['module_system:tenant:create']"
|
||||
:perm-delete="['module_system:tenant:delete']"
|
||||
:delete-loading="batchDeleting"
|
||||
@add="handleOpenDialog('create')"
|
||||
:create-loading="createLoading"
|
||||
@add="handleAdd"
|
||||
@delete="handleBatchDelete"
|
||||
/>
|
||||
</template>
|
||||
@@ -355,6 +356,8 @@ const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(n
|
||||
|
||||
const { selectedIds, batchDeleting, onTableSelectionChange } = useTableSelection<TenantTable>();
|
||||
|
||||
const createLoading = ref(false);
|
||||
|
||||
async function deleteTenantRow(id: number) {
|
||||
try {
|
||||
await confirmDelete();
|
||||
@@ -600,6 +603,15 @@ function brandCropBind(key: string) {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user