journalRecord.mock.js
5.92 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import { buildJournalDetailJsonContent } from "../views/residentManage/journalRecord/fixtures/journalDetailEcho.sample.js";
import { mapOverviewPageResponse } from "./adapters/journalRecord/mapOverviewRow";
import { mapDetailResponse } from "./adapters/journalRecord/mapDetailResponse";
import { mapMerchantListResponse } from "./adapters/journalRecord/mapMerchantList";
import { mapMerchantStaffListResponse } from "./adapters/journalRecord/mapMerchantStaffList";
const MERCHANT_NAME = "深圳市鹏程汽车有限公司";
const STORE_LIST = [
{ merchantId: "1001", merchantName: MERCHANT_NAME, sceneType: 1 },
{ merchantId: "1002", merchantName: "广州天河汽车销售服务有限公司", sceneType: 1 },
{ merchantId: "1003", merchantName: "东莞南城汽车贸易有限公司", sceneType: 0 },
{ merchantId: "1004", merchantName: "佛山顺德智行汽车销售有限公司", sceneType: 1 },
{ merchantId: "1005", merchantName: "惠州惠城汽车服务有限公司", sceneType: 0 },
];
const STAFF_LIST = [
{ staffUuid: "staff-uuid-001", staffName: "袁春梅" },
{ staffUuid: "staff-uuid-002", staffName: "韩文" },
{ staffUuid: "staff-uuid-003", staffName: "刘明杰" },
{ staffUuid: "staff-uuid-004", staffName: "王芳" },
{ staffUuid: "staff-uuid-005", staffName: "张伟" },
{ staffUuid: "staff-uuid-006", staffName: "李娜" },
{ staffUuid: "staff-uuid-007", staffName: "陈静" },
{ staffUuid: "staff-uuid-008", staffName: "赵强" },
{ staffUuid: "staff-uuid-009", staffName: "孙丽" },
{ staffUuid: "staff-uuid-010", staffName: "周涛" },
];
function delay(result, ms = 300) {
return new Promise((resolve) => {
setTimeout(() => resolve(result), ms);
});
}
function paginate(list, params) {
const { currentPage = 1, pageSize = 10 } = params;
const start = (currentPage - 1) * pageSize;
return {
list: list.slice(start, start + pageSize),
total: list.length,
pageNum: currentPage,
pageSize,
};
}
function filterStaffList(list, params) {
let result = [ ...list ];
if (params.merchantId) {
result = result.filter((item) => item.merchantId === params.merchantId);
}
if (params.staffName) {
result = result.filter((item) => item.staffName === params.staffName);
}
return result;
}
function buildStaffDailyList(params) {
return STAFF_LIST.map((item, index) => ({
id: `staff-daily-${index + 1}`,
staffUuid: item.staffUuid,
staffName: item.staffName,
merchantId: STORE_LIST[index % STORE_LIST.length].merchantId,
merchantName: STORE_LIST[index % STORE_LIST.length].merchantName,
sceneType: index % 2 === 0 ? "1" : "0",
onBreak: index % 3 === 0 ? "调休" : "在岗",
createdDate: "2026-06-12 14:41:00",
reportStatus: 0,
reportDate: params.reportDate,
templateType: 1,
}));
}
function buildStoreDailyList(params) {
return STORE_LIST.map((store, index) => ({
id: `store-daily-${index + 1}`,
merchantId: store.merchantId,
merchantName: store.merchantName,
sceneType: String(store.sceneType),
staffCount: 3,
staffName: index % 3 === 0 ? "" : STAFF_LIST[index % STAFF_LIST.length].staffName,
createdDate: "2026-06-12 14:41:00",
reportStatus: index % 3 === 0 ? 0 : 1,
reportDate: params.reportDate,
templateType: 2,
}));
}
function buildNegotiationList(params) {
return STAFF_LIST.map((item, index) => ({
id: `negotiation-${index + 1}`,
staffUuid: item.staffUuid,
staffName: item.staffName,
merchantId: STORE_LIST[index % STORE_LIST.length].merchantId,
merchantName: STORE_LIST[index % STORE_LIST.length].merchantName,
sceneType: index % 2 === 0 ? "0" : "1",
onBreak: "在岗",
createdDate: "2026-06-12 14:41:00",
reportStatus: 1,
reportDate: params.reportDate,
templateType: 3,
}));
}
function buildDetailMeta(journalType, reportDate) {
const metaMap = {
staffDaily: {
journalType: "staffDaily",
staffName: "高思琪",
merchantName: MERCHANT_NAME,
sceneType: "1",
templateType: 1,
},
storeDaily: {
journalType: "storeDaily",
staffName: "",
merchantName: MERCHANT_NAME,
sceneType: "1",
templateType: 2,
},
negotiation: {
journalType: "negotiation",
staffName: "高思琪",
merchantName: MERCHANT_NAME,
sceneType: "0",
templateType: 3,
},
};
return {
...(metaMap[journalType] || metaMap.staffDaily),
reportDate: reportDate || "2026-03-30",
reportTemplateId: "mock-template-001",
baseSceneCode: 110201,
jsonContent: buildJournalDetailJsonContent(),
};
}
const DETAIL_MAP = {
"staff-daily-1": buildDetailMeta("staffDaily", "2026-03-30"),
"store-daily-1": buildDetailMeta("storeDaily", "2026-03-30"),
"negotiation-1": buildDetailMeta("negotiation", "2026-03-30"),
};
export function mockDailyReportMerchantList(params) {
return delay(mapMerchantListResponse({ list: STORE_LIST }));
}
export function mockDailyReportMerchantStaffList(params) {
let list = STAFF_LIST.map((item, index) => ({
...item,
merchantId: STORE_LIST[index % STORE_LIST.length].merchantId,
}));
if (params.merchantId) {
list = list.filter((item) => item.merchantId === params.merchantId);
}
return delay(mapMerchantStaffListResponse({ list }));
}
export function mockDailyReportOverviewPage(params) {
const { templateType } = params;
let list = [];
if (templateType === 1) {
list = filterStaffList(buildStaffDailyList(params), params);
} else if (templateType === 2) {
list = buildStoreDailyList(params);
if (params.merchantId) {
list = list.filter((item) => item.merchantId === params.merchantId);
}
} else if (templateType === 3) {
list = filterStaffList(buildNegotiationList(params), params);
} else {
list = filterStaffList(buildStaffDailyList(params), params);
}
return delay(mapOverviewPageResponse(paginate(list, params)));
}
export function mockDailyReportDetailSelect(params) {
const { id, journalType, reportDate } = params;
let detail = DETAIL_MAP[id];
if (!detail) {
detail = {
id,
...buildDetailMeta(journalType || "staffDaily", reportDate),
};
}
return delay(mapDetailResponse({ ...detail, id: id || detail.id }, params));
}