ソースを参照

report update

tags/Baseline_30082024_FRONTEND_UAT
leoho2fi 1年前
コミット
b8c0f86609
3個のファイルの変更35行の追加12行の削除
  1. +1
    -0
      src/app/api/reports/index.ts
  2. +31
    -11
      src/components/Report/LateStartReportGen/LateStartReportGen.tsx
  3. +3
    -1
      src/components/Report/LateStartReportGen/LateStartReportGenWrapper.tsx

+ 1
- 0
src/app/api/reports/index.ts ファイルの表示

@@ -86,6 +86,7 @@ export interface LateStartReportRequest {
clientId: number;
remainedDate: string;
remainedDateTo: string;
type: string;
}

export interface ProjectCompletionReportFilter {


+ 31
- 11
src/components/Report/LateStartReportGen/LateStartReportGen.tsx ファイルの表示

@@ -13,15 +13,17 @@ import { Customer } from "@/app/api/customer";
import { downloadFile } from "@/app/utils/commonUtil";
import { fetchLateStartReport } from "@/app/api/reports/actions";
import { LateStartReportRequest } from "@/app/api/reports";
import { Subsidiary } from "@/app/api/subsidiary";
//import { GET_QC_CATEGORY_COMBO } from 'utils/ApiPathConst';
interface Props {
projects: LateStart[];
customers: Customer[];
clients: Customer[];
subsidiaries: Subsidiary[];
}
type SearchQuery = Partial<Omit<LateStartReportRequest, "id">>;
type SearchParamNames = keyof SearchQuery;

const ProgressByClientSearch: React.FC<Props> = ({ projects, customers }) => {
const ProgressByClientSearch: React.FC<Props> = ({ projects, clients,subsidiaries }) => {
//console.log(customers)
const { t } = useTranslation("projects");
const [teamCombo, setteamCombo] = useState<comboProp[]>([])
@@ -37,6 +39,17 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects, customers }) => {
console.log(err)
}
}
const clientCombo = clients.map(client => ({
value: `client: ${client.id}` ,
label: `${client.code} - ${client.name}`,
group: t("Client")
}))

const subsidiaryCombo = subsidiaries.map(subsidiary => ({
value: `subsidiary: ${subsidiary.id}`,
label: `${subsidiary.code} - ${subsidiary.name}`,
group: t("Subsidiary")
}))

useEffect(() => {
getTeamCombo()
@@ -45,33 +58,40 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects, customers }) => {
const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [
{ label: "Team", paramName: "teamId", type: "select", options: teamCombo.map(team => team.label) },
{ label: "Client", paramName: "clientId", type: "select", options: customers.map(customer => `${customer.code}-${customer.name}`) },
//{ label: "Client", paramName: "clientId", type: "autocomplete", options: clients.map(customer => `${customer.code}-${customer.name}`) },
{ label: t("Client"), paramName: "clientId", type: "autocomplete", options: [...subsidiaryCombo, ...clientCombo] },
{
label: "Remained Date From",
label2: "Remained Date To",
label: "Next Stage Due Date From",
label2: "Next Stage Due Date To",
paramName: "remainedDate",
type: "dateRange",
},
],
[t, teamCombo, customers],
[t, teamCombo, clients],
);

return (
<>
{!isLoading && <SearchBox
<SearchBox
formType={"download"}
criteria={searchCriteria}
onSearch={async (query) => {
console.log(query);
//console.log(query);

try {
// const teamId = teamCombo.find(team => team.label === query.teamId)?.id!!
// const clientId = customers.find(customer => `${customer.code}-${customer.name}` === query.clientId)?.id!!
const teamId = teamCombo.find(team => team.label === query.teamId)?.id || 0;
const clientId = customers.find(customer => `${customer.code}-${customer.name}` === query.clientId)?.id || 0;
const clientId = clients.find(customer => `${customer.code}-${customer.name}` === query.clientId)?.id || 0;
const remainedDate = query.remainedDate || "1900-01-01";
const remainedDateTo = query.remainedDateTo || "2100-12-31";
const clientIndex = clientCombo.findIndex(client => client.value === query.clientId)
const subsidiaryIndex = subsidiaryCombo.findIndex(subsidiary => subsidiary.value === query.clientId)

const fileResponse = await fetchLateStartReport({teamId: teamId, clientId: clientId, remainedDate: remainedDate, remainedDateTo: remainedDateTo});
const fileResponse = await fetchLateStartReport({teamId: teamId,
clientId: clientIndex >= 0 ? clients[clientIndex].id : subsidiaryIndex >= 0 ? subsidiaries[subsidiaryIndex].id : 0,
remainedDate: remainedDate, remainedDateTo: remainedDateTo,
type: clientIndex >= 0 ? "client" : subsidiaryIndex >= 0 ? "subsidiary" : "All",});
if (fileResponse) {
downloadFile(new Uint8Array(fileResponse.blobValue), fileResponse.filename!!)
}
@@ -80,7 +100,7 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects, customers }) => {
}
//console.log(teamCombo.find(team => team.label === query.team)?.id);
}}
/>}
/>
{/* <DownloadReportButton /> */}
</>
);


+ 3
- 1
src/components/Report/LateStartReportGen/LateStartReportGenWrapper.tsx ファイルの表示

@@ -3,6 +3,7 @@ import React from "react";
import LateStartReportGen from "./LateStartReportGen";
import LateStartReportGenLoading from "./LateStartReportGenLoading";
import { fetchAllCustomers } from "@/app/api/customer";
import { fetchAllSubsidiaries } from "@/app/api/subsidiary";

interface SubComponents {
Loading: typeof LateStartReportGenLoading;
@@ -11,8 +12,9 @@ interface SubComponents {
const LateStartReportGenWrapper: React.FC & SubComponents = async () => {
const clentprojects = await fetchProjectsLateStart();
const customers = await fetchAllCustomers();
const subsidiaries = await fetchAllSubsidiaries();

return <LateStartReportGen projects={clentprojects} customers={customers}/>;
return <LateStartReportGen projects={clentprojects} clients={customers} subsidiaries={subsidiaries}/>;
};

LateStartReportGenWrapper.Loading = LateStartReportGenLoading;


読み込み中…
キャンセル
保存