25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

431 lines
14 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 * as HttpUtils from "utils/HttpUtils";
  21. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  22. const ApplicationDetailCard = Loadable(lazy(() => import('./ApplicationDetailCard')));
  23. const GazetteDetailCard = Loadable(lazy(() => import('./GazetteDetailCard')));
  24. const ClientDetailCard = Loadable(lazy(() => import('./ClientDetailCard')));
  25. const TabTableDetail = Loadable(lazy(() => import('./tabTableDetail/TabTable')));
  26. import {
  27. GET_PUBLIC_NOTICE_APPLY_DETAIL,
  28. UPDATE_PUBLIC_NOTICE_APPLY_DETAIL,
  29. SET_PUBLIC_NOTICE_GROUP_DETAIL,
  30. SET_PUBLIC_NOTICE_STATUS_NOT_ACCEPT,
  31. SET_PUBLIC_NOTICE_STATUS_COMPLATED,
  32. SET_PUBLIC_NOTICE_STATUS_WITHDRAW,
  33. SET_PUBLIC_NOTICE_STATUS_RESUBMIT,
  34. SET_PUBLIC_NOTICE_STATUS_REVIEWED,
  35. SET_PUBLIC_NOTICE_STATUS_PUBLISH
  36. } from "utils/ApiPathConst";
  37. const StatusChangeDialog = Loadable(lazy(() => import('./StatusChangeDialog')));
  38. import * as DateUtils from "utils/DateUtils";
  39. import { notifyActionSuccess, notifySaveSuccess } from "utils/CommonFunction";
  40. import ForwardIcon from '@mui/icons-material/Forward';
  41. import { useNavigate } from "react-router-dom";
  42. // ==============================|| Body - DEFAULT ||============================== //
  43. const PublicNoticeDetail_GLD = () => {
  44. const params = useParams();
  45. const navigate = useNavigate()
  46. const [applicationDetailData, setApplicationDetailData] = useState({});
  47. const [proofList, setProofList] = useState([]);
  48. const [paymentList, setPaymentList] = useState([]);
  49. // const [refApplicationDetailData, setRefApplicationDetailData] = React.useState({});
  50. const [isLoading, setLoading] = useState(false);
  51. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  52. const [getUploadStatus, setUploadStatus] = useState(false);
  53. //pageTitle
  54. const [appNo, setAapNo] = useState("");
  55. const [gazetteIssue, setGazetteIssue] = useState("");
  56. const [issueDate, setIssueDate] = useState("");
  57. const [issueNum, setIssueNum] = useState("");
  58. const [groupNo, setGroupNo] = useState("");
  59. // const [groupTitle, setGroupTitle] = useState("");
  60. //statusWindow
  61. const [open, setOpen] = useState(false);
  62. const [getStatus, setStatus] = useState("");
  63. const [statusWindowAccepted, setStatusWindowAccepted] = useState(false);
  64. const [selectedGazetteGroup, setSelectedGazetteGroup] = useState({});
  65. const [selectedGazetteGroupInputType, setSelectedGazetteGroupInputType] = useState("");
  66. const [getReason, setReason] = useState({});
  67. //editMode
  68. const [updateApplicationObject, setUpdateApplicationObject] = useState({});
  69. const [editMode, isEditMode] = useState(false);
  70. const [isSave, setiIsSave] = useState(false);
  71. const BackgroundHead = {
  72. backgroundImage: `url(${titleBackgroundImg})`,
  73. width: '100%',
  74. height: '100%',
  75. backgroundSize: 'contain',
  76. backgroundRepeat: 'no-repeat',
  77. backgroundColor: '#0C489E',
  78. backgroundPosition: 'right'
  79. }
  80. const title = groupNo != null ? (appNo + ", " + gazetteIssue + ", " + issueNum + " , " + groupNo) : (appNo + ", " + gazetteIssue + ", " + issueNum)
  81. useEffect(() => {
  82. loadApplicationDetail();
  83. }, []);
  84. // useEffect(() => {
  85. // if (reload){
  86. // loadApplicationDetail()
  87. // }
  88. // }, [reload]);
  89. useEffect(() => {
  90. if (editMode && isSave) {
  91. onUpdateClick(updateApplicationObject)
  92. }
  93. }, [updateApplicationObject]);
  94. const loadApplicationDetail = () => {
  95. if (params.id > 0) {
  96. axios.get(`${GET_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`)
  97. .then((response) => {
  98. if (response.status === 200) {
  99. setApplicationDetailData(response.data);
  100. const gazetteIssueDetail = response.data.gazetteIssueDetail;
  101. setAapNo(response.data.data.appNo);
  102. setGazetteIssue(gazetteIssueDetail.issueYear + " Vol " + gazetteIssueDetail.volume);
  103. setIssueNum(" No. " + gazetteIssueDetail.issueNo);
  104. setIssueDate(DateUtils.dateFormat(gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
  105. setGroupNo(response.data.data.groupNo);
  106. setProofList(response.data.proofList);
  107. setPaymentList(response.data.paymentList);
  108. setLoading(false);
  109. }
  110. })
  111. .catch(error => {
  112. console.log(error);
  113. return false;
  114. });
  115. }
  116. }
  117. const onUpdateClick = (updateApplicationObject) => {
  118. const data = updateApplicationObject.objectData
  119. if (params.id > 0) {
  120. setLoading(true);
  121. axios.post(`${UPDATE_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`,
  122. {
  123. contactPerson: data.contactPerson,
  124. contactFaxNo: data.contactFaxNo,
  125. contactTelNo: data.contactTelNo,
  126. }
  127. )
  128. .then((response) => {
  129. if (response.status === 200) {
  130. location.reload();
  131. }
  132. })
  133. .catch(error => {
  134. console.log(error);
  135. return false;
  136. });
  137. }
  138. };
  139. useEffect(() => {
  140. // console.log(getStatus)
  141. if (getStatus !== "") {
  142. setOpen(true)
  143. }
  144. }, [getStatus]);
  145. const handleClose = () => {
  146. handleReset()
  147. setOpen(false);
  148. setStatus("")
  149. setStatusWindowAccepted(false)
  150. };
  151. const handleReset = () => {
  152. setSelectedGazetteGroupInputType("")
  153. setSelectedGazetteGroup({});
  154. setReason({});
  155. };
  156. useEffect(() => {
  157. if (statusWindowAccepted) {
  158. if (getStatus == "genGazetteCode") {
  159. onAcceptedClick()
  160. } else if (getStatus == "complete") {
  161. onComplatedClick()
  162. } else if (getStatus == "withdraw") {
  163. onWithdrawnClick()
  164. } else if (getStatus == "notAccepted") {
  165. onNotAcceptClick(getReason);
  166. } else if (getStatus == "resubmit") {
  167. onReSubmitClick(getReason);
  168. } else if (getStatus == "publish") {
  169. onPublishClick();
  170. }
  171. }
  172. }, [statusWindowAccepted]);
  173. const onAcceptedClick = () => {
  174. if (params.id > 0) {
  175. axios.post(`${SET_PUBLIC_NOTICE_GROUP_DETAIL}/${params.id}`,
  176. {
  177. "groupTitle": selectedGazetteGroup.title,
  178. "groupNo": selectedGazetteGroup.type,
  179. }
  180. )
  181. .then((response) => {
  182. if (response.status === 204) {
  183. setOpen(false);
  184. handleClose();
  185. // location.reload();
  186. loadApplicationDetail()
  187. notifyActionSuccess("Gen Gazette Code Success!")
  188. }
  189. })
  190. .catch(error => {
  191. console.log(error);
  192. return false;
  193. });
  194. }
  195. };
  196. const onNotAcceptClick = (reason) => {
  197. if (params.id <= 0) return;
  198. HttpUtils.post({
  199. url: `${SET_PUBLIC_NOTICE_STATUS_NOT_ACCEPT}/${params.id}`,
  200. params: reason,
  201. onSuccess: function () {
  202. setOpen(false);
  203. handleClose();
  204. // location.reload();
  205. loadApplicationDetail()
  206. notifySaveSuccess()
  207. }
  208. });
  209. }
  210. const onPublishClick = () => {
  211. if (params.id <= 0) return;
  212. HttpUtils.get({
  213. url: `${SET_PUBLIC_NOTICE_STATUS_PUBLISH}/${params.id}`,
  214. onSuccess: function () {
  215. setOpen(false);
  216. handleClose();
  217. loadApplicationDetail()
  218. notifySaveSuccess()
  219. }
  220. });
  221. }
  222. const onComplatedClick = () => {
  223. if (params.id > 0) {
  224. axios.get(`${SET_PUBLIC_NOTICE_STATUS_COMPLATED}/${params.id}`)
  225. .then((response) => {
  226. if (response.status === 204) {
  227. setOpen(false);
  228. handleClose();
  229. // location.reload();
  230. loadApplicationDetail()
  231. notifySaveSuccess()
  232. }
  233. })
  234. .catch(error => {
  235. console.log(error);
  236. return false;
  237. });
  238. }
  239. };
  240. const onWithdrawnClick = () => {
  241. if (params.id > 0) {
  242. axios.get(`${SET_PUBLIC_NOTICE_STATUS_WITHDRAW}/${params.id}`)
  243. .then((response) => {
  244. if (response.status === 204) {
  245. setOpen(false);
  246. handleClose();
  247. loadApplicationDetail()
  248. notifyActionSuccess("Withdrawn Success!")
  249. }
  250. })
  251. .catch(error => {
  252. console.log(error);
  253. return false;
  254. });
  255. }
  256. };
  257. const onReSubmitClick = (reason) => {
  258. if (params.id > 0) {
  259. HttpUtils.post({
  260. url: `${SET_PUBLIC_NOTICE_STATUS_RESUBMIT}/${params.id}`,
  261. params: reason,
  262. onSuccess: function () {
  263. setOpen(false);
  264. handleClose();
  265. // location.reload();
  266. loadApplicationDetail()
  267. notifySaveSuccess()
  268. }
  269. });
  270. // axios.post(`${SET_PUBLIC_NOTICE_STATUS_RESUBMIT}/${params.id}`)
  271. // .then((response) => {
  272. // if (response.status === 204) {
  273. // setOpen(false);
  274. // handleClose();
  275. // // location.reload();
  276. // loadApplicationDetail()
  277. // notifySaveSuccess()
  278. // }
  279. // })
  280. // .catch(error => {
  281. // console.log(error);
  282. // return false;
  283. // });
  284. }
  285. };
  286. useEffect(() => {
  287. const status = applicationDetailData.data != undefined ? applicationDetailData.data.status : ""
  288. if (status === "submitted" && params.id > 0 && getUploadStatus) {
  289. axios.get(`${SET_PUBLIC_NOTICE_STATUS_REVIEWED}/${params.id}`)
  290. .then((response) => {
  291. if (response.status === 204) {
  292. setUploadStatus(false);
  293. location.reload();
  294. }
  295. })
  296. .catch(error => {
  297. console.log(error);
  298. return false;
  299. });
  300. } else {
  301. setUploadStatus(false);
  302. }
  303. }, [getUploadStatus]);
  304. return (
  305. <Grid container sx={{ width: "100%", backgroundColor: 'backgroundColor.default' }} direction="column">
  306. <StatusChangeDialog open={open}
  307. handleClose={handleClose}
  308. setReason={setReason}
  309. setStatusWindowAccepted={setStatusWindowAccepted}
  310. getStatus={getStatus}
  311. issueDate={issueDate}
  312. issueNum={issueNum}
  313. gazetteIssue={gazetteIssue}
  314. //combo value
  315. selectedGazetteGroup={selectedGazetteGroup}
  316. setSelectedGazetteGroup={setSelectedGazetteGroup}
  317. selectedGazetteGroupInputType={selectedGazetteGroupInputType}
  318. setSelectedGazetteGroupInputType={setSelectedGazetteGroupInputType}
  319. />
  320. <Grid item xs={12} >
  321. <div style={BackgroundHead}>
  322. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  323. <Typography ml={15} color='#FFF' variant="h4">Application</Typography>
  324. </Stack>
  325. </div>
  326. </Grid>
  327. <Grid item xs={12} sm={12} md={12} lg={12}>
  328. <Stack direction="row">
  329. <Button title="Back" sx={{ ml: 3.5, mt: 2.5 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate("/application/search") }}>
  330. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  331. </Button>
  332. <Typography ml={4} mt={3} variant="h4">{title}</Typography>
  333. </Stack>
  334. </Grid>
  335. {/* <Grid item xs={12} >
  336. <Stack direction="row" height='20px' justifyContent="flex-start" alignItems="center">
  337. <Typography ml={4} mt={3} variant="h4">{title}</Typography>
  338. </Stack>
  339. </Grid> */}
  340. <Grid item xs={12} sm={12} md={12} lg={12} xl={12} >
  341. <Grid container direction="row">
  342. <Grid item xs={12} md={12} lg={9} xl={9}>
  343. <Grid container direction="column">
  344. <Grid item xs={12} sm={12} md={12} lg={12} xl={12}>
  345. <Box xs={12} sx={{ ml: 2, mt: 3, mr: { xs: 2, sm: 2 }, borderRadius: '10px', backgroundColor: '#ffffff' }}>
  346. {isLoading && editMode ?
  347. <LoadingComponent /> :
  348. <ApplicationDetailCard
  349. applicationDetailData={applicationDetailData}
  350. setStatus={setStatus}
  351. // setReload = {setReload}
  352. setUploadStatus={setUploadStatus}
  353. setUpdateApplicationObject={setUpdateApplicationObject}
  354. isEditMode={isEditMode}
  355. setiIsSave={setiIsSave}
  356. // isNewRecord={isNewRecord}
  357. />
  358. }
  359. </Box>
  360. </Grid>
  361. <Grid item xs={12} md={12} lg={12} xl={12}>
  362. <Box xs={12} sx={{ ml: 2, mt: 3, mr: { xs: 2, sm: 2 }, borderRadius: '10px', backgroundColor: '#ffffff' }}>
  363. <GazetteDetailCard
  364. // updateUserObject={updateUserObject}
  365. applicationDetailData={applicationDetailData}
  366. setStatus={setStatus}
  367. // isCollectData={isCollectData}
  368. // isNewRecord={isNewRecord}
  369. />
  370. </Box>
  371. </Grid>
  372. <Grid item xs={12} md={12} lg={12} xl={12}>
  373. <Box xs={12} sx={{ ml: 2, mt: 3, mr: { sm: 2 }, borderRadius: '10px', width: { xs: '92vw', sm: '96.5vw', md: "auto" }, backgroundColor: '#ffffff' }}>
  374. <TabTableDetail
  375. applicationDetailData={applicationDetailData}
  376. proofList={proofList}
  377. paymentList={paymentList}
  378. />
  379. </Box>
  380. <br />
  381. </Grid>
  382. </Grid>
  383. </Grid>
  384. <Grid item xs={12} md={12} lg={3} xl={3} sx={{ mt: { xs: -3, sm: -3 } }}>
  385. <Grid container>
  386. <Grid item xs={12} md={12}>
  387. <Box xs={12} md={12} sx={{ ml: 2, mt: 3, mb: 3, mr: { xs: 2, sm: 2 }, borderRadius: '10px', backgroundColor: '#ffffff' }}>
  388. <ClientDetailCard
  389. // updateUserObject={updateUserObject}
  390. applicationDetailData={applicationDetailData}
  391. // isCollectData={isCollectData}
  392. // isNewRecord={isNewRecord}
  393. />
  394. </Box>
  395. </Grid>
  396. </Grid>
  397. </Grid>
  398. </Grid>
  399. </Grid>
  400. </Grid>
  401. );
  402. };
  403. export default PublicNoticeDetail_GLD;