Browse Source

update

master
CANCERYS\kw093 2 weeks ago
parent
commit
decbd31d3e
4 changed files with 107 additions and 22 deletions
  1. +22
    -0
      src/app/api/jo/actions.ts
  2. +6
    -3
      src/components/PoDetail/PoDetail.tsx
  3. +8
    -3
      src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx
  4. +71
    -16
      src/components/ProductionProcess/ProductionProcessStepExecution.tsx

+ 22
- 0
src/app/api/jo/actions.ts View File

@@ -208,6 +208,7 @@ export interface ProductProcessWithLinesResponse {
bomId?: number;
jobOrderId?: number;
jobOrderCode: string;
jobOrderStatus: string;
isDark: string;
isDense: number;
isFloat: string;
@@ -230,6 +231,13 @@ export interface UpdateProductProcessLineQtyRequest {
byproductUom: string;
defectQty: number;
defectUom: string;
defect2Qty: number;
defect2Uom: string;
defect3Qty: number;
defect3Uom: string;
defectDescription: string;
defectDescription2: string;
defectDescription3: string;
scrapQty: number;
scrapUom: string;
}
@@ -239,6 +247,13 @@ export interface UpdateProductProcessLineQtyResponse {
outputFromProcessUom: string;
defectQty: number;
defectUom: string;
defect2Qty: number;
defect2Uom: string;
defect3Qty: number;
defect3Uom: string;
defectDescription: string;
defectDescription2: string;
defectDescription3: string;
scrapQty: number;
scrapUom: string;
byproductName: string;
@@ -344,6 +359,13 @@ export interface JobOrderProcessLineDetailResponse {
outputFromProcessUom: string;
defectQty: number;
defectUom: string;
defectDescription: string;
defectQty2: number;
defectUom2: string;
defectDescription2: string;
defectQty3: number;
defectUom3: string;
defectDescription3: string;
scrapQty: number;
scrapUom: string;
byproductId: number;


+ 6
- 3
src/components/PoDetail/PoDetail.tsx View File

@@ -260,14 +260,15 @@ const PoDetail: React.FC<Props> = ({ po, warehouse, printerCombo }) => {
}, [selectedIdsParam]);


const fetchPoDetail = useCallback(async (poId: string) => {
const fetchPoDetail = useCallback(async (poId: string, preserveDnNo: boolean = false) => {
try {
const result = await fetchPoInClient(parseInt(poId));
if (result) {
console.log("%c Fetched PO:", "color:orange", result);
setPurchaseOrder(result);
const currentDnNo = preserveDnNo ? dnFormProps.getValues("dnNo") : "";
dnFormProps.reset({
dnNo: "",
dnNo: currentDnNo,
receiptDate: dayjsToDateString(dayjs()),
});
setRows(result.pol || []);
@@ -416,6 +417,7 @@ const PoDetail: React.FC<Props> = ({ po, warehouse, printerCombo }) => {
() => {
setTimeout(async () => {
// post stock in line
const currentDnNo = dnFormProps.watch("dnNo");
const oldId = row.id;
const acceptedQty = Number(polInputList[rowIndex].dnQty);
if (isNaN(acceptedQty) || acceptedQty <= 0) { alert("來貨數量必須大於0!"); return; } // Temp check, need update
@@ -436,7 +438,8 @@ const PoDetail: React.FC<Props> = ({ po, warehouse, printerCombo }) => {
// if (secondReceiveQty === 0) return
const res = await createStockInLine(postData);
if (res) {
fetchPoDetail(selectedPoId.toString());
fetchPoDetail(selectedPoId.toString(), true);
//dnFormProps.setValue("dnNo", currentDnNo);
}
console.log(res);
}, 200);


+ 8
- 3
src/components/ProductionProcess/ProductionProcessJobOrderDetail.tsx View File

@@ -28,6 +28,7 @@ import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutli
import DoDisturbAltRoundedIcon from '@mui/icons-material/DoDisturbAltRounded';
import { fetchInventories } from "@/app/api/inventory/actions";
import { InventoryResult } from "@/app/api/inventory";
import { releaseJo, startJo } from "@/app/api/jo/actions";
import JobPickExecutionsecondscan from "../Jodetail/JobPickExecutionsecondscan";
interface JobOrderLine {
id: number;
@@ -127,9 +128,13 @@ const stockCounts = useMemo(() => {
}, [jobOrderLines, inventoryData]);
const status = processData?.status?.toLowerCase?.() ?? "";

const handleRelease = useCallback(() => {
const handleRelease = useCallback(async ( jobOrderId: number) => {
// TODO: 替换为实际的 release 调用
console.log("Release clicked for jobOrderId:", jobOrderId);
const response = await releaseJo({ id: jobOrderId })
if (response) {
setProcessData(response.entity);
}
}, [jobOrderId]);
const handleTabChange = useCallback<NonNullable<TabsProps["onChange"]>>(
(_e, newValue) => {
@@ -372,8 +377,8 @@ const handleRelease = useCallback(() => {
<Button
variant="contained"
color="primary"
onClick={handleRelease}
disabled={stockCounts.insufficient > 0 || status !== "planning"}
onClick={() => handleRelease(jobOrderId)}
disabled={stockCounts.insufficient > 0 || processData?.jobOrderStatus !== "planning"}
>
{t("Release")}
</Button>


+ 71
- 16
src/components/ProductionProcess/ProductionProcessStepExecution.tsx View File

@@ -53,7 +53,14 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
scrapUom: "",
byproductName: "",
byproductQty: 0,
byproductUom: ""
byproductUom: "",
defect2Qty: 0,
defect2Uom: "",
defect3Qty: 0,
defect3Uom: "",
defectDescription: "",
defectDescription2: "",
defectDescription3: ""
});
const [isManualScanning, setIsManualScanning] = useState(false);
const [processedQrCodes, setProcessedQrCodes] = useState<Set<string>>(new Set());
@@ -135,6 +142,13 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
// outputFromProcessUom: outputData.outputFromProcessUom,
defectQty: outputData.defectQty,
defectUom: outputData.defectUom,
defect2Qty: outputData.defect2Qty,
defect2Uom: outputData.defect2Uom,
defect3Qty: outputData.defect3Qty,
defect3Uom: outputData.defect3Uom,
defectDescription: outputData.defectDescription,
defectDescription2: outputData.defectDescription2,
defectDescription3: outputData.defectDescription3,
scrapQty: outputData.scrapQty,
scrapUom: outputData.scrapUom,
});
@@ -152,6 +166,13 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
outputFromProcessUom: (detail as any).outputFromProcessUom || "", // 取消注释,使用类型断言
defectQty: detail.defectQty || 0,
defectUom: detail.defectUom || "",
defectDescription: detail.defectDescription || "",
defectDescription2: detail.defectDescription2 || "",
defectDescription3: detail.defectDescription3 || "",
defectQty2: detail.defectQty2 || 0,
defectUom2: detail.defectUom2 || "",
defectQty3: detail.defectQty3 || 0,
defectUom3: detail.defectUom3 || "",
scrapQty: detail.scrapQty || 0,
scrapUom: detail.scrapUom || "",
byproductName: detail.byproductName || "",
@@ -256,9 +277,10 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
<Table size="small" sx={{ mt: 2 }}>
<TableHead>
<TableRow>
<TableCell width="30%"><strong>{t("Type")}</strong></TableCell>
<TableCell width="35%"><strong>{t("Quantity")}</strong></TableCell>
<TableCell width="35%"><strong>{t("Unit")}</strong></TableCell>
<TableCell width="25%"><strong>{t("Type")}</strong></TableCell>
<TableCell width="25%"><strong>{t("Quantity")}</strong></TableCell>
<TableCell width="25%"><strong>{t("Unit")}</strong></TableCell>
<TableCell width="25%"><strong>{t("Description")}</strong></TableCell>
</TableRow>
</TableHead>
<TableBody>
@@ -306,8 +328,41 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
<TableCell>
<Typography>{lineDetail.defectUom || "-"}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectDescription || "-"}</Typography>
</TableCell>
</TableRow>
<TableRow sx={{ bgcolor: 'warning.50' }}>
<TableCell>
<Typography fontWeight={500} color="warning.dark">{t("Defect")}{t("(3)")}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectQty3}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectUom3 || "-"}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectDescription3 || "-"}</Typography>
</TableCell>
</TableRow>
<TableRow sx={{ bgcolor: 'warning.50' }}>
<TableCell>
<Typography fontWeight={500} color="warning.dark">{t("Defect")}{t("(2)")}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectQty2}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectUom2 || "-"}</Typography>
</TableCell>
<TableCell>
<Typography>{lineDetail.defectDescription2 || "-"}</Typography>
</TableCell>
</TableRow>

{/* Scrap */}
<TableRow sx={{ bgcolor: 'error.50' }}>
<TableCell>
@@ -506,7 +561,7 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
//value={outputData.defectUom}
onChange={(e) => setOutputData({
...outputData,
defectUom: e.target.value
defectDescription: e.target.value
})}
/>
</TableCell>
@@ -521,10 +576,10 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
type="number"
fullWidth
size="small"
value={outputData.defectQty}
value={outputData.defect2Qty}
onChange={(e) => setOutputData({
...outputData,
defectQty: parseInt(e.target.value) || 0
defect2Qty: parseInt(e.target.value) || 0
})}
/>
</TableCell>
@@ -532,10 +587,10 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
<TextField
fullWidth
size="small"
value={outputData.defectUom}
value={outputData.defect2Uom}
onChange={(e) => setOutputData({
...outputData,
defectUom: e.target.value
defect2Uom: e.target.value
})}
/>
</TableCell>
@@ -546,7 +601,7 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
//value={outputData.defectUom}
onChange={(e) => setOutputData({
...outputData,
defectUom: e.target.value
defectDescription2: e.target.value
})}
/>
</TableCell>
@@ -561,10 +616,10 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
type="number"
fullWidth
size="small"
value={outputData.defectQty}
value={outputData.defect3Qty}
onChange={(e) => setOutputData({
...outputData,
defectQty: parseInt(e.target.value) || 0
defect3Qty: parseInt(e.target.value) || 0
})}
/>
</TableCell>
@@ -572,10 +627,10 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
<TextField
fullWidth
size="small"
value={outputData.defectUom}
value={outputData.defect3Uom}
onChange={(e) => setOutputData({
...outputData,
defectUom: e.target.value
defect3Uom: e.target.value
})}
/>
</TableCell>
@@ -586,7 +641,7 @@ const ProductionProcessStepExecution: React.FC<ProductionProcessStepExecutionPro
//value={outputData.defectUom}
onChange={(e) => setOutputData({
...outputData,
defectUom: e.target.value
defectDescription3: e.target.value
})}
/>
</TableCell>


Loading…
Cancel
Save