zhou zhou
4 小时以前 89847f0c5a5d37e5a720afd32cdd7e4d9ead664b
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
export const QLY_INSPECT_REPORT_TITLE = '质检信息报表'
export const QLY_INSPECT_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
  orientation: 'portrait',
  density: 'compact',
  showSequence: true
}
 
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
}
 
export function createQlyInspectSearchState() {
  return {
    condition: '',
    code: '',
    wkType: '',
    asnCode: '',
    isptStatus: '',
    isptQty: ''
  }
}
 
export function buildQlyInspectSearchParams(params = {}) {
  const result = {}
 
  ;['condition', 'code', 'wkType', 'asnCode', 'isptStatus', 'isptQty'].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  return result
}
 
export function buildQlyInspectPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildQlyInspectSearchParams(params)
  }
}
 
export function buildQlyInspectItemsQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...(params.ispectId !== undefined ? { ispectId: params.ispectId } : {})
  }
}
 
export function normalizeQlyInspectRow(record = {}) {
  return {
    ...record,
    code: record.code || '-',
    wkTypeLabel: record['wkType$'] || record.wkType || '-',
    asnId: record.asnId ?? '-',
    asnCode: record.asnCode || '-',
    isptQty: normalizeNumber(record.isptQty),
    isptStatusText: record['isptStatus$'] || '-',
    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 normalizeQlyInspectItemRow(record = {}) {
  return {
    ...record,
    ispectId: record.ispectId ?? '-',
    matnrCode: record.matnrCode || '-',
    maktx: record.maktx || '-',
    label: record.label || '-',
    splrBatch: record.splrBatch || '-',
    stockBatch: record.stockBatch || '-',
    rcptQty: normalizeNumber(record.rcptQty),
    dlyQty: normalizeNumber(record.dlyQty),
    anfme: normalizeNumber(record.anfme),
    splrName: record.splrName || '-',
    isptResultText: record['isptResult$'] || '-'
  }
}
 
export function buildQlyInspectPrintRows(records = []) {
  if (!Array.isArray(records)) {
    return []
  }
  return records.map((record) => normalizeQlyInspectRow(record))
}
 
export function buildQlyInspectReportMeta({
  previewMeta = {},
  count = 0,
  orientation = QLY_INSPECT_REPORT_STYLE.orientation
} = {}) {
  return {
    reportTitle: QLY_INSPECT_REPORT_TITLE,
    reportDate: previewMeta.reportDate,
    printedAt: previewMeta.printedAt,
    operator: previewMeta.operator,
    count,
    reportStyle: {
      ...QLY_INSPECT_REPORT_STYLE,
      orientation
    }
  }
}