zhou zhou
23 小时以前 5d31cb5f1fb32a478d5b751ebfe97d47db890778
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
const STATUS_META = {
  1: { text: '正常', type: 'success' },
  0: { text: '冻结', type: 'info' }
}
 
export const TASK_ITEM_LOG_REPORT_TITLE = '任务工作历史档报表'
 
function normalizeText(value) {
  return String(value ?? '').trim()
}
 
function normalizeNumber(value) {
  if (value === '' || value === null || value === undefined) {
    return null
  }
  const numericValue = Number(value)
  return Number.isFinite(numericValue) ? numericValue : null
}
 
function normalizeReportText(value) {
  return value === null || value === undefined || value === '' ? '--' : value
}
 
export function createTaskItemLogSearchState() {
  return {
    condition: '',
    timeStart: '',
    timeEnd: '',
    logId: '',
    taskId: '',
    taskItemId: '',
    matnrId: '',
    maktx: '',
    platItemId: '',
    platOrderCode: '',
    platWorkCode: '',
    projectCode: '',
    source: '',
    sourceCode: '',
    sourceId: '',
    matnrCode: '',
    unit: '',
    anfme: '',
    batch: '',
    spec: '',
    model: '',
    fieldsIndex: '',
    memo: '',
    status: '',
    baseUnit: '',
    useOrgId: '',
    useOrgName: '',
    erpClsId: '',
    priceUnitId: '',
    inStockType: '',
    ownerTypeId: '',
    ownerId: '',
    ownerName: '',
    keeperTypeId: '',
    keeperId: '',
    keeperName: '',
    targetWarehouseId: '',
    sourceWarehouseId: ''
  }
}
 
export function getTaskItemLogPaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function buildTaskItemLogSearchParams(params = {}) {
  const result = {}
 
  ;[
    'condition',
    'maktx',
    'platItemId',
    'platOrderCode',
    'platWorkCode',
    'projectCode',
    'sourceCode',
    'matnrCode',
    'unit',
    'batch',
    'spec',
    'model',
    'fieldsIndex',
    'memo',
    'baseUnit',
    'useOrgId',
    'useOrgName',
    'erpClsId',
    'priceUnitId',
    'inStockType',
    'ownerTypeId',
    'ownerId',
    'ownerName',
    'keeperTypeId',
    'keeperId',
    'keeperName',
    'targetWarehouseId',
    'sourceWarehouseId'
  ].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
 
  ;['timeStart', 'timeEnd'].forEach((key) => {
    if (params[key]) {
      result[key] = params[key]
    }
  })
 
  ;['logId', 'taskId', 'taskItemId', 'matnrId', 'source', 'sourceId', 'anfme', 'status'].forEach(
    (key) => {
      const value = normalizeNumber(params[key])
      if (value !== null) {
        result[key] = value
      }
    }
  )
 
  return {
    condition: '',
    ...result
  }
}
 
export function buildTaskItemLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildTaskItemLogSearchParams(params)
  }
}
 
export function getTaskItemLogStatusMeta(value) {
  return STATUS_META[Number(value)] || { text: '-', type: 'info' }
}
 
export function normalizeTaskItemLogRow(record = {}) {
  const statusMeta = getTaskItemLogStatusMeta(record.status)
  return {
    ...record,
    logId: record.logId ?? '--',
    taskId: record.taskId ?? '--',
    taskItemId: record.taskItemId ?? '--',
    matnrId: record.matnrId ?? '--',
    maktx: normalizeReportText(record.maktx),
    platItemId: normalizeReportText(record.platItemId),
    platOrderCode: normalizeReportText(record.platOrderCode),
    platWorkCode: normalizeReportText(record.platWorkCode),
    projectCode: normalizeReportText(record.projectCode),
    source: record.source ?? '--',
    sourceCode: normalizeReportText(record.sourceCode),
    sourceId: record.sourceId ?? '--',
    matnrCode: normalizeReportText(record.matnrCode),
    unit: normalizeReportText(record.unit),
    anfme: record.anfme ?? '--',
    batch: normalizeReportText(record.batch),
    spec: normalizeReportText(record.spec),
    model: normalizeReportText(record.model),
    fieldsIndex: normalizeReportText(record.fieldsIndex),
    baseUnit: normalizeReportText(record.baseUnit),
    useOrgId: normalizeReportText(record.useOrgId),
    useOrgName: normalizeReportText(record.useOrgName),
    erpClsId: normalizeReportText(record.erpClsId),
    priceUnitId: normalizeReportText(record.priceUnitId),
    inStockType: normalizeReportText(record.inStockType),
    ownerTypeId: normalizeReportText(record.ownerTypeId),
    ownerId: normalizeReportText(record.ownerId),
    ownerName: normalizeReportText(record.ownerName),
    keeperTypeId: normalizeReportText(record.keeperTypeId),
    keeperId: normalizeReportText(record.keeperId),
    keeperName: normalizeReportText(record.keeperName),
    targetWarehouseId: normalizeReportText(record.targetWarehouseId),
    sourceWarehouseId: normalizeReportText(record.sourceWarehouseId),
    createByText: record['createBy$'] || record.createByText || '--',
    createTimeText: record['createTime$'] || record.createTime || '--',
    updateByText: record['updateBy$'] || record.updateByText || '--',
    updateTimeText: record['updateTime$'] || record.updateTime || '--',
    memo: normalizeReportText(record.memo),
    statusText: record['status$'] || statusMeta.text,
    statusType: statusMeta.type
  }
}
 
export function getTaskItemLogReportColumns() {
  return [
    { source: 'taskId', label: '任务ID' },
    { source: 'taskItemId', label: '任务明细ID' },
    { source: 'matnrId', label: '物料ID' },
    { source: 'maktx', label: '物料名称' },
    { source: 'platWorkCode', label: '工单号' },
    { source: 'platOrderCode', label: '客户订单号' },
    { source: 'projectCode', label: '项目号' },
    { source: 'source', label: '源编码' },
    { source: 'sourceCode', label: '源单号' },
    { source: 'matnrCode', label: '物料编码' },
    { source: 'unit', label: '库存单位' },
    { source: 'anfme', label: '数量' },
    { source: 'batch', label: '库存批次' },
    { source: 'spec', label: '规格' },
    { source: 'model', label: '型号' },
    { source: 'fieldsIndex', label: '字段索引' },
    { source: 'createByText', label: '创建人' },
    { source: 'createTimeText', label: '创建时间' },
    { source: 'updateByText', label: '更新人' },
    { source: 'updateTimeText', label: '更新时间' },
    { source: 'statusText', label: '状态' },
    { source: 'memo', label: '备注' }
  ]
}
 
export function buildTaskItemLogPrintRows(records = []) {
  return records.map((record) => {
    const row = normalizeTaskItemLogRow(record)
    return {
      taskId: row.taskId,
      taskItemId: row.taskItemId,
      matnrId: row.matnrId,
      maktx: row.maktx,
      platWorkCode: row.platWorkCode,
      platOrderCode: row.platOrderCode,
      projectCode: row.projectCode,
      source: row.source,
      sourceCode: row.sourceCode,
      matnrCode: row.matnrCode,
      unit: row.unit,
      anfme: row.anfme,
      batch: row.batch,
      spec: row.spec,
      model: row.model,
      fieldsIndex: row.fieldsIndex,
      createByText: row.createByText,
      createTimeText: row.createTimeText,
      updateByText: row.updateByText,
      updateTimeText: row.updateTimeText,
      statusText: row.statusText,
      statusType: row.statusType,
      memo: row.memo
    }
  })
}