| @@ -31,8 +31,8 @@ import { decimalFormatter } from "@/app/utils/formatUtil"; | |||||
| import { GridRenderCellParams } from "@mui/x-data-grid"; | import { GridRenderCellParams } from "@mui/x-data-grid"; | ||||
| type Props = { | type Props = { | ||||
| apiRef: MutableRefObject<GridApiCommunity> | |||||
| isEdit: boolean | |||||
| apiRef: MutableRefObject<GridApiCommunity>; | |||||
| isEdit: boolean; | |||||
| }; | }; | ||||
| type EntryError = | type EntryError = | ||||
| | { | | { | ||||
| @@ -53,16 +53,16 @@ export type FGOverallRecord = { | |||||
| code: string; | code: string; | ||||
| name: string; | name: string; | ||||
| type: string; | type: string; | ||||
| inStockQty: number; | |||||
| purchaseQty: number; | |||||
| purchaseQty1: number; | |||||
| purchaseQty2: number; | |||||
| purchaseQty3: number; | |||||
| purchaseQty4: number; | |||||
| purchaseQty5: number; | |||||
| purchaseQty6: number; | |||||
| purchaseQty7: number; | |||||
| overallPurchaseQty: number; | |||||
| 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 ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => { | ||||
| @@ -1002,22 +1002,197 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => { | |||||
| [], | [], | ||||
| ); | ); | ||||
| const updatePagingController = (updatedObj: { index: number, pageNum: number, pageSize: number, totalCount: number }) => { | |||||
| 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 updatePagingController = (updatedObj: { index: number, pageNum: number, pageSize: number, totalCount: number }) => { | |||||
| // 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 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.0, | |||||
| 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.0, | |||||
| purchaseQty: 0, | |||||
| }, | |||||
| { | |||||
| id: 9, | |||||
| code: "PP8001", | |||||
| type: "Material", | |||||
| name: "咖哩汁箱料粉", | |||||
| inStockQty: 77.42, | |||||
| purchaseQty: 774.2, | |||||
| }, | |||||
| { | |||||
| id: 10, | |||||
| code: "PP1096", | |||||
| type: "Material", | |||||
| name: "白麵撈", | |||||
| inStockQty: 60.0, | |||||
| purchaseQty: 0, | |||||
| }, | |||||
| { | |||||
| id: 11, | |||||
| code: "NA0476", | |||||
| type: "Material", | |||||
| name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", | |||||
| inStockQty: 600.0, | |||||
| 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.0, | |||||
| }, | |||||
| ], | |||||
| [], | |||||
| ); | |||||
| const [pagingController, setPagingController] = useState([ | const [pagingController, setPagingController] = useState([ | ||||
| { | { | ||||
| @@ -1062,7 +1237,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => { | |||||
| }, | }, | ||||
| ]); | ]); | ||||
| const updatePagingController = (updatedObj) => { | |||||
| const updatePagingController = (updatedObj: any) => { | |||||
| setPagingController((prevState) => { | setPagingController((prevState) => { | ||||
| return prevState.map((item, index) => { | return prevState.map((item, index) => { | ||||
| if (index === updatedObj?.index) { | if (index === updatedObj?.index) { | ||||
| @@ -1286,8 +1461,9 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => { | |||||
| </Typography> | </Typography> | ||||
| <EditableSearchResults<FGRecord> | <EditableSearchResults<FGRecord> | ||||
| index={7} | index={7} | ||||
| items={fakeOverallRecords} | |||||
| isMockUp={true} | |||||
| items={fakeOverallRecords as FGRecord[]} | |||||
| hasCollapse | |||||
| // isMockUp={true} | |||||
| columns={overallColumns} | columns={overallColumns} | ||||
| setPagingController={updatePagingController} | setPagingController={updatePagingController} | ||||
| pagingController={pagingController[7]} | pagingController={pagingController[7]} | ||||
| @@ -1302,6 +1478,7 @@ const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => { | |||||
| {`${t("Material Demand Date")}: ${date}`} | {`${t("Material Demand Date")}: ${date}`} | ||||
| </Typography> | </Typography> | ||||
| <EditableSearchResults<FGRecord> | <EditableSearchResults<FGRecord> | ||||
| hasCollapse | |||||
| index={index} | index={index} | ||||
| items={fakeRecords[index]} // Use the corresponding records for the day | items={fakeRecords[index]} // Use the corresponding records for the day | ||||
| columns={columns} | columns={columns} | ||||