25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

173 satır
5.2 KiB

  1. import {
  2. useEffect,
  3. useState
  4. } from "react";
  5. // material-ui
  6. import {
  7. Grid,
  8. Typography,
  9. Stack,
  10. Box,
  11. Button
  12. } from '@mui/material';
  13. import Loadable from 'components/Loadable';
  14. import { lazy } from 'react';
  15. import {
  16. // useNavigate,
  17. useParams
  18. } from "react-router-dom";
  19. import axios from "axios";
  20. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  21. const ApplicationDetailCard = Loadable(lazy(() => import('./ApplicationDetailCard')));
  22. // const TabTableDetail = Loadable(lazy(() => import('./tabTableDetail/TabTable')));
  23. import {
  24. GET_PUBLIC_NOTICE_APPLY_DETAIL,
  25. SET_PUBLIC_NOTICE_STATUS_CANCELLED
  26. } from "utils/ApiPathConst";
  27. import { useNavigate } from "react-router-dom";
  28. const StatusChangeDialog = Loadable(lazy(() => import('./StatusChangeDialog')));
  29. import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined';
  30. // ==============================|| Body - DEFAULT ||============================== //
  31. const DashboardDefault = () => {
  32. const params = useParams();
  33. const [applicationDetailData, setApplicationDetailData] = useState({});
  34. const [appNo, setAapNo] = useState("");
  35. // const [refApplicationDetailData, setRefApplicationDetailData] = React.useState({});
  36. const navigate = useNavigate()
  37. //statusWindow
  38. const [open, setOpen] = useState(false);
  39. const [getStatus, setStatus] = useState("");
  40. const [statusWindowAccepted, setStatusWindowAccepted] = useState(false);
  41. const BackgroundHead = {
  42. backgroundImage: `url(${titleBackgroundImg})`,
  43. width: '100%',
  44. height: '100%',
  45. backgroundSize: 'contain',
  46. backgroundRepeat: 'no-repeat',
  47. backgroundColor: '#0C489E',
  48. backgroundPosition: 'right'
  49. }
  50. // const appNo = "G2023-343"
  51. useEffect(() => {
  52. loadApplicationDetail()
  53. }, []);
  54. const loadApplicationDetail = () => {
  55. if (params.id > 0) {
  56. axios.get(`${GET_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`)
  57. .then((response) => {
  58. if (response.status === 200) {
  59. setApplicationDetailData(response.data);
  60. setAapNo(response.data.data.appNo);
  61. }
  62. })
  63. .catch(error => {
  64. console.log(error);
  65. return false;
  66. });
  67. }
  68. }
  69. useEffect(() => {
  70. if (applicationDetailData.data === null) {
  71. navigate('/publicNotice');
  72. }
  73. }, [applicationDetailData]);
  74. const handleClose = () => {
  75. setOpen(false);
  76. setStatus("")
  77. setStatusWindowAccepted(false)
  78. };
  79. useEffect(() => {
  80. if (statusWindowAccepted) {
  81. if (getStatus == "cancel") {
  82. onCancelledClick()
  83. }
  84. }
  85. }, [statusWindowAccepted]);
  86. useEffect(() => {
  87. // console.log(getStatus)
  88. if (getStatus !== "") {
  89. setOpen(true)
  90. }
  91. }, [getStatus]);
  92. const onCancelledClick = () => {
  93. if (params.id > 0) {
  94. axios.get(`${SET_PUBLIC_NOTICE_STATUS_CANCELLED}/${params.id}`)
  95. .then((response) => {
  96. if (response.status === 204) {
  97. setOpen(false);
  98. handleClose();
  99. loadApplicationDetail()
  100. }
  101. })
  102. .catch(error => {
  103. console.log(error);
  104. return false;
  105. });
  106. }
  107. };
  108. return (
  109. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#ffffff' }} direction="column">
  110. <StatusChangeDialog open={open} handleClose={handleClose} setStatusWindowAccepted={setStatusWindowAccepted} getStatus={getStatus} />
  111. <Grid item xs={12}>
  112. <div style={BackgroundHead}>
  113. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  114. <Typography ml={15} color='#FFF' variant="h4">我的公共啟事</Typography>
  115. </Stack>
  116. </div>
  117. </Grid>
  118. <Grid item xs={12} >
  119. <Stack direction="row" height='20px' justifyContent="flex-start" alignItems="center">
  120. <Typography ml={3} mt={3} variant="h4">我的公共啟事 / {appNo}</Typography>
  121. </Stack>
  122. </Grid>
  123. <Grid item xs={12} md={12}>
  124. <Grid container direction="column" justifyContent="flex-start" alignItems="center">
  125. <Grid item xs={12} width="75%">
  126. <Button sx={{ mt: 4 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate("/publicNotice") }}>
  127. <KeyboardBackspaceOutlinedIcon />
  128. <Typography variant="h4">Back</Typography>
  129. </Button>
  130. </Grid>
  131. {/* <Grid item xs={12} md={12} > */}
  132. {/* <Grid container direction="column" alignItems="center"> */}
  133. <Grid item width="75%">
  134. <Box xs={12} mt={3} sx={{ p: 2, border: '3px groove grey', borderRadius: '10px' }}>
  135. <ApplicationDetailCard
  136. setStatus={setStatus}
  137. applicationDetailData={applicationDetailData}
  138. // isCollectData={isCollectData}
  139. // isNewRecord={isNewRecord}
  140. />
  141. </Box>
  142. </Grid>
  143. {/* <Grid item xs={12} md={12} width="85%">
  144. <Box xs={12} mt={3}>
  145. <TabTableDetail applicationDetailData={applicationDetailData}/>
  146. </Box>
  147. </Grid> */}
  148. {/* </Grid> */}
  149. {/* </Grid> */}
  150. </Grid>
  151. </Grid>
  152. </Grid>
  153. );
  154. };
  155. export default DashboardDefault;