FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2197 regels
54 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, 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, {
  21. Column,
  22. } from "@/components/SearchResults/EditableSearchResults";
  23. import { decimalFormatter, integerFormatter } from "@/app/utils/formatUtil";
  24. type Props = {
  25. apiRef: MutableRefObject<GridApiCommunity>;
  26. isEdit: boolean;
  27. };
  28. type EntryError =
  29. | {
  30. [field in keyof QcChecksInputs]?: string;
  31. }
  32. | undefined;
  33. export type FGRecord = {
  34. id: string | number;
  35. code: string;
  36. name: string;
  37. inStockQty: number;
  38. productionQty?: number;
  39. purchaseQty?: number;
  40. safetyStock?: number;
  41. lastMonthAvgStock?: number
  42. };
  43. const ViewByFGDetails: React.FC<Props> = ({ apiRef, isEdit }) => {
  44. const {
  45. t,
  46. i18n: { language },
  47. } = useTranslation("schedule");
  48. const {
  49. formState: { errors, defaultValues, touchedFields },
  50. } = useFormContext<CreateItemInputs>();
  51. // const apiRef = useGridApiRef();
  52. const dayPeriod = [
  53. "2025-05-07",
  54. // '2025-05-12',
  55. // '2025-05-13',
  56. // '2025-05-14',
  57. // '2025-05-15',
  58. // '2025-05-16',
  59. // '2025-05-17',
  60. ];
  61. const fakeRecordLine = useMemo<FGRecord[][]>(
  62. () => [
  63. [
  64. {
  65. id: 1,
  66. code: "mt1",
  67. name: "material 1",
  68. inStockQty: 10,
  69. purchaseQty: 1,
  70. },
  71. {
  72. id: 2,
  73. code: "mt2",
  74. name: "material 2",
  75. inStockQty: 20,
  76. purchaseQty: 199,
  77. },
  78. ],
  79. [
  80. {
  81. id: 3,
  82. code: "mt3",
  83. name: "material 3",
  84. inStockQty: 30,
  85. purchaseQty: 3,
  86. },
  87. {
  88. id: 4,
  89. code: "mt4",
  90. name: "material 4",
  91. inStockQty: 40,
  92. purchaseQty: 499,
  93. },
  94. ],
  95. [
  96. {
  97. id: 5,
  98. code: "mt5",
  99. name: "material 5",
  100. inStockQty: 50,
  101. purchaseQty: 5,
  102. },
  103. {
  104. id: 6,
  105. code: "mt6",
  106. name: "material 6",
  107. inStockQty: 60,
  108. purchaseQty: 699,
  109. },
  110. ],
  111. [
  112. {
  113. id: 7,
  114. code: "mt7",
  115. name: "material 7",
  116. inStockQty: 70,
  117. purchaseQty: 7,
  118. },
  119. {
  120. id: 8,
  121. code: "mt8",
  122. name: "material 8",
  123. inStockQty: 80,
  124. purchaseQty: 899,
  125. },
  126. ],
  127. [
  128. {
  129. id: 9,
  130. code: "mt9",
  131. name: "material 9",
  132. inStockQty: 90,
  133. purchaseQty: 9,
  134. },
  135. {
  136. id: 10,
  137. code: "mt10",
  138. name: "material 10",
  139. inStockQty: 100,
  140. purchaseQty: 999,
  141. },
  142. ],
  143. [
  144. {
  145. id: 11,
  146. code: "mt11",
  147. name: "material 11",
  148. inStockQty: 110,
  149. purchaseQty: 11,
  150. },
  151. {
  152. id: 12,
  153. code: "mt12",
  154. name: "material 12",
  155. inStockQty: 120,
  156. purchaseQty: 1299,
  157. },
  158. ],
  159. [
  160. {
  161. id: 13,
  162. code: "mt13",
  163. name: "material 13",
  164. inStockQty: 130,
  165. purchaseQty: 13,
  166. },
  167. {
  168. id: 14,
  169. code: "mt14",
  170. name: "material 14",
  171. inStockQty: 140,
  172. purchaseQty: 1499,
  173. },
  174. ],
  175. ],
  176. [],
  177. );
  178. const fakeRecords = useMemo<FGRecord[][]>(
  179. () => [
  180. [
  181. {
  182. id: 1,
  183. jobNo: "JO20250507001",
  184. estimatedProductionTime: "1 hr",
  185. priority: 85,
  186. code: "PP1193",
  187. type: "FG",
  188. name: "蔥油(1磅) ",
  189. inStockQty: 1322,
  190. productionQty: 661,
  191. lines: [
  192. {
  193. id: 1,
  194. code: "MH0040",
  195. type: "Material",
  196. name: "大豆油(1噸/桶)",
  197. inStockQty: 100,
  198. purchaseQty: 20,
  199. },
  200. {
  201. id: 2,
  202. code: "FA0161",
  203. type: "Material",
  204. name: "洋蔥粒",
  205. inStockQty: 80,
  206. purchaseQty: 10,
  207. },
  208. ],
  209. },
  210. {
  211. id: 2,
  212. jobNo: "JO20250507002",
  213. estimatedProductionTime: "2 hrs",
  214. priority: 80,
  215. code: " PP1096",
  216. type: "FG",
  217. name: "白麵撈",
  218. inStockQty: 1040,
  219. productionQty: 520,
  220. lines: [
  221. {
  222. id: 1,
  223. code: "MH0040",
  224. type: "Material",
  225. name: "大豆油(1噸/桶)",
  226. inStockQty: 1000,
  227. purchaseQty: 190.0,
  228. },
  229. {
  230. id: 1,
  231. code: "MH0040",
  232. type: "Material",
  233. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  234. inStockQty: 1000,
  235. purchaseQty: 250.0,
  236. },
  237. {
  238. id: 2,
  239. code: "FA0161",
  240. type: "Material",
  241. name: "蔥油",
  242. inStockQty: 1322,
  243. purchaseQty: 0,
  244. },
  245. ],
  246. },
  247. {
  248. id: 3,
  249. jobNo: "JO20250507003",
  250. estimatedProductionTime: "5 hrs : 15 mins",
  251. priority: 35,
  252. code: "PP1080",
  253. type: "FG",
  254. name: "咖哩汁",
  255. inStockQty: 2400,
  256. productionQty: 1200.0,
  257. lines: [
  258. {
  259. id: 1,
  260. code: "MH0040",
  261. type: "Material",
  262. name: "大豆油(1噸/桶)",
  263. inStockQty: 0,
  264. purchaseQty: 108.88,
  265. },
  266. {
  267. id: 2,
  268. code: "GI3236",
  269. type: "Material",
  270. name: "清水(煮過牛腩)",
  271. inStockQty: 317.52,
  272. purchaseQty: 635.04,
  273. },
  274. {
  275. id: 3,
  276. code: "MG1700",
  277. type: "Material",
  278. name: "STERILTOM 意大利茄粒",
  279. inStockQty: 9.0,
  280. purchaseQty: 18.0,
  281. },
  282. {
  283. id: 4,
  284. code: "FA0533",
  285. type: "Material",
  286. name: "乾蔥茸",
  287. inStockQty: 6.04,
  288. purchaseQty: 12.08,
  289. },
  290. {
  291. id: 5,
  292. code: "FA0210",
  293. type: "Material",
  294. name: "薑茸",
  295. inStockQty: 0,
  296. purchaseQty: 12.08,
  297. },
  298. {
  299. id: 6,
  300. code: "FA0608",
  301. type: "Material",
  302. name: "粗蒜茸",
  303. inStockQty: 0,
  304. purchaseQty: 12.08,
  305. },
  306. {
  307. id: 7,
  308. code: "FA0056",
  309. type: "Material",
  310. name: "洋蔥肉",
  311. inStockQty: 241.98,
  312. purchaseQty: 483.96,
  313. },
  314. {
  315. id: 8,
  316. code: "PP1188",
  317. type: "Material",
  318. name: "咖喱膽",
  319. inStockQty: 36.0,
  320. purchaseQty: 72.0,
  321. },
  322. {
  323. id: 9,
  324. code: "PP8001",
  325. type: "Material",
  326. name: "咖哩汁箱料粉",
  327. inStockQty: 77.42,
  328. purchaseQty: 154.84,
  329. },
  330. {
  331. id: 10,
  332. code: "PP1096",
  333. type: "Material",
  334. name: "白麵撈",
  335. inStockQty: 60.0,
  336. purchaseQty: 120.0,
  337. },
  338. {
  339. id: 10,
  340. code: "NA0476",
  341. type: "Material",
  342. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  343. inStockQty: 600.0,
  344. purchaseQty: 200.0,
  345. },
  346. ],
  347. },
  348. {
  349. id: 4,
  350. jobNo: "JO20250507004",
  351. estimatedProductionTime: "3 hrs",
  352. priority: 20,
  353. code: " PP1188",
  354. type: "FG",
  355. name: "咖喱膽",
  356. inStockQty: 1016.2,
  357. productionQty: 508.1,
  358. lines: [
  359. {
  360. id: 1,
  361. code: "MH0040",
  362. type: "Material",
  363. name: "大豆油(1噸/桶)",
  364. inStockQty: 0,
  365. purchaseQty: 217.72,
  366. },
  367. {
  368. id: 2,
  369. code: "FA0161",
  370. type: "Material",
  371. name: "洋蔥粒",
  372. inStockQty: 0,
  373. purchaseQty: 18.15,
  374. },
  375. {
  376. id: 3,
  377. code: "FA0608",
  378. type: "Material",
  379. name: "粗蒜茸",
  380. inStockQty: 0,
  381. purchaseQty: 18.15,
  382. },
  383. {
  384. id: 4,
  385. code: "MG1288",
  386. type: "Material",
  387. name: "炸紅蔥頭",
  388. inStockQty: 0,
  389. purchaseQty: 6.05,
  390. },
  391. {
  392. id: 5,
  393. code: "FA0210",
  394. type: "Material",
  395. name: "薑茸",
  396. inStockQty: 0,
  397. purchaseQty: 6.05,
  398. },
  399. {
  400. id: 6,
  401. code: "MG0066",
  402. type: "Material",
  403. name: "咖哩料(5斤x16包+2斤/包)",
  404. inStockQty: 0,
  405. purchaseQty: 241.98,
  406. },
  407. ],
  408. },
  409. ],
  410. [
  411. {
  412. id: 1,
  413. code: "PP1080",
  414. type: "FG",
  415. name: "咖哩汁",
  416. inStockQty: 2400,
  417. productionQty: 1200.0,
  418. lines: [
  419. {
  420. id: 1,
  421. code: "MH0040",
  422. type: "Material",
  423. name: "大豆油(1噸/桶)",
  424. inStockQty: 0,
  425. purchaseQty: 108.88,
  426. },
  427. {
  428. id: 2,
  429. code: "GI3236",
  430. type: "Material",
  431. name: "清水(煮過牛腩)",
  432. inStockQty: 317.52,
  433. purchaseQty: 635.04,
  434. },
  435. {
  436. id: 3,
  437. code: "MG1700",
  438. type: "Material",
  439. name: "STERILTOM 意大利茄粒",
  440. inStockQty: 9.0,
  441. purchaseQty: 18.0,
  442. },
  443. {
  444. id: 4,
  445. code: "FA0533",
  446. type: "Material",
  447. name: "乾蔥茸",
  448. inStockQty: 6.04,
  449. purchaseQty: 12.08,
  450. },
  451. {
  452. id: 5,
  453. code: "FA0210",
  454. type: "Material",
  455. name: "薑茸",
  456. inStockQty: 0,
  457. purchaseQty: 12.08,
  458. },
  459. {
  460. id: 6,
  461. code: "FA0608",
  462. type: "Material",
  463. name: "粗蒜茸",
  464. inStockQty: 0,
  465. purchaseQty: 12.08,
  466. },
  467. {
  468. id: 7,
  469. code: "FA0056",
  470. type: "Material",
  471. name: "洋蔥肉",
  472. inStockQty: 241.98,
  473. purchaseQty: 483.96,
  474. },
  475. {
  476. id: 8,
  477. code: "PP1188",
  478. type: "Material",
  479. name: "咖喱膽",
  480. inStockQty: 36.0,
  481. purchaseQty: 72.0,
  482. },
  483. {
  484. id: 9,
  485. code: "PP8001",
  486. type: "Material",
  487. name: "咖哩汁箱料粉",
  488. inStockQty: 77.42,
  489. purchaseQty: 154.84,
  490. },
  491. {
  492. id: 10,
  493. code: "PP1096",
  494. type: "Material",
  495. name: "白麵撈",
  496. inStockQty: 60.0,
  497. purchaseQty: 120.0,
  498. },
  499. {
  500. id: 10,
  501. code: "NA0476",
  502. type: "Material",
  503. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  504. inStockQty: 600.0,
  505. purchaseQty: 200.0,
  506. },
  507. ],
  508. },
  509. {
  510. id: 2,
  511. code: "PP1193",
  512. type: "FG",
  513. name: "蔥油(1磅) ",
  514. inStockQty: 1322,
  515. productionQty: 661,
  516. lines: [
  517. {
  518. id: 1,
  519. code: "MH0040",
  520. type: "Material",
  521. name: "大豆油(1噸/桶)",
  522. inStockQty: 0,
  523. purchaseQty: 20,
  524. },
  525. {
  526. id: 2,
  527. code: "FA0161",
  528. type: "Material",
  529. name: "洋蔥粒",
  530. inStockQty: 0,
  531. purchaseQty: 10,
  532. },
  533. ],
  534. },
  535. {
  536. id: 3,
  537. code: " PP1188",
  538. type: "FG",
  539. name: "咖喱膽",
  540. inStockQty: 1016.2,
  541. productionQty: 508.1,
  542. lines: [
  543. {
  544. id: 1,
  545. code: "MH0040",
  546. type: "Material",
  547. name: "大豆油(1噸/桶)",
  548. inStockQty: 0,
  549. purchaseQty: 217.72,
  550. },
  551. {
  552. id: 2,
  553. code: "FA0161",
  554. type: "Material",
  555. name: "洋蔥粒",
  556. inStockQty: 0,
  557. purchaseQty: 18.15,
  558. },
  559. {
  560. id: 3,
  561. code: "FA0608",
  562. type: "Material",
  563. name: "粗蒜茸",
  564. inStockQty: 0,
  565. purchaseQty: 18.15,
  566. },
  567. {
  568. id: 4,
  569. code: "MG1288",
  570. type: "Material",
  571. name: "炸紅蔥頭",
  572. inStockQty: 0,
  573. purchaseQty: 6.05,
  574. },
  575. {
  576. id: 5,
  577. code: "FA0210",
  578. type: "Material",
  579. name: "薑茸",
  580. inStockQty: 0,
  581. purchaseQty: 6.05,
  582. },
  583. {
  584. id: 6,
  585. code: "MG0066",
  586. type: "Material",
  587. name: "咖哩料(5斤x16包+2斤/包)",
  588. inStockQty: 0,
  589. purchaseQty: 241.98,
  590. },
  591. ],
  592. },
  593. {
  594. id: 4,
  595. code: " PP1096",
  596. type: "FG",
  597. name: "白麵撈",
  598. inStockQty: 1040,
  599. productionQty: 520,
  600. lines: [
  601. {
  602. id: 1,
  603. code: "MH0040",
  604. type: "Material",
  605. name: "大豆油(1噸/桶)",
  606. inStockQty: 0,
  607. purchaseQty: 190.0,
  608. },
  609. {
  610. id: 1,
  611. code: "MH0040",
  612. type: "Material",
  613. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  614. inStockQty: 0,
  615. purchaseQty: 250.0,
  616. },
  617. {
  618. id: 2,
  619. code: "FA0161",
  620. type: "Material",
  621. name: "蔥油",
  622. inStockQty: 1322,
  623. purchaseQty: 0,
  624. },
  625. ],
  626. },
  627. ],
  628. [
  629. {
  630. id: 1,
  631. code: "PP1080",
  632. type: "FG",
  633. name: "咖哩汁",
  634. inStockQty: 2400,
  635. productionQty: 1200.0,
  636. lines: [
  637. {
  638. id: 1,
  639. code: "MH0040",
  640. type: "Material",
  641. name: "大豆油(1噸/桶)",
  642. inStockQty: 0,
  643. purchaseQty: 108.88,
  644. },
  645. {
  646. id: 2,
  647. code: "GI3236",
  648. type: "Material",
  649. name: "清水(煮過牛腩)",
  650. inStockQty: 317.52,
  651. purchaseQty: 635.04,
  652. },
  653. {
  654. id: 3,
  655. code: "MG1700",
  656. type: "Material",
  657. name: "STERILTOM 意大利茄粒",
  658. inStockQty: 9.0,
  659. purchaseQty: 18.0,
  660. },
  661. {
  662. id: 4,
  663. code: "FA0533",
  664. type: "Material",
  665. name: "乾蔥茸",
  666. inStockQty: 6.04,
  667. purchaseQty: 12.08,
  668. },
  669. {
  670. id: 5,
  671. code: "FA0210",
  672. type: "Material",
  673. name: "薑茸",
  674. inStockQty: 0,
  675. purchaseQty: 12.08,
  676. },
  677. {
  678. id: 6,
  679. code: "FA0608",
  680. type: "Material",
  681. name: "粗蒜茸",
  682. inStockQty: 0,
  683. purchaseQty: 12.08,
  684. },
  685. {
  686. id: 7,
  687. code: "FA0056",
  688. type: "Material",
  689. name: "洋蔥肉",
  690. inStockQty: 241.98,
  691. purchaseQty: 483.96,
  692. },
  693. {
  694. id: 8,
  695. code: "PP1188",
  696. type: "Material",
  697. name: "咖喱膽",
  698. inStockQty: 36.0,
  699. purchaseQty: 72.0,
  700. },
  701. {
  702. id: 9,
  703. code: "PP8001",
  704. type: "Material",
  705. name: "咖哩汁箱料粉",
  706. inStockQty: 77.42,
  707. purchaseQty: 154.84,
  708. },
  709. {
  710. id: 10,
  711. code: "PP1096",
  712. type: "Material",
  713. name: "白麵撈",
  714. inStockQty: 60.0,
  715. purchaseQty: 120.0,
  716. },
  717. {
  718. id: 10,
  719. code: "NA0476",
  720. type: "Material",
  721. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  722. inStockQty: 600.0,
  723. purchaseQty: 200.0,
  724. },
  725. ],
  726. },
  727. {
  728. id: 2,
  729. code: "PP1193",
  730. type: "FG",
  731. name: "蔥油(1磅) ",
  732. inStockQty: 1322,
  733. productionQty: 661,
  734. lines: [
  735. {
  736. id: 1,
  737. code: "MH0040",
  738. type: "Material",
  739. name: "大豆油(1噸/桶)",
  740. inStockQty: 0,
  741. purchaseQty: 20,
  742. },
  743. {
  744. id: 2,
  745. code: "FA0161",
  746. type: "Material",
  747. name: "洋蔥粒",
  748. inStockQty: 0,
  749. purchaseQty: 10,
  750. },
  751. ],
  752. },
  753. {
  754. id: 3,
  755. code: " PP1188",
  756. type: "FG",
  757. name: "咖喱膽",
  758. inStockQty: 1016.2,
  759. productionQty: 508.1,
  760. lines: [
  761. {
  762. id: 1,
  763. code: "MH0040",
  764. type: "Material",
  765. name: "大豆油(1噸/桶)",
  766. inStockQty: 0,
  767. purchaseQty: 217.72,
  768. },
  769. {
  770. id: 2,
  771. code: "FA0161",
  772. type: "Material",
  773. name: "洋蔥粒",
  774. inStockQty: 0,
  775. purchaseQty: 18.15,
  776. },
  777. {
  778. id: 3,
  779. code: "FA0608",
  780. type: "Material",
  781. name: "粗蒜茸",
  782. inStockQty: 0,
  783. purchaseQty: 18.15,
  784. },
  785. {
  786. id: 4,
  787. code: "MG1288",
  788. type: "Material",
  789. name: "炸紅蔥頭",
  790. inStockQty: 0,
  791. purchaseQty: 6.05,
  792. },
  793. {
  794. id: 5,
  795. code: "FA0210",
  796. type: "Material",
  797. name: "薑茸",
  798. inStockQty: 0,
  799. purchaseQty: 6.05,
  800. },
  801. {
  802. id: 6,
  803. code: "MG0066",
  804. type: "Material",
  805. name: "咖哩料(5斤x16包+2斤/包)",
  806. inStockQty: 0,
  807. purchaseQty: 241.98,
  808. },
  809. ],
  810. },
  811. {
  812. id: 4,
  813. code: " PP1096",
  814. type: "FG",
  815. name: "白麵撈",
  816. inStockQty: 1040,
  817. productionQty: 520,
  818. lines: [
  819. {
  820. id: 1,
  821. code: "MH0040",
  822. type: "Material",
  823. name: "大豆油(1噸/桶)",
  824. inStockQty: 0,
  825. purchaseQty: 190.0,
  826. },
  827. {
  828. id: 1,
  829. code: "MH0040",
  830. type: "Material",
  831. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  832. inStockQty: 0,
  833. purchaseQty: 250.0,
  834. },
  835. {
  836. id: 2,
  837. code: "FA0161",
  838. type: "Material",
  839. name: "蔥油",
  840. inStockQty: 1322,
  841. purchaseQty: 0,
  842. },
  843. ],
  844. },
  845. ],
  846. [
  847. {
  848. id: 1,
  849. code: "PP1080",
  850. type: "FG",
  851. name: "咖哩汁",
  852. inStockQty: 2400,
  853. productionQty: 1200.0,
  854. lines: [
  855. {
  856. id: 1,
  857. code: "MH0040",
  858. type: "Material",
  859. name: "大豆油(1噸/桶)",
  860. inStockQty: 0,
  861. purchaseQty: 108.88,
  862. },
  863. {
  864. id: 2,
  865. code: "GI3236",
  866. type: "Material",
  867. name: "清水(煮過牛腩)",
  868. inStockQty: 317.52,
  869. purchaseQty: 635.04,
  870. },
  871. {
  872. id: 3,
  873. code: "MG1700",
  874. type: "Material",
  875. name: "STERILTOM 意大利茄粒",
  876. inStockQty: 9.0,
  877. purchaseQty: 18.0,
  878. },
  879. {
  880. id: 4,
  881. code: "FA0533",
  882. type: "Material",
  883. name: "乾蔥茸",
  884. inStockQty: 6.04,
  885. purchaseQty: 12.08,
  886. },
  887. {
  888. id: 5,
  889. code: "FA0210",
  890. type: "Material",
  891. name: "薑茸",
  892. inStockQty: 0,
  893. purchaseQty: 12.08,
  894. },
  895. {
  896. id: 6,
  897. code: "FA0608",
  898. type: "Material",
  899. name: "粗蒜茸",
  900. inStockQty: 0,
  901. purchaseQty: 12.08,
  902. },
  903. {
  904. id: 7,
  905. code: "FA0056",
  906. type: "Material",
  907. name: "洋蔥肉",
  908. inStockQty: 241.98,
  909. purchaseQty: 483.96,
  910. },
  911. {
  912. id: 8,
  913. code: "PP1188",
  914. type: "Material",
  915. name: "咖喱膽",
  916. inStockQty: 36.0,
  917. purchaseQty: 72.0,
  918. },
  919. {
  920. id: 9,
  921. code: "PP8001",
  922. type: "Material",
  923. name: "咖哩汁箱料粉",
  924. inStockQty: 77.42,
  925. purchaseQty: 154.84,
  926. },
  927. {
  928. id: 10,
  929. code: "PP1096",
  930. type: "Material",
  931. name: "白麵撈",
  932. inStockQty: 60.0,
  933. purchaseQty: 120.0,
  934. },
  935. {
  936. id: 10,
  937. code: "NA0476",
  938. type: "Material",
  939. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  940. inStockQty: 600.0,
  941. purchaseQty: 200.0,
  942. },
  943. ],
  944. },
  945. {
  946. id: 2,
  947. code: "PP1193",
  948. type: "FG",
  949. name: "蔥油(1磅) ",
  950. inStockQty: 1322,
  951. productionQty: 661,
  952. lines: [
  953. {
  954. id: 1,
  955. code: "MH0040",
  956. type: "Material",
  957. name: "大豆油(1噸/桶)",
  958. inStockQty: 0,
  959. purchaseQty: 20,
  960. },
  961. {
  962. id: 2,
  963. code: "FA0161",
  964. type: "Material",
  965. name: "洋蔥粒",
  966. inStockQty: 0,
  967. purchaseQty: 10,
  968. },
  969. ],
  970. },
  971. {
  972. id: 3,
  973. code: " PP1188",
  974. type: "FG",
  975. name: "咖喱膽",
  976. inStockQty: 1016.2,
  977. productionQty: 508.1,
  978. lines: [
  979. {
  980. id: 1,
  981. code: "MH0040",
  982. type: "Material",
  983. name: "大豆油(1噸/桶)",
  984. inStockQty: 0,
  985. purchaseQty: 217.72,
  986. },
  987. {
  988. id: 2,
  989. code: "FA0161",
  990. type: "Material",
  991. name: "洋蔥粒",
  992. inStockQty: 0,
  993. purchaseQty: 18.15,
  994. },
  995. {
  996. id: 3,
  997. code: "FA0608",
  998. type: "Material",
  999. name: "粗蒜茸",
  1000. inStockQty: 0,
  1001. purchaseQty: 18.15,
  1002. },
  1003. {
  1004. id: 4,
  1005. code: "MG1288",
  1006. type: "Material",
  1007. name: "炸紅蔥頭",
  1008. inStockQty: 0,
  1009. purchaseQty: 6.05,
  1010. },
  1011. {
  1012. id: 5,
  1013. code: "FA0210",
  1014. type: "Material",
  1015. name: "薑茸",
  1016. inStockQty: 0,
  1017. purchaseQty: 6.05,
  1018. },
  1019. {
  1020. id: 6,
  1021. code: "MG0066",
  1022. type: "Material",
  1023. name: "咖哩料(5斤x16包+2斤/包)",
  1024. inStockQty: 0,
  1025. purchaseQty: 241.98,
  1026. },
  1027. ],
  1028. },
  1029. {
  1030. id: 4,
  1031. code: " PP1096",
  1032. type: "FG",
  1033. name: "白麵撈",
  1034. inStockQty: 1040,
  1035. productionQty: 520,
  1036. lines: [
  1037. {
  1038. id: 1,
  1039. code: "MH0040",
  1040. type: "Material",
  1041. name: "大豆油(1噸/桶)",
  1042. inStockQty: 0,
  1043. purchaseQty: 190.0,
  1044. },
  1045. {
  1046. id: 1,
  1047. code: "MH0040",
  1048. type: "Material",
  1049. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1050. inStockQty: 0,
  1051. purchaseQty: 250.0,
  1052. },
  1053. {
  1054. id: 2,
  1055. code: "FA0161",
  1056. type: "Material",
  1057. name: "蔥油",
  1058. inStockQty: 1322,
  1059. purchaseQty: 0,
  1060. },
  1061. ],
  1062. },
  1063. ],
  1064. [
  1065. {
  1066. id: 1,
  1067. code: "PP1080",
  1068. name: "咖哩汁",
  1069. inStockQty: 2400,
  1070. productionQty: 1200.0,
  1071. lines: [
  1072. {
  1073. id: 1,
  1074. code: "MH0040",
  1075. name: "大豆油(1噸/桶)",
  1076. inStockQty: 0,
  1077. purchaseQty: 108.88,
  1078. },
  1079. {
  1080. id: 2,
  1081. code: "GI3236",
  1082. name: "清水(煮過牛腩)",
  1083. inStockQty: 317.52,
  1084. purchaseQty: 635.04,
  1085. },
  1086. {
  1087. id: 3,
  1088. code: "MG1700",
  1089. name: "STERILTOM 意大利茄粒",
  1090. inStockQty: 9.0,
  1091. purchaseQty: 18.0,
  1092. },
  1093. {
  1094. id: 4,
  1095. code: "FA0533",
  1096. name: "乾蔥茸",
  1097. inStockQty: 6.04,
  1098. purchaseQty: 12.08,
  1099. },
  1100. {
  1101. id: 5,
  1102. code: "FA0210",
  1103. name: "薑茸",
  1104. inStockQty: 0,
  1105. purchaseQty: 12.08,
  1106. },
  1107. {
  1108. id: 6,
  1109. code: "FA0608",
  1110. name: "粗蒜茸",
  1111. inStockQty: 0,
  1112. purchaseQty: 12.08,
  1113. },
  1114. {
  1115. id: 7,
  1116. code: "FA0056",
  1117. name: "洋蔥肉",
  1118. inStockQty: 241.98,
  1119. purchaseQty: 483.96,
  1120. },
  1121. {
  1122. id: 8,
  1123. code: "PP1188",
  1124. name: "咖喱膽",
  1125. inStockQty: 36.0,
  1126. purchaseQty: 72.0,
  1127. },
  1128. {
  1129. id: 9,
  1130. code: "PP8001",
  1131. name: "咖哩汁箱料粉",
  1132. inStockQty: 77.42,
  1133. purchaseQty: 154.84,
  1134. },
  1135. {
  1136. id: 10,
  1137. code: "PP1096",
  1138. name: "白麵撈",
  1139. inStockQty: 60.0,
  1140. purchaseQty: 120.0,
  1141. },
  1142. {
  1143. id: 10,
  1144. code: "NA0476",
  1145. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  1146. inStockQty: 600.0,
  1147. purchaseQty: 200.0,
  1148. },
  1149. ],
  1150. },
  1151. {
  1152. id: 2,
  1153. code: "PP1193",
  1154. name: "蔥油(1磅) ",
  1155. inStockQty: 1322,
  1156. productionQty: 661,
  1157. lines: [
  1158. {
  1159. id: 1,
  1160. code: "MH0040",
  1161. name: "大豆油(1噸/桶)",
  1162. inStockQty: 0,
  1163. purchaseQty: 20,
  1164. },
  1165. {
  1166. id: 2,
  1167. code: "FA0161",
  1168. name: "洋蔥粒",
  1169. inStockQty: 0,
  1170. purchaseQty: 10,
  1171. },
  1172. ],
  1173. },
  1174. {
  1175. id: 3,
  1176. code: " PP1188",
  1177. name: "咖喱膽",
  1178. inStockQty: 1016.2,
  1179. productionQty: 508.1,
  1180. lines: [
  1181. {
  1182. id: 1,
  1183. code: "MH0040",
  1184. name: "大豆油(1噸/桶)",
  1185. inStockQty: 0,
  1186. purchaseQty: 217.72,
  1187. },
  1188. {
  1189. id: 2,
  1190. code: "FA0161",
  1191. name: "洋蔥粒",
  1192. inStockQty: 0,
  1193. purchaseQty: 18.15,
  1194. },
  1195. {
  1196. id: 3,
  1197. code: "FA0608",
  1198. name: "粗蒜茸",
  1199. inStockQty: 0,
  1200. purchaseQty: 18.15,
  1201. },
  1202. {
  1203. id: 4,
  1204. code: "MG1288",
  1205. name: "炸紅蔥頭",
  1206. inStockQty: 0,
  1207. purchaseQty: 6.05,
  1208. },
  1209. {
  1210. id: 5,
  1211. code: "FA0210",
  1212. name: "薑茸",
  1213. inStockQty: 0,
  1214. purchaseQty: 6.05,
  1215. },
  1216. {
  1217. id: 6,
  1218. code: "MG0066",
  1219. name: "咖哩料(5斤x16包+2斤/包)",
  1220. inStockQty: 0,
  1221. purchaseQty: 241.98,
  1222. },
  1223. ],
  1224. },
  1225. {
  1226. id: 4,
  1227. code: " PP1096",
  1228. name: "白麵撈",
  1229. inStockQty: 1040,
  1230. productionQty: 520,
  1231. lines: [
  1232. {
  1233. id: 1,
  1234. code: "MH0040",
  1235. name: "大豆油(1噸/桶)",
  1236. inStockQty: 0,
  1237. purchaseQty: 190.0,
  1238. },
  1239. {
  1240. id: 1,
  1241. code: "MH0040",
  1242. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1243. inStockQty: 0,
  1244. purchaseQty: 250.0,
  1245. },
  1246. {
  1247. id: 2,
  1248. code: "FA0161",
  1249. name: "蔥油",
  1250. inStockQty: 1322,
  1251. purchaseQty: 0,
  1252. },
  1253. ],
  1254. },
  1255. ],
  1256. [
  1257. {
  1258. id: 1,
  1259. code: "PP1080",
  1260. type: "FG",
  1261. name: "咖哩汁",
  1262. inStockQty: 2400,
  1263. productionQty: 1200.0,
  1264. lines: [
  1265. {
  1266. id: 1,
  1267. code: "MH0040",
  1268. type: "Material",
  1269. name: "大豆油(1噸/桶)",
  1270. inStockQty: 0,
  1271. purchaseQty: 108.88,
  1272. },
  1273. {
  1274. id: 2,
  1275. code: "GI3236",
  1276. type: "Material",
  1277. name: "清水(煮過牛腩)",
  1278. inStockQty: 317.52,
  1279. purchaseQty: 635.04,
  1280. },
  1281. {
  1282. id: 3,
  1283. code: "MG1700",
  1284. type: "Material",
  1285. name: "STERILTOM 意大利茄粒",
  1286. inStockQty: 9.0,
  1287. purchaseQty: 18.0,
  1288. },
  1289. {
  1290. id: 4,
  1291. code: "FA0533",
  1292. type: "Material",
  1293. name: "乾蔥茸",
  1294. inStockQty: 6.04,
  1295. purchaseQty: 12.08,
  1296. },
  1297. {
  1298. id: 5,
  1299. code: "FA0210",
  1300. type: "Material",
  1301. name: "薑茸",
  1302. inStockQty: 0,
  1303. purchaseQty: 12.08,
  1304. },
  1305. {
  1306. id: 6,
  1307. code: "FA0608",
  1308. type: "Material",
  1309. name: "粗蒜茸",
  1310. inStockQty: 0,
  1311. purchaseQty: 12.08,
  1312. },
  1313. {
  1314. id: 7,
  1315. code: "FA0056",
  1316. type: "Material",
  1317. name: "洋蔥肉",
  1318. inStockQty: 241.98,
  1319. purchaseQty: 483.96,
  1320. },
  1321. {
  1322. id: 8,
  1323. code: "PP1188",
  1324. type: "Material",
  1325. name: "咖喱膽",
  1326. inStockQty: 36.0,
  1327. purchaseQty: 72.0,
  1328. },
  1329. {
  1330. id: 9,
  1331. code: "PP8001",
  1332. type: "Material",
  1333. name: "咖哩汁箱料粉",
  1334. inStockQty: 77.42,
  1335. purchaseQty: 154.84,
  1336. },
  1337. {
  1338. id: 10,
  1339. code: "PP1096",
  1340. type: "Material",
  1341. name: "白麵撈",
  1342. inStockQty: 60.0,
  1343. purchaseQty: 120.0,
  1344. },
  1345. {
  1346. id: 10,
  1347. code: "NA0476",
  1348. type: "Material",
  1349. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  1350. inStockQty: 600.0,
  1351. purchaseQty: 200.0,
  1352. },
  1353. ],
  1354. },
  1355. {
  1356. id: 2,
  1357. code: "PP1193",
  1358. type: "FG",
  1359. name: "蔥油(1磅) ",
  1360. inStockQty: 1322,
  1361. productionQty: 661,
  1362. lines: [
  1363. {
  1364. id: 1,
  1365. code: "MH0040",
  1366. type: "Material",
  1367. name: "大豆油(1噸/桶)",
  1368. inStockQty: 0,
  1369. purchaseQty: 20,
  1370. },
  1371. {
  1372. id: 2,
  1373. code: "FA0161",
  1374. type: "Material",
  1375. name: "洋蔥粒",
  1376. inStockQty: 0,
  1377. purchaseQty: 10,
  1378. },
  1379. ],
  1380. },
  1381. {
  1382. id: 3,
  1383. code: " PP1188",
  1384. type: "FG",
  1385. name: "咖喱膽",
  1386. inStockQty: 1016.2,
  1387. productionQty: 508.1,
  1388. lines: [
  1389. {
  1390. id: 1,
  1391. code: "MH0040",
  1392. type: "Material",
  1393. name: "大豆油(1噸/桶)",
  1394. inStockQty: 0,
  1395. purchaseQty: 217.72,
  1396. },
  1397. {
  1398. id: 2,
  1399. code: "FA0161",
  1400. type: "Material",
  1401. name: "洋蔥粒",
  1402. inStockQty: 0,
  1403. purchaseQty: 18.15,
  1404. },
  1405. {
  1406. id: 3,
  1407. code: "FA0608",
  1408. type: "Material",
  1409. name: "粗蒜茸",
  1410. inStockQty: 0,
  1411. purchaseQty: 18.15,
  1412. },
  1413. {
  1414. id: 4,
  1415. code: "MG1288",
  1416. type: "Material",
  1417. name: "炸紅蔥頭",
  1418. inStockQty: 0,
  1419. purchaseQty: 6.05,
  1420. },
  1421. {
  1422. id: 5,
  1423. code: "FA0210",
  1424. type: "Material",
  1425. name: "薑茸",
  1426. inStockQty: 0,
  1427. purchaseQty: 6.05,
  1428. },
  1429. {
  1430. id: 6,
  1431. code: "MG0066",
  1432. type: "Material",
  1433. name: "咖哩料(5斤x16包+2斤/包)",
  1434. inStockQty: 0,
  1435. purchaseQty: 241.98,
  1436. },
  1437. ],
  1438. },
  1439. {
  1440. id: 4,
  1441. code: " PP1096",
  1442. type: "FG",
  1443. name: "白麵撈",
  1444. inStockQty: 1040,
  1445. productionQty: 520,
  1446. lines: [
  1447. {
  1448. id: 1,
  1449. code: "MH0040",
  1450. type: "Material",
  1451. name: "大豆油(1噸/桶)",
  1452. inStockQty: 0,
  1453. purchaseQty: 190.0,
  1454. },
  1455. {
  1456. id: 1,
  1457. code: "MH0040",
  1458. type: "Material",
  1459. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1460. inStockQty: 0,
  1461. purchaseQty: 250.0,
  1462. },
  1463. {
  1464. id: 2,
  1465. code: "FA0161",
  1466. type: "Material",
  1467. name: "蔥油",
  1468. inStockQty: 1322,
  1469. purchaseQty: 0,
  1470. },
  1471. ],
  1472. },
  1473. ],
  1474. [
  1475. {
  1476. id: 1,
  1477. code: "PP1080",
  1478. type: "FG",
  1479. name: "咖哩汁",
  1480. inStockQty: 2400,
  1481. productionQty: 1200.0,
  1482. lines: [
  1483. {
  1484. id: 1,
  1485. code: "MH0040",
  1486. type: "Material",
  1487. name: "大豆油(1噸/桶)",
  1488. inStockQty: 0,
  1489. purchaseQty: 108.88,
  1490. },
  1491. {
  1492. id: 2,
  1493. code: "GI3236",
  1494. type: "Material",
  1495. name: "清水(煮過牛腩)",
  1496. inStockQty: 317.52,
  1497. purchaseQty: 635.04,
  1498. },
  1499. {
  1500. id: 3,
  1501. code: "MG1700",
  1502. type: "Material",
  1503. name: "STERILTOM 意大利茄粒",
  1504. inStockQty: 9.0,
  1505. purchaseQty: 18.0,
  1506. },
  1507. {
  1508. id: 4,
  1509. code: "FA0533",
  1510. type: "Material",
  1511. name: "乾蔥茸",
  1512. inStockQty: 6.04,
  1513. purchaseQty: 12.08,
  1514. },
  1515. {
  1516. id: 5,
  1517. code: "FA0210",
  1518. type: "Material",
  1519. name: "薑茸",
  1520. inStockQty: 0,
  1521. purchaseQty: 12.08,
  1522. },
  1523. {
  1524. id: 6,
  1525. code: "FA0608",
  1526. type: "Material",
  1527. name: "粗蒜茸",
  1528. inStockQty: 0,
  1529. purchaseQty: 12.08,
  1530. },
  1531. {
  1532. id: 7,
  1533. code: "FA0056",
  1534. type: "Material",
  1535. name: "洋蔥肉",
  1536. inStockQty: 241.98,
  1537. purchaseQty: 483.96,
  1538. },
  1539. {
  1540. id: 8,
  1541. code: "PP1188",
  1542. type: "Material",
  1543. name: "咖喱膽",
  1544. inStockQty: 36.0,
  1545. purchaseQty: 72.0,
  1546. },
  1547. {
  1548. id: 9,
  1549. code: "PP8001",
  1550. type: "Material",
  1551. name: "咖哩汁箱料粉",
  1552. inStockQty: 77.42,
  1553. purchaseQty: 154.84,
  1554. },
  1555. {
  1556. id: 10,
  1557. code: "PP1096",
  1558. type: "Material",
  1559. name: "白麵撈",
  1560. inStockQty: 60.0,
  1561. purchaseQty: 120.0,
  1562. },
  1563. {
  1564. id: 10,
  1565. code: "NA0476",
  1566. type: "Material",
  1567. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  1568. inStockQty: 600.0,
  1569. purchaseQty: 200.0,
  1570. },
  1571. ],
  1572. },
  1573. {
  1574. id: 2,
  1575. code: "PP1193",
  1576. type: "FG",
  1577. name: "蔥油(1磅) ",
  1578. inStockQty: 1322,
  1579. productionQty: 661,
  1580. lines: [
  1581. {
  1582. id: 1,
  1583. code: "MH0040",
  1584. type: "Material",
  1585. name: "大豆油(1噸/桶)",
  1586. inStockQty: 0,
  1587. purchaseQty: 20,
  1588. },
  1589. {
  1590. id: 2,
  1591. code: "FA0161",
  1592. type: "Material",
  1593. name: "洋蔥粒",
  1594. inStockQty: 0,
  1595. purchaseQty: 10,
  1596. },
  1597. ],
  1598. },
  1599. {
  1600. id: 3,
  1601. code: " PP1188",
  1602. type: "FG",
  1603. name: "咖喱膽",
  1604. inStockQty: 1016.2,
  1605. productionQty: 508.1,
  1606. lines: [
  1607. {
  1608. id: 1,
  1609. code: "MH0040",
  1610. type: "Material",
  1611. name: "大豆油(1噸/桶)",
  1612. inStockQty: 0,
  1613. purchaseQty: 217.72,
  1614. },
  1615. {
  1616. id: 2,
  1617. code: "FA0161",
  1618. type: "Material",
  1619. name: "洋蔥粒",
  1620. inStockQty: 0,
  1621. purchaseQty: 18.15,
  1622. },
  1623. {
  1624. id: 3,
  1625. code: "FA0608",
  1626. type: "Material",
  1627. name: "粗蒜茸",
  1628. inStockQty: 0,
  1629. purchaseQty: 18.15,
  1630. },
  1631. {
  1632. id: 4,
  1633. code: "MG1288",
  1634. type: "Material",
  1635. name: "炸紅蔥頭",
  1636. inStockQty: 0,
  1637. purchaseQty: 6.05,
  1638. },
  1639. {
  1640. id: 5,
  1641. code: "FA0210",
  1642. type: "Material",
  1643. name: "薑茸",
  1644. inStockQty: 0,
  1645. purchaseQty: 6.05,
  1646. },
  1647. {
  1648. id: 6,
  1649. code: "MG0066",
  1650. type: "Material",
  1651. name: "咖哩料(5斤x16包+2斤/包)",
  1652. inStockQty: 0,
  1653. purchaseQty: 241.98,
  1654. },
  1655. ],
  1656. },
  1657. {
  1658. id: 4,
  1659. code: " PP1096",
  1660. type: "FG",
  1661. name: "白麵撈",
  1662. inStockQty: 1040,
  1663. productionQty: 520,
  1664. lines: [
  1665. {
  1666. id: 1,
  1667. code: "MH0040",
  1668. type: "Material",
  1669. name: "大豆油(1噸/桶)",
  1670. inStockQty: 0,
  1671. purchaseQty: 190.0,
  1672. },
  1673. {
  1674. id: 1,
  1675. code: "MH0040",
  1676. type: "Material",
  1677. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1678. inStockQty: 0,
  1679. purchaseQty: 250.0,
  1680. },
  1681. {
  1682. id: 2,
  1683. code: "FA0161",
  1684. type: "Material",
  1685. name: "蔥油",
  1686. inStockQty: 1322,
  1687. purchaseQty: 0,
  1688. },
  1689. ],
  1690. },
  1691. ],
  1692. ],
  1693. [],
  1694. );
  1695. const [pagingController, setPagingController] = useState([
  1696. {
  1697. pageNum: 1,
  1698. pageSize: 10,
  1699. totalCount: 0,
  1700. },
  1701. {
  1702. pageNum: 1,
  1703. pageSize: 10,
  1704. totalCount: 0,
  1705. },
  1706. {
  1707. pageNum: 1,
  1708. pageSize: 10,
  1709. totalCount: 0,
  1710. },
  1711. {
  1712. pageNum: 1,
  1713. pageSize: 10,
  1714. totalCount: 0,
  1715. },
  1716. {
  1717. pageNum: 1,
  1718. pageSize: 10,
  1719. totalCount: 0,
  1720. },
  1721. {
  1722. pageNum: 1,
  1723. pageSize: 10,
  1724. totalCount: 0,
  1725. },
  1726. {
  1727. pageNum: 1,
  1728. pageSize: 10,
  1729. totalCount: 0,
  1730. },
  1731. {
  1732. pageNum: 1,
  1733. pageSize: 10,
  1734. totalCount: 0,
  1735. },
  1736. ]);
  1737. const updatePagingController = (updatedObj: any) => {
  1738. setPagingController((prevState) => {
  1739. return prevState.map((item, index) => {
  1740. if (index === updatedObj?.index) {
  1741. return {
  1742. ...item,
  1743. pageNum: item.pageNum,
  1744. pageSize: item.pageSize,
  1745. totalCount: item.totalCount,
  1746. };
  1747. } else return item;
  1748. });
  1749. });
  1750. };
  1751. const columns = useMemo<Column<any>[]>(
  1752. () => [
  1753. {
  1754. field: "jobNo",
  1755. label: t("Job No."),
  1756. type: "read-only",
  1757. // editable: true,
  1758. },
  1759. {
  1760. field: "code",
  1761. label: t("code"),
  1762. type: "read-only",
  1763. // editable: true,
  1764. },
  1765. {
  1766. field: "name",
  1767. label: t("name"),
  1768. type: "read-only",
  1769. },
  1770. {
  1771. field: "type",
  1772. label: t("type"),
  1773. type: "read-only",
  1774. // editable: true,
  1775. },
  1776. // {
  1777. // field: "inStockQty",
  1778. // label: "Available Qty",
  1779. // type: 'read-only',
  1780. // style: {
  1781. // textAlign: "right",
  1782. // },
  1783. // // editable: true,
  1784. // renderCell: (row: FGRecord) => {
  1785. // if (typeof (row.inStockQty) == "number") {
  1786. // return decimalFormatter.format(row.inStockQty)
  1787. // }
  1788. // return row.inStockQty
  1789. // }
  1790. // },
  1791. {
  1792. field: "productionQty",
  1793. label: t("Demand Qty"),
  1794. type: "input",
  1795. style: {
  1796. textAlign: "right",
  1797. },
  1798. renderCell: (row: FGRecord) => {
  1799. if (typeof row.productionQty == "number") {
  1800. return decimalFormatter.format(row.productionQty ?? 0);
  1801. }
  1802. return row.productionQty;
  1803. },
  1804. },
  1805. {
  1806. field: "estimatedProductionTime",
  1807. label: t("Estimated Production Time"),
  1808. type: "read-only",
  1809. style: {
  1810. textAlign: "right",
  1811. },
  1812. },
  1813. {
  1814. field: "priority",
  1815. label: t("Production Priority"),
  1816. type: "read-only",
  1817. style: {
  1818. textAlign: "right",
  1819. },
  1820. // editable: true,
  1821. },
  1822. ],
  1823. [],
  1824. );
  1825. const overallColumns = useMemo<Column<any>[]>(
  1826. () => [
  1827. {
  1828. field: "code",
  1829. label: t("code"),
  1830. type: "read-only",
  1831. // editable: true,
  1832. },
  1833. {
  1834. field: "name",
  1835. label: t("name"),
  1836. type: "read-only",
  1837. },
  1838. {
  1839. field: "type",
  1840. label: t("type"),
  1841. type: "read-only",
  1842. // editable: true,
  1843. },
  1844. {
  1845. field: "lastMonthAvgStock",
  1846. label: t("Last Month Average Stock"),
  1847. type: "read-only",
  1848. style: {
  1849. textAlign: "right",
  1850. },
  1851. renderCell: (row: FGRecord) => {
  1852. if (typeof row.lastMonthAvgStock == "number") {
  1853. return decimalFormatter.format(row.lastMonthAvgStock);
  1854. }
  1855. return row.lastMonthAvgStock;
  1856. },
  1857. // editable: true,
  1858. },
  1859. {
  1860. field: "safetyStock",
  1861. label: t("Safety Stock"),
  1862. type: "read-only",
  1863. style: {
  1864. textAlign: "right",
  1865. },
  1866. renderCell: (row: FGRecord) => {
  1867. if (typeof row.safetyStock == "number") {
  1868. return decimalFormatter.format(row.safetyStock);
  1869. }
  1870. return row.safetyStock;
  1871. },
  1872. // editable: true,
  1873. },
  1874. {
  1875. field: "inStockQty",
  1876. label: t("Available Qty"),
  1877. type: "read-only",
  1878. style: {
  1879. textAlign: "right",
  1880. },
  1881. renderCell: (row: FGRecord) => {
  1882. if (typeof row.inStockQty == "number") {
  1883. return decimalFormatter.format(row.inStockQty);
  1884. }
  1885. return row.inStockQty;
  1886. },
  1887. // editable: true,
  1888. },
  1889. {
  1890. field: "productionQty",
  1891. label: t("Demand Qty (7 Days)"),
  1892. type: "read-only",
  1893. style: {
  1894. textAlign: "right",
  1895. },
  1896. renderCell: (row: FGRecord) => {
  1897. if (typeof row.productionQty == "number") {
  1898. return decimalFormatter.format(row.productionQty);
  1899. }
  1900. return row.productionQty;
  1901. },
  1902. },
  1903. ],
  1904. [],
  1905. );
  1906. const fakeOverallRecords = useMemo<FGRecord[]>(
  1907. () => [
  1908. {
  1909. id: 1,
  1910. jobNo: "JO20250507001",
  1911. priority: 20,
  1912. code: "PP1193",
  1913. type: "FG",
  1914. name: "蔥油(1磅) ",
  1915. lastMonthAvgStock: 1320,
  1916. safetyStock: 1322,
  1917. inStockQty: 1322,
  1918. productionQty: 4627,
  1919. lines: [
  1920. {
  1921. id: 2,
  1922. code: "MH0040",
  1923. type: "Material",
  1924. name: "大豆油(1噸/桶)",
  1925. inStockQty: 0,
  1926. purchaseQty: 20 * 7,
  1927. },
  1928. {
  1929. id: 3,
  1930. code: "FA0161",
  1931. type: "Material",
  1932. name: "洋蔥粒",
  1933. inStockQty: 0,
  1934. purchaseQty: 10 * 7,
  1935. },
  1936. ],
  1937. },
  1938. {
  1939. id: 2,
  1940. jobNo: "JO20250507002",
  1941. priority: 25,
  1942. code: " PP1096",
  1943. type: "FG",
  1944. name: "白麵撈",
  1945. lastMonthAvgStock: 1040,
  1946. safetyStock: 1040,
  1947. inStockQty: 1040,
  1948. productionQty: 3640,
  1949. lines: [
  1950. {
  1951. id: 1,
  1952. code: "MH0040",
  1953. type: "Material",
  1954. name: "大豆油(1噸/桶)",
  1955. inStockQty: 0,
  1956. purchaseQty: 190.0 * 7,
  1957. },
  1958. {
  1959. id: 1,
  1960. code: "MH0040",
  1961. type: "Material",
  1962. name: "星加坡綠富貴花牌幼白麵粉 (50磅/包)",
  1963. inStockQty: 0,
  1964. purchaseQty: 250.0 * 7,
  1965. },
  1966. {
  1967. id: 2,
  1968. code: "FA0161",
  1969. type: "Material",
  1970. name: "蔥油",
  1971. inStockQty: 1322,
  1972. purchaseQty: 0,
  1973. },
  1974. ],
  1975. },
  1976. {
  1977. id: 3,
  1978. jobNo: "JO20250507003",
  1979. priority: 70,
  1980. code: "PP1080",
  1981. type: "FG",
  1982. name: "咖哩汁",
  1983. lastMonthAvgStock: 2400,
  1984. safetyStock: 2400,
  1985. inStockQty: 2400,
  1986. productionQty: 8400.0 * 7,
  1987. lines: [
  1988. {
  1989. id: 1,
  1990. code: "MH0040",
  1991. type: "Material",
  1992. name: "大豆油(1噸/桶)",
  1993. inStockQty: 54.44,
  1994. purchaseQty: 544.4 * 7,
  1995. },
  1996. {
  1997. id: 2,
  1998. code: "GI3236",
  1999. type: "Material",
  2000. name: "清水(煮過牛腩)",
  2001. inStockQty: 317.52,
  2002. purchaseQty: 3175.2 * 7,
  2003. },
  2004. {
  2005. id: 3,
  2006. code: "MG1700",
  2007. type: "Material",
  2008. name: "STERILTOM 意大利茄粒",
  2009. inStockQty: 9.0,
  2010. purchaseQty: 90 * 7,
  2011. },
  2012. {
  2013. id: 4,
  2014. code: "FA0533",
  2015. type: "Material",
  2016. name: "乾蔥茸",
  2017. inStockQty: 6.04,
  2018. purchaseQty: 60.4 * 7,
  2019. },
  2020. {
  2021. id: 5,
  2022. code: "FA0210",
  2023. type: "Material",
  2024. name: "薑茸",
  2025. inStockQty: 6.04,
  2026. purchaseQty: 60.4 * 7,
  2027. },
  2028. {
  2029. id: 6,
  2030. code: "FA0608",
  2031. type: "Material",
  2032. name: "粗蒜茸",
  2033. inStockQty: 6.04,
  2034. purchaseQty: 60.4 * 7,
  2035. },
  2036. {
  2037. id: 7,
  2038. code: "FA0056",
  2039. type: "Material",
  2040. name: "洋蔥肉",
  2041. inStockQty: 241.98,
  2042. purchaseQty: 2419.8 * 7,
  2043. },
  2044. {
  2045. id: 8,
  2046. code: "PP1188",
  2047. type: "Material",
  2048. name: "咖喱膽",
  2049. inStockQty: 36.0,
  2050. purchaseQty: 360 * 7,
  2051. },
  2052. {
  2053. id: 9,
  2054. code: "PP8001",
  2055. type: "Material",
  2056. name: "咖哩汁箱料粉",
  2057. inStockQty: 77.42,
  2058. purchaseQty: 774.2 * 7,
  2059. },
  2060. {
  2061. id: 10,
  2062. code: "PP1096",
  2063. type: "Material",
  2064. name: "白麵撈",
  2065. inStockQty: 60.0,
  2066. purchaseQty: 600 * 7,
  2067. },
  2068. {
  2069. id: 10,
  2070. code: "NA0476",
  2071. type: "Material",
  2072. name: "2磅份量三邊覆合袋 (0.1x225x260mm)個計",
  2073. inStockQty: 600.0,
  2074. purchaseQty: 6000 * 7,
  2075. },
  2076. ],
  2077. },
  2078. {
  2079. id: 4,
  2080. jobNo: "JO20250507004",
  2081. priority: 80,
  2082. code: " PP1188",
  2083. type: "FG",
  2084. name: "咖喱膽",
  2085. lastMonthAvgStock: 1017,
  2086. safetyStock: 1017,
  2087. inStockQty: 1016.2,
  2088. productionQty: 3556.7,
  2089. lines: [
  2090. {
  2091. id: 1,
  2092. code: "MH0040",
  2093. type: "Material",
  2094. name: "大豆油(1噸/桶)",
  2095. inStockQty: 0,
  2096. purchaseQty: 217.72 * 7,
  2097. },
  2098. {
  2099. id: 2,
  2100. code: "FA0161",
  2101. type: "Material",
  2102. name: "洋蔥粒",
  2103. inStockQty: 0,
  2104. purchaseQty: 18.15 * 7,
  2105. },
  2106. {
  2107. id: 3,
  2108. code: "FA0608",
  2109. type: "Material",
  2110. name: "粗蒜茸",
  2111. inStockQty: 0,
  2112. purchaseQty: 18.15 * 7,
  2113. },
  2114. {
  2115. id: 4,
  2116. code: "MG1288",
  2117. type: "Material",
  2118. name: "炸紅蔥頭",
  2119. inStockQty: 0,
  2120. purchaseQty: 6.05 * 7,
  2121. },
  2122. {
  2123. id: 5,
  2124. code: "FA0210",
  2125. type: "Material",
  2126. name: "薑茸",
  2127. inStockQty: 0,
  2128. purchaseQty: 6.05 * 7,
  2129. },
  2130. {
  2131. id: 6,
  2132. code: "MG0066",
  2133. type: "Material",
  2134. name: "咖哩料(5斤x16包+2斤/包)",
  2135. inStockQty: 0,
  2136. purchaseQty: 241.98 * 7,
  2137. },
  2138. ],
  2139. },
  2140. ],
  2141. [],
  2142. );
  2143. return (
  2144. <Grid container spacing={2}>
  2145. {/* <Grid item xs={12} key={"all"}>
  2146. <Typography variant="overline" display="block" marginBlockEnd={1}>
  2147. {t("FG Demand List (7 Days)")}
  2148. </Typography>
  2149. <EditableSearchResults<FGRecord>
  2150. index={7}
  2151. items={fakeOverallRecords}
  2152. columns={overallColumns}
  2153. setPagingController={updatePagingController}
  2154. pagingController={pagingController[7]}
  2155. isAutoPaging={false}
  2156. isEditable={false}
  2157. isEdit={isEdit}
  2158. hasCollapse={true}
  2159. />
  2160. </Grid> */}
  2161. {dayPeriod.map((date, index) => (
  2162. <Grid item xs={12} key={index}>
  2163. {/* <Typography variant="overline" display="block" marginBlockEnd={1}>
  2164. {`${t("FG Demand Date")}: ${date}`}
  2165. </Typography> */}
  2166. <EditableSearchResults<FGRecord>
  2167. index={1}
  2168. items={fakeRecords[index]} // Use the corresponding records for the day
  2169. columns={columns}
  2170. setPagingController={updatePagingController}
  2171. pagingController={pagingController[index]}
  2172. isAutoPaging={false}
  2173. isEditable={true}
  2174. isEdit={isEdit}
  2175. hasCollapse={true}
  2176. />
  2177. </Grid>
  2178. ))}
  2179. </Grid>
  2180. );
  2181. };
  2182. export default ViewByFGDetails;