Commit b0d5280a by zhangleyuan

feat:处理自定义分组集合合的提示

parent 91a3f720
...@@ -25,7 +25,7 @@ function LeftStructureTree(props) { ...@@ -25,7 +25,7 @@ function LeftStructureTree(props) {
const [completeOptions,setCompleteOption] = useState([]); const [completeOptions,setCompleteOption] = useState([]);
const [selectedKeys,setSelectedKeys]= useState([]); // 设置选中的部门key值 const [selectedKeys,setSelectedKeys]= useState([]); // 设置选中的部门key值
const [queryName,setQueryName] = useState(''); const [queryName,setQueryName] = useState('');
const [postGroupTreeData,setPostGroupTreeData] = useState([]); const [postGroupTreeData,setPostGroupTreeData] = useState([]); // 为了判定创建和编辑时的数据会不会重明
const [open,setOpen]=useState(false); const [open,setOpen]=useState(false);
const renderTitle = (title) => ( const renderTitle = (title) => (
...@@ -214,7 +214,7 @@ function LeftStructureTree(props) { ...@@ -214,7 +214,7 @@ function LeftStructureTree(props) {
} }
function handleData(dataArray){ function handleData(dataArray){
const _dataArray = dataArray.map((item,index)=>{ const _dataArray = dataArray.map((item,index)=>{
item.title = item.name; item.title = "";
item.key=item.id; item.key=item.id;
if(item.sonDepartmentVOList){ if(item.sonDepartmentVOList){
item.children = item.sonDepartmentVOList; item.children = item.sonDepartmentVOList;
...@@ -307,9 +307,20 @@ function LeftStructureTree(props) { ...@@ -307,9 +307,20 @@ function LeftStructureTree(props) {
}else{ }else{
setPostGroupModalTitle('编辑岗位'); setPostGroupModalTitle('编辑岗位');
setPostGroupModalLable('岗位'); setPostGroupModalLable('岗位');
setPostGroupTreeData([]); setPostGroupTreeData(getParentChildernData(record.parentId));
} }
} }
// 获取父节点下的所有的子级数据
function getParentChildernData(parentId){
let _parentChildernData = []
treeData.map((item,index)=>{
if( parentId=== item.id){
_parentChildernData = item.sonDepartmentVOList
}
})
return _parentChildernData
}
function delPostGroup(record){ function delPostGroup(record){
let title = '确认删除该岗位组吗?'; let title = '确认删除该岗位组吗?';
let content= '删除后,该岗位组下的岗位及也将全部删除。'; let content= '删除后,该岗位组下的岗位及也将全部删除。';
...@@ -384,14 +395,14 @@ function LeftStructureTree(props) { ...@@ -384,14 +395,14 @@ function LeftStructureTree(props) {
setPostGroupModalLevel(record.level); setPostGroupModalLevel(record.level);
setCurrentGroupData(record) setCurrentGroupData(record)
//level为0的时候编辑的是岗位组 大于0的时候 //level为0的时候编辑的是岗位组 大于0的时候
if(record.level===0){ if(record.depLevel===0){
setPostGroupModalTitle('编辑分组集合'); setPostGroupModalTitle('编辑分组集合');
setPostGroupModalLable('分组集合'); setPostGroupModalLable('分组集合');
setPostGroupTreeData(treeData); setPostGroupTreeData(treeData);
}else{ }else{
setPostGroupModalTitle('编辑分组'); setPostGroupModalTitle('编辑分组');
setPostGroupModalLable('分组'); setPostGroupModalLable('分组');
setPostGroupTreeData([]); setPostGroupTreeData(getParentChildernData(record.parentId));
} }
} }
function delCustomGroup(record){ function delCustomGroup(record){
......
...@@ -38,7 +38,7 @@ function MemberTree(props) { ...@@ -38,7 +38,7 @@ function MemberTree(props) {
} }
function handleData(dataArray){ function handleData(dataArray){
const _dataArray = dataArray.map((item,index)=>{ const _dataArray = dataArray.map((item,index)=>{
item.title = item.name || item.userName; item.title = "";
item.key=item.id; item.key=item.id;
item.children = [] item.children = []
if(item.departmentUserVOList){ if(item.departmentUserVOList){
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wufan * @Author: wufan
* @Date: 2020-11-27 16:21:49 * @Date: 2020-11-27 16:21:49
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-08-05 18:24:06 * @LastEditTime: 2021-08-06 11:43:10
* @Description: Description * @Description: Description
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -16,24 +16,28 @@ function AddOrEditPostGroupModal(props) { ...@@ -16,24 +16,28 @@ function AddOrEditPostGroupModal(props) {
const [nameErrorMsg,setNameErrorMsg] = useState(''); const [nameErrorMsg,setNameErrorMsg] = useState('');
const [validateStatus,setValidateStatus] = useState('success'); const [validateStatus,setValidateStatus] = useState('success');
const [postGroupName,setPostGroupName] = useState(''); const [postGroupName,setPostGroupName] = useState('');
const [isError,setIsError] = useState(false)
useEffect(() => { useEffect(() => {
},[]); },[]);
function changePostGroupName(e){ function changePostGroupName(e){
let isError = false; setIsError(false)
setValidateStatus('success'); setValidateStatus('success');
setNameErrorMsg(''); setNameErrorMsg('');
if(!postGroupName || /^\s+$/.test(postGroupName)){
setValidateStatus('error');
setNameErrorMsg(`${props.label}不能为空`);
setIsError(true)
}
props.postGroupTreeData.map((item,index)=>{ props.postGroupTreeData.map((item,index)=>{
if(item.name === e.target.value){ if(item.name === e.target.value){
setValidateStatus('error'); setValidateStatus('error');
setNameErrorMsg(`该${props.label}已存在`); setNameErrorMsg(`该${props.label}已存在`);
isError = true; setIsError(true)
} }
return item; return item;
}) })
if(!isError){ setPostGroupName(e.target.value);
setPostGroupName(e.target.value);
}
} }
function handleConfirm(){ function handleConfirm(){
...@@ -44,7 +48,7 @@ function AddOrEditPostGroupModal(props) { ...@@ -44,7 +48,7 @@ function AddOrEditPostGroupModal(props) {
} }
} }
function addGroup(){ function addGroup(){
if(!postGroupName){ if(isError){
return; return;
} }
const { postGroupModalLevel,currentTab,currentGroupData,label} = props const { postGroupModalLevel,currentTab,currentGroupData,label} = props
...@@ -69,7 +73,7 @@ function AddOrEditPostGroupModal(props) { ...@@ -69,7 +73,7 @@ function AddOrEditPostGroupModal(props) {
}); });
} }
function editGroup(){ function editGroup(){
if(!postGroupName){ if(isError){
return; return;
} }
const {postGroupModalLevel,currentTab,currentGroupData,label} = props const {postGroupModalLevel,currentTab,currentGroupData,label} = props
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment