2 Commits

Author SHA1 Message Date
  tommy 8df6e68854 Merge branch 'production' of https://git.2fi-solutions.com/jason/FPSMS-frontend into production 6 days ago
  tommy 10ad3fc3ea DO補貨 search itemName 6 days ago
3 changed files with 63 additions and 12 deletions
Split View
  1. +61
    -12
      src/components/DoSearch/DoReplenishmentTab.tsx
  2. +1
    -0
      src/i18n/en/do.json
  3. +1
    -0
      src/i18n/zh/do.json

+ 61
- 12
src/components/DoSearch/DoReplenishmentTab.tsx View File

@@ -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>



+ 1
- 0
src/i18n/en/do.json View File

@@ -114,6 +114,7 @@
"Batch release replenishment info only": "Pending replenishments matching this search. For information only.",
"Replenishment Entry": "Replenishment Entry",
"Replenishment item code": "Item Code",
"Replenishment item name": "Item Name",
"Replenishment Tracking": "Replenishment Tracking",
"Required field": "Required field",
"replenishmentDatePlaceholder": "YYYY-MM-DD",


+ 1
- 0
src/i18n/zh/do.json View File

@@ -59,6 +59,7 @@
"Batch release replenishment info only": "以下為符合搜尋條件的待放單補貨,僅供查閱。",
"Replenishment Entry": "補貨填表",
"Replenishment item code": "貨品編號",
"Replenishment item name": "貨品名稱",
"Replenishment Tracking": "補貨進度追蹤",
"Required field": "為必填項",
"replenishmentDatePlaceholder": "YYYY-MM-DD",


Loading…
Cancel
Save