部门管理-修改部门
This commit is contained in:
+6
-6
@@ -53,9 +53,9 @@
|
||||
<div nz-col nzSpan="24">
|
||||
<nz-form-item>
|
||||
<nz-form-label>机构类型</nz-form-label>
|
||||
<span *ngIf='organization_type==1' class="detail-item-text">机构</span>
|
||||
<span *ngIf='organization_type==2' class="detail-item-text">部门</span>
|
||||
<span *ngIf='!organization_type' class="detail-item-text">无</span>
|
||||
<span *ngIf="orgDetail.organization_type==1" class="detail-item-text">机构</span>
|
||||
<span *ngIf="orgDetail.organization_type==2" class="detail-item-text">部门</span>
|
||||
<span *ngIf='!orgDetail.organization_type' class="detail-item-text">无</span>
|
||||
</nz-form-item>
|
||||
</div>
|
||||
<div nz-col nzSpan="24">
|
||||
@@ -119,7 +119,7 @@
|
||||
<nz-form-item>
|
||||
<nz-form-label [nzSm]="4" [nzXs]="24" nzFor="code" nzRequired>机构编码</nz-form-label>
|
||||
<nz-form-control [nzSm]="18" [nzXs]="24" [nzValidateStatus]="checkNameStatus" nzHasFeedback>
|
||||
<input nz-input id="code" formControlName="code" placeholder="请输入姓名" (blur)='checkName()' (keydown)="checkNameStatus='';nameOnly=true" name="validating">
|
||||
<input nz-input id="code" formControlName="code" placeholder="请输入机构编码" (blur)='checkName()' (keydown)="checkNameStatus='';nameOnly=true" name="validating">
|
||||
<nz-form-explain *ngIf="validateForm.get('code').dirty && validateForm.get('code').errors">请输入机构编码</nz-form-explain>
|
||||
<nz-form-explain *ngIf="!nameOnly" class="danger">该编码已存在</nz-form-explain>
|
||||
</nz-form-control>
|
||||
@@ -148,8 +148,8 @@
|
||||
<nz-form-label [nzSm]="4" [nzXs]="24" nzFor="organization_type" >机构类型</nz-form-label>
|
||||
<nz-form-control [nzSm]="18" [nzXs]="24">
|
||||
<nz-radio-group formControlName="organization_type">
|
||||
<label nz-radio nzValue="1">机构</label>
|
||||
<label nz-radio nzValue="2">部门</label>
|
||||
<label nz-radio [nzValue]=1>机构</label>
|
||||
<label nz-radio [nzValue]=2>部门</label>
|
||||
</nz-radio-group>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
|
||||
+63
-9
@@ -32,8 +32,8 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
page_size:'10',
|
||||
real_name:'',
|
||||
}
|
||||
public orgDetail:any='';
|
||||
public orgSeleted:any=''; //所选机构详情
|
||||
public orgDetail:any=''; //左侧机构目录当前选中项机构的详情信息
|
||||
public orgSeleted:any=''; //新增或者修改时,当前选中的所属机构的机构详情信息
|
||||
public modifyType:any='3'; //操作状态 1新增 2修改 3详情
|
||||
public parentName:any='';
|
||||
public parentNode:any=''; //当前选中机构的父级节点
|
||||
@@ -71,17 +71,45 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
code:[ '', [ Validators.required ] ],
|
||||
contact_person:[ '' ],
|
||||
contact_method:[ '' ],
|
||||
organization_type:[ '1' ],
|
||||
organization_type:[ '' ],
|
||||
address:[ '' ],
|
||||
|
||||
});
|
||||
this.initTree();
|
||||
this.queryTable();
|
||||
}
|
||||
//新增、修改
|
||||
//新增、修改 type 1新增 2修改
|
||||
addModify(type){
|
||||
//数据清空重置
|
||||
this.modifyType=type;
|
||||
this.validateForm.reset();
|
||||
this.userSelecteds=[];
|
||||
this.orgSeleted='';
|
||||
this.checkNameStatus='';
|
||||
this.nameOnly=true;
|
||||
this.validateForm.patchValue({organization_type:1,});
|
||||
if(type==1){
|
||||
|
||||
}else if(type==2){
|
||||
let item=this.orgDetail;
|
||||
this.validateForm.patchValue({
|
||||
organization:item.organization,
|
||||
shortName:item.shortName,
|
||||
code:item.code,
|
||||
contact_person:item.contact_person,
|
||||
contact_method:item.contact_method,
|
||||
organization_type:item.organization_type,
|
||||
address:item.address,
|
||||
});
|
||||
this.orgSeleted=this.parentNode;
|
||||
this.userList.forEach(option=>{
|
||||
option.checked=true;
|
||||
option.disabled=false;
|
||||
this.userSelecteds.push(option)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//保存
|
||||
submitForm(){
|
||||
@@ -95,6 +123,25 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
}
|
||||
let params=Object.assign({},this.validateForm.value,{pid:pid},{userList:userList})
|
||||
console.log(params)
|
||||
if(this.modifyType==1){
|
||||
this.http.post('/sysapi/setting/organization/add/',params).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.message.success(`新增成功!`);
|
||||
this.initTree();
|
||||
}else{
|
||||
this.message.success(`新增失败!`);
|
||||
}
|
||||
})
|
||||
}else if(this.modifyType==2){
|
||||
this.http.put('/sysapi/setting/organization/updateById/'+this.orgDetail.id,params).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.message.success(`修改成功!`);
|
||||
this.initTree();
|
||||
}else{
|
||||
this.message.success(`修改失败!`);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
//取消
|
||||
cancel(){
|
||||
@@ -105,12 +152,12 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
console.log(this.userData);
|
||||
this.userData.forEach(item=>{
|
||||
if(item.checked&&!item.disabled){
|
||||
console.log(item)
|
||||
// 增加数据
|
||||
this.userSelecteds = [ ...this.userSelecteds, item];
|
||||
this.userSelecteds = [ ...this.userSelecteds, item];
|
||||
}
|
||||
})
|
||||
this.visibleUsers = false;
|
||||
console.log(this.userSelecteds)
|
||||
}
|
||||
//保存选择机构
|
||||
treeSave(){
|
||||
@@ -170,7 +217,7 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
//获取列表
|
||||
//获取用户列表
|
||||
queryTable():void{
|
||||
this.statusParamsUsers.status=1;
|
||||
this.http.get('/sysapi/setting/user/list',this.search).subscribe((json)=>{
|
||||
@@ -223,12 +270,20 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
this.checkNameStatus='success';
|
||||
return false;
|
||||
}
|
||||
//拿用户输入的机构编码跟机构列表的编码对比,判断编码是否已经存在
|
||||
let status='true';
|
||||
this.orgList.forEach(item=>{
|
||||
if(this.validateForm.value.code.trim()==item.code){
|
||||
this.checkNameStatus='error';
|
||||
this.nameOnly = false;
|
||||
status='false';
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
if(status=='true'&&this.validateForm.value.code.trim()){
|
||||
this.checkNameStatus='success';
|
||||
this.nameOnly = true;
|
||||
}
|
||||
}
|
||||
//获取机构列表,树模型数据处理
|
||||
initTree(){
|
||||
@@ -296,7 +351,6 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
||||
this.treeSelected=treeNode;
|
||||
let isTopNode=this.treeSelected.getParentNode(); //是否为顶级节点 true不是顶级节点 false 为顶级节点
|
||||
console.log(isTopNode)
|
||||
if(isTopNode){ //子节点
|
||||
this.orgDetail=treeNode;
|
||||
this.oldLoginName=this.orgDetail.code;
|
||||
|
||||
Reference in New Issue
Block a user