Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 

211 рядки
5.6 KiB

  1. "use client";
  2. import * as React from "react";
  3. import Grid from "@mui/material/Grid";
  4. import { useState,useEffect, useMemo } from 'react'
  5. import Paper from "@mui/material/Paper";
  6. import { TFunction } from "i18next";
  7. import { useTranslation } from "react-i18next";
  8. import {Card,CardHeader} from '@mui/material';
  9. import CustomSearchForm from "../CustomSearchForm/CustomSearchForm";
  10. import CustomDatagrid from '../CustomDatagrid/CustomDatagrid';
  11. import ReactApexChart from 'react-apexcharts';
  12. import { ApexOptions } from 'apexcharts';
  13. import { GridColDef, GridRowSelectionModel} from '@mui/x-data-grid';
  14. import ReportProblemIcon from '@mui/icons-material/ReportProblem';
  15. import dynamic from 'next/dynamic';
  16. import '../../app/global.css';
  17. import { AnyARecord, AnyCnameRecord } from "dns";
  18. import SearchBox, { Criterion } from "../SearchBox";
  19. import ProgressByClientSearch from "@/components/ProgressByClientSearch";
  20. import { Suspense } from "react";
  21. import ProgressCashFlowSearch from "@/components/ProgressCashFlowSearch";
  22. const ProjectCashFlow: React.FC = () => {
  23. const [selectionModel, setSelectionModel] : any[] = React.useState([]);
  24. // const series: ApexAxisChartSeries | ApexNonAxisChartSeries = [{
  25. // name: 'Monthly Income',
  26. // type: 'line',
  27. // data: [80, 55, 40, 65, 70],
  28. // },
  29. // {
  30. // name: 'Monthly Incomess',
  31. // type: 'column',
  32. // data: [80, 55, 40, 65, 70],
  33. // }
  34. // ];
  35. const columns = [
  36. {
  37. id: 'projectCode',
  38. field: 'projectCode',
  39. headerName: "Project Code",
  40. flex: 1,
  41. },
  42. {
  43. id: 'projectName',
  44. field: 'projectName',
  45. headerName: "Project Name",
  46. flex: 1,
  47. },
  48. {
  49. id: 'team',
  50. field: 'team',
  51. headerName: "Team",
  52. flex: 1,
  53. },
  54. {
  55. id: 'teamLeader',
  56. field: 'teamLeader',
  57. headerName: "Team Leader",
  58. flex: 1,
  59. },
  60. {
  61. id: 'startDate',
  62. field: 'startDate',
  63. headerName: "Start Date",
  64. flex: 1,
  65. },
  66. {
  67. id: 'targetEndDate',
  68. field: 'targetEndDate',
  69. headerName: "Target End Date",
  70. flex: 1,
  71. },
  72. {
  73. id: 'client',
  74. field: 'client',
  75. headerName: "Client",
  76. flex: 1,
  77. },
  78. {
  79. id: 'subsidiary',
  80. field: 'subsidiary',
  81. headerName: "Subsidiary",
  82. flex: 1,
  83. },
  84. ];
  85. const options: ApexOptions = {
  86. chart: {
  87. height: 350,
  88. type: 'line',
  89. },
  90. plotOptions: {
  91. bar: {
  92. horizontal: false,
  93. distributed: false,
  94. },
  95. },
  96. dataLabels: {
  97. enabled: false
  98. },
  99. xaxis: {
  100. categories: [
  101. 'Q1',
  102. 'Q2',
  103. 'Q3',
  104. 'Q4',
  105. 'Q5',
  106. 'Q6',
  107. 'Q7',
  108. 'Q8',
  109. 'Q9',
  110. 'Q10',
  111. 'Q11',
  112. 'Q12',
  113. ],
  114. },
  115. yaxis: [{
  116. title: {
  117. text: 'Monthly Income and Expenditure (HKD)'
  118. },
  119. labels: {
  120. maxWidth: 300,
  121. style: {
  122. cssClass: 'apexcharts-yaxis-label',
  123. },
  124. },
  125. },
  126. {
  127. opposite: true,
  128. title: {
  129. text: 'Cumulative Income and Expenditure (HKD)'
  130. }}
  131. ],
  132. title: {
  133. text: 'Current Stage Completion Percentage',
  134. align: 'center'
  135. },
  136. grid: {
  137. borderColor: '#f1f1f1',
  138. },
  139. annotations: {
  140. },
  141. series:[
  142. {
  143. name:"Monthly Income",
  144. type:"column",
  145. color: "#ffde91",
  146. data:[0,110000,0,0,185000,0,0,189000,0,0,300000,0]
  147. },
  148. {
  149. name:"Monthly Expenditure",
  150. type:"column",
  151. color: "#82b59d",
  152. data:[0,160000,120000,120000,55000,55000,55000,55000,55000,70000,55000,55000]
  153. },
  154. {
  155. name:"Cumulative Income",
  156. type:"line",
  157. color: "#EE6D7A",
  158. data:[1,2,3,5,6,9,8,5,6,1,16,15]
  159. },
  160. {
  161. name:"Cumulative Expenditure",
  162. type:"line",
  163. color: "#EE6D7A",
  164. data:[1,2,3,5,6,9,8,5,6,1,16,15]
  165. }
  166. ]
  167. };
  168. const rows = [{id: 1,projectCode:"M1001",projectName:"Consultancy Project A", team:"XXX", teamLeader:"XXX", startDate:"01/07/2022", targetEndDate: "01/04/2024", client:"Client B", subsidiary:"N/A"},
  169. {id: 2,projectCode:"M1301",projectName:"Consultancy Project AAAA", team:"XXX", teamLeader:"XXX", startDate:"01/09/2022", targetEndDate: "20/02/2024", client:"Client C", subsidiary:"Subsidiary A"},
  170. {id: 3,projectCode:"M1354",projectName:"Consultancy Project BBB", team:"YYY", teamLeader:"YYY", startDate:"01/02/2023", targetEndDate: "31/01/2024", client:"Client D", subsidiary:"Subsidiary C"}
  171. ]
  172. const [selectedTeamData, setSelectedTeamData] : any[] = React.useState(rows);
  173. const handleSelectionChange = (newSelectionModel: GridRowSelectionModel) => {
  174. const selectedRowsData = selectedTeamData.filter((row:any) =>
  175. newSelectionModel.includes(row.id)
  176. );
  177. console.log(selectedRowsData)
  178. }
  179. return (
  180. <>
  181. <Suspense fallback={<ProgressCashFlowSearch.Loading />}>
  182. <ProgressCashFlowSearch/>
  183. </Suspense>
  184. <CustomDatagrid rows={selectedTeamData} columns={columns} columnWidth={200} dataGridHeight={300} checkboxSelection={true} onRowSelectionModelChange={handleSelectionChange} selectionModel={selectionModel}/>
  185. <Grid item sm>
  186. <div style={{display:"inline-block",width:"50%"}}>
  187. <Grid item xs={12} md={12} lg={12}>
  188. <Card>
  189. <CardHeader className="text-slate-500" title="Project Cash Flow by Month"/>
  190. <div style={{display:"inline-block",width:"99%"}}>
  191. <ReactApexChart
  192. options={options}
  193. series={options.series}
  194. height={350}
  195. />
  196. </div>
  197. </Card>
  198. </Grid>
  199. </div>
  200. </Grid>
  201. </>
  202. );
  203. };
  204. export default ProjectCashFlow;