Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

398 rindas
22 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. // InputAdornment,
  7. Typography, FormLabel,
  8. OutlinedInput,
  9. Stack
  10. } from '@mui/material';
  11. // import MainCard from "../../components/MainCard";
  12. const MainCard = Loadable(lazy(() => import('components/MainCard')));
  13. import {useForm} from "react-hook-form";
  14. import {
  15. useEffect,
  16. useState
  17. } from "react";
  18. // import Checkbox from "@mui/material/Checkbox";
  19. import Loadable from 'components/Loadable';
  20. import { lazy } from 'react';
  21. const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent')));
  22. // import {useParams} from "react-router-dom";
  23. import * as HttpUtils from "utils/HttpUtils"
  24. import * as StatusUtils from "../PublicNotice/ListPanel/PublicNoteStatusUtils";
  25. import * as DateUtils from "utils/DateUtils";
  26. // import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined';
  27. // import DoneIcon from '@mui/icons-material/Done';
  28. import CloseIcon from '@mui/icons-material/Close';
  29. import EditNoteIcon from '@mui/icons-material/EditNote';
  30. import DownloadIcon from '@mui/icons-material/Download';
  31. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  32. const ApplicationDetailCard = (
  33. { applicationDetailData,
  34. setStatus,
  35. // updateUserObject,
  36. // isNewRecord
  37. }
  38. ) => {
  39. // const params = useParams();
  40. const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
  41. const [companyName, setCompanyName] = useState({});
  42. const [fileDetail, setfileDetail] = useState({});
  43. const [onReady,setOnReady] = useState(false);
  44. const [issueNum,setIssueNum] = useState("");
  45. const [issueDate,setIssueDate] = useState("");
  46. const {register,
  47. // getValues
  48. } = useForm()
  49. useEffect(() => {
  50. //if user data from parent are not null
  51. // console.log(applicationDetailData)
  52. if (Object.keys(applicationDetailData).length > 0 &&applicationDetailData.data!==null) {
  53. setCurrentApplicationDetailData(applicationDetailData.data);
  54. setCompanyName(applicationDetailData.companyName);
  55. setfileDetail(applicationDetailData.fileDetail);
  56. setIssueNum(applicationDetailData.gazetteIssueDetail.volume+"/"+applicationDetailData.gazetteIssueDetail.year
  57. +" No. "+applicationDetailData.gazetteIssueDetail.issueNo);
  58. setIssueDate(DateUtils.dateFormat(applicationDetailData.gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
  59. }
  60. }, [applicationDetailData]);
  61. useEffect(() => {
  62. //if state data are ready and assign to different field
  63. // console.log(currentApplicationDetailData)
  64. if (Object.keys(currentApplicationDetailData).length > 0) {
  65. setOnReady(true);
  66. }
  67. }, [currentApplicationDetailData]);
  68. const onDownloadClick = () => () => {
  69. HttpUtils.fileDownload({
  70. fileId:fileDetail.id,
  71. skey:fileDetail.skey,
  72. filename:fileDetail.filename,
  73. });
  74. };
  75. const cancelledClick = () => () =>{
  76. setStatus("cancel")
  77. };
  78. return (
  79. !onReady ?
  80. <LoadingComponent/>
  81. :
  82. <MainCard elevation={0}
  83. border={false}
  84. content={false}
  85. >
  86. <Grid container spacing={1} direction="row">
  87. <Grid item xs={12}>
  88. <Stack
  89. direction="row"
  90. justifyContent="space-between"
  91. alignItems="center"
  92. spacing={2}
  93. mb={2}
  94. >
  95. <Button
  96. // size="large"
  97. variant="contained"
  98. // onClick={handleNewUserClick}
  99. disabled= {currentApplicationDetailData.status =="rejected"||currentApplicationDetailData.status =="cancelled"||currentApplicationDetailData.status =="paid"}
  100. sx={{
  101. textTransform: 'capitalize',
  102. alignItems: 'end'
  103. }}>
  104. <EditNoteIcon/>
  105. <Typography ml={1}> 支付</Typography>
  106. </Button>
  107. <Button
  108. // size="large"
  109. variant="contained"
  110. onClick={cancelledClick()}
  111. disabled= {currentApplicationDetailData.status !=="submitted"}
  112. sx={{
  113. textTransform: 'capitalize',
  114. alignItems: 'end',
  115. backgroundColor:'#ffa733'
  116. }}>
  117. <CloseIcon/>
  118. <Typography ml={1}> 取消</Typography>
  119. </Button>
  120. </Stack>
  121. </Grid>
  122. </Grid>
  123. <Typography variant="h5" sx={{mb: 2, borderBottom: "1px solid black"}}>
  124. 公共啟事申請資料
  125. </Typography>
  126. <form>
  127. <Grid container direction="column">
  128. <Grid item xs={12} md={12}>
  129. <Grid container direction="row" justifyContent="space-between"
  130. alignItems="center">
  131. <Grid item xs={12} md={6} lg={6} sx={{mb: 1}}>
  132. <Grid container alignItems={"center"}>
  133. <Grid item xs={12} md={3} lg={3}
  134. sx={{display: 'flex', alignItems: 'center'}}>
  135. <FormLabel>申請編號:</FormLabel>
  136. </Grid>
  137. <Grid item xs={12} md={9} lg={9}>
  138. <FormControl variant="outlined" fullWidth disabled>
  139. <OutlinedInput
  140. fullWidth
  141. size="small"
  142. {...register("appNo",
  143. {
  144. value: currentApplicationDetailData.appNo,
  145. })}
  146. id='appNo'
  147. />
  148. </FormControl>
  149. </Grid>
  150. </Grid>
  151. </Grid>
  152. <Grid item xs={12} md={5} lg={5} sx={{mb: 1, ml:1}}>
  153. <Grid container alignItems={"center"}>
  154. <Grid item xs={12} md={3} lg={3}
  155. sx={{display: 'flex', alignItems: 'center'}}>
  156. <FormLabel>申請狀態:</FormLabel>
  157. </Grid>
  158. <Grid item xs={12} md={9} lg={9}>
  159. <FormControl variant="outlined" fullWidth >
  160. {StatusUtils.getStatusByText(currentApplicationDetailData.status)}
  161. </FormControl>
  162. </Grid>
  163. </Grid>
  164. </Grid>
  165. </Grid>
  166. <Grid container direction="row" justifyContent="space-between"
  167. alignItems="center">
  168. <Grid item xs={12} md={6} lg={6} sx={{mb: 1}}>
  169. <Grid container alignItems={"center"}>
  170. <Grid item xs={12} md={3} lg={3}
  171. sx={{display: 'flex', alignItems: 'center'}}>
  172. <FormLabel>申請人:</FormLabel>
  173. </Grid>
  174. <Grid item xs={12} md={9} lg={9}>
  175. <FormControl variant="outlined" fullWidth disabled >
  176. { currentApplicationDetailData.orgId===null?
  177. <OutlinedInput
  178. fullWidth
  179. size="small"
  180. {...register("contactPerson",
  181. {
  182. value: currentApplicationDetailData.contactPerson,
  183. })}
  184. id='contactPerson'
  185. />:
  186. <OutlinedInput
  187. fullWidth
  188. size="small"
  189. {...register("companyName",
  190. {
  191. value: companyName.enCompanyName,
  192. })}
  193. id='companyName'
  194. />
  195. }
  196. </FormControl>
  197. </Grid>
  198. </Grid>
  199. </Grid>
  200. <Grid item xs={12} md={5} lg={5} sx={{mb: 1, ml:1}}>
  201. <Grid container alignItems={"center"}>
  202. <Grid item xs={12} md={3} lg={3}
  203. sx={{display: 'flex', alignItems: 'center'}}>
  204. <FormLabel>憲報期數:</FormLabel>
  205. </Grid>
  206. <Grid item xs={12} md={9} lg={9}>
  207. <Stack direction="row">
  208. <FormControl variant="outlined" fullWidth disabled>
  209. <OutlinedInput
  210. size="small"
  211. {...register("issueNum",
  212. {
  213. value: issueNum,
  214. })}
  215. id='issueNum'
  216. />
  217. </FormControl>
  218. </Stack>
  219. </Grid>
  220. </Grid>
  221. </Grid>
  222. </Grid>
  223. <Grid container direction="row" justifyContent="space-between"
  224. alignItems="center">
  225. <Grid item xs={12} md={6} lg={6} sx={{mb: 1}}>
  226. <Grid container alignItems={"center"}>
  227. <Grid item xs={12} md={3} lg={3}
  228. sx={{display: 'flex', alignItems: 'center'}}>
  229. <FormLabel>聯絡人:</FormLabel>
  230. </Grid>
  231. <Grid item xs={12} md={9} lg={9}>
  232. <FormControl variant="outlined" fullWidth disabled>
  233. <OutlinedInput
  234. fullWidth
  235. size="small"
  236. {...register("contactPerson",
  237. {
  238. value: currentApplicationDetailData.contactPerson,
  239. })}
  240. id='contactPerson'
  241. />
  242. </FormControl>
  243. </Grid>
  244. </Grid>
  245. </Grid>
  246. <Grid item xs={12} md={5} lg={5} sx={{mb: 1, ml:1}}>
  247. <Grid container alignItems={"center"}>
  248. <Grid item xs={12} md={3} lg={3}
  249. sx={{display: 'flex', alignItems: 'center'}}>
  250. <FormLabel>發布日期:</FormLabel>
  251. </Grid>
  252. <Grid item xs={12} md={9} lg={9}>
  253. <Stack direction="row">
  254. <FormControl variant="outlined" fullWidth disabled>
  255. <OutlinedInput
  256. size="small"
  257. {...register("issueDate",
  258. {
  259. value: issueDate,
  260. })}
  261. id='issueDate'
  262. />
  263. </FormControl>
  264. </Stack>
  265. </Grid>
  266. </Grid>
  267. </Grid>
  268. </Grid>
  269. <Grid item xs={12} md={6} lg={6} sx={{mb: 1,}}>
  270. <Grid container alignItems={"center"}>
  271. <Grid item xs={12} md={3} lg={3}
  272. sx={{display: 'flex', alignItems: 'center'}}>
  273. <FormLabel>聯絡電話:</FormLabel>
  274. </Grid>
  275. <Grid item xs={12} md={9} lg={9}>
  276. <Stack direction="row">
  277. <FormControl variant="outlined" sx={{width:'25%'}} disabled>
  278. <OutlinedInput
  279. size="small"
  280. {...register("countryCode",
  281. {
  282. value: currentApplicationDetailData.contactTelNo.countryCode,
  283. })}
  284. id='countryCode'
  285. />
  286. </FormControl>
  287. <FormControl variant="outlined" sx={{width:'100%'}} disabled>
  288. <OutlinedInput
  289. size="small"
  290. {...register("phoneNumber",
  291. {
  292. value: currentApplicationDetailData.contactTelNo.phoneNumber,
  293. })}
  294. id='phoneNumber'
  295. />
  296. </FormControl>
  297. </Stack>
  298. </Grid>
  299. </Grid>
  300. </Grid>
  301. <Grid item xs={12} md={6} lg={6} sx={{mb: 1,}}>
  302. <Grid container alignItems={"center"}>
  303. <Grid item xs={12} md={3} lg={3}
  304. sx={{display: 'flex', alignItems: 'center'}}>
  305. <FormLabel>傳真號碼:</FormLabel>
  306. </Grid>
  307. <Grid item xs={12} md={9} lg={9}>
  308. <Stack direction="row">
  309. <FormControl variant="outlined" sx={{width:'25%'}} disabled>
  310. <OutlinedInput
  311. size="small"
  312. {...register("countryCode",
  313. {
  314. value: currentApplicationDetailData.contactFaxNo.countryCode,
  315. })}
  316. id='countryCode'
  317. />
  318. </FormControl>
  319. <FormControl variant="outlined" sx={{width:'100%'}} disabled>
  320. <OutlinedInput
  321. size="small"
  322. {...register("faxNumber",
  323. {
  324. value: currentApplicationDetailData.contactFaxNo.faxNumber,
  325. })}
  326. id='faxNumber'
  327. />
  328. </FormControl>
  329. </Stack>
  330. </Grid>
  331. </Grid>
  332. </Grid>
  333. <Grid container direction="row" justifyContent="space-between"
  334. alignItems="center">
  335. <Grid item xs={12} md={12} lg={12} mt={1}>
  336. <Grid container alignItems={"center"}>
  337. <Grid item xs={12} md={6} lg={6}>
  338. <Grid container direction="row">
  339. <Grid item xs={12} md={3} lg={3}
  340. sx={{display: 'flex', alignItems: 'center'}}>
  341. <FormLabel>犒件檔案:</FormLabel>
  342. </Grid>
  343. <Grid item xs={12} md={9} lg={9} sx={{display: 'flex', alignItems: 'center'}}>
  344. <Grid container direction="row" justifyContent="flex-start">
  345. <Grid item xs={12} md={5} lg={5} sx={{display: 'flex', alignItems: 'center'}}>
  346. <FormControl variant="outlined" fullWidth >
  347. <Typography
  348. fullWidth
  349. id='fileName'
  350. >
  351. {fileDetail.filename}
  352. </Typography>
  353. </FormControl>
  354. </Grid>
  355. <Grid item md={2} lg={2}>
  356. <Button
  357. size="small"
  358. variant="contained"
  359. onClick={onDownloadClick()}
  360. sx={{
  361. textTransform: 'capitalize',
  362. alignItems: 'end',
  363. }}>
  364. <DownloadIcon/>
  365. </Button>
  366. </Grid>
  367. </Grid>
  368. </Grid>
  369. </Grid>
  370. </Grid>
  371. </Grid>
  372. </Grid>
  373. </Grid>
  374. </Grid>
  375. </Grid>
  376. </form>
  377. </MainCard>
  378. );
  379. };
  380. export default ApplicationDetailCard;