feat(波次拣货): 拣货任务列表新增「拣货用时」字段(完成时间-开始时间,单位分钟,保留2位小数)
This commit is contained in:
parent
7ae618471d
commit
3df2ae0404
@ -138,6 +138,10 @@
|
||||
{{ formatDateTime(row.finish_at || row.finish_time) }}
|
||||
</template>
|
||||
|
||||
<template #column-pick_duration="{ row }">
|
||||
<span>{{ row.pick_duration === null || row.pick_duration === undefined ? '—' : row.pick_duration }}</span>
|
||||
</template>
|
||||
|
||||
<template #column-review_start_time="{ row }">
|
||||
{{ formatDateTime(row.review_start_time) }}
|
||||
</template>
|
||||
@ -528,6 +532,31 @@ function toNumber(value: unknown, fallback = 0): number {
|
||||
return Number.isFinite(num) ? num : fallback
|
||||
}
|
||||
|
||||
/** 解析时间值(支持 毫秒/秒级时间戳、ISO/日期字符串),失败返回 null */
|
||||
function parseDateValue(value: unknown): Date | null {
|
||||
if (value === null || value === undefined || value === '') return null
|
||||
const text = String(value)
|
||||
const ts = Number(text)
|
||||
if (Number.isFinite(ts) && ts > 0) {
|
||||
const date = new Date(ts)
|
||||
if (!Number.isNaN(date.getTime())) return date
|
||||
}
|
||||
const date = new Date(text)
|
||||
if (!Number.isNaN(date.getTime())) return date
|
||||
return null
|
||||
}
|
||||
|
||||
/** 拣货用时 = 完成时间 - 开始时间(分钟,保留 2 位小数);起止缺失或解析失败返回 null */
|
||||
function calcPickDurationMinutes(start: unknown, finish: unknown): number | null {
|
||||
const startDate = parseDateValue(start)
|
||||
const finishDate = parseDateValue(finish)
|
||||
if (!startDate || !finishDate) return null
|
||||
const ms = finishDate.getTime() - startDate.getTime()
|
||||
if (!Number.isFinite(ms)) return null
|
||||
const minutes = ms / (60 * 1000)
|
||||
return Number(minutes.toFixed(2))
|
||||
}
|
||||
|
||||
function normalizePickTaskRow(row: WavePickTaskListItem) {
|
||||
return {
|
||||
...row,
|
||||
@ -559,7 +588,9 @@ function normalizePickTaskRow(row: WavePickTaskListItem) {
|
||||
review_start_time: row.review_start_time || '',
|
||||
review_finish_time: row.review_finish_time || '',
|
||||
created_at: row.created_at || row.create_time || '',
|
||||
update_time: row.update_time || ''
|
||||
update_time: row.update_time || '',
|
||||
/** 拣货用时 = 完成时间 - 开始时间(分钟,保留 2 位小数);未完成/缺失时返回 null */
|
||||
pick_duration: calcPickDurationMinutes(row.start_at || row.start_time, row.finish_at || row.finish_time)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1120,6 +1120,7 @@ export const pickTaskWaveColumns = applyWaveListCopyActions([
|
||||
{ prop: 'device_id', label: '设备ID', minWidth: 140 },
|
||||
{ prop: 'start_at', label: '开始时间', minWidth: 168 },
|
||||
{ prop: 'finish_at', label: '完成时间', minWidth: 168 },
|
||||
{ prop: 'pick_duration', label: '拣货用时(分)', width: 110, align: 'center' },
|
||||
{ prop: 'review_start_time', label: '复核开始', minWidth: 168 },
|
||||
{ prop: 'review_finish_time', label: '复核完成', minWidth: 168 },
|
||||
{ prop: 'created_at', label: '创建时间', minWidth: 168 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user