From 605d5a047d04196ea45611967ed39665e33cfc80 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Tue, 27 Apr 2021 17:11:37 +0800
Subject: [PATCH] merge undo
---
src/forge/Component/SearchUser.jsx | 71 ++++++++++++++++++------------
src/forge/Main/CoderDepot.jsx | 4 +-
src/forge/Team/Sub/Detail.jsx | 19 ++++++--
3 files changed, 60 insertions(+), 34 deletions(-)
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(
-