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

OrganizationSearchForm.js 6.4 KiB

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