|
|
|
@@ -231,6 +231,32 @@ function lineUomDisplay(line?: DoDetailLine | null): string { |
|
|
|
return (line.shortUom ?? line.uomCode ?? line.uom ?? "").trim(); |
|
|
|
} |
|
|
|
|
|
|
|
function filterSourceDoLinesByItemNo( |
|
|
|
lines: DoDetailLine[], |
|
|
|
inputValue: string, |
|
|
|
): DoDetailLine[] { |
|
|
|
const query = inputValue.trim().toLowerCase(); |
|
|
|
if (!query) return lines; |
|
|
|
return lines.filter((line) => |
|
|
|
(line.itemNo ?? "").toLowerCase().includes(query), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function filterSourceDoLinesByItemName( |
|
|
|
lines: DoDetailLine[], |
|
|
|
inputValue: string, |
|
|
|
): DoDetailLine[] { |
|
|
|
const query = inputValue.trim().toLowerCase(); |
|
|
|
if (!query) return lines; |
|
|
|
return lines.filter((line) => |
|
|
|
(line.itemName ?? "").toLowerCase().includes(query), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
function sourceDoLineNameLabel(line: DoDetailLine): string { |
|
|
|
return (line.itemName ?? line.itemNo ?? "").trim(); |
|
|
|
} |
|
|
|
|
|
|
|
type DraftDoGroup = { |
|
|
|
sourceDoId: number; |
|
|
|
sourceDoCode: string; |
|
|
|
@@ -1190,13 +1216,9 @@ const DoReplenishmentTab: React.FC = () => { |
|
|
|
}} |
|
|
|
getOptionLabel={(line) => line.itemNo ?? ""} |
|
|
|
isOptionEqualToValue={(a, b) => a.id === b.id} |
|
|
|
filterOptions={(options, { inputValue }) => { |
|
|
|
const query = inputValue.trim().toLowerCase(); |
|
|
|
if (!query) return options; |
|
|
|
return options.filter((line) => |
|
|
|
(line.itemNo ?? "").toLowerCase().includes(query), |
|
|
|
); |
|
|
|
}} |
|
|
|
filterOptions={(options, { inputValue }) => |
|
|
|
filterSourceDoLinesByItemNo(options, inputValue) |
|
|
|
} |
|
|
|
renderInput={(params) => { |
|
|
|
const { inputProps } = params; |
|
|
|
return ( |
|
|
|
@@ -1225,11 +1247,38 @@ const DoReplenishmentTab: React.FC = () => { |
|
|
|
</ReplenishmentFilterField> |
|
|
|
|
|
|
|
<ReplenishmentFilterField title={t("Item Name")}> |
|
|
|
<ReplenishmentReadonlyValue> |
|
|
|
{selectedLine |
|
|
|
? (selectedLine.itemName ?? selectedLine.itemNo ?? "") |
|
|
|
: null} |
|
|
|
</ReplenishmentReadonlyValue> |
|
|
|
<Autocomplete |
|
|
|
size="small" |
|
|
|
fullWidth |
|
|
|
options={sourceDo.lines} |
|
|
|
value={selectedLine} |
|
|
|
onChange={(_, newValue) => setSelectedLine(newValue)} |
|
|
|
onInputChange={(_, inputValue, reason) => { |
|
|
|
if (reason === "clear") { |
|
|
|
setSelectedLine(null); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (reason === "input" && selectedLine) { |
|
|
|
const selectedName = sourceDoLineNameLabel(selectedLine); |
|
|
|
if (inputValue.trim() !== selectedName) { |
|
|
|
setSelectedLine(null); |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
getOptionLabel={sourceDoLineNameLabel} |
|
|
|
isOptionEqualToValue={(a, b) => a.id === b.id} |
|
|
|
filterOptions={(options, { inputValue }) => |
|
|
|
filterSourceDoLinesByItemName(options, inputValue) |
|
|
|
} |
|
|
|
renderInput={(params) => ( |
|
|
|
<ReplenishmentTextField |
|
|
|
{...params} |
|
|
|
placeholder={t("Replenishment item name")} |
|
|
|
InputProps={{ ...params.InputProps, disableUnderline: true }} |
|
|
|
/> |
|
|
|
)} |
|
|
|
sx={REPLENISHMENT_AUTOCOMPLETE_SX} |
|
|
|
/> |
|
|
|
</ReplenishmentFilterField> |
|
|
|
</Box> |
|
|
|
|
|
|
|
|