index.js 992 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { useModel } from '@umijs/max';
  2. import { Select } from 'antd';
  3. import { useEffect } from 'react';
  4. const { Option } = Select;
  5. function InnerContactField(props) {
  6. const {
  7. initialState: { user },
  8. } = useModel('@@initialState');
  9. const { value, onChange, disabled = false } = props;
  10. const { userList, run, loading } = useModel('userList');
  11. useEffect(() => {
  12. run();
  13. }, []);
  14. return (
  15. <Select
  16. showSearch
  17. value={user.ID}
  18. defaultValue={value ? Number(value) : undefined}
  19. onChange={(value) => {
  20. onChange(String(value));
  21. // onChange(JSON.stringify([value]));
  22. }}
  23. loading={loading}
  24. filterOption={(input, option) =>
  25. option.children.toLowerCase().includes(input.toLowerCase())
  26. }
  27. disabled={true}
  28. >
  29. {(userList || []).map((item) => (
  30. <Option key={item.ID} value={item.ID}>
  31. {item.CName}
  32. </Option>
  33. ))}
  34. </Select>
  35. );
  36. }
  37. export default InnerContactField;