From 2157f2ffe5618c07d2dd9250040f72898412df29 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Tue, 8 Jun 2021 10:44:44 +0800 Subject: [PATCH] merge --- .../users/GeneralView/ConcentrateBox.jsx | 78 ++++++++++++------- src/forge/users/Infos.js | 14 +--- src/forge/users/Material/Base.jsx | 12 ++- 3 files changed, 57 insertions(+), 47 deletions(-) diff --git a/src/forge/users/GeneralView/ConcentrateBox.jsx b/src/forge/users/GeneralView/ConcentrateBox.jsx index 0ec8d9c66..4c0b2afca 100644 --- a/src/forge/users/GeneralView/ConcentrateBox.jsx +++ b/src/forge/users/GeneralView/ConcentrateBox.jsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { Modal , Checkbox , Spin , Input } from 'antd'; import Axios from 'axios'; import { Link } from 'react-router-dom'; +import { values } from 'lodash'; const { Search } = Input; const limit = 20; @@ -15,13 +16,20 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) { const [ value , setValue ]= useState([]); const [ isSpin , setIsSpin ]= useState(true); const [ disable , setDisable ] = useState(false); + + const [ copyList , setCopyList ] = useState([]); + const [ copyAllList , setCopyAllList ] = useState([]); useEffect(()=>{ if(visible){ setIsSpin(true); getProjectList(); + }else{ + setSearch(undefined); + setCopyAllList([]); + setCopyList([]); + setList([]); } - setSearch(undefined); },[visible]) useEffect(()=>{ @@ -31,12 +39,6 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) { } },[page]) - useEffect(()=>{ - if(search !== undefined){ - setIsSpin(true); - getProjectList(1,search); - } - },[search]) useEffect(()=>{ if(visible && choosed && choosed.length >0 ){ @@ -60,11 +62,11 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) { } }).then(result=>{ 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); setList(e); setIsSpin(false); - // 查看更多需要页数 let s = parseInt(result.data.count/limit,0); let y = result.data.count%limit; @@ -86,28 +88,39 @@ function ConcentrateBox({ visible , onCancel , onSure , username , choosed }) { return array1 } + function saveList(c) { + // 将选中的复制下来保存到copyList数组里 + if(c && c.length > 0){ + let l = [] + for(var i=0;ij.id === c[i]); + if(filter && filter.length>0){ + l.push(filter[0]); + } + } + setCopyList(l); + } + } + function onOk() { onSure && onSure(value); setValue([]); } - function chooseProject(e,p) { + function chooseProject(e) { setValue(e); } // 搜索 function onSearch(params) { + setCopyAllList(list); + value && value.length > 0 ? saveList(value) : setCopyList([]); setPage(1); - setList([]); setSearch(params); - // if(params){ - // setValueCopy(value); - // }else{ - // setValue(valueCopy); - // setValueCopy([]); - // } + getProjectList(1,params); } + return(
- { - list && list.length > 0 && - - { - list.map((i,k)=>{ - return( - j === i.id).length===0)}>{i.name} - ) - }) - } - - } + + { + copyList && copyList.length >0 && copyList.map((i,k)=>{ + return( + j === i.id).length===0)}>{i.author && i.author.name}/{i.name} + ) + }) + } + { + list && list.length > 0 && list.map((i,k)=>{ + let c = copyList && copyList.length >0 && copyList.filter(j=>j.id === i.id).length !== 0; + return( + !c && j === i.id).length===0)}>{i.author && i.author.name}/{i.name} + ) + }) + } +
{ total > limit && page < pageSize &&
setPage(page+1)}>查看更多
} - { list && list.length === 0 &&
您还没有公开的{search && `“${search}”`}项目,先去新建项目
} + { (list && list.length === 0) && (copyList && copyList.length === 0) &&
您还没有公开的{search && `“${search}”`}项目,先去新建项目
}
) diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index 77ab795a1..3701c1be8 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -183,17 +183,11 @@ class Infos extends Component { this.props.history.push(`/users/${user && user.login}/organizes`) } - resetUser=()=>{ - const { resetUserInfo } = this.props; - - this.fetchUser(); - resetUserInfo && resetUserInfo(); - } - render() { - const { current_user, mygetHelmetapi , resetUserInfo } = this.props; + const { current_user, mygetHelmetapi } = this.props; const { username } = this.props.match.params; const { user, isSpin, project_type, route_type , undo_events , undo_messages , menuKey } = this.state; + return (
@@ -213,7 +207,7 @@ class Infos extends Component { -
+
{user && user.username}
@@ -342,7 +336,7 @@ class Infos extends Component { { - return ; + return ; }} > { const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form; const { username } = props && props.match && props.match.params; - const { user , resetUser , current_user } = props; - + const { user , resetUser } = props; useEffect(()=>{ - if(current_user && current_user.login){ + if(user && user.login){ setFieldsValue({ - ...current_user, - location:current_user.province && [current_user.province,current_user.city] + ...user, + location:user.province && [user.province,user.city] }) } - },[current_user]) + },[user]) function submit() { validateFields((error,values)=>{ @@ -45,7 +44,6 @@ export default Form.create()( if(result && result.data){ props.showNotification("资料修改成功!") resetUser && resetUser(result.data); - props.history.push(`/users/${username}`) } }).catch(error=>{}) }