Selaa lähdekoodia

update

master
cyril.tsui 1 kuukausi sitten
vanhempi
commit
f3af4a6f60
3 muutettua tiedostoa jossa 51 lisäystä ja 25 poistoa
  1. +3
    -2
      src/app/api/scheduling/actions.ts
  2. +44
    -21
      src/components/DetailedSchedule/DetailedScheduleSearchView.tsx
  3. +4
    -2
      src/components/RoughSchedule/RoughSchedileSearchView.tsx

+ 3
- 2
src/app/api/scheduling/actions.ts Näytä tiedosto

@@ -85,9 +85,10 @@ export const testRoughSchedule = cache(async () => {
);
});

export const testDetailedSchedule = cache(async () => {
export const testDetailedSchedule = cache(async (date?: string) => {
const queryStr = convertObjToURLSearchParams({genDate: date})
return serverFetchJson(
`${BASE_API_URL}/productionSchedule/testDetailedSchedule`,
`${BASE_API_URL}/productionSchedule/testDetailedSchedule?${queryStr}`,
{
method: "GET",
headers: { "Content-Type": "application/json" },


+ 44
- 21
src/components/DetailedSchedule/DetailedScheduleSearchView.tsx Näytä tiedosto

@@ -11,11 +11,13 @@ import {
ProdScheduleResult,
SearchProdSchedule,
fetchProdSchedules,
testDetailedSchedule,
} from "@/app/api/scheduling/actions";
import { defaultPagingController } from "../SearchResults/SearchResults";
import { arrayToDateString, decimalFormatter } from "@/app/utils/formatUtil";
import dayjs from "dayjs";
import { uniqBy } from "lodash";
import { orderBy, uniqBy } from "lodash";
import { Button, Stack } from "@mui/material";

// may need move to "index" or "actions"
// type RecordStructure = {
@@ -63,12 +65,12 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {

const searchCriteria: Criterion<SearchParamNames>[] = useMemo(() => {
const searchCriteria: Criterion<SearchParamNames>[] = [
{
label: t("Schedule Period"),
label2: t("Schedule Period To"),
paramName: "schedulePeriod",
type: "dateRange",
},
// {
// label: t("Schedule Period"),
// label2: t("Schedule Period To"),
// paramName: "schedulePeriod",
// type: "dateRange",
// },
{ label: t("Production Date"), paramName: "scheduleAt", type: "date" },
{
label: t("Product Count"),
@@ -110,15 +112,15 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
onClick: (record) => onDetailClick(record),
buttonIcon: <EditNote />,
},
{
name: "schedulePeriod",
label: t("Demand Forecast Period"),
renderCell: (params) => {
return `${arrayToDateString(
params.schedulePeriod,
)} - ${arrayToDateString(params.schedulePeriodTo)}`;
},
},
// {
// name: "schedulePeriod",
// label: t("Demand Forecast Period"),
// renderCell: (params) => {
// return `${arrayToDateString(
// params.schedulePeriod,
// )} - ${arrayToDateString(params.schedulePeriodTo)}`;
// },
// },
{
name: "scheduleAt",
label: t("Production Date"),
@@ -169,8 +171,6 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
: query.types
) as ScheduleType[];

console.log(convertedTypes);
console.log(query.types);
const params: SearchProdSchedule = {
scheduleAt: dayjs(query?.scheduleAt).isValid()
? query?.scheduleAt
@@ -200,8 +200,9 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
break;
case "paging":
setFilteredSchedules((fs) =>
orderBy(
uniqBy([...fs, ...response.records], "id"),
);
["id"], ["desc"]));
break;
}
}
@@ -278,8 +279,30 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
refetchData(inputs, "reset");
}, []);

const testDetailedScheduleClick = useCallback(async () => {
console.log(inputs.scheduleAt)
const response = await testDetailedSchedule(inputs.scheduleAt)

if (response) {
refetchData(inputs, "paging");
}
}, [])

return (
<>
<Stack
direction="row"
justifyContent="flex-end"
flexWrap="wrap"
rowGap={2}
>
<Button
variant="contained"
onClick={testDetailedScheduleClick}
>
{t("Test Detailed Schedule")}
</Button>
</Stack>
<SearchBox
criteria={searchCriteria}
onSearch={(query) => {
@@ -300,8 +323,8 @@ const DSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
setPagingController={setPagingController}
pagingController={pagingController}
totalCount={totalCount}
// isAutoPaging={false}
// hasCollapse={false}
// isAutoPaging={false}
// hasCollapse={false}
/>
</>
);


+ 4
- 2
src/components/RoughSchedule/RoughSchedileSearchView.tsx Näytä tiedosto

@@ -23,7 +23,7 @@ import {
testRoughSchedule,
} from "@/app/api/scheduling/actions";
import { arrayToDateString, decimalFormatter } from "@/app/utils/formatUtil";
import { isEqual, uniqBy } from "lodash";
import { isEqual, orderBy, sortBy, uniqBy } from "lodash";
import dayjs from "dayjs";
import { defaultPagingController } from "../SearchResults/SearchResults";
import { ScheduleType } from "@/app/api/scheduling";
@@ -178,7 +178,9 @@ const RSOverview: React.FC<Props> = ({ type, defaultInputs }) => {
break;
case "paging":
setFilteredSchedules((fs) =>
uniqBy([...fs, ...response.records], "id"),
orderBy(
uniqBy([...fs, ...response.records], "id")
, ["id"], ["desc"]),
);
break;
}


Ladataan…
Peruuta
Tallenna