浏览代码

update

master
cyril.tsui 4 周前
父节点
当前提交
4dff1a447f
共有 4 个文件被更改,包括 34 次插入34 次删除
  1. +32
    -0
      src/app/utils/commonClientUtil.ts
  2. +0
    -32
      src/app/utils/formatUtil.ts
  3. +1
    -1
      src/components/DetailedScheduleDetail/ProdTimeColumn.tsx
  4. +1
    -1
      src/components/DetailedScheduleDetail/ViewByFGDetails.tsx

+ 32
- 0
src/app/utils/commonClientUtil.ts 查看文件

@@ -0,0 +1,32 @@
import { useTranslation } from "react-i18next";

export const minutesToHoursMinutes = (minutes: number): string => {
const { t } = useTranslation("common");
const defaultHrStr = "hr"
const defaultMinStr = "min"

if (minutes == 0) {
return `0 ${defaultMinStr}`
}

const hrs = Math.floor(minutes / 60)
const mins = minutes % 60

let finalHrStr: string = ""
if (hrs > 1) {
finalHrStr = `${hrs} ` + t(`${defaultHrStr}s`)
} else if (hrs == 1) {
finalHrStr = `1 ` + t(`${defaultHrStr}`)
}

let finalMinStr: string = ""
if (mins > 1) {
finalMinStr = `${mins} ` + t(`${defaultMinStr}s`)
} else if (mins == 1) {
finalMinStr = `1 ` + t(`${defaultMinStr}`)
}

const colon = finalHrStr.length > 0 && finalMinStr.length > 0 ? ":" : ""

return `${finalHrStr} ${colon} ${finalMinStr}`.trim()
}

+ 0
- 32
src/app/utils/formatUtil.ts 查看文件

@@ -10,7 +10,6 @@ import {
take, take,
} from "lodash"; } from "lodash";
import { Box, BoxProps } from "@mui/material"; import { Box, BoxProps } from "@mui/material";
import { useTranslation } from "react-i18next";


export const manhourFormatter = new Intl.NumberFormat("en-HK", { export const manhourFormatter = new Intl.NumberFormat("en-HK", {
minimumFractionDigits: 2, minimumFractionDigits: 2,
@@ -69,37 +68,6 @@ export const dayjsToDateString = (date: Dayjs) => {
return date.format(OUTPUT_DATE_FORMAT); return date.format(OUTPUT_DATE_FORMAT);
}; };


export const minutesToHoursMinutes = (minutes: number): string => {
const { t } = useTranslation("common");
const defaultHrStr = "hr"
const defaultMinStr = "min"

if (minutes == 0) {
return `0 ${defaultMinStr}`
}

const hrs = Math.floor(minutes / 60)
const mins = minutes % 60

let finalHrStr: string = ""
if (hrs > 1) {
finalHrStr = `${hrs} `+ t(`${defaultHrStr}s`)
} else if (hrs == 1) {
finalHrStr = `1 `+ t(`${defaultHrStr}`)
}

let finalMinStr: string = ""
if (mins > 1) {
finalMinStr = `${mins} ` + t(`${defaultMinStr}s`)
} else if (mins == 1) {
finalMinStr = `1 ` + t(`${defaultMinStr}`)
}

const colon = finalHrStr.length > 0 && finalMinStr.length > 0 ? ":" : ""

return `${finalHrStr} ${colon} ${finalMinStr}`.trim()
}

export const stockInLineStatusMap: { [status: string]: number } = { export const stockInLineStatusMap: { [status: string]: number } = {
draft: 0, draft: 0,
pending: 1, pending: 1,


+ 1
- 1
src/components/DetailedScheduleDetail/ProdTimeColumn.tsx 查看文件

@@ -1,5 +1,5 @@
import { DetailedProdScheduleLineProdTimeResult } from "@/app/api/scheduling" import { DetailedProdScheduleLineProdTimeResult } from "@/app/api/scheduling"
import { minutesToHoursMinutes } from "@/app/utils/formatUtil";
import { minutesToHoursMinutes } from "@/app/utils/commonClientUtil";
import { Box, Divider, Grid, Typography } from "@mui/material"; import { Box, Divider, Grid, Typography } from "@mui/material";
import React, { useMemo } from "react" import React, { useMemo } from "react"
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";


+ 1
- 1
src/components/DetailedScheduleDetail/ViewByFGDetails.tsx 查看文件

@@ -14,7 +14,7 @@ import { useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Box, Grid, Tooltip, Typography } from "@mui/material"; import { Box, Grid, Tooltip, Typography } from "@mui/material";
import { GridApiCommunity } from "@mui/x-data-grid/internals"; import { GridApiCommunity } from "@mui/x-data-grid/internals";
import { decimalFormatter, integerFormatter, minutesToHoursMinutes } from "@/app/utils/formatUtil";
import { decimalFormatter, integerFormatter } from "@/app/utils/formatUtil";
import { DetailedProdScheduleLineResult, DetailedProdScheduleResult, ScheduleType } from "@/app/api/scheduling"; import { DetailedProdScheduleLineResult, DetailedProdScheduleResult, ScheduleType } from "@/app/api/scheduling";
import ProdTimeColumn from "./ProdTimeColumn"; import ProdTimeColumn from "./ProdTimeColumn";
import ScheduleTable, { Column } from "../ScheduleTable/ScheduleTable"; import ScheduleTable, { Column } from "../ScheduleTable/ScheduleTable";


正在加载...
取消
保存