diff --git a/src/components/AppBar/Profile.tsx b/src/components/AppBar/Profile.tsx index 8cb49cf..dc37351 100644 --- a/src/components/AppBar/Profile.tsx +++ b/src/components/AppBar/Profile.tsx @@ -25,7 +25,7 @@ const Profile: React.FC = ({ avatarImageSrc, profileName }) => { setProfileMenuAnchorEl(undefined); }; - const { t } = useTranslation("login"); + const { t } = useTranslation("common"); return ( <> diff --git a/src/components/FinishedGoodSearch/AssignAndRelease.tsx b/src/components/FinishedGoodSearch/AssignAndRelease.tsx index ab19e48..c38ec1d 100644 --- a/src/components/FinishedGoodSearch/AssignAndRelease.tsx +++ b/src/components/FinishedGoodSearch/AssignAndRelease.tsx @@ -35,6 +35,7 @@ import dayjs from "dayjs"; import arraySupport from "dayjs/plugin/arraySupport"; import SearchBox, { Criterion } from "../SearchBox"; import { fetchPickOrderItemsByPageClient } from "@/app/api/settings/item/actions"; +import { RESPONSE_LIMIT_DEFAULT } from "next/dist/server/api-utils"; dayjs.extend(arraySupport); @@ -159,7 +160,7 @@ const AssignAndRelease: React.FC = ({ filterArgs }) => { console.log("First record targetDate:", res.records[0]?.targetDate); console.log("First record targetDate type:", typeof res.records[0]?.targetDate); console.log("First record targetDate parsed:", new Date(res.records[0]?.targetDate)); -console.log("First record targetDate formatted:", new Date(res.records[0]?.targetDate).toLocaleDateString()); +console.log("First record targetDate formatted:", dayjs(res.records[0]?.targetDate).format(OUTPUT_DATE_FORMAT)); // 新增:在前端也过滤掉 "assigned" 状态的项目 const filteredRecords = res.records.filter((item: any) => item.status !== "assigned"); diff --git a/src/components/FinishedGoodSearch/CombinedLotTable.tsx b/src/components/FinishedGoodSearch/CombinedLotTable.tsx index 8b99721..f594d94 100644 --- a/src/components/FinishedGoodSearch/CombinedLotTable.tsx +++ b/src/components/FinishedGoodSearch/CombinedLotTable.tsx @@ -130,7 +130,7 @@ const CombinedLotTable: React.FC = ({ {lot.itemName} {lot.lotNo} {/* - {lot.expiryDate ? new Date(lot.expiryDate).toLocaleDateString() : 'N/A'} + {lot.expiryDate ? dayjs(lot.expiryDate).format(OUTPUT_DATE_FORMAT) : 'N/A'} */} {lot.location} diff --git a/src/components/FinishedGoodSearch/CreatedItemsTable.tsx b/src/components/FinishedGoodSearch/CreatedItemsTable.tsx index e60bf2f..20f56fd 100644 --- a/src/components/FinishedGoodSearch/CreatedItemsTable.tsx +++ b/src/components/FinishedGoodSearch/CreatedItemsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; +import dayjs from 'dayjs'; interface CreatedItem { itemId: number; @@ -179,7 +181,7 @@ const CreatedItemsTable: React.FC = ({ - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/FinishedGoodSearch/FGPickOrderCard.tsx b/src/components/FinishedGoodSearch/FGPickOrderCard.tsx index e2d3dc9..1f705ea 100644 --- a/src/components/FinishedGoodSearch/FGPickOrderCard.tsx +++ b/src/components/FinishedGoodSearch/FGPickOrderCard.tsx @@ -4,6 +4,8 @@ import { FGPickOrderResponse } from "@/app/api/pickOrder/actions"; import { Box, Card, CardContent, Grid, Stack, TextField, Button } from "@mui/material"; import { useTranslation } from "react-i18next"; import QrCodeIcon from '@mui/icons-material/QrCode'; +import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import dayjs from "dayjs"; type Props = { fgOrder: FGPickOrderResponse; @@ -58,7 +60,7 @@ const FGPickOrderCard: React.FC = ({ fgOrder, onQrCodeClick }) => { label={t("Delivery Date")} fullWidth disabled={true} - value={new Date(fgOrder.deliveryDate).toLocaleDateString()} + value={dayjs(fgOrder.deliveryDate).format(OUTPUT_DATE_FORMAT)} /> diff --git a/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx b/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx index 89d50b6..6deb569 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx @@ -21,6 +21,9 @@ import { useTranslation } from "react-i18next"; import { GetPickOrderLineInfo, PickExecutionIssueData } from "@/app/api/pickOrder/actions"; import { fetchEscalationCombo } from "@/app/api/user/actions"; import { useRef } from "react"; +import dayjs from 'dayjs'; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; + interface LotPickData { id: number; lotId: number; @@ -127,12 +130,15 @@ const PickExecutionForm: React.FC = ({ if (initKeyRef.current === key) return; const getSafeDate = (dateValue: any): string => { - if (!dateValue) return new Date().toISOString().split('T')[0]; + if (!dateValue) return dayjs().format(INPUT_DATE_FORMAT); try { - const d = new Date(dateValue); - return isNaN(d.getTime()) ? new Date().toISOString().split('T')[0] : d.toISOString().split('T')[0]; + const date = dayjs(dateValue); + if (!date.isValid()) { + return dayjs().format(INPUT_DATE_FORMAT); + } + return date.format(INPUT_DATE_FORMAT); } catch { - return new Date().toISOString().split('T')[0]; + return dayjs().format(INPUT_DATE_FORMAT); } }; @@ -140,7 +146,7 @@ const PickExecutionForm: React.FC = ({ pickOrderId: pickOrderId, pickOrderCode: selectedPickOrderLine.pickOrderCode, pickOrderCreateDate: getSafeDate(pickOrderCreateDate), - pickExecutionDate: new Date().toISOString().split('T')[0], + pickExecutionDate: dayjs().format(INPUT_DATE_FORMAT), pickOrderLineId: selectedPickOrderLine.id, itemId: selectedPickOrderLine.itemId, itemCode: selectedPickOrderLine.itemCode, diff --git a/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx b/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx index d07f1e9..28d0d14 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx @@ -61,6 +61,8 @@ import { SessionWithTokens } from "@/config/authConfig"; import { fetchStockInLineInfo } from "@/app/api/po/actions"; import GoodPickExecutionForm from "./GoodPickExecutionForm"; import FGPickOrderCard from "./FGPickOrderCard"; +import dayjs from "dayjs"; +import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; interface Props { filterArgs: Record; @@ -343,7 +345,7 @@ const GoodPickExecutionRecord: React.FC = ({ filterArgs }) => { {/* 结果统计 */} - {t("Total")}: {filteredDoPickOrders.length} {t("completed DO pick orders")} + {t("Completed DO pick orders: ")} {filteredDoPickOrders.length} {/* 列表 */} @@ -367,7 +369,7 @@ const GoodPickExecutionRecord: React.FC = ({ filterArgs }) => { {doPickOrder.shopName} - {doPickOrder.deliveryNo} - {t("Completed")}: {new Date(doPickOrder.completedDate).toLocaleString()} + {t("Completed")}: {dayjs(doPickOrder.completedDate).format(OUTPUT_DATE_FORMAT)} diff --git a/src/components/FinishedGoodSearch/Jobcreatitem.tsx b/src/components/FinishedGoodSearch/Jobcreatitem.tsx index 9231102..5e956e2 100644 --- a/src/components/FinishedGoodSearch/Jobcreatitem.tsx +++ b/src/components/FinishedGoodSearch/Jobcreatitem.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -835,7 +835,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -942,7 +942,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, @@ -1601,7 +1601,7 @@ const CustomSearchResultsTable = () => { {/* Target Date - Show the item's own target date (or "-" if not selected) */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/FinishedGoodSearch/SearchResultsTable.tsx b/src/components/FinishedGoodSearch/SearchResultsTable.tsx index 5ceb5f8..ff82ac8 100644 --- a/src/components/FinishedGoodSearch/SearchResultsTable.tsx +++ b/src/components/FinishedGoodSearch/SearchResultsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; +import dayjs from 'dayjs'; interface SearchItemWithQty { id: number; @@ -213,7 +215,7 @@ const SearchResultsTable: React.FC = ({ {/* Target Date */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/FinishedGoodSearch/newcreatitem copy.tsx b/src/components/FinishedGoodSearch/newcreatitem copy.tsx index 4d876fa..dc94095 100644 --- a/src/components/FinishedGoodSearch/newcreatitem copy.tsx +++ b/src/components/FinishedGoodSearch/newcreatitem copy.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -837,7 +837,7 @@ const NewCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/FinishedGoodSearch/newcreatitem.tsx b/src/components/FinishedGoodSearch/newcreatitem.tsx index 344687b..3edb2ec 100644 --- a/src/components/FinishedGoodSearch/newcreatitem.tsx +++ b/src/components/FinishedGoodSearch/newcreatitem.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient,fetchItemsWithDetails } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -954,7 +954,7 @@ const handleQtyBlur = useCallback((itemId: number) => { - {item.targetDate&& item.targetDate !== "" ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate&& item.targetDate !== "" ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -1061,7 +1061,7 @@ const handleQtyBlur = useCallback((itemId: number) => { label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, @@ -1806,7 +1806,7 @@ const CustomSearchResultsTable = () => { - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/Jodetail/CombinedLotTable.tsx b/src/components/Jodetail/CombinedLotTable.tsx index 8b99721..3d5c4c0 100644 --- a/src/components/Jodetail/CombinedLotTable.tsx +++ b/src/components/Jodetail/CombinedLotTable.tsx @@ -130,7 +130,7 @@ const CombinedLotTable: React.FC = ({ {lot.itemName} {lot.lotNo} {/* - {lot.expiryDate ? new Date(lot.expiryDate).toLocaleDateString() : 'N/A'} + {lot.expiryDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : 'N/A'} */} {lot.location} diff --git a/src/components/Jodetail/CreatedItemsTable.tsx b/src/components/Jodetail/CreatedItemsTable.tsx index e60bf2f..3c08dc7 100644 --- a/src/components/Jodetail/CreatedItemsTable.tsx +++ b/src/components/Jodetail/CreatedItemsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import dayjs from 'dayjs'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; interface CreatedItem { itemId: number; @@ -179,7 +181,7 @@ const CreatedItemsTable: React.FC = ({ - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/Jodetail/FGPickOrderCard.tsx b/src/components/Jodetail/FGPickOrderCard.tsx index 36156b3..cbde663 100644 --- a/src/components/Jodetail/FGPickOrderCard.tsx +++ b/src/components/Jodetail/FGPickOrderCard.tsx @@ -4,6 +4,8 @@ import { FGPickOrderResponse } from "@/app/api/pickOrder/actions"; import { Box, Card, CardContent, Grid, Stack, TextField, Button } from "@mui/material"; import { useTranslation } from "react-i18next"; import QrCodeIcon from '@mui/icons-material/QrCode'; +import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import dayjs from "dayjs"; type Props = { fgOrder: FGPickOrderResponse; @@ -72,7 +74,7 @@ const FGPickOrderCard: React.FC = ({ fgOrder, onQrCodeClick }) => { label={t("Delivery Date")} fullWidth disabled={true} - value={new Date(fgOrder.deliveryDate).toLocaleDateString()} + value={dayjs(fgOrder.deliveryDate).format(OUTPUT_DATE_FORMAT)} /> diff --git a/src/components/Jodetail/JobPickExecutionForm.tsx b/src/components/Jodetail/JobPickExecutionForm.tsx index 88db1c0..7241bdd 100644 --- a/src/components/Jodetail/JobPickExecutionForm.tsx +++ b/src/components/Jodetail/JobPickExecutionForm.tsx @@ -22,6 +22,9 @@ import { GetPickOrderLineInfo, PickExecutionIssueData } from "@/app/api/pickOrde import { fetchEscalationCombo } from "@/app/api/user/actions"; import { useSession } from "next-auth/react"; import { SessionWithTokens } from "@/config/authConfig"; +import dayjs from 'dayjs'; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; + interface LotPickData { id: number; lotId: number; @@ -111,18 +114,18 @@ const PickExecutionForm: React.FC = ({ // 初始化表单数据 - 每次打开时都重新初始化 useEffect(() => { if (open && selectedLot && selectedPickOrderLine && pickOrderId) { - const getSafeDate = (dateValue: any): string => { - if (!dateValue) return new Date().toISOString().split('T')[0]; - try { - const date = new Date(dateValue); - if (isNaN(date.getTime())) { - return new Date().toISOString().split('T')[0]; - } - return date.toISOString().split('T')[0]; - } catch { - return new Date().toISOString().split('T')[0]; + const getSafeDate = (dateValue: any): string => { + if (!dateValue) return dayjs().format(INPUT_DATE_FORMAT); + try { + const date = dayjs(dateValue); + if (!date.isValid()) { + return dayjs().format(INPUT_DATE_FORMAT); } - }; + return date.format(INPUT_DATE_FORMAT); + } catch { + return dayjs().format(INPUT_DATE_FORMAT); + } + }; // ✅ Initialize verified quantity to the received quantity (actualPickQty) const initialVerifiedQty = selectedLot.actualPickQty || 0; @@ -137,7 +140,7 @@ const PickExecutionForm: React.FC = ({ pickOrderId: pickOrderId, pickOrderCode: selectedPickOrderLine.pickOrderCode, pickOrderCreateDate: getSafeDate(pickOrderCreateDate), - pickExecutionDate: new Date().toISOString().split('T')[0], + pickExecutionDate: dayjs().format(INPUT_DATE_FORMAT), pickOrderLineId: selectedPickOrderLine.id, itemId: selectedPickOrderLine.itemId, itemCode: selectedPickOrderLine.itemCode, diff --git a/src/components/Jodetail/Jobcreatitem.tsx b/src/components/Jodetail/Jobcreatitem.tsx index 9231102..5e956e2 100644 --- a/src/components/Jodetail/Jobcreatitem.tsx +++ b/src/components/Jodetail/Jobcreatitem.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -835,7 +835,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -942,7 +942,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, @@ -1601,7 +1601,7 @@ const CustomSearchResultsTable = () => { {/* Target Date - Show the item's own target date (or "-" if not selected) */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/Jodetail/JobmatchForm.tsx b/src/components/Jodetail/JobmatchForm.tsx index 1aa4729..a454e20 100644 --- a/src/components/Jodetail/JobmatchForm.tsx +++ b/src/components/Jodetail/JobmatchForm.tsx @@ -22,6 +22,8 @@ import { GetPickOrderLineInfo, PickExecutionIssueData } from "@/app/api/pickOrde import { fetchEscalationCombo } from "@/app/api/user/actions"; import { useSession } from "next-auth/react"; import { SessionWithTokens } from "@/config/authConfig"; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import dayjs from "dayjs"; interface LotPickData { id: number; @@ -113,19 +115,19 @@ const PickExecutionForm: React.FC = ({ // 初始化表单数据 - 每次打开时都重新初始化 useEffect(() => { if (open && selectedLot && selectedPickOrderLine && pickOrderId) { - const getSafeDate = (dateValue: any): string => { - if (!dateValue) return new Date().toISOString().split('T')[0]; - try { - const date = new Date(dateValue); - if (isNaN(date.getTime())) { - return new Date().toISOString().split('T')[0]; - } - return date.toISOString().split('T')[0]; - } catch { - return new Date().toISOString().split('T')[0]; + const getSafeDate = (dateValue: any): string => { + if (!dateValue) return dayjs().format(INPUT_DATE_FORMAT); + try { + const date = dayjs(dateValue); + if (!date.isValid()) { + return dayjs().format(INPUT_DATE_FORMAT); } - }; - + return date.format(INPUT_DATE_FORMAT); + } catch { + return dayjs().format(INPUT_DATE_FORMAT); + } + }; + // ✅ Initialize verified quantity to the received quantity (actualPickQty) const initialVerifiedQty = selectedLot.actualPickQty || 0; setVerifiedQty(initialVerifiedQty); @@ -139,7 +141,7 @@ const PickExecutionForm: React.FC = ({ pickOrderId: pickOrderId, pickOrderCode: selectedPickOrderLine.pickOrderCode, pickOrderCreateDate: getSafeDate(pickOrderCreateDate), - pickExecutionDate: new Date().toISOString().split('T')[0], + pickExecutionDate: dayjs().format(INPUT_DATE_FORMAT), pickOrderLineId: selectedPickOrderLine.id, itemId: selectedPickOrderLine.itemId, itemCode: selectedPickOrderLine.itemCode, diff --git a/src/components/Jodetail/SearchResultsTable.tsx b/src/components/Jodetail/SearchResultsTable.tsx index 5ceb5f8..ff82ac8 100644 --- a/src/components/Jodetail/SearchResultsTable.tsx +++ b/src/components/Jodetail/SearchResultsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; +import dayjs from 'dayjs'; interface SearchItemWithQty { id: number; @@ -213,7 +215,7 @@ const SearchResultsTable: React.FC = ({ {/* Target Date */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/PickOrderSearch/CreatedItemsTable.tsx b/src/components/PickOrderSearch/CreatedItemsTable.tsx index 50e7a0e..05d7149 100644 --- a/src/components/PickOrderSearch/CreatedItemsTable.tsx +++ b/src/components/PickOrderSearch/CreatedItemsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; +import dayjs from 'dayjs'; interface CreatedItem { itemId: number; @@ -179,7 +181,7 @@ const CreatedItemsTable: React.FC = ({ - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/PickOrderSearch/Jobcreatitem.tsx b/src/components/PickOrderSearch/Jobcreatitem.tsx index 9231102..5e956e2 100644 --- a/src/components/PickOrderSearch/Jobcreatitem.tsx +++ b/src/components/PickOrderSearch/Jobcreatitem.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -835,7 +835,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -942,7 +942,7 @@ const JobCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, @@ -1601,7 +1601,7 @@ const CustomSearchResultsTable = () => { {/* Target Date - Show the item's own target date (or "-" if not selected) */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/PickOrderSearch/PickExecution.tsx b/src/components/PickOrderSearch/PickExecution.tsx index 30cfdbb..9da3953 100644 --- a/src/components/PickOrderSearch/PickExecution.tsx +++ b/src/components/PickOrderSearch/PickExecution.tsx @@ -56,7 +56,7 @@ import { SubmitHandler, useForm, } from "react-hook-form"; -import { pickOrderStatusMap } from "@/app/utils/formatUtil"; +import { OUTPUT_DATE_FORMAT, pickOrderStatusMap } from "@/app/utils/formatUtil"; import { QcItemWithChecks } from "@/app/api/qc"; import { fetchQcItemCheck, fetchPickOrderQcResult } from "@/app/api/qc/actions"; @@ -610,7 +610,7 @@ const PickExecution: React.FC = ({ filterArgs }) => { id: lot.id, lotId: lot.lotId, lotNo: lot.lotNo, - expiryDate: lot.expiryDate ? new Date(lot.expiryDate).toLocaleDateString() : 'N/A', + expiryDate: lot.expiryDate ? dayjs(lot.expiryDate).format(OUTPUT_DATE_FORMAT) : 'N/A', location: lot.location, stockUnit: lot.stockUnit, inQty: lot.inQty, diff --git a/src/components/PickOrderSearch/PickExecutionForm.tsx b/src/components/PickOrderSearch/PickExecutionForm.tsx index e51ea71..43c9da4 100644 --- a/src/components/PickOrderSearch/PickExecutionForm.tsx +++ b/src/components/PickOrderSearch/PickExecutionForm.tsx @@ -20,6 +20,9 @@ import { useCallback, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { GetPickOrderLineInfo, PickExecutionIssueData } from "@/app/api/pickOrder/actions"; import { fetchEscalationCombo } from "@/app/api/user/actions"; +import dayjs from 'dayjs'; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; + interface LotPickData { id: number; @@ -108,18 +111,18 @@ const calculateRequiredQty = useCallback((lot: LotPickData) => { // 初始化表单数据 - 每次打开时都重新初始化 useEffect(() => { if (open && selectedLot && selectedPickOrderLine && pickOrderId) { - const getSafeDate = (dateValue: any): string => { - if (!dateValue) return new Date().toISOString().split('T')[0]; - try { - const date = new Date(dateValue); - if (isNaN(date.getTime())) { - return new Date().toISOString().split('T')[0]; - } - return date.toISOString().split('T')[0]; - } catch { - return new Date().toISOString().split('T')[0]; + const getSafeDate = (dateValue: any): string => { + if (!dateValue) return dayjs().format(INPUT_DATE_FORMAT); + try { + const date = dayjs(dateValue); + if (!date.isValid()) { + return dayjs().format(INPUT_DATE_FORMAT); } - }; + return date.format(INPUT_DATE_FORMAT); + } catch { + return dayjs().format(INPUT_DATE_FORMAT); + } + }; // 计算剩余可用数量 const remainingAvailableQty = calculateRemainingAvailableQty(selectedLot); @@ -136,7 +139,7 @@ const calculateRequiredQty = useCallback((lot: LotPickData) => { pickOrderId: pickOrderId, pickOrderCode: selectedPickOrderLine.pickOrderCode, pickOrderCreateDate: getSafeDate(pickOrderCreateDate), - pickExecutionDate: new Date().toISOString().split('T')[0], + pickExecutionDate: dayjs().format(INPUT_DATE_FORMAT), pickOrderLineId: selectedPickOrderLine.id, itemId: selectedPickOrderLine.itemId, itemCode: selectedPickOrderLine.itemCode, diff --git a/src/components/PickOrderSearch/SearchResultsTable.tsx b/src/components/PickOrderSearch/SearchResultsTable.tsx index 5ceb5f8..ff82ac8 100644 --- a/src/components/PickOrderSearch/SearchResultsTable.tsx +++ b/src/components/PickOrderSearch/SearchResultsTable.tsx @@ -17,6 +17,8 @@ import { MenuItem, } from '@mui/material'; import { useTranslation } from 'react-i18next'; +import { OUTPUT_DATE_FORMAT } from '@/app/utils/formatUtil'; +import dayjs from 'dayjs'; interface SearchItemWithQty { id: number; @@ -213,7 +215,7 @@ const SearchResultsTable: React.FC = ({ {/* Target Date */} - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/PickOrderSearch/newcreatitem copy.tsx b/src/components/PickOrderSearch/newcreatitem copy.tsx index 4d876fa..cded46e 100644 --- a/src/components/PickOrderSearch/newcreatitem copy.tsx +++ b/src/components/PickOrderSearch/newcreatitem copy.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -837,7 +837,7 @@ const NewCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -944,7 +944,7 @@ const NewCreateItem: React.FC = ({ filterArgs, searchQuery, onPickOrderCr label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, diff --git a/src/components/PickOrderSearch/newcreatitem.tsx b/src/components/PickOrderSearch/newcreatitem.tsx index 3e3ffc2..264cd93 100644 --- a/src/components/PickOrderSearch/newcreatitem.tsx +++ b/src/components/PickOrderSearch/newcreatitem.tsx @@ -33,7 +33,7 @@ import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import dayjs from "dayjs"; import { Check, Search, RestartAlt } from "@mui/icons-material"; import { ItemCombo, fetchAllItemsInClient,fetchItemsWithDetails } from "@/app/api/settings/item/actions"; -import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; import SearchResults, { Column } from "../SearchResults/SearchResults"; import { fetchJobOrderDetailByCode } from "@/app/api/jo/actions"; import SearchBox, { Criterion } from "../SearchBox"; @@ -960,7 +960,7 @@ const handleQtyBlur = useCallback((itemId: number) => { - {item.targetDate&& item.targetDate !== "" ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate&& item.targetDate !== "" ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} @@ -1067,7 +1067,7 @@ const handleQtyBlur = useCallback((itemId: number) => { label: t("Target Date"), renderCell: (item) => ( - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} ), }, @@ -1812,7 +1812,7 @@ const CustomSearchResultsTable = () => { - {item.targetDate ? new Date(item.targetDate).toLocaleDateString() : "-"} + {item.targetDate ? dayjs(item.targetDate).format(OUTPUT_DATE_FORMAT) : "-"} diff --git a/src/components/ProductionProcess/ProductionRecordingModal.tsx b/src/components/ProductionProcess/ProductionRecordingModal.tsx index 4aece49..9bb5a51 100644 --- a/src/components/ProductionProcess/ProductionRecordingModal.tsx +++ b/src/components/ProductionProcess/ProductionRecordingModal.tsx @@ -19,6 +19,8 @@ import { Operator, Machine } from "@/app/api/jo"; import OperatorScanner from "./OperatorScanner"; import MachineScanner from "./MachineScanner"; import MaterialLotScanner from "./MaterialLotScanner"; +import dayjs from 'dayjs'; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; interface ProductionRecordingModalProps { isOpen: boolean; @@ -43,7 +45,7 @@ const ProductionRecordingModal: React.FC = ({ formState: { errors }, } = useForm({ defaultValues: { - productionDate: new Date().toISOString().split("T")[0], + productionDate: dayjs().format(INPUT_DATE_FORMAT), notes: "", operators: [], machines: [], @@ -128,7 +130,7 @@ const ProductionRecordingModal: React.FC = ({ const handleClose = (): void => { reset({ - productionDate: new Date().toISOString().split("T")[0], + productionDate: dayjs().format(INPUT_DATE_FORMAT), notes: "", operators: [], machines: [], diff --git a/src/components/ProductionProcess/QualityCheckModal.tsx b/src/components/ProductionProcess/QualityCheckModal.tsx index 277859c..d3212e8 100644 --- a/src/components/ProductionProcess/QualityCheckModal.tsx +++ b/src/components/ProductionProcess/QualityCheckModal.tsx @@ -22,6 +22,8 @@ import { import { getStatusIcon, getStatusColor } from "./utils/QualityCheckHelper"; import DefectsSection from "./DefectsSection"; import OperatorScanner from "./OperatorScanner"; +import dayjs from 'dayjs'; +import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; const QualityCheckModal: React.FC = ({ isOpen, @@ -39,8 +41,7 @@ const QualityCheckModal: React.FC = ({ formState: { errors, isValid }, } = useForm({ defaultValues: { - inspectors: [], - checkDate: new Date().toISOString().split("T")[0], + checkDate: dayjs().format(INPUT_DATE_FORMAT), status: "pending", notes: "", defects: [], @@ -94,7 +95,7 @@ const QualityCheckModal: React.FC = ({ const handleClose = (): void => { reset({ inspectors: [], - checkDate: new Date().toISOString().split("T")[0], + checkDate: dayjs().format(INPUT_DATE_FORMAT), status: "pending", notes: "", defects: [], diff --git a/src/i18n/zh/common.json b/src/i18n/zh/common.json index 7d6ac34..7058bea 100644 --- a/src/i18n/zh/common.json +++ b/src/i18n/zh/common.json @@ -103,6 +103,7 @@ "All Pick Order Lots": "所有提料單批號", "Row per page": "每頁行數", "No data available": "沒有資料", - "jodetail": "工單細節" + "jodetail": "工單細節", + "Sign out": "登出" } diff --git a/src/i18n/zh/jo.json b/src/i18n/zh/jo.json index 26776d1..178d111 100644 --- a/src/i18n/zh/jo.json +++ b/src/i18n/zh/jo.json @@ -270,7 +270,8 @@ "success": "成功", "Total (Verified + Bad + Missing) must equal Required quantity": "驗證數量 + 不良數量 + 缺失數量必須等於需求數量", "BOM Status": "材料預備狀況", - "Estimated Production Date": "預計生產日期", - "Plan Start": "預計生產日期", - "Plan Start To": "預計生產日期(至)" + "Estimated Production Date": "預計生產日期及時間", + "Plan Start": "預計生產日期及時間", + "Plan Start From": "預計生產日期及時間", + "Plan Start To": "預計生產日期及時間至" } diff --git a/src/i18n/zh/pickOrder.json b/src/i18n/zh/pickOrder.json index c5dd822..2a33c10 100644 --- a/src/i18n/zh/pickOrder.json +++ b/src/i18n/zh/pickOrder.json @@ -282,7 +282,7 @@ "Pick Execution Record":"提料執行記錄", "Delivery No.":"送貨單編號", "Total":"總數", - "completed DO pick orders":"已完成送貨單提料單", + "Completed DO pick orders: ":"已完成送貨單提料單:", "No completed DO pick orders found":"沒有已完成送貨單提料單", "Print DN Label":"列印送貨單標貼",