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

549 行
33 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. sx={{
  132. textTransform: 'capitalize',
  133. alignItems: 'end',
  134. backgroundColor: '#ffa733'
  135. }}>
  136. <CloseIcon />
  137. <Typography ml={1} variant="h5"> 取消</Typography>
  138. </Button>
  139. </Stack>
  140. </Grid>
  141. </Grid>
  142. <Typography variant="h4" sx={{ mb: 2, borderBottom: "1px solid black" }}>
  143. 公共啟事申請資料
  144. </Typography>
  145. <form>
  146. <Grid container direction="column">
  147. <Grid item xs={12} md={12}>
  148. <Grid container direction="row" justifyContent="space-between"
  149. alignItems="center">
  150. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  151. <Grid container alignItems={"center"}>
  152. <Grid item xs={12} md={3} lg={3}
  153. sx={{ display: 'flex', alignItems: 'center' }}>
  154. <FormLabel><Typography variant="h5">申請編號:</Typography></FormLabel>
  155. </Grid>
  156. <Grid item xs={12} md={9} lg={9}>
  157. <FormControl variant="outlined" fullWidth disabled>
  158. <OutlinedInput
  159. fullWidth
  160. size="small"
  161. {...register("appNo",
  162. {
  163. value: currentApplicationDetailData.appNo,
  164. })}
  165. id='appNo'
  166. sx={{
  167. "& .MuiInputBase-input.Mui-disabled": {
  168. WebkitTextFillColor: "#000000",
  169. background: "#f8f8f8",
  170. },
  171. }}
  172. />
  173. </FormControl>
  174. </Grid>
  175. </Grid>
  176. </Grid>
  177. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  178. <Grid container alignItems={"center"}>
  179. <Grid item xs={12} md={3} lg={3}
  180. sx={{ display: 'flex', alignItems: 'center' }}>
  181. <FormLabel><Typography variant="h5">申請狀態:</Typography></FormLabel>
  182. </Grid>
  183. <Grid item xs={12} md={4} lg={4}>
  184. <FormControl variant="outlined">
  185. {StatusUtils.getStatusByText(currentApplicationDetailData.status)}
  186. </FormControl>
  187. </Grid>
  188. {
  189. currentApplicationDetailData.reason ?
  190. <Grid item xs={12} md={5} lg={5}>
  191. <Grid container alignItems={"center"}>
  192. <Stack direction="row" justifyContent="flex-start" alignItems="center">
  193. <Grid item xs={12} md={7} lg={7}>
  194. <FormLabel><Typography variant="h5">原因:</Typography></FormLabel>
  195. </Grid>
  196. <Grid item xs={12} md={5} lg={5}>
  197. <FormControl variant="outlined" fullWidth disabled>
  198. <Typography id='reason' variant="h5">
  199. {currentApplicationDetailData.reason}
  200. </Typography>
  201. </FormControl>
  202. </Grid>
  203. </Stack>
  204. </Grid>
  205. </Grid>
  206. : ""
  207. }
  208. </Grid>
  209. </Grid>
  210. </Grid>
  211. <Grid container direction="row" justifyContent="space-between"
  212. alignItems="center">
  213. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  214. <Grid container alignItems={"center"}>
  215. <Grid item xs={12} md={3} lg={3}
  216. sx={{ display: 'flex', alignItems: 'center' }}>
  217. <FormLabel><Typography variant="h5">申請人:</Typography></FormLabel>
  218. </Grid>
  219. <Grid item xs={12} md={9} lg={9}>
  220. <FormControl variant="outlined" fullWidth disabled >
  221. {currentApplicationDetailData.orgId === null ?
  222. <OutlinedInput
  223. fullWidth
  224. size="small"
  225. {...register("contactPerson",
  226. {
  227. value: currentApplicationDetailData.contactPerson,
  228. })}
  229. id='contactPerson'
  230. sx={{
  231. "& .MuiInputBase-input.Mui-disabled": {
  232. WebkitTextFillColor: "#000000",
  233. background: "#f8f8f8",
  234. },
  235. }}
  236. /> :
  237. <OutlinedInput
  238. fullWidth
  239. size="small"
  240. {...register("companyName",
  241. {
  242. value: companyName.enCompanyName,
  243. })}
  244. id='companyName'
  245. sx={{
  246. "& .MuiInputBase-input.Mui-disabled": {
  247. WebkitTextFillColor: "#000000",
  248. background: "#f8f8f8",
  249. },
  250. }}
  251. />
  252. }
  253. </FormControl>
  254. </Grid>
  255. </Grid>
  256. </Grid>
  257. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  258. <Grid container alignItems={"center"}>
  259. <Grid item xs={12} md={3} lg={3}
  260. sx={{ display: 'flex', alignItems: 'center' }}>
  261. <FormLabel><Typography variant="h5">憲報期數:</Typography></FormLabel>
  262. </Grid>
  263. <Grid item xs={12} md={9} lg={9}>
  264. <Stack direction="row">
  265. <FormControl variant="outlined" fullWidth disabled>
  266. <OutlinedInput
  267. size="small"
  268. {...register("issueNum",
  269. {
  270. value: issueNum,
  271. })}
  272. id='issueNum'
  273. sx={{
  274. "& .MuiInputBase-input.Mui-disabled": {
  275. WebkitTextFillColor: "#000000",
  276. background: "#f8f8f8",
  277. },
  278. }}
  279. />
  280. </FormControl>
  281. </Stack>
  282. </Grid>
  283. </Grid>
  284. </Grid>
  285. </Grid>
  286. <Grid container direction="row" justifyContent="space-between"
  287. alignItems="center">
  288. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  289. <Grid container alignItems={"center"}>
  290. <Grid item xs={12} md={3} lg={3}
  291. sx={{ display: 'flex', alignItems: 'center' }}>
  292. <FormLabel><Typography variant="h5">聯絡人:</Typography></FormLabel>
  293. </Grid>
  294. <Grid item xs={12} md={9} lg={9}>
  295. <FormControl variant="outlined" fullWidth disabled>
  296. <OutlinedInput
  297. fullWidth
  298. size="small"
  299. {...register("contactPerson",
  300. {
  301. value: currentApplicationDetailData.contactPerson,
  302. })}
  303. id='contactPerson'
  304. sx={{
  305. "& .MuiInputBase-input.Mui-disabled": {
  306. WebkitTextFillColor: "#000000",
  307. background: "#f8f8f8",
  308. },
  309. }}
  310. />
  311. </FormControl>
  312. </Grid>
  313. </Grid>
  314. </Grid>
  315. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  316. <Grid container alignItems={"center"}>
  317. <Grid item xs={12} md={3} lg={3}
  318. sx={{ display: 'flex', alignItems: 'center' }}>
  319. <FormLabel><Typography variant="h5">發布日期:</Typography></FormLabel>
  320. </Grid>
  321. <Grid item xs={12} md={9} lg={9}>
  322. <Stack direction="row">
  323. <FormControl variant="outlined" fullWidth disabled>
  324. <OutlinedInput
  325. size="small"
  326. {...register("issueDate",
  327. {
  328. value: issueDate,
  329. })}
  330. id='issueDate'
  331. sx={{
  332. "& .MuiInputBase-input.Mui-disabled": {
  333. WebkitTextFillColor: "#000000",
  334. background: "#f8f8f8",
  335. },
  336. }}
  337. />
  338. </FormControl>
  339. </Stack>
  340. </Grid>
  341. </Grid>
  342. </Grid>
  343. </Grid>
  344. <Grid container direction="row" justifyContent="space-between"
  345. alignItems="center">
  346. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  347. <Grid container alignItems={"center"}>
  348. <Grid item xs={12} md={3} lg={3}
  349. sx={{ display: 'flex', alignItems: 'center' }}>
  350. <FormLabel><Typography variant="h5">聯絡電話:</Typography></FormLabel>
  351. </Grid>
  352. <Grid item xs={12} md={9} lg={9}>
  353. <Stack direction="row">
  354. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  355. <OutlinedInput
  356. size="small"
  357. {...register("countryCode",
  358. {
  359. value: currentApplicationDetailData.contactTelNo.countryCode,
  360. })}
  361. id='countryCode'
  362. sx={{
  363. "& .MuiInputBase-input.Mui-disabled": {
  364. WebkitTextFillColor: "#000000",
  365. background: "#f8f8f8",
  366. },
  367. }}
  368. />
  369. </FormControl>
  370. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  371. <OutlinedInput
  372. size="small"
  373. {...register("phoneNumber",
  374. {
  375. value: currentApplicationDetailData.contactTelNo.phoneNumber,
  376. })}
  377. id='phoneNumber'
  378. sx={{
  379. "& .MuiInputBase-input.Mui-disabled": {
  380. WebkitTextFillColor: "#000000",
  381. background: "#f8f8f8",
  382. },
  383. }}
  384. />
  385. </FormControl>
  386. </Stack>
  387. </Grid>
  388. </Grid>
  389. </Grid>
  390. {
  391. fee > 0 ?
  392. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  393. <Grid container alignItems={"center"}>
  394. <Grid item xs={12} md={3} lg={3}
  395. sx={{ display: 'flex', alignItems: 'center' }}>
  396. <FormLabel><Typography variant="h5">價錢:</Typography></FormLabel>
  397. </Grid>
  398. <Grid item xs={12} md={9} lg={9}>
  399. <FormLabel><Typography variant="h5">{FormatUtils.currencyFormat(fee)}</Typography></FormLabel>
  400. </Grid>
  401. </Grid>
  402. </Grid>
  403. :
  404. <></>
  405. }
  406. </Grid>
  407. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  408. <Grid container alignItems={"center"}>
  409. <Grid item xs={12} md={3} lg={3}
  410. sx={{ display: 'flex', alignItems: 'center' }}>
  411. <FormLabel><Typography variant="h5">傳真號碼:</Typography></FormLabel>
  412. </Grid>
  413. <Grid item xs={12} md={9} lg={9}>
  414. <Stack direction="row">
  415. <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
  416. <OutlinedInput
  417. size="small"
  418. {...register("countryCode",
  419. {
  420. value: currentApplicationDetailData.contactFaxNo.countryCode,
  421. })}
  422. id='countryCode'
  423. sx={{
  424. "& .MuiInputBase-input.Mui-disabled": {
  425. WebkitTextFillColor: "#000000",
  426. background: "#f8f8f8",
  427. },
  428. }}
  429. />
  430. </FormControl>
  431. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  432. <OutlinedInput
  433. size="small"
  434. {...register("faxNumber",
  435. {
  436. value: currentApplicationDetailData.contactFaxNo.faxNumber,
  437. })}
  438. id='faxNumber'
  439. sx={{
  440. "& .MuiInputBase-input.Mui-disabled": {
  441. WebkitTextFillColor: "#000000",
  442. background: "#f8f8f8",
  443. },
  444. }}
  445. />
  446. </FormControl>
  447. </Stack>
  448. </Grid>
  449. </Grid>
  450. </Grid>
  451. <Grid container direction="row" justifyContent="space-between"
  452. alignItems="center">
  453. <Grid item xs={12} md={12} lg={12} mt={1}>
  454. <Grid container alignItems={"center"}>
  455. <Grid item xs={12} md={6} lg={6}>
  456. <Grid container direction="row">
  457. <Grid item xs={12} md={3} lg={3}
  458. sx={{ display: 'flex', alignItems: 'center' }}>
  459. <FormLabel><Typography variant="h5">稿件檔案:</Typography></FormLabel>
  460. </Grid>
  461. <Grid item xs={12} md={9} lg={9} sx={{ display: 'flex', alignItems: 'center' }}>
  462. <Grid container direction="row" justifyContent="flex-start">
  463. <Grid item xs={12} md={8} lg={8} sx={{ display: 'flex', alignItems: 'center' }}>
  464. <FormControl variant="outlined" fullWidth >
  465. <Typography
  466. fullWidth
  467. id='fileName'
  468. variant="h5"
  469. >
  470. {fileDetail.filename}
  471. </Typography>
  472. </FormControl>
  473. </Grid>
  474. <Grid item md={4} lg={4}>
  475. <Button
  476. size="small"
  477. variant="contained"
  478. onClick={onDownloadClick()}
  479. title="下載"
  480. style={{display:"flex-right"}}
  481. sx={{
  482. textTransform: 'capitalize',
  483. alignItems: 'end',
  484. }}>
  485. <DownloadIcon />
  486. </Button>
  487. </Grid>
  488. </Grid>
  489. </Grid>
  490. </Grid>
  491. </Grid>
  492. </Grid>
  493. </Grid>
  494. </Grid>
  495. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
  496. <Grid container alignItems={"center"}>
  497. <Grid item xs={12} md={3} lg={3}
  498. sx={{ display: 'flex', alignItems: 'center' }}>
  499. <FormLabel><Typography variant="h5">備註:</Typography></FormLabel>
  500. </Grid>
  501. <Grid item xs={12} md={9} lg={9}>
  502. <Typography variant="h5">{currentApplicationDetailData.remarks}</Typography>
  503. </Grid>
  504. </Grid>
  505. </Grid>
  506. </Grid>
  507. </Grid>
  508. <div>
  509. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  510. <DialogTitle></DialogTitle>
  511. <Typography variant="h3" style={{ padding: '16px' }}>確認付款</Typography>
  512. <DialogContent style={{ display: 'flex', }}>
  513. <Stack direction="column" justifyContent="space-between">
  514. <Typography variant="h4">總計金額: {FormatUtils.currencyFormat(fee)}</Typography>
  515. </Stack>
  516. </DialogContent>
  517. <DialogActions>
  518. <Button onClick={() => setIsPopUp(false)}><Typography variant="h5">Close</Typography></Button>
  519. <Button onClick={() => doPayment()}><Typography variant="h5">確認</Typography></Button>
  520. </DialogActions>
  521. </Dialog>
  522. </div>
  523. </form>
  524. </MainCard >
  525. );
  526. };
  527. export default ApplicationDetailCard;