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: ''
|
}
|
}
|
|
export function getTaskLogPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function buildTaskLogSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'taskCode',
|
'orgLoc',
|
'orgSite',
|
'targLoc',
|
'targSite',
|
'barcode',
|
'robotCode',
|
'expDesc',
|
'expCode'
|
].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'].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,
|
...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: '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: 'targLoc', label: $t('pages.manager.taskLog.table.targLoc') },
|
{ prop: 'barcode', label: $t('pages.manager.taskLog.table.barcode') },
|
{ prop: 'robotCode', label: $t('pages.manager.taskLog.table.robotCode') },
|
{ prop: 'startTimeText', label: $t('pages.manager.taskLog.table.startTime') },
|
{ prop: 'endTimeText', label: $t('pages.manager.taskLog.table.endTime') }
|
]
|
}
|
|
export function buildTaskLogPrintRows(records = []) {
|
return records.map((record) => {
|
const row = normalizeTaskLogRow(record)
|
return {
|
taskCode: row.taskCode,
|
taskStatusText: row.taskStatusText,
|
taskTypeText: row.taskTypeText,
|
orgLoc: row.orgLoc,
|
targLoc: row.targLoc,
|
barcode: row.barcode,
|
robotCode: row.robotCode,
|
startTimeText: row.startTimeText,
|
endTimeText: row.endTimeText
|
}
|
})
|
}
|