Browse Source

update

master
cyril.tsui 2 weeks ago
parent
commit
fd34051aa6
3 changed files with 48 additions and 8 deletions
  1. +1
    -0
      src/app/api/po/index.ts
  2. +44
    -6
      src/app/api/scheduling/actions.ts
  3. +3
    -2
      src/components/DetailedSchedule/DetailedScheduleSearchView.tsx

+ 1
- 0
src/app/api/po/index.ts View File

@@ -14,6 +14,7 @@ export interface PoResult {
supplier: string; supplier: string;
estimatedArrivalDate: string; estimatedArrivalDate: string;
completedDate: string; completedDate: string;
itemDetail?: String;
escalated: boolean; escalated: boolean;
status: string; status: string;
pol?: PurchaseOrderLine[]; pol?: PurchaseOrderLine[];


+ 44
- 6
src/app/api/scheduling/actions.ts View File

@@ -11,6 +11,7 @@ export interface SearchProdSchedule {
scheduleAt?: string; scheduleAt?: string;
schedulePeriod?: string; schedulePeriod?: string;
schedulePeriodTo?: string; schedulePeriodTo?: string;
produceAt?: string;
totalEstProdCount?: number; totalEstProdCount?: number;
types?: ScheduleType[]; types?: ScheduleType[];
pageSize?: number; pageSize?: number;
@@ -20,8 +21,9 @@ export interface SearchProdSchedule {
export interface ProdScheduleResult { export interface ProdScheduleResult {
id: number; id: number;
scheduleAt: number[]; scheduleAt: number[];
schedulePeriod: number[];
schedulePeriodTo: number[];
schedulePeriod?: number[];
schedulePeriodTo?: number[];
produceAt: string;
totalEstProdCount: number; totalEstProdCount: number;
totalFGType: number; totalFGType: number;
type: string; type: string;
@@ -72,6 +74,40 @@ export const fetchProdSchedules = cache(
}, },
); );


export const fetchRoughProdSchedules = cache(
async (data: SearchProdSchedule | null) => {
const params = convertObjToURLSearchParams<SearchProdSchedule>(data);
// console.log(params)
return serverFetchJson<ProdScheduleResultByPage>(
`${BASE_API_URL}/productionSchedule/getRecordByPage/rough?${params}`,
{
method: "GET",
headers: { "Content-Type": "application/json" },
next: {
tags: ["roughProdSchedules"],
},
},
);
},
);

export const fetchDetailedProdSchedules = cache(
async (data: SearchProdSchedule | null) => {
const params = convertObjToURLSearchParams<SearchProdSchedule>(data);
// console.log(params)
return serverFetchJson<ProdScheduleResultByPage>(
`${BASE_API_URL}/productionSchedule/getRecordByPage/detailed?${params}`,
{
method: "GET",
headers: { "Content-Type": "application/json" },
next: {
tags: ["detailedProdSchedules"],
},
},
);
},
);

export const testRoughSchedule = cache(async () => { export const testRoughSchedule = cache(async () => {
return serverFetchJson( return serverFetchJson(
`${BASE_API_URL}/productionSchedule/testRoughSchedule`, `${BASE_API_URL}/productionSchedule/testRoughSchedule`,
@@ -79,7 +115,7 @@ export const testRoughSchedule = cache(async () => {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
next: { next: {
tags: ["prodSchedules"],
tags: ["roughProdSchedules"],
}, },
}, },
); );
@@ -93,7 +129,7 @@ export const testDetailedSchedule = cache(async (date?: string) => {
method: "GET", method: "GET",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
next: { next: {
tags: ["prodSchedules"],
tags: ["detailedProdSchedules"],
}, },
}, },
); );
@@ -109,7 +145,8 @@ export const releaseProdScheduleLine = cache(async (data: ReleaseProdScheduleInp
} }
); );


revalidateTag("prodSchedules");
revalidateTag("detailedProdSchedules");
revalidateTag("prodSchedule");


return response; return response;
}) })
@@ -124,7 +161,8 @@ export const saveProdScheduleLine = cache(async (data: ReleaseProdScheduleInputs
} }
); );


revalidateTag("prodSchedules");
revalidateTag("detailedProdSchedules");
revalidateTag("prodSchedule");


return response; return response;
}) })

+ 3
- 2
src/components/DetailedSchedule/DetailedScheduleSearchView.tsx View File

@@ -10,6 +10,7 @@ import { ScheduleType } from "@/app/api/scheduling";
import { import {
ProdScheduleResult, ProdScheduleResult,
SearchProdSchedule, SearchProdSchedule,
fetchDetailedProdSchedules,
fetchProdSchedules, fetchProdSchedules,
testDetailedSchedule, testDetailedSchedule,
} from "@/app/api/scheduling/actions"; } from "@/app/api/scheduling/actions";
@@ -192,7 +193,7 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
pageNum: pagingController.pageNum - 1, pageNum: pagingController.pageNum - 1,
pageSize: pagingController.pageSize, pageSize: pagingController.pageSize,
}; };
const response = await fetchProdSchedules(params);
const response = await fetchDetailedProdSchedules(params);


// console.log(response) // console.log(response)
if (response) { if (response) {
@@ -308,7 +309,7 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
<Button <Button
variant="contained" variant="contained"
onClick={testDetailedScheduleClick} onClick={testDetailedScheduleClick}
disabled={filteredSchedules.some(ele => arrayToDayjs(ele.scheduleAt).isToday())}
// disabled={filteredSchedules.some(ele => arrayToDayjs(ele.scheduleAt).isToday())}
> >
{t("Test Detailed Schedule")} {t("Test Detailed Schedule")}
</Button> </Button>


Loading…
Cancel
Save