Added totalTime field to Job and SubJob models for duration calculation, and updated OrderItem model to include reference field and reorder properties for improved data structure.
This commit is contained in:
parent
c96f223176
commit
705c517acf
@ -2,6 +2,7 @@ import JobIcon from '../../components/Icons/JobIcon'
|
|||||||
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
||||||
import ReloadIcon from '../../components/Icons/ReloadIcon'
|
import ReloadIcon from '../../components/Icons/ReloadIcon'
|
||||||
import CheckIcon from '../../components/Icons/CheckIcon'
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
export const Job = {
|
export const Job = {
|
||||||
name: 'job',
|
name: 'job',
|
||||||
@ -37,7 +38,7 @@ export const Job = {
|
|||||||
url: (_id) => `/dashboard/production/jobs/info?jobId=${_id}&action=reload`
|
url: (_id) => `/dashboard/production/jobs/info?jobId=${_id}&action=reload`
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
columns: ['_id', 'gcodeFile', 'quantity', 'state', 'createdAt'],
|
columns: ['_id', 'quantity', 'state', 'gcodeFile', 'createdAt'],
|
||||||
filters: ['state', '_id', 'gcodeFile', 'quantity'],
|
filters: ['state', '_id', 'gcodeFile', 'quantity'],
|
||||||
sorters: ['createdAt', 'state', 'quantity', 'gcodeFile'],
|
sorters: ['createdAt', 'state', 'quantity', 'gcodeFile'],
|
||||||
properties: [
|
properties: [
|
||||||
@ -77,6 +78,7 @@ export const Job = {
|
|||||||
name: 'quantity',
|
name: 'quantity',
|
||||||
label: 'Quantity',
|
label: 'Quantity',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
columnFixed: 'left',
|
||||||
columnWidth: 125,
|
columnWidth: 125,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
@ -103,10 +105,37 @@ export const Job = {
|
|||||||
name: 'gcodeFile',
|
name: 'gcodeFile',
|
||||||
label: 'GCode File',
|
label: 'GCode File',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
columnFixed: 'left',
|
|
||||||
objectType: 'gcodeFile',
|
objectType: 'gcodeFile',
|
||||||
required: true,
|
required: true,
|
||||||
showHyperlink: true
|
showHyperlink: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'totalTime',
|
||||||
|
label: 'Total Time',
|
||||||
|
type: 'text',
|
||||||
|
readOnly: true,
|
||||||
|
value: (objectData) => {
|
||||||
|
if (!objectData?.startedAt || !objectData?.finishedAt) {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
const totalSeconds = dayjs(objectData?.finishedAt).diff(
|
||||||
|
dayjs(objectData?.startedAt),
|
||||||
|
'seconds'
|
||||||
|
)
|
||||||
|
const days = Math.floor(totalSeconds / 86400)
|
||||||
|
const hours = Math.floor((totalSeconds % 86400) / 3600)
|
||||||
|
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||||
|
const seconds = totalSeconds % 60
|
||||||
|
|
||||||
|
const parts = []
|
||||||
|
if (days > 0) parts.push(`${days}d`)
|
||||||
|
if (hours > 0) parts.push(`${hours}h`)
|
||||||
|
if (minutes > 0) parts.push(`${minutes}m`)
|
||||||
|
if (seconds > 0 || parts.length === 0) parts.push(`${seconds}s`)
|
||||||
|
|
||||||
|
return parts.join(' ')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
stats: [
|
stats: [
|
||||||
|
|||||||
@ -49,13 +49,13 @@ export const OrderItem = {
|
|||||||
type: 'dateTime',
|
type: 'dateTime',
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'orderType',
|
name: '_reference',
|
||||||
label: 'Order Type',
|
label: 'Reference',
|
||||||
type: 'objectType',
|
type: 'reference',
|
||||||
masterFilter: ['purchaseOrder', 'salesOrder'],
|
objectType: 'orderItem',
|
||||||
required: true
|
showCopy: true,
|
||||||
|
readOnly: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'updatedAt',
|
name: 'updatedAt',
|
||||||
@ -63,6 +63,15 @@ export const OrderItem = {
|
|||||||
type: 'dateTime',
|
type: 'dateTime',
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
{ name: 'state', label: 'State', type: 'state', readOnly: true },
|
||||||
|
{
|
||||||
|
name: 'orderType',
|
||||||
|
label: 'Order Type',
|
||||||
|
type: 'objectType',
|
||||||
|
masterFilter: ['purchaseOrder', 'salesOrder'],
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'order',
|
name: 'order',
|
||||||
label: 'Order',
|
label: 'Order',
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import SubJobIcon from '../../components/Icons/SubJobIcon'
|
import SubJobIcon from '../../components/Icons/SubJobIcon'
|
||||||
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
||||||
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
export const SubJob = {
|
export const SubJob = {
|
||||||
name: 'subJob',
|
name: 'subJob',
|
||||||
@ -68,7 +69,6 @@ export const SubJob = {
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
columnWidth: 175
|
columnWidth: 175
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'moonrakerJobId',
|
name: 'moonrakerJobId',
|
||||||
label: 'Moonraker Job ID',
|
label: 'Moonraker Job ID',
|
||||||
@ -76,28 +76,12 @@ export const SubJob = {
|
|||||||
columnWidth: 140,
|
columnWidth: 140,
|
||||||
showCopy: true
|
showCopy: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'startedAt',
|
name: 'startedAt',
|
||||||
label: 'Started At',
|
label: 'Started At',
|
||||||
type: 'dateTime',
|
type: 'dateTime',
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
name: 'createdPartStock',
|
|
||||||
label: 'Created Part Stock',
|
|
||||||
type: 'bool',
|
|
||||||
readOnly: true
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'finishedAt',
|
|
||||||
label: 'Finished At',
|
|
||||||
type: 'dateTime',
|
|
||||||
readOnly: true
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'job',
|
name: 'job',
|
||||||
label: 'Job',
|
label: 'Job',
|
||||||
@ -105,7 +89,12 @@ export const SubJob = {
|
|||||||
objectType: 'job',
|
objectType: 'job',
|
||||||
showHyperlink: true
|
showHyperlink: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'finishedAt',
|
||||||
|
label: 'Finished At',
|
||||||
|
type: 'dateTime',
|
||||||
|
readOnly: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'printer',
|
name: 'printer',
|
||||||
label: 'Printer',
|
label: 'Printer',
|
||||||
@ -113,6 +102,33 @@ export const SubJob = {
|
|||||||
columnFixed: 'left',
|
columnFixed: 'left',
|
||||||
objectType: 'printer',
|
objectType: 'printer',
|
||||||
showHyperlink: true
|
showHyperlink: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'totalTime',
|
||||||
|
label: 'Total Time',
|
||||||
|
type: 'text',
|
||||||
|
readOnly: true,
|
||||||
|
value: (objectData) => {
|
||||||
|
if (!objectData?.startedAt || !objectData?.finishedAt) {
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
const totalSeconds = dayjs(objectData?.finishedAt).diff(
|
||||||
|
dayjs(objectData?.startedAt),
|
||||||
|
'seconds'
|
||||||
|
)
|
||||||
|
const days = Math.floor(totalSeconds / 86400)
|
||||||
|
const hours = Math.floor((totalSeconds % 86400) / 3600)
|
||||||
|
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||||
|
const seconds = totalSeconds % 60
|
||||||
|
|
||||||
|
const parts = []
|
||||||
|
if (days > 0) parts.push(`${days}d`)
|
||||||
|
if (hours > 0) parts.push(`${hours}h`)
|
||||||
|
if (minutes > 0) parts.push(`${minutes}m`)
|
||||||
|
if (seconds > 0 || parts.length === 0) parts.push(`${seconds}s`)
|
||||||
|
|
||||||
|
return parts.join(' ')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user