部门管理-新增
This commit is contained in:
+89
-7
@@ -1,7 +1,9 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder,FormControl,FormGroup,Validators} from '@angular/forms';
|
||||
import { HttpClientService } from '../../../services/http-client.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { NzMessageService } from 'ng-zorro-antd';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import 'ztree';
|
||||
declare var $: any;
|
||||
@@ -14,18 +16,28 @@ declare var jQuery: any
|
||||
})
|
||||
export class DepartmentManagementComponent implements OnInit {
|
||||
treeSelected:any; //树模型-当前选中项
|
||||
treeSelectedChild:any; //上级机构选择树
|
||||
statusParamsTree:any={ //获取机构接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
|
||||
status:1,
|
||||
}
|
||||
public TreeData:any;
|
||||
public canDel:any=false;
|
||||
public canEdit:any=false;
|
||||
public search:any={
|
||||
orgId:'',
|
||||
}
|
||||
public orgDetail:any='';
|
||||
public orgSeleted:any=''; //所选机构详情
|
||||
public modifyType:any='3'; //操作状态 1新增 2修改 3详情
|
||||
public parentName:any='';
|
||||
public parentNode:any=''; //当前选中机构的父级节点
|
||||
public userList:any=''; //机构负责人列表
|
||||
saveCheck:any=false; //保存检查,保存验证表单 false 还未验证 true 触发了验证
|
||||
|
||||
validateForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
private http:HttpClientService,
|
||||
private router:Router,
|
||||
private message: NzMessageService,
|
||||
@@ -38,6 +50,17 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
$('.tree-box').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
$('.main-content').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
})
|
||||
//表单实例化
|
||||
this.validateForm = this.fb.group({
|
||||
organization:[ '', [ Validators.required ] ],
|
||||
shortName:[ '' ],
|
||||
code:[ '', [ Validators.required ] ],
|
||||
contact_person:[ '' ],
|
||||
contact_method:[ '' ],
|
||||
organization_type:[ '1' ],
|
||||
address:[ '' ],
|
||||
|
||||
});
|
||||
this.initTree();
|
||||
}
|
||||
//新增、修改
|
||||
@@ -45,9 +68,43 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
this.modifyType=type;
|
||||
}
|
||||
|
||||
//获取机构详情
|
||||
queryDetail(){
|
||||
submitForm(){
|
||||
this.saveCheck=true;
|
||||
}
|
||||
//保存选择机构
|
||||
treeSave(){
|
||||
if(this.treeSelectedChild){
|
||||
this.orgSeleted=this.treeSelectedChild;
|
||||
this.visible = false;
|
||||
this.orgSeletedBtn=false;
|
||||
}else{
|
||||
//如果没有选择机构,提示请选择机构
|
||||
this.message.create('warning', `请选择所属机构!`,{ nzDuration: 2000 });
|
||||
}
|
||||
}
|
||||
//打开机构树抽屉
|
||||
open(): void {
|
||||
this.treeSelectedChild='';
|
||||
this.visible = true;
|
||||
}
|
||||
//关闭机构选择页面
|
||||
close(): void {
|
||||
this.visible = false;
|
||||
}
|
||||
//删除机构标签
|
||||
tagClose(event){
|
||||
this.orgSeletedBtn=true;
|
||||
this.orgSeleted='';
|
||||
}
|
||||
//修改时查询该系统下的所有用户
|
||||
queryUserById():void{
|
||||
this.http.get('/sysapi/setting/organization/queryUserById/'+this.orgDetail.id).subscribe((json)=>{
|
||||
if(json.is_success){
|
||||
this.userList=json.body
|
||||
}else{
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
//获取机构列表,树模型数据处理
|
||||
initTree(){
|
||||
@@ -81,7 +138,9 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
this.statusParamsTree.status=0;
|
||||
}
|
||||
this.zNodes=json.body;
|
||||
this.zNodesChild=json.body;
|
||||
$.fn.zTree.init($("#treeDemo"), this.setting, this.zNodes);
|
||||
$.fn.zTree.init($("#treeDemoChild"), this.settingChild, this.zNodesChild);
|
||||
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
||||
let node = zTree.getNodes();
|
||||
if(json.body.length>0){
|
||||
@@ -90,7 +149,7 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
}
|
||||
})
|
||||
}
|
||||
//树模型参数设置
|
||||
//树模型参数设置-左侧机构树
|
||||
public zNodes: any[];
|
||||
setting = {
|
||||
data: {
|
||||
@@ -107,26 +166,49 @@ export class DepartmentManagementComponent implements OnInit {
|
||||
//节点点击事件
|
||||
onClick: (event, treeId, treeNode, clickFlag) => {
|
||||
this.modifyType=3;
|
||||
this.parentName='';
|
||||
this.parentNode='';
|
||||
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.queryUserById();
|
||||
this.canDel=true;
|
||||
this.canEdit=true;
|
||||
if(isTopNode.pId=='hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc'){
|
||||
if(isTopNode.id=='hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc'){
|
||||
//除去全部机构这层的第一层 也就是实际意义的顶层
|
||||
|
||||
}else{
|
||||
|
||||
this.parentName=isTopNode.name;
|
||||
this.parentNode=isTopNode;
|
||||
}
|
||||
}else{ //顶级节点
|
||||
this.orgDetail='';
|
||||
this.canDel=false;
|
||||
this.canEdit=false;
|
||||
}
|
||||
this.queryDetail();
|
||||
},
|
||||
},
|
||||
};
|
||||
//树模型参数设置-右侧机构树
|
||||
public zNodesChild: any[];
|
||||
settingChild = {
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
view: {
|
||||
showLine: true,
|
||||
dblClickExpand: false,
|
||||
showIcon:true
|
||||
},
|
||||
callback: {
|
||||
//节点点击事件
|
||||
onClick: (event, treeId, treeNode, clickFlag) => {
|
||||
var zTree = $.fn.zTree.getZTreeObj("treeDemoChild");
|
||||
this.treeSelectedChild=treeNode;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user