FPSMS-frontend
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

1497 satır
35 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 {
  12. MutableRefObject,
  13. useCallback,
  14. useEffect,
  15. useMemo,
  16. useState,
  17. } from "react";
  18. import { useFormContext } from "react-hook-form";
  19. import { useTranslation } from "react-i18next";
  20. import InputDataGrid, { TableRow } from "../InputDataGrid/InputDataGrid";
  21. import { Box, Grid, Tooltip, Typography } from "@mui/material";
  22. import { ItemQc } from "@/app/api/settings/item";
  23. import { QcChecksInputs } from "@/app/api/settings/qcCheck/actions";
  24. import { GridApiCommunity } from "@mui/x-data-grid/internals";
  25. import { RiceBowl } from "@mui/icons-material";
  26. import EditableSearchResults, {
  27. Column,
  28. } from "@/components/SearchResults/EditableSearchResults";
  29. import { decimalFormatter } from "@/app/utils/formatUtil";
  30. import { GridRenderCellParams } from "@mui/x-data-grid";
  31. type Props = {
  32. apiRef: MutableRefObject<GridApiCommunity>;
  33. isEdit: boolean;
  34. };
  35. type EntryError =
  36. | {
  37. [field in keyof QcChecksInputs]?: string;
  38. }
  39. | undefined;
  40. export type FGRecord = {
  41. id: string | number;
  42. code: string;
  43. name: string;
  44. inStockQty: number;
  45. purchaseQty: number;
  46. };
  47. export type FGOverallRecord = {
  48. id: string | number;
  49. code: string;
  50. name: string;
  51. type: string;
  52. inStockQty?: number;
  53. purchaseQty?: number;
  54. purchaseQty1?: number;
  55. purchaseQty2?: number;
  56. purchaseQty3?: number;
  57. purchaseQty4?: number;
  58. purchaseQty5?: number;
  59. purchaseQty6?: number;
  60. purchaseQty7?: number;
  61. overallPurchaseQty?: number;
  62. };
  63. const ViewByBomDetails: React.FC<Props> = ({ apiRef, isEdit }) => {
  64. const {
  65. t,
  66. i18n: { language },
  67. } = useTranslation("schedule");
  68. const {
  69. formState: { errors, defaultValues, touchedFields },
  70. } = useFormContext<CreateItemInputs>();
  71. // const apiRef = useGridApiRef();
  72. const dayPeriod = [
  73. "2025-05-11",
  74. "2025-05-12",
  75. "2025-05-13",
  76. "2025-05-14",
  77. "2025-05-15",
  78. "2025-05-16",
  79. "2025-05-17",
  80. ];
  81. const fakeRecords = useMemo<FGRecord[][]>(
  82. () => [
  83. [
  84. {
  85. id: 1,
  86. code: "MH0040",
  87. type: "Material",
  88. name: "大豆油(1噸/桶)",
  89. inStockQty: 54.44,
  90. purchaseQty: 972.12,
  91. },
  92. {
  93. id: 2,
  94. code: "GI3236",
  95. type: "Material",
  96. name: "清水(煮過牛腩)",
  97. inStockQty: 317.52,
  98. purchaseQty: 3175.2,
  99. },
  100. {
  101. id: 3,
  102. code: "MG1700",
  103. type: "Material",
  104. name: "STERILTOM 意大利茄粒",
  105. inStockQty: 9.0,
  106. purchaseQty: 90,
  107. },
  108. {
  109. id: 4,
  110. code: "FA0533",
  111. type: "Material",
  112. name: "乾蔥茸",
  113. inStockQty: 6.04,
  114. purchaseQty: 60.4,
  115. },
  116. {
  117. id: 5,
  118. code: "FA0210",
  119. type: "Material",
  120. name: "薑茸",
  121. inStockQty: 6.04,
  122. purchaseQty: 66.45,
  123. },
  124. {
  125. id: 6,
  126. code: "FA0608",
  127. type: "Material",
  128. name: "粗蒜茸",
  129. inStockQty: 6.04,
  130. purchaseQty: 78.55,
  131. },
  132. {
  133. id: 7,
  134. code: "FA0056",
  135. type: "Material",
  136. name: "洋蔥肉",
  137. inStockQty: 241.98,
  138. purchaseQty: 2419.8,
  139. },
  140. {
  141. id: 8,
  142. code: "PP1188",
  143. type: "Material",
  144. name: "咖喱膽",
  145. inStockQty: 36.0,
  146. purchaseQty: 0,
  147. },
  148. {
  149. id: 9,
  150. code: "PP8001",
  151. type: "Material",
  152. name: "咖哩汁箱料粉",
  153. inStockQty: 77.42,
  154. purchaseQty: 774.2,
  155. },
  156. {
  157. id: 10,
  158. code: "PP1096",
  159. type: "Material",
  160. name: "白麵撈",
  161. inStockQty: 60.0,
  162. purchaseQty: 0,
  163. },
  164. {
  165. id: 11,
  166. code: "NA0476",
  167. type: "Material",
  168. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  169. inStockQty: 600.0,
  170. purchaseQty: 6000,
  171. },
  172. {
  173. id: 12,
  174. code: "MH0040",
  175. type: "Material",
  176. name: "大豆油(1噸/桶)",
  177. inStockQty: 0,
  178. purchaseQty: 972.12,
  179. },
  180. {
  181. id: 13,
  182. code: "FA0161",
  183. type: "Material",
  184. name: "洋蔥粒",
  185. inStockQty: 0,
  186. purchaseQty: 28.15,
  187. },
  188. {
  189. id: 14,
  190. code: "MG1288",
  191. type: "Material",
  192. name: "炸紅蔥頭",
  193. inStockQty: 0,
  194. purchaseQty: 6.05,
  195. },
  196. {
  197. id: 15,
  198. code: "MG0066",
  199. type: "Material",
  200. name: "咖哩料(5斤x16包+2斤/包)",
  201. inStockQty: 0,
  202. purchaseQty: 241.98,
  203. },
  204. {
  205. id: 16,
  206. code: "MH0040",
  207. type: "Material",
  208. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  209. inStockQty: 0,
  210. purchaseQty: 250.0,
  211. },
  212. ],
  213. [
  214. {
  215. id: 1,
  216. code: "MH0040",
  217. type: "Material",
  218. name: "大豆油(1噸/桶)",
  219. inStockQty: 54.44,
  220. purchaseQty: 972.12,
  221. },
  222. {
  223. id: 2,
  224. code: "GI3236",
  225. type: "Material",
  226. name: "清水(煮過牛腩)",
  227. inStockQty: 317.52,
  228. purchaseQty: 3175.2,
  229. },
  230. {
  231. id: 3,
  232. code: "MG1700",
  233. type: "Material",
  234. name: "STERILTOM 意大利茄粒",
  235. inStockQty: 9.0,
  236. purchaseQty: 90,
  237. },
  238. {
  239. id: 4,
  240. code: "FA0533",
  241. type: "Material",
  242. name: "乾蔥茸",
  243. inStockQty: 6.04,
  244. purchaseQty: 60.4,
  245. },
  246. {
  247. id: 5,
  248. code: "FA0210",
  249. type: "Material",
  250. name: "薑茸",
  251. inStockQty: 6.04,
  252. purchaseQty: 66.45,
  253. },
  254. {
  255. id: 6,
  256. code: "FA0608",
  257. type: "Material",
  258. name: "粗蒜茸",
  259. inStockQty: 6.04,
  260. purchaseQty: 78.55,
  261. },
  262. {
  263. id: 7,
  264. code: "FA0056",
  265. type: "Material",
  266. name: "洋蔥肉",
  267. inStockQty: 241.98,
  268. purchaseQty: 2419.8,
  269. },
  270. {
  271. id: 8,
  272. code: "PP1188",
  273. type: "Material",
  274. name: "咖喱膽",
  275. inStockQty: 36.0,
  276. purchaseQty: 0,
  277. },
  278. {
  279. id: 9,
  280. code: "PP8001",
  281. type: "Material",
  282. name: "咖哩汁箱料粉",
  283. inStockQty: 77.42,
  284. purchaseQty: 774.2,
  285. },
  286. {
  287. id: 10,
  288. code: "PP1096",
  289. type: "Material",
  290. name: "白麵撈",
  291. inStockQty: 60.0,
  292. purchaseQty: 0,
  293. },
  294. {
  295. id: 11,
  296. code: "NA0476",
  297. type: "Material",
  298. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  299. inStockQty: 600.0,
  300. purchaseQty: 6000,
  301. },
  302. {
  303. id: 12,
  304. code: "MH0040",
  305. type: "Material",
  306. name: "大豆油(1噸/桶)",
  307. inStockQty: 0,
  308. purchaseQty: 972.12,
  309. },
  310. {
  311. id: 13,
  312. code: "FA0161",
  313. type: "Material",
  314. name: "洋蔥粒",
  315. inStockQty: 0,
  316. purchaseQty: 28.15,
  317. },
  318. {
  319. id: 14,
  320. code: "MG1288",
  321. type: "Material",
  322. name: "炸紅蔥頭",
  323. inStockQty: 0,
  324. purchaseQty: 6.05,
  325. },
  326. {
  327. id: 15,
  328. code: "MG0066",
  329. type: "Material",
  330. name: "咖哩料(5斤x16包+2斤/包)",
  331. inStockQty: 0,
  332. purchaseQty: 241.98,
  333. },
  334. {
  335. id: 16,
  336. code: "MH0040",
  337. type: "Material",
  338. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  339. inStockQty: 0,
  340. purchaseQty: 250.0,
  341. },
  342. ],
  343. [
  344. {
  345. id: 1,
  346. code: "MH0040",
  347. type: "Material",
  348. name: "大豆油(1噸/桶)",
  349. inStockQty: 54.44,
  350. purchaseQty: 972.12,
  351. },
  352. {
  353. id: 2,
  354. code: "GI3236",
  355. type: "Material",
  356. name: "清水(煮過牛腩)",
  357. inStockQty: 317.52,
  358. purchaseQty: 3175.2,
  359. },
  360. {
  361. id: 3,
  362. code: "MG1700",
  363. type: "Material",
  364. name: "STERILTOM 意大利茄粒",
  365. inStockQty: 9.0,
  366. purchaseQty: 90,
  367. },
  368. {
  369. id: 4,
  370. code: "FA0533",
  371. type: "Material",
  372. name: "乾蔥茸",
  373. inStockQty: 6.04,
  374. purchaseQty: 60.4,
  375. },
  376. {
  377. id: 5,
  378. code: "FA0210",
  379. type: "Material",
  380. name: "薑茸",
  381. inStockQty: 6.04,
  382. purchaseQty: 66.45,
  383. },
  384. {
  385. id: 6,
  386. code: "FA0608",
  387. type: "Material",
  388. name: "粗蒜茸",
  389. inStockQty: 6.04,
  390. purchaseQty: 78.55,
  391. },
  392. {
  393. id: 7,
  394. code: "FA0056",
  395. type: "Material",
  396. name: "洋蔥肉",
  397. inStockQty: 241.98,
  398. purchaseQty: 2419.8,
  399. },
  400. {
  401. id: 8,
  402. code: "PP1188",
  403. type: "Material",
  404. name: "咖喱膽",
  405. inStockQty: 36.0,
  406. purchaseQty: 0,
  407. },
  408. {
  409. id: 9,
  410. code: "PP8001",
  411. type: "Material",
  412. name: "咖哩汁箱料粉",
  413. inStockQty: 77.42,
  414. purchaseQty: 774.2,
  415. },
  416. {
  417. id: 10,
  418. code: "PP1096",
  419. type: "Material",
  420. name: "白麵撈",
  421. inStockQty: 60.0,
  422. purchaseQty: 0,
  423. },
  424. {
  425. id: 11,
  426. code: "NA0476",
  427. type: "Material",
  428. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  429. inStockQty: 600.0,
  430. purchaseQty: 6000,
  431. },
  432. {
  433. id: 12,
  434. code: "MH0040",
  435. type: "Material",
  436. name: "大豆油(1噸/桶)",
  437. inStockQty: 0,
  438. purchaseQty: 972.12,
  439. },
  440. {
  441. id: 13,
  442. code: "FA0161",
  443. type: "Material",
  444. name: "洋蔥粒",
  445. inStockQty: 0,
  446. purchaseQty: 28.15,
  447. },
  448. {
  449. id: 14,
  450. code: "MG1288",
  451. type: "Material",
  452. name: "炸紅蔥頭",
  453. inStockQty: 0,
  454. purchaseQty: 6.05,
  455. },
  456. {
  457. id: 15,
  458. code: "MG0066",
  459. type: "Material",
  460. name: "咖哩料(5斤x16包+2斤/包)",
  461. inStockQty: 0,
  462. purchaseQty: 241.98,
  463. },
  464. {
  465. id: 16,
  466. code: "MH0040",
  467. type: "Material",
  468. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  469. inStockQty: 0,
  470. purchaseQty: 250.0,
  471. },
  472. ],
  473. [
  474. {
  475. id: 1,
  476. code: "MH0040",
  477. type: "Material",
  478. name: "大豆油(1噸/桶)",
  479. inStockQty: 54.44,
  480. purchaseQty: 972.12,
  481. },
  482. {
  483. id: 2,
  484. code: "GI3236",
  485. type: "Material",
  486. name: "清水(煮過牛腩)",
  487. inStockQty: 317.52,
  488. purchaseQty: 3175.2,
  489. },
  490. {
  491. id: 3,
  492. code: "MG1700",
  493. type: "Material",
  494. name: "STERILTOM 意大利茄粒",
  495. inStockQty: 9.0,
  496. purchaseQty: 90,
  497. },
  498. {
  499. id: 4,
  500. code: "FA0533",
  501. type: "Material",
  502. name: "乾蔥茸",
  503. inStockQty: 6.04,
  504. purchaseQty: 60.4,
  505. },
  506. {
  507. id: 5,
  508. code: "FA0210",
  509. type: "Material",
  510. name: "薑茸",
  511. inStockQty: 6.04,
  512. purchaseQty: 66.45,
  513. },
  514. {
  515. id: 6,
  516. code: "FA0608",
  517. type: "Material",
  518. name: "粗蒜茸",
  519. inStockQty: 6.04,
  520. purchaseQty: 78.55,
  521. },
  522. {
  523. id: 7,
  524. code: "FA0056",
  525. type: "Material",
  526. name: "洋蔥肉",
  527. inStockQty: 241.98,
  528. purchaseQty: 2419.8,
  529. },
  530. {
  531. id: 8,
  532. code: "PP1188",
  533. type: "Material",
  534. name: "咖喱膽",
  535. inStockQty: 36.0,
  536. purchaseQty: 0,
  537. },
  538. {
  539. id: 9,
  540. code: "PP8001",
  541. type: "Material",
  542. name: "咖哩汁箱料粉",
  543. inStockQty: 77.42,
  544. purchaseQty: 774.2,
  545. },
  546. {
  547. id: 10,
  548. code: "PP1096",
  549. type: "Material",
  550. name: "白麵撈",
  551. inStockQty: 60.0,
  552. purchaseQty: 0,
  553. },
  554. {
  555. id: 11,
  556. code: "NA0476",
  557. type: "Material",
  558. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  559. inStockQty: 600.0,
  560. purchaseQty: 6000,
  561. },
  562. {
  563. id: 12,
  564. code: "MH0040",
  565. type: "Material",
  566. name: "大豆油(1噸/桶)",
  567. inStockQty: 0,
  568. purchaseQty: 972.12,
  569. },
  570. {
  571. id: 13,
  572. code: "FA0161",
  573. type: "Material",
  574. name: "洋蔥粒",
  575. inStockQty: 0,
  576. purchaseQty: 28.15,
  577. },
  578. {
  579. id: 14,
  580. code: "MG1288",
  581. type: "Material",
  582. name: "炸紅蔥頭",
  583. inStockQty: 0,
  584. purchaseQty: 6.05,
  585. },
  586. {
  587. id: 15,
  588. code: "MG0066",
  589. type: "Material",
  590. name: "咖哩料(5斤x16包+2斤/包)",
  591. inStockQty: 0,
  592. purchaseQty: 241.98,
  593. },
  594. {
  595. id: 16,
  596. code: "MH0040",
  597. type: "Material",
  598. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  599. inStockQty: 0,
  600. purchaseQty: 250.0,
  601. },
  602. ],
  603. [
  604. {
  605. id: 1,
  606. code: "MH0040",
  607. type: "Material",
  608. name: "大豆油(1噸/桶)",
  609. inStockQty: 54.44,
  610. purchaseQty: 972.12,
  611. },
  612. {
  613. id: 2,
  614. code: "GI3236",
  615. type: "Material",
  616. name: "清水(煮過牛腩)",
  617. inStockQty: 317.52,
  618. purchaseQty: 3175.2,
  619. },
  620. {
  621. id: 3,
  622. code: "MG1700",
  623. type: "Material",
  624. name: "STERILTOM 意大利茄粒",
  625. inStockQty: 9.0,
  626. purchaseQty: 90,
  627. },
  628. {
  629. id: 4,
  630. code: "FA0533",
  631. type: "Material",
  632. name: "乾蔥茸",
  633. inStockQty: 6.04,
  634. purchaseQty: 60.4,
  635. },
  636. {
  637. id: 5,
  638. code: "FA0210",
  639. type: "Material",
  640. name: "薑茸",
  641. inStockQty: 6.04,
  642. purchaseQty: 66.45,
  643. },
  644. {
  645. id: 6,
  646. code: "FA0608",
  647. type: "Material",
  648. name: "粗蒜茸",
  649. inStockQty: 6.04,
  650. purchaseQty: 78.55,
  651. },
  652. {
  653. id: 7,
  654. code: "FA0056",
  655. type: "Material",
  656. name: "洋蔥肉",
  657. inStockQty: 241.98,
  658. purchaseQty: 2419.8,
  659. },
  660. {
  661. id: 8,
  662. code: "PP1188",
  663. type: "Material",
  664. name: "咖喱膽",
  665. inStockQty: 36.0,
  666. purchaseQty: 0,
  667. },
  668. {
  669. id: 9,
  670. code: "PP8001",
  671. type: "Material",
  672. name: "咖哩汁箱料粉",
  673. inStockQty: 77.42,
  674. purchaseQty: 774.2,
  675. },
  676. {
  677. id: 10,
  678. code: "PP1096",
  679. type: "Material",
  680. name: "白麵撈",
  681. inStockQty: 60.0,
  682. purchaseQty: 0,
  683. },
  684. {
  685. id: 11,
  686. code: "NA0476",
  687. type: "Material",
  688. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  689. inStockQty: 600.0,
  690. purchaseQty: 6000,
  691. },
  692. {
  693. id: 12,
  694. code: "MH0040",
  695. type: "Material",
  696. name: "大豆油(1噸/桶)",
  697. inStockQty: 0,
  698. purchaseQty: 972.12,
  699. },
  700. {
  701. id: 13,
  702. code: "FA0161",
  703. type: "Material",
  704. name: "洋蔥粒",
  705. inStockQty: 0,
  706. purchaseQty: 28.15,
  707. },
  708. {
  709. id: 14,
  710. code: "MG1288",
  711. type: "Material",
  712. name: "炸紅蔥頭",
  713. inStockQty: 0,
  714. purchaseQty: 6.05,
  715. },
  716. {
  717. id: 15,
  718. code: "MG0066",
  719. type: "Material",
  720. name: "咖哩料(5斤x16包+2斤/包)",
  721. inStockQty: 0,
  722. purchaseQty: 241.98,
  723. },
  724. {
  725. id: 16,
  726. code: "MH0040",
  727. type: "Material",
  728. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  729. inStockQty: 0,
  730. purchaseQty: 250.0,
  731. },
  732. ],
  733. [
  734. {
  735. id: 1,
  736. code: "MH0040",
  737. type: "Material",
  738. name: "大豆油(1噸/桶)",
  739. inStockQty: 54.44,
  740. purchaseQty: 972.12,
  741. },
  742. {
  743. id: 2,
  744. code: "GI3236",
  745. type: "Material",
  746. name: "清水(煮過牛腩)",
  747. inStockQty: 317.52,
  748. purchaseQty: 3175.2,
  749. },
  750. {
  751. id: 3,
  752. code: "MG1700",
  753. type: "Material",
  754. name: "STERILTOM 意大利茄粒",
  755. inStockQty: 9.0,
  756. purchaseQty: 90,
  757. },
  758. {
  759. id: 4,
  760. code: "FA0533",
  761. type: "Material",
  762. name: "乾蔥茸",
  763. inStockQty: 6.04,
  764. purchaseQty: 60.4,
  765. },
  766. {
  767. id: 5,
  768. code: "FA0210",
  769. type: "Material",
  770. name: "薑茸",
  771. inStockQty: 6.04,
  772. purchaseQty: 66.45,
  773. },
  774. {
  775. id: 6,
  776. code: "FA0608",
  777. type: "Material",
  778. name: "粗蒜茸",
  779. inStockQty: 6.04,
  780. purchaseQty: 78.55,
  781. },
  782. {
  783. id: 7,
  784. code: "FA0056",
  785. type: "Material",
  786. name: "洋蔥肉",
  787. inStockQty: 241.98,
  788. purchaseQty: 2419.8,
  789. },
  790. {
  791. id: 8,
  792. code: "PP1188",
  793. type: "Material",
  794. name: "咖喱膽",
  795. inStockQty: 36.0,
  796. purchaseQty: 0,
  797. },
  798. {
  799. id: 9,
  800. code: "PP8001",
  801. type: "Material",
  802. name: "咖哩汁箱料粉",
  803. inStockQty: 77.42,
  804. purchaseQty: 774.2,
  805. },
  806. {
  807. id: 10,
  808. code: "PP1096",
  809. type: "Material",
  810. name: "白麵撈",
  811. inStockQty: 60.0,
  812. purchaseQty: 0,
  813. },
  814. {
  815. id: 11,
  816. code: "NA0476",
  817. type: "Material",
  818. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  819. inStockQty: 600.0,
  820. purchaseQty: 6000,
  821. },
  822. {
  823. id: 12,
  824. code: "MH0040",
  825. type: "Material",
  826. name: "大豆油(1噸/桶)",
  827. inStockQty: 0,
  828. purchaseQty: 972.12,
  829. },
  830. {
  831. id: 13,
  832. code: "FA0161",
  833. type: "Material",
  834. name: "洋蔥粒",
  835. inStockQty: 0,
  836. purchaseQty: 28.15,
  837. },
  838. {
  839. id: 14,
  840. code: "MG1288",
  841. type: "Material",
  842. name: "炸紅蔥頭",
  843. inStockQty: 0,
  844. purchaseQty: 6.05,
  845. },
  846. {
  847. id: 15,
  848. code: "MG0066",
  849. type: "Material",
  850. name: "咖哩料(5斤x16包+2斤/包)",
  851. inStockQty: 0,
  852. purchaseQty: 241.98,
  853. },
  854. {
  855. id: 16,
  856. code: "MH0040",
  857. type: "Material",
  858. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  859. inStockQty: 0,
  860. purchaseQty: 250.0,
  861. },
  862. ],
  863. [
  864. {
  865. id: 1,
  866. code: "MH0040",
  867. type: "Material",
  868. name: "大豆油(1噸/桶)",
  869. inStockQty: 54.44,
  870. purchaseQty: 972.12,
  871. },
  872. {
  873. id: 2,
  874. code: "GI3236",
  875. type: "Material",
  876. name: "清水(煮過牛腩)",
  877. inStockQty: 317.52,
  878. purchaseQty: 3175.2,
  879. },
  880. {
  881. id: 3,
  882. code: "MG1700",
  883. type: "Material",
  884. name: "STERILTOM 意大利茄粒",
  885. inStockQty: 9.0,
  886. purchaseQty: 90,
  887. },
  888. {
  889. id: 4,
  890. code: "FA0533",
  891. type: "Material",
  892. name: "乾蔥茸",
  893. inStockQty: 6.04,
  894. purchaseQty: 60.4,
  895. },
  896. {
  897. id: 5,
  898. code: "FA0210",
  899. type: "Material",
  900. name: "薑茸",
  901. inStockQty: 6.04,
  902. purchaseQty: 66.45,
  903. },
  904. {
  905. id: 6,
  906. code: "FA0608",
  907. type: "Material",
  908. name: "粗蒜茸",
  909. inStockQty: 6.04,
  910. purchaseQty: 78.55,
  911. },
  912. {
  913. id: 7,
  914. code: "FA0056",
  915. type: "Material",
  916. name: "洋蔥肉",
  917. inStockQty: 241.98,
  918. purchaseQty: 2419.8,
  919. },
  920. {
  921. id: 8,
  922. code: "PP1188",
  923. type: "Material",
  924. name: "咖喱膽",
  925. inStockQty: 36.0,
  926. purchaseQty: 0,
  927. },
  928. {
  929. id: 9,
  930. code: "PP8001",
  931. type: "Material",
  932. name: "咖哩汁箱料粉",
  933. inStockQty: 77.42,
  934. purchaseQty: 774.2,
  935. },
  936. {
  937. id: 10,
  938. code: "PP1096",
  939. type: "Material",
  940. name: "白麵撈",
  941. inStockQty: 60.0,
  942. purchaseQty: 0,
  943. },
  944. {
  945. id: 11,
  946. code: "NA0476",
  947. type: "Material",
  948. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  949. inStockQty: 600.0,
  950. purchaseQty: 6000,
  951. },
  952. {
  953. id: 12,
  954. code: "MH0040",
  955. type: "Material",
  956. name: "大豆油(1噸/桶)",
  957. inStockQty: 0,
  958. purchaseQty: 972.12,
  959. },
  960. {
  961. id: 13,
  962. code: "FA0161",
  963. type: "Material",
  964. name: "洋蔥粒",
  965. inStockQty: 0,
  966. purchaseQty: 28.15,
  967. },
  968. {
  969. id: 14,
  970. code: "MG1288",
  971. type: "Material",
  972. name: "炸紅蔥頭",
  973. inStockQty: 0,
  974. purchaseQty: 6.05,
  975. },
  976. {
  977. id: 15,
  978. code: "MG0066",
  979. type: "Material",
  980. name: "咖哩料(5斤x16包+2斤/包)",
  981. inStockQty: 0,
  982. purchaseQty: 241.98,
  983. },
  984. {
  985. id: 16,
  986. code: "MH0040",
  987. type: "Material",
  988. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  989. inStockQty: 0,
  990. purchaseQty: 250.0,
  991. },
  992. ],
  993. ],
  994. [],
  995. );
  996. // const updatePagingController = (updatedObj: { index: number, pageNum: number, pageSize: number, totalCount: number }) => {
  997. // setPagingController((prevState) => {
  998. // return prevState.map((item, index) => {
  999. // if (index === updatedObj?.index){
  1000. // return {
  1001. // ...item,
  1002. // pageNum: item.pageNum,
  1003. // pageSize: item.pageSize,
  1004. // totalCount: item.totalCount,
  1005. // };
  1006. // }
  1007. // else
  1008. // return item
  1009. // });
  1010. // });
  1011. // };
  1012. const fakeOverallRecords = useMemo<FGOverallRecord[]>(
  1013. () => [
  1014. {
  1015. id: 1,
  1016. code: "MH0040",
  1017. type: "Material",
  1018. name: "大豆油(1噸/桶)",
  1019. inStockQty: 54.44,
  1020. purchaseQty1: 972.12,
  1021. purchaseQty2: 972.12,
  1022. purchaseQty3: 972.12,
  1023. purchaseQty4: 972.12,
  1024. purchaseQty5: 972.12,
  1025. purchaseQty6: 972.12,
  1026. purchaseQty7: 972.12,
  1027. overallPurchaseQty: 6804.84,
  1028. },
  1029. {
  1030. id: 2,
  1031. code: "GI3236",
  1032. type: "Material",
  1033. name: "清水(煮過牛腩)",
  1034. inStockQty: 317.52,
  1035. purchaseQty1: 3175.2,
  1036. purchaseQty2: 3175.2,
  1037. purchaseQty3: 3175.2,
  1038. purchaseQty4: 3175.2,
  1039. purchaseQty5: 3175.2,
  1040. purchaseQty6: 3175.2,
  1041. purchaseQty7: 3175.2,
  1042. overallPurchaseQty: 22226.4,
  1043. },
  1044. {
  1045. id: 3,
  1046. code: "MG1700",
  1047. type: "Material",
  1048. name: "STERILTOM 意大利茄粒",
  1049. inStockQty: 9.0,
  1050. purchaseQty1: 90,
  1051. purchaseQty2: 90,
  1052. purchaseQty3: 90,
  1053. purchaseQty4: 90,
  1054. purchaseQty5: 90,
  1055. purchaseQty6: 90,
  1056. purchaseQty7: 90,
  1057. overallPurchaseQty: 630,
  1058. },
  1059. {
  1060. id: 4,
  1061. code: "FA0533",
  1062. type: "Material",
  1063. name: "乾蔥茸",
  1064. inStockQty: 6.04,
  1065. purchaseQty1: 60.4,
  1066. purchaseQty2: 60.4,
  1067. purchaseQty3: 60.4,
  1068. purchaseQty4: 60.4,
  1069. purchaseQty5: 60.4,
  1070. purchaseQty6: 60.4,
  1071. purchaseQty7: 60.4,
  1072. overallPurchaseQty: 422.8,
  1073. },
  1074. {
  1075. id: 5,
  1076. code: "FA0210",
  1077. type: "Material",
  1078. name: "薑茸",
  1079. inStockQty: 6.04,
  1080. purchaseQty1: 66.45,
  1081. purchaseQty2: 66.45,
  1082. purchaseQty3: 66.45,
  1083. purchaseQty4: 66.45,
  1084. purchaseQty5: 66.45,
  1085. purchaseQty6: 66.45,
  1086. purchaseQty7: 66.45,
  1087. overallPurchaseQty: 465.15,
  1088. },
  1089. {
  1090. id: 6,
  1091. code: "FA0608",
  1092. type: "Material",
  1093. name: "粗蒜茸",
  1094. inStockQty: 6.04,
  1095. purchaseQty1: 78.55,
  1096. purchaseQty2: 78.55,
  1097. purchaseQty3: 78.55,
  1098. purchaseQty4: 78.55,
  1099. purchaseQty5: 78.55,
  1100. purchaseQty6: 78.55,
  1101. purchaseQty7: 78.55,
  1102. overallPurchaseQty: 549.85,
  1103. },
  1104. {
  1105. id: 7,
  1106. code: "FA0056",
  1107. type: "Material",
  1108. name: "洋蔥肉",
  1109. inStockQty: 241.98,
  1110. purchaseQty: 2419.8,
  1111. },
  1112. {
  1113. id: 8,
  1114. code: "PP1188",
  1115. type: "Material",
  1116. name: "咖喱膽",
  1117. inStockQty: 36.0,
  1118. purchaseQty: 0,
  1119. },
  1120. {
  1121. id: 9,
  1122. code: "PP8001",
  1123. type: "Material",
  1124. name: "咖哩汁箱料粉",
  1125. inStockQty: 77.42,
  1126. purchaseQty: 774.2,
  1127. },
  1128. {
  1129. id: 10,
  1130. code: "PP1096",
  1131. type: "Material",
  1132. name: "白麵撈",
  1133. inStockQty: 60.0,
  1134. purchaseQty: 0,
  1135. },
  1136. {
  1137. id: 11,
  1138. code: "NA0476",
  1139. type: "Material",
  1140. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  1141. inStockQty: 600.0,
  1142. purchaseQty: 6000,
  1143. },
  1144. {
  1145. id: 12,
  1146. code: "MH0040",
  1147. type: "Material",
  1148. name: "大豆油(1噸/桶)",
  1149. inStockQty: 0,
  1150. purchaseQty: 972.12,
  1151. },
  1152. {
  1153. id: 13,
  1154. code: "FA0161",
  1155. type: "Material",
  1156. name: "洋蔥粒",
  1157. inStockQty: 0,
  1158. purchaseQty: 28.15,
  1159. },
  1160. {
  1161. id: 14,
  1162. code: "MG1288",
  1163. type: "Material",
  1164. name: "炸紅蔥頭",
  1165. inStockQty: 0,
  1166. purchaseQty: 6.05,
  1167. },
  1168. {
  1169. id: 15,
  1170. code: "MG0066",
  1171. type: "Material",
  1172. name: "咖哩料(5斤x16包+2斤/包)",
  1173. inStockQty: 0,
  1174. purchaseQty: 241.98,
  1175. },
  1176. {
  1177. id: 16,
  1178. code: "MH0040",
  1179. type: "Material",
  1180. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1181. inStockQty: 0,
  1182. purchaseQty: 250.0,
  1183. },
  1184. ],
  1185. [],
  1186. );
  1187. const [pagingController, setPagingController] = useState([
  1188. {
  1189. pageNum: 1,
  1190. pageSize: 10,
  1191. totalCount: 0,
  1192. },
  1193. {
  1194. pageNum: 1,
  1195. pageSize: 10,
  1196. totalCount: 0,
  1197. },
  1198. {
  1199. pageNum: 1,
  1200. pageSize: 10,
  1201. totalCount: 0,
  1202. },
  1203. {
  1204. pageNum: 1,
  1205. pageSize: 10,
  1206. totalCount: 0,
  1207. },
  1208. {
  1209. pageNum: 1,
  1210. pageSize: 10,
  1211. totalCount: 0,
  1212. },
  1213. {
  1214. pageNum: 1,
  1215. pageSize: 10,
  1216. totalCount: 0,
  1217. },
  1218. {
  1219. pageNum: 1,
  1220. pageSize: 10,
  1221. totalCount: 0,
  1222. },
  1223. {
  1224. pageNum: 1,
  1225. pageSize: 10,
  1226. totalCount: 0,
  1227. },
  1228. ]);
  1229. const updatePagingController = (updatedObj: any) => {
  1230. setPagingController((prevState) => {
  1231. return prevState.map((item, index) => {
  1232. if (index === updatedObj?.index) {
  1233. return {
  1234. ...item,
  1235. pageNum: item.pageNum,
  1236. pageSize: item.pageSize,
  1237. totalCount: item.totalCount,
  1238. };
  1239. } else return item;
  1240. });
  1241. });
  1242. };
  1243. const overallColumns = useMemo<Column<any>[]>(
  1244. () => [
  1245. {
  1246. field: "code",
  1247. label: t("code"),
  1248. type: "read-only",
  1249. // editable: true,
  1250. },
  1251. {
  1252. field: "name",
  1253. label: t("name"),
  1254. type: "read-only",
  1255. },
  1256. {
  1257. field: "type",
  1258. label: t("type"),
  1259. type: "read-only",
  1260. // editable: true,
  1261. },
  1262. {
  1263. field: "inStockQty",
  1264. label: t("Available Qty"),
  1265. type: "read-only",
  1266. style: {
  1267. textAlign: "right",
  1268. },
  1269. renderCell: (row: FGOverallRecord) => {
  1270. if (typeof row.inStockQty == "number") {
  1271. return decimalFormatter.format(row.inStockQty);
  1272. }
  1273. return row.inStockQty;
  1274. },
  1275. // editable: true,
  1276. },
  1277. {
  1278. field: "overallPurchaseQty",
  1279. label: t("Total Demand Qty"),
  1280. type: "read-only",
  1281. style: {
  1282. textAlign: "right",
  1283. },
  1284. renderCell: (row: FGOverallRecord) => {
  1285. if (typeof row.overallPurchaseQty == "number") {
  1286. return decimalFormatter.format(row.overallPurchaseQty);
  1287. }
  1288. return row.overallPurchaseQty;
  1289. },
  1290. },
  1291. {
  1292. field: "purchaseQty1",
  1293. label: t("Demand Qty (Day1)"),
  1294. type: "read-only",
  1295. style: {
  1296. textAlign: "right",
  1297. },
  1298. renderCell: (row: FGOverallRecord) => {
  1299. if (typeof row.purchaseQty1 == "number") {
  1300. return decimalFormatter.format(row.purchaseQty1);
  1301. }
  1302. return row.purchaseQty1;
  1303. },
  1304. },
  1305. {
  1306. field: "purchaseQty2",
  1307. label: t("Demand Qty (Day2)"),
  1308. type: "read-only",
  1309. style: {
  1310. textAlign: "right",
  1311. },
  1312. renderCell: (row: FGOverallRecord) => {
  1313. if (typeof row.purchaseQty2 == "number") {
  1314. return decimalFormatter.format(row.purchaseQty2);
  1315. }
  1316. return row.purchaseQty2;
  1317. },
  1318. },
  1319. {
  1320. field: "purchaseQty3",
  1321. label: t("Demand Qty (Day3)"),
  1322. type: "read-only",
  1323. style: {
  1324. textAlign: "right",
  1325. },
  1326. renderCell: (row: FGOverallRecord) => {
  1327. if (typeof row.purchaseQty3 == "number") {
  1328. return decimalFormatter.format(row.purchaseQty3);
  1329. }
  1330. return row.purchaseQty3;
  1331. },
  1332. },
  1333. {
  1334. field: "purchaseQty4",
  1335. label: t("Demand Qty (Day4)"),
  1336. type: "read-only",
  1337. style: {
  1338. textAlign: "right",
  1339. },
  1340. renderCell: (row: FGOverallRecord) => {
  1341. if (typeof row.purchaseQty4 == "number") {
  1342. return decimalFormatter.format(row.purchaseQty4);
  1343. }
  1344. return row.purchaseQty4;
  1345. },
  1346. },
  1347. {
  1348. field: "purchaseQty5",
  1349. label: t("Demand Qty (Day5)"),
  1350. type: "read-only",
  1351. style: {
  1352. textAlign: "right",
  1353. },
  1354. renderCell: (row: FGOverallRecord) => {
  1355. if (typeof row.purchaseQty5 == "number") {
  1356. return decimalFormatter.format(row.purchaseQty5);
  1357. }
  1358. return row.purchaseQty5;
  1359. },
  1360. },
  1361. {
  1362. field: "purchaseQty6",
  1363. label: t("Demand Qty (Day6)"),
  1364. type: "read-only",
  1365. style: {
  1366. textAlign: "right",
  1367. },
  1368. renderCell: (row: FGOverallRecord) => {
  1369. if (typeof row.purchaseQty6 == "number") {
  1370. return decimalFormatter.format(row.purchaseQty6);
  1371. }
  1372. return row.purchaseQty6;
  1373. },
  1374. },
  1375. {
  1376. field: "purchaseQty7",
  1377. label: t("Demand Qty (Day7)"),
  1378. type: "read-only",
  1379. style: {
  1380. textAlign: "right",
  1381. },
  1382. renderCell: (row: FGOverallRecord) => {
  1383. if (typeof row.purchaseQty7 == "number") {
  1384. return decimalFormatter.format(row.purchaseQty7);
  1385. }
  1386. return row.purchaseQty7;
  1387. },
  1388. },
  1389. ],
  1390. [],
  1391. );
  1392. const columns = useMemo<Column<any>[]>(
  1393. () => [
  1394. {
  1395. field: "code",
  1396. label: t("code"),
  1397. type: "read-only",
  1398. // editable: true,
  1399. },
  1400. {
  1401. field: "name",
  1402. label: t("name"),
  1403. type: "read-only",
  1404. },
  1405. {
  1406. field: "type",
  1407. label: t("type"),
  1408. type: "read-only",
  1409. },
  1410. {
  1411. field: "inStockQty",
  1412. label: t("Available Qty"),
  1413. type: "read-only",
  1414. // editable: true,
  1415. style: {
  1416. textAlign: "right",
  1417. },
  1418. renderCell: (row: FGRecord) => {
  1419. if (typeof row.inStockQty == "number") {
  1420. return decimalFormatter.format(row.inStockQty);
  1421. }
  1422. return row.inStockQty;
  1423. },
  1424. },
  1425. {
  1426. field: "purchaseQty",
  1427. label: t("Demand Qty"),
  1428. type: "read-only",
  1429. style: {
  1430. textAlign: "right",
  1431. },
  1432. renderCell: (row: FGRecord) => {
  1433. if (typeof row.purchaseQty == "number") {
  1434. return decimalFormatter.format(row.purchaseQty);
  1435. }
  1436. return row.purchaseQty;
  1437. },
  1438. },
  1439. ],
  1440. [],
  1441. );
  1442. return (
  1443. <Grid container spacing={2}>
  1444. <Grid item xs={12} key={"all"}>
  1445. <Typography variant="overline" display="block" marginBlockEnd={1}>
  1446. {t("Material Demand List (7 Days)")}
  1447. </Typography>
  1448. <EditableSearchResults<FGRecord>
  1449. index={7}
  1450. items={fakeOverallRecords as FGRecord[]}
  1451. hasCollapse
  1452. // isMockUp={true}
  1453. columns={overallColumns}
  1454. setPagingController={updatePagingController}
  1455. pagingController={pagingController[7]}
  1456. isAutoPaging={true}
  1457. isEditable={false}
  1458. isEdit={false}
  1459. />
  1460. </Grid>
  1461. {dayPeriod.map((date, index) => (
  1462. <Grid item xs={12} key={index}>
  1463. <Typography variant="overline" display="block" marginBlockEnd={1}>
  1464. {`${t("Material Demand Date")}: ${date}`}
  1465. </Typography>
  1466. <EditableSearchResults<FGRecord>
  1467. hasCollapse
  1468. index={index}
  1469. items={fakeRecords[index]} // Use the corresponding records for the day
  1470. columns={columns}
  1471. setPagingController={updatePagingController}
  1472. pagingController={pagingController[index]}
  1473. isAutoPaging={true}
  1474. isEditable={false}
  1475. isEdit={isEdit}
  1476. />
  1477. </Grid>
  1478. ))}
  1479. </Grid>
  1480. );
  1481. };
  1482. export default ViewByBomDetails;