Browse Source

fix

master
kelvin.yau 2 months ago
parent
commit
ac7ab93ebb
7 changed files with 34 additions and 24 deletions
  1. +12
    -2
      src/app/api/jo/actions.ts
  2. +3
    -3
      src/components/FinishedGoodSearch/FinishedGoodSearch.tsx
  3. +1
    -3
      src/components/JoSave/InfoCard.tsx
  4. +7
    -0
      src/components/JoSave/JoRelease.tsx
  5. +9
    -3
      src/components/JoSave/JoSave.tsx
  6. +0
    -12
      src/components/JoSave/PickTable.tsx
  7. +2
    -1
      src/i18n/zh/pickOrder.json

+ 12
- 2
src/app/api/jo/actions.ts View File

@@ -254,21 +254,31 @@ export const fetchJos = cache(async (data?: SearchJoResultRequest) => {
}) })


export const releaseJo = cache(async (data: CommonActionJoRequest) => { export const releaseJo = cache(async (data: CommonActionJoRequest) => {
return serverFetchJson<CommonActionJoResponse>(`${BASE_API_URL}/jo/release`,
const response = serverFetchJson<CommonActionJoResponse>(`${BASE_API_URL}/jo/release`,
{ {
method: "POST", method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}) })
// Invalidate the cache after releasing
revalidateTag("jo");
return response;
}) })


export const startJo = cache(async (data: CommonActionJoRequest) => { export const startJo = cache(async (data: CommonActionJoRequest) => {
return serverFetchJson<CommonActionJoResponse>(`${BASE_API_URL}/jo/start`,
const response = serverFetchJson<CommonActionJoResponse>(`${BASE_API_URL}/jo/start`,
{ {
method: "POST", method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
}) })
// Invalidate the cache after starting
revalidateTag("jo");
return response;
}) })


export const manualCreateJo = cache(async (data: SaveJo) => { export const manualCreateJo = cache(async (data: SaveJo) => {


+ 3
- 3
src/components/FinishedGoodSearch/FinishedGoodSearch.tsx View File

@@ -75,7 +75,7 @@ const PickOrderSearch: React.FC<Props> = ({ pickOrders }) => {
const currentFgOrder = fgPickOrdersData[0]; const currentFgOrder = fgPickOrdersData[0];


const printRequest = { const printRequest = {
printerId: 2,
printerId: 1,
printQty: 1, printQty: 1,
isDraft: true, isDraft: true,
numOfCarton: 0, numOfCarton: 0,
@@ -141,7 +141,7 @@ const PickOrderSearch: React.FC<Props> = ({ pickOrders }) => {
const currentFgOrder = fgPickOrdersData[0]; const currentFgOrder = fgPickOrdersData[0];


const printRequest = { const printRequest = {
printerId: 2,
printerId: 1,
printQty: 1, printQty: 1,
isDraft: false, isDraft: false,
numOfCarton: numOfCartons, numOfCarton: numOfCartons,
@@ -208,7 +208,7 @@ const PickOrderSearch: React.FC<Props> = ({ pickOrders }) => {
const currentFgOrder = fgPickOrdersData[0]; const currentFgOrder = fgPickOrdersData[0];


const printDNRequest = { const printDNRequest = {
printerId: 2,
printerId: 1,
printQty: 1, printQty: 1,
isDraft: false, isDraft: false,
numOfCarton: numOfCartons, numOfCarton: numOfCartons,


+ 1
- 3
src/components/JoSave/InfoCard.tsx View File

@@ -88,9 +88,7 @@ const InfoCard: React.FC<Props> = ({
label={t("Production Priority")} label={t("Production Priority")}
fullWidth fullWidth
disabled={true} disabled={true}
{
...register("id")
}
value={50}
/> />
</Grid> </Grid>
</Grid> </Grid>


+ 7
- 0
src/components/JoSave/JoRelease.tsx View File

@@ -24,6 +24,12 @@ const JoRelease: React.FC<Props> = ({


const { watch } = useFormContext<JoDetail>(); const { watch } = useFormContext<JoDetail>();


const status = useMemo(() => {
const currentStatus = watch("status").toLowerCase();
console.log("JoRelease status:", currentStatus, "id:", pickLines[0]?.id);
return currentStatus;
}, [watch("status")])

useEffect(() => { useEffect(() => {
const fetchInventoryData = async () => { const fetchInventoryData = async () => {
try { try {
@@ -98,6 +104,7 @@ const JoRelease: React.FC<Props> = ({
variant="contained" variant="contained"
color="primary" color="primary"
onClick={handleRelease} onClick={handleRelease}
disabled={stockCounts.insufficient > 0 || status !== "planning"}
> >
{t("Release")} {t("Release")}
</Button> </Button>


+ 9
- 3
src/components/JoSave/JoSave.tsx View File

@@ -32,7 +32,8 @@ const JoSave: React.FC<Props> = ({
const scanner = useQrCodeScannerContext() const scanner = useQrCodeScannerContext()
const [serverError, setServerError] = useState(""); const [serverError, setServerError] = useState("");


const finalDefaultValues = useMemo(() => {
const finalDefaultValues = useMemo(() => {
console.log("finalDefaultValues recalculated", defaultValues?.status, id);
const values = { const values = {
...defaultValues, ...defaultValues,
pickLines: defaultValues?.pickLines?.map(line => ({ pickLines: defaultValues?.pickLines?.map(line => ({
@@ -47,11 +48,16 @@ const JoSave: React.FC<Props> = ({
} }


return values; return values;
}, [defaultValues])
}, [defaultValues, id])


const formProps = useForm<JoDetail>({ const formProps = useForm<JoDetail>({
defaultValues: finalDefaultValues
defaultValues: finalDefaultValues,
}) })

useEffect(() => {
formProps.reset(finalDefaultValues);
}, [finalDefaultValues, formProps.reset])

const pickLines = useMemo(() => { const pickLines = useMemo(() => {
return formProps.watch("pickLines") return formProps.watch("pickLines")
}, [formProps.watch("pickLines")]) }, [formProps.watch("pickLines")])


+ 0
- 12
src/components/JoSave/PickTable.tsx View File

@@ -65,16 +65,6 @@ const PickTable: React.FC<Props> = ({
return 0; return 0;
}; };


const getUomShortDesc = (pickLine: JoDetailPickLine) => {
const inventory = inventoryData.find(inventory =>
inventory.itemCode === pickLine.code || inventory.itemName === pickLine.name
);
console.log("inventory", inventory)

return inventory?.uomShortDesc; // || pickLine.uom;
};

const isStockSufficient = (pickLine: JoDetailPickLine) => { const isStockSufficient = (pickLine: JoDetailPickLine) => {
const stockAvailable = getStockAvailable(pickLine); const stockAvailable = getStockAvailable(pickLine);
return stockAvailable >= pickLine.reqQty; return stockAvailable >= pickLine.reqQty;
@@ -180,7 +170,6 @@ const PickTable: React.FC<Props> = ({
align: "right", align: "right",
headerAlign: "right", headerAlign: "right",
renderCell: (params: GridRenderCellParams<JoDetailPickLine>) => { renderCell: (params: GridRenderCellParams<JoDetailPickLine>) => {
const uomShortDesc = getUomShortDesc(params.row);
return `${decimalFormatter.format(params.value)} (${params.row.shortUom})`; return `${decimalFormatter.format(params.value)} (${params.row.shortUom})`;
}, },
}, },
@@ -192,7 +181,6 @@ const PickTable: React.FC<Props> = ({
headerAlign: "right", headerAlign: "right",
type: "number", type: "number",
renderCell: (params: GridRenderCellParams<JoDetailPickLine>) => { renderCell: (params: GridRenderCellParams<JoDetailPickLine>) => {
const uomShortDesc = getUomShortDesc(params.row);
return `${decimalFormatter.format(params.value)} (${params.row.shortUom})`; return `${decimalFormatter.format(params.value)} (${params.row.shortUom})`;
}, },
}, },


+ 2
- 1
src/i18n/zh/pickOrder.json View File

@@ -291,7 +291,8 @@
"You need to enter a number": "箱數不能為空", "You need to enter a number": "箱數不能為空",
"Number must be at least 1": "箱數最少為一", "Number must be at least 1": "箱數最少為一",
"Printed Successfully.": "已成功列印", "Printed Successfully.": "已成功列印",
"Total exceeds required qty":"總數超出所需數量"
"Total exceeds required qty":"總數超出所需數量",
"Enter the number of cartons:": "請輸入總箱數"






Loading…
Cancel
Save