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.
 
 

149 line
4.8 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 axios from "axios";
  13. import Loadable from 'components/Loadable';
  14. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  15. const SearchForm = Loadable(React.lazy(() => import('./SearchForm')));
  16. // const EventTable = Loadable(React.lazy(() => import('./DataGrid')));
  17. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  18. const BackgroundHead = {
  19. backgroundImage: `url(${titleBackgroundImg})`,
  20. width: '100%',
  21. height: '100%',
  22. backgroundSize:'contain',
  23. backgroundRepeat: 'no-repeat',
  24. backgroundColor: '#0C489E',
  25. backgroundPosition: 'right'
  26. }
  27. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  28. const Index = () => {
  29. // const [record,setRecord] = React.useState([]);
  30. const [searchCriteria, setSearchCriteria] = React.useState({
  31. // dateTo: DateUtils.dateValue(new Date()),
  32. // dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)),
  33. });
  34. const [onReady] = React.useState(true);
  35. // const [onDownload, setOnDownload] = React.useState(false);
  36. const [onLoad, setonLoad] = React.useState(false);
  37. // React.useEffect(() => {
  38. // setOnReady(true);
  39. // }, [record]);
  40. React.useEffect(() => {
  41. if (Object.keys(searchCriteria).length > 0){
  42. // console.log(searchCriteria)
  43. loadGrid();
  44. }
  45. }, [searchCriteria]);
  46. function loadGrid(){
  47. setonLoad(true)
  48. HttpUtils.get({
  49. url: UrlUtils.VIEW_RECON_REPORT,
  50. params: searchCriteria,
  51. onSuccess: function(responseData){
  52. // console.log(responseData)
  53. if(responseData.status != 200){
  54. alert(responseData.content)
  55. setonLoad(false)
  56. } else {
  57. var myWindow = window.open();
  58. myWindow.document.write(responseData.content);
  59. setonLoad(false)
  60. }
  61. },
  62. onError:()=>{
  63. setonLoad(false)
  64. }
  65. });
  66. }
  67. function downloadXML(input) {
  68. // console.log(input)
  69. const hasCollRange = input.CollDateFrom!="" && input.CollDateTo!="";
  70. const hasTxnRange = input.TxnDateFrom!="" && input.TxnDateTo!="";
  71. const hasSysTxnRange = input.SysTxnDateFrom!="" && input.SysTxnDateTo!="";
  72. let countRanges= 0;
  73. if(hasCollRange) countRanges+=1;
  74. if(hasTxnRange) countRanges+=1;
  75. if(hasSysTxnRange) countRanges+=1;
  76. if(countRanges>1){
  77. alert("Only one date range is allowed Trans/Coll dates")
  78. // return "<div>Only one date range is allowed Trans/Coll dates</div>";
  79. }else if(countRanges == 0){
  80. alert("Must have a date range")
  81. // return "<div>must have a date range</div>";
  82. }else{
  83. setonLoad(true)
  84. HttpUtils.fileDownload({
  85. url: UrlUtils.GEN_RECON_REPORT,
  86. params:input,
  87. onResponse:(response)=>{
  88. console.log(response)
  89. setonLoad(false)
  90. },
  91. onError:()=>{
  92. setonLoad(false)
  93. }
  94. });
  95. }
  96. // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true")
  97. }
  98. function applySearch(input) {
  99. setSearchCriteria(input);
  100. }
  101. function generateReport(input) {
  102. downloadXML(input);
  103. }
  104. return (
  105. !onReady ?
  106. <LoadingComponent/>
  107. :
  108. <Grid container sx={{minHeight: '87vh', backgroundColor: 'backgroundColor.default'}} direction="column">
  109. <Grid item xs={12}>
  110. <div style={BackgroundHead}>
  111. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  112. <Typography ml={15} color='#FFF' variant="h4">
  113. Recon Report
  114. </Typography>
  115. </Stack>
  116. </div>
  117. </Grid>
  118. {/*row 1*/}
  119. <Grid item xs={12} md={12} lg={12} sx={{mb:-1}}>
  120. <SearchForm
  121. applySearch={applySearch}
  122. generateReport={generateReport}
  123. searchCriteria={searchCriteria}
  124. onLoad={onLoad}
  125. />
  126. </Grid>
  127. {/*row 2*/}
  128. </Grid>
  129. );
  130. };
  131. export default Index;