customerInfo.pagination.js
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file 客户档案弹框分页纯函数,供 CustomerInfo 组件与单测复用。
*/
/** 客户档案弹框每页条数 */
const DEFAULT_PAGE_SIZE = 20
/**
* 是否还能加载下一页(与工单首页 onReachBottom 判断一致)
* @param {number} total 总条数
* @param {number} pageNum 当前已加载页码
* @param {number} [pageSize=20] 每页条数
* @returns {boolean}
*/
function canLoadMorePage(total, pageNum, pageSize = DEFAULT_PAGE_SIZE) {
if (!total || !pageNum) return false
return Math.ceil(total / pageSize) > pageNum
}
/**
* 为订单列表项补充车型展示字段
* @param {Array} list 接口返回的 list
* @returns {Array}
*/
function mapCustomerListWithCarType(list) {
if (!list?.length) return []
return list.map((item) => {
if (item.customer?.carSeriesName) {
item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}`
}
return item
})
}
export {
DEFAULT_PAGE_SIZE,
canLoadMorePage,
mapCustomerListWithCarType
}