diff --git a/src/app/utils/formatUtil.ts b/src/app/utils/formatUtil.ts index e87b21a..4aada22 100644 --- a/src/app/utils/formatUtil.ts +++ b/src/app/utils/formatUtil.ts @@ -49,25 +49,26 @@ export const arrayToDayjs = (arr: ConfigType | (number | undefined)[], showTime: tempArr = `${arr[0]?.toString().padStart(4, "0")}-${arr[1]?.toString().padStart(2, "0")}-${arr[2]?.toString().padStart(2, "0")}`; if (showTime) { // [year, month, day, hour, minute, second] - tempArr += ` ${arr[3]?.toString().padStart(2, "0")}-${arr[4]?.toString().padStart(2, "0")}-${arr[5]?.toString().padStart(2, "0")}`; + tempArr += ` ${arr[3]?.toString().padStart(2, "0")}:${arr[4]?.toString().padStart(2, "0")}:${arr[5]?.toString().padStart(2, "0")}`; } } return dayjs(tempArr as ConfigType); }; -export const arrayToDateString = (arr: ConfigType | (number | undefined)[]) => { - return arrayToDayjs(arr).format(OUTPUT_DATE_FORMAT); +export const arrayToDateString = (arr: ConfigType | (number | undefined)[], format: "input"|"output" = "output") => { + if (format == "output") { + return arrayToDayjs(arr).format(OUTPUT_DATE_FORMAT); + } + else { + return arrayToDayjs(arr).format(INPUT_DATE_FORMAT); + } }; export const arrayToDateTimeString = (arr: ConfigType | (number | undefined)[]) => { return arrayToDayjs(arr, true).format(`${OUTPUT_DATE_FORMAT} ${OUTPUT_TIME_FORMAT}`); }; -export const arrayToInputDateString = (arr: ConfigType | (number | undefined)[]) => { - return arrayToDayjs(arr).format(INPUT_DATE_FORMAT); -}; - export const dateStringToDayjs = (date: string) => { // Format: YYYY/MM/DD return dayjs(date, OUTPUT_DATE_FORMAT); diff --git a/src/components/DashboardPage/escalation/EscalationLogTable.tsx b/src/components/DashboardPage/escalation/EscalationLogTable.tsx index e6af50d..e097134 100644 --- a/src/components/DashboardPage/escalation/EscalationLogTable.tsx +++ b/src/components/DashboardPage/escalation/EscalationLogTable.tsx @@ -98,12 +98,12 @@ const EscalationLogTable: React.FC = ({ }, { name: "recordDate", - label: t("escalated date"), + label: t("escalated datetime"), align: "right", headerAlign: "right", sx: { width: "10%", minWidth: 100 }, renderCell: (params) => { - return arrayToDateString(params.recordDate); + return arrayToDateTimeString(params.recordDate); } }, { diff --git a/src/components/PoDetail/QcStockInModalVer2.tsx b/src/components/PoDetail/QcStockInModalVer2.tsx index 4502c00..dfb7f74 100644 --- a/src/components/PoDetail/QcStockInModalVer2.tsx +++ b/src/components/PoDetail/QcStockInModalVer2.tsx @@ -17,14 +17,13 @@ import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } f import { FormProvider, SubmitErrorHandler, SubmitHandler, useForm } from "react-hook-form"; import { StockInLineRow } from "./PoInputGrid"; import { useTranslation } from "react-i18next"; -import StockInForm from "./StockInForm"; import StockInFormVer2 from "./StockInFormVer2"; import QcComponent from "./QcComponent"; import { dummyPutAwayLine, dummyQCData } from "./dummyQcTemplate"; import PutAwayForm from "./PutAwayForm"; import { GridRowModes, useGridApiRef } from "@mui/x-data-grid"; import {submitDialogWithWarning} from "../Swal/CustomAlerts"; -import { INPUT_DATE_FORMAT, arrayToDateString, arrayToInputDateString, dayjsToInputDateString } from "@/app/utils/formatUtil"; +import { INPUT_DATE_FORMAT, arrayToDateString, dayjsToInputDateString } from "@/app/utils/formatUtil"; import dayjs from "dayjs"; import { fetchPoQrcode } from "@/app/api/pdf/actions"; import { downloadFile } from "@/app/utils/commonUtil"; @@ -103,12 +102,14 @@ const defaultNewValue = useMemo(() => { { ...itemDetail, status: itemDetail.status ?? "pending", - dnDate: arrayToInputDateString(itemDetail.dnDate)?? dayjsToInputDateString(dayjs()), + dnDate: arrayToDateString(itemDetail.dnDate, "input")?? dayjsToInputDateString(dayjs()), // putAwayLines: dummyPutAwayLine, // putAwayLines: itemDetail.putAwayLines.map((line) => (return {...line, printQty: 1})) ?? [], putAwayLines: itemDetail.putAwayLines?.map((line) => ({...line, printQty: 1, _isNew: false})) ?? [], // qcResult: (itemDetail.qcResult && itemDetail.qcResult?.length > 0) ? itemDetail.qcResult : [],//[...dummyQCData], escResult: (itemDetail.escResult && itemDetail.escResult?.length > 0) ? itemDetail.escResult : [], + productionDate: itemDetail.productionDate ? arrayToDateString(itemDetail.productionDate, "input") : undefined, + expiryDate: itemDetail.expiryDate ? arrayToDateString(itemDetail.expiryDate, "input") : undefined, receiptDate: itemDetail.receiptDate ?? dayjs().add(0, "month").format(INPUT_DATE_FORMAT), acceptQty: itemDetail.demandQty?? itemDetail.acceptedQty, warehouseId: itemDetail.defaultWarehouseId ?? 1 @@ -241,7 +242,7 @@ const [qcItems, setQcItems] = useState(dummyQCData) // if (qcAccept === undefined) { validationErrors.push(t("QC decision is required")); } - + // Check if accept quantity is valid if (data.qcDecision == 2) { acceptQty = 0; @@ -282,10 +283,10 @@ const [qcItems, setQcItems] = useState(dummyQCData) const qcData = { dnNo : data.dnNo? data.dnNo : "DN00000", - dnDate : data.dnDate? arrayToInputDateString(data.dnDate) : dayjsToInputDateString(dayjs()), - productionDate : arrayToInputDateString(data.productionDate), - expiryDate : arrayToInputDateString(data.expiryDate), - receiptDate : arrayToInputDateString(data.receiptDate), + dnDate : data.dnDate? arrayToDateString(data.dnDate, "input") : dayjsToInputDateString(dayjs()), + productionDate : arrayToDateString(data.productionDate, "input"), + expiryDate : arrayToDateString(data.expiryDate, "input"), + receiptDate : arrayToDateString(data.receiptDate, "input"), qcAccept: qcAccept? qcAccept : false, acceptQty: acceptQty? acceptQty : 0, @@ -388,10 +389,10 @@ const [qcItems, setQcItems] = useState(dummyQCData) status: data.status, //TODO Fix it! // ...data, - dnDate : data.dnDate? arrayToInputDateString(data.dnDate) : dayjsToInputDateString(dayjs()), - productionDate : arrayToInputDateString(data.productionDate), - expiryDate : arrayToInputDateString(data.expiryDate), - receiptDate : arrayToInputDateString(data.receiptDate), + dnDate : data.dnDate? arrayToDateString(data.dnDate) : dayjsToInputDateString(dayjs()), + productionDate : arrayToDateString(data.productionDate, "input"), + expiryDate : arrayToDateString(data.expiryDate, "input"), + receiptDate : arrayToDateString(data.receiptDate, "input"), // for putaway data inventoryLotLines: data.putAwayLines?.filter((line) => line._isNew !== false) diff --git a/src/components/PoDetail/StockInFormVer2.tsx b/src/components/PoDetail/StockInFormVer2.tsx index 336c27c..398e9c7 100644 --- a/src/components/PoDetail/StockInFormVer2.tsx +++ b/src/components/PoDetail/StockInFormVer2.tsx @@ -109,7 +109,9 @@ const StockInFormVer2: React.FC = ({ if (productionDate) clearErrors(); }, [productionDate, expiryDate, clearErrors]); - // console.log(itemDetail) + useEffect(() => { + console.log("%c StockInForm itemDetail update: ", "color: brown", itemDetail); + }, [itemDetail]); return ( @@ -286,7 +288,6 @@ const StockInFormVer2: React.FC = ({ value={expiryDate ? dayjs(expiryDate) : undefined} disabled={disabled} onChange={(date) => { - console.log(date); if (!date) return; console.log(date.format(INPUT_DATE_FORMAT)); setValue("expiryDate", date.format(INPUT_DATE_FORMAT)); diff --git a/src/i18n/zh/dashboard.json b/src/i18n/zh/dashboard.json index c84f0aa..9de6d0f 100644 --- a/src/i18n/zh/dashboard.json +++ b/src/i18n/zh/dashboard.json @@ -1,7 +1,7 @@ { "Dashboard": "資訊展示面板", "Order status": "訂單狀態", - "pending": "未收貨", + "pending": "待處理", "receiving": "收貨中", "total": "未完成總數", "Warehouse temperature record": "倉庫溫度記錄", @@ -33,7 +33,6 @@ "Processed application": "已處理提料申請", "Pending application": "待處理提料申請", "pending inspection material": "待品檢物料", - "pending": "待處理", "rejected": "已拒絕", "escalated": "已上報", "inspected material": "已品檢物料", @@ -50,5 +49,6 @@ "Purchase UoM": "計量單位", "QC Completed Count": "品檢完成數量", "QC Fail-Total Count": "品檢不合格/總數", - "escalationStatus": "上報狀態" + "escalationStatus": "上報狀態", + "escalated datetime": "上報時間" }