|
- /** FP-MTMS Version Checklist | Functions Ref. No. 39 | v1.0.0 | 2026-08-03 */
- export type FieldType = 'date' | 'text' | 'select' | 'number' | 'checkbox';
-
- import { NEXT_PUBLIC_API_URL } from "@/config/api";
-
- export interface ReportField {
- label: string;
- name: string;
- type: FieldType;
- placeholder?: string;
- required: boolean;
- options?: { label: string; value: string }[]; // For select types
- multiple?: boolean; // For select types - allow multiple selection
- dynamicOptions?: boolean; // For select types - load options dynamically
- dynamicOptionsEndpoint?: string; // API endpoint to fetch dynamic options
- dynamicOptionsParam?: string; // Parameter name to pass when fetching options
- allowInput?: boolean; // Allow user to input custom values (for select types)
- /** Typeahead options instead of preloading the full list (use with allowInput) */
- asyncSearch?: boolean;
- /** Minimum characters before asyncSearch fetches. Default 2. */
- asyncSearchMinChars?: number;
- /** When checkbox is checked, disable these field names (by `name`) */
- disablesFieldsWhenChecked?: string[];
- /** For date fields: restrict picker so value cannot be before today */
- minDate?: 'today';
- /** Disable the input (e.g. date locked to today) */
- disabled?: boolean;
- }
-
- export type ReportResponseType = 'pdf' | 'excel';
-
- export interface ReportDefinition {
- id: string;
- title: string;
- apiEndpoint: string;
- /** When 'excel', report page fetches JSON and builds .xlsx for download. Default 'pdf'. */
- responseType?: ReportResponseType;
- fields: ReportField[];
- }
-
- /** FP-MTMS Version Checklist | Functions Ref. No. 69 | v1.0.2 | 2026-09-10 */
- const asyncItemCodeField = (
- label = "貨品編號 Item Code",
- name = "itemCode",
- ): ReportField => ({
- label,
- name,
- type: "select",
- required: false,
- multiple: true,
- allowInput: true,
- asyncSearch: true,
- placeholder: "e.g. FA0591",
- });
-
- export const REPORTS: ReportDefinition[] = [
- //{
- // id: "rep-001",
- // title: "報告 1",
- // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report1`,
- // fields: [
- // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
- // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
- // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
- // { label: "Item Type", name: "itemType", type: "select", required: false,
- // options: [
- // { label: "FG", value: "FG" },
- // { label: "Material", value: "Mat" }
- // ] },
- // ]
- //},
- //{
- // id: "rep-002",
- // title: "報告 2",
- // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report2`,
- // fields: [
- // { label: "Target Date", name: "targetDate", type: "date", required: false },
- // { label: "Item Code", name: "itemCode", type: "text", required: false },
- // { label: "Shift", name: "shift", type: "select", options: [
- // { label: "Day", value: "D" },
- // { label: "Night", value: "N" }
- // ], required: false}
- // ]
- //},
- //{
- // id: "rep-003",
- // title: "報告 3",
- // apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-report3`,
- // fields: [
- // { label: "From Date", name: "fromDate", type: "date", required: true }, // Mandatory
- // { label: "To Date", name: "toDate", type: "date", required: true }, // Mandatory
- // { label: "Item Code", name: "itemCode", type: "text", required: false, placeholder: "e.g. FG"},
- // { label: "Item Type", name: "itemType", type: "select", required: false,
- // options: [
- // { label: "FG", value: "FG" },
- // { label: "Material", value: "Mat" }
- // ] },
- // ]
- //},
- {
- id: "rep-004",
- title: "入倉追蹤報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-in-traceability`,
- fields: [
- { label: "入倉日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
- { label: "入倉日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
- asyncItemCodeField(),
- {
- label: "樓層 Store ID",
- name: "storeId",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "1F", value: "1F" },
- { label: "2F", value: "2F" },
- { label: "3F", value: "3F" },
- { label: "4F", value: "4F" },
- ],
- },
- { label: "倉庫 Warehouse", name: "warehouse", type: "text", required: false, placeholder: "e.g. W201" },
- { label: "區域 Area", name: "area", type: "text", required: false, placeholder: "e.g. #A" },
- { label: "儲位 Slot", name: "slot", type: "text", required: false, placeholder: "e.g. 01" },
- { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
- {
- label: "PP/PF 分類",
- name: "poPrefix",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "PP", value: "PP" },
- { label: "PF", value: "PF" },
- ],
- },
- ]
- },
- {
- id: "rep-008",
- title: "成品出倉報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-delivery-report`,
- fields: [
- { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
- { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
- { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
- asyncItemCodeField(),
- ]
- },
- /*
- { id: "rep-012",
- title: "庫存盤點報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance`,
- fields: [
- { label: "盤點日期:由 Stock Take Date Start", name: "stockTakeDateStart", type: "date", required: false },
- { label: "盤點日期:至 Stock Take Date End", name: "stockTakeDateEnd", type: "date", required: false },
- { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
- ]
- },
- */
- {
- id: "rep-012",
- title: "庫存盤點報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-take-variance-v2`,
- fields: [
- {
- label: "盤點輪次(可多選)",
- name: "stockTakeRoundId",
- type: "select",
- required: true,
- multiple: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
- options: []
- },
- asyncItemCodeField("貨品編號"),
- {
- label: "倉庫樓層",
- name: "store_id",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "1F", value: "1F" },
- { label: "2F", value: "2F" },
- { label: "3F", value: "3F" },
- { label: "4F", value: "4F" }
- ],
- },
- {
- label: "狀態",
- name: "status",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "待盤點", value: "pending" },
- { label: "已審核", value: "completed" }
- ],
- },
- {
- label: "類型",
- name: "type",
- type: "select",
- required: false,
- multiple: true,
- options: [
- { label: "全部", value: "All" },
- { label: "PP", value: "PP" },
- { label: "PF", value: "PF" },
- { label: "TOA", value: "TOA" },
- { label: "工廠生產", value: "工廠生產" },
- { label: "倉存調整", value: "倉存調整" },
- { label: "期初存貨", value: "期初存貨" },
- { label: "採購入倉", value: "採購入倉" },
- { label: "其他入倉", value: "其他入倉" },
- ],
- },
- ]
- },
- /* Hidden for now: 庫存批次結餘報告 (rep-019)
- {
- id: "rep-019",
- title: "庫存批次結餘報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-balance`,
- responseType: "excel",
- fields: [
- { label: "庫存日期 Stock Date(僅今天)", name: "stockDate", type: "date", required: true, disabled: true },
- { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
- { label: "倉位 Warehouse Code", name: "warehouseCode", type: "text", required: false, placeholder: "e.g. W200 or 2F-W200-#A-00" },
- {
- label: "樓層 Store ID",
- name: "storeId",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "1F", value: "1F" },
- { label: "2F", value: "2F" },
- { label: "3F", value: "3F" },
- { label: "4F", value: "4F" },
- ],
- },
- { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
- ],
- },
- */
- {
- id: "rep-021",
- title: "庫存批次現況報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-onhand`,
- responseType: "excel",
- fields: [
- asyncItemCodeField(),
- {
- label: "樓層 Store ID",
- name: "storeId",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "1F", value: "1F" },
- { label: "2F", value: "2F" },
- { label: "3F", value: "3F" },
- { label: "4F", value: "4F" },
- ],
- },
- { label: "倉庫 Warehouse", name: "warehouse", type: "text", required: false, placeholder: "e.g. W201" },
- { label: "區域 Area", name: "area", type: "text", required: false, placeholder: "e.g. #A" },
- { label: "儲位 Slot", name: "slot", type: "text", required: false, placeholder: "e.g. 02" },
- {
- label: "盤點區域說明 Stock Take Section",
- name: "stockTakeSectionDescription",
- type: "select",
- required: false,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/warehouse/stockTakeSections`,
- options: [{ label: "全部", value: "All" }],
- },
- { label: "批號 Lot No", name: "lotNo", type: "text", required: false, placeholder: "e.g. LT-202608" },
- {
- label: "來源 Lot Origin",
- name: "lotOrigin",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "PP", value: "PP" },
- { label: "PF", value: "PF" },
- { label: "其他", value: "other" },
- ],
- },
- ],
- },
- { id: "rep-011",
- title: "庫存明細報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-ledger`,
- fields: [
- { label: "庫存日期:由 Last In Date Start", name: "lastInDateStart", type: "date", required: false },
- { label: "庫存日期:至 Last In Date End", name: "lastInDateEnd", type: "date", required: false },
- asyncItemCodeField(),
- ]
- },
- /* Hidden for now: 庫存流水帳報告 (rep-020)
- {
- id: "rep-020",
- title: "庫存流水帳報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-lot-ledger`,
- responseType: "excel",
- fields: [
- { label: "期間起 Period From(永遠該月1日)", name: "lastInDateStart", type: "date", required: true },
- { label: "期間迄 Period To", name: "lastInDateEnd", type: "date", required: true },
- { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false },
- ],
- },
- */
- /*
- {
- id: "rep-007",
- title: "庫存結餘報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
- fields: [
- {
- label: "盤點輪次 Stock Take Round",
- name: "stockTakeRoundId",
- type: "select",
- required: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-take-rounds`,
- options: []
- },
- { label: "貨品編號 Item Code", name: "itemCode", type: "text", required: false},
- ]
- },
- */
- /** FP-MTMS Version Checklist | Functions Ref. No. 82 | v1.0.0 | 2026-09-10 */
- {
- id: "rep-007",
- title: "庫存結餘報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-balance`,
- fields: [
- { label: "庫存日期: Stock Date", name: "stockDate", type: "date", required: true },
- asyncItemCodeField(),
- ]
- },
-
-
- {
- id: "rep-014",
- title: "PO入倉記錄報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/grn-report`,
- responseType: "excel",
- fields: [
- { label: "收貨日期:由 Receipt Date Start", name: "receiptDateStart", type: "date", required: false },
- { label: "收貨日期:至 Receipt Date End", name: "receiptDateEnd", type: "date", required: false },
- asyncItemCodeField(),
- ],
- },
-
- { id: "rep-009",
- title: "成品出倉追蹤報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-fg-stock-out-traceability`,
- fields: [
- { label: "出貨日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
- { label: "出貨日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
- asyncItemCodeField(),
- { label: "提料員 Handler", name: "handler", type: "select", required: false,
- multiple: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/fg-stock-out-traceability-handlers`,
- options: [] },
- ]
- },
-
-
- { id: "rep-010",
- /** FP-MTMS Version Checklist | Functions Ref. No. 64 | v1.0.0 | 2026-08-11 */
- title: "庫存品質檢測報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-item-qc-fail`,
- fields: [
- { label: "QC 檢測日期:由 QC Date Start", name: "lastInDateStart", type: "date", required: false },
- { label: "QC 檢測日期:至 QC Date End", name: "lastInDateEnd", type: "date", required: false },
- { label: "QC 類型", name: "qcType", type: "select", required: false,
- options: [
- { label: "全部", value: "all" },
- { label: "IQC(採購)", value: "IQC" },
- { label: "EPQC(工單)", value: "EPQC" },
- ] },
- asyncItemCodeField(),
- {
- label: "QC 項目範圍",
- name: "qcItemScope",
- type: "select",
- required: false,
- options: [
- { label: "全部 QC 項目", value: "all" },
- { label: "只包含溫度濕度", value: "measurable" },
- ],
- },
- ]
- },
- { id: "rep-013",
- title: "貨品出倉追蹤報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-material-stock-out-traceability`,
- fields: [
- { label: "出倉日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
- { label: "出倉日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
- asyncItemCodeField(),
- { label: "提料人 Handler", name: "handler", type: "select", required: false,
- multiple: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/material-stock-out-traceability-handlers`,
- options: [] },
- ]
- },
- {
- id: "rep-006",
- title: "庫存材料消耗趨勢報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-item-consumption-trend`,
- fields: [
- { label: "材料消耗日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
- { label: "材料消耗日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
- { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
- { label: "類別 Category", name: "stockCategory", type: "select", required: false,
- multiple: true,
- options: [
- { label: "All", value: "All" },
- { label: "MAT", value: "MAT" },
- { label: "WIP", value: "WIP" },
- { label: "NM", value: "NM" },
- { label: "FG", value: "FG" },
- { label: "CMB", value: "CMB" }
- ] },
- { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
- multiple: true,
- allowInput: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/stock-item-code-prefixes`,
- dynamicOptionsParam: "stockCategory",
- options: [] },
- ]
- },
-
-
- {
- id: "rep-005",
- title: "成品/半成品生產分析報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-semi-fg-production-analysis`,
- fields: [
- { label: "完成生產日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false, placeholder: "dd/mm/yyyy" },
- { label: "完成生產日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false, placeholder: "dd/mm/yyyy" },
- { label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
- { label: "類別 Category", name: "stockCategory", type: "select", required: false,
- multiple: true,
- options: [
- { label: "All", value: "All" },
- { label: "WIP", value: "WIP" },
- { label: "FG", value: "FG" },
- ] },
- { label: "貨品編號 Item Code", name: "itemCode", type: "select", required: false,
- multiple: true,
- allowInput: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/semi-fg-item-codes`,
- dynamicOptionsParam: "stockCategory",
- options: [] },
- ]
- },
- {
- id: "rep-015",
- title: "M18 BOM Shop 同步記錄",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/bom-shop-sync-history`,
- responseType: "excel",
- fields: [
- { label: "同步日期:由 Sync Date Start", name: "syncDateStart", type: "date", required: false },
- { label: "同步日期:至 Sync Date End", name: "syncDateEnd", type: "date", required: false },
- asyncItemCodeField("成品貨號 Finished Item Code", "finishedItemCode"),
- {
- label: "同步狀態 Sync Status",
- name: "syncStatus",
- type: "select",
- required: false,
- options: [
- { label: "全部 All", value: "all" },
- { label: "成功 Success", value: "success" },
- { label: "失敗 Failed", value: "failed" },
- ],
- },
- ],
- },
- {
- id: "rep-016",
- title: "成品出倉揀貨合規報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-do-user-pick-audit`,
- responseType: "excel",
- fields: [
- { label: "日期 Date", name: "dateStart", type: "date", required: true },
- {
- label: "提料人 Handler",
- name: "handler",
- type: "select",
- required: false,
- multiple: true,
- dynamicOptions: true,
- dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/do-user-pick-audit-handlers`,
- options: [],
- },
- { label: "提票號碼", name: "ticketNo", type: "text", required: false },
- asyncItemCodeField(),
- {
- label: "樓層",
- name: "storeId",
- type: "select",
- required: false,
- options: [
- { label: "2F", value: "2F" },
- { label: "4F", value: "4F" },
- ],
- },
- ],
- },
- {
- id: "rep-017",
- title: "店鋪訂單補貨記錄",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/shop-order-replenishment`,
- responseType: "excel",
- fields: [
- // { label: "補貨日期:由 Reorder Date Start", name: "reorderDateStart", type: "date", required: false },
- //{ label: "補貨日期:至 Reorder Date End", name: "reorderDateEnd", type: "date", required: false },
- { label: "店鋪訂單日期:由 Shop Order Date Start", name: "shopOrderDateStart", type: "date", required: false },
- { label: "店鋪訂單日期:至 Shop Order Date End", name: "shopOrderDateEnd", type: "date", required: false },
- //{ label: "送貨日期:由 Delivered Date Start", name: "deliveredDateStart", type: "date", required: false },
- //{ label: "送貨日期:至 Delivered Date End", name: "deliveredDateEnd", type: "date", required: false },
- { label: "店鋪編號 Shop Code", name: "shopCode", type: "text", required: false, placeholder: "e.g. S001" },
- ],
- },
- {
- /** FP-MTMS Version Checklist | Functions Ref. No. 60 | v1.0.1 | 2026-08-11 */
- id: "rep-018",
- title: "送貨訂單與倉存單位不符報告",
- apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-do-inventory-uom-mismatch`,
- responseType: "excel",
- fields: [
- {
- label: "預計送貨日期 Estimated Arrival Date",
- name: "deliveryDate",
- type: "date",
- required: true,
- minDate: "today",
- },
- {
- label: "送貨訂單樓層 Floor",
- name: "storeId",
- type: "select",
- required: false,
- options: [
- { label: "全部", value: "All" },
- { label: "2F", value: "2F" },
- { label: "4F", value: "4F" },
- ],
- },
- ],
- },
- ]
|