Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

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