Преглед изворни кода

Stock Item Consumption Trend Report

MergeProblem1
B.E.N.S.O.N пре 4 часа
родитељ
комит
e7c273ba0e
2 измењених фајлова са 79 додато и 47 уклоњено
  1. +7
    -2
      src/app/(main)/report/page.tsx
  2. +72
    -45
      src/config/reportConfig.ts

+ 7
- 2
src/app/(main)/report/page.tsx Прегледај датотеку

@@ -33,7 +33,8 @@ export default function ReportPage() {
const [criteria, setCriteria] = useState<Record<string, string>>({});
const [loading, setLoading] = useState(false);
const [dynamicOptions, setDynamicOptions] = useState<Record<string, { label: string; value: string }[]>>({});

const [showConfirmDialog, setShowConfirmDialog] = useState(false);
// Find the configuration for the currently selected report
const currentReport = useMemo(() =>
REPORTS.find((r) => r.id === selectedReportId),
@@ -175,7 +176,11 @@ export default function ReportPage() {
},
});

if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
if (!response.ok) {
const errorText = await response.text();
console.error("Response error:", errorText);
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
}

const blob = await response.blob();
const downloadUrl = window.URL.createObjectURL(blob);


+ 72
- 45
src/config/reportConfig.ts Прегледај датотеку

@@ -24,49 +24,49 @@ export interface ReportDefinition {
}

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-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: "入倉記錄報告",
@@ -94,14 +94,41 @@ export const REPORTS: ReportDefinition[] = [
] },
{ label: "物料編號 Item Code", name: "itemCode", type: "select", required: false,
multiple: true,
allowInput: true, // Allow user to input custom item codes
allowInput: true,
dynamicOptions: true,
dynamicOptionsEndpoint: `${NEXT_PUBLIC_API_URL}/report/semi-fg-item-codes`,
dynamicOptionsParam: "stockCategory",
options: [] }, // Options will be loaded dynamically
options: [] },
{ label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
{ 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" },
]
},
{
id: "rep-006",
title: "庫存商品消費趨勢報告",
apiEndpoint: `${NEXT_PUBLIC_API_URL}/report/print-stock-item-consumption-trend`,
fields: [
{ label: "倉存類別 Stock 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: [] },
{ label: "年份 Year", name: "year", type: "text", required: false, placeholder: "e.g. 2026" },
{ label: "完成生產日期:由 Last Out Date Start", name: "lastOutDateStart", type: "date", required: false },
{ label: "完成生產日期:至 Last Out Date End", name: "lastOutDateEnd", type: "date", required: false },
]
}
];

Loading…
Откажи
Сачувај