您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

63 行
2.2 KiB

  1. import {
  2. Autocomplete, TextField
  3. } from '@mui/material';
  4. import * as React from 'react';
  5. import Select, { SelectChangeEvent } from '@mui/material/Select';
  6. export default function Combo ({valueName, disabled, form, dataList, filterOptions, getOptionLabel, isOptionEqualToValue, onInputChange, onChange, ...props}){
  7. const [value, setValue] = React.useState(form.values[valueName]);
  8. const [inputValue, setInputValue] = React.useState("");
  9. return (
  10. <Autocomplete
  11. {...props}
  12. disablePortal
  13. fullWidth
  14. id={valueName}
  15. name={valueName}
  16. disabled={disabled}
  17. value={value}
  18. inputValue={inputValue}
  19. filterOptions={filterOptions}
  20. options={dataList}
  21. getOptionLabel={getOptionLabel}
  22. isOptionEqualToValue={(option, newValue)=>{
  23. if(isOptionEqualToValue)
  24. isOptionEqualToValue(option,newValue, setValue,setInputValue )
  25. }}
  26. onInputChange={(event, newValue) => {
  27. setInputValue(newValue);
  28. if(onInputChange){
  29. onInputChange(event,newValue, setInputValue)
  30. }
  31. }}
  32. onChange={(event, newValue) => {
  33. setValue(newValue);
  34. if (!onChange){
  35. form.setFieldValue(valueName, newValue);
  36. }else{
  37. onChange(event, newValue);
  38. }
  39. }}
  40. sx={{
  41. "& .MuiInputBase-root": {
  42. height: "41px",
  43. padding: "0px 0px 0px 8px"
  44. },
  45. "& .MuiAutocomplete-endAdornment": {
  46. top: "auto"
  47. },
  48. "& .MuiInputBase-input.Mui-disabled": {
  49. WebkitTextFillColor: "#000000",
  50. background: "#f8f8f8",
  51. },
  52. }}
  53. renderInput={(params) => <TextField {...params} sx={{
  54. "& .MuiInputBase-input.Mui-disabled": {
  55. WebkitTextFillColor: "#000000",
  56. background: "#f8f8f8",
  57. },
  58. }}/>}
  59. />
  60. );
  61. }