表单显示问题优化

main
COT001\DEV 2026-03-31 11:07:21 +08:00
parent 88f358df33
commit a1bb5b74c5
5 changed files with 18 additions and 12 deletions

View File

@ -28,13 +28,14 @@ async def get_test_form_list(
current_user: CurrentUserModel = Depends(LoginService.get_current_user)
):
"""获取表单列表"""
query_obj = TestFormPageModel(
page_num=page_num,
page_size=page_size,
name=name,
form_type=form_type,
is_active=is_active
)
# 直接使用字典传递参数,避免 Pydantic alias 问题
query_obj = {
'page_num': page_num,
'page_size': page_size,
'name': name,
'form_type': form_type,
'is_active': is_active
}
result = await TestFormService.get_test_form_list(db, query_obj, is_page=True)
return ResponseUtil.success(dict_content=result)

View File

@ -49,8 +49,7 @@ class TestFormPageModel(BaseModel):
"""
分页查询模型
"""
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
# 不使用 alias_generator直接使用下划线命名
page_num: int = Field(default=1, description='当前页码')
page_size: int = Field(default=10, description='每页记录数')
name: Optional[str] = Field(default=None, description='表单名称')

View File

@ -24,8 +24,12 @@ class TestFormService:
return CamelCaseUtil.transform_result(test_form)
@classmethod
async def get_test_form_list(cls, db: AsyncSession, query_obj: TestFormPageModel, is_page: bool = True):
async def get_test_form_list(cls, db: AsyncSession, query_obj, is_page: bool = True):
"""获取表单列表"""
# 如果 query_obj 是字典,转换为 TestFormPageModel
if isinstance(query_obj, dict):
query_obj = TestFormPageModel(**query_obj)
if is_page:
test_form_list, total = await TestFormDao.get_list(db, query_obj, is_page=True)
return {

View File

@ -101,7 +101,7 @@ export default {
pageNum: 1,
pageSize: 10,
name: null,
formType: 'CONDITION',
form_type: 'CONDITION',
isActive: null
},
form: {
@ -138,6 +138,7 @@ export default {
resetQuery() {
this.queryParams.name = null;
this.queryParams.isActive = null;
// form_type
this.handleQuery();
},
handleSelectionChange(selection) {

View File

@ -101,7 +101,7 @@ export default {
pageNum: 1,
pageSize: 10,
name: null,
formType: 'RESULT',
form_type: 'RESULT',
isActive: null
},
form: {
@ -138,6 +138,7 @@ export default {
resetQuery() {
this.queryParams.name = null;
this.queryParams.isActive = null;
// form_type
this.handleQuery();
},
handleSelectionChange(selection) {