浏览代码

fix date time display

master
kelvinsuen 1 天前
父节点
当前提交
af677a8d88
共有 5 个文件被更改,包括 29 次插入26 次删除
  1. +8
    -7
      src/app/utils/formatUtil.ts
  2. +2
    -2
      src/components/DashboardPage/escalation/EscalationLogTable.tsx
  3. +13
    -12
      src/components/PoDetail/QcStockInModalVer2.tsx
  4. +3
    -2
      src/components/PoDetail/StockInFormVer2.tsx
  5. +3
    -3
      src/i18n/zh/dashboard.json

+ 8
- 7
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);


+ 2
- 2
src/components/DashboardPage/escalation/EscalationLogTable.tsx 查看文件

@@ -98,12 +98,12 @@ const EscalationLogTable: React.FC<Props> = ({
},
{
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);
}
},
{


+ 13
- 12
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)


+ 3
- 2
src/components/PoDetail/StockInFormVer2.tsx 查看文件

@@ -109,7 +109,9 @@ const StockInFormVer2: React.FC<Props> = ({
if (productionDate) clearErrors();
}, [productionDate, expiryDate, clearErrors]);

// console.log(itemDetail)
useEffect(() => {
console.log("%c StockInForm itemDetail update: ", "color: brown", itemDetail);
}, [itemDetail]);

return (
<Grid container justifyContent="flex-start" alignItems="flex-start">
@@ -286,7 +288,6 @@ const StockInFormVer2: React.FC<Props> = ({
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));


+ 3
- 3
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": "上報時間"
}

正在加载...
取消
保存