|
|
|
@@ -19,11 +19,13 @@ import { |
|
|
|
TableRow, |
|
|
|
Paper, |
|
|
|
CircularProgress, |
|
|
|
TablePagination |
|
|
|
TablePagination, |
|
|
|
Chip |
|
|
|
} from '@mui/material'; |
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import { fetchTicketReleaseTable, getTicketReleaseTable } from '@/app/api/do/actions'; |
|
|
|
import { time } from 'console'; |
|
|
|
|
|
|
|
const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
const { t } = useTranslation("pickOrder"); |
|
|
|
@@ -33,9 +35,34 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
const [loading, setLoading] = useState<boolean>(true); |
|
|
|
const [paginationController, setPaginationController] = useState({ |
|
|
|
pageNum: 0, |
|
|
|
pageSize: 10, |
|
|
|
pageSize: 5, |
|
|
|
}); |
|
|
|
|
|
|
|
const formatTime = (timeData: any): string => { |
|
|
|
if (!timeData) return ''; |
|
|
|
|
|
|
|
let hour: number; |
|
|
|
let minute: number; |
|
|
|
|
|
|
|
if (typeof timeData === 'string') { |
|
|
|
|
|
|
|
const parts = timeData.split(':'); |
|
|
|
hour = parseInt(parts[0], 10); |
|
|
|
minute = parseInt(parts[1] || '0', 10); |
|
|
|
} else if (Array.isArray(timeData)) { |
|
|
|
|
|
|
|
hour = timeData[0] || 0; |
|
|
|
minute = timeData[1] || 0; |
|
|
|
} |
|
|
|
else { |
|
|
|
return ''; |
|
|
|
} |
|
|
|
|
|
|
|
const formattedHour = hour.toString().padStart(2, '0'); |
|
|
|
const formattedMinute = minute.toString().padStart(2, '0'); |
|
|
|
return `${formattedHour}:${formattedMinute}`; |
|
|
|
}; |
|
|
|
|
|
|
|
const getDateLabel = (offset: number) => { |
|
|
|
return dayjs().add(offset, 'day').format('YYYY-MM-DD'); |
|
|
|
}; |
|
|
|
@@ -175,7 +202,7 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
{t("Truck Information")} |
|
|
|
</Typography> |
|
|
|
<Typography variant="caption" sx={{ color: 'text.secondary' }}> |
|
|
|
{t("Departure Time")} / {t("Truck Lane Code")} |
|
|
|
{t("Departure Time")} {t("Truck Lane Code")} |
|
|
|
</Typography> |
|
|
|
</Box> |
|
|
|
</TableCell> |
|
|
|
@@ -195,7 +222,10 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
{t("Ticket Information")} |
|
|
|
</Typography> |
|
|
|
<Typography variant="caption" sx={{ color: 'text.secondary' }}> |
|
|
|
{t("Ticket No.")} ({t("Status")}) / {t("Release Time")} / {t("Complete Time")} |
|
|
|
{t("Ticket No.")} ({t("Status")}) |
|
|
|
</Typography> |
|
|
|
<Typography variant="caption" sx={{ color: 'text.secondary' }}> |
|
|
|
{t("Released Time")} - {t("Completed Time")} |
|
|
|
</Typography> |
|
|
|
</Box> |
|
|
|
</TableCell> |
|
|
|
@@ -211,10 +241,7 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
</TableCell> |
|
|
|
</TableRow> |
|
|
|
) : ( |
|
|
|
paginatedData.map((row) => { |
|
|
|
const isPending = row.ticketStatus?.toLowerCase() === 'pending'; |
|
|
|
const showTimes = !isPending && (row.ticketStatus?.toLowerCase() === 'released' || row.ticketStatus?.toLowerCase() === 'completed'); |
|
|
|
|
|
|
|
paginatedData.map((row) => { |
|
|
|
return ( |
|
|
|
<TableRow key={row.id}> |
|
|
|
<TableCell>{row.storeId || '-'}</TableCell> |
|
|
|
@@ -225,33 +252,27 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
</TableCell> |
|
|
|
|
|
|
|
<TableCell> |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.truckDepartureTime && row.truckLanceCode |
|
|
|
? (() => { |
|
|
|
let timeStr = row.truckDepartureTime.toString().trim(); |
|
|
|
timeStr = timeStr.replace(',', ':'); |
|
|
|
const timeMatch = timeStr.match(/^(\d{1,2})[:](\d{2})/); |
|
|
|
if (timeMatch) { |
|
|
|
const hours = timeMatch[1].padStart(2, '0'); |
|
|
|
const minutes = timeMatch[2]; |
|
|
|
return `${hours}:${minutes} | ${row.truckLanceCode}`; |
|
|
|
} |
|
|
|
return `${timeStr} | ${row.truckLanceCode}`; |
|
|
|
})() |
|
|
|
: row.truckDepartureTime |
|
|
|
? (() => { |
|
|
|
let timeStr = row.truckDepartureTime.toString().trim(); |
|
|
|
timeStr = timeStr.replace(',', ':'); |
|
|
|
const timeMatch = timeStr.match(/^(\d{1,2})[:](\d{2})/); |
|
|
|
if (timeMatch) { |
|
|
|
const hours = timeMatch[1].padStart(2, '0'); |
|
|
|
const minutes = timeMatch[2]; |
|
|
|
return `${hours}:${minutes}`; |
|
|
|
} |
|
|
|
return timeStr; |
|
|
|
})() |
|
|
|
: row.truckLanceCode || '-'} |
|
|
|
</Typography> |
|
|
|
<Box sx={{ display: 'flex', gap: 0.5, flexWrap: 'wrap', alignItems: 'center' }}> |
|
|
|
{row.truckLanceCode && ( |
|
|
|
<Chip |
|
|
|
label={row.truckLanceCode} |
|
|
|
size="small" |
|
|
|
color="primary" |
|
|
|
/> |
|
|
|
)} |
|
|
|
{row.truckDepartureTime && ( |
|
|
|
<Chip |
|
|
|
label={formatTime(row.truckDepartureTime)} |
|
|
|
size="small" |
|
|
|
color="secondary" |
|
|
|
/> |
|
|
|
)} |
|
|
|
{!row.truckLanceCode && !row.truckDepartureTime && ( |
|
|
|
<Typography variant="body2" sx={{ color: 'text.secondary' }}> |
|
|
|
- |
|
|
|
</Typography> |
|
|
|
)} |
|
|
|
</Box> |
|
|
|
</TableCell> |
|
|
|
|
|
|
|
<TableCell>{row.shopName || '-'}</TableCell> |
|
|
|
@@ -276,20 +297,16 @@ const FGPickOrderTicketReleaseTable: React.FC = () => { |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.ticketNo || '-'} ({row.ticketStatus || '-'}) |
|
|
|
</Typography> |
|
|
|
{showTimes && ( |
|
|
|
<> |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.ticketReleaseTime |
|
|
|
? dayjs(row.ticketReleaseTime, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') |
|
|
|
: '-'} |
|
|
|
</Typography> |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.ticketCompleteDateTime |
|
|
|
? dayjs(row.ticketCompleteDateTime, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') |
|
|
|
: '-'} |
|
|
|
</Typography> |
|
|
|
</> |
|
|
|
)} |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.ticketReleaseTime |
|
|
|
? dayjs(row.ticketReleaseTime, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') |
|
|
|
: '-'} |
|
|
|
</Typography> |
|
|
|
<Typography variant="body2"> |
|
|
|
{row.ticketCompleteDateTime |
|
|
|
? dayjs(row.ticketCompleteDateTime, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') |
|
|
|
: '-'} |
|
|
|
</Typography> |
|
|
|
</Box> |
|
|
|
</TableCell> |
|
|
|
<TableCell>{row.handlerName || '-'}</TableCell> |
|
|
|
|