FPSMS-frontend
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

64 řádky
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(async (data: SearchProdSchedule | null) => {
  30. const params = convertObjToURLSearchParams<SearchProdSchedule>(data)
  31. // console.log(params)
  32. return serverFetchJson<ProdScheduleResultByPage>(`${BASE_API_URL}/productionSchedule/getRecordByPage?${params}`, {
  33. method: "GET",
  34. headers: { "Content-Type": "application/json" },
  35. next: {
  36. tags: ["prodSchedules"]
  37. }
  38. })
  39. })
  40. export const testRoughSchedule = cache(async () => {
  41. return serverFetchJson(`${BASE_API_URL}/productionSchedule/testRoughSchedule`, {
  42. method: "GET",
  43. headers: { "Content-Type": "application/json" },
  44. next: {
  45. tags: ["prodSchedules"]
  46. }
  47. })
  48. })
  49. export const testDetailSchedule = cache(async () => {
  50. return serverFetchJson(`${BASE_API_URL}/productionSchedule/testDetailSchedule`, {
  51. method: "GET",
  52. headers: { "Content-Type": "application/json" },
  53. next: {
  54. tags: ["prodSchedules"]
  55. }
  56. })
  57. })