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

294 строки
12 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. },
  145. { id: "rep-011",
  146. title: "庫存明細報告",
  147. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-ledger`,
  148. fields: [
  149. { label: "庫存日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  150. { label: "庫存日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  151. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  152. ]
  153. },
  154. /*
  155. {
  156. id: "rep-007",
  157. title: "庫存結餘報告",
  158. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
  159. fields: [
  160. {
  161. label: "盤點輪次 Stock Take Round",
  162. name: "stockTakeRoundId",
  163. type: "select",
  164. required: true,
  165. dynamicOptions: true,
  166. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
  167. options: []
  168. },
  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. { label: "庫存日期: Stock Date", name: "stockDate", type: "date", required: true },
  179. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  180. ]
  181. },
  182. {
  183. id: "rep-014",
  184. title: "PO入倉記錄報告",
  185. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/grn-report`,
  186. responseType: "excel",
  187. fields: [
  188. { label: "收貨日期:由 Receipt Date Start", name: "receiptDateStart", type: "date", required: false },
  189. { label: "收貨日期:至 Receipt Date End", name: "receiptDateEnd", type: "date", required: false },
  190. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
  191. ],
  192. },
  193. { id: "rep-009",
  194. title: "成品出倉追蹤報告",
  195. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-stock-out-traceability`,
  196. fields: [
  197. { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  198. { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  199. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  200. { label: "提料人 Handler", name: "handler", type: "select", required: false,
  201. multiple: true,
  202. dynamicOptions: true,
  203. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/fg-stock-out-traceability-handlers`,
  204. options: [] },
  205. ]
  206. },
  207. { id: "rep-010",
  208. title: "庫存品質檢測報告",
  209. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-item-qc-fail`,
  210. fields: [
  211. { label: "QC 不合格日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
  212. { label: "QC 不合格日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
  213. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  214. ]
  215. },
  216. { id: "rep-013",
  217. title: "貨品出倉追蹤報告",
  218. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-material-stock-out-traceability`,
  219. fields: [
  220. { label: "出倉日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  221. { label: "出倉日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  222. { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
  223. { label: "提料人 Handler", name: "handler", type: "select", required: false,
  224. multiple: true,
  225. dynamicOptions: true,
  226. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/material-stock-out-traceability-handlers`,
  227. options: [] },
  228. ]
  229. },
  230. {
  231. id: "rep-006",
  232. title: "庫存材料消耗趨勢報告",
  233. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-item-consumption-trend`,
  234. fields: [
  235. { label: "材料消耗日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
  236. { label: "材料消耗日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
  237. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  238. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  239. multiple: true,
  240. options: [
  241. { label: "All", value: "All" },
  242. { label: "MAT", value: "MAT" },
  243. { label: "WIP", value: "WIP" },
  244. { label: "NM", value: "NM" },
  245. { label: "FG", value: "FG" },
  246. { label: "CMB", value: "CMB" }
  247. ] },
  248. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  249. multiple: true,
  250. allowInput: true,
  251. dynamicOptions: true,
  252. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-item-code-prefixes`,
  253. dynamicOptionsParam: "stockCategory",
  254. options: [] },
  255. ]
  256. },
  257. {
  258. id: "rep-005",
  259. title: "成品/半成品生產分析報告",
  260. apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-semi-fg-production-analysis`,
  261. fields: [
  262. { label: "完成生產日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  263. { label: "完成生產日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false, placeholder: "dd/mm/yyyy" },
  264. { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
  265. { label: "類別 Category", name: "stockCategory", type: "select", required: false,
  266. multiple: true,
  267. options: [
  268. { label: "All", value: "All" },
  269. { label: "WIP", value: "WIP" },
  270. { label: "FG", value: "FG" },
  271. ] },
  272. { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
  273. multiple: true,
  274. allowInput: true,
  275. dynamicOptions: true,
  276. dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/semi-fg-item-codes`,
  277. dynamicOptionsParam: "stockCategory",
  278. options: [] },
  279. ]
  280. }
  281. ]