1
82 分钟以前 e711c834aec2293c53b07efe53e81e3573c289b6
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
import {
  buildOutStockItemSearchParams,
  normalizeOutStockItemRow
} from '../out-stock-item/outStockItemPage.helpers.js'
 
export const PREPARATION_ITEM_REPORT_TITLE = '备料单明细报表'
export const PREPARATION_ITEM_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
  orientation: 'landscape',
  density: 'compact',
  showSequence: true
}
 
export function createPreparationItemSearchState(seed = {}) {
  return {
    condition: '',
    orderId: '',
    orderCode: '',
    poCode: '',
    platItemId: '',
    matnrCode: '',
    maktx: '',
    batch: '',
    splrBatch: '',
    trackCode: '',
    barcode: '',
    fieldsIndex: '',
    status: '',
    ...seed
  }
}
 
export function getPreparationItemPaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function buildPreparationItemSearchParams(params = {}) {
  const result = {
    ...buildOutStockItemSearchParams(params)
  }
 
  if (params.orderId !== '' && params.orderId !== undefined && params.orderId !== null) {
    const numericValue = Number(params.orderId)
    if (!Number.isNaN(numericValue)) {
      result.orderId = numericValue
    }
  }
 
  return result
}
 
export function buildPreparationItemPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildPreparationItemSearchParams(params)
  }
}
 
export function normalizePreparationItemRow(record = {}) {
  return normalizeOutStockItemRow(record)
}
 
export function getPreparationItemReportColumns() {
  return [
    { key: 'orderCode', label: '备料单号' },
    { key: 'poCode', label: 'PO单号' },
    { key: 'platItemId', label: '平台行号' },
    { key: 'matnrCode', label: '物料编码' },
    { key: 'maktx', label: '物料名称' },
    { key: 'batch', label: '批次' },
    { key: 'splrBatch', label: '供应商批次' },
    { key: 'stockUnit', label: '库存单位' },
    { key: 'anfme', label: '数量' },
    { key: 'workQty', label: '执行数量' },
    { key: 'qty', label: '已出数量' },
    { key: 'fieldsIndex', label: '字段索引' },
    { key: 'statusText', label: '状态' },
    { key: 'updateTimeText', label: '更新时间' },
    { key: 'memo', label: '备注' }
  ]
}
 
export function buildPreparationItemPrintRows(records = []) {
  if (!Array.isArray(records)) {
    return []
  }
  return records.map((record) => normalizePreparationItemRow(record))
}
 
export function buildPreparationItemReportMeta({
  previewMeta = {},
  count = 0,
  orientation = PREPARATION_ITEM_REPORT_STYLE.orientation
} = {}) {
  return {
    reportTitle: PREPARATION_ITEM_REPORT_TITLE,
    reportDate: previewMeta.reportDate,
    printedAt: previewMeta.printedAt,
    operator: previewMeta.operator,
    count,
    reportStyle: {
      ...PREPARATION_ITEM_REPORT_STYLE,
      orientation
    }
  }
}