zhou zhou
13 小时以前 e12fb4e6e8e0a408e81ce05a269a15cc535d8c78
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
export const WAIT_PAKIN_LOG_REPORT_TITLE = '组托历史档报表'
export const WAIT_PAKIN_LOG_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
  orientation: 'landscape',
  density: 'compact',
  showSequence: true
}
 
const IO_STATUS_MAP = {
  0: { label: '待入库', tagType: 'info' },
  1: { label: '入库中', tagType: 'warning' },
  2: { label: '任务执行中', tagType: 'warning' },
  3: { label: '任务完成', tagType: 'success' }
}
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function normalizeNumber(value) {
  if (value === '' || value === null || value === undefined) {
    return 0
  }
  const numericValue = Number(value)
  return Number.isFinite(numericValue) ? numericValue : 0
}
 
function getIoStatusConfig(status, statusText) {
  const numericStatus = Number(status)
  const fallback = IO_STATUS_MAP[numericStatus] || {
    label: statusText || '-',
    tagType: 'info'
  }
  return {
    label: statusText || fallback.label,
    tagType: fallback.tagType
  }
}
 
export function createWaitPakinLogSearchState() {
  return {
    condition: '',
    pakinId: '',
    code: '',
    barcode: '',
    ioStatus: ''
  }
}
 
export function buildWaitPakinLogSearchParams(params = {}) {
  const result = {}
 
  ;['condition', 'code', 'barcode'].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  if (params.pakinId !== '' && params.pakinId !== undefined && params.pakinId !== null) {
    result.pakinId = Number(params.pakinId)
  }
 
  if (params.ioStatus !== '' && params.ioStatus !== undefined && params.ioStatus !== null) {
    result.ioStatus = Number(params.ioStatus)
  }
 
  return result
}
 
export function buildWaitPakinLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildWaitPakinLogSearchParams(params)
  }
}
 
export function buildWaitPakinLogDetailQueryParams(params = {}) {
  return {
    logId: params.logId,
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
}
 
export function normalizeWaitPakinLogRow(record = {}) {
  const ioStatusConfig = getIoStatusConfig(record.ioStatus, record['ioStatus$'])
  return {
    ...record,
    id: record.id ?? null,
    pakinId: record.pakinId ?? '-',
    code: record.code || '-',
    barcode: record.barcode || '-',
    anfme: normalizeNumber(record.anfme),
    ioStatusText: ioStatusConfig.label,
    ioStatusTagType: ioStatusConfig.tagType,
    updateByText: record['updateBy$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-',
    createByText: record['createBy$'] || '-',
    createTimeText: record['createTime$'] || record.createTime || '-',
    statusText:
      record.statusBool === true || Number(record.status) === 1
        ? '正常'
        : record.statusBool === false || Number(record.status) === 0
          ? '冻结'
          : '-',
    memo: record.memo || '-'
  }
}
 
export function normalizeWaitPakinItemLogRow(record = {}) {
  return {
    ...record,
    id: record.id ?? null,
    pakinId: record.pakinId ?? '-',
    pakinItemId: record.pakinItemId ?? '-',
    asnId: record.asnId ?? '-',
    asnCode: record.asnCode || '-',
    asnItemId: record.asnItemId ?? '-',
    trackCode: record.trackCode || '-',
    maktx: record.maktx || '-',
    matnrCode: record.matnrCode || '-',
    anfme: normalizeNumber(record.anfme),
    workQty: normalizeNumber(record.workQty),
    unit: record.unit || '-',
    qty: normalizeNumber(record.qty),
    batch: record.batch || '-',
    updateByText: record['updateBy$'] || '-',
    updateTimeText: record['updateTime$'] || record.updateTime || '-'
  }
}
 
export function buildWaitPakinLogPrintRows(records = []) {
  if (!Array.isArray(records)) {
    return []
  }
  return records.map((record) => normalizeWaitPakinLogRow(record))
}
 
export function buildWaitPakinLogReportMeta({
  previewMeta = {},
  count = 0,
  orientation = WAIT_PAKIN_LOG_REPORT_STYLE.orientation
} = {}) {
  return {
    reportTitle: WAIT_PAKIN_LOG_REPORT_TITLE,
    reportDate: previewMeta.reportDate,
    printedAt: previewMeta.printedAt,
    operator: previewMeta.operator,
    count,
    reportStyle: {
      ...WAIT_PAKIN_LOG_REPORT_STYLE,
      orientation
    }
  }
}
 
export function getWaitPakinIoStatusOptions() {
  return Object.entries(IO_STATUS_MAP).map(([value, item]) => ({
    label: item.label,
    value: Number(value)
  }))
}