FPSMS-frontend
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

557 líneas
30 KiB

  1. "use client";
  2. import { CreateItemInputs } from "@/app/api/settings/item/actions";
  3. import {
  4. GridColDef,
  5. GridRowModel,
  6. GridRenderEditCellParams,
  7. GridEditInputCell,
  8. GridRowSelectionModel,
  9. useGridApiRef,
  10. } from "@mui/x-data-grid";
  11. import {MutableRefObject, useCallback, useEffect, useMemo, useState} from "react";
  12. import { useFormContext } from "react-hook-form";
  13. import { useTranslation } from "react-i18next";
  14. import InputDataGrid, { TableRow } from "../InputDataGrid/InputDataGrid";
  15. import {Box, Grid, Tooltip, Typography} from "@mui/material";
  16. import { ItemQc } from "@/app/api/settings/item";
  17. import { QcChecksInputs } from "@/app/api/settings/qcCheck/actions";
  18. import { GridApiCommunity } from "@mui/x-data-grid/internals";
  19. import { RiceBowl } from "@mui/icons-material";
  20. import EditableSearchResults, {Column} from "@/components/SearchResults/EditableSearchResults";
  21. import { decimalFormatter } from "@/app/utils/formatUtil";
  22. import { GridRenderCellParams } from "@mui/x-data-grid";
  23. type Props = {
  24. apiRef: MutableRefObject<GridApiCommunity>
  25. };
  26. type EntryError =
  27. | {
  28. [field in keyof QcChecksInputs]?: string;
  29. }
  30. | undefined;
  31. export type FGRecord = {
  32. id: string | number
  33. code: string;
  34. name: string;
  35. inStockQty: number;
  36. purchaseQty: number;
  37. }
  38. export type FGOverallRecord = {
  39. id: string | number
  40. code: string;
  41. name: string;
  42. type: string;
  43. inStockQty: number;
  44. purchaseQty: number;
  45. purchaseQty1: number;
  46. purchaseQty2: number;
  47. purchaseQty3: number;
  48. purchaseQty4: number;
  49. purchaseQty5: number;
  50. purchaseQty6: number;
  51. purchaseQty7: number;
  52. overallPurchaseQty: number;
  53. }
  54. const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => {
  55. const {
  56. t,
  57. i18n: { language },
  58. } = useTranslation("schedule");
  59. const {
  60. formState: { errors, defaultValues, touchedFields },
  61. } = useFormContext<CreateItemInputs>();
  62. // const apiRef = useGridApiRef();
  63. const dayPeriod = [
  64. '2025-05-11',
  65. '2025-05-12',
  66. '2025-05-13',
  67. '2025-05-14',
  68. '2025-05-15',
  69. '2025-05-16',
  70. '2025-05-17',
  71. ];
  72. const fakeRecords = useMemo<FGRecord[][]>(
  73. () => [
  74. [
  75. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  76. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  77. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  78. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  79. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  80. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  81. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  82. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  83. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  84. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  85. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  86. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  87. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  88. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  89. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  90. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  91. ],
  92. [
  93. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  94. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  95. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  96. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  97. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  98. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  99. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  100. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  101. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  102. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  103. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  104. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  105. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  106. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  107. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  108. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  109. ],
  110. [
  111. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  112. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  113. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  114. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  115. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  116. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  117. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  118. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  119. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  120. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  121. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  122. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  123. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  124. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  125. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  126. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  127. ],
  128. [
  129. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  130. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  131. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  132. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  133. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  134. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  135. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  136. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  137. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  138. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  139. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  140. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  141. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  142. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  143. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  144. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  145. ],
  146. [
  147. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  148. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  149. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  150. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  151. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  152. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  153. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  154. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  155. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  156. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  157. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  158. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  159. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  160. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  161. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  162. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  163. ],
  164. [
  165. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  166. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  167. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  168. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  169. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  170. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  171. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  172. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  173. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  174. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  175. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  176. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  177. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  178. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  179. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  180. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  181. ],
  182. [
  183. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 , purchaseQty: 972.12 },
  184. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 , purchaseQty: 3175.2 },
  185. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 , purchaseQty: 90 },
  186. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 , purchaseQty: 60.4 },
  187. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 , purchaseQty: 66.45 },
  188. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 , purchaseQty: 78.55 },
  189. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  190. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  191. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  192. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  193. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  194. { id: 12, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  195. { id: 13, code: "FA0161", type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  196. { id: 14, code: "MG1288", type: "Material", name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  197. { id: 15, code: "MG0066", type: "Material", name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  198. { id: 16, code: "MH0040", type: "Material", name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  199. ],
  200. ],
  201. []
  202. );
  203. const fakeOverallRecords = useMemo<FGOverallRecord[]>(
  204. () => [
  205. { id: 1, code: "MH0040", type: "Material", name: "大豆油(1噸/桶)", inStockQty: 54.44 ,
  206. purchaseQty1: 972.12, purchaseQty2: 972.12, purchaseQty3: 972.12,
  207. purchaseQty4: 972.12, purchaseQty5: 972.12, purchaseQty6: 972.12,
  208. purchaseQty7: 972.12, overallPurchaseQty: 6804.84
  209. },
  210. { id: 2, code: "GI3236", type: "Material", name: "清水(煮過牛腩)", inStockQty: 317.52 ,
  211. purchaseQty1: 3175.2, purchaseQty2: 3175.2, purchaseQty3: 3175.2,
  212. purchaseQty4: 3175.2, purchaseQty5: 3175.2, purchaseQty6: 3175.2,
  213. purchaseQty7: 3175.2, overallPurchaseQty: 22226.4
  214. },
  215. { id: 3, code: "MG1700", type: "Material", name: "STERILTOM 意大利茄粒", inStockQty: 9.00 ,
  216. purchaseQty1: 90, purchaseQty2: 90, purchaseQty3: 90,
  217. purchaseQty4: 90, purchaseQty5: 90, purchaseQty6: 90,
  218. purchaseQty7: 90, overallPurchaseQty: 630
  219. },
  220. { id: 4, code: "FA0533", type: "Material", name: "乾蔥茸", inStockQty: 6.04 ,
  221. purchaseQty1: 60.4, purchaseQty2: 60.4, purchaseQty3: 60.4,
  222. purchaseQty4: 60.4, purchaseQty5: 60.4, purchaseQty6: 60.4,
  223. purchaseQty7: 60.4, overallPurchaseQty: 422.8
  224. },
  225. { id: 5, code: "FA0210", type: "Material", name: "薑茸", inStockQty: 6.04 ,
  226. purchaseQty1: 66.45, purchaseQty2: 66.45, purchaseQty3: 66.45,
  227. purchaseQty4: 66.45, purchaseQty5: 66.45, purchaseQty6: 66.45,
  228. purchaseQty7: 66.45, overallPurchaseQty: 465.15
  229. },
  230. { id: 6, code: "FA0608", type: "Material", name: "粗蒜茸", inStockQty: 6.04 ,
  231. purchaseQty1: 78.55, purchaseQty2: 78.55, purchaseQty3: 78.55,
  232. purchaseQty4: 78.55, purchaseQty5: 78.55, purchaseQty6: 78.55,
  233. purchaseQty7: 78.55, overallPurchaseQty: 549.85
  234. },
  235. { id: 7, code: "FA0056", type: "Material", name: "洋蔥肉", inStockQty: 241.98 , purchaseQty: 2419.8 },
  236. { id: 8, code: "PP1188", type: "Material", name: "咖喱膽", inStockQty: 36.00 , purchaseQty: 0 },
  237. { id: 9, code: "PP8001", type: "Material", name: "咖哩汁箱料粉", inStockQty: 77.42 , purchaseQty: 774.2 },
  238. { id: 10, code: "PP1096", type: "Material", name: "白麵撈", inStockQty: 60.00 , purchaseQty: 0 },
  239. { id: 11, code: "NA0476", type: "Material", name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計", inStockQty: 600.00 , purchaseQty: 6000 },
  240. { id: 12, code: "MH0040",type: "Material", name: "大豆油(1噸/桶)", inStockQty: 0, purchaseQty: 972.12 },
  241. { id: 13, code: "FA0161",type: "Material", name: "洋蔥粒", inStockQty: 0, purchaseQty: 28.15 },
  242. { id: 14, code: "MG1288", type: "Material",name: "炸紅蔥頭", inStockQty: 0, purchaseQty: 6.05 },
  243. { id: 15, code: "MG0066", type: "Material",name: "咖哩料(5斤x16包+2斤/包)", inStockQty: 0, purchaseQty: 241.98 },
  244. { id: 16, code: "MH0040", type: "Material",name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)", inStockQty: 0, purchaseQty: 250.00 },
  245. ],
  246. []
  247. );
  248. const [pagingController, setPagingController] = useState([
  249. {
  250. pageNum: 1,
  251. pageSize: 10,
  252. totalCount: 0,
  253. },
  254. {
  255. pageNum: 1,
  256. pageSize: 10,
  257. totalCount: 0,
  258. },
  259. {
  260. pageNum: 1,
  261. pageSize: 10,
  262. totalCount: 0,
  263. },
  264. {
  265. pageNum: 1,
  266. pageSize: 10,
  267. totalCount: 0,
  268. },
  269. {
  270. pageNum: 1,
  271. pageSize: 10,
  272. totalCount: 0,
  273. },
  274. {
  275. pageNum: 1,
  276. pageSize: 10,
  277. totalCount: 0,
  278. },
  279. {
  280. pageNum: 1,
  281. pageSize: 10,
  282. totalCount: 0,
  283. },
  284. {
  285. pageNum: 1,
  286. pageSize: 10,
  287. totalCount: 0,
  288. },
  289. ])
  290. const updatePagingController = (updatedObj) => {
  291. setPagingController((prevState) => {
  292. return prevState.map((item, index) => {
  293. if (index === updatedObj?.index){
  294. return {
  295. ...item,
  296. pageNum: item.pageNum,
  297. pageSize: item.pageSize,
  298. totalCount: item.totalCount,
  299. };
  300. }
  301. else
  302. return item
  303. });
  304. });
  305. };
  306. const overallColumns = useMemo<Column<any>[]>(
  307. () => [
  308. {
  309. field: "code",
  310. label: "code",
  311. type: 'read-only',
  312. // editable: true,
  313. },
  314. {
  315. field: "name",
  316. label: t("name"),
  317. type: 'read-only',
  318. },
  319. {
  320. field: "type",
  321. label: "type",
  322. type: 'read-only',
  323. // editable: true,
  324. },
  325. {
  326. field: "inStockQty",
  327. label: t("Available Qty"),
  328. type: 'read-only',
  329. style: {
  330. textAlign: "right",
  331. },
  332. renderCell: (row: FGOverallRecord) => {
  333. if (typeof(row.inStockQty) == "number") {
  334. return decimalFormatter.format(row.inStockQty)
  335. }
  336. return row.inStockQty
  337. }
  338. // editable: true,
  339. },
  340. {
  341. field: "overallPurchaseQty",
  342. label: t("Total Demand Qty"),
  343. type: 'read-only',
  344. style: {
  345. textAlign: "right",
  346. },
  347. renderCell: (row: FGOverallRecord) => {
  348. if (typeof(row.overallPurchaseQty) == "number") {
  349. return decimalFormatter.format(row.overallPurchaseQty)
  350. }
  351. return row.overallPurchaseQty
  352. }
  353. },
  354. {
  355. field: "purchaseQty1",
  356. label: t("Demand Qty (Day1)"),
  357. type: 'read-only',
  358. style: {
  359. textAlign: "right",
  360. },
  361. renderCell: (row: FGOverallRecord) => {
  362. if (typeof(row.purchaseQty1) == "number") {
  363. return decimalFormatter.format(row.purchaseQty1)
  364. }
  365. return row.purchaseQty1
  366. }
  367. },
  368. {
  369. field: "purchaseQty2",
  370. label: t("Demand Qty (Day2)"),
  371. type: 'read-only',
  372. style: {
  373. textAlign: "right",
  374. },
  375. renderCell: (row: FGOverallRecord) => {
  376. if (typeof(row.purchaseQty2) == "number") {
  377. return decimalFormatter.format(row.purchaseQty2)
  378. }
  379. return row.purchaseQty2
  380. }
  381. },
  382. {
  383. field: "purchaseQty3",
  384. label: t("Demand Qty (Day3)"),
  385. type: 'read-only',
  386. style: {
  387. textAlign: "right",
  388. },
  389. renderCell: (row: FGOverallRecord) => {
  390. if (typeof(row.purchaseQty3) == "number") {
  391. return decimalFormatter.format(row.purchaseQty3)
  392. }
  393. return row.purchaseQty3
  394. }
  395. },
  396. {
  397. field: "purchaseQty4",
  398. label: t("Demand Qty (Day4)"),
  399. type: 'read-only',
  400. style: {
  401. textAlign: "right",
  402. },
  403. renderCell: (row: FGOverallRecord) => {
  404. if (typeof(row.purchaseQty4) == "number") {
  405. return decimalFormatter.format(row.purchaseQty4)
  406. }
  407. return row.purchaseQty4
  408. }
  409. },{
  410. field: "purchaseQty5",
  411. label: t("Demand Qty (Day5)"),
  412. type: 'read-only',
  413. style: {
  414. textAlign: "right",
  415. },
  416. renderCell: (row: FGOverallRecord) => {
  417. if (typeof(row.purchaseQty5) == "number") {
  418. return decimalFormatter.format(row.purchaseQty5)
  419. }
  420. return row.purchaseQty5
  421. }
  422. },
  423. {
  424. field: "purchaseQty6",
  425. label: t("Demand Qty (Day6)"),
  426. type: 'read-only',
  427. style: {
  428. textAlign: "right",
  429. },
  430. renderCell: (row: FGOverallRecord) => {
  431. if (typeof(row.purchaseQty6) == "number") {
  432. return decimalFormatter.format(row.purchaseQty6)
  433. }
  434. return row.purchaseQty6
  435. }
  436. },
  437. {
  438. field: "purchaseQty7",
  439. label: t("Demand Qty (Day7)"),
  440. type: 'read-only',
  441. style: {
  442. textAlign: "right",
  443. },
  444. renderCell: (row: FGOverallRecord) => {
  445. if (typeof(row.purchaseQty7) == "number") {
  446. return decimalFormatter.format(row.purchaseQty7)
  447. }
  448. return row.purchaseQty7
  449. }
  450. },
  451. ],
  452. []
  453. );
  454. const columns = useMemo<Column<any>[]>(
  455. () => [
  456. {
  457. field: "code",
  458. label: "code",
  459. type: 'read-only',
  460. // editable: true,
  461. },
  462. {
  463. field: "name",
  464. label: "name",
  465. type: 'read-only',
  466. },
  467. {
  468. field: "type",
  469. label: "type",
  470. type: 'read-only',
  471. },
  472. {
  473. field: "inStockQty",
  474. label: "Available Qty",
  475. type: 'read-only',
  476. // editable: true,
  477. style: {
  478. textAlign: "right",
  479. },
  480. renderCell: (row: FGRecord) => {
  481. if (typeof(row.inStockQty) == "number") {
  482. return decimalFormatter.format(row.inStockQty)
  483. }
  484. return row.inStockQty
  485. }
  486. },
  487. {
  488. field: "purchaseQty",
  489. label: "Demand Qty",
  490. type: 'read-only',
  491. style: {
  492. textAlign: "right",
  493. },
  494. renderCell: (row: FGRecord) => {
  495. if (typeof(row.purchaseQty) == "number") {
  496. return decimalFormatter.format(row.purchaseQty)
  497. }
  498. return row.purchaseQty
  499. }
  500. },
  501. ],
  502. []
  503. );
  504. return (
  505. <Grid container spacing={2}>
  506. <Grid item xs={12} key={"all"}>
  507. <Typography variant="overline" display="block" marginBlockEnd={1}>
  508. {t("Material Demand List (7 Days)")}
  509. </Typography>
  510. <EditableSearchResults<FGRecord>
  511. index={7}
  512. items={fakeOverallRecords}
  513. isMockUp={true}
  514. columns={overallColumns}
  515. setPagingController={updatePagingController}
  516. pagingController={pagingController[7]}
  517. isAutoPaging={true}
  518. isEditable={false}
  519. isEdit={false}
  520. />
  521. </Grid>
  522. {dayPeriod.map((date, index) => (
  523. <Grid item xs={12} key={index}>
  524. <Typography variant="overline" display="block" marginBlockEnd={1}>
  525. {`${t("Material Demand Date")}: ${date}`}
  526. </Typography>
  527. <EditableSearchResults<FGRecord>
  528. index={index}
  529. items={fakeRecords[index]} // Use the corresponding records for the day
  530. columns={columns}
  531. setPagingController={updatePagingController}
  532. pagingController={pagingController[index]}
  533. isAutoPaging={true}
  534. isEditable={false}
  535. isEdit={isEdit}
  536. />
  537. </Grid>
  538. ))}
  539. </Grid>
  540. );
  541. };
  542. export default ViewByBomDetails;