FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

76 rivejä
1.8 KiB

  1. "use server";
  2. import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
  3. import { serverFetchJson } from "@/app/utils/fetchUtil";
  4. import { BASE_API_URL } from "@/config/api";
  5. import { cache } from "react";
  6. import { ScheduleType } from ".";
  7. export interface SearchProdSchedule {
  8. scheduleAt?: string;
  9. schedulePeriod?: string;
  10. schedulePeriodTo?: string;
  11. totalEstProdCount?: number;
  12. types?: ScheduleType[];
  13. pageSize?: number;
  14. pageNum?: number;
  15. }
  16. export interface ProdScheduleResult {
  17. id: number;
  18. scheduleAt: number[];
  19. schedulePeriod: number[];
  20. schedulePeriodTo: number[];
  21. totalEstProdCount: number;
  22. totalFGType: number;
  23. type: string;
  24. }
  25. export interface ProdScheduleResultByPage {
  26. total: number;
  27. records: ProdScheduleResult[];
  28. }
  29. export const fetchProdSchedules = cache(
  30. async (data: SearchProdSchedule | null) => {
  31. const params = convertObjToURLSearchParams<SearchProdSchedule>(data);
  32. // console.log(params)
  33. return serverFetchJson<ProdScheduleResultByPage>(
  34. `${BASE_API_URL}/productionSchedule/getRecordByPage?${params}`,
  35. {
  36. method: "GET",
  37. headers: { "Content-Type": "application/json" },
  38. next: {
  39. tags: ["prodSchedules"],
  40. },
  41. },
  42. );
  43. },
  44. );
  45. export const testRoughSchedule = cache(async () => {
  46. return serverFetchJson(
  47. `${BASE_API_URL}/productionSchedule/testRoughSchedule`,
  48. {
  49. method: "GET",
  50. headers: { "Content-Type": "application/json" },
  51. next: {
  52. tags: ["prodSchedules"],
  53. },
  54. },
  55. );
  56. });
  57. export const testDetailSchedule = cache(async () => {
  58. return serverFetchJson(
  59. `${BASE_API_URL}/productionSchedule/testDetailSchedule`,
  60. {
  61. method: "GET",
  62. headers: { "Content-Type": "application/json" },
  63. next: {
  64. tags: ["prodSchedules"],
  65. },
  66. },
  67. );
  68. });