FPSMS-frontend
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

82 行
3.3 KiB

  1. import { Card, CardContent, Stack, Typography } from "@mui/material";
  2. import dayjs from "dayjs";
  3. import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil";
  4. import { useTranslation } from "react-i18next";
  5. import { ProductProcessWithLinesResponse } from "@/app/api/jo/actions";
  6. interface Props {
  7. processData?: ProductProcessWithLinesResponse | null;
  8. }
  9. const ProcessSummaryHeader: React.FC<Props> = ({ processData }) => {
  10. const { t } = useTranslation(["common", "jo"]);
  11. // 计算 Assume Time Need:从所有 productProcessLines 的 durationInMinutes 求和
  12. const assumeTimeNeed = processData?.productProcessLines?.reduce(
  13. (sum, line) => sum + (line.durationInMinutes || 0),
  14. 0
  15. ) || 0;
  16. // Start Time:使用 processData.startTime
  17. const startTime = processData?.startTime;
  18. // Assume End Time:Start Time + Assume Time Need(分钟)
  19. const assumeEndTime = startTime
  20. ? dayjs(startTime).add(assumeTimeNeed, 'minute')
  21. : null;
  22. return (
  23. <Card sx={{ mb: 2 }}>
  24. <CardContent>
  25. <Stack direction="row" alignItems="center" justifyContent="space-between" spacing={2}>
  26. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  27. {t("Job Order Code")}: <strong>{processData?.jobOrderCode}</strong>
  28. </Typography>
  29. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  30. {t("Item")}: <strong>{processData?.itemCode+"-"+processData?.itemName}</strong>
  31. </Typography>
  32. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  33. {t("Job Type")}: <strong style={{ color: "green" }}>{t(processData?.jobType ?? "")}</strong>
  34. </Typography>
  35. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  36. {t("Qty")}: <strong style={{ color: "green" }}>{processData?.outputQty}</strong> ({processData?.outputQtyUom ?? ""})
  37. </Typography>
  38. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  39. {t("Production Date")}: <strong style={{ color: "green" }}>{processData?.date ? dayjs(processData.date).format(OUTPUT_DATE_FORMAT) : ""}</strong>
  40. </Typography>
  41. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  42. {t("Assume Time Need")}: <strong style={{ color: "blue" }}>{assumeTimeNeed} {t("minutes")}</strong>
  43. </Typography>
  44. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  45. {t("Start Time")}: <strong>
  46. {startTime
  47. ? (
  48. <>
  49. <span style={{ color: "green" }}>{dayjs(startTime).format("MM-DD")}</span>
  50. {" "}
  51. <span style={{ color: "blue" }}>{dayjs(startTime).format("HH:mm")}</span>
  52. </>
  53. )
  54. : "-"}
  55. </strong>
  56. </Typography>
  57. <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
  58. {t("Assume End Time")}: <strong>
  59. {assumeEndTime ? (
  60. <>
  61. <span style={{ color: "green" }}>{assumeEndTime.format("MM-DD")}</span>
  62. {" "}
  63. <span style={{ color: "blue" }}>{assumeEndTime.format("HH:mm")}</span>
  64. </>
  65. ) : "-"}
  66. </strong>
  67. </Typography>
  68. </Stack>
  69. </CardContent>
  70. </Card>
  71. );
  72. };
  73. export default ProcessSummaryHeader;