Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

156 wiersze
6.3 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Box,
  7. Button
  8. } from '@mui/material';
  9. import * as UrlUtils from "utils/ApiPathConst";
  10. import * as React from "react";
  11. import * as HttpUtils from "utils/HttpUtils";
  12. import * as DateUtils from "utils/DateUtils";
  13. import { useParams } from "react-router-dom";
  14. import { useNavigate } from "react-router-dom";
  15. import ForwardIcon from '@mui/icons-material/Forward';
  16. import Loadable from 'components/Loadable';
  17. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  18. const PaymentDetails = Loadable(React.lazy(() => import('./PaymentDetails')));
  19. const DataGrid = Loadable(React.lazy(() => import('./DataGrid')));
  20. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  21. const BackgroundHead = {
  22. backgroundImage: `url(${titleBackgroundImg})`,
  23. width: '100%',
  24. height: '100%',
  25. backgroundSize: 'contain',
  26. backgroundRepeat: 'no-repeat',
  27. backgroundColor: '#0C489E',
  28. backgroundPosition: 'right'
  29. }
  30. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  31. const Index = () => {
  32. const params = useParams();
  33. const navigate = useNavigate()
  34. const [record, setRecord] = React.useState();
  35. const [itemList, setItemList] = React.useState([]);
  36. const [onReady, setOnReady] = React.useState(false);
  37. const [onDownload, setOnDownload] = React.useState(false);
  38. // const [detailsOrder, setDetailsOrder] = React.useState(2);
  39. React.useEffect(() => {
  40. loadForm();
  41. // window.addEventListener('resize', handleResize);
  42. }, []);
  43. React.useEffect(() => {
  44. setOnReady(true);
  45. }, [record]);
  46. // const handleResize = () => {
  47. // setDetailsOrder(window.innerWidth > 1023 ? 2 : -1);
  48. // }
  49. const doPrint = () => {
  50. // window.print();
  51. setOnDownload(true)
  52. HttpUtils.fileDownload({
  53. url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+params.id+"/"+"en",
  54. onResponse:()=>{
  55. setOnDownload(false)
  56. },
  57. onError:()=>{
  58. setOnDownload(false)
  59. }
  60. });
  61. };
  62. const loadForm = () => {
  63. if (params.id > 0) {
  64. HttpUtils.get({
  65. url: UrlUtils.PAYMENT_LOAD + "/" + params.id,
  66. onSuccess: (responseData) => {
  67. if (!responseData.data?.id) {
  68. navigate("/paymentPage/search");
  69. }
  70. responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY");
  71. responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss");
  72. setItemList(responseData.paymentItemList)
  73. setRecord(responseData.data);
  74. }
  75. });
  76. }
  77. }
  78. return (
  79. !onReady ?
  80. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  81. <Grid item>
  82. <LoadingComponent />
  83. </Grid>
  84. </Grid>
  85. :
  86. (
  87. <div>
  88. <style>
  89. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  90. </style>
  91. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  92. <Grid className="printHidden" item xs={12} width="100%">
  93. <div style={BackgroundHead} width="100%">
  94. <Stack direction="row" height='70px'>
  95. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>Payment Details</Typography>
  96. </Stack>
  97. </div>
  98. </Grid>
  99. <Grid item xs={12} width={{xs:"90%", sm:"90%", md:"90%", lg:"90%"}}>
  100. <Button
  101. aria-label={"back"}
  102. title={"back"}
  103. sx={{ ml: 0, mt: 2.5 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate(-1) }}
  104. >
  105. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  106. </Button>
  107. </Grid>
  108. {/*row 1*/}
  109. <Grid item xs={12} md={12} sx={{textAlign: "center" }}>
  110. <Grid container justifyContent="center" direction="column" spacing={2} sx={{ p: 2 }} alignitems="stretch" >
  111. <Grid className="printOrder" item xs={12} md={5} sx={{ pt: 2 }} style={{ height: '100%', order: 1 }}>
  112. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  113. <PaymentDetails
  114. formData={record}
  115. doPrint={doPrint}
  116. onDownload={onDownload}
  117. style={{
  118. display: "flex",
  119. height: "100%",
  120. flex: 1
  121. }}
  122. />
  123. </Box>
  124. </Grid>
  125. <Grid item xs={12} md={5} sx={{ pt: 1, pb: 2 }} style={{ height: '100%', order: 2 }}>
  126. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  127. <DataGrid
  128. recordList={itemList}
  129. />
  130. </Box>
  131. </Grid>
  132. </Grid>
  133. </Grid>
  134. {/*row 2*/}
  135. </Grid >
  136. </div>
  137. )
  138. );
  139. };
  140. export default Index;