a0aeefab
“wangming”
好了,设计现在需要给美国那边看,估...
|
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
|
/**
* Print Log 为唯一数据源,labelId 格式: X-YYMMDD
*/
export interface PrintLogRecord {
labelId: string
productName: string
category: string
template: string
templateSize: string
templateName: string
printedAt: string
printedBy: string
location: string
expiryDate: string
qty: number
dateFull: string
time: string
labelType?: string
printer: string
}
export const printLogList: PrintLogRecord[] = [
{ labelId: '1-251201', productName: 'Whole Milk', category: 'Dairy', template: '2"x2" Basic', templateSize: '2"x2"', templateName: 'Basic', printedAt: '2024-03-20 09:30 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-27 14:30', qty: 1, dateFull: 'Mar 20, 2024', time: '09:30 AM', printer: 'Zebra ZD421' },
{ labelId: '2-251201', productName: 'Ground Beef', category: 'Meat', template: '2"x2" Basic', templateSize: '2"x2"', templateName: 'Basic', printedAt: '2024-03-20 10:15 AM', printedBy: 'Bob Smith', location: 'Uptown Store (102)', expiryDate: '2024-03-23 09:45', qty: 1, dateFull: 'Mar 20, 2024', time: '10:15 AM', printer: 'Zebra ZD421' },
{ labelId: '3-251201', productName: 'Croissant', category: 'Bakery', template: '2"x2" Basic', templateSize: '2"x2"', templateName: 'Basic', printedAt: '2024-03-19 14:00 PM', printedBy: 'Charlie Brown', location: 'Downtown Store (101)', expiryDate: '2024-03-20 16:00', qty: 1, dateFull: 'Mar 19, 2024', time: '02:00 PM', printer: 'Zebra ZD421' },
{ labelId: '4-251201', productName: 'Caesar Salad', category: 'Deli', template: '2"x6" G\'n\'G !!!', templateSize: '2"x6"', templateName: "G'n'G", printedAt: '2024-03-18 11:45 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-21 11:30', qty: 1, dateFull: 'Mar 18, 2024', time: '11:45 AM', printer: 'Brother QL-820NWB' },
{ labelId: '5-251201', productName: 'Orange Juice', category: 'Beverage', template: '2"x2" Basic', templateSize: '2"x2"', templateName: 'Basic', printedAt: '2024-03-18 08:20 AM', printedBy: 'Bob Smith', location: 'Airport Kiosk (201)', expiryDate: '2024-03-25 08:00', qty: 1, dateFull: 'Mar 18, 2024', time: '08:20 AM', printer: 'Brother QL-820NWB' },
]
export function getRecordByLabelId(labelId: string): PrintLogRecord | undefined {
return printLogList.find(r => r.labelId === labelId)
}
/** 生成下一个 labelId,格式与 print log 一致 X-YYMMDD */
export function generateNextLabelId(): string {
const now = new Date()
const yy = String(now.getFullYear()).slice(-2)
const mm = String(now.getMonth() + 1).padStart(2, '0')
const dd = String(now.getDate()).padStart(2, '0')
const datePart = yy + mm + dd
const todayRecords = printLogList.filter(r => {
const parts = r.labelId.split('-')
return parts.length === 2 && parts[1] === datePart
})
const maxSeq = todayRecords.length > 0
? Math.max(...todayRecords.map(r => parseInt(r.labelId.split('-')[0], 10)))
: 0
return `${maxSeq + 1}-${datePart}`
}
|