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

193 строки
6.6 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. Grid, TextField,
  5. // Autocomplete,
  6. Typography
  7. } from '@mui/material';
  8. import MainCard from "components/MainCard";
  9. import { useForm } from "react-hook-form";
  10. import * as React from "react";
  11. // import * as DateUtils from "utils/DateUtils";
  12. import {PNSPS_BUTTON_THEME} from "../../themes/buttonConst";
  13. import {ThemeProvider} from "@emotion/react";
  14. // import * as ComboData from "utils/ComboData";
  15. import * as DateUtils from "utils/DateUtils";
  16. import { makeStyles } from '@mui/styles';
  17. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  18. const useStyles = makeStyles(() => ({
  19. root: {
  20. position: "relative"
  21. },
  22. display: {
  23. position: "absolute",
  24. top: 2,
  25. left: 12,
  26. bottom: 2,
  27. background: "white",
  28. pointerEvents: "none",
  29. right: 50,
  30. display: "flex",
  31. alignItems: "center"
  32. },
  33. }));
  34. const SearchPublicNoticeForm = ({ applySearch, generateXML, searchCriteria }) => {
  35. // const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom);
  36. const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom);
  37. const [maxDate] = React.useState(searchCriteria.dateFrom);
  38. // const [status, setStatus] = React.useState(ComboData.paymentStatus[0]);
  39. const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy");
  40. const { register, handleSubmit, } = useForm()
  41. React.useEffect(() => {
  42. setFromDateValue(minDate);
  43. }, [minDate]);
  44. function FormDateInputComponent({ inputRef, ...props }) {
  45. const classes = useStyles();
  46. return (
  47. <>
  48. <div className={classes.display}>
  49. {DateUtils.dateStr(fromDateValue) == "Invalid Date" ?
  50. fromDateValue
  51. :
  52. DateUtils.dateStr(fromDateValue)}
  53. </div>
  54. <input
  55. // className={classes.input}
  56. ref={inputRef}
  57. {...props}
  58. // onChange={handleChange}
  59. value={fromDateValue}
  60. max={maxDate}
  61. />
  62. </>
  63. );
  64. }
  65. const onSubmit = () => {
  66. let sentDateFrom = "";
  67. if (fromDateValue != "dd / mm / yyyy") {
  68. sentDateFrom = DateUtils.dateValue(fromDateValue)
  69. }
  70. const temp = {
  71. // code: data.code,
  72. // transNo: data.transNo,
  73. dateFrom: sentDateFrom,
  74. // dateTo: data.dateTo,
  75. // status : (status?.type && status?.type != 'all') ? status?.type : "",
  76. };
  77. applySearch(temp);
  78. };
  79. const generateHandler = () => {
  80. let sentDateFrom = "";
  81. if (fromDateValue != "dd / mm / yyyy") {
  82. sentDateFrom = DateUtils.dateValue(fromDateValue)
  83. }
  84. // const dateTo = getValues("dateTo")
  85. const temp = {
  86. // code: data.code,
  87. // transNo: data.transNo,
  88. dateFrom: sentDateFrom,
  89. dateTo: "",
  90. // status : (status?.type && status?.type != 'all') ? status?.type : "",
  91. };
  92. generateXML(temp);
  93. }
  94. return (
  95. <MainCard xs={12} md={12} lg={12}
  96. border={false}
  97. content={false}
  98. >
  99. <form onSubmit={handleSubmit(onSubmit)} >
  100. <Grid container sx={{ backgroundColor: '#ffffff', ml: 2, mt: 1}} width="98%">
  101. {/*row 1*/}
  102. <Grid item justifyContent="space-between" alignItems="center" sx={{mt:1,ml:3,mb:2.5}}>
  103. <Typography variant="h5" >
  104. Credit Date
  105. </Typography>
  106. </Grid>
  107. {/*row 2*/}
  108. <Grid container display="flex" alignItems={"center"}>
  109. <Grid item xs={9} s={6} md={4} lg={4} sx={{ ml: 3, mr: 3, mb: 3 }}>
  110. <TextField
  111. fullWidth
  112. {...register("dateFrom")}
  113. id="dateFrom"
  114. type="date"
  115. label="Credit Date"
  116. defaultValue={searchCriteria.dateFrom}
  117. InputProps={{
  118. inputComponent: FormDateInputComponent,
  119. }}
  120. onChange={(newValue) => {
  121. setMinDate(newValue.target.value);
  122. }}
  123. InputLabelProps={{
  124. shrink: true
  125. }}
  126. />
  127. </Grid>
  128. <Grid item xs={9} s={6} md={4} lg={4} sx={{ ml: 3, mr: 3, mb: 3 }}>
  129. {/* <TextField
  130. fullWidth
  131. InputLabelProps={{
  132. shrink: true
  133. }}
  134. {...register("dateTo")}
  135. InputProps={{ inputProps: { min: minDate } }}
  136. onChange={(newValue) => {
  137. setMaxDate(DateUtils.dateValue(newValue));
  138. }}
  139. id="dateTo"
  140. type="date"
  141. label="To"
  142. defaultValue={searchCriteria.dateTo}
  143. /> */}
  144. </Grid>
  145. {/* <Grid item xs={9} s={6} md={4} lg={3}>
  146. </Grid> */}
  147. </Grid>
  148. <Grid container justifyContent="flex-end" direction="row" alignItems="center" spacing={3}>
  149. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  150. <Grid item sx={{ ml: 3, mb: 3, }} >
  151. <Button
  152. variant="contained"
  153. type="submit"
  154. >
  155. Preview
  156. </Button>
  157. </Grid>
  158. <Grid item sx={{ ml: 3, mr: 3, mb: 3, }} >
  159. <Button
  160. variant="contained"
  161. onClick={generateHandler}
  162. >
  163. Generate
  164. </Button>
  165. </Grid>
  166. </ThemeProvider>
  167. </Grid>
  168. </Grid>
  169. </form>
  170. </MainCard>
  171. );
  172. };
  173. export default SearchPublicNoticeForm;