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 regels
5.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 Loadable from 'components/Loadable';
  16. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  17. const PaymentDetails = Loadable(React.lazy(() => import('./PaymentDetails')));
  18. const DataGrid = Loadable(React.lazy(() => import('./DataGrid')));
  19. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  20. import {FormattedMessage} from "react-intl";
  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 [detailsOrder, setDetailsOrder] = React.useState(2);
  38. React.useEffect(() => {
  39. loadForm();
  40. // window.addEventListener('resize', handleResize)
  41. }, []);
  42. React.useEffect(() => {
  43. setOnReady(true);
  44. }, [record]);
  45. // const handleResize = () => {
  46. // setDetailsOrder(window.innerWidth > 1023 ? 2 : -1);
  47. // }
  48. const doPrint = () => {
  49. // window.print();
  50. HttpUtils.fileDownload({
  51. url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+params.id,
  52. });
  53. };
  54. const loadForm = () => {
  55. if (params.id > 0) {
  56. HttpUtils.get({
  57. url: UrlUtils.PAYMENT_LOAD + "/" + params.id,
  58. onSuccess: (responseData) => {
  59. if (!responseData.data?.id) {
  60. navigate("/paymentPage/search");
  61. }
  62. responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY");
  63. responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss");
  64. setItemList(responseData.paymentItemList)
  65. setRecord(responseData.data);
  66. }
  67. });
  68. }
  69. }
  70. return (
  71. !onReady ?
  72. <LoadingComponent />
  73. :
  74. (
  75. <div>
  76. <style>
  77. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  78. </style>
  79. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  80. <Grid className="printHidden" item xs={12} width="100%">
  81. <div style={BackgroundHead} width="100%">
  82. <Stack direction="row" height='70px'>
  83. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>
  84. <FormattedMessage id="payDetail"/>
  85. </Typography>
  86. </Stack>
  87. </div>
  88. </Grid>
  89. {/*row 1*/}
  90. <Grid item xs={12} md={12} spacing={2} sx={{ textAlign: "center" }}>
  91. <Grid container justifyContent="center" direction="column" spacing={2} sx={{ p: 2 }} alignitems="stretch" >
  92. <Grid item className="printOrder" xs={12} md={12} sx={{ pt: 2 }} style={{ height: '100%', order: 1 }}>
  93. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  94. <PaymentDetails
  95. formData={record}
  96. doPrint={doPrint}
  97. style={{
  98. display: "flex",
  99. height: "100%",
  100. flex: 1
  101. }}
  102. />
  103. </Box>
  104. </Grid>
  105. <Grid item xs={12} md={12} sx={{ pt: 1, pb: 2 }} style={{ height: '100%', order: 2 }}>
  106. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  107. <DataGrid
  108. recordList={itemList}
  109. />
  110. </Box>
  111. </Grid>
  112. </Grid>
  113. </Grid>
  114. {/*row 2*/}
  115. </Grid >
  116. </div>
  117. )
  118. );
  119. };
  120. export default Index;