岗位更新

This commit is contained in:
red-deng-deng 2021-11-11 18:03:35 +08:00
parent fabf1dcbcf
commit add1a74fc2
2 changed files with 67 additions and 79 deletions

View File

@ -66,7 +66,19 @@ export default class adduserinfo extends React.Component{
pwd:[
{ type: "required", message: "请输入密码"},
{ type: "regExp", message: "格式不对",reg:"^[1][3,5,7,8][0-9]\\d{8}$"}
]
],
name: [
{ type: "required", message: "请输入真实姓名"},
],
post: [
{ type: "required", message: "请输入岗位"},
],
station: [
{ type: "required", message: "请输入角色"},
],
}

View File

@ -19,26 +19,28 @@ export default class station extends React.Component{
post:[{id:1-1-1,name:'后端'},{id:2,name:'前端'},{id:3,name:'测试'}],
}
this.addItem=this.addItem.bind(this);
this.sureFn=this.sureFn.bind(this);
}
onChange = options => {
this.setState(options);
};
//弹出框
setVisible = visible => {
this.setState({ visible });
};
saveFn(e,placeholder){
// if(e.innerHTML=="取消"){
// if(placeholder=='公司'){
// this.setState({'companyBtn':true});
// }else if(placeholder=='部门'){
// this.setState({'departmentBtn':true});
// }else if(placeholder=='岗位'){
// this.setState({'postBtn':true});
// }
// e.parentNode.parentNode.remove();
// }else{
// this.setState({visible:true});
// }
if(e.innerHTML=="取消"){
if(placeholder=='公司'){
this.setState({'companyBtn':true});
}else if(placeholder=='部门'){
this.setState({'departmentBtn':true});
}else if(placeholder=='岗位'){
this.setState({'postBtn':true});
}
e.parentNode.parentNode.remove();
}else{
this.setState({visible:true});
}
}
editFn(e,placeholder){
let cssname=null;
@ -55,18 +57,15 @@ export default class station extends React.Component{
}
if(e.parentNode.parentNode.children[0].value){
if( e.innerHTML=="保存"){
if(this.hasVal(cssname,e.parentNode.parentNode.children[0].value)>-1){
if(this.hasVal(stationame,e.parentNode.parentNode.children[0].value)>-1){
Notify.clear()
Notify.warn(`${placeholder}重复,请重新增加`);
Notify.warn(`${placeholder}已存在,请重新增加`);
}else{
e.parentNode.firstChild.innerHTML='删除';
e.parentNode.parentNode.children[0].disabled="disabled";
e.parentNode.parentNode.className=cssname+" newitem";
Notify.clear()
Notify.success('保存成功');
this.setState({company:[]})
e.innerHTML="编辑";
if(placeholder=='公司'){
this.setState({'companyBtn':true});
@ -105,17 +104,17 @@ export default class station extends React.Component{
let stationame=[];
if(placeholder=='公司'){
cssname='companyBtn';
stationame=this.state.company;
stationame=this.state.company
}else if(placeholder=='部门'){
cssname='departmentBtn';
stationame=this.state.department;
stationame=this.state.department
}else if(placeholder=='岗位'){
cssname='postBtn';
stationame=this.state.post;
stationame=this.state.post
}
if(this.hasVal(this.state.company,e.target.value)>-1){
if(this.hasVal(stationame,e.target.value)>-1){
Notify.clear()
Notify.warn(`${placeholder}重复,请重新增加`);
Notify.warn(`${placeholder}已存在,请重新增加`);
}else{
rp.parentNode.children[1].firstChild.innerHTML='删除';
rp.disabled="disabled";
@ -134,15 +133,15 @@ export default class station extends React.Component{
}
}
chooseFn(e,disbtn){
// let netList=document.querySelectorAll('.'+disbtn);
// netList.forEach((item,i)=>{
// item.addEventListener('click',()=>{
// netList.forEach((item2,i2)=>{
// item2.className=disbtn+" newitem"
// });
// item.className=disbtn+" newitem choseactive";
// });
// });
let netList=document.querySelectorAll('.'+disbtn);
netList.forEach((item,i)=>{
item.addEventListener('click',()=>{
netList.forEach((item2,i2)=>{
item2.className=disbtn+" newitem"
});
item.className=disbtn+" newitem choseactive";
});
});
}
close(){
this.setState({'visible':false});
@ -151,7 +150,7 @@ export default class station extends React.Component{
this.setState({'visible':true});
}
addItem(e,disbtn){
// 获取节点追加填入的input
//获取节点追加填入的input
let flag=null;
let place=null;
if(disbtn=='companyBtn'){
@ -165,6 +164,15 @@ export default class station extends React.Component{
place="岗位"
}
if(flag){
let btnName=1;
let nextDom=e.target.nextSibling;
let addipt=document.createElement('div');
addipt.className=disbtn+" newitem";
addipt.innerHTML=`
<input placeholder=请输入新增${place} onKeydown={window["mystation"].sureFn(event,this,'${place}')} />
<p><span class="del" onClick={window["mystation"].saveFn(this,'${place}')}>取消</span><span class="operation" onClick={window["mystation"].editFn(this,'${place}')}></span></p>
`;
nextDom.appendChild(addipt);
if(disbtn=='companyBtn'){
this.setState({companyBtn:false});
}else if(disbtn=='departmentBtn'){
@ -172,52 +180,22 @@ export default class station extends React.Component{
}else if(disbtn=='postBtn'){
this.setState({postBtn:false});
}
// let data=JSON.parse(JSON.stringify(this.state.company));
let obj={id:'',name:''}
// data.unshift(obj);
// this.setState({company:data});
let data = [...this.state.company]
data.unshift(obj);
this.setState({company:data});
// setTimeout(()=>{
// let netList=document.querySelectorAll('.companyBtn');
// console.log(netList)
// netList.forEach((item,i)=>{
// console.log(item);
// item.className=disbtn+" newitem";
// netList.forEach((item2,i2)=>{
// netList[0].className="newitem focusactive";
// netList[0].children[0].focus();
// })
// })
// },200)
let netList=document.querySelectorAll('.'+disbtn);
netList.forEach((item,i)=>{
item.className=disbtn+" newitem";
netList.forEach((item2,i2)=>{
netList[netList.length-1].className="newitem focusactive";
console.log(netList[netList.length-1].children[0].focus());
})
})
}else{
Notify.clear()
Notify.warn(`请先操作新增的${place}`);
}
}
changeval(e,item){
let index=this.hasVal(this.state.company,item);
let changeVal=_.cloneDeepWith(this.state.company, []);
if(index==-1){
changeVal[0].name=e.target.value;
this.setState({company:changeVal});
}
}
render(){
// let netList=document.querySelectorAll('.companyBtn');
// console.log('netList',netList);
const { current, pageSize } = this.state;
return(
<div id="station" className="maincenter">
@ -235,15 +213,13 @@ export default class station extends React.Component{
<Card type="nested" title="公司" className="carditem">
<div>
<p className="newadd" onClick={(event)=>this.addItem(event,'companyBtn')}>+新建公司</p>
<div className="addComList" onClick={(event)=>this.chooseFn(event,'companyBtn')}>
<div className="addList" onClick={(event)=>this.chooseFn(event,'companyBtn')}>
{
this.state.company.map((item,key)=>{
return(
<div className="newitem companyBtn"><input value={item.name} type="text" onChange={e =>this.changeval(e,item)} onKeyDown={(e)=>this.sureFn(e,'公司')} />
<div className="newitem companyBtn"><input value={item.name}/>
<p><span className="operation
" onClick={(e)=>this.saveFn(e,'公司')}>删除</span><span className="operation
" onClick={(e)=>this.editFn(e,'公司')} style={{marginLeft:'15px'}}>取消</span><span className="operation
" onClick={(e)=>this.editFn(e,'公司')} style={{marginLeft:'15px'}}>保存</span></p>
" onClick={(e)=>this.saveFn(e,'公司')}>删除</span></p>
</div>
)
})