浏览代码

Filter by Project to team

tags/Baseline_30082024_FRONTEND_UAT
MSI\2Fi 1年前
父节点
当前提交
888a0b095b
共有 3 个文件被更改,包括 15 次插入15 次删除
  1. +4
    -4
      src/app/api/reporte1/index.ts
  2. +8
    -8
      src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx
  3. +3
    -3
      src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx

+ 4
- 4
src/app/api/reporte1/index.ts 查看文件

@@ -18,7 +18,7 @@ export interface FinancialStatus {
status: string; status: string;
} }


export interface ProjectCombo {
export interface TeamCombo {
id: number; id: number;
name: string; name: string;
code: string; code: string;
@@ -32,9 +32,9 @@ export const fetchProjectsFinancialStatus = cache(async () => {
return mockProjects; return mockProjects;
}); });


export const fetchProjectCombo = cache(async () => {
return serverFetchJson<ProjectCombo[]>(`${BASE_API_URL}/projects`, {
next: { tags: ["projects"] },
export const fetchTeamCombo = cache(async () => {
return serverFetchJson<TeamCombo[]>(`${BASE_API_URL}/team/combo2`, {
next: { tags: ["teamCombo"] },
}); });
}); });




+ 8
- 8
src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx 查看文件

@@ -3,7 +3,7 @@
import React, { useMemo, useState } from "react"; import React, { useMemo, useState } from "react";
// import SearchBox, { Criterion } from "../ReportSearchBoxe1"; // import SearchBox, { Criterion } from "../ReportSearchBoxe1";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { FinancialStatus, ProjectCombo } from "@/app/api/reporte1";
import { FinancialStatus, TeamCombo } from "@/app/api/reporte1";
import SearchBox, { Criterion } from "@/components/SearchBox"; import SearchBox, { Criterion } from "@/components/SearchBox";
import { FinancialStatusReportFilter } from "@/app/api/reports"; import { FinancialStatusReportFilter } from "@/app/api/reports";
import { fetchAllClientSubsidiaryProjects } from "@/app/api/clientprojects/actions"; import { fetchAllClientSubsidiaryProjects } from "@/app/api/clientprojects/actions";
@@ -12,19 +12,19 @@ import { downloadFile } from "@/app/utils/commonUtil";
//import { DownloadReportButton } from './DownloadReportButton'; //import { DownloadReportButton } from './DownloadReportButton';
interface Props { interface Props {
projects: FinancialStatus[]; projects: FinancialStatus[];
projectCombo : ProjectCombo[];
teamCombo : TeamCombo[];
} }
type SearchQuery = Partial<Omit<ProjectCombo, "id">>;
type SearchQuery = Partial<Omit<TeamCombo, "id">>;
type SearchParamNames = keyof SearchQuery; type SearchParamNames = keyof SearchQuery;


const GenFinancialStatusReport: React.FC<Props> = ({ projects, projectCombo }) => {
const GenFinancialStatusReport: React.FC<Props> = ({ projects, teamCombo }) => {
const { t } = useTranslation("projects"); const { t } = useTranslation("projects");


const combo = projectCombo.map(project => {return `${project.code} - ${project.name}`})
const combo = teamCombo.map(combo => {return `${combo.code} - ${combo.name}`})


const searchCriteria: Criterion<SearchParamNames>[] = useMemo( const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [ () => [
{ label: t("Project No"), paramName: "code", type: "select", options: combo, },
{ label: t("Team"), paramName: "code", type: "select", options: combo, },
// { // {
// label: "Status", // label: "Status",
// label2: "Remained Date To", // label2: "Remained Date To",
@@ -41,8 +41,8 @@ const GenFinancialStatusReport: React.FC<Props> = ({ projects, projectCombo }) =
criteria={searchCriteria} criteria={searchCriteria}
onSearch={async (query) => { onSearch={async (query) => {
if (query.code.length > 0 && query.code.toLocaleLowerCase() !== "all") { if (query.code.length > 0 && query.code.toLocaleLowerCase() !== "all") {
const projectIndex = projectCombo.findIndex((project) => `${project.code} - ${project.name}` === query.code)
console.log(projectCombo[projectIndex].id)
const projectIndex = teamCombo.findIndex((project) => `${project.code} - ${project.name}` === query.code)
console.log(teamCombo[projectIndex].id)
const response = await fetchProjectsFinancialStatusReport({ projectId: projects[projectIndex].id }) const response = await fetchProjectsFinancialStatusReport({ projectId: projects[projectIndex].id })
if (response) { if (response) {
downloadFile(new Uint8Array(response.blobValue), response.filename!!) downloadFile(new Uint8Array(response.blobValue), response.filename!!)


+ 3
- 3
src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx 查看文件

@@ -1,5 +1,5 @@
//src\components\LateStartReportGen\LateStartReportGenWrapper.tsx //src\components\LateStartReportGen\LateStartReportGenWrapper.tsx
import { fetchProjectCombo, fetchProjectsFinancialStatus } from "@/app/api/reporte1";
import { fetchProjectsFinancialStatus, fetchTeamCombo } from "@/app/api/reporte1";
import React from "react"; import React from "react";
import FinancialStatusReportGen from "./FinancialStatusReportGen"; import FinancialStatusReportGen from "./FinancialStatusReportGen";
import FinancialStatusReportGenLoading from "./FinancialStatusReportGenLoading"; import FinancialStatusReportGenLoading from "./FinancialStatusReportGenLoading";
@@ -11,9 +11,9 @@ interface SubComponents {
const FinancialStatusReportGenWrapper: React.FC & SubComponents = async () => { const FinancialStatusReportGenWrapper: React.FC & SubComponents = async () => {
const clentprojects = await fetchProjectsFinancialStatus(); const clentprojects = await fetchProjectsFinancialStatus();


const projectCombo = await fetchProjectCombo()
const teamCombo = await fetchTeamCombo()


return <FinancialStatusReportGen projects={clentprojects} projectCombo={projectCombo}/>;
return <FinancialStatusReportGen projects={clentprojects} teamCombo={teamCombo}/>;
}; };


FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading; FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading;


正在加载...
取消
保存