Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

403 строки
19 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Grid,
  5. Typography,
  6. FormLabel,
  7. TextField,
  8. Button,
  9. Stack,
  10. Dialog, DialogTitle, DialogContent, DialogActions,
  11. CircularProgress,
  12. } from '@mui/material';
  13. import { useFormik } from 'formik';
  14. import { useIntl } from 'react-intl';
  15. import {isGranted} from "auth/utils";
  16. import {useState, useEffect, useRef, lazy} from "react";
  17. import * as HttpUtils from "utils/HttpUtils"
  18. import * as UrlUtils from "utils/ApiPathConst"
  19. import * as DateUtils from "utils/DateUtils"
  20. import * as FormatUtils from "utils/FormatUtils"
  21. import { useParams } from "react-router-dom";
  22. import Loadable from 'components/Loadable';
  23. const MainCard = Loadable(lazy(() => import('components/MainCard')));
  24. import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
  25. import FileList from "components/FileList"
  26. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  27. const ApplicationDetailCard = ({
  28. formData,
  29. showCancelBtn,
  30. showProofBtn
  31. // setBackButtonPos
  32. }) => {
  33. const params = useParams();
  34. const intl = useIntl();
  35. const [data, setData] = useState({});
  36. const [cancelPopUp, setCancelPopUp] = useState(false);
  37. const [cancelLoading, setCancelLoading] = useState(false);
  38. const cancellingRef = useRef(false);
  39. const [onDownload, setOnDownload] = useState(false);
  40. const [alertMsg, setAlertMsg] = useState('');
  41. const [showAlert, setShowAlert] = useState(false);
  42. useEffect(() => {
  43. if (formData) {
  44. setData(formData);
  45. }
  46. }, [formData]);
  47. const formik = useFormik({
  48. enableReinitialize: true,
  49. initialValues: data,
  50. });
  51. const DisplayField = ({ name, width, dummyUser }) => {
  52. return <>
  53. {dummyUser?
  54. <TextField
  55. fullWidth
  56. disabled
  57. size="small"
  58. onChange={formik.handleChange}
  59. id={name}
  60. name={name}
  61. value={"GLD: "+formik.values[name]}
  62. variant="outlined"
  63. sx={
  64. {
  65. "& .MuiInputBase-input.Mui-disabled": {
  66. WebkitTextFillColor: "#000000",
  67. background: "#f8f8f8",
  68. },
  69. width: width ? width : '100%'
  70. }
  71. }
  72. />
  73. :
  74. <TextField
  75. fullWidth
  76. disabled
  77. size="small"
  78. onChange={formik.handleChange}
  79. id={name}
  80. name={name}
  81. value={formik.values[name]}
  82. variant="outlined"
  83. sx={
  84. {
  85. "& .MuiInputBase-input.Mui-disabled": {
  86. WebkitTextFillColor: "#000000",
  87. background: "#f8f8f8",
  88. },
  89. width: width ? width : '100%'
  90. }
  91. }
  92. />
  93. }
  94. </>
  95. }
  96. const confirmCancel = () => {
  97. if (cancellingRef.current) return;
  98. cancellingRef.current = true;
  99. setCancelLoading(true);
  100. HttpUtils.get({
  101. url: UrlUtils.CANCEL_PROOF + "/" + params.id,
  102. onSuccess: function (responseData) {
  103. cancellingRef.current = false;
  104. setCancelLoading(false);
  105. if (responseData && responseData.success === false) {
  106. setCancelPopUp(false);
  107. const msg = responseData.msg ? intl.formatMessage({ id: responseData.msg }) : intl.formatMessage({ id: 'proofAlreadyCancelled' });
  108. setAlertMsg(msg);
  109. setShowAlert(true);
  110. } else {
  111. window.location.reload(false);
  112. }
  113. },
  114. onFail: () => {
  115. cancellingRef.current = false;
  116. setCancelLoading(false);
  117. },
  118. onError: () => {
  119. cancellingRef.current = false;
  120. setCancelLoading(false);
  121. }
  122. });
  123. }
  124. const doCancel = () => {
  125. setCancelPopUp(true);
  126. }
  127. const genProof = () => {
  128. setOnDownload(true)
  129. HttpUtils.fileDownload({
  130. url: UrlUtils.GEN_GAZETTE_PROOF + "/" + params.id,
  131. onResponse:()=>{
  132. setOnDownload(false)
  133. },
  134. onError:()=>{
  135. setOnDownload(false)
  136. }
  137. });
  138. }
  139. return (
  140. <MainCard
  141. id={"applicationDetailsMainCard"}
  142. border={false}
  143. content={false}
  144. >
  145. <Typography variant="h4" sx={{ textAlign: "left", mb: 2, borderBottom: "1px solid black" }}>
  146. <Stack
  147. direction="row"
  148. justifyContent="space-between"
  149. alignItems="center"
  150. >
  151. Public Notice: Proofreading Reply
  152. {data.appMode != "offline"?
  153. <>
  154. <Button
  155. component="span"
  156. variant="contained"
  157. size="large"
  158. disabled={!showProofBtn||onDownload}
  159. onClick={genProof}
  160. >
  161. <Typography variant="h5">Proof Slip</Typography>
  162. </Button>
  163. {
  164. isGranted(["MAINTAIN_PROOF"]) ? <Button
  165. component="span"
  166. variant="contained"
  167. size="large"
  168. color="error"
  169. disabled={showCancelBtn}
  170. onClick={doCancel}
  171. >
  172. <Typography variant="h5">Cancel</Typography>
  173. </Button> : <></>
  174. }
  175. </>
  176. :null
  177. }
  178. </Stack>
  179. </Typography>
  180. <form>
  181. <Grid container direction="column">
  182. <Grid item xs={12} md={12} lg={12}>
  183. <Grid container direction="row" justifyContent="space-between"
  184. alignItems="center">
  185. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  186. <Grid container alignItems={"center"}>
  187. <Grid item xs={12} md={3} lg={3}
  188. sx={{ display: 'flex', alignItems: 'center' }}>
  189. <FormLabel><Typography variant="h5">App. No.:</Typography></FormLabel>
  190. </Grid>
  191. <Grid item xs={12} md={9} lg={9}>
  192. <DisplayField name="appNo" />
  193. </Grid>
  194. </Grid>
  195. </Grid>
  196. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  197. <Grid container alignItems={"left"}>
  198. <Grid item xs={12} md={3} lg={3}
  199. sx={{ display: 'flex', alignItems: 'center' }}>
  200. <FormLabel><Typography variant="h5">App. Status:</Typography></FormLabel>
  201. </Grid>
  202. <Grid item xs={12} md={9} lg={9} sx={{ display: 'flex', alignItems: 'center' }}>
  203. <FormControl variant="outlined">
  204. {StatusUtils.getStatusByTextEng(data.appStatus, data.creditor)}
  205. </FormControl>
  206. </Grid>
  207. </Grid>
  208. </Grid>
  209. </Grid>
  210. <Grid container direction="row" justifyContent="space-between"
  211. alignItems="center">
  212. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  213. <Grid container alignItems={"center"}>
  214. <Grid item xs={12} md={3} lg={3}
  215. sx={{ display: 'flex', alignItems: 'center' }}>
  216. <FormLabel><Typography variant="h5">Applicant:</Typography></FormLabel>
  217. </Grid>
  218. <Grid item xs={12} md={9} lg={9}>
  219. <FormControl variant="outlined" fullWidth disabled >
  220. {data?.orgId?
  221. <DisplayField
  222. name="applicant"
  223. dummyUser={data?.enCompanyName == "GLD" ? true : false}/>
  224. :
  225. <DisplayField name="contactPerson" />
  226. }
  227. </FormControl>
  228. </Grid>
  229. </Grid>
  230. </Grid>
  231. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  232. <Grid container alignItems={"center"}>
  233. <Grid item xs={12} md={3} lg={3}
  234. sx={{ display: 'flex', alignItems: 'center' }}>
  235. <FormLabel><Typography variant="h5">Issue No:</Typography></FormLabel>
  236. </Grid>
  237. <Grid item xs={12} md={9} lg={9}>
  238. <DisplayField name="issueNoStr" />
  239. </Grid>
  240. </Grid>
  241. </Grid>
  242. </Grid>
  243. <Grid container direction="row" justifyContent="space-between"
  244. alignItems="center">
  245. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  246. <Grid container alignItems={"center"}>
  247. <Grid item xs={12} md={3} lg={3}
  248. sx={{ display: 'flex', alignItems: 'center' }}>
  249. <FormLabel><Typography variant="h5">Contact Person:</Typography></FormLabel>
  250. </Grid>
  251. <Grid item xs={12} md={9} lg={9}>
  252. <DisplayField name="contactPerson" />
  253. </Grid>
  254. </Grid>
  255. </Grid>
  256. <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
  257. <Grid container alignItems={"center"}>
  258. <Grid item xs={12} md={3} lg={3}
  259. sx={{ display: 'flex', alignItems: 'center' }}>
  260. <FormLabel><Typography variant="h5">Issue Date:</Typography></FormLabel>
  261. </Grid>
  262. <Grid item xs={12} md={9} lg={9}>
  263. <DisplayField name="issueDateStr" />
  264. </Grid>
  265. </Grid>
  266. </Grid>
  267. </Grid>
  268. {/* <Grid container direction="row" justifyContent="space-between"
  269. alignItems="center">
  270. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  271. <Grid container alignItems="left">
  272. <Grid item xs={12} md={3} lg={3}
  273. sx={{ display: 'flex', alignItems: 'center' }}>
  274. <FormLabel>Remarks:</FormLabel>
  275. </Grid>
  276. <Grid item xs={12} md={9} lg={9}>
  277. <Stack direction="row">
  278. <DisplayField name="appRemarks" />
  279. </Stack>
  280. </Grid>
  281. </Grid>
  282. </Grid>
  283. </Grid> */}
  284. <Grid container direction="row" justifyContent="space-between"
  285. alignItems="center">
  286. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
  287. <Grid container alignItems={"center"}>
  288. <Grid item xs={12} md={12} lg={12} sx={{ display: 'flex', alignItems: 'center' }}>
  289. <Typography variant="h5">Print file:</Typography>
  290. </Grid>
  291. </Grid>
  292. <FileList
  293. refId={params.id}
  294. refType={"proof"}
  295. dateHideable={true}
  296. disablePagination
  297. disableSelectionOnClick
  298. disableColumnMenu
  299. disableColumnSelector
  300. hideFooter
  301. />
  302. </Grid>
  303. <Grid item xs={12} md={4} lg={4} sx={{ mb: 1, }}>
  304. <Grid container alignItems={"center"}>
  305. <Grid item xs={12} md={12} lg={12}
  306. sx={{ display: 'flex', alignItems: 'center' }}>
  307. <Typography variant="h5">Deadline for proof with revision:</Typography>
  308. </Grid>
  309. <Grid item xs={12} md={12} lg={12} sx={{ mb: 4, display: 'flex', alignItems: 'center' }}>
  310. <Typography variant="h5">Before {DateUtils.datetimeStr(data.reviseDeadline)}</Typography>
  311. </Grid>
  312. <Grid item xs={12} md={12} lg={12}
  313. sx={{ display: 'flex', alignItems: 'center' }}>
  314. <Typography variant="h5">Deadline for confirm proof and payment:</Typography>
  315. </Grid>
  316. <Grid item xs={12} md={12} lg={12} sx={{ mb: 4, display: 'flex', alignItems: 'center' }}>
  317. <Typography variant="h5">Before {DateUtils.datetimeStr(data.proofPaymentDeadline)}</Typography>
  318. </Grid>
  319. <Grid item xs={12} md={3} lg={3}
  320. sx={{ mb: 1, display: 'flex', alignItems: 'center' }}>
  321. <Typography variant="h5">Fee:</Typography>
  322. </Grid>
  323. <Grid item xs={12} md={9} lg={9} sx={{ mb: 1, display: 'flex', alignItems: 'center' }}>
  324. <Typography variant="h5" style={{ color: "blue", fontWeight: "bold", }}>{FormatUtils.currencyFormat(data.fee)}</Typography>
  325. </Grid>
  326. <Grid item xs={12} md={12} lg={12} sx={{ mb: 4, display: 'flex', alignItems: 'center' }}>
  327. {
  328. formik.values.groupType == "Private Bill"
  329. ?
  330. <Typography variant="h5">( {data.noOfPages} {data.noOfPages === 1 ? 'page' : 'pages'} x $6,552 )</Typography>
  331. :
  332. <Typography variant="h5">( {data.length} cm x {data.colCount == 2 ? "$364 Double Column" : "$182 Single Column"} )</Typography>
  333. }
  334. </Grid>
  335. </Grid>
  336. </Grid>
  337. </Grid>
  338. </Grid>
  339. </Grid>
  340. <div>
  341. <Dialog
  342. open={cancelPopUp}
  343. onClose={() => {
  344. if (cancelLoading) return;
  345. setCancelPopUp(false);
  346. }}
  347. >
  348. <DialogTitle><Typography variant="h3">Confirm</Typography></DialogTitle>
  349. <DialogContent style={{ display: 'flex', }}>
  350. <Typography variant="h4" style={{ padding: '16px' }}>Are you sure you want to cancel this proof?</Typography>
  351. </DialogContent>
  352. <DialogActions>
  353. <Button onClick={() => setCancelPopUp(false)} disabled={cancelLoading}><Typography variant="h5">Cancel</Typography></Button>
  354. <Button
  355. onClick={() => confirmCancel()}
  356. disabled={cancelLoading}
  357. startIcon={cancelLoading ? <CircularProgress color="inherit" size={20} /> : null}
  358. >
  359. <Typography variant="h5">Confirm</Typography>
  360. </Button>
  361. </DialogActions>
  362. </Dialog>
  363. <Dialog open={showAlert} onClose={() => setShowAlert(false)}>
  364. <DialogTitle><Typography variant="h3">{intl.formatMessage({ id: 'attention' })}</Typography></DialogTitle>
  365. <DialogContent>
  366. <Typography variant="h4" style={{ padding: '16px' }}>{alertMsg}</Typography>
  367. </DialogContent>
  368. <DialogActions>
  369. <Button onClick={() => setShowAlert(false)}><Typography variant="h5">OK</Typography></Button>
  370. </DialogActions>
  371. </Dialog>
  372. </div>
  373. </form>
  374. </MainCard>
  375. );
  376. };
  377. export default ApplicationDetailCard;