mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-29 07:33:58 +00:00
refactor: 统一项目中状态字段类型为数字类型
这是一个大规模的类型对齐优化: 1. 将多处字符串类型的status字段统一改为数字类型,包括前后端接口定义、数据模型、页面组件 2. 重构编排节点相关的命名和注释,统一改为"节点类型"替代"编排节点类型" 3. 移除了过时的忘记密码相关接口和模板代码 4. 优化搜索栏组件,支持展开仅显示次要字段 5. 调整部分接口参数和路由逻辑,对齐前后端参数格式
This commit is contained in:
@@ -6,6 +6,7 @@ export type AuditSearchFormParams = {
|
||||
updated_id?: number | null;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
tenant_id?: number | null;
|
||||
};
|
||||
|
||||
export interface GetAuditSearchFormItemsOptions {
|
||||
@@ -15,18 +16,30 @@ export interface GetAuditSearchFormItemsOptions {
|
||||
updatedByLabel?: string;
|
||||
createdTimeLabel?: string;
|
||||
updatedTimeLabel?: string;
|
||||
tenantIdLabel?: string;
|
||||
createdByPlaceholder?: string;
|
||||
updatedByPlaceholder?: string;
|
||||
tenantIdPlaceholder?: string;
|
||||
/** 日期时间范围 valueFormat,默认 YYYY-MM-DD HH:mm:ss */
|
||||
valueFormat?: string;
|
||||
rangeSeparator?: string;
|
||||
startPlaceholder?: string;
|
||||
endPlaceholder?: string;
|
||||
/** 是否显示租户ID字段,默认 false */
|
||||
showTenantId?: boolean;
|
||||
/** 是否显示创建人字段,默认 true */
|
||||
showCreatedBy?: boolean;
|
||||
/** 是否显示更新人字段,默认 true */
|
||||
showUpdatedBy?: boolean;
|
||||
/** 是否显示创建时间字段,默认 true */
|
||||
showCreatedTime?: boolean;
|
||||
/** 是否显示更新时间字段,默认 true */
|
||||
showUpdatedTime?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 常见「创建人 / 更新人 / 创建时间 / 更新时间」搜索项,供 FaSearchBar `items` 使用。
|
||||
* 当 FaSearchBar 设置 `includeAudit` 为 true 时,会自动追加这四个字段。
|
||||
* 常见「创建人 / 更新人 / 创建时间 / 更新时间 / 租户ID」搜索项,供 FaSearchBar `items` 使用。
|
||||
* 当 FaSearchBar 设置 `includeAudit` 为 true 时,会自动追加这些字段。
|
||||
* 创建人、更新人插槽由 FaSearchBar 内置提供,也可通过 `#created_id`、`#updated_id` 覆盖。
|
||||
*/
|
||||
export function getAuditSearchFormItems(
|
||||
@@ -37,9 +50,14 @@ export function getAuditSearchFormItems(
|
||||
const rangeSep = options?.rangeSeparator ?? "至";
|
||||
const sp = options?.startPlaceholder ?? "开始";
|
||||
const ep = options?.endPlaceholder ?? "结束";
|
||||
const showTenantId = options?.showTenantId ?? false;
|
||||
const showCreatedBy = options?.showCreatedBy ?? true;
|
||||
const showUpdatedBy = options?.showUpdatedBy ?? true;
|
||||
const showCreatedTime = options?.showCreatedTime ?? true;
|
||||
const showUpdatedTime = options?.showUpdatedTime ?? true;
|
||||
|
||||
return [
|
||||
{
|
||||
const fieldMap: Record<string, SearchFormItem> = {
|
||||
created_id: {
|
||||
label: options?.createdByLabel ?? "创建人",
|
||||
key: "created_id",
|
||||
type: "input",
|
||||
@@ -48,8 +66,9 @@ export function getAuditSearchFormItems(
|
||||
style: { width: "100%" },
|
||||
},
|
||||
span,
|
||||
expandOnly: true, // 标记为展开专属字段
|
||||
},
|
||||
{
|
||||
updated_id: {
|
||||
label: options?.updatedByLabel ?? "更新人",
|
||||
key: "updated_id",
|
||||
type: "input",
|
||||
@@ -58,8 +77,9 @@ export function getAuditSearchFormItems(
|
||||
style: { width: "100%" },
|
||||
},
|
||||
span,
|
||||
expandOnly: true, // 标记为展开专属字段
|
||||
},
|
||||
{
|
||||
created_time: {
|
||||
label: options?.createdTimeLabel ?? "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
@@ -72,8 +92,9 @@ export function getAuditSearchFormItems(
|
||||
valueFormat,
|
||||
},
|
||||
span,
|
||||
expandOnly: true, // 标记为展开专属字段
|
||||
},
|
||||
{
|
||||
updated_time: {
|
||||
label: options?.updatedTimeLabel ?? "更新时间",
|
||||
key: "updated_time",
|
||||
type: "datetimerange",
|
||||
@@ -86,6 +107,27 @@ export function getAuditSearchFormItems(
|
||||
valueFormat,
|
||||
},
|
||||
span,
|
||||
expandOnly: true, // 标记为展开专属字段
|
||||
},
|
||||
];
|
||||
tenant_id: {
|
||||
label: options?.tenantIdLabel ?? "租户ID",
|
||||
key: "tenant_id",
|
||||
type: "input",
|
||||
props: {
|
||||
placeholder: options?.tenantIdPlaceholder ?? "请输入租户ID",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
span,
|
||||
expandOnly: true, // 标记为展开专属字段
|
||||
},
|
||||
};
|
||||
|
||||
const fieldOrder: string[] = [];
|
||||
if (showCreatedBy) fieldOrder.push("created_id");
|
||||
if (showUpdatedBy) fieldOrder.push("updated_id");
|
||||
if (showCreatedTime) fieldOrder.push("created_time");
|
||||
if (showUpdatedTime) fieldOrder.push("updated_time");
|
||||
if (showTenantId) fieldOrder.push("tenant_id");
|
||||
|
||||
return fieldOrder.map((key) => fieldMap[key]).filter((item): item is SearchFormItem => Boolean(item));
|
||||
}
|
||||
|
||||
@@ -209,6 +209,8 @@ export interface SearchFormItem {
|
||||
render?: (() => VNode) | Component;
|
||||
/** 是否隐藏该表单项 */
|
||||
hidden?: boolean;
|
||||
/** 是否仅在展开状态下显示(用于审计字段等次要字段) */
|
||||
expandOnly?: boolean;
|
||||
/** 表单项占据的列宽,基于24格栅格系统 */
|
||||
span?: number;
|
||||
/** 选项数据,用于 select、checkbox-group、radio-group 等 */
|
||||
@@ -280,7 +282,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
labelWidth: "70px",
|
||||
showExpand: true,
|
||||
defaultExpanded: false,
|
||||
buttonLeftLimit: 2,
|
||||
buttonLeftLimit: 0,
|
||||
showReset: true,
|
||||
showSearch: true,
|
||||
disabledSearch: false,
|
||||
@@ -492,18 +494,26 @@ const visibleFormItems = computed(() => {
|
||||
const shouldShowLess = !props.isExpand && !isExpanded.value;
|
||||
if (shouldShowLess) {
|
||||
const maxItemsPerRow = Math.floor(24 / props.span) - 1;
|
||||
return filteredItems.slice(0, maxItemsPerRow);
|
||||
// 收起时:只显示非 expandOnly 的字段,且不超过最大数量
|
||||
const nonExpandOnlyItems = filteredItems.filter((item) => !item.expandOnly);
|
||||
return nonExpandOnlyItems.slice(0, maxItemsPerRow);
|
||||
}
|
||||
// 展开时:显示所有字段
|
||||
return filteredItems;
|
||||
});
|
||||
|
||||
/**
|
||||
* 非隐藏表单项总数(包含审计字段)
|
||||
*/
|
||||
const visibleItemCount = computed(() => mergedItems.value.filter((item) => !item.hidden).length);
|
||||
|
||||
/**
|
||||
* 是否应该显示展开/收起按钮
|
||||
* 当合并后的总字段数超过一行可展示数量时显示展开按钮
|
||||
*/
|
||||
const shouldShowExpandToggle = computed(() => {
|
||||
const filteredItems = props.items.filter((item) => !item.hidden);
|
||||
return (
|
||||
!props.isExpand && props.showExpand && filteredItems.length > Math.floor(24 / props.span) - 1
|
||||
!props.isExpand && props.showExpand && visibleItemCount.value > Math.floor(24 / props.span) - 1
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -57,6 +57,18 @@
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
</ElTooltip>
|
||||
<ElFormItem v-if="showEmail" prop="email">
|
||||
<ElInput
|
||||
class="custom-height"
|
||||
v-model.trim="registerForm.email"
|
||||
clearable
|
||||
:placeholder="$t('login.placeholder.email')"
|
||||
>
|
||||
<template #prefix>
|
||||
<ElIcon><Message /></ElIcon>
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<ElCheckbox v-model="registerAgreementReadModel">
|
||||
@@ -96,7 +108,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Lock, User } from "@element-plus/icons-vue";
|
||||
import { Lock, Message, User } from "@element-plus/icons-vue";
|
||||
import type { RegisterForm } from "@/api/module_system/user";
|
||||
import type { FormRules } from "element-plus";
|
||||
|
||||
@@ -105,13 +117,14 @@ const registerForm = defineModel<RegisterForm>("registerForm", { required: true
|
||||
defineOptions({ name: "FaLoginRegisterPanel" });
|
||||
|
||||
interface Props {
|
||||
registerRules: FormRules<RegisterForm>;
|
||||
registerRules: FormRules<RegisterForm & { email: string }>;
|
||||
formKey: number | string;
|
||||
registerLoading: boolean;
|
||||
userAgreementHref: string;
|
||||
showEmail?: boolean;
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {});
|
||||
withDefaults(defineProps<Props>(), { showEmail: false });
|
||||
|
||||
const registerAgreementReadModel = defineModel<boolean>("registerAgreementRead", {
|
||||
required: true,
|
||||
|
||||
Reference in New Issue
Block a user