diff --git a/src/forge/Component/SearchUser.jsx b/src/forge/Component/SearchUser.jsx index 79d23fb65..de8ea9a3a 100644 --- a/src/forge/Component/SearchUser.jsx +++ b/src/forge/Component/SearchUser.jsx @@ -5,25 +5,21 @@ import axios from 'axios'; const Option = AutoComplete.Option; -export default ({ getUser , placeholder, width ,value })=>{ +export default ({ getUser , placeholder, width ,value, userList=[] })=>{ const [ source , setSource ] = useState(undefined); - const [ searchKey , setSearchKey ] = useState(undefined); - useEffect(()=>{ - if(!value){ - setSearchKey(undefined); + if(userList && userList.length){ + sourceOptions(userList); + }else{ + getUserList(); } - },[value]) - - useEffect(()=>{ - getUserList(); - },[searchKey]) + },[]) - function getUserList(e){ + function getUserList(value){ const url = `/users/list.json`; axios.get(url, { params: { - search: searchKey, + search: value, }, }).then((result) => { if (result) { @@ -61,13 +57,9 @@ export default ({ getUser , placeholder, width ,value })=>{ setSource(s); } - function changeInputUser(e){ - setSearchKey(e); - }; - // 选择用户 function selectInputUser(e, option){ - setSearchKey(option.props.name); + getUserList(option.props.name); getUser(option.props.login); }; @@ -76,12 +68,12 @@ export default ({ getUser , placeholder, width ,value })=>{ trigger.parentNode} dataSource={source} - value={searchKey} style={{ width: width || 300 }} - onChange={changeInputUser} + onSearch={(value)=>{getUserList(value)}} onSelect={selectInputUser} placeholder={placeholder || "搜索需要添加的用户..."} allowClear + optionLabelProp="name" /> ) diff --git a/src/forge/Divert/DivertModal.jsx b/src/forge/Divert/DivertModal.jsx index d4c1f2014..27e3e4f79 100644 --- a/src/forge/Divert/DivertModal.jsx +++ b/src/forge/Divert/DivertModal.jsx @@ -8,14 +8,9 @@ const { Option } = Select; function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ const { getFieldDecorator, validateFields , setFieldsValue } = form; const [ cate , setCate ] = useState(0); - const [ value , setValue ] = useState(undefined); const [ organizations , setOrganizations ] = useState(undefined); - useEffect(()=>{ - setFieldsValue({goal:cate}) - },[]) - useEffect(()=>{ if(owner && repo && visible===true){ getTeam(); @@ -25,7 +20,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ owner_name:undefined, identifier:undefined }) - setValue(undefined) + setCate(0); } },[repo,owner,visible]) @@ -79,7 +74,6 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ }; function getUser(id){ - setValue(id); setFieldsValue({ owner_name:id }) @@ -94,6 +88,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ okText="确认转移" cancelText={"取消"} centered + destroyOnClose={true} >
{ @@ -113,7 +108,8 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
{getFieldDecorator("goal",{ - rules:[] + rules:[], + initialValue: 0 })( 个人 @@ -128,7 +124,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){ rules:[{required:true,message:"请输入目标用户名"}] })( // - + )} } diff --git a/src/forge/users/contribution/index.jsx b/src/forge/users/contribution/index.jsx index 381b474e3..aec4cb470 100644 --- a/src/forge/users/contribution/index.jsx +++ b/src/forge/users/contribution/index.jsx @@ -1,11 +1,8 @@ import React , { useEffect , useState } from 'react'; import { Button, Dropdown, Input, Menu , message, Pagination } from 'antd'; -import Search from '../../Component/Search'; -import Item from '../Team-item'; import Nodata from '../../Nodata'; import axios from 'axios'; -import CheckProfile from '../../Component/ProfileModal/Profile'; import './index.scss'; import SearchUser from '../../Component/SearchUser'; import { FlexAJ } from '../../Component/layout'; @@ -28,6 +25,10 @@ function Contribution(props){ const [error2, setError2] = useState(undefined); // 操作仓库id const [proId, setProId] = useState(undefined); + // 名称搜索 + const [content, setContent] = useState(undefined); + // 平台用户列表 + const [userList, setUserList] = useState([]); const {current_user:{user_id, login, open_blockchain}, current_user} = props; const {user} = props; const username = props.match.params.username; @@ -43,7 +44,8 @@ function Contribution(props){ axios.get(`/users/blockchain/balance.json`,{params: { user_id, limit, - page + page, + keyword: content }}).then(res=>{ if(res && res.data){ const {projects} = res.data; @@ -63,7 +65,7 @@ function Contribution(props){ setTotal(res.data.total_count); } }) - }, [reload, page]) + }, [reload, page, content]) useEffect(()=>{ if(user){ @@ -73,6 +75,16 @@ function Contribution(props){ } },[user]) + useEffect(()=>{ + // 获取平台用户列表 + const url = `/users/list.json`; + axios.get(url).then((result) => { + if (result) { + setUserList(result.data.users); + } + }) + }, []) + // 目标转账用户 function getUser(id, login){ // 使用JSON进行对象深拷贝 @@ -113,7 +125,7 @@ function Contribution(props){ project_id: id }).then(res=>{ if(res && res.data && res.data.status === 2){ - getUser(id, undefined); + // getUser(id, undefined); setToken(id, undefined); setReload(Math.random()); message.success('转账成功'); @@ -124,10 +136,14 @@ function Contribution(props){ return(
{/* 转账/记录切换 */} - {/*
- {setType(1)}}>token转账 - {setType(0)}}>token记录 -
*/} +
+ {/* {setType(1)}}>token转账 + {setType(0)}}>token记录 */} + { + setPage(1); + setContent(value); + }}/> +
{/* token转账 */} {type ?
{list && list.length > 0 &&
@@ -142,7 +158,7 @@ function Contribution(props){
{item.name}
{item.balance}
- {getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户" value={userLogin[item.id]}/> + {getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户" userList={userList}/> {proId === item.id && error1 &&
{error1}
}