Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

563 linhas
34 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. // InputAdornment,
  7. Typography, FormLabel,
  8. OutlinedInput,
  9. Stack,
  10. Dialog, DialogTitle, DialogContent, DialogActions
  11. } from '@mui/material';
  12. // import MainCard from "../../components/MainCard";
  13. const MainCard = Loadable(lazy(() => import('components/MainCard')));
  14. import { useForm } from "react-hook-form";
  15. import { useNavigate } from "react-router-dom";
  16. import {
  17. useEffect,
  18. useState
  19. } from "react";
  20. // import Checkbox from "@mui/material/Checkbox";
  21. import Loadable from 'components/Loadable';
  22. import { lazy } from 'react';
  23. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  24. // import {useParams} from "react-router-dom";
  25. import * as HttpUtils from "utils/HttpUtils"
  26. import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
  27. import * as DateUtils from "utils/DateUtils";
  28. import * as FormatUtils from "utils/FormatUtils";
  29. // import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined';
  30. // import DoneIcon from '@mui/icons-material/Done';
  31. import CloseIcon from '@mui/icons-material/Close';
  32. import EditNoteIcon from '@mui/icons-material/EditNote';
  33. import DownloadIcon from '@mui/icons-material/Download';
  34. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  35. const ApplicationDetailCard = (
  36. { applicationDetailData,
  37. setStatus,
  38. // updateUserObject,
  39. // isNewRecord
  40. }
  41. ) => {
  42. const [isPopUp, setIsPopUp] = useState(false);
  43. // const params = useParams();
  44. const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
  45. const [fee, setFee] = useState(0);
  46. const [companyName, setCompanyName] = useState({});
  47. const [fileDetail, setfileDetail] = useState({});
  48. const [onReady, setOnReady] = useState(false);
  49. const [issueNum, setIssueNum] = useState("");
  50. const [issueDate, setIssueDate] = useState("");
  51. const { register,
  52. // getValues
  53. } = useForm();
  54. const navigate = useNavigate();
  55. useEffect(() => {
  56. //if user data from parent are not null
  57. // console.log(applicationDetailData)
  58. if (Object.keys(applicationDetailData).length > 0 && applicationDetailData.data !== null) {
  59. setCurrentApplicationDetailData(applicationDetailData.data);
  60. setCompanyName(applicationDetailData.companyName);
  61. setfileDetail(applicationDetailData.fileDetail);
  62. setIssueNum(applicationDetailData.gazetteIssueDetail.volume + "/" + applicationDetailData.gazetteIssueDetail.year
  63. + " No. " + applicationDetailData.gazetteIssueDetail.issueNo);
  64. setIssueDate(DateUtils.dateFormat(applicationDetailData.gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
  65. for (let i = 0; i < applicationDetailData.proofList.length; i++) {
  66. if (applicationDetailData.proofList[i].action == true) {
  67. setFee(applicationDetailData.proofList[i].fee);
  68. }
  69. }
  70. }
  71. }, [applicationDetailData]);
  72. useEffect(() => {
  73. //if state data are ready and assign to different field
  74. // console.log(currentApplicationDetailData)
  75. if (Object.keys(currentApplicationDetailData).length > 0) {
  76. setOnReady(true);
  77. }
  78. }, [currentApplicationDetailData]);
  79. const onDownloadClick = () => () => {
  80. HttpUtils.fileDownload({
  81. fileId: fileDetail.id,
  82. skey: fileDetail.skey,
  83. filename: fileDetail.filename,
  84. });
  85. };
  86. const cancelledClick = () => () => {
  87. setStatus("cancel")
  88. };
  89. function doPayment() {
  90. setIsPopUp(false);
  91. navigate('/paymentPage', { state: { amount: fee, appIdList: [currentApplicationDetailData.id] } });
  92. }
  93. return (
  94. !onReady ?
  95. <LoadingComponent />
  96. :
  97. <MainCard elevation={0}
  98. border={false}
  99. content={false}
  100. >
  101. <Grid container spacing={1} direction="row">
  102. <Grid item xs={12}>
  103. <Stack
  104. direction="row"
  105. justifyContent="space-between"
  106. alignItems="center"
  107. spacing={2}
  108. mb={2}
  109. >
  110. {
  111. currentApplicationDetailData.status == "confirmed" ?
  112. <Button
  113. // size="large"
  114. variant="contained"
  115. onClick={() => { setIsPopUp(true) }}
  116. disabled={currentApplicationDetailData.status == "rejected" || currentApplicationDetailData.status == "cancelled" || currentApplicationDetailData.status == "paid"}
  117. sx={{
  118. textTransform: 'capitalize',
  119. alignItems: 'end'
  120. }}>
  121. <EditNoteIcon />
  122. <Typography ml={1} variant="h5"> 支付</Typography>
  123. </Button>
  124. : null
  125. }
  126. <Button
  127. // size="large"
  128. variant="contained"
  129. onClick={cancelledClick()}
  130. disabled={currentApplicationDetailData.status !== "submitted"}
  131. title={"取消"}
  132. sx={{
  133. textTransform: 'capitalize',
  134. alignItems: 'end',
  135. backgroundColor: '#ffa733'
  136. }}>
  137. <CloseIcon sx={{mb:0.5}}/>
  138. <Typography ml={1} variant="h5"> 取消</Typography>
  139. </Button>
  140. </Stack>
  141. </Grid>
  142. </Grid>
  143. <Typography variant="h4" sx={{ mb: 2, borderBottom: "1px solid black" }}>
  144. 公共啟事申請資料
  145. </Typography>
  146. <form>
  147. <Grid container direction="column">
  148. <Grid item xs={12} md={12}>
  149. <Grid container direction="row" justifyContent="space-between"
  150. alignItems="center">
  151. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  152. <Grid container alignItems={"center"}>
  153. <Grid item xs={12} md={3} lg={3}
  154. sx={{ display: 'flex', alignItems: 'center' }}>
  155. <FormLabel><Typography variant="h5">申請編號:</Typography></FormLabel>
  156. </Grid>
  157. <Grid item xs={12} md={9} lg={9}>
  158. <FormControl variant="outlined" fullWidth disabled>
  159. <OutlinedInput
  160. fullWidth
  161. size="small"
  162. {...register("appNo",
  163. {
  164. value: currentApplicationDetailData.appNo,
  165. })}
  166. id='appNo'
  167. sx={{
  168. "& .MuiInputBase-input.Mui-disabled": {
  169. WebkitTextFillColor: "#000000",
  170. background: "#f8f8f8",
  171. },
  172. }}
  173. />
  174. </FormControl>
  175. </Grid>
  176. </Grid>
  177. </Grid>
  178. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  179. <Grid container alignItems={"center"}>
  180. <Grid item xs={12} md={3} lg={3}
  181. sx={{ display: 'flex', alignItems: 'center' }}>
  182. <FormLabel><Typography variant="h5">申請狀態:</Typography></FormLabel>
  183. </Grid>
  184. <Grid item xs={12} md={4} lg={4}>
  185. <FormControl variant="outlined">
  186. {StatusUtils.getStatusByText(currentApplicationDetailData.status)}
  187. </FormControl>
  188. </Grid>
  189. {
  190. currentApplicationDetailData.reason ?
  191. <Grid item xs={12} md={5} lg={5}>
  192. <Grid container alignItems={"center"}>
  193. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  194. <Grid item xs={12} md={7} lg={7}>
  195. <FormLabel><Typography variant="h5">原因:</Typography></FormLabel>
  196. </Grid>
  197. <Grid item xs={12} md={5} lg={5}>
  198. <FormControl variant="outlined" fullWidth disabled>
  199. <Typography id='reason' variant="h5">
  200. {currentApplicationDetailData.reason}
  201. </Typography>
  202. </FormControl>
  203. </Grid>
  204. </Stack>
  205. </Grid>
  206. </Grid>
  207. : ""
  208. }
  209. </Grid>
  210. </Grid>
  211. </Grid>
  212. <Grid container direction="row" justifyContent="space-between"
  213. alignItems="center">
  214. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  215. <Grid container alignItems={"center"}>
  216. <Grid item xs={12} md={3} lg={3}
  217. sx={{ display: 'flex', alignItems: 'center' }}>
  218. <FormLabel><Typography variant="h5">申請人:</Typography></FormLabel>
  219. </Grid>
  220. <Grid item xs={12} md={9} lg={9}>
  221. <FormControl variant="outlined" fullWidth disabled >
  222. {currentApplicationDetailData.orgId === null ?
  223. <OutlinedInput
  224. fullWidth
  225. size="small"
  226. {...register("contactPerson",
  227. {
  228. value: currentApplicationDetailData.contactPerson,
  229. })}
  230. id='contactPerson'
  231. sx={{
  232. "& .MuiInputBase-input.Mui-disabled": {
  233. WebkitTextFillColor: "#000000",
  234. background: "#f8f8f8",
  235. },
  236. }}
  237. /> :
  238. <OutlinedInput
  239. fullWidth
  240. size="small"
  241. {...register("companyName",
  242. {
  243. value: companyName.enCompanyName,
  244. })}
  245. id='companyName'
  246. sx={{
  247. "& .MuiInputBase-input.Mui-disabled": {
  248. WebkitTextFillColor: "#000000",
  249. background: "#f8f8f8",
  250. },
  251. }}
  252. />
  253. }
  254. </FormControl>
  255. </Grid>
  256. </Grid>
  257. </Grid>
  258. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  259. <Grid container alignItems={"center"}>
  260. <Grid item xs={12} md={3} lg={3}
  261. sx={{ display: 'flex', alignItems: 'center' }}>
  262. <FormLabel><Typography variant="h5">憲報期數:</Typography></FormLabel>
  263. </Grid>
  264. <Grid item xs={12} md={9} lg={9}>
  265. <Stack direction="row">
  266. <FormControl variant="outlined" fullWidth disabled>
  267. <OutlinedInput
  268. size="small"
  269. {...register("issueNum",
  270. {
  271. value: issueNum,
  272. })}
  273. id='issueNum'
  274. sx={{
  275. "& .MuiInputBase-input.Mui-disabled": {
  276. WebkitTextFillColor: "#000000",
  277. background: "#f8f8f8",
  278. },
  279. }}
  280. />
  281. </FormControl>
  282. </Stack>
  283. </Grid>
  284. </Grid>
  285. </Grid>
  286. </Grid>
  287. <Grid container direction="row" justifyContent="space-between"
  288. alignItems="center">
  289. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  290. <Grid container alignItems={"center"}>
  291. <Grid item xs={12} md={3} lg={3}
  292. sx={{ display: 'flex', alignItems: 'center' }}>
  293. <FormLabel><Typography variant="h5">聯絡人:</Typography></FormLabel>
  294. </Grid>
  295. <Grid item xs={12} md={9} lg={9}>
  296. <FormControl variant="outlined" fullWidth disabled>
  297. <OutlinedInput
  298. fullWidth
  299. size="small"
  300. {...register("contactPerson",
  301. {
  302. value: currentApplicationDetailData.contactPerson,
  303. })}
  304. id='contactPerson'
  305. sx={{
  306. "& .MuiInputBase-input.Mui-disabled": {
  307. WebkitTextFillColor: "#000000",
  308. background: "#f8f8f8",
  309. },
  310. }}
  311. />
  312. </FormControl>
  313. </Grid>
  314. </Grid>
  315. </Grid>
  316. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  317. <Grid container alignItems={"center"}>
  318. <Grid item xs={12} md={3} lg={3}
  319. sx={{ display: 'flex', alignItems: 'center' }}>
  320. <FormLabel><Typography variant="h5">發布日期:</Typography></FormLabel>
  321. </Grid>
  322. <Grid item xs={12} md={9} lg={9}>
  323. <Stack direction="row">
  324. <FormControl variant="outlined" fullWidth disabled>
  325. <OutlinedInput
  326. size="small"
  327. {...register("issueDate",
  328. {
  329. value: issueDate,
  330. })}
  331. id='issueDate'
  332. sx={{
  333. "& .MuiInputBase-input.Mui-disabled": {
  334. WebkitTextFillColor: "#000000",
  335. background: "#f8f8f8",
  336. },
  337. }}
  338. />
  339. </FormControl>
  340. </Stack>
  341. </Grid>
  342. </Grid>
  343. </Grid>
  344. </Grid>
  345. <Grid container direction="row" justifyContent="space-between"
  346. alignItems="center">
  347. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  348. <Grid container alignItems={"center"}>
  349. <Grid item xs={12} md={3} lg={3}
  350. sx={{ display: 'flex', alignItems: 'center' }}>
  351. <FormLabel><Typography variant="h5">聯絡電話:</Typography></FormLabel>
  352. </Grid>
  353. <Grid item xs={12} md={9} lg={9}>
  354. <Stack direction="row">
  355. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  356. <OutlinedInput
  357. size="small"
  358. {...register("countryCode",
  359. {
  360. value: currentApplicationDetailData.contactTelNo.countryCode,
  361. })}
  362. id='countryCode'
  363. sx={{
  364. "& .MuiInputBase-input.Mui-disabled": {
  365. WebkitTextFillColor: "#000000",
  366. background: "#f8f8f8",
  367. },
  368. }}
  369. />
  370. </FormControl>
  371. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  372. <OutlinedInput
  373. size="small"
  374. {...register("phoneNumber",
  375. {
  376. value: currentApplicationDetailData.contactTelNo.phoneNumber,
  377. })}
  378. id='phoneNumber'
  379. sx={{
  380. "& .MuiInputBase-input.Mui-disabled": {
  381. WebkitTextFillColor: "#000000",
  382. background: "#f8f8f8",
  383. },
  384. }}
  385. />
  386. </FormControl>
  387. </Stack>
  388. </Grid>
  389. </Grid>
  390. </Grid>
  391. {
  392. fee > 0 ?
  393. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  394. <Grid container alignItems={"center"}>
  395. <Grid item xs={12} md={3} lg={3}
  396. sx={{ display: 'flex', alignItems: 'center' }}>
  397. <FormLabel><Typography variant="h5">價錢:</Typography></FormLabel>
  398. </Grid>
  399. <Grid item xs={12} md={9} lg={9}>
  400. <FormLabel><Typography variant="h5">{FormatUtils.currencyFormat(fee)}</Typography></FormLabel>
  401. </Grid>
  402. </Grid>
  403. </Grid>
  404. :
  405. <></>
  406. }
  407. </Grid>
  408. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  409. <Grid container alignItems={"center"}>
  410. <Grid item xs={12} md={3} lg={3}
  411. sx={{ display: 'flex', alignItems: 'center' }}>
  412. <FormLabel><Typography variant="h5">傳真號碼:</Typography></FormLabel>
  413. </Grid>
  414. <Grid item xs={12} md={9} lg={9}>
  415. <Stack direction="row">
  416. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  417. <OutlinedInput
  418. size="small"
  419. {...register("countryCode",
  420. {
  421. value: currentApplicationDetailData.contactFaxNo.countryCode,
  422. })}
  423. id='countryCode'
  424. sx={{
  425. "& .MuiInputBase-input.Mui-disabled": {
  426. WebkitTextFillColor: "#000000",
  427. background: "#f8f8f8",
  428. },
  429. }}
  430. />
  431. </FormControl>
  432. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  433. <OutlinedInput
  434. size="small"
  435. {...register("faxNumber",
  436. {
  437. value: currentApplicationDetailData.contactFaxNo.faxNumber,
  438. })}
  439. id='faxNumber'
  440. sx={{
  441. "& .MuiInputBase-input.Mui-disabled": {
  442. WebkitTextFillColor: "#000000",
  443. background: "#f8f8f8",
  444. },
  445. }}
  446. />
  447. </FormControl>
  448. </Stack>
  449. </Grid>
  450. </Grid>
  451. </Grid>
  452. <Grid container direction="row" justifyContent="space-between"
  453. alignItems="center">
  454. <Grid item xs={12} md={12} lg={12} mt={1}>
  455. <Grid container alignItems={"center"}>
  456. <Grid item xs={12} md={6} lg={6}>
  457. <Grid container direction="row">
  458. <Grid item xs={12} md={3} lg={3}
  459. sx={{ display: 'flex', alignItems: 'center' }}>
  460. <FormLabel><Typography variant="h5">稿件檔案:</Typography></FormLabel>
  461. </Grid>
  462. <Grid item xs={12} md={9} lg={9} sx={{ display: 'flex', alignItems: 'center' }}>
  463. <Grid container direction="row" justifyContent="flex-start">
  464. <Grid item xs={12} md={8} lg={8} sx={{ display: 'flex', alignItems: 'center' }}>
  465. <FormControl variant="outlined" fullWidth >
  466. <Typography
  467. fullWidth
  468. id='fileName'
  469. variant="h5"
  470. >
  471. {fileDetail.filename}
  472. </Typography>
  473. </FormControl>
  474. </Grid>
  475. <Grid item md={4} lg={4}>
  476. <Button
  477. variant="contained"
  478. onClick={onDownloadClick()}
  479. title="下載"
  480. style={{display:"flex-right"}}
  481. sx={{
  482. textTransform: 'capitalize',
  483. alignItems: 'end',
  484. }}>
  485. <DownloadIcon sx={{mb: 0.5}}/>
  486. <Typography sx={{ml: 1}} variant="h5">下載</Typography>
  487. </Button>
  488. </Grid>
  489. </Grid>
  490. </Grid>
  491. </Grid>
  492. </Grid>
  493. </Grid>
  494. </Grid>
  495. </Grid>
  496. {currentApplicationDetailData.orgId === null ? null:
  497. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
  498. <Grid container alignItems={"center"}>
  499. <Grid item xs={12} md={3} lg={3}
  500. sx={{ display: 'flex', alignItems: 'center' }}>
  501. <FormLabel><Typography variant="h5">Care Of:</Typography></FormLabel>
  502. </Grid>
  503. <Grid item xs={12} md={9} lg={9}>
  504. <Typography variant="h5">{currentApplicationDetailData.careOf}</Typography>
  505. </Grid>
  506. </Grid>
  507. </Grid>
  508. }
  509. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
  510. <Grid container alignItems={"center"}>
  511. <Grid item xs={12} md={3} lg={3}
  512. sx={{ display: 'flex', alignItems: 'center' }}>
  513. <FormLabel><Typography variant="h5">備註:</Typography></FormLabel>
  514. </Grid>
  515. <Grid item xs={12} md={9} lg={9}>
  516. <Typography variant="h5">{currentApplicationDetailData.remarks}</Typography>
  517. </Grid>
  518. </Grid>
  519. </Grid>
  520. </Grid>
  521. </Grid>
  522. <div>
  523. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  524. <DialogTitle></DialogTitle>
  525. <Typography variant="h3" style={{ padding: '16px' }}>確認付款</Typography>
  526. <DialogContent style={{ display: 'flex', }}>
  527. <Stack direction="column" justifyContent="space-between">
  528. <Typography variant="h4">總計金額: {FormatUtils.currencyFormat(fee)}</Typography>
  529. </Stack>
  530. </DialogContent>
  531. <DialogActions>
  532. <Button onClick={() => setIsPopUp(false)}><Typography variant="h5">Close</Typography></Button>
  533. <Button onClick={() => doPayment()}><Typography variant="h5">確認</Typography></Button>
  534. </DialogActions>
  535. </Dialog>
  536. </div>
  537. </form>
  538. </MainCard >
  539. );
  540. };
  541. export default ApplicationDetailCard;