Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

201 lignes
8.6 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Tab,
  6. Box,
  7. Button,
  8. Stack
  9. } from '@mui/material';
  10. import { TabPanel, TabContext, TabList } from '@mui/lab';
  11. import { useEffect, useState } from "react";
  12. import { useNavigate } from "react-router-dom";
  13. import * as React from "react";
  14. import * as HttpUtils from "../../../utils/HttpUtils";
  15. import * as UrlUtils from "../../../utils/ApiPathConst";
  16. import Loadable from 'components/Loadable';
  17. import { lazy } from 'react';
  18. const BaseGrid = Loadable(lazy(() => import('./BaseGrid')));
  19. const PendingPaymentTab = Loadable(lazy(() => import('./PendingPaymentTab')));
  20. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  21. const SearchTab = Loadable(lazy(() => import('./SearchPublicNoticeTab')));
  22. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  23. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  24. const PublicNotice = () => {
  25. const [submittedList, setSubmittedList] = useState([]);
  26. const [inProgressList, setInProgressList] = useState([]);
  27. const [pendingPaymentList, setPendingPaymentList] = useState([]);
  28. const [pendingPublishList, setPendingPublishList] = useState([]);
  29. const [isLoading, setLoding] = useState(true);
  30. const [selectedTab, setSelectedTab] = useState("1");
  31. const navigate = useNavigate();
  32. const BackgroundHead = {
  33. backgroundImage: `url(${titleBackgroundImg})`,
  34. width: '100%',
  35. height: '100%',
  36. backgroundSize:'contain',
  37. backgroundRepeat: 'no-repeat',
  38. backgroundColor: '#0C489E',
  39. backgroundPosition: 'right'
  40. }
  41. useEffect(() => {
  42. loadData();
  43. }, []);
  44. const reloadPage = () => {
  45. window.location.reload(false);
  46. }
  47. const loadData = () => {
  48. setLoding(true);
  49. HttpUtils.get({
  50. url: `${UrlUtils.GET_PUBLIC_NOTICE_LIST_ListByStatus}`,
  51. onSuccess: function (response) {
  52. setSubmittedList(response["submitted"]);
  53. setInProgressList(response["inProgress"]);
  54. setPendingPaymentList(response["pendingPayment"]);
  55. setPendingPublishList(response["pendingPublish"]);
  56. }
  57. });
  58. };
  59. useEffect(() => {
  60. setLoding(false);
  61. }, [submittedList]);
  62. const handleChange = (event, newValue) => {
  63. setSelectedTab(newValue);
  64. }
  65. const onBtnClick = () => {
  66. navigate('/publicNotice/apply')
  67. }
  68. return (
  69. isLoading ?
  70. <LoadingComponent />
  71. :
  72. <Grid container >
  73. <Grid item xs={12}>
  74. <div style={BackgroundHead}>
  75. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  76. <Typography ml={15} color='#FFF' variant="h4">我的公共啟事</Typography>
  77. </Stack>
  78. </div>
  79. </Grid>
  80. <Grid item xs={12} mt={1} >
  81. <Stack direction="row" justifyContent="flex-end" alignItems="center">
  82. <Box sx={{ mr: { md: "47px" } }}>
  83. <Button variant="contained" onClick={() => { onBtnClick() }}>申請公共啟事</Button>
  84. </Box>
  85. </Stack>
  86. </Grid>
  87. {/*col 2*/}
  88. {
  89. JSON.parse(localStorage.getItem('userData')).creditor ? (
  90. <Grid item xs={12} sx={{ minHeight: '75vh' }}>
  91. <TabContext value={selectedTab}>
  92. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  93. <TabList onChange={handleChange} aria-label="lab API tabs example">
  94. <Tab label={"已提交(" + submittedList?.length + ")"} value="1" />
  95. <Tab label={"處理中(" + inProgressList?.length + ")"} value="2" />
  96. <Tab label={"待發佈(" + pendingPublishList?.length + ")"} value="3" />
  97. <Tab label={"待付款(" + pendingPaymentList?.length + ")"} value="4" />
  98. <Tab label="搜尋申請記錄" value="5" />
  99. </TabList>
  100. </Box>
  101. <TabPanel value="1">
  102. <BaseGrid
  103. rows={submittedList}
  104. reloadFunction={reloadPage}
  105. />
  106. </TabPanel>
  107. <TabPanel value="2">
  108. <BaseGrid
  109. rows={inProgressList}
  110. reloadFunction={reloadPage}
  111. />
  112. </TabPanel>
  113. <TabPanel value="3">
  114. <BaseGrid
  115. rows={pendingPublishList}
  116. reloadFunction={reloadPage}
  117. />
  118. </TabPanel>
  119. <TabPanel value="4">
  120. <BaseGrid
  121. rows={pendingPaymentList}
  122. reloadFunction={reloadPage}
  123. />
  124. </TabPanel>
  125. <TabPanel value="5">
  126. <SearchTab
  127. rows={pendingPublishList}
  128. reloadFunction={reloadPage}
  129. />
  130. </TabPanel>
  131. </TabContext>
  132. </Grid>
  133. ) : (
  134. <Grid item xs={12} sx={{ minHeight: '75vh' }}>
  135. <TabContext value={selectedTab}>
  136. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  137. <TabList onChange={handleChange} aria-label="lab API tabs example">
  138. <Tab label={"已提交(" + submittedList.length + ")"} value="1" />
  139. <Tab label={"處理中(" + inProgressList.length + ")"} value="2" />
  140. <Tab label={"待付款(" + pendingPaymentList.length + ")"} value="3" />
  141. <Tab label={"待發佈(" + pendingPublishList.length + ")"} value="4" />
  142. <Tab label="搜尋申請記錄" value="5" />
  143. </TabList>
  144. </Box>
  145. <TabPanel value="1">
  146. <BaseGrid
  147. rows={submittedList}
  148. reloadFunction={reloadPage}
  149. />
  150. </TabPanel>
  151. <TabPanel value="2">
  152. <BaseGrid
  153. rows={inProgressList}
  154. reloadFunction={reloadPage}
  155. />
  156. </TabPanel>
  157. <TabPanel value="3">
  158. <PendingPaymentTab
  159. rows={pendingPaymentList}
  160. reloadFunction={reloadPage}
  161. />
  162. </TabPanel>
  163. <TabPanel value="4">
  164. <BaseGrid
  165. rows={pendingPublishList}
  166. reloadFunction={reloadPage}
  167. />
  168. </TabPanel>
  169. <TabPanel value="5">
  170. <SearchTab
  171. rows={pendingPublishList}
  172. reloadFunction={reloadPage}
  173. />
  174. </TabPanel>
  175. </TabContext>
  176. </Grid>
  177. )
  178. }
  179. </Grid>
  180. );
  181. };
  182. export default PublicNotice;