mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-29 22:56:41 +08:00
fix table data with null records
This commit is contained in:
parent
9ad5d7170a
commit
9c81fe8064
@ -43,19 +43,29 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
// Ensure that the size is greater than 0, If it is less than 0, it will cause paging calculation errors.
|
// Ensure that the size is greater than 0, If it is less than 0, it will cause paging calculation errors.
|
||||||
const pageSize = size <= 0 ? 10 : size;
|
const pageSize = size <= 0 ? 10 : size;
|
||||||
|
|
||||||
|
let recordsData;
|
||||||
|
if (Array.isArray(records) && records.length > 0) {
|
||||||
const recordsWithIndex = records.map((item, index) => {
|
const recordsWithIndex = records.map((item, index) => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
index: (current - 1) * pageSize + index + 1
|
index: (current - 1) * pageSize + index + 1
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
recordsData = {
|
||||||
return {
|
|
||||||
data: recordsWithIndex,
|
data: recordsWithIndex,
|
||||||
pageNum: current,
|
pageNum: current,
|
||||||
pageSize,
|
pageSize,
|
||||||
total
|
total
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
recordsData = {
|
||||||
|
data: [],
|
||||||
|
pageNum: current,
|
||||||
|
pageSize,
|
||||||
|
total: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return recordsData;
|
||||||
},
|
},
|
||||||
getColumnChecks: cols => {
|
getColumnChecks: cols => {
|
||||||
const checks: NaiveUI.TableColumnCheck[] = [];
|
const checks: NaiveUI.TableColumnCheck[] = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user