選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

191 行
8.2 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 [responeData, setResponeData] = React.useState({});
  35. const [transactionData, setTransactionData] = React.useState({});
  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. React.useEffect(() => {
  42. loadForm();
  43. // window.addEventListener('resize', handleResize);
  44. }, []);
  45. React.useEffect(() => {
  46. if (Object.keys(responeData).length > 0) {
  47. setTransactionData(responeData);
  48. }
  49. }, [responeData]);
  50. React.useEffect(() => {
  51. if (Object.keys(transactionData).length > 0) {
  52. setOnReady(true);
  53. }
  54. }, [transactionData]);
  55. // const handleResize = () => {
  56. // setDetailsOrder(window.innerWidth > 1023 ? 2 : -1);
  57. // }
  58. const doPrint = () => {
  59. // window.print();
  60. setOnDownload(true)
  61. HttpUtils.fileDownload({
  62. url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+params.id+"/"+"en",
  63. onResponse:()=>{
  64. setOnDownload(false)
  65. },
  66. onError:()=>{
  67. setOnDownload(false)
  68. }
  69. });
  70. };
  71. const loadForm = () => {
  72. if (params.id > 0) {
  73. HttpUtils.get({
  74. url: UrlUtils.PAYMENT_LOAD + "/" + params.id,
  75. onSuccess: (responseData) => {
  76. if (!responseData.data?.id) {
  77. navigate("/paymentPage/search");
  78. }
  79. if (responseData.data.status == null || responseData.data.status == "INPR") {
  80. HttpUtils.post({
  81. url: UrlUtils.PAYMENT_RETRY_STATUS_API,
  82. params: {
  83. "paymentId": params.id
  84. },
  85. onSuccess: function (responseData2) {
  86. responseData2.data["transDateStr"] = responseData2.data.transDateTime;
  87. responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss");
  88. setResponeData(responseData2.transactionData);
  89. setItemList(responseData2.paymentItemList);
  90. setRecord(responseData2.data);
  91. },
  92. onError: function () {
  93. responseData.data["transDateStr"] = responseData.data.transDateTime;
  94. responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss");
  95. setResponeData(responseData);
  96. setItemList(responseData.paymentItemList);
  97. setRecord(responseData.data);
  98. }
  99. });
  100. } else {
  101. responseData.data["transDateStr"] = responseData.data.transDateTime;
  102. responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss");
  103. setResponeData(responseData);
  104. setItemList(responseData.paymentItemList);
  105. setRecord(responseData.data);
  106. }
  107. }
  108. });
  109. }
  110. }
  111. return (
  112. !onReady ?
  113. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  114. <Grid item>
  115. <LoadingComponent />
  116. </Grid>
  117. </Grid>
  118. :
  119. (
  120. <div>
  121. <style>
  122. {`@media print {.printHidden{display: none;} .printOrder{order:-1 !important;}`}
  123. </style>
  124. <Grid container className="printheight" sx={{ minHeight: '80%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  125. <Grid className="printHidden" item xs={12} width="100%">
  126. <div style={BackgroundHead} width="100%">
  127. <Stack direction="row" height='70px'>
  128. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>Payment Details</Typography>
  129. </Stack>
  130. </div>
  131. </Grid>
  132. <Grid item xs={12} width={{xs:"90%", sm:"90%", md:"90%", lg:"90%"}}>
  133. <Button
  134. aria-label={"back"}
  135. title={"back"}
  136. sx={{ ml: 0, mt: 2.5 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate(-1) }}
  137. >
  138. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  139. </Button>
  140. </Grid>
  141. {/*row 1*/}
  142. <Grid item xs={12} md={12} sx={{textAlign: "center" }}>
  143. <Grid container justifyContent="center" direction="column" spacing={2} sx={{ p: 2 }} alignitems="stretch" >
  144. <Grid className="printOrder" item xs={12} md={5} sx={{ pt: 2 }} style={{ height: '100%', order: 1 }}>
  145. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  146. <PaymentDetails
  147. formData={record}
  148. doPrint={doPrint}
  149. onDownload={onDownload}
  150. onRefresh={loadForm}
  151. style={{
  152. display: "flex",
  153. height: "100%",
  154. flex: 1
  155. }}
  156. />
  157. </Box>
  158. </Grid>
  159. <Grid item xs={12} md={5} sx={{ pt: 1, pb: 2 }} style={{ height: '100%', order: 2 }}>
  160. <Box xs={12} md={12} sx={{ border: '3px solid #eee', borderRadius: '10px' }} >
  161. <DataGrid
  162. recordList={itemList}
  163. />
  164. </Box>
  165. </Grid>
  166. </Grid>
  167. </Grid>
  168. {/*row 2*/}
  169. </Grid >
  170. </div>
  171. )
  172. );
  173. };
  174. export default Index;