mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 01:10:36 +00:00
refactor: 统一项目中状态字段类型为数字类型
这是一个大规模的类型对齐优化: 1. 将多处字符串类型的status字段统一改为数字类型,包括前后端接口定义、数据模型、页面组件 2. 重构编排节点相关的命名和注释,统一改为"节点类型"替代"编排节点类型" 3. 移除了过时的忘记密码相关接口和模板代码 4. 优化搜索栏组件,支持展开仅显示次要字段 5. 调整部分接口参数和路由逻辑,对齐前后端参数格式
This commit is contained in:
@@ -414,7 +414,7 @@ const validateRegisterConfirm = (_rule: unknown, value: string, callback: (e?: E
|
||||
callback();
|
||||
};
|
||||
|
||||
const registerRules = computed<FormRules<RegisterForm>>(() => ({
|
||||
const registerRules = computed<FormRules<RegisterForm & { email: string }>>(() => ({
|
||||
username: [{ required: true, message: t("login.message.username.required"), trigger: "blur" }],
|
||||
password: [
|
||||
{ required: true, validator: validateRegisterPassword, trigger: "blur" },
|
||||
@@ -425,6 +425,14 @@ const registerRules = computed<FormRules<RegisterForm>>(() => ({
|
||||
{ min: 6, message: t("login.message.password.min"), trigger: "blur" },
|
||||
{ validator: validateRegisterConfirm, trigger: "blur" },
|
||||
],
|
||||
email: [
|
||||
{ required: true, message: t("login.email.required"), trigger: "blur" },
|
||||
{
|
||||
type: "email",
|
||||
message: t("login.email.invalid"),
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
const validateForgetConfirm = (_rule: unknown, value: string, callback: (e?: Error) => void) => {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
/>
|
||||
@@ -240,21 +242,6 @@ const deptSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const tableRef = ref<{
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
/>
|
||||
@@ -164,6 +166,7 @@ type DictTypeSearchForm = {
|
||||
dict_type?: string;
|
||||
status?: number;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
};
|
||||
|
||||
const dictStore = useDictStore();
|
||||
@@ -174,6 +177,7 @@ const searchForm = ref<DictTypeSearchForm>({
|
||||
dict_type: undefined,
|
||||
status: undefined,
|
||||
created_time: undefined,
|
||||
updated_time: undefined,
|
||||
});
|
||||
|
||||
const showSearchBar = ref(true);
|
||||
@@ -213,21 +217,6 @@ const dictTypeSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
|
||||
@@ -15,18 +15,11 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleOpSearch"
|
||||
@reset="onOpResetSearch"
|
||||
>
|
||||
<template #created_id>
|
||||
<FaUserTableSelect
|
||||
:model-value="opSearchForm.created_id == null ? undefined : opSearchForm.created_id"
|
||||
@update:model-value="(v: number | undefined) => (opSearchForm.created_id = v)"
|
||||
@confirm-click="afterOpUserSelectSearch"
|
||||
@clear-click="afterOpUserSelectSearch"
|
||||
/>
|
||||
</template>
|
||||
</FaSearchBar>
|
||||
/>
|
||||
|
||||
<ElCard
|
||||
shadow="hover"
|
||||
@@ -126,7 +119,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
:button-left-limit="0"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleLoginSearch"
|
||||
@reset="onLoginResetSearch"
|
||||
/>
|
||||
@@ -255,22 +249,6 @@ const opSearchItems = computed<SearchFormItem[]>(() => [
|
||||
clearable: true,
|
||||
span: 6,
|
||||
},
|
||||
{ label: "创建人", key: "created_id", type: "input", span: 6 },
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
function buildOpReplaceParams(p: OpSearchForm): Record<string, unknown> {
|
||||
@@ -398,17 +376,6 @@ async function handleOpSearch(params: OpSearchForm) {
|
||||
opGetData();
|
||||
}
|
||||
|
||||
async function applyOpSearchFromForm() {
|
||||
await opSearchBarRef.value?.validate?.();
|
||||
opReplaceSearchParams(buildOpReplaceParams(opSearchForm.value));
|
||||
opGetData();
|
||||
}
|
||||
|
||||
async function afterOpUserSelectSearch() {
|
||||
await nextTick();
|
||||
await applyOpSearchFromForm();
|
||||
}
|
||||
|
||||
function onOpResetSearch() {
|
||||
opSearchForm.value = { request_path: undefined, created_id: undefined, created_time: undefined };
|
||||
void opResetSearchParams();
|
||||
@@ -486,9 +453,9 @@ async function handleOpBatchDelete() {
|
||||
|
||||
// ==================== 登录日志 ====================
|
||||
|
||||
type LoginSearchForm = { username?: string; status?: number };
|
||||
type LoginSearchForm = { username?: string; status?: number; created_time?: string[] };
|
||||
|
||||
const loginSearchForm = ref<LoginSearchForm>({ username: undefined, status: undefined });
|
||||
const loginSearchForm = ref<LoginSearchForm>({ username: undefined, status: undefined, created_time: undefined });
|
||||
const loginShowSearchBar = ref(true);
|
||||
const loginSearchBarRef = ref<InstanceType<typeof FaSearchBar> | null>(null);
|
||||
const loginSearchBarRules: Record<string, unknown> = {};
|
||||
@@ -514,6 +481,21 @@ const loginSearchItems = computed<SearchFormItem[]>(() => [
|
||||
props: { placeholder: "请选择状态", options: loginStatusOptions.value, clearable: true },
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "登录时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
function buildLoginReplaceParams(p: LoginSearchForm): Record<string, unknown> {
|
||||
@@ -523,6 +505,8 @@ function buildLoginReplaceParams(p: LoginSearchForm): Record<string, unknown> {
|
||||
p.status !== undefined && p.status !== null && p.status !== ("" as unknown as number)
|
||||
? Number(p.status)
|
||||
: undefined,
|
||||
created_time:
|
||||
Array.isArray(p.created_time) && p.created_time.length === 2 ? p.created_time : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -614,7 +598,7 @@ async function handleLoginSearch(params: LoginSearchForm) {
|
||||
}
|
||||
|
||||
function onLoginResetSearch() {
|
||||
loginSearchForm.value = { username: undefined, status: undefined };
|
||||
loginSearchForm.value = { username: undefined, status: undefined, created_time: undefined };
|
||||
void loginResetSearchParams();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
>
|
||||
@@ -257,27 +259,6 @@ const noticeSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "创建人",
|
||||
key: "created_id",
|
||||
type: "input",
|
||||
span: 6,
|
||||
},
|
||||
]);
|
||||
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
/>
|
||||
@@ -212,19 +214,18 @@ const paramSearchItems = computed<SearchFormItem[]>(() => [
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
label: "状态",
|
||||
key: "status",
|
||||
type: "select",
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
placeholder: "请选择状态",
|
||||
options: [
|
||||
{ label: "启用", value: 0 },
|
||||
{ label: "停用", value: 1 },
|
||||
],
|
||||
clearable: true,
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -13,18 +13,11 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
>
|
||||
<template #created_id>
|
||||
<FaUserTableSelect
|
||||
:model-value="searchForm.created_id == null ? undefined : searchForm.created_id"
|
||||
@update:model-value="(v: number | undefined) => (searchForm.created_id = v)"
|
||||
@confirm-click="afterUserSelectSearch"
|
||||
@clear-click="afterUserSelectSearch"
|
||||
/>
|
||||
</template>
|
||||
</FaSearchBar>
|
||||
/>
|
||||
|
||||
<ElCard
|
||||
shadow="hover"
|
||||
@@ -330,27 +323,6 @@ const positionSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "创建人",
|
||||
key: "created_id",
|
||||
type: "input",
|
||||
span: 6,
|
||||
},
|
||||
]);
|
||||
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
@@ -596,17 +568,6 @@ async function handleSearchBarSearch(params: PositionSearchForm) {
|
||||
getData();
|
||||
}
|
||||
|
||||
async function applyPositionSearchFromForm() {
|
||||
await searchBarRef.value?.validate?.();
|
||||
replaceSearchParams(buildPositionReplaceParams(searchForm.value));
|
||||
getData();
|
||||
}
|
||||
|
||||
async function afterUserSelectSearch() {
|
||||
await nextTick();
|
||||
await applyPositionSearchFromForm();
|
||||
}
|
||||
|
||||
function onResetSearch() {
|
||||
searchForm.value = {
|
||||
name: undefined,
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
/>
|
||||
@@ -339,21 +341,6 @@ const roleSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
|
||||
@@ -13,26 +13,11 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
>
|
||||
<template #created_id>
|
||||
<FaUserTableSelect
|
||||
:model-value="searchForm.created_id == null ? undefined : searchForm.created_id"
|
||||
@update:model-value="(v: number | undefined) => (searchForm.created_id = v)"
|
||||
@confirm-click="afterUserSelectSearch"
|
||||
@clear-click="afterUserSelectSearch"
|
||||
/>
|
||||
</template>
|
||||
<template #assigned_id>
|
||||
<FaUserTableSelect
|
||||
:model-value="searchForm.assigned_id == null ? undefined : searchForm.assigned_id"
|
||||
@update:model-value="(v: number | undefined) => (searchForm.assigned_id = v)"
|
||||
@confirm-click="afterUserSelectSearch"
|
||||
@clear-click="afterUserSelectSearch"
|
||||
/>
|
||||
</template>
|
||||
</FaSearchBar>
|
||||
/>
|
||||
|
||||
<ElCard
|
||||
shadow="hover"
|
||||
@@ -325,27 +310,6 @@ const ticketSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "创建人",
|
||||
key: "created_id",
|
||||
type: "input",
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "处理人",
|
||||
key: "assigned_id",
|
||||
@@ -656,17 +620,6 @@ async function handleSearchBarSearch(params: TicketSearchForm) {
|
||||
getData();
|
||||
}
|
||||
|
||||
async function applyTicketSearchFromForm() {
|
||||
await searchBarRef.value?.validate?.();
|
||||
replaceSearchParams(buildTicketReplaceParams(searchForm.value));
|
||||
getData();
|
||||
}
|
||||
|
||||
async function afterUserSelectSearch() {
|
||||
await nextTick();
|
||||
await applyTicketSearchFromForm();
|
||||
}
|
||||
|
||||
function onResetSearch() {
|
||||
searchForm.value = {
|
||||
title: undefined,
|
||||
|
||||
@@ -32,18 +32,11 @@
|
||||
:show-search="true"
|
||||
:disabled-search="false"
|
||||
:default-expanded="false"
|
||||
include-audit
|
||||
:audit-item-options="{ showTenantId: true }"
|
||||
@search="handleSearchBarSearch"
|
||||
@reset="onResetSearch"
|
||||
>
|
||||
<template #created_id>
|
||||
<FaUserTableSelect
|
||||
:model-value="searchForm.created_id == null ? undefined : searchForm.created_id"
|
||||
@update:model-value="(v: number | undefined) => (searchForm.created_id = v)"
|
||||
@confirm-click="afterUserSelectSearch"
|
||||
@clear-click="afterUserSelectSearch"
|
||||
/>
|
||||
</template>
|
||||
</FaSearchBar>
|
||||
/>
|
||||
|
||||
<ElCard
|
||||
shadow="hover"
|
||||
@@ -514,27 +507,6 @@ const userSearchItems = computed<SearchFormItem[]>(() => [
|
||||
},
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建人",
|
||||
key: "created_id",
|
||||
type: "input",
|
||||
span: 6,
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
key: "created_time",
|
||||
type: "datetimerange",
|
||||
span: 6,
|
||||
props: {
|
||||
type: "datetimerange",
|
||||
rangeSeparator: "至",
|
||||
startPlaceholder: "开始日期",
|
||||
endPlaceholder: "结束日期",
|
||||
format: "YYYY-MM-DD HH:mm:ss",
|
||||
valueFormat: "YYYY-MM-DD HH:mm:ss",
|
||||
style: { width: "100%" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const faTableRef = ref<{ elTableRef?: { clearSelection: () => void } } | null>(null);
|
||||
@@ -552,7 +524,7 @@ async function handleResetPassword(row: UserInfo) {
|
||||
ElMessage.warning("密码至少需要6位字符,请重新输入");
|
||||
return;
|
||||
}
|
||||
await UserAPI.resetUserPassword({ id: row.id!, password: value });
|
||||
await UserAPI.resetUserPassword(row.id!, { password: value });
|
||||
} catch {
|
||||
// 用户取消
|
||||
}
|
||||
@@ -789,17 +761,6 @@ async function handleSearchBarSearch(params: UserSearchForm) {
|
||||
await getData();
|
||||
}
|
||||
|
||||
async function applyUserSearchFromForm() {
|
||||
await searchBarRef.value?.validate?.();
|
||||
replaceSearchParams(buildUserReplaceParams(searchForm.value));
|
||||
await getData();
|
||||
}
|
||||
|
||||
async function afterUserSelectSearch() {
|
||||
await nextTick();
|
||||
await applyUserSearchFromForm();
|
||||
}
|
||||
|
||||
function onResetSearch() {
|
||||
searchForm.value = {
|
||||
username: undefined,
|
||||
@@ -917,7 +878,7 @@ async function handleSubmit() {
|
||||
const id = formData.value.id;
|
||||
try {
|
||||
if (id) {
|
||||
await UserAPI.updateUser(id, { id, ...formData.value });
|
||||
await UserAPI.updateUser(id, formData.value);
|
||||
await refreshUpdate();
|
||||
} else {
|
||||
await UserAPI.createUser(formData.value);
|
||||
|
||||
Reference in New Issue
Block a user