You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.6 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack
  6. } from '@mui/material';
  7. // import MainCard from "components/MainCard";
  8. import * as UrlUtils from "utils/ApiPathConst";
  9. import * as React from "react";
  10. import * as HttpUtils from "utils/HttpUtils";
  11. // import * as DateUtils from "utils/DateUtils";
  12. import Loadable from 'components/Loadable';
  13. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  14. const SearchForm = Loadable(React.lazy(() => import('./SearchForm')));
  15. // const EventTable = Loadable(React.lazy(() => import('./DataGrid')));
  16. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  17. const BackgroundHead = {
  18. backgroundImage: `url(${titleBackgroundImg})`,
  19. width: '100%',
  20. height: '100%',
  21. backgroundSize:'contain',
  22. backgroundRepeat: 'no-repeat',
  23. backgroundColor: '#0C489E',
  24. backgroundPosition: 'right'
  25. }
  26. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  27. const Index = () => {
  28. // const [record,setRecord] = React.useState([]);
  29. const [searchCriteria, setSearchCriteria] = React.useState({
  30. // dateTo: DateUtils.dateStr(new Date()),
  31. // dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)),
  32. });
  33. const [onReady] = React.useState(true);
  34. const [onDownload, setOnDownload] = React.useState(false);
  35. // React.useEffect(() => {
  36. // setOnReady(true);
  37. // }, [record]);
  38. React.useEffect(() => {
  39. if (Object.keys(searchCriteria).length > 0){
  40. console.log(searchCriteria)
  41. loadGrid();
  42. }
  43. }, [searchCriteria]);
  44. function loadGrid(){
  45. HttpUtils.get({
  46. url: UrlUtils.VIEW_RECON_REPORT,
  47. params: searchCriteria,
  48. onSuccess: function(responseData){
  49. console.log(responseData)
  50. var myWindow = window.open();
  51. myWindow.document.write(responseData);
  52. }
  53. });
  54. }
  55. function downloadXML(input) {
  56. // console.log(input)
  57. setOnDownload(true)
  58. HttpUtils.fileDownload({
  59. url: UrlUtils.GEN_RECON_REPORT,
  60. params:input,
  61. onResponse:(response)=>{
  62. console.log(response)
  63. setOnDownload(false)
  64. },
  65. onError:()=>{
  66. setOnDownload(false)
  67. }
  68. });
  69. // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true")
  70. }
  71. function applySearch(input) {
  72. setSearchCriteria(input);
  73. }
  74. function generateReport(input) {
  75. downloadXML(input);
  76. }
  77. return (
  78. !onReady ?
  79. <LoadingComponent/>
  80. :
  81. <Grid container sx={{minHeight: '87vh', backgroundColor: 'backgroundColor.default'}} direction="column">
  82. <Grid item xs={12}>
  83. <div style={BackgroundHead}>
  84. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  85. <Typography ml={15} color='#FFF' variant="h4">
  86. Recon Report
  87. </Typography>
  88. </Stack>
  89. </div>
  90. </Grid>
  91. {/*row 1*/}
  92. <Grid item xs={12} md={12} lg={12} sx={{mb:-1}}>
  93. <SearchForm
  94. applySearch={applySearch}
  95. generateReport={generateReport}
  96. searchCriteria={searchCriteria}
  97. onDownload={onDownload}
  98. />
  99. </Grid>
  100. {/*row 2*/}
  101. </Grid>
  102. );
  103. };
  104. export default Index;