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

136 строки
5.0 KiB

  1. // material-ui
  2. import {
  3. Grid, Typography
  4. } from '@mui/material';
  5. import MainCard from "../../../components/MainCard";
  6. import {useEffect, useState} from "react";
  7. import axios from "axios";
  8. import {apiPath} from "../../../auth/utils";
  9. import {
  10. // GET_DIVISION_FROM_SUB_DIVISION,
  11. GET_CLIENT_PATH,
  12. // GET_SEARCH_TEMPLATE_COMBO_PATH,
  13. // GET_SEARCH_TEMPLATE_PATH
  14. } from "../../../utils/ApiPathConst";
  15. import * as React from "react";
  16. import LoadingComponent from "../../extra-pages/LoadingComponent";
  17. import ClientTable from "./ClientTable";
  18. import ClientSearchForm from "./ClientSearchForm";
  19. import Qs from "qs";
  20. // import Autocomplete from "@mui/material/Autocomplete";
  21. import {isObjEmpty} from "../../../utils/Utils";
  22. import {isFormEmpty} from "../../../utils/CommonFunction";
  23. // import UploadContext from "../../components/UploadProvider";
  24. // import {useLocation} from "react-router-dom";
  25. // import dayjs from "dayjs";
  26. import {LIONER_FORM_THEME, CARD_MAX_WIDTH} from "../../../themes/themeConst";
  27. import {ThemeProvider} from "@emotion/react";
  28. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  29. const ClientSearchPage = () => {
  30. const [onReady, setOnReady] = useState(false);
  31. const [expanded, setExpanded] = React.useState(true);
  32. const [record,setRecord] = useState([]);
  33. const [searchCriteria, setSearchCriteria] = useState({});
  34. function getClientList() {
  35. // const userSubDivision = queryParams.get('userSubDivision');
  36. // const year = queryParams.get('year');
  37. // const temp = {
  38. // fromDate: year === null ? null : dayjs(year+"-01-01").format('YYYY-MM-DD'),
  39. // toDate: year === null ? null : dayjs(year+"-12-31").format('YYYY-MM-DD'),
  40. // divisionIdList: userSubDivision === "true" ? [userDivision.id] : null,
  41. // };
  42. axios.get(`${apiPath}${GET_CLIENT_PATH}`, {
  43. params: searchCriteria,
  44. // params: isInit? temp : searchCriteria,
  45. paramsSerializer: function (params) {
  46. return Qs.stringify(params, { arrayFormat: 'repeat' });
  47. },
  48. }
  49. )
  50. .then((response) => {
  51. if (response.status === 200) {
  52. if (!isFormEmpty(searchCriteria) && !isObjEmpty(response.data.records)) {
  53. setExpanded(false);
  54. }
  55. setRecord(response.data.records);
  56. setOnReady(true);
  57. }
  58. })
  59. .catch(error => {
  60. console.log(error);
  61. return false;
  62. });
  63. }
  64. useEffect(() => {
  65. getClientList();
  66. }, [searchCriteria]);
  67. // useEffect(() => {
  68. // if(isObjEmpty(searchCriteria)){
  69. // getClientList();
  70. // }
  71. // console.log("1st");
  72. // }, []);
  73. function applySearch(input) {
  74. // console.log("SearchCriteria:")
  75. // console.log(input)
  76. setSearchCriteria(input);
  77. }
  78. return (
  79. <Grid container rowSpacing={3} columnSpacing={2.75} >
  80. <ThemeProvider theme={LIONER_FORM_THEME}>
  81. <Grid item xs={12} md={12} lg={12} >
  82. <Grid container maxWidth justifyContent="space-between" sx={{mt:-2, width:CARD_MAX_WIDTH}} >
  83. <Grid item xs={4} s={4} md={4} lg={4}
  84. sx={{ mb: -2.25, display: 'flex', alignItems: 'center'}}>
  85. <Typography variant="h4">Search Client</Typography>
  86. </Grid>
  87. </Grid>
  88. </Grid>
  89. {/* Search Form */}
  90. <Grid item xs={12} md={12} lg={12}>
  91. <ClientSearchForm
  92. // isUpdating={isUpdating}
  93. // setIsUpdating={setIsUpdating}
  94. applySearch={applySearch}
  95. // refTemplateData={refTemplateData}
  96. // getTemplateList={getTemplateList}
  97. setExpanded={setExpanded}
  98. expanded={expanded}
  99. // userDivision={userDivision}
  100. />
  101. </Grid>
  102. {!onReady? <LoadingComponent/> :
  103. // Client Table
  104. <Grid item xs={12} md={12} lg={12}>
  105. <MainCard elevation={0}
  106. content={false}
  107. sx={{mt:{lg:-1.5}, width: CARD_MAX_WIDTH}}
  108. >
  109. <div style={{/*height: expanded? '46vh' : '75vh',*/ width: '100%'}}>
  110. <ClientTable
  111. recordList={record}
  112. pageSize={10}
  113. expanded={expanded}
  114. />
  115. </div>
  116. </MainCard>
  117. </Grid>
  118. }
  119. </ThemeProvider>
  120. </Grid>
  121. );
  122. };
  123. export default ClientSearchPage;