浏览代码

update P&L report

tags/Baseline_30082024_FRONTEND_UAT
cyril.tsui 1年前
父节点
当前提交
d85a8e7841
共有 2 个文件被更改,包括 11 次插入8 次删除
  1. +1
    -1
      src/app/api/reports/index.ts
  2. +10
    -7
      src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx

+ 1
- 1
src/app/api/reports/index.ts 查看文件

@@ -6,7 +6,7 @@ export interface FinancialStatusReportFilter {


// - Project P&L Report // - Project P&L Report
export interface ProjectPandLReportFilter { export interface ProjectPandLReportFilter {
project: string[];
project: AutocompleteOptions[];
startMonth: string; startMonth: string;
startMonthTo: string; startMonthTo: string;
} }


+ 10
- 7
src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx 查看文件

@@ -20,11 +20,14 @@ type SearchParamNames = keyof SearchQuery;


const GenerateProjectPandLReport: React.FC<Props> = ({ projects }) => { const GenerateProjectPandLReport: React.FC<Props> = ({ projects }) => {
const { t } = useTranslation("report"); const { t } = useTranslation("report");
const projectCombo = projects.map(project => `${project.code} - ${project.name}`)
const projectCombo = projects.map(project => ({
label: `${project.code} - ${project.name}`,
value: project.id
}))


const searchCriteria: Criterion<SearchParamNames>[] = useMemo( const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [ () => [
{ label: t("Project *"), paramName: "project", type: "select", options: projectCombo, needAll: false},
{ label: t("Project *"), paramName: "project", type: "autocomplete", options: projectCombo, needAll: false},
{ label: t("Start Month *"), label2: t("End Month *"), paramName: "startMonth", type: "dateRange", needMonth: true }, { label: t("Start Month *"), label2: t("End Month *"), paramName: "startMonth", type: "dateRange", needMonth: true },


], ],
@@ -37,11 +40,11 @@ const GenerateProjectPandLReport: React.FC<Props> = ({ projects }) => {
criteria={searchCriteria} criteria={searchCriteria}
onSearch={async (query) => { onSearch={async (query) => {


if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") {
const projectIndex = projectCombo.findIndex(project => project === query.project)
console.log(projects[projectIndex].id, query.startMonth, query.startMonthTo)
if(projects[projectIndex].id != null && query.startMonth != "" && query.startMonthTo != undefined){
const response = await fetchProjectPandLReport({ projectId: projects[projectIndex].id, startMonth: query.startMonth, endMonth: query.startMonthTo })
if (Boolean(query.project) && query.project !== "All") {
// const projectIndex = projectCombo.findIndex(project => project === query.project)
// console.log(projects[projectIndex].id, query.startMonth, query.startMonthTo)
if(query.project != null && query.startMonth != "" && query.startMonthTo != undefined){
const response = await fetchProjectPandLReport({ projectId: parseFloat(query.project), startMonth: query.startMonth, endMonth: query.startMonthTo })
if (response) { if (response) {
downloadFile(new Uint8Array(response.blobValue), response.filename!!) downloadFile(new Uint8Array(response.blobValue), response.filename!!)
} }


正在加载...
取消
保存