zhou zhou
3 天以前 0a1d91e42e6c5af96e1108e9ebcc37e99eb3b22c
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
const TYPE_OPTIONS = [
  { label: '库存调整', value: 0, tagType: 'primary' },
  { label: '盘点调整', value: 1, tagType: 'warning' },
  { label: '其它调整', value: 2, tagType: 'info' }
]
 
const STATUS_OPTIONS = [
  { label: '正常', value: 1, tagType: 'success' },
  { label: '冻结', value: 0, tagType: 'danger' }
]
 
function normalizeText(value) {
  return typeof value === 'string' ? value.trim() : value
}
 
function normalizeNumber(value, fallback = void 0) {
  if (value === '' || value === null || value === undefined) {
    return fallback
  }
  const numericValue = Number(value)
  return Number.isFinite(numericValue) ? numericValue : fallback
}
 
function pickText(record, keys, fallback = '-') {
  for (const key of keys) {
    const value = record?.[key]
    if (typeof value === 'string' && value.trim()) {
      return value.trim()
    }
  }
  return fallback
}
 
export const REVISE_LOG_REPORT_TITLE = '库位调整日志'
export const REVISE_LOG_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
  orientation: 'landscape',
  density: 'compact',
  showSequence: true
}
 
export function getReviseLogTypeOptions() {
  return TYPE_OPTIONS
}
 
export function getReviseLogStatusOptions() {
  return STATUS_OPTIONS
}
 
export function getReviseLogPaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function createReviseLogSearchState() {
  return {
    condition: '',
    reviseId: '',
    reviseCode: '',
    warehouseId: '',
    areaId: '',
    type: '',
    barcode: '',
    useStatus: '',
    channel: '',
    row: '',
    col: '',
    lev: '',
    memo: '',
    status: '',
    timeStart: '',
    timeEnd: ''
  }
}
 
export function buildReviseLogSearchParams(params = {}) {
  const result = {}
  ;[
    'condition',
    'reviseCode',
    'barcode',
    'useStatus',
    'memo',
    'timeStart',
    'timeEnd'
  ].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  ;['reviseId', 'warehouseId', 'areaId', 'type', 'channel', 'row', 'col', 'lev', 'status'].forEach(
    (key) => {
      const value = normalizeNumber(params[key], void 0)
      if (value !== void 0) {
        result[key] = value
      }
    }
  )
 
  return result
}
 
export function buildReviseLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildReviseLogSearchParams(params)
  }
}
 
export function getReviseLogTypeMeta(value) {
  const target = TYPE_OPTIONS.find((item) => Number(item.value) === Number(value))
  return target || { label: '-', value, tagType: 'info' }
}
 
export function getReviseLogStatusMeta(value) {
  const target = STATUS_OPTIONS.find((item) => Number(item.value) === Number(value))
  return target || { label: '-', value, tagType: 'info' }
}
 
export function normalizeReviseLogRow(record = {}) {
  const typeMeta = getReviseLogTypeMeta(record.type)
  const statusMeta = getReviseLogStatusMeta(record.status)
  return {
    ...record,
    reviseId: normalizeNumber(record.reviseId, record.reviseId),
    reviseCode: pickText(record, ['reviseCode', 'code']),
    warehouseLabel: pickText(record, ['warehouseId$', 'warehouseName', 'warehouseLabel']),
    areaLabel: pickText(record, ['areaId$', 'areaName', 'areaLabel']),
    locCode: pickText(record, ['locCode']),
    typeLabel: pickText(record, ['type$'], typeMeta.label),
    barcode: pickText(record, ['barcode']),
    useStatusText: pickText(record, ['useStatus$'], record.useStatus || '-'),
    channelText: pickText(record, ['channel$'], record.channel ?? '-'),
    rowText: pickText(record, ['row$'], record.row ?? '-'),
    colText: pickText(record, ['col$'], record.col ?? '-'),
    levText: pickText(record, ['lev$'], record.lev ?? '-'),
    statusText: pickText(record, ['status$'], statusMeta.label),
    statusTagType: statusMeta.tagType,
    createByText: pickText(record, ['createBy$']),
    createTimeText: pickText(record, ['createTime$'], record.createTime || '-'),
    updateByText: pickText(record, ['updateBy$']),
    updateTimeText: pickText(record, ['updateTime$'], record.updateTime || '-'),
    memo: pickText(record, ['memo'], '-')
  }
}