FPSMS-frontend
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

545 linhas
21 KiB

  1. /** FP-MTMS Version Checklist | Functions Ref. No. 39 | v1.0.0 | 2026-08-03 */
  2. export type FieldType = 'date' | 'text' | 'select' | 'number' | 'checkbox';
  3. import { NEXT_PUBLIC_API_URL } from "@/config/api";
  4. export interface ReportField {
  5. label: string;
  6. name: string;
  7. type: FieldType;
  8. placeholder?: string;
  9. required: boolean;
  10. options?: { label: string; value: string }[]; // For select types
  11. multiple?: boolean; // For select types - allow multiple selection
  12. dynamicOptions?: boolean; // For select types - load options dynamically
  13. dynamicOptionsEndpoint?: string; // API endpoint to fetch dynamic options
  14. dynamicOptionsParam?: string; // Parameter name to pass when fetching options
  15. allowInput?: boolean; // Allow user to input custom values (for select types)
  16. /** When checkbox is checked, disable these field names (by `name`) */
  17. disablesFieldsWhenChecked?: string[];
  18. /** For date fields: restrict picker so value cannot be before today */
  19. minDate?: 'today';
  20. /** Disable the input (e.g. date locked to today) */
  21. disabled?: boolean;
  22. }
  23. export type ReportResponseType = 'pdf' | 'excel';
  24. export interface ReportDefinition {
  25. id: string;
  26. title: string;
  27. apiEndpoint: string;
  28. /** When 'excel', report page fetches JSON and builds .xlsx for download. Default 'pdf'. */
  29. responseType?: ReportResponseType;
  30. fields: ReportField[];
  31. }
  32. /** FP-MTMS Version Checklist | Functions Ref. No. 69 | v1.0.1 | 2026-08-31 */
  33. export const REPORTS: ReportDefinition[] = [
  34. //{
  35. // id: "rep-001",
  36. // title: "報告 1",
  37. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report1`,
  38. // fields: [
  39. // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
  40. // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
  41. // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
  42. // { label: "Item Type", name: "itemType", type: "select", required: false,
  43. // options: [
  44. // { label: "FG", value: "FG" },
  45. // { label: "Material", value: "Mat" }
  46. // ] },
  47. // ]
  48. //},
  49. //{
  50. // id: "rep-002",
  51. // title: "報告 2",
  52. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report2`,
  53. // fields: [
  54. // { label: "Target Date", name: "targetDate", type: "date", required: false },
  55. // { label: "Item Code", name: "itemCode", type: "text", required: false },
  56. // { label: "Shift", name: "shift", type: "select", options: [
  57. // { label: "Day", value: "D" },
  58. // { label: "Night", value: "N" }
  59. // ], required: false}
  60. // ]
  61. //},
  62. //{
  63. // id: "rep-003",
  64. // title: "報告 3",
  65. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report3`,
  66. // fields: [
  67. // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
  68. // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
  69. // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
  70. // { label: "Item Type", name: "itemType", type: "select", required: false,
  71. // options: [
  72. // { label: "FG", value: "FG" },
  73. // { label: "Material", value: "Mat" }
  74. // ] },
  75. // ]
  76. //},
  77. {
  78. id: "rep-004",
  79. title: "入倉追蹤報告",
  80. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-in-traceability`,
  81. fields: [
  82. { label: "入倉日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  83. { label: "入倉日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  84. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  85. {
  86. label: "樓層 Store ID",
  87. name: "storeId",
  88. type: "select",
  89. required: false,
  90. options: [
  91. { label: "全部", value: "All" },
  92. { label: "1F", value: "1F" },
  93. { label: "2F", value: "2F" },
  94. { label: "3F", value: "3F" },
  95. { label: "4F", value: "4F" },
  96. ],
  97. },
  98. { label: "倉庫 Warehouse", name: "warehouse", type: "text", required: false, placeholder: "e.g. W201" },
  99. { label: "區域 Area", name: "area", type: "text", required: false, placeholder: "e.g. #A" },
  100. { label: "儲位 Slot", name: "slot", type: "text", required: false, placeholder: "e.g. 01" },
  101. { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
  102. {
  103. label: "PP/PF 分類",
  104. name: "poPrefix",
  105. type: "select",
  106. required: false,
  107. options: [
  108. { label: "全部", value: "All" },
  109. { label: "PP", value: "PP" },
  110. { label: "PF", value: "PF" },
  111. ],
  112. },
  113. ]
  114. },
  115. {
  116. id: "rep-008",
  117. title: "成品出倉報告",
  118. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-delivery-report`,
  119. fields: [
  120. { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  121. { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  122. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  123. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  124. ]
  125. },
  126. /*
  127. { id: "rep-012",
  128. title: "庫存盤點報告",
  129. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance`,
  130. fields: [
  131. { label: "盤點日期:由 Stock Take Date Start", name: "stockTakeDateStart", type: "date", required: false },
  132. { label: "盤點日期:至 Stock Take Date End", name: "stockTakeDateEnd", type: "date", required: false },
  133. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  134. ]
  135. },
  136. */
  137. {
  138. id: "rep-012",
  139. title: "庫存盤點報告",
  140. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance-v2`,
  141. fields: [
  142. {
  143. label: "盤點輪次(可多選)",
  144. name: "stockTakeRoundId",
  145. type: "select",
  146. required: true,
  147. multiple: true,
  148. dynamicOptions: true,
  149. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
  150. options: []
  151. },
  152. { label: "貨品編號", name: "itemCode", type: "text", required: false},
  153. {
  154. label: "倉庫樓層",
  155. name: "store_id",
  156. type: "select",
  157. required: false,
  158. options: [
  159. { label: "全部", value: "All" },
  160. { label: "1F", value: "1F" },
  161. { label: "2F", value: "2F" },
  162. { label: "3F", value: "3F" },
  163. { label: "4F", value: "4F" }
  164. ],
  165. },
  166. {
  167. label: "狀態",
  168. name: "status",
  169. type: "select",
  170. required: false,
  171. options: [
  172. { label: "全部", value: "All" },
  173. { label: "待盤點", value: "pending" },
  174. { label: "已審核", value: "completed" }
  175. ],
  176. },
  177. {
  178. label: "類型",
  179. name: "type",
  180. type: "select",
  181. required: false,
  182. multiple: true,
  183. options: [
  184. { label: "全部", value: "All" },
  185. { label: "PP", value: "PP" },
  186. { label: "PF", value: "PF" },
  187. { label: "TOA", value: "TOA" },
  188. { label: "工廠生產", value: "工廠生產" },
  189. { label: "倉存調整", value: "倉存調整" },
  190. { label: "期初存貨", value: "期初存貨" },
  191. { label: "採購入倉", value: "採購入倉" },
  192. { label: "其他入倉", value: "其他入倉" },
  193. ],
  194. },
  195. ]
  196. },
  197. /* Hidden for now: 庫存批次結餘報告 (rep-019)
  198. {
  199. id: "rep-019",
  200. title: "庫存批次結餘報告",
  201. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-balance`,
  202. responseType: "excel",
  203. fields: [
  204. { label: "庫存日期 Stock Date(僅今天)", name: "stockDate", type: "date", required: true, disabled: true },
  205. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  206. { label: "倉位 Warehouse Code", name: "warehouseCode", type: "text", required: false, placeholder: "e.g. W200 or 2F-W200-#A-00" },
  207. {
  208. label: "樓層 Store ID",
  209. name: "storeId",
  210. type: "select",
  211. required: false,
  212. options: [
  213. { label: "全部", value: "All" },
  214. { label: "1F", value: "1F" },
  215. { label: "2F", value: "2F" },
  216. { label: "3F", value: "3F" },
  217. { label: "4F", value: "4F" },
  218. ],
  219. },
  220. { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
  221. ],
  222. },
  223. */
  224. {
  225. id: "rep-021",
  226. title: "庫存批次現況報告",
  227. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-onhand`,
  228. responseType: "excel",
  229. fields: [
  230. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  231. {
  232. label: "樓層 Store ID",
  233. name: "storeId",
  234. type: "select",
  235. required: false,
  236. options: [
  237. { label: "全部", value: "All" },
  238. { label: "1F", value: "1F" },
  239. { label: "2F", value: "2F" },
  240. { label: "3F", value: "3F" },
  241. { label: "4F", value: "4F" },
  242. ],
  243. },
  244. { label: "倉庫 Warehouse", name: "warehouse", type: "text", required: false, placeholder: "e.g. W201" },
  245. { label: "區域 Area", name: "area", type: "text", required: false, placeholder: "e.g. #A" },
  246. { label: "儲位 Slot", name: "slot", type: "text", required: false, placeholder: "e.g. 02" },
  247. {
  248. label: "盤點區域說明 Stock Take Section",
  249. name: "stockTakeSectionDescription",
  250. type: "select",
  251. required: false,
  252. dynamicOptions: true,
  253. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/warehouse/stockTakeSections`,
  254. options: [{ label: "全部", value: "All" }],
  255. },
  256. { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
  257. {
  258. label: "來源 Lot Origin",
  259. name: "lotOrigin",
  260. type: "select",
  261. required: false,
  262. options: [
  263. { label: "全部", value: "All" },
  264. { label: "PP", value: "PP" },
  265. { label: "PF", value: "PF" },
  266. { label: "其他", value: "other" },
  267. ],
  268. },
  269. ],
  270. },
  271. { id: "rep-011",
  272. title: "庫存明細報告",
  273. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-ledger`,
  274. fields: [
  275. { label: "庫存日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  276. { label: "庫存日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  277. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  278. ]
  279. },
  280. /* Hidden for now: 庫存流水帳報告 (rep-020)
  281. {
  282. id: "rep-020",
  283. title: "庫存流水帳報告",
  284. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-ledger`,
  285. responseType: "excel",
  286. fields: [
  287. { label: "期間起 Period From(永遠該月1日)", name: "lastInDateStart", type: "date", required: true },
  288. { label: "期間迄 Period To", name: "lastInDateEnd", type: "date", required: true },
  289. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  290. ],
  291. },
  292. */
  293. /*
  294. {
  295. id: "rep-007",
  296. title: "庫存結餘報告",
  297. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
  298. fields: [
  299. {
  300. label: "盤點輪次 Stock Take Round",
  301. name: "stockTakeRoundId",
  302. type: "select",
  303. required: true,
  304. dynamicOptions: true,
  305. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
  306. options: []
  307. },
  308. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  309. ]
  310. },
  311. */
  312. {
  313. id: "rep-007",
  314. title: "庫存結餘報告",
  315. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
  316. fields: [
  317. { label: "庫存日期: Stock Date", name: "stockDate", type: "date", required: true },
  318. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  319. ]
  320. },
  321. {
  322. id: "rep-014",
  323. title: "PO入倉記錄報告",
  324. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/grn-report`,
  325. responseType: "excel",
  326. fields: [
  327. { label: "收貨日期:由 Receipt Date Start", name: "receiptDateStart", type: "date", required: false },
  328. { label: "收貨日期:至 Receipt Date End", name: "receiptDateEnd", type: "date", required: false },
  329. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  330. ],
  331. },
  332. { id: "rep-009",
  333. title: "成品出倉追蹤報告",
  334. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-stock-out-traceability`,
  335. fields: [
  336. { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  337. { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  338. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  339. { label: "提料員 Handler", name: "handler", type: "select", required: false,
  340. multiple: true,
  341. dynamicOptions: true,
  342. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/fg-stock-out-traceability-handlers`,
  343. options: [] },
  344. ]
  345. },
  346. { id: "rep-010",
  347. /** FP-MTMS Version Checklist | Functions Ref. No. 64 | v1.0.0 | 2026-08-11 */
  348. title: "庫存品質檢測報告",
  349. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-item-qc-fail`,
  350. fields: [
  351. { label: "QC 檢測日期:由 QC Date Start", name: "lastInDateStart", type: "date", required: false },
  352. { label: "QC 檢測日期:至 QC Date End", name: "lastInDateEnd", type: "date", required: false },
  353. { label: "QC 類型", name: "qcType", type: "select", required: false,
  354. options: [
  355. { label: "全部", value: "all" },
  356. { label: "IQC(採購)", value: "IQC" },
  357. { label: "EPQC(工單)", value: "EPQC" },
  358. ] },
  359. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  360. {
  361. label: "QC 項目範圍",
  362. name: "qcItemScope",
  363. type: "select",
  364. required: false,
  365. options: [
  366. { label: "全部 QC 項目", value: "all" },
  367. { label: "只包含溫度濕度", value: "measurable" },
  368. ],
  369. },
  370. ]
  371. },
  372. { id: "rep-013",
  373. title: "貨品出倉追蹤報告",
  374. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-material-stock-out-traceability`,
  375. fields: [
  376. { label: "出倉日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  377. { label: "出倉日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  378. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  379. { label: "提料人 Handler", name: "handler", type: "select", required: false,
  380. multiple: true,
  381. dynamicOptions: true,
  382. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/material-stock-out-traceability-handlers`,
  383. options: [] },
  384. ]
  385. },
  386. {
  387. id: "rep-006",
  388. title: "庫存材料消耗趨勢報告",
  389. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-item-consumption-trend`,
  390. fields: [
  391. { label: "材料消耗日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  392. { label: "材料消耗日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  393. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  394. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  395. multiple: true,
  396. options: [
  397. { label: "All", value: "All" },
  398. { label: "MAT", value: "MAT" },
  399. { label: "WIP", value: "WIP" },
  400. { label: "NM", value: "NM" },
  401. { label: "FG", value: "FG" },
  402. { label: "CMB", value: "CMB" }
  403. ] },
  404. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  405. multiple: true,
  406. allowInput: true,
  407. dynamicOptions: true,
  408. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-item-code-prefixes`,
  409. dynamicOptionsParam: "stockCategory",
  410. options: [] },
  411. ]
  412. },
  413. {
  414. id: "rep-005",
  415. title: "成品/半成品生產分析報告",
  416. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-semi-fg-production-analysis`,
  417. fields: [
  418. { label: "完成生產日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  419. { label: "完成生產日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  420. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  421. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  422. multiple: true,
  423. options: [
  424. { label: "All", value: "All" },
  425. { label: "WIP", value: "WIP" },
  426. { label: "FG", value: "FG" },
  427. ] },
  428. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  429. multiple: true,
  430. allowInput: true,
  431. dynamicOptions: true,
  432. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/semi-fg-item-codes`,
  433. dynamicOptionsParam: "stockCategory",
  434. options: [] },
  435. ]
  436. },
  437. {
  438. id: "rep-015",
  439. title: "M18 BOM Shop 同步記錄",
  440. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/bom-shop-sync-history`,
  441. responseType: "excel",
  442. fields: [
  443. { label: "同步日期:由 Sync Date Start", name: "syncDateStart", type: "date", required: false },
  444. { label: "同步日期:至 Sync Date End", name: "syncDateEnd", type: "date", required: false },
  445. { label: "成品貨號 Finished Item Code", name: "finishedItemCode", type: "text", required: false },
  446. {
  447. label: "同步狀態 Sync Status",
  448. name: "syncStatus",
  449. type: "select",
  450. required: false,
  451. options: [
  452. { label: "全部 All", value: "all" },
  453. { label: "成功 Success", value: "success" },
  454. { label: "失敗 Failed", value: "failed" },
  455. ],
  456. },
  457. ],
  458. },
  459. {
  460. id: "rep-016",
  461. title: "成品出倉揀貨合規報告",
  462. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-do-user-pick-audit`,
  463. responseType: "excel",
  464. fields: [
  465. { label: "日期 Date", name: "dateStart", type: "date", required: true },
  466. {
  467. label: "提料人 Handler",
  468. name: "handler",
  469. type: "select",
  470. required: false,
  471. multiple: true,
  472. dynamicOptions: true,
  473. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/do-user-pick-audit-handlers`,
  474. options: [],
  475. },
  476. { label: "提票號碼", name: "ticketNo", type: "text", required: false },
  477. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  478. {
  479. label: "樓層",
  480. name: "storeId",
  481. type: "select",
  482. required: false,
  483. options: [
  484. { label: "2F", value: "2F" },
  485. { label: "4F", value: "4F" },
  486. ],
  487. },
  488. ],
  489. },
  490. {
  491. id: "rep-017",
  492. title: "店鋪訂單補貨記錄",
  493. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/shop-order-replenishment`,
  494. responseType: "excel",
  495. fields: [
  496. // { label: "補貨日期:由 Reorder Date Start", name: "reorderDateStart", type: "date", required: false },
  497. //{ label: "補貨日期:至 Reorder Date End", name: "reorderDateEnd", type: "date", required: false },
  498. { label: "店鋪訂單日期:由 Shop Order Date Start", name: "shopOrderDateStart", type: "date", required: false },
  499. { label: "店鋪訂單日期:至 Shop Order Date End", name: "shopOrderDateEnd", type: "date", required: false },
  500. //{ label: "送貨日期:由 Delivered Date Start", name: "deliveredDateStart", type: "date", required: false },
  501. //{ label: "送貨日期:至 Delivered Date End", name: "deliveredDateEnd", type: "date", required: false },
  502. { label: "店鋪編號 Shop Code", name: "shopCode", type: "text", required: false, placeholder: "e.g. S001" },
  503. ],
  504. },
  505. {
  506. /** FP-MTMS Version Checklist | Functions Ref. No. 60 | v1.0.1 | 2026-08-11 */
  507. id: "rep-018",
  508. title: "送貨訂單與倉存單位不符報告",
  509. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-do-inventory-uom-mismatch`,
  510. responseType: "excel",
  511. fields: [
  512. {
  513. label: "預計送貨日期 Estimated Arrival Date",
  514. name: "deliveryDate",
  515. type: "date",
  516. required: true,
  517. minDate: "today",
  518. },
  519. {
  520. label: "送貨訂單樓層 Floor",
  521. name: "storeId",
  522. type: "select",
  523. required: false,
  524. options: [
  525. { label: "全部", value: "All" },
  526. { label: "2F", value: "2F" },
  527. { label: "4F", value: "4F" },
  528. ],
  529. },
  530. ],
  531. },
  532. ]