|
@@ -249,16 +249,23 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { |
|
|
if (result) { |
|
|
if (result) { |
|
|
setPurchaseOrder(result); |
|
|
setPurchaseOrder(result); |
|
|
setRows(result.pol || []); |
|
|
setRows(result.pol || []); |
|
|
if (result.pol && result.pol.length > 0 && result.id !== selectedPoId) { |
|
|
|
|
|
setSelectedRow(result.pol[0]); |
|
|
|
|
|
setStockInLine(result.pol[0].stockInLine); |
|
|
|
|
|
setProcessedQty(result.pol[0].processed); |
|
|
|
|
|
|
|
|
if (result.pol && result.pol.length > 0) { |
|
|
|
|
|
if (result.id === selectedPoId) { |
|
|
|
|
|
const polIndex = result.pol.findIndex((p) => p.id === selectedRow?.id) |
|
|
|
|
|
// setSelectedRow(result.pol[polIndex]); |
|
|
|
|
|
setStockInLine(result.pol[polIndex].stockInLine); |
|
|
|
|
|
setProcessedQty(result.pol[polIndex].processed); |
|
|
|
|
|
} else { |
|
|
|
|
|
// setSelectedRow(result.pol[0]); |
|
|
|
|
|
setStockInLine(result.pol[0].stockInLine); |
|
|
|
|
|
setProcessedQty(result.pol[0].processed); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error("Failed to fetch PO detail:", error); |
|
|
console.error("Failed to fetch PO detail:", error); |
|
|
} |
|
|
} |
|
|
}, []); |
|
|
|
|
|
|
|
|
}, [selectedRow]); |
|
|
|
|
|
|
|
|
const handlePoSelect = useCallback( |
|
|
const handlePoSelect = useCallback( |
|
|
async (selectedPo: PoResult) => { |
|
|
async (selectedPo: PoResult) => { |
|
@@ -470,6 +477,8 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { |
|
|
<TableCell align="right">{integerFormatter.format(row.qty)}</TableCell> |
|
|
<TableCell align="right">{integerFormatter.format(row.qty)}</TableCell> |
|
|
<TableCell align="right">{integerFormatter.format(processedQty)}</TableCell> |
|
|
<TableCell align="right">{integerFormatter.format(processedQty)}</TableCell> |
|
|
<TableCell align="left">{row.uom?.code}</TableCell> |
|
|
<TableCell align="left">{row.uom?.code}</TableCell> |
|
|
|
|
|
<TableCell align="right">{decimalFormatter.format(row.stockUom.stockQty)}</TableCell> |
|
|
|
|
|
<TableCell align="left">{row.stockUom.stockUomCode}</TableCell> |
|
|
{/* <TableCell align="right"> |
|
|
{/* <TableCell align="right"> |
|
|
{decimalFormatter.format(totalWeight)} {weightUnit} |
|
|
{decimalFormatter.format(totalWeight)} {weightUnit} |
|
|
</TableCell> */} |
|
|
</TableCell> */} |
|
@@ -491,7 +500,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { |
|
|
<TableCell align="center"> |
|
|
<TableCell align="center"> |
|
|
<TextField |
|
|
<TextField |
|
|
id="dnQty" |
|
|
id="dnQty" |
|
|
label="輸入來貨數量" |
|
|
|
|
|
|
|
|
label="輸入採購來貨數量" |
|
|
type="text" // Use type="text" to allow validation in the change handler |
|
|
type="text" // Use type="text" to allow validation in the change handler |
|
|
variant="outlined" |
|
|
variant="outlined" |
|
|
defaultValue={polInputList[rowIndex]?.dnQty ?? ''} |
|
|
defaultValue={polInputList[rowIndex]?.dnQty ?? ''} |
|
@@ -770,6 +779,8 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { |
|
|
<TableCell align="right">{t("qty")}</TableCell> |
|
|
<TableCell align="right">{t("qty")}</TableCell> |
|
|
<TableCell align="right">{t("processed")}</TableCell> |
|
|
<TableCell align="right">{t("processed")}</TableCell> |
|
|
<TableCell align="left">{t("uom")}</TableCell> |
|
|
<TableCell align="left">{t("uom")}</TableCell> |
|
|
|
|
|
<TableCell align="right">{t("Stock In Qty")}</TableCell> |
|
|
|
|
|
<TableCell align="left">{t("Stock UoM")}</TableCell> |
|
|
{/* <TableCell align="right">{t("total weight")}</TableCell> */} |
|
|
{/* <TableCell align="right">{t("total weight")}</TableCell> */} |
|
|
{/* <TableCell align="right">{`${t("price")} (HKD)`}</TableCell> */} |
|
|
{/* <TableCell align="right">{`${t("price")} (HKD)`}</TableCell> */} |
|
|
<TableCell align="left" sx={{ width: '75px' }}>{t("status")}</TableCell> |
|
|
<TableCell align="left" sx={{ width: '75px' }}>{t("status")}</TableCell> |
|
@@ -793,7 +804,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { |
|
|
<Grid container xs={12} justifyContent="start"> |
|
|
<Grid container xs={12} justifyContent="start"> |
|
|
<Grid item xs={12}> |
|
|
<Grid item xs={12}> |
|
|
<Typography variant="h6"> |
|
|
<Typography variant="h6"> |
|
|
{selectedRow ? `已選擇: ${selectedRow?.itemNo ? selectedRow.itemNo : 'N/A'} - ${selectedRow?.itemName ? selectedRow?.itemName : 'N/A'}` : "未選擇貨品"} |
|
|
|
|
|
|
|
|
{selectedRow ? `已選擇貨品: ${selectedRow?.itemNo ? selectedRow.itemNo : 'N/A'} - ${selectedRow?.itemName ? selectedRow?.itemName : 'N/A'}` : "未選擇貨品"} |
|
|
</Typography> |
|
|
</Typography> |
|
|
</Grid> |
|
|
</Grid> |
|
|
<Grid item xs={12}> |
|
|
<Grid item xs={12}> |
|
|