FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 

334 строки
13 KiB

  1. export type FieldType = 'date' | 'text' | 'select' | 'number' | 'checkbox';
  2. import { NEXT_PUBLIC_API_URL } from "@/config/api";
  3. export interface ReportField {
  4. label: string;
  5. name: string;
  6. type: FieldType;
  7. placeholder?: string;
  8. required: boolean;
  9. options?: { label: string; value: string }[]; // For select types
  10. multiple?: boolean; // For select types - allow multiple selection
  11. dynamicOptions?: boolean; // For select types - load options dynamically
  12. dynamicOptionsEndpoint?: string; // API endpoint to fetch dynamic options
  13. dynamicOptionsParam?: string; // Parameter name to pass when fetching options
  14. allowInput?: boolean; // Allow user to input custom values (for select types)
  15. /** When checkbox is checked, disable these field names (by `name`) */
  16. disablesFieldsWhenChecked?: string[];
  17. }
  18. export type ReportResponseType = 'pdf' | 'excel';
  19. export interface ReportDefinition {
  20. id: string;
  21. title: string;
  22. apiEndpoint: string;
  23. /** When 'excel', report page fetches JSON and builds .xlsx for download. Default 'pdf'. */
  24. responseType?: ReportResponseType;
  25. fields: ReportField[];
  26. }
  27. export const REPORTS: ReportDefinition[] = [
  28. //{
  29. // id: "rep-001",
  30. // title: "報告 1",
  31. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report1`,
  32. // fields: [
  33. // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
  34. // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
  35. // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
  36. // { label: "Item Type", name: "itemType", type: "select", required: false,
  37. // options: [
  38. // { label: "FG", value: "FG" },
  39. // { label: "Material", value: "Mat" }
  40. // ] },
  41. // ]
  42. //},
  43. //{
  44. // id: "rep-002",
  45. // title: "報告 2",
  46. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report2`,
  47. // fields: [
  48. // { label: "Target Date", name: "targetDate", type: "date", required: false },
  49. // { label: "Item Code", name: "itemCode", type: "text", required: false },
  50. // { label: "Shift", name: "shift", type: "select", options: [
  51. // { label: "Day", value: "D" },
  52. // { label: "Night", value: "N" }
  53. // ], required: false}
  54. // ]
  55. //},
  56. //{
  57. // id: "rep-003",
  58. // title: "報告 3",
  59. // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report3`,
  60. // fields: [
  61. // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
  62. // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
  63. // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
  64. // { label: "Item Type", name: "itemType", type: "select", required: false,
  65. // options: [
  66. // { label: "FG", value: "FG" },
  67. // { label: "Material", value: "Mat" }
  68. // ] },
  69. // ]
  70. //},
  71. {
  72. id: "rep-004",
  73. title: "入倉追蹤報告",
  74. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-in-traceability`,
  75. fields: [
  76. { label: "入倉日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  77. { label: "入倉日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  78. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  79. ]
  80. },
  81. {
  82. id: "rep-008",
  83. title: "成品出倉報告",
  84. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-delivery-report`,
  85. fields: [
  86. { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  87. { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  88. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  89. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  90. ]
  91. },
  92. /*
  93. { id: "rep-012",
  94. title: "庫存盤點報告",
  95. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance`,
  96. fields: [
  97. { label: "盤點日期:由 Stock Take Date Start", name: "stockTakeDateStart", type: "date", required: false },
  98. { label: "盤點日期:至 Stock Take Date End", name: "stockTakeDateEnd", type: "date", required: false },
  99. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  100. ]
  101. },
  102. */
  103. {
  104. id: "rep-012",
  105. title: "庫存盤點報告",
  106. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance-v2`,
  107. fields: [
  108. {
  109. label: "盤點輪次(可多選)",
  110. name: "stockTakeRoundId",
  111. type: "select",
  112. required: true,
  113. multiple: true,
  114. dynamicOptions: true,
  115. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
  116. options: []
  117. },
  118. { label: "貨品編號", name: "itemCode", type: "text", required: false},
  119. {
  120. label: "倉庫樓層",
  121. name: "store_id",
  122. type: "select",
  123. required: false,
  124. options: [
  125. { label: "全部", value: "All" },
  126. { label: "1F", value: "1F" },
  127. { label: "2F", value: "2F" },
  128. { label: "3F", value: "3F" },
  129. { label: "4F", value: "4F" }
  130. ],
  131. },
  132. {
  133. label: "狀態",
  134. name: "status",
  135. type: "select",
  136. required: false,
  137. options: [
  138. { label: "全部", value: "All" },
  139. { label: "待盤點", value: "pending" },
  140. { label: "已審核", value: "completed" }
  141. ],
  142. },
  143. {
  144. label: "類型",
  145. name: "type",
  146. type: "select",
  147. required: false,
  148. multiple: true,
  149. options: [
  150. { label: "全部", value: "All" },
  151. { label: "PP", value: "PP" },
  152. { label: "PF", value: "PF" },
  153. { label: "TOA", value: "TOA" },
  154. { label: "工廠生產", value: "工廠生產" },
  155. { label: "倉存調整", value: "倉存調整" },
  156. { label: "期初存貨", value: "期初存貨" },
  157. { label: "採購入倉", value: "採購入倉" },
  158. { label: "其他入倉", value: "其他入倉" },
  159. ],
  160. },
  161. ]
  162. },
  163. { id: "rep-011",
  164. title: "庫存明細報告",
  165. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-ledger`,
  166. fields: [
  167. { label: "庫存日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  168. { label: "庫存日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  169. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  170. ]
  171. },
  172. /*
  173. {
  174. id: "rep-007",
  175. title: "庫存結餘報告",
  176. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
  177. fields: [
  178. {
  179. label: "盤點輪次 Stock Take Round",
  180. name: "stockTakeRoundId",
  181. type: "select",
  182. required: true,
  183. dynamicOptions: true,
  184. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
  185. options: []
  186. },
  187. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  188. ]
  189. },
  190. */
  191. {
  192. id: "rep-007",
  193. title: "庫存結餘報告",
  194. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
  195. fields: [
  196. { label: "庫存日期: Stock Date", name: "stockDate", type: "date", required: true },
  197. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  198. ]
  199. },
  200. {
  201. id: "rep-014",
  202. title: "PO入倉記錄報告",
  203. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/grn-report`,
  204. responseType: "excel",
  205. fields: [
  206. { label: "收貨日期:由 Receipt Date Start", name: "receiptDateStart", type: "date", required: false },
  207. { label: "收貨日期:至 Receipt Date End", name: "receiptDateEnd", type: "date", required: false },
  208. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  209. ],
  210. },
  211. { id: "rep-009",
  212. title: "成品出倉追蹤報告",
  213. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-stock-out-traceability`,
  214. fields: [
  215. { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  216. { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  217. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  218. { label: "提料人 Handler", name: "handler", type: "select", required: false,
  219. multiple: true,
  220. dynamicOptions: true,
  221. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/fg-stock-out-traceability-handlers`,
  222. options: [] },
  223. ]
  224. },
  225. { id: "rep-010",
  226. title: "庫存品質檢測報告",
  227. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-item-qc-fail`,
  228. fields: [
  229. { label: "QC 不合格日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  230. { label: "QC 不合格日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  231. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  232. ]
  233. },
  234. { id: "rep-013",
  235. title: "貨品出倉追蹤報告",
  236. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-material-stock-out-traceability`,
  237. fields: [
  238. { label: "出倉日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  239. { label: "出倉日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  240. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  241. { label: "提料人 Handler", name: "handler", type: "select", required: false,
  242. multiple: true,
  243. dynamicOptions: true,
  244. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/material-stock-out-traceability-handlers`,
  245. options: [] },
  246. ]
  247. },
  248. {
  249. id: "rep-006",
  250. title: "庫存材料消耗趨勢報告",
  251. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-item-consumption-trend`,
  252. fields: [
  253. { label: "材料消耗日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  254. { label: "材料消耗日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  255. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  256. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  257. multiple: true,
  258. options: [
  259. { label: "All", value: "All" },
  260. { label: "MAT", value: "MAT" },
  261. { label: "WIP", value: "WIP" },
  262. { label: "NM", value: "NM" },
  263. { label: "FG", value: "FG" },
  264. { label: "CMB", value: "CMB" }
  265. ] },
  266. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  267. multiple: true,
  268. allowInput: true,
  269. dynamicOptions: true,
  270. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-item-code-prefixes`,
  271. dynamicOptionsParam: "stockCategory",
  272. options: [] },
  273. ]
  274. },
  275. {
  276. id: "rep-005",
  277. title: "成品/半成品生產分析報告",
  278. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-semi-fg-production-analysis`,
  279. fields: [
  280. { label: "完成生產日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  281. { label: "完成生產日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  282. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  283. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  284. multiple: true,
  285. options: [
  286. { label: "All", value: "All" },
  287. { label: "WIP", value: "WIP" },
  288. { label: "FG", value: "FG" },
  289. ] },
  290. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  291. multiple: true,
  292. allowInput: true,
  293. dynamicOptions: true,
  294. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/semi-fg-item-codes`,
  295. dynamicOptionsParam: "stockCategory",
  296. options: [] },
  297. ]
  298. },
  299. {
  300. id: "rep-015",
  301. title: "M18 BOM Shop 同步記錄",
  302. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/bom-shop-sync-history`,
  303. responseType: "excel",
  304. fields: [
  305. { label: "同步日期:由 Sync Date Start", name: "syncDateStart", type: "date", required: false },
  306. { label: "同步日期:至 Sync Date End", name: "syncDateEnd", type: "date", required: false },
  307. { label: "成品貨號 Finished Item Code", name: "finishedItemCode", type: "text", required: false },
  308. {
  309. label: "同步狀態 Sync Status",
  310. name: "syncStatus",
  311. type: "select",
  312. required: false,
  313. options: [
  314. { label: "全部 All", value: "all" },
  315. { label: "成功 Success", value: "success" },
  316. { label: "失敗 Failed", value: "failed" },
  317. ],
  318. },
  319. ],
  320. },
  321. ]