代码格式化

pull/157/head
gao 2023-08-28 11:53:54 +08:00
parent 2dcff6f5c5
commit d28af316a8
1 changed files with 122 additions and 120 deletions

View File

@ -58,23 +58,24 @@ watch(props, (newValue) => {
//
const onPage = (param = {}) => {
if (props.pageFunction) {
initParams.value = { ...initParams.value, ...param, size: props.pageSize };
initParams.value = { ...initParams.value, ...param, size: props.pageSize }
// API
spinning.value = true;
props.pageFunction(initParams.value)
spinning.value = true
props
.pageFunction(initParams.value)
.then((data) => {
//
initParams.value.current = data.current;
initParams.value.current = data.current
//
total.value = data.total;
options.value = data.records;
queryEcho();
total.value = data.total
options.value = data.records
queryEcho()
})
.finally(() => {
spinning.value = false;
});
spinning.value = false
})
}
}
};
const queryEcho = () => {
//
if (props.echoFunction) {
@ -116,28 +117,29 @@ const handlePopupScroll = (e) => {
const handlePagination = () => {
//
if (options.value.length < total.value) {
const param = { ...initParams.value, current: initParams.value.current + 1 };
spinning.value = true;
props.pageFunction(param)
const param = { ...initParams.value, current: initParams.value.current + 1 }
spinning.value = true
props
.pageFunction(param)
.then((data) => {
if (data.records.length > 0) {
//
initParams.value.current = data.current;
initParams.value.current = data.current
//
const newOptions = [...options.value, ...data.records];
const newOptions = [...options.value, ...data.records]
// 使 id
const uniqueOptions = newOptions.reduce((acc, cur) => {
acc[cur.id] = cur;
return acc;
}, {});
options.value = Object.values(uniqueOptions);
acc[cur.id] = cur
return acc
}, {})
options.value = Object.values(uniqueOptions)
}
})
.finally(() => {
spinning.value = false;
});
spinning.value = false
})
}
}
};
defineExpose({
onPage