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.
 
 

138 lines
4.7 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 React from "react";
  9. import {GET_ORG_COMBO, GET_ISSUE_COMBO} from "utils/ApiPathConst";
  10. import * as HttpUtils from "utils/HttpUtils";
  11. import * as DateUtils from "utils/DateUtils";
  12. import { getSearchCriteria } from "auth/utils";
  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. import {FormattedMessage} from "react-intl";
  19. const BackgroundHead = {
  20. backgroundImage: `url(${titleBackgroundImg})`,
  21. width: '100%',
  22. height: '100%',
  23. backgroundSize: 'contain',
  24. backgroundRepeat: 'no-repeat',
  25. backgroundColor: '#0C489E',
  26. backgroundPosition: 'right'
  27. }
  28. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  29. const SearchPage_DemandNote_Pub = () => {
  30. const [orgCombo, setOrgCombo] = React.useState([]);
  31. const [issueCombo, setIssueCombo] = React.useState([]);
  32. const [searchCriteria, setSearchCriteria] = React.useState({});
  33. const [onReady, setOnReady] = React.useState(false);
  34. const [onGridReady, setGridOnReady] = React.useState(false);
  35. React.useEffect(() => {
  36. getOrgCombo();
  37. getIssueCombo();
  38. if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){
  39. setSearchCriteria(getSearchCriteria(window.location.pathname))
  40. }else{
  41. localStorage.setItem('searchCriteria',"")
  42. setSearchCriteria({
  43. dateTo: DateUtils.dateValue(new Date()),
  44. dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)),
  45. })
  46. }
  47. }, []);
  48. React.useEffect(() => {
  49. setOnReady(true);
  50. }, [searchCriteria]);
  51. function getOrgCombo() {
  52. HttpUtils.get({
  53. url: GET_ORG_COMBO,
  54. onSuccess: function (responseData) {
  55. let combo = responseData;
  56. setOrgCombo(combo);
  57. }
  58. });
  59. }
  60. function getIssueCombo() {
  61. HttpUtils.get({
  62. url: GET_ISSUE_COMBO,
  63. onSuccess: function (responseData) {
  64. let combo = responseData;
  65. setIssueCombo(combo);
  66. }
  67. });
  68. }
  69. function applySearch(input) {
  70. setGridOnReady(true)
  71. setSearchCriteria(input);
  72. localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input}))
  73. }
  74. function applyGridOnReady(input) {
  75. setGridOnReady(input);
  76. }
  77. return (
  78. !onReady ?
  79. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  80. <Grid item>
  81. <LoadingComponent />
  82. </Grid>
  83. </Grid>
  84. :
  85. <Grid container sx={{ minHeight: '85vh', backgroundColor: 'backgroundColor.default' }} direction="column">
  86. <Grid item xs={12}>
  87. <div style={BackgroundHead}>
  88. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  89. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block' }}}>
  90. <FormattedMessage id="paymentInfoRecord" />
  91. </Typography>
  92. </Stack>
  93. </div>
  94. </Grid>
  95. {/*row 1*/}
  96. <Grid item xs={12} md={12} lg={12} sx={{mb:-1}}>
  97. <SearchForm
  98. applySearch={applySearch}
  99. orgComboData={orgCombo}
  100. issueComboData={issueCombo}
  101. searchCriteria={searchCriteria}
  102. onGridReady={onGridReady}
  103. />
  104. </Grid>
  105. {/*row 2*/}
  106. <Grid item xs={12} md={12} lg={12}>
  107. <MainCard elevation={0}
  108. border={false}
  109. content={false}
  110. sx={{ backgroundColor: '#fff' }}
  111. >
  112. <EventTable
  113. searchCriteria={searchCriteria}
  114. applyGridOnReady={applyGridOnReady}
  115. applySearch={applySearch}
  116. />
  117. </MainCard>
  118. </Grid>
  119. </Grid>
  120. );
  121. }
  122. export default SearchPage_DemandNote_Pub;