|
- "use client";
-
- import { CreateItemInputs } from "@/app/api/settings/item/actions";
- import {
- GridColDef,
- GridRowModel,
- GridRenderEditCellParams,
- GridEditInputCell,
- GridRowSelectionModel,
- useGridApiRef,
- } from "@mui/x-data-grid";
- import {MutableRefObject, useCallback, useEffect, useMemo, useState} from "react";
- import { useFormContext } from "react-hook-form";
- import { useTranslation } from "react-i18next";
- import InputDataGrid, { TableRow } from "../InputDataGrid/InputDataGrid";
- import {Box, Grid, Tooltip, Typography} from "@mui/material";
- import { ItemQc } from "@/app/api/settings/item";
- import { QcChecksInputs } from "@/app/api/settings/qcCheck/actions";
- import { GridApiCommunity } from "@mui/x-data-grid/internals";
- import { RiceBowl } from "@mui/icons-material";
- import EditableSearchResults, {Column} from "@/components/SearchResults/EditableSearchResults";
- import { decimalFormatter } from "@/app/utils/formatUtil";
- import { GridRenderCellParams } from "@mui/x-data-grid";
-
- type Props = {
- apiRef: MutableRefObject<GridApiCommunity>
- };
- type EntryError =
- | {
- [field in keyof QcChecksInputs]?: string;
- }
- | undefined;
-
- export type FGRecord = {
- id: string | number
- code: string;
- name: string;
- inStockQty: number;
- purchaseQty: number;
- }
-
- export type FGOverallRecord = {
- id: string | number
- code: string;
- name: string;
- type: string;
- inStockQty: number;
- purchaseQty: number;
- purchaseQty1: number;
- purchaseQty2: number;
- purchaseQty3: number;
- purchaseQty4: number;
- purchaseQty5: number;
- purchaseQty6: number;
- purchaseQty7: number;
- overallPurchaseQty: number;
- }
-
- const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => {
- const {
- t,
- i18n: { language },
- } = useTranslation("schedule");
-
- const {
- formState: { errors, defaultValues, touchedFields },
- } = useFormContext<CreateItemInputs>();
- // const apiRef = useGridApiRef();
-
- const dayPeriod = [
- '2025-05-11',
- '2025-05-12',
- '2025-05-13',
- '2025-05-14',
- '2025-05-15',
- '2025-05-16',
- '2025-05-17',
- ];
-
- const fakeRecords = useMemo<FGRecord[][]>(
- () => [
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- ],
- []
- );
-
- const fakeOverallRecords = useMemo<FGOverallRecord[]>(
- () => [
- { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 ,
- purchaseQty1: 972.12, purchaseQty2: 972.12, purchaseQty3: 972.12,
- purchaseQty4: 972.12, purchaseQty5: 972.12, purchaseQty6: 972.12,
- purchaseQty7: 972.12, overallPurchaseQty: 6804.84
- },
- { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 ,
- purchaseQty1: 3175.2, purchaseQty2: 3175.2, purchaseQty3: 3175.2,
- purchaseQty4: 3175.2, purchaseQty5: 3175.2, purchaseQty6: 3175.2,
- purchaseQty7: 3175.2, overallPurchaseQty: 22226.4
- },
- { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 ,
- purchaseQty1: 90, purchaseQty2: 90, purchaseQty3: 90,
- purchaseQty4: 90, purchaseQty5: 90, purchaseQty6: 90,
- purchaseQty7: 90, overallPurchaseQty: 630
- },
- { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 ,
- purchaseQty1: 60.4, purchaseQty2: 60.4, purchaseQty3: 60.4,
- purchaseQty4: 60.4, purchaseQty5: 60.4, purchaseQty6: 60.4,
- purchaseQty7: 60.4, overallPurchaseQty: 422.8
- },
- { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 ,
- purchaseQty1: 66.45, purchaseQty2: 66.45, purchaseQty3: 66.45,
- purchaseQty4: 66.45, purchaseQty5: 66.45, purchaseQty6: 66.45,
- purchaseQty7: 66.45, overallPurchaseQty: 465.15
- },
- { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 ,
- purchaseQty1: 78.55, purchaseQty2: 78.55, purchaseQty3: 78.55,
- purchaseQty4: 78.55, purchaseQty5: 78.55, purchaseQty6: 78.55,
- purchaseQty7: 78.55, overallPurchaseQty: 549.85
- },
- { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
- { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
- { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
- { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
- { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
- { id: 12, code: "MH0040",type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
- { id: 13, code: "FA0161",type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
- { id: 14, code: "MG1288", type: "Material",name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
- { id: 15, code: "MG0066", type: "Material",name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
- { id: 16, code: "MH0040", type: "Material",name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
- ],
- []
- );
-
- const [pagingController, setPagingController] = useState([
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- {
- pageNum: 1,
- pageSize: 10,
- totalCount: 0,
- },
- ])
-
- const updatePagingController = (updatedObj) => {
- setPagingController((prevState) => {
- return prevState.map((item, index) => {
- if (index === updatedObj?.index){
- return {
- ...item,
- pageNum: item.pageNum,
- pageSize: item.pageSize,
- totalCount: item.totalCount,
- };
- }
- else
- return item
- });
- });
- };
-
- const overallColumns = useMemo<Column<any>[]>(
- () => [
- {
- field: "code",
- label: "code",
- type: 'read-only',
- // editable: true,
- },
- {
- field: "name",
- label: t("name"),
- type: 'read-only',
- },
- {
- field: "type",
- label: "type",
- type: 'read-only',
- // editable: true,
- },
- {
- field: "inStockQty",
- label: t("Available Qty"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.inStockQty) == "number") {
- return decimalFormatter.format(row.inStockQty)
- }
- return row.inStockQty
- }
- // editable: true,
- },
- {
- field: "overallPurchaseQty",
- label: t("Total Demand Qty"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.overallPurchaseQty) == "number") {
- return decimalFormatter.format(row.overallPurchaseQty)
- }
- return row.overallPurchaseQty
- }
- },
- {
- field: "purchaseQty1",
- label: t("Demand Qty (Day1)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty1) == "number") {
- return decimalFormatter.format(row.purchaseQty1)
- }
- return row.purchaseQty1
- }
- },
- {
- field: "purchaseQty2",
- label: t("Demand Qty (Day2)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty2) == "number") {
- return decimalFormatter.format(row.purchaseQty2)
- }
- return row.purchaseQty2
- }
- },
- {
- field: "purchaseQty3",
- label: t("Demand Qty (Day3)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty3) == "number") {
- return decimalFormatter.format(row.purchaseQty3)
- }
- return row.purchaseQty3
- }
- },
- {
- field: "purchaseQty4",
- label: t("Demand Qty (Day4)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty4) == "number") {
- return decimalFormatter.format(row.purchaseQty4)
- }
- return row.purchaseQty4
- }
- },{
- field: "purchaseQty5",
- label: t("Demand Qty (Day5)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty5) == "number") {
- return decimalFormatter.format(row.purchaseQty5)
- }
- return row.purchaseQty5
- }
- },
- {
- field: "purchaseQty6",
- label: t("Demand Qty (Day6)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty6) == "number") {
- return decimalFormatter.format(row.purchaseQty6)
- }
- return row.purchaseQty6
- }
- },
- {
- field: "purchaseQty7",
- label: t("Demand Qty (Day7)"),
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGOverallRecord) => {
- if (typeof(row.purchaseQty7) == "number") {
- return decimalFormatter.format(row.purchaseQty7)
- }
- return row.purchaseQty7
- }
- },
- ],
- []
- );
-
- const columns = useMemo<Column<any>[]>(
- () => [
- {
- field: "code",
- label: "code",
- type: 'read-only',
- // editable: true,
- },
- {
- field: "name",
- label: "name",
- type: 'read-only',
- },
- {
- field: "type",
- label: "type",
- type: 'read-only',
- },
- {
- field: "inStockQty",
- label: "Available Qty",
- type: 'read-only',
- // editable: true,
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGRecord) => {
- if (typeof(row.inStockQty) == "number") {
- return decimalFormatter.format(row.inStockQty)
- }
- return row.inStockQty
- }
- },
- {
- field: "purchaseQty",
- label: "Demand Qty",
- type: 'read-only',
- style: {
- textAlign: "right",
- },
- renderCell: (row: FGRecord) => {
- if (typeof(row.purchaseQty) == "number") {
- return decimalFormatter.format(row.purchaseQty)
- }
- return row.purchaseQty
- }
- },
- ],
- []
- );
-
- return (
- <Grid container spacing={2}>
- <Grid item xs={12} key={"all"}>
- <Typography variant="overline" display="block" marginBlockEnd={1}>
- {t("Material Demand List (7 Days)")}
- </Typography>
- <EditableSearchResults<FGRecord>
- index={7}
- items={fakeOverallRecords}
- isMockUp={true}
- columns={overallColumns}
- setPagingController={updatePagingController}
- pagingController={pagingController[7]}
- isAutoPaging={true}
- isEditable={false}
- isEdit={false}
- />
- </Grid>
- {dayPeriod.map((date, index) => (
- <Grid item xs={12} key={index}>
- <Typography variant="overline" display="block" marginBlockEnd={1}>
- {`${t("Material Demand Date")}: ${date}`}
- </Typography>
- <EditableSearchResults<FGRecord>
- index={index}
- items={fakeRecords[index]} // Use the corresponding records for the day
- columns={columns}
- setPagingController={updatePagingController}
- pagingController={pagingController[index]}
- isAutoPaging={true}
- isEditable={false}
- isEdit={isEdit}
- />
- </Grid>
- ))}
- </Grid>
- );
- };
- export default ViewByBomDetails;
|