#
zhou zhou
87 分钟以前 56bbba2a422d7c4fb2d6bfb497aeb700157027a9
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
export const ASN_ORDER_LOG_REPORT_TITLE = '历史通知单报表'
export const ASN_ORDER_LOG_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
  orientation: 'landscape',
  density: 'compact',
  showSequence: true
}
 
const RLE_STATUS_META = {
  0: { text: '正常', type: 'info' },
  1: { text: '已释放', type: 'success' }
}
 
const NTY_STATUS_META = {
  0: { text: '未上报', type: 'info' },
  1: { text: '已上报', type: 'success' },
  2: { text: '部分上报', type: 'warning' }
}
 
const STATUS_META = {
  1: { text: '正常', type: 'success' },
  0: { text: '冻结', type: 'danger' }
}
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function normalizeNumber(value, fallback = void 0) {
  if (value === '' || value === null || value === undefined) {
    return fallback
  }
  const parsed = Number(value)
  return Number.isNaN(parsed) ? fallback : parsed
}
 
function normalizeDateText(value) {
  return normalizeText(value)
}
 
function getStatusMeta(value, map, fallbackText = '-') {
  const numericValue = Number(value)
  const meta = map[numericValue]
  if (meta) {
    return meta
  }
  const text = normalizeText(value)
  if (!text) {
    return { text: fallbackText, type: 'info' }
  }
  return { text, type: 'info' }
}
 
function normalizeTagText(value, map) {
  const text = normalizeText(value)
  if (text) {
    return text
  }
  const numericValue = Number(value)
  const meta = map[numericValue]
  return meta?.text || '-'
}
 
export function createAsnOrderLogSearchState() {
  return {
    condition: '',
    code: '',
    poCode: '',
    poId: '',
    type: '',
    wkType: '',
    logisNo: '',
    arrTime: '',
    rleStatus: '',
    ntyStatus: '',
    exceStatus: '',
    status: ''
  }
}
 
export function buildAsnOrderLogSearchParams(params = {}) {
  const searchParams = {
    condition: normalizeText(params.condition),
    code: normalizeText(params.code),
    poCode: normalizeText(params.poCode),
    poId:
      params.poId !== undefined && params.poId !== null && params.poId !== ''
        ? normalizeNumber(params.poId)
        : void 0,
    type: normalizeText(params.type),
    wkType: normalizeText(params.wkType),
    logisNo: normalizeText(params.logisNo),
    arrTime: normalizeText(params.arrTime),
    rleStatus:
      params.rleStatus !== undefined && params.rleStatus !== null && params.rleStatus !== ''
        ? normalizeNumber(params.rleStatus)
        : void 0,
    ntyStatus:
      params.ntyStatus !== undefined && params.ntyStatus !== null && params.ntyStatus !== ''
        ? normalizeNumber(params.ntyStatus)
        : void 0,
    exceStatus:
      params.exceStatus !== undefined && params.exceStatus !== null && params.exceStatus !== ''
        ? normalizeNumber(params.exceStatus)
        : void 0,
    status:
      params.status !== undefined && params.status !== null && params.status !== ''
        ? normalizeNumber(params.status)
        : void 0
  }
 
  return Object.fromEntries(
    Object.entries(searchParams).filter(
      ([, value]) => value !== '' && value !== void 0 && value !== null
    )
  )
}
 
export function buildAsnOrderLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildAsnOrderLogSearchParams(params)
  }
}
 
export function buildAsnOrderLogDetailQueryParams(params = {}) {
  return {
    logId: params.logId,
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20
  }
}
 
export function normalizeAsnOrderLogRow(record = {}) {
  const rleStatusMeta = getStatusMeta(record.rleStatus, RLE_STATUS_META)
  const ntyStatusMeta = getStatusMeta(record.ntyStatus, NTY_STATUS_META)
  const statusMeta = getStatusMeta(record.status, STATUS_META)
 
  return {
    ...record,
    id: record.id ?? null,
    asnId: record.asnId ?? '--',
    code: normalizeText(record.code) || '--',
    poCode: normalizeText(record.poCode) || '--',
    poId: record.poId ?? '--',
    type: normalizeText(record.type) || '',
    typeText: normalizeTagText(record['type$'] || record.typeText || record.type, {}),
    wkType: normalizeText(record.wkType) || '',
    wkTypeText: normalizeTagText(record['wkType$'] || record.wkTypeText || record.wkType, {}),
    anfme: record.anfme ?? '--',
    qty: record.qty ?? '--',
    logisNo: normalizeText(record.logisNo) || '--',
    arrTime: record.arrTime ?? null,
    arrTimeText: normalizeDateText(record['arrTime$'] || record.arrTime) || '--',
    rleStatus: record.rleStatus ?? '--',
    rleStatusText: normalizeTagText(record['rleStatus$'] || rleStatusMeta.text, RLE_STATUS_META),
    rleStatusTagType: rleStatusMeta.type,
    ntyStatus: record.ntyStatus ?? '--',
    ntyStatusText: normalizeTagText(record['ntyStatus$'] || ntyStatusMeta.text, NTY_STATUS_META),
    ntyStatusTagType: ntyStatusMeta.type,
    exceStatus: record.exceStatus ?? '--',
    exceStatusText: normalizeTagText(record['exceStatus$'] || record.exceStatusText || record.exceStatus, {}),
    status: record.status ?? '--',
    statusText: normalizeTagText(record['status$'] || statusMeta.text, STATUS_META),
    statusType: statusMeta.type,
    createByText: normalizeText(record['createBy$'] || record.createByText || '') || '--',
    createTimeText: normalizeDateText(record['createTime$'] || record.createTime) || '--',
    updateByText: normalizeText(record['updateBy$'] || record.updateByText || '') || '--',
    updateTimeText: normalizeDateText(record['updateTime$'] || record.updateTime) || '--',
    memo: normalizeText(record.memo) || '--'
  }
}
 
export function normalizeAsnOrderItemLogRow(record = {}) {
  const ntyStatusMeta = getStatusMeta(record.ntyStatus, NTY_STATUS_META)
  const statusMeta = getStatusMeta(record.status, STATUS_META)
 
  return {
    ...record,
    id: record.id ?? null,
    logId: record.logId ?? '--',
    asnItemId: record.asnItemId ?? '--',
    asnId: record.asnId ?? '--',
    asnCode: normalizeText(record.asnCode) || '--',
    platItemId: normalizeText(record.platItemId) || '--',
    poDetlId: record.poDetlId ?? '--',
    poCode: normalizeText(record.poCode) || '--',
    fieldsIndex: normalizeText(record.fieldsIndex) || '--',
    matnrId: record.matnrId ?? '--',
    matnrCode: normalizeText(record.matnrCode) || '--',
    maktx: normalizeText(record.maktx) || '--',
    anfme: record.anfme ?? '--',
    stockUnit: normalizeText(record.stockUnit) || '--',
    purQty: record.purQty ?? '--',
    purUnit: normalizeText(record.purUnit) || '--',
    qty: record.qty ?? '--',
    splrCode: normalizeText(record.splrCode) || '--',
    splrBatch: normalizeText(record.splrBatch) || '--',
    splrName: normalizeText(record.splrName) || '--',
    qrcode: normalizeText(record.qrcode) || '--',
    trackCode: normalizeText(record.trackCode) || '--',
    barcode: normalizeText(record.barcode) || '--',
    packName: normalizeText(record.packName) || '--',
    ntyStatus: record.ntyStatus ?? '--',
    ntyStatusText: normalizeTagText(record['ntyStatus$'] || ntyStatusMeta.text, NTY_STATUS_META),
    ntyStatusTagType: ntyStatusMeta.type,
    status: record.status ?? '--',
    statusText: normalizeTagText(record['status$'] || statusMeta.text, STATUS_META),
    statusType: statusMeta.type,
    createByText: normalizeText(record['createBy$'] || record.createByText || '') || '--',
    createTimeText: normalizeDateText(record['createTime$'] || record.createTime) || '--',
    updateByText: normalizeText(record['updateBy$'] || record.updateByText || '') || '--',
    updateTimeText: normalizeDateText(record['updateTime$'] || record.updateTime) || '--',
    memo: normalizeText(record.memo) || '--'
  }
}
 
export function buildAsnOrderLogPrintRows(records = []) {
  if (!Array.isArray(records)) {
    return []
  }
  return records.map((record) => normalizeAsnOrderLogRow(record))
}
 
export function buildAsnOrderLogReportMeta({
  previewMeta = {},
  count = 0,
  orientation = ASN_ORDER_LOG_REPORT_STYLE.orientation
} = {}) {
  return {
    reportTitle: ASN_ORDER_LOG_REPORT_TITLE,
    reportDate: previewMeta.reportDate,
    printedAt: previewMeta.printedAt,
    operator: previewMeta.operator,
    count,
    reportStyle: {
      ...ASN_ORDER_LOG_REPORT_STYLE,
      orientation
    }
  }
}
 
export function getAsnOrderLogRleStatusOptions() {
  return [
    { label: '正常', value: 0 },
    { label: '已释放', value: 1 }
  ]
}
 
export function getAsnOrderLogNtyStatusOptions() {
  return [
    { label: '未上报', value: 0 },
    { label: '已上报', value: 1 },
    { label: '部分上报', value: 2 }
  ]
}
 
export function getAsnOrderLogStatusOptions() {
  return [
    { label: '正常', value: 1 },
    { label: '冻结', value: 0 }
  ]
}
 
export function getAsnOrderLogTypeOptions() {
  return []
}
 
export function getAsnOrderLogWkTypeOptions() {
  return []
}
 
export function getAsnOrderLogExceStatusOptions() {
  return []
}
 
export function resolveDictOptions(records = [], options = {}) {
  const { group } = options
  if (!Array.isArray(records)) {
    return []
  }
 
  return records
    .filter((item) => {
      if (!item || typeof item !== 'object') {
        return false
      }
      if (group === undefined) {
        return true
      }
      return normalizeText(item.group) === normalizeText(group)
    })
    .map((item) => {
      const value = item.value ?? item.id ?? item.dictValue
      if (value === undefined || value === null || value === '') {
        return null
      }
      return {
        value: normalizeText(value),
        label: normalizeText(item.label || item.name || item.dictLabel || value)
      }
    })
    .filter(Boolean)
}