mapOverviewRow.js
1.42 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
41
42
43
44
45
46
47
import { collectSceneCodes, mapSceneType } from "./mapSceneType";
/**
* dailyReport.overview.page 行数据 → 表格行
*/
export function mapOverviewRow(row = {}) {
const scene = mapSceneType(row.sceneType, row);
const reportStatus = row.reportStatus;
const createdDate = row.createdDate ?? row.lastSaveTime ?? row.updatedDate;
let baseSceneCode = row.baseSceneCode;
if (!collectSceneCodes(baseSceneCode).length) {
const sceneListCodes = collectSceneCodes(row.sceneList);
baseSceneCode = sceneListCodes.length ? sceneListCodes : undefined;
}
return {
id: row.id ?? row.dailyReportRecordId,
staffName: row.staffName ?? row.staffname ?? "",
staffUuid: row.staffUuid,
merchantId: row.merchantId,
merchantName: row.merchantName,
bizType: row.bizType ?? scene.bizType,
bizTypeName: row.bizTypeName || scene.bizTypeName,
attendanceStatus: row.onBreak ?? row.attendanceStatus ?? row.attendanceStatusName,
staffCount: row.staffCount,
lastSaveTime: createdDate,
submissionDate: row.submissionDate,
reportDate: row.reportDate,
templateType: row.templateType,
baseSceneCode,
sceneType: row.sceneType,
brandIds: row.brandIds,
sceneList: row.sceneList,
reportStatus,
};
}
export function mapOverviewPageResponse(res = {}) {
const list = Array.isArray(res.list) ? res.list.map(mapOverviewRow) : [];
return {
...res,
list,
pageNum: res.pageNum ?? res.currentPage,
};
}
export default mapOverviewRow;