zhou zhou
1 天以前 d4e039545c9e97347223eb415fbba85ee01bc263
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
import { $t } from '@/locales'
 
const STATUS_META = {
  1: { text: $t('common.status.enabled'), type: 'success' },
  0: { text: $t('common.status.disabled'), type: 'info' }
}
 
export const TASK_LOG_REPORT_TITLE = $t('pages.manager.taskLog.reportTitle')
 
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
}
 
export function createTaskLogSearchState() {
  return {
    condition: '',
    timeStart: '',
    timeEnd: '',
    taskId: '',
    taskCode: '',
    taskStatus: '',
    taskType: '',
    orgLoc: '',
    orgSite: '',
    targLoc: '',
    targSite: '',
    barcode: '',
    robotCode: '',
    exceStatus: '',
    expDesc: '',
    sort: '',
    expCode: '',
    startTime: '',
    endTime: '',
    memo: '',
    status: '',
    orderBy: 'create_time desc'
  }
}
 
export function getTaskLogPaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function buildTaskLogSearchParams(params = {}) {
  const result = {}
 
  ;[
    'condition',
    'taskCode',
    'orgLoc',
    'orgSite',
    'targLoc',
    'targSite',
    'barcode',
    'robotCode',
    'expDesc',
    'expCode',
    'memo'
  ].forEach((key) => {
    const value = normalizeText(params[key])
    if (value) {
      result[key] = value
    }
  })
  ;['timeStart', 'timeEnd', 'startTime', 'endTime'].forEach((key) => {
    if (params[key]) {
      result[key] = params[key]
    }
  })
  ;['taskId', 'taskStatus', 'taskType', 'exceStatus', 'sort', 'status'].forEach((key) => {
    const value = normalizeNumber(params[key])
    if (value !== null) {
      result[key] = value
    }
  })
 
  return {
    condition: '',
    ...result
  }
}
 
export function buildTaskLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    orderBy: normalizeText(params.orderBy) || 'create_time desc',
    ...buildTaskLogSearchParams(params)
  }
}
 
export function getTaskLogStatusMeta(value) {
  return STATUS_META[Number(value)] || { text: '-', type: 'info' }
}
 
export function normalizeTaskLogRow(record = {}) {
  const statusMeta = getTaskLogStatusMeta(record.status)
  return {
    ...record,
    taskId: record.taskId ?? '--',
    taskCode: record.taskCode || '--',
    taskStatusText: record['taskStatus$'] || record.taskStatusText || (record.taskStatus ?? '--'),
    taskTypeText: record['taskType$'] || record.taskTypeText || (record.taskType ?? '--'),
    orgLoc: record.orgLoc || '--',
    orgSite: record.orgSite || '--',
    targLoc: record.targLoc || '--',
    targSite: record.targSite || '--',
    barcode: record.barcode || '--',
    robotCode: record.robotCode || '--',
    exceStatusText: record.exceStatusText || (record.exceStatus ?? '--'),
    expDesc: record.expDesc || '--',
    sort: record.sort ?? '--',
    expCode: record.expCode || '--',
    startTimeText: record['startTime$'] || record.startTime || '--',
    endTimeText: record['endTime$'] || record.endTime || '--',
    createByText: record['createBy$'] || record.createByText || '--',
    createTimeText: record['createTime$'] || record.createTime || '--',
    updateByText: record['updateBy$'] || record.updateByText || '--',
    updateTimeText: record['updateTime$'] || record.updateTime || '--',
    memo: record.memo || '--',
    statusText: record['status$'] || statusMeta.text,
    statusType: statusMeta.type
  }
}
 
export function getTaskLogReportColumns() {
  return [
    { prop: 'id', label: $t('table.id') },
    { prop: 'taskId', label: $t('pages.manager.taskLog.detail.taskId') },
    { prop: 'taskCode', label: $t('pages.manager.taskLog.table.taskCode') },
    { prop: 'taskStatusText', label: $t('pages.manager.taskLog.table.taskStatus') },
    { prop: 'taskTypeText', label: $t('pages.manager.taskLog.table.taskType') },
    { prop: 'orgLoc', label: $t('pages.manager.taskLog.table.orgLoc') },
    { prop: 'orgSite', label: $t('pages.manager.taskLog.table.orgSite') },
    { prop: 'targLoc', label: $t('pages.manager.taskLog.table.targLoc') },
    { prop: 'targSite', label: $t('pages.manager.taskLog.table.targSite') },
    { prop: 'barcode', label: $t('pages.manager.taskLog.table.barcode') },
    { prop: 'robotCode', label: $t('pages.manager.taskLog.table.robotCode') },
    { prop: 'exceStatusText', label: $t('pages.manager.taskLog.detail.exceStatus') },
    { prop: 'sort', label: $t('pages.manager.taskLog.detail.sort') },
    { prop: 'expCode', label: $t('pages.manager.taskLog.detail.expCode') },
    { prop: 'startTimeText', label: $t('pages.manager.taskLog.table.startTime') },
    { prop: 'endTimeText', label: $t('pages.manager.taskLog.table.endTime') },
    { prop: 'createByText', label: $t('table.createBy') },
    { prop: 'createTimeText', label: $t('table.createTime') },
    { prop: 'updateByText', label: $t('table.updateBy') },
    { prop: 'updateTimeText', label: $t('table.updateTime') },
    { prop: 'memo', label: $t('table.memo') }
  ]
}
 
export function buildTaskLogPrintRows(records = []) {
  return records.map((record) => {
    const row = normalizeTaskLogRow(record)
    return {
      id: row.id ?? '--',
      taskId: row.taskId,
      taskCode: row.taskCode,
      taskStatusText: row.taskStatusText,
      taskTypeText: row.taskTypeText,
      orgLoc: row.orgLoc,
      orgSite: row.orgSite,
      targLoc: row.targLoc,
      targSite: row.targSite,
      barcode: row.barcode,
      robotCode: row.robotCode,
      exceStatusText: row.exceStatusText,
      sort: row.sort,
      expCode: row.expCode,
      startTimeText: row.startTimeText,
      endTimeText: row.endTimeText,
      createByText: row.createByText,
      createTimeText: row.createTimeText,
      updateByText: row.updateByText,
      updateTimeText: row.updateTimeText,
      memo: row.memo
    }
  })
}