|
|
@@ -19,7 +19,7 @@ import { |
|
|
|
Tooltip, |
|
|
|
Typography, |
|
|
|
} from "@mui/material"; |
|
|
|
import { useFormContext, Controller } from "react-hook-form"; |
|
|
|
import { useFormContext, Controller, FieldPath, useFieldArray } from "react-hook-form"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import StyledDataGrid from "../StyledDataGrid"; |
|
|
|
import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } from "react"; |
|
|
@@ -59,8 +59,8 @@ interface Props { |
|
|
|
itemDetail: StockInLine & { qcResult?: PurchaseQcResult[] } & { escResult?: EscalationResult[] }; |
|
|
|
qc: QcItemWithChecks[]; |
|
|
|
disabled: boolean; |
|
|
|
qcItems: QcData[] |
|
|
|
setQcItems: Dispatch<SetStateAction<QcData[]>> |
|
|
|
// qcItems: QcData[] |
|
|
|
// setQcItems: Dispatch<SetStateAction<QcData[]>> |
|
|
|
} |
|
|
|
|
|
|
|
type EntryError = |
|
|
@@ -71,7 +71,7 @@ type EntryError = |
|
|
|
|
|
|
|
type QcRow = TableRow<Partial<QcData>, EntryError>; |
|
|
|
// fetchQcItemCheck |
|
|
|
const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQcItems }) => { |
|
|
|
const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled = false }) => { |
|
|
|
const { t } = useTranslation("purchaseOrder"); |
|
|
|
const apiRef = useGridApiRef(); |
|
|
|
const { |
|
|
@@ -93,8 +93,9 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
// const [qcResult, setQcResult] = useState(); |
|
|
|
const qcAccept = watch("qcAccept"); |
|
|
|
const qcDecision = watch("qcDecision"); //WIP |
|
|
|
const qcResult = watch("qcResult"); |
|
|
|
console.log(qcResult); |
|
|
|
// const qcResult = useMemo(() => [...watch("qcResult")], [watch("qcResult")]); |
|
|
|
const qcResult = [...watch("qcResult")]; |
|
|
|
|
|
|
|
// const [qcAccept, setQcAccept] = useState(true); |
|
|
|
// const [qcItems, setQcItems] = useState(dummyQCData) |
|
|
|
|
|
|
@@ -119,32 +120,59 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
[], |
|
|
|
); |
|
|
|
|
|
|
|
// W I P // |
|
|
|
const validateFieldFail = (field : FieldPath<PurchaseQCInput>, condition: boolean, message: string) : boolean => { |
|
|
|
// console.log("Checking if " + message) |
|
|
|
if (condition) { setError(field, { message: message}); return false; } |
|
|
|
else { clearErrors(field); return true; } |
|
|
|
} |
|
|
|
|
|
|
|
//// validate form |
|
|
|
const accQty = watch("acceptQty"); |
|
|
|
const validateForm = useCallback(() => { |
|
|
|
if (qcDecision == 1) { |
|
|
|
if (accQty > itemDetail.acceptedQty) { |
|
|
|
setError("acceptQty", { |
|
|
|
message: `${t("acceptQty must not greater than")} ${ |
|
|
|
itemDetail.acceptedQty |
|
|
|
}`, |
|
|
|
type: "required", |
|
|
|
}); |
|
|
|
if (accQty > itemDetail.acceptedQty){ |
|
|
|
setError("acceptQty", { message: `${t("acceptQty must not greater than")} ${ |
|
|
|
itemDetail.acceptedQty}` }); |
|
|
|
} |
|
|
|
if (accQty < 1) { |
|
|
|
setError("acceptQty", { |
|
|
|
message: t("minimal value is 1"), |
|
|
|
type: "required", |
|
|
|
}); |
|
|
|
if (accQty < 1){ |
|
|
|
setError("acceptQty", { message: t("minimal value is 1") }); |
|
|
|
} |
|
|
|
if (isNaN(accQty)) { |
|
|
|
setError("acceptQty", { |
|
|
|
message: t("value must be a number"), |
|
|
|
type: "required", |
|
|
|
}); |
|
|
|
if (isNaN(accQty)){ |
|
|
|
setError("acceptQty", { message: t("value must be a number") }); |
|
|
|
} |
|
|
|
} |
|
|
|
}, [accQty, qcDecision]); |
|
|
|
},[setError, qcDecision, accQty, itemDetail]) |
|
|
|
|
|
|
|
useEffect(() => { // W I P // ----- |
|
|
|
if (qcDecision == 1) { |
|
|
|
if (validateFieldFail("acceptQty", accQty > itemDetail.acceptedQty, `${t("acceptQty must not greater than")} ${ |
|
|
|
itemDetail.acceptedQty}`)) return; |
|
|
|
|
|
|
|
if (validateFieldFail("acceptQty", accQty < 1, t("minimal value is 1"))) return; |
|
|
|
if (validateFieldFail("acceptQty", isNaN(accQty), t("value must be a number"))) return; |
|
|
|
} |
|
|
|
|
|
|
|
const qcResultItems = qcResult; console.log("Validating:", qcResultItems); |
|
|
|
// Check if failed items have failed quantity |
|
|
|
const failedItemsWithoutQty = qcResultItems.filter(item => |
|
|
|
item.qcPassed === false && (!item.failQty || item.failQty <= 0) |
|
|
|
); |
|
|
|
if (validateFieldFail("qcResult", failedItemsWithoutQty.length > 0, `${t("Failed items must have failed quantity")}`)) return; |
|
|
|
|
|
|
|
// Check if all QC items have results |
|
|
|
const itemsWithoutResult = qcResultItems.filter(item => item.qcPassed === undefined); |
|
|
|
if (validateFieldFail("qcDecision", (itemsWithoutResult.length > 0 && itemDetail.status != "escalated"), |
|
|
|
`${t("QC items without result")}`)) return; |
|
|
|
|
|
|
|
if (validateFieldFail("qcDecision", (!qcResultItems.every((qc) => qc.qcPassed) && qcDecision == 1 && itemDetail.status != "escalated"), |
|
|
|
"有不合格檢查項目,無法收貨!")) return; // TODO: Fix it please |
|
|
|
// submitDialogWithWarning(() => postStockInLineWithQc(qcData), t, {title:"有不合格檢查項目,確認接受收貨?", |
|
|
|
// confirmButtonText: t("confirm putaway"), html: ""}); |
|
|
|
// return; |
|
|
|
|
|
|
|
// console.log("Validated without errors"); |
|
|
|
}, [accQty, qcDecision, watch("qcResult")]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
clearErrors(); |
|
|
@@ -188,39 +216,41 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
return <Checkbox checked={!!value} onChange={handleChange} sx={{ p: 0 }} />; |
|
|
|
} |
|
|
|
|
|
|
|
const qcColumns: GridColDef[] = [ |
|
|
|
const qcColumns: GridColDef[] = useMemo(() => [ |
|
|
|
{ |
|
|
|
field: "code", |
|
|
|
headerName: t("qcItem"), |
|
|
|
flex: 2, |
|
|
|
renderCell: (params) => ( |
|
|
|
renderCell: (params) => { |
|
|
|
const index = params.api.getRowIndexRelativeToVisibleRows(params.id) + 1; |
|
|
|
return ( |
|
|
|
<Box> |
|
|
|
<b>{`${params.api.getRowIndexRelativeToVisibleRows(params.id) + 1}. ${params.value}`}</b><br/> |
|
|
|
<b>{`${index}. ${params.value}`}</b><br/> |
|
|
|
{params.row.name}<br/> |
|
|
|
</Box> |
|
|
|
), |
|
|
|
)}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'qcPassed', |
|
|
|
field: 'qcResult', |
|
|
|
headerName: t("qcResult"), |
|
|
|
flex: 1.5, |
|
|
|
renderCell: (params) => { |
|
|
|
const currentValue = params.row; |
|
|
|
const rowValue = params.row; |
|
|
|
const index = params.api.getRowIndexRelativeToVisibleRows(params.id); |
|
|
|
// console.log(currentValue.row); |
|
|
|
// console.log(rowValue.row); |
|
|
|
return ( |
|
|
|
<FormControl> |
|
|
|
<RadioGroup |
|
|
|
row |
|
|
|
aria-labelledby="demo-radio-buttons-group-label" |
|
|
|
value={currentValue.qcPassed === undefined ? "" : (currentValue.qcPassed ? "true" : "false")} |
|
|
|
// value={currentValue.qcPassed === undefined ? (currentValue.failQty!==undefined?(currentValue.failQty==0?"true":"false"):"") : (currentValue.qcPassed ? "true" : "false")} |
|
|
|
// defaultValue={""} |
|
|
|
value={rowValue.qcPassed === undefined ? "" : (rowValue.qcPassed ? "true" : "false")} |
|
|
|
onChange={(e) => { |
|
|
|
const value = e.target.value; |
|
|
|
setQcItems((prev) => |
|
|
|
prev.map((r): QcData => (r.id === params.id ? { ...r, qcPassed: value === "true" } : r)) |
|
|
|
); |
|
|
|
// setValue(`qcResult.${index}.qcPassed`, value == "true"); |
|
|
|
const value = (e.target.value === "true"); |
|
|
|
// setQcItems((prev) => |
|
|
|
// prev.map((r): QcData => (r.id === params.id ? { ...r, qcPassed: value === "true" } : r)) |
|
|
|
// ); |
|
|
|
setValue(`qcResult.${index}.qcPassed`, value); |
|
|
|
}} |
|
|
|
name={`qcPassed-${params.id}`} |
|
|
|
> |
|
|
@@ -230,7 +260,7 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
label="合格" |
|
|
|
disabled={disabled || itemDetail.status == "escalated"} |
|
|
|
sx={{ |
|
|
|
color: currentValue.qcPassed === true ? "green" : "inherit", |
|
|
|
color: rowValue.qcPassed === true ? "green" : "inherit", |
|
|
|
"& .Mui-checked": {color: "green"} |
|
|
|
}} |
|
|
|
/> |
|
|
@@ -240,7 +270,7 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
label="不合格" |
|
|
|
disabled={disabled || itemDetail.status == "escalated"} |
|
|
|
sx={{ |
|
|
|
color: currentValue.qcPassed === false ? "red" : "inherit", |
|
|
|
color: rowValue.qcPassed === false ? "red" : "inherit", |
|
|
|
"& .Mui-checked": {color: "red"} |
|
|
|
}} |
|
|
|
/> |
|
|
@@ -254,58 +284,68 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
headerName: t("failedQty"), |
|
|
|
flex: 1, |
|
|
|
// editable: true, |
|
|
|
renderCell: (params) => ( |
|
|
|
<TextField |
|
|
|
type="number" |
|
|
|
size="small" |
|
|
|
value={!params.row.qcPassed? (params.value ?? '') : '0'} |
|
|
|
disabled={params.row.qcPassed || disabled || itemDetail.status == "escalated"} |
|
|
|
onChange={(e) => { |
|
|
|
const v = e.target.value; |
|
|
|
const next = v === '' ? undefined : Number(v); |
|
|
|
if (Number.isNaN(next)) return; |
|
|
|
setQcItems((prev) => |
|
|
|
prev.map((r) => (r.id === params.id ? { ...r, failQty: next } : r)) |
|
|
|
); |
|
|
|
// setValue(`failQty`,failQty); |
|
|
|
}} |
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
onMouseDown={(e) => e.stopPropagation()} |
|
|
|
onKeyDown={(e) => e.stopPropagation()} |
|
|
|
inputProps={{ min: 0 }} |
|
|
|
sx={{ width: '100%' }} |
|
|
|
/> |
|
|
|
), |
|
|
|
renderCell: (params) => { |
|
|
|
const index = params.api.getRowIndexRelativeToVisibleRows(params.id); |
|
|
|
return ( |
|
|
|
<TextField |
|
|
|
type="number" |
|
|
|
size="small" |
|
|
|
value={!params.row.qcPassed? params.value : '0'} |
|
|
|
disabled={params.row.qcPassed || disabled || itemDetail.status == "escalated"} |
|
|
|
onBlur={(e) => { |
|
|
|
const v = e.target.value; |
|
|
|
const next = v === '' ? undefined : Number(v); |
|
|
|
if (Number.isNaN(next)) return; |
|
|
|
// setQcItems((prev) => |
|
|
|
// prev.map((r) => (r.id === params.id ? { ...r, failQty: next } : r)) |
|
|
|
// ); |
|
|
|
setValue(`qcResult.${index}.failQty`, next); |
|
|
|
}} |
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
onMouseDown={(e) => e.stopPropagation()} |
|
|
|
onKeyDown={(e) => e.stopPropagation()} |
|
|
|
inputProps={{ min: 0 }} |
|
|
|
sx={{ width: '100%' }} |
|
|
|
/> |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: "remarks", |
|
|
|
headerName: t("remarks"), |
|
|
|
flex: 2, |
|
|
|
renderCell: (params) => ( |
|
|
|
<TextField |
|
|
|
size="small" |
|
|
|
value={params.value ?? ''} |
|
|
|
disabled={disabled || itemDetail.status == "escalated"} |
|
|
|
onChange={(e) => { |
|
|
|
const remarks = e.target.value; |
|
|
|
// const next = v === '' ? undefined : Number(v); |
|
|
|
// if (Number.isNaN(next)) return; |
|
|
|
setQcItems((prev) => |
|
|
|
prev.map((r) => (r.id === params.id ? { ...r, remarks: remarks } : r)) |
|
|
|
); |
|
|
|
}} |
|
|
|
// {...register(`qcResult.${params.row.rowIndex}.remarks`, { |
|
|
|
// required: "remarks required!", |
|
|
|
// })} |
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
onMouseDown={(e) => e.stopPropagation()} |
|
|
|
onKeyDown={(e) => e.stopPropagation()} |
|
|
|
inputProps={{ min: 0 }} |
|
|
|
sx={{ width: '100%' }} |
|
|
|
/> |
|
|
|
), |
|
|
|
renderCell: (params) => { |
|
|
|
const index = params.api.getRowIndexRelativeToVisibleRows(params.id); |
|
|
|
return ( |
|
|
|
<TextField |
|
|
|
size="small" |
|
|
|
defaultValue={params.value} |
|
|
|
disabled={disabled || itemDetail.status == "escalated"} |
|
|
|
onBlur={(e) => { |
|
|
|
const value = e.target.value; |
|
|
|
setValue(`qcResult.${index}.remarks`, value); |
|
|
|
}} |
|
|
|
// onChange={(e) => { |
|
|
|
// const remarks = e.target.value; |
|
|
|
// // const next = v === '' ? undefined : Number(v); |
|
|
|
// // if (Number.isNaN(next)) return; |
|
|
|
// // setQcItems((prev) => |
|
|
|
// // prev.map((r) => (r.id === params.id ? { ...r, remarks: remarks } : r)) |
|
|
|
// // ); |
|
|
|
// }} |
|
|
|
// {...register(`qcResult.${index}.remarks`, { |
|
|
|
// required: "remarks required!", |
|
|
|
// })} |
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
onMouseDown={(e) => e.stopPropagation()} |
|
|
|
onKeyDown={(e) => e.stopPropagation()} |
|
|
|
inputProps={{ min: 0 }} |
|
|
|
sx={{ width: '100%' }} |
|
|
|
/> |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
], []) |
|
|
|
|
|
|
|
// Set initial value for acceptQty |
|
|
|
useEffect(() => { |
|
|
@@ -316,12 +356,23 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
} |
|
|
|
}, [itemDetail?.demandQty, itemDetail?.acceptedQty, setValue]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
// console.log("Qc Result updated:", qcResult); |
|
|
|
if (qcResult.length < 1) { // New QC |
|
|
|
const mutableQcData = dummyQCData; |
|
|
|
// const mutableQcData = JSON.parse(JSON.stringify(dummyQCData)); |
|
|
|
// replace([mutableQcData]); |
|
|
|
setValue("qcResult", mutableQcData); |
|
|
|
// setValue("qcResult.0.qcPassed", false); |
|
|
|
} |
|
|
|
}, [qcResult, setValue]) |
|
|
|
|
|
|
|
// const [openCollapse, setOpenCollapse] = useState(false) |
|
|
|
const [isCollapsed, setIsCollapsed] = useState<boolean>(true); |
|
|
|
|
|
|
|
const onFailedOpenCollapse = useCallback((qcItems: PurchaseQcResult[]) => { |
|
|
|
const isFailed = qcItems.some((qc) => !qc.qcPassed) |
|
|
|
console.log(isFailed) |
|
|
|
// console.log(isFailed) |
|
|
|
if (isFailed) { |
|
|
|
setIsCollapsed(true) |
|
|
|
} else { |
|
|
@@ -336,30 +387,29 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
console.log("ItemDetail in QC:", itemDetail); |
|
|
|
console.log("Qc Result in QC:", qcResult); |
|
|
|
console.log("%c QC ItemDetail updated:", "color: gold", itemDetail); |
|
|
|
|
|
|
|
}, [itemDetail]); |
|
|
|
|
|
|
|
const setQcDecision = (status : string | undefined) => { |
|
|
|
const setDefaultQcDecision = (status : string | undefined) => { |
|
|
|
const param = status?.toLowerCase(); |
|
|
|
if (param !== undefined && param !== null) { |
|
|
|
if (param == "completed") { |
|
|
|
if (param == "completed" || param == "partially_completed") { |
|
|
|
return 1; |
|
|
|
} else if (param == "rejected") { |
|
|
|
return 2; |
|
|
|
} else if (param == "escalated") { |
|
|
|
return 3; |
|
|
|
return 1; // For new flow |
|
|
|
// return 3; |
|
|
|
} else { return undefined; } |
|
|
|
} else { |
|
|
|
return undefined; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
// onFailedOpenCollapse(qcItems) // This function is no longer needed |
|
|
|
}, [qcItems]); |
|
|
|
// useEffect(() => { |
|
|
|
// // onFailedOpenCollapse(qcItems) |
|
|
|
// }, [qcItems]); |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
@@ -405,9 +455,11 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
/> */} |
|
|
|
<StyledDataGrid |
|
|
|
columns={qcColumns} |
|
|
|
rows={qcResult && qcResult.length > 0 ? qcResult : qcItems} |
|
|
|
rows={qcResult} |
|
|
|
// rows={qcResult && qcResult.length > 0 ? qcResult : qcItems} |
|
|
|
// rows={disabled? qcResult:qcItems} |
|
|
|
autoHeight |
|
|
|
sortModel={[]} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
</> |
|
|
@@ -443,57 +495,69 @@ const QcComponent: React.FC<Props> = ({ qc, itemDetail, disabled, qcItems, setQc |
|
|
|
name="qcDecision" |
|
|
|
// name="qcAccept" |
|
|
|
control={control} |
|
|
|
defaultValue={setQcDecision(itemDetail?.status)} |
|
|
|
defaultValue={setDefaultQcDecision(itemDetail?.status)} |
|
|
|
// defaultValue={true} |
|
|
|
render={({ field }) => ( |
|
|
|
<RadioGroup |
|
|
|
row |
|
|
|
aria-labelledby="demo-radio-buttons-group-label" |
|
|
|
{...field} |
|
|
|
value={field.value} |
|
|
|
// value={field.value?.toString() || "true"} |
|
|
|
onChange={(e) => { |
|
|
|
const value = e.target.value.toString();// === 'true'; |
|
|
|
if (value != "1" && Boolean(errors.acceptQty)) { |
|
|
|
// if (!value && Boolean(errors.acceptQty)) { |
|
|
|
setValue("acceptQty", itemDetail.acceptedQty ?? 0); |
|
|
|
} |
|
|
|
field.onChange(value); |
|
|
|
}} |
|
|
|
> |
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="1" control={<Radio />} label="接受來貨" /> |
|
|
|
|
|
|
|
{itemDetail.status == "escalated" && (<Box sx={{mr:2}}> |
|
|
|
<TextField |
|
|
|
type="number" |
|
|
|
label={t("acceptQty")} |
|
|
|
sx={{ width: '150px' }} |
|
|
|
value={(qcDecision == 1)? accQty : 0 } |
|
|
|
// value={qcAccept? accQty : 0 } |
|
|
|
disabled={qcDecision != 1 || disabled} |
|
|
|
// disabled={!qcAccept || disabled} |
|
|
|
{...register("acceptQty", { |
|
|
|
required: "acceptQty required!", |
|
|
|
})} |
|
|
|
error={Boolean(errors.acceptQty)} |
|
|
|
helperText={errors.acceptQty?.message} |
|
|
|
/> |
|
|
|
</Box>)} |
|
|
|
|
|
|
|
{itemDetail.status == "pending" && (<> |
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="2" control={<Radio />} |
|
|
|
sx={{"& .Mui-checked": {color: "red"}}} |
|
|
|
label="不接受並退貨" /> |
|
|
|
|
|
|
|
<> |
|
|
|
{/* <Typography sx={{color:"red"}}> |
|
|
|
{errors.qcDecision?.message} |
|
|
|
</Typography> */} |
|
|
|
<RadioGroup |
|
|
|
row |
|
|
|
aria-labelledby="demo-radio-buttons-group-label" |
|
|
|
{...field} |
|
|
|
value={field.value} |
|
|
|
// value={field.value?.toString() || "true"} |
|
|
|
onChange={(e) => { |
|
|
|
const value = e.target.value.toString();// === 'true'; |
|
|
|
if (value != "1" && Boolean(errors.acceptQty)) { |
|
|
|
// if (!value && Boolean(errors.acceptQty)) { |
|
|
|
setValue("acceptQty", itemDetail.acceptedQty ?? 0); |
|
|
|
} |
|
|
|
field.onChange(value); |
|
|
|
}} |
|
|
|
> |
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="1" control={<Radio />} label="接受來貨" /> |
|
|
|
|
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="3" control={<Radio />} |
|
|
|
sx={{"& .Mui-checked": {color: "blue"}}} |
|
|
|
label="上報品檢結果" /> |
|
|
|
</>)} |
|
|
|
</RadioGroup> |
|
|
|
{(itemDetail.status == "escalated" || (disabled && accQty != itemDetail.acceptedQty && qcDecision == 1)) && ( //TODO Improve |
|
|
|
<Box sx={{mr:2}}> |
|
|
|
<TextField |
|
|
|
type="number" |
|
|
|
label={t("acceptQty")} |
|
|
|
sx={{ width: '150px' }} |
|
|
|
value={(qcDecision == 1)? Number(accQty) : 0 } |
|
|
|
// value={qcAccept? accQty : 0 } |
|
|
|
disabled={qcDecision != 1 || disabled} |
|
|
|
// disabled={!qcAccept || disabled} |
|
|
|
{...register("acceptQty", { |
|
|
|
required: "acceptQty required!", |
|
|
|
})} |
|
|
|
error={Boolean(errors.acceptQty)} |
|
|
|
helperText={errors.acceptQty?.message} |
|
|
|
/> |
|
|
|
<TextField |
|
|
|
type="number" |
|
|
|
label={t("rejectQty")} |
|
|
|
sx={{ width: '150px' }} |
|
|
|
value={itemDetail.acceptedQty - accQty} |
|
|
|
disabled={true} |
|
|
|
/> |
|
|
|
</Box>)} |
|
|
|
|
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="2" control={<Radio />} |
|
|
|
sx={{"& .Mui-checked": {color: "red"}}} |
|
|
|
label= {itemDetail.status == "escalated" ? "全部拒絕並退貨" : "不接受並退貨"} /> |
|
|
|
|
|
|
|
{(itemDetail.status == "pending" || disabled) && (<> |
|
|
|
<FormControlLabel disabled={disabled} |
|
|
|
value="3" control={<Radio />} |
|
|
|
sx={{"& .Mui-checked": {color: "blue"}}} |
|
|
|
label="上報品檢結果" /> |
|
|
|
</>)} |
|
|
|
</RadioGroup> |
|
|
|
</> |
|
|
|
)} |
|
|
|
/> |
|
|
|
</FormControl> |
|
|
|