2
0

fix:修复报错

This commit is contained in:
zhongzm
2024-12-13 19:29:26 +08:00
parent 42fad1ca96
commit 5118479630

View File

@@ -13,7 +13,7 @@ const doGetUserInfo: AntDesign.TableApiFn<UserInfo, SearchModel> = async (params
try { try {
console.log('Search params received in API function:', params); console.log('Search params received in API function:', params);
// 直接使用传入的 params // 构造API请求参数
const apiParams = { const apiParams = {
userName: params.username, userName: params.username,
email: params.email, email: params.email,
@@ -44,10 +44,10 @@ const doGetUserInfo: AntDesign.TableApiFn<UserInfo, SearchModel> = async (params
fullname: user.nickName, fullname: user.nickName,
sex: user.sex === '1' ? 'M' : 'F', sex: user.sex === '1' ? 'M' : 'F',
birthdate: user.createTime?.split(' ')[0] || '-', birthdate: user.createTime?.split(' ')[0] || '-',
age: 0, age: 0, // 如果后端没有提供年龄字段可以设为0或者根据生日计算
email: user.email, email: user.email,
phonenumber: user.phonenumber, phonenumber: user.phonenumber,
isKYC: user.status === '0' isKYC: user.status === '0' // 假设status为'0'表示已验证
})), })),
total: data.total total: data.total
}, },
@@ -74,7 +74,17 @@ const scrollConfig = computed(() => {
}; };
}); });
const { columns, columnChecks, data, loading, getData, mobilePagination, searchParams, updateSearchParams, resetSearchParams } = useTable<AntDesign.TableApiFn<UserInfo, SearchModel>>({ const {
columns,
columnChecks,
data,
loading,
getData,
mobilePagination,
searchParams,
updateSearchParams,
resetSearchParams
} = useTable({
apiFn: doGetUserInfo, apiFn: doGetUserInfo,
immediate: true, immediate: true,
apiParams: { apiParams: {
@@ -168,13 +178,12 @@ const handleSearch = () => {
// 处理重置 // 处理重置
const handleReset = () => { const handleReset = () => {
const defaultParams: SearchModel = { const defaultParams = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
username: undefined, username: undefined,
email: undefined email: undefined
}; };
// 使用 updateSearchParams 更新参数
updateSearchParams(defaultParams); updateSearchParams(defaultParams);
resetSearchParams(); resetSearchParams();
}; };