選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OrganizationSearchForm.js 6.4 KiB

2年前
2年前
2年前
1年前
2年前
1年前
2年前
2年前
2年前
2年前
1年前
2年前
2年前
2年前
1年前
2年前
2年前
2年前
1年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
1年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // material-ui
  2. import {
  3. Button,
  4. CardContent,
  5. Grid, TextField,
  6. Typography,
  7. Autocomplete,
  8. } from '@mui/material';
  9. import MainCard from "components/MainCard";
  10. import { useForm } from "react-hook-form";
  11. import { useState } from "react";
  12. import * as React from "react";
  13. import * as UrlUtils from "utils/ApiPathConst";
  14. import * as HttpUtils from "utils/HttpUtils";
  15. import * as ComboData from "utils/ComboData";
  16. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  17. const OrganizationSearchForm = ({ applySearch }) => {
  18. const [type, setType] = useState([]);
  19. const [creditorSelected, setCreditorSelected] = React.useState({ key: 0, labelCht: '全部', label: 'All', type: 'all' });
  20. const { reset, register, handleSubmit } = useForm()
  21. const onSubmit = (data) => {
  22. let typeArray = [];
  23. for (let i = 0; i < type.length; i++) {
  24. typeArray.push(type[i].label);
  25. }
  26. const temp = {
  27. brNo: data.brNo,
  28. enCompanyName: data.enCompanyName,
  29. chCompanyName: data.chCompanyName,
  30. };
  31. if(creditorSelected.type == 'true'){
  32. temp["creditor"] = true;
  33. }else if(creditorSelected.type == 'false'){
  34. temp["creditor"] = false;
  35. }
  36. applySearch(temp);
  37. };
  38. function resetForm() {
  39. setType([]);
  40. reset();
  41. }
  42. const doExport=()=>{
  43. HttpUtils.fileDownload({
  44. url: UrlUtils.GET_ORG_EXPORT
  45. });
  46. }
  47. return (
  48. <MainCard xs={12} md={12} lg={12}
  49. border={false}
  50. content={false}>
  51. <form onSubmit={handleSubmit(onSubmit)}>
  52. {/*row 1*/}
  53. <CardContent sx={{ px: 2.5, pt: 3 }}>
  54. <Grid item justifyContent="space-between" alignItems="center">
  55. <Typography variant="h4">Search Form</Typography>
  56. </Grid>
  57. </CardContent>
  58. {/*row 2*/}
  59. <Grid container alignItems={"center"}>
  60. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
  61. <TextField
  62. fullWidth
  63. {...register("brNo")}
  64. id='brNo'
  65. label="BR No."
  66. InputLabelProps={{
  67. shrink: true
  68. }}
  69. />
  70. </Grid>
  71. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
  72. <TextField
  73. fullWidth
  74. {...register("enCompanyName")}
  75. id="enCompanyName"
  76. label="Name (English)"
  77. InputLabelProps={{
  78. shrink: true
  79. }}
  80. />
  81. </Grid>
  82. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
  83. <TextField
  84. fullWidth
  85. {...register("chCompanyName")}
  86. id="chCompanyName"
  87. label="Name (Chinese)"
  88. InputLabelProps={{
  89. shrink: true
  90. }}
  91. />
  92. </Grid>
  93. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3}}>
  94. <Autocomplete
  95. {...register("searchCreditor")}
  96. id="searchCreditor"
  97. size="small"
  98. options={ComboData.CreditorStatus}
  99. value={creditorSelected}
  100. onChange={(event, newValue) => {
  101. setCreditorSelected(newValue);
  102. }}
  103. getOptionLabel={(option) => option.label}
  104. renderInput={(params) => (
  105. <TextField
  106. {...params}
  107. label="Status"
  108. InputLabelProps={{
  109. shrink: true
  110. }}
  111. />
  112. )}
  113. />
  114. </Grid>
  115. </Grid>
  116. {/*last row*/}
  117. <Grid container maxWidth justifyContent="flex-end">
  118. <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
  119. <Button
  120. size="large"
  121. variant="contained"
  122. onClick={doExport}
  123. sx={{
  124. textTransform: 'capitalize',
  125. alignItems: 'end'
  126. }}>
  127. <Typography variant="h5">Export</Typography>
  128. </Button>
  129. </Grid>
  130. <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
  131. <Button
  132. size="large"
  133. variant="contained"
  134. onClick={resetForm}
  135. sx={{
  136. textTransform: 'capitalize',
  137. alignItems: 'end'
  138. }}>
  139. <Typography variant="h5">Clear</Typography>
  140. </Button>
  141. </Grid>
  142. <Grid item sx={{ ml: 3, mr: 3, mb: 3, mt: 3 }}>
  143. <Button
  144. size="large"
  145. variant="contained"
  146. type="submit"
  147. sx={{
  148. textTransform: 'capitalize',
  149. alignItems: 'end'
  150. }}>
  151. <Typography variant="h5">Submit</Typography>
  152. </Button>
  153. </Grid>
  154. </Grid>
  155. </form>
  156. </MainCard>
  157. );
  158. };
  159. export default OrganizationSearchForm;