fix: PageTable调整后一些页面问题修复

This commit is contained in:
meilin.huang
2023-12-11 11:00:20 +08:00
parent e444500835
commit d00bd2ed72
9 changed files with 91 additions and 49 deletions

View File

@@ -223,15 +223,19 @@ const props = defineProps({
type: Api,
required: true,
},
// 数据处理回调函数,用于将请求回来的数据二次加工处理等
dataHandlerFn: {
type: Function,
},
// 懒加载即需要手动调用search方法才可调接口获取数据不会在mounted的时候调用。
lazy: {
type: Boolean,
default: false,
},
// 执行查询时对查询参数进行处理,调整等
beforeQueryFn: {
type: Function,
},
// 数据处理回调函数,用于将请求回来的数据二次加工处理等
dataHandlerFn: {
type: Function,
},
// 查询条件配置
query: {
type: Array<TableQuery>,
@@ -347,13 +351,23 @@ const handleSelectionChange = (val: any) => {
const reqPageApi = async () => {
try {
state.loading = true;
const res = await props.pageApi?.request(queryForm_.value);
let qf = queryForm_.value;
if (props.beforeQueryFn) {
qf = await props.beforeQueryFn(qf);
}
const res = await props.pageApi?.request(qf);
if (!res) {
return;
}
state.total = res.total;
if (props.dataHandlerFn) {
state.data = await props.dataHandlerFn(res.list);
} else {
state.data = res.list;
}
state.total = res.total;
} finally {
state.loading = false;
}