表单显示问题优化
parent
88f358df33
commit
a1bb5b74c5
|
|
@ -28,13 +28,14 @@ async def get_test_form_list(
|
||||||
current_user: CurrentUserModel = Depends(LoginService.get_current_user)
|
current_user: CurrentUserModel = Depends(LoginService.get_current_user)
|
||||||
):
|
):
|
||||||
"""获取表单列表"""
|
"""获取表单列表"""
|
||||||
query_obj = TestFormPageModel(
|
# 直接使用字典传递参数,避免 Pydantic alias 问题
|
||||||
page_num=page_num,
|
query_obj = {
|
||||||
page_size=page_size,
|
'page_num': page_num,
|
||||||
name=name,
|
'page_size': page_size,
|
||||||
form_type=form_type,
|
'name': name,
|
||||||
is_active=is_active
|
'form_type': form_type,
|
||||||
)
|
'is_active': is_active
|
||||||
|
}
|
||||||
result = await TestFormService.get_test_form_list(db, query_obj, is_page=True)
|
result = await TestFormService.get_test_form_list(db, query_obj, is_page=True)
|
||||||
return ResponseUtil.success(dict_content=result)
|
return ResponseUtil.success(dict_content=result)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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_num: int = Field(default=1, description='当前页码')
|
||||||
page_size: int = Field(default=10, description='每页记录数')
|
page_size: int = Field(default=10, description='每页记录数')
|
||||||
name: Optional[str] = Field(default=None, description='表单名称')
|
name: Optional[str] = Field(default=None, description='表单名称')
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,12 @@ class TestFormService:
|
||||||
return CamelCaseUtil.transform_result(test_form)
|
return CamelCaseUtil.transform_result(test_form)
|
||||||
|
|
||||||
@classmethod
|
@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:
|
if is_page:
|
||||||
test_form_list, total = await TestFormDao.get_list(db, query_obj, is_page=True)
|
test_form_list, total = await TestFormDao.get_list(db, query_obj, is_page=True)
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ export default {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
name: null,
|
name: null,
|
||||||
formType: 'CONDITION',
|
form_type: 'CONDITION',
|
||||||
isActive: null
|
isActive: null
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
|
|
@ -138,6 +138,7 @@ export default {
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.queryParams.name = null;
|
this.queryParams.name = null;
|
||||||
this.queryParams.isActive = null;
|
this.queryParams.isActive = null;
|
||||||
|
// 保留 form_type 筛选条件
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ export default {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
name: null,
|
name: null,
|
||||||
formType: 'RESULT',
|
form_type: 'RESULT',
|
||||||
isActive: null
|
isActive: null
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
|
|
@ -138,6 +138,7 @@ export default {
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.queryParams.name = null;
|
this.queryParams.name = null;
|
||||||
this.queryParams.isActive = null;
|
this.queryParams.isActive = null;
|
||||||
|
// 保留 form_type 筛选条件
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue