个人主页-区块确权添加项目名称搜索,同时优化用户下拉搜索组件,减少list接口请求
This commit is contained in:
parent
f08c140426
commit
9c46682dcf
|
|
@ -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 })=>{
|
|||
<AutoComplete
|
||||
getPopupContainer={trigger => trigger.parentNode}
|
||||
dataSource={source}
|
||||
value={searchKey}
|
||||
style={{ width: width || 300 }}
|
||||
onChange={changeInputUser}
|
||||
onSearch={(value)=>{getUserList(value)}}
|
||||
onSelect={selectInputUser}
|
||||
placeholder={placeholder || "搜索需要添加的用户..."}
|
||||
allowClear
|
||||
optionLabelProp="name"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
>
|
||||
<div className="diverModal">
|
||||
{
|
||||
|
|
@ -113,7 +108,8 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
<Form {...layout} colon={false} layout={"horizontal"}>
|
||||
<Form.Item label="转移给:" style={{marginBottom:"0px"}}>
|
||||
{getFieldDecorator("goal",{
|
||||
rules:[]
|
||||
rules:[],
|
||||
initialValue: 0
|
||||
})(
|
||||
<Radio.Group onChange={changeType}>
|
||||
<Radio value={0}>个人</Radio>
|
||||
|
|
@ -128,7 +124,7 @@ function DivertModal({form , visible , onSuccess , onCancel,owner,repo}){
|
|||
rules:[{required:true,message:"请输入目标用户名"}]
|
||||
})(
|
||||
// <Input placeholder="请输入目标用户" autoComplete={"off"}/>
|
||||
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户" value={value}/>
|
||||
<SearchUser getUser={getUser} width={"100%"} placeholder="请输入目标用户"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(<div className='mt15 contribution'>
|
||||
{/* 转账/记录切换 */}
|
||||
{/* <div className='contHead'>
|
||||
<a className={`itemCont ${type ? 'active' : ''}`} onClick={()=>{setType(1)}}>token转账</a>
|
||||
<a className={`itemCont ${type ? '' : 'active'}`} onClick={()=>{setType(0)}}>token记录</a>
|
||||
</div> */}
|
||||
<div className='contHead clearfix'>
|
||||
{/* <a className={`itemCont ${type ? 'active' : ''}`} onClick={()=>{setType(1)}}>token转账</a>
|
||||
<a className={`itemCont ${type ? '' : 'active'}`} onClick={()=>{setType(0)}}>token记录</a> */}
|
||||
<Input.Search className='fr' style={{width: 'auto'}} placeholder='请输入项目名称进行搜索' allowClear onSearch={(value)=>{
|
||||
setPage(1);
|
||||
setContent(value);
|
||||
}}/>
|
||||
</div>
|
||||
{/* token转账 */}
|
||||
{type ? <div className='contributionTable mt25'>
|
||||
{list && list.length > 0 && <div className='flexCenterCont tableHeadTri mb5'>
|
||||
|
|
@ -142,7 +158,7 @@ function Contribution(props){
|
|||
<div className='tableColumn1'>{item.name}</div>
|
||||
<div className='tableColumn2'>{item.balance}</div>
|
||||
<div className='tableColumn3'>
|
||||
<SearchUser getUser={(login)=>{getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户" value={userLogin[item.id]}/>
|
||||
<SearchUser getUser={(login)=>{getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户" userList={userList}/>
|
||||
{proId === item.id && error1 && <div className='errorTipTri'>{error1}</div>}
|
||||
</div>
|
||||
<div className='tableColumn4'>
|
||||
|
|
|
|||
Loading…
Reference in New Issue