瀏覽代碼

no message

MergeProblem1
[email protected] 2 天之前
父節點
當前提交
fc398b038b
共有 2 個文件被更改,包括 45 次插入40 次删除
  1. +44
    -40
      src/app/(main)/ps/page.tsx
  2. +1
    -0
      src/i18n/zh/common.json

+ 44
- 40
src/app/(main)/ps/page.tsx 查看文件

@@ -110,15 +110,15 @@ export default function ProductionSchedulePage() {

if (response.ok) {
await handleSearch(); // refresh list
alert("Forecast generated successfully!");
alert("成功計算排期!");
} else {
const errorText = await response.text();
console.error("Forecast failed:", errorText);
alert(`Forecast failed: ${response.status} - ${errorText.substring(0, 120)}`);
alert(`計算錯誤: ${response.status} - ${errorText.substring(0, 120)}`);
}
} catch (e) {
console.error("Forecast Error:", e);
alert("Error occurred while generating forecast.");
alert("發生不明狀況.");
} finally {
setLoading(false);
}
@@ -233,7 +233,11 @@ export default function ProductionSchedulePage() {
});

if (response.ok) {
alert("Job Orders generated successfully!");
const data = await response.json();
const displayMessage = data.message || "Operation completed.";

alert(displayMessage);
//alert("Job Orders generated successfully!");
setIsDetailOpen(false);
} else {
alert("Failed to generate jobs.");
@@ -252,7 +256,7 @@ export default function ProductionSchedulePage() {
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mb: 3 }}>
<Stack direction="row" spacing={2} alignItems="center">
<CalendarMonth color="primary" sx={{ fontSize: 32 }} />
<Typography variant="h4" sx={{ fontWeight: 'bold' }}>排</Typography>
<Typography variant="h4" sx={{ fontWeight: 'bold' }}>排</Typography>
</Stack>
<Stack direction="row" spacing={2}>
@@ -263,7 +267,7 @@ export default function ProductionSchedulePage() {
onClick={() => setIsExportDialogOpen(true)}
sx={{ fontWeight: 'bold' }}
>
Export Excel
匯出計劃/物料需求Excel
</Button>
<Button
variant="contained"
@@ -273,7 +277,7 @@ export default function ProductionSchedulePage() {
disabled={loading}
sx={{ fontWeight: 'bold' }}
>
Forecast
預測排期
</Button>
</Stack>
</Stack>
@@ -281,7 +285,7 @@ export default function ProductionSchedulePage() {
{/* Query Bar – unchanged */}
<Paper sx={{ p: 2, mb: 3, display: 'flex', alignItems: 'center', gap: 2, borderLeft: '6px solid #1976d2' }}>
<TextField
label="Produce Date"
label="生產日期"
type="date"
size="small"
InputLabelProps={{ shrink: true }}
@@ -289,7 +293,7 @@ export default function ProductionSchedulePage() {
onChange={(e) => setSearchDate(e.target.value)}
/>
<Button variant="contained" startIcon={<Search />} onClick={handleSearch}>
Query
搜尋
</Button>
</Paper>

@@ -298,11 +302,10 @@ export default function ProductionSchedulePage() {
<Table stickyHeader size="small">
<TableHead>
<TableRow sx={{ bgcolor: '#f5f5f5' }}>
<TableCell align="center" sx={{ fontWeight: 'bold', width: 100 }}>Action</TableCell>
<TableCell sx={{ fontWeight: 'bold' }}>ID</TableCell>
<TableCell sx={{ fontWeight: 'bold' }}>Production Date</TableCell>
<TableCell align="right" sx={{ fontWeight: 'bold' }}>Est. Prod Count</TableCell>
<TableCell align="right" sx={{ fontWeight: 'bold' }}>Total FG Types</TableCell>
<TableCell align="center" sx={{ fontWeight: 'bold', width: 100 }}>詳細</TableCell>
<TableCell sx={{ fontWeight: 'bold' }}>生產日期</TableCell>
<TableCell align="right" sx={{ fontWeight: 'bold' }}>預計生產數</TableCell>
<TableCell align="right" sx={{ fontWeight: 'bold' }}>成品款數</TableCell>
</TableRow>
</TableHead>
<TableBody>
@@ -313,7 +316,6 @@ export default function ProductionSchedulePage() {
<Visibility fontSize="small" />
</IconButton>
</TableCell>
<TableCell>#{ps.id}</TableCell>
<TableCell>{formatBackendDate(ps.produceAt)}</TableCell>
<TableCell align="right">{formatNum(ps.totalEstProdCount)}</TableCell>
<TableCell align="right">{formatNum(ps.totalFGType)}</TableCell>
@@ -328,7 +330,7 @@ export default function ProductionSchedulePage() {
<DialogTitle sx={{ bgcolor: '#1976d2', color: 'white' }}>
<Stack direction="row" alignItems="center" spacing={1}>
<ListAlt />
<Typography variant="h6">Schedule Details: {selectedPs?.id} ({formatBackendDate(selectedPs?.produceAt)})</Typography>
<Typography variant="h6">排期詳細: {selectedPs?.id} ({formatBackendDate(selectedPs?.produceAt)})</Typography>
</Stack>
</DialogTitle>
<DialogContent sx={{ p: 0 }}>
@@ -336,15 +338,16 @@ export default function ProductionSchedulePage() {
<Table size="small" stickyHeader>
<TableHead>
<TableRow>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Job Order</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Item Code</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Item Name</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Avg Last Month</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Stock</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Days Left</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Batch Need</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Prod Qty</TableCell>
<TableCell align="center" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>Priority</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>工單號</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>物料編號</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>物料名稱</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>每日平均出貨量</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>出貨前預計存貨量</TableCell>
<TableCell sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>單位</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>可用日</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>生產量(批)</TableCell>
<TableCell align="right" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>預計生產包數</TableCell>
<TableCell align="center" sx={{ bgcolor: '#eee', fontWeight: 'bold' }}>優先度</TableCell>
</TableRow>
</TableHead>
<TableBody>
@@ -355,6 +358,7 @@ export default function ProductionSchedulePage() {
<TableCell>{line.itemName}</TableCell>
<TableCell align="right">{formatNum(line.avgQtyLastMonth)}</TableCell>
<TableCell align="right">{formatNum(line.stockQty)}</TableCell>
<TableCell>{line.stockUnit}</TableCell>
<TableCell align="right" sx={{ color: line.daysLeft < 5 ? 'error.main' : 'inherit', fontWeight: line.daysLeft < 5 ? 'bold' : 'normal' }}>
{line.daysLeft}
</TableCell>
@@ -378,9 +382,10 @@ export default function ProductionSchedulePage() {
color="primary"
startIcon={isGenerating ? <CircularProgress size={20} color="inherit" /> : <SettingsEthernet />}
onClick={handleAutoGenJob}
disabled={isGenerating || !isDateToday}
disabled={isGenerating}
//disabled={isGenerating || !isDateToday}
>
Auto Gen Job
自動生成工單
</Button>
</span>
</Tooltip>
@@ -390,7 +395,7 @@ export default function ProductionSchedulePage() {
color="inherit"
disabled={isGenerating}
>
Close
關閉
</Button>
</Stack>
</DialogActions>
@@ -403,15 +408,15 @@ export default function ProductionSchedulePage() {
maxWidth="sm"
fullWidth
>
<DialogTitle>Generate Production Forecast</DialogTitle>
<DialogTitle>準備生成預計排期</DialogTitle>
<DialogContent>
<DialogContentText sx={{ mb: 3 }}>
Select the starting date and number of days to forecast.
</DialogContentText>
<Stack spacing={3} sx={{ mt: 2 }}>
<TextField
label="Start Date"
label="開始日期"
type="date"
fullWidth
value={forecastStartDate}
@@ -422,7 +427,7 @@ export default function ProductionSchedulePage() {
}}
/>
<TextField
label="No. of Dates (days)"
label="排期日數"
type="number"
fullWidth
value={forecastDays}
@@ -437,13 +442,12 @@ export default function ProductionSchedulePage() {
max: 365,
step: 1,
}}
helperText="Number of days to generate forecast for (1–365)"
/>
</Stack>
</DialogContent>
<DialogActions>
<Button onClick={() => setIsForecastDialogOpen(false)} color="inherit">
Cancel
取消
</Button>
<Button
variant="contained"
@@ -452,7 +456,7 @@ export default function ProductionSchedulePage() {
disabled={!forecastStartDate || forecastDays === '' || loading}
startIcon={loading ? <CircularProgress size={20} /> : <OnlinePrediction />}
>
Generate Forecast
計算預測排期
</Button>
</DialogActions>
</Dialog>
@@ -464,14 +468,14 @@ export default function ProductionSchedulePage() {
maxWidth="xs"
fullWidth
>
<DialogTitle>Export Production Schedule</DialogTitle>
<DialogTitle>匯出排期/物料用量預計</DialogTitle>
<DialogContent>
<DialogContentText sx={{ mb: 3 }}>
Select the starting date for the export.
選擇要匯出的起始日期
</DialogContentText>
<TextField
label="From Date"
label="起始日期"
type="date"
fullWidth
value={exportFromDate}
@@ -485,7 +489,7 @@ export default function ProductionSchedulePage() {
</DialogContent>
<DialogActions>
<Button onClick={() => setIsExportDialogOpen(false)} color="inherit">
Cancel
取消
</Button>
<Button
variant="contained"
@@ -494,7 +498,7 @@ export default function ProductionSchedulePage() {
disabled={!exportFromDate || loading}
startIcon={loading ? <CircularProgress size={20} /> : <FileDownload />}
>
Export
匯出
</Button>
</DialogActions>
</Dialog>


+ 1
- 0
src/i18n/zh/common.json 查看文件

@@ -425,6 +425,7 @@
"Add Shop to Truck Lane": "新增店鋪至卡車路線",
"Truck lane code already exists. Please use a different code.": "卡車路線編號已存在,請使用其他編號。",
"MaintenanceEdit": "編輯維護和保養",
"ps": "排程",
"Printer": "列印機",
"Delete": "刪除",
"Delete Success": "刪除成功",


Loading…
取消
儲存