diff --git a/src/forge/Component/SearchUser.jsx b/src/forge/Component/SearchUser.jsx
index 0203d24f..b9841123 100644
--- a/src/forge/Component/SearchUser.jsx
+++ b/src/forge/Component/SearchUser.jsx
@@ -1,45 +1,43 @@
-import React , { useState } from 'react';
+import React , { useState , useEffect } from 'react';
import { AutoComplete } from 'antd';
import { getImageUrl } from "educoder";
import axios from 'axios';
const Option = AutoComplete.Option;
-export default ({ getUser })=>{
+export default ({ getUser , placeholder, width })=>{
+ const [ source , setSource ] = useState(undefined);
const [ searchKey , setSearchKey ] = useState(undefined);
- const [ userDataSource , setUserDataSource ] = useState(undefined);
+
+ useEffect(()=>{
+ getUserList();
+ },[searchKey])
function getUserList(e){
const url = `/users/list.json`;
axios.get(url, {
params: {
- search: e,
+ search: searchKey,
},
- })
- .then((result) => {
+ }).then((result) => {
if (result) {
- setUserDataSource(result.data.users);
+ sourceOptions(result.data.users);
}
})
.catch((error) => {
console.log(error);
});
};
-
- function changeInputUser(value){
- setSearchKey(value);
- getUserList(value);
- }
- function selectInputUser(id, option){
- setSearchKey(option.props.value);
- getUserList(option.props.value);
- getUser && getUser(id);
- }
- const source =
- userDataSource && userDataSource.map((item, key) => {
+ function sourceOptions(userDataSource){
+ const s = userDataSource && userDataSource.map((item, key) => {
return (
-
);
});
+ setSource(s);
+ }
+
+ function changeInputUser(e){
+ setSearchKey(e);
+ };
+
+ // 选择用户
+ function selectInputUser(e, option){
+ setSearchKey(option.props.name);
+ getUser(option.props.login);
+ };
+
return(
-