Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

297 строки
14 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Button,
  7. Dialog, DialogTitle, DialogContent, DialogActions
  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 { useParams } from "react-router-dom";
  13. import { useNavigate } from "react-router-dom";
  14. import * as DateUtils from "utils/DateUtils"
  15. import * as FormatUtils from "utils/FormatUtils";
  16. import Loadable from 'components/Loadable';
  17. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  18. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  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. import {
  29. // useEffect,
  30. useState
  31. } from "react";
  32. import { PNSPS_BUTTON_THEME,
  33. // PNSPS_LONG_BUTTON_THEME
  34. } from "../../../themes/buttonConst";
  35. import { ThemeProvider } from "@emotion/react";
  36. import { FormattedMessage, useIntl } from "react-intl";
  37. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  38. const Index = () => {
  39. const params = useParams();
  40. const navigate = useNavigate()
  41. const [fee, setFee] = useState(0);
  42. const [record, setRecord] = React.useState({});
  43. const [onReady, setOnReady] = React.useState(false);
  44. const [isPopUp, setIsPopUp] = useState(false);
  45. const [paymentHoldedErrText, setPaymentHoldedErrText] = React.useState("");
  46. const [paymentHoldedErr, setPaymentHoldedErr] = React.useState(false);
  47. const intl = useIntl();
  48. React.useEffect(() => {
  49. loadForm();
  50. }, []);
  51. React.useEffect(() => {
  52. setOnReady(true);
  53. }, [record]);
  54. const loadForm = () => {
  55. if (params.id > 0) {
  56. HttpUtils.get({
  57. url: UrlUtils.GET_PROOF_PAY + "/" + params.id,
  58. onSuccess: (responseData) => {
  59. // if (!responseData.data?.id) {
  60. // navigate("/proof/search");
  61. // }
  62. setRecord(responseData.data);
  63. setFee(responseData.data.fee);
  64. },
  65. onError: () => {
  66. }
  67. });
  68. }
  69. }
  70. function doPayment() {
  71. setIsPopUp(false);
  72. let appIdList = [record?.appId]
  73. handlePaymentCheck(appIdList)
  74. }
  75. const handlePaymentCheck = (appIdList) => {
  76. HttpUtils.post({
  77. url: UrlUtils.PAYMENT_CHECK,
  78. params: {
  79. appIds: appIdList
  80. },
  81. onSuccess: (responseData) => {
  82. const latestData = {};
  83. responseData.forEach(item => {
  84. const { appId, timeDiff } = item;
  85. if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) {
  86. latestData[appId] = item;
  87. }
  88. });
  89. const latestDataObjects = Object.values(latestData);
  90. const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR");
  91. const filteredAppIds = filteredData.map(item => item.appId);
  92. const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId));
  93. const combinedAppIdsArray = [...appIdsNotInData, ...filteredAppIds];
  94. const readyToPayment = appIdList.every(appId => combinedAppIdsArray.includes(appId));
  95. if (readyToPayment) {
  96. navigate('/paymentPage', { state: { amount: fee, appIdList: appIdList } });
  97. } else {
  98. const appIdsInData = appIdList.filter(appId => !combinedAppIdsArray.some(item => item === appId));
  99. const HoldingApplication = latestDataObjects.filter(item => appIdsInData.includes(item.appId));
  100. const resultString = HoldingApplication.map(item => item.appNo).join(' , ');
  101. setPaymentHoldedErrText(resultString);
  102. // setPaymentHoldedErrText(intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: record.appNo }));
  103. setPaymentHoldedErr(true);
  104. }
  105. }
  106. });
  107. };
  108. return (
  109. !onReady ?
  110. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  111. <Grid item>
  112. <LoadingComponent />
  113. </Grid>
  114. </Grid>
  115. :
  116. (
  117. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  118. <Grid item xs={12} width="100%">
  119. <div style={BackgroundHead} width="100%" >
  120. <Stack direction="row" height='70px'>
  121. <Typography ml={15} color='#FFF' variant="h4" sx={{ display: { xs: 'none', sm: 'none', md: 'block' }, pt: 2 }}>
  122. <FormattedMessage id="proofRecord" />
  123. </Typography>
  124. </Stack>
  125. </div>
  126. </Grid>
  127. {/*row 1*/}
  128. <Grid item xs={12} md={12} >
  129. <Grid container justifyContent="flex-start" alignItems="center" >
  130. <center>
  131. <Grid item xs={12} md={8} >
  132. <Typography variant="h4" sx={{ textAlign: "left", ml: 4, mr: 4, mt: 4, borderBottom: "1px solid black" }}>
  133. <FormattedMessage id="proofPaymentHeader_online" />
  134. </Typography>
  135. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  136. <div dangerouslySetInnerHTML={{
  137. __html: intl.formatMessage(
  138. {
  139. id: 'proofPaymentBody_online'
  140. },
  141. {
  142. appNo: record?.appNo,
  143. }
  144. )
  145. }} />
  146. <br />
  147. <div dangerouslySetInnerHTML={{
  148. __html: intl.formatMessage(
  149. {
  150. id: 'proofPaymentBody_online2'
  151. },
  152. {
  153. paymentDeadline: DateUtils.dateFormat(record?.closingDate, intl.formatMessage({id: "dateStrFormat"})),
  154. }
  155. )
  156. }} />
  157. <br />
  158. </Typography>
  159. <Typography variant="h4" sx={{ ml: 8, textAlign: "left" }}>
  160. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  161. <Button
  162. component="span"
  163. variant="contained"
  164. // sx={{ ml: { sm: 4, md: 4, lg: 4 }, mr: 4, mt: { xs: 2, sm: 2 }, mb: { xs: 2, sm: 2 } }}
  165. sx={{mr: 4 }}
  166. onClick={() => { setIsPopUp(true) }}
  167. >
  168. <FormattedMessage id="payInstantly" />
  169. </Button>
  170. </ThemeProvider>
  171. <FormattedMessage id="or" />
  172. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  173. <Button
  174. component="span"
  175. variant="contained"
  176. sx={{ ml: { sm: 4, md: 4, lg: 4 }, mr: 4, mt: { xs: 2, sm: 2 }, mb: { xs: 2, sm: 2 } }}
  177. onClick={() => {
  178. navigate("/publicNotice");
  179. }}
  180. >
  181. <FormattedMessage id="payLater" />
  182. </Button>
  183. </ThemeProvider>
  184. </Typography>
  185. <Typography variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  186. <div dangerouslySetInnerHTML={{
  187. __html: intl.formatMessage(
  188. {
  189. id: 'proofPaymentBody_online3'
  190. }
  191. )
  192. }} />
  193. <br />
  194. </Typography>
  195. </Grid>
  196. </center>
  197. </Grid>
  198. </Grid>
  199. <div>
  200. <Dialog
  201. open={isPopUp}
  202. onClose={() => setIsPopUp(false)}
  203. PaperProps={{
  204. sx: {
  205. minWidth: '40vw',
  206. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '30vw' },
  207. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '50vh' }
  208. }
  209. }}
  210. >
  211. <DialogTitle>
  212. <Typography variant="h3" >
  213. <FormattedMessage id="payConfirm" />
  214. </Typography>
  215. </DialogTitle>
  216. <DialogContent style={{ display: 'flex', }}>
  217. <Stack direction="column" justifyContent="space-between">
  218. <Typography variant="h4">
  219. <FormattedMessage id="totalAmount" /> ($): {FormatUtils.currencyFormat(fee)}
  220. </Typography>
  221. </Stack>
  222. </DialogContent>
  223. <DialogActions>
  224. <Button onClick={() => setIsPopUp(false)}>
  225. <Typography variant="h5">
  226. <FormattedMessage id="close" />
  227. </Typography></Button>
  228. <Button onClick={() => doPayment()}><Typography variant="h5">
  229. <FormattedMessage id="confirm" />
  230. </Typography></Button>
  231. </DialogActions>
  232. </Dialog>
  233. </div>
  234. {/*row 2*/}
  235. <div>
  236. <Dialog
  237. open={paymentHoldedErr}
  238. onClose={() => setPaymentHoldedErr(false)}
  239. PaperProps={{
  240. sx: {
  241. minWidth: '40vw',
  242. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  243. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  244. }
  245. }}
  246. >
  247. <DialogTitle></DialogTitle>
  248. <Typography variant="h4" style={{ paddingLeft: '24px' }}><FormattedMessage id="MSG.actionFail" /></Typography>
  249. <DialogContent style={{ display: 'flex', }}>
  250. <Stack direction="column" justifyContent="space-between">
  251. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: 'MSG.paymentHolded' }, { appNo: paymentHoldedErrText }) }} />
  252. </Stack>
  253. </DialogContent>
  254. <DialogActions>
  255. <Button onClick={() => setPaymentHoldedErr(false)} aria-label={intl.formatMessage({ id: 'close' })}>
  256. <Typography variant="h5">
  257. <FormattedMessage id="close" />
  258. </Typography></Button>
  259. </DialogActions>
  260. </Dialog>
  261. </div>
  262. </Grid >
  263. )
  264. );
  265. };
  266. export default Index;