merge
This commit is contained in:
parent
7c40f9be36
commit
2157f2ffe5
|
@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
||||||
import { Modal , Checkbox , Spin , Input } from 'antd';
|
import { Modal , Checkbox , Spin , Input } from 'antd';
|
||||||
import Axios from 'axios';
|
import Axios from 'axios';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { values } from 'lodash';
|
||||||
|
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
const limit = 20;
|
const limit = 20;
|
||||||
|
@ -16,12 +17,19 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) {
|
||||||
const [ isSpin , setIsSpin ]= useState(true);
|
const [ isSpin , setIsSpin ]= useState(true);
|
||||||
const [ disable , setDisable ] = useState(false);
|
const [ disable , setDisable ] = useState(false);
|
||||||
|
|
||||||
|
const [ copyList , setCopyList ] = useState([]);
|
||||||
|
const [ copyAllList , setCopyAllList ] = useState([]);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(visible){
|
if(visible){
|
||||||
setIsSpin(true);
|
setIsSpin(true);
|
||||||
getProjectList();
|
getProjectList();
|
||||||
|
}else{
|
||||||
|
setSearch(undefined);
|
||||||
|
setCopyAllList([]);
|
||||||
|
setCopyList([]);
|
||||||
|
setList([]);
|
||||||
}
|
}
|
||||||
setSearch(undefined);
|
|
||||||
},[visible])
|
},[visible])
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
|
@ -31,12 +39,6 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) {
|
||||||
}
|
}
|
||||||
},[page])
|
},[page])
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
if(search !== undefined){
|
|
||||||
setIsSpin(true);
|
|
||||||
getProjectList(1,search);
|
|
||||||
}
|
|
||||||
},[search])
|
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(visible && choosed && choosed.length >0 ){
|
if(visible && choosed && choosed.length >0 ){
|
||||||
|
@ -60,11 +62,11 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) {
|
||||||
}
|
}
|
||||||
}).then(result=>{
|
}).then(result=>{
|
||||||
if(result && result.data){
|
if(result && result.data){
|
||||||
let e = page > 1 ? mergeArrayMerge(list,result.data.projects) : result.data.projects;
|
let e = !search ? mergeArrayMerge(list,result.data.projects) : result.data.projects;
|
||||||
|
setCopyAllList(!search ? e : copyAllList);
|
||||||
setTotal(result.data.count);
|
setTotal(result.data.count);
|
||||||
setList(e);
|
setList(e);
|
||||||
setIsSpin(false);
|
setIsSpin(false);
|
||||||
|
|
||||||
// 查看更多需要页数
|
// 查看更多需要页数
|
||||||
let s = parseInt(result.data.count/limit,0);
|
let s = parseInt(result.data.count/limit,0);
|
||||||
let y = result.data.count%limit;
|
let y = result.data.count%limit;
|
||||||
|
@ -86,28 +88,39 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) {
|
||||||
return array1
|
return array1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveList(c) {
|
||||||
|
// 将选中的复制下来保存到copyList数组里
|
||||||
|
if(c && c.length > 0){
|
||||||
|
let l = []
|
||||||
|
for(var i=0;i<c.length;i++){
|
||||||
|
let filter = copyAllList.filter(j=>j.id === c[i]);
|
||||||
|
if(filter && filter.length>0){
|
||||||
|
l.push(filter[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setCopyList(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onOk() {
|
function onOk() {
|
||||||
onSure && onSure(value);
|
onSure && onSure(value);
|
||||||
setValue([]);
|
setValue([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chooseProject(e,p) {
|
function chooseProject(e) {
|
||||||
setValue(e);
|
setValue(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
function onSearch(params) {
|
function onSearch(params) {
|
||||||
|
setCopyAllList(list);
|
||||||
|
value && value.length > 0 ? saveList(value) : setCopyList([]);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
setList([]);
|
|
||||||
setSearch(params);
|
setSearch(params);
|
||||||
// if(params){
|
getProjectList(1,params);
|
||||||
// setValueCopy(value);
|
|
||||||
// }else{
|
|
||||||
// setValue(valueCopy);
|
|
||||||
// setValueCopy([]);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
|
@ -133,21 +146,26 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="listbox">
|
<div className="listbox">
|
||||||
{
|
<Checkbox.Group value={value} onChange={chooseProject} style={{width:"100%"}}>
|
||||||
list && list.length > 0 &&
|
{
|
||||||
<Checkbox.Group value={value} onChange={chooseProject} style={{width:"100%"}}>
|
copyList && copyList.length >0 && copyList.map((i,k)=>{
|
||||||
{
|
return(
|
||||||
list.map((i,k)=>{
|
<Checkbox value={i.id} disabled={disable && (value.filter(j=>j === i.id).length===0)}>{i.author && i.author.name}/{i.name}</Checkbox>
|
||||||
return(
|
)
|
||||||
<Checkbox value={i.id} disabled={disable && (value.filter(j=>j === i.id).length===0)}>{i.name}</Checkbox>
|
})
|
||||||
)
|
}
|
||||||
})
|
{
|
||||||
}
|
list && list.length > 0 && list.map((i,k)=>{
|
||||||
</Checkbox.Group>
|
let c = copyList && copyList.length >0 && copyList.filter(j=>j.id === i.id).length !== 0;
|
||||||
}
|
return(
|
||||||
|
!c && <Checkbox value={i.id} disabled={disable && (value.filter(j=>j === i.id).length===0)}>{i.author && i.author.name}/{i.name}</Checkbox>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</Checkbox.Group>
|
||||||
</div>
|
</div>
|
||||||
{ total > limit && page < pageSize && <div className="morelist" onClick={()=>setPage(page+1)}>查看更多</div> }
|
{ total > limit && page < pageSize && <div className="morelist" onClick={()=>setPage(page+1)}>查看更多</div> }
|
||||||
{ list && list.length === 0 && <div style={{textAlign:"center"}}>您还没有公开的{search && `“${search}”`}项目,先去<Link to={`/projects/deposit/new`} className="color-blue">新建项目</Link></div> }
|
{ (list && list.length === 0) && (copyList && copyList.length === 0) && <div style={{textAlign:"center"}}>您还没有公开的{search && `“${search}”`}项目,先去<Link to={`/projects/deposit/new`} className="color-blue">新建项目</Link></div> }
|
||||||
</Spin>
|
</Spin>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
|
|
|
@ -183,17 +183,11 @@ class Infos extends Component {
|
||||||
this.props.history.push(`/users/${user && user.login}/organizes`)
|
this.props.history.push(`/users/${user && user.login}/organizes`)
|
||||||
}
|
}
|
||||||
|
|
||||||
resetUser=()=>{
|
|
||||||
const { resetUserInfo } = this.props;
|
|
||||||
|
|
||||||
this.fetchUser();
|
|
||||||
resetUserInfo && resetUserInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { current_user, mygetHelmetapi , resetUserInfo } = this.props;
|
const { current_user, mygetHelmetapi } = this.props;
|
||||||
const { username } = this.props.match.params;
|
const { username } = this.props.match.params;
|
||||||
const { user, isSpin, project_type, route_type , undo_events , undo_messages , menuKey } = this.state;
|
const { user, isSpin, project_type, route_type , undo_events , undo_messages , menuKey } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="newMain clearfix">
|
<div className="newMain clearfix">
|
||||||
<Spin spinning={isSpin}>
|
<Spin spinning={isSpin}>
|
||||||
|
@ -213,7 +207,7 @@ class Infos extends Component {
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className="text-center mt15 font-24 task-hide" title={user && user.username}>
|
<div className="text-center mt15 font-16 fwb task-hide" title={user && user.username}>
|
||||||
{user && user.username}
|
{user && user.username}
|
||||||
</div>
|
</div>
|
||||||
<div className="userDescription">
|
<div className="userDescription">
|
||||||
|
@ -342,7 +336,7 @@ class Infos extends Component {
|
||||||
<Route
|
<Route
|
||||||
path="/users/:username/info"
|
path="/users/:username/info"
|
||||||
render={() => {
|
render={() => {
|
||||||
return <UpdateInfo {...this.props} {...this.state} resetUser={this.resetUser}/>;
|
return <UpdateInfo {...this.props} {...this.state} resetUser={this.fetchUser}/>;
|
||||||
}}
|
}}
|
||||||
></Route>
|
></Route>
|
||||||
<Route
|
<Route
|
||||||
|
|
|
@ -10,16 +10,15 @@ export default Form.create()(
|
||||||
forwardRef((props)=>{
|
forwardRef((props)=>{
|
||||||
const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form;
|
const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form;
|
||||||
const { username } = props && props.match && props.match.params;
|
const { username } = props && props.match && props.match.params;
|
||||||
const { user , resetUser , current_user } = props;
|
const { user , resetUser } = props;
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(current_user && current_user.login){
|
if(user && user.login){
|
||||||
setFieldsValue({
|
setFieldsValue({
|
||||||
...current_user,
|
...user,
|
||||||
location:current_user.province && [current_user.province,current_user.city]
|
location:user.province && [user.province,user.city]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},[current_user])
|
},[user])
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
validateFields((error,values)=>{
|
validateFields((error,values)=>{
|
||||||
|
@ -45,7 +44,6 @@ export default Form.create()(
|
||||||
if(result && result.data){
|
if(result && result.data){
|
||||||
props.showNotification("资料修改成功!")
|
props.showNotification("资料修改成功!")
|
||||||
resetUser && resetUser(result.data);
|
resetUser && resetUser(result.data);
|
||||||
props.history.push(`/users/${username}`)
|
|
||||||
}
|
}
|
||||||
}).catch(error=>{})
|
}).catch(error=>{})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue