部门详情
This commit is contained in:
+122
-3
@@ -1,4 +1,11 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClientService } from '../../../services/http-client.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { NzMessageService } from 'ng-zorro-antd';
|
||||
|
||||
import 'ztree';
|
||||
declare var $: any;
|
||||
declare var jQuery: any
|
||||
|
||||
@Component({
|
||||
selector: 'app-department-management',
|
||||
@@ -6,10 +13,122 @@ import { Component, OnInit } from '@angular/core';
|
||||
styleUrls: ['./department-management.component.scss']
|
||||
})
|
||||
export class DepartmentManagementComponent implements OnInit {
|
||||
treeSelected:any; //树模型-当前选中项
|
||||
statusParamsTree:any={ //获取机构接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
|
||||
status:1,
|
||||
}
|
||||
public canDel:any=false;
|
||||
public canEdit:any=false;
|
||||
public search:any={
|
||||
orgId:'',
|
||||
}
|
||||
public orgDetail:any='';
|
||||
public modifyType:any='3'; //操作状态 1新增 2修改 3详情
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private http:HttpClientService,
|
||||
private router:Router,
|
||||
private message: NzMessageService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
ngOnInit() {
|
||||
$('.tree-box').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
$('.main-content').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
$(window).resize(function(){
|
||||
$('.tree-box').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
$('.main-content').css('height',(document.documentElement.clientHeight-106+'px'));
|
||||
})
|
||||
this.initTree();
|
||||
}
|
||||
//新增、修改
|
||||
addModify(type){
|
||||
this.modifyType=type;
|
||||
}
|
||||
|
||||
//获取机构详情
|
||||
queryDetail(){
|
||||
|
||||
}
|
||||
//获取机构列表,树模型数据处理
|
||||
initTree(){
|
||||
//获取目录列表
|
||||
this.statusParamsTree.status=1;
|
||||
this.http.get("/sysapi/setting/organization/list",).subscribe(json=>{
|
||||
if(json.is_success){
|
||||
if(json.body.length>0){
|
||||
this.statusParamsTree.status=3;
|
||||
let children=[];
|
||||
json.body.forEach(option=>{
|
||||
option.name=option.organization;
|
||||
if(option.pid){
|
||||
option.pId=option.pid;
|
||||
}else{
|
||||
option.pId='hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc';
|
||||
}
|
||||
});
|
||||
json.body.push({
|
||||
name:"全部机构",
|
||||
isParent:true,
|
||||
open:true,
|
||||
id:'hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc',
|
||||
})
|
||||
}else{
|
||||
//数据为空
|
||||
this.statusParamsTree.status=4;
|
||||
}
|
||||
}else{
|
||||
//请求失败
|
||||
this.statusParamsTree.status=0;
|
||||
}
|
||||
this.zNodes=json.body;
|
||||
$.fn.zTree.init($("#treeDemo"), this.setting, this.zNodes);
|
||||
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
||||
let node = zTree.getNodes();
|
||||
if(json.body.length>0){
|
||||
zTree.selectNode(node[0].children[0])
|
||||
zTree.setting.callback.onClick(null,zTree.setting.treeId,node[0].children[0])
|
||||
}
|
||||
})
|
||||
}
|
||||
//树模型参数设置
|
||||
public zNodes: any[];
|
||||
setting = {
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true
|
||||
}
|
||||
},
|
||||
view: {
|
||||
showLine: true,
|
||||
dblClickExpand: false,
|
||||
showIcon:true
|
||||
},
|
||||
callback: {
|
||||
//节点点击事件
|
||||
onClick: (event, treeId, treeNode, clickFlag) => {
|
||||
this.modifyType=3;
|
||||
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.canDel=true;
|
||||
this.canEdit=true;
|
||||
if(isTopNode.pId=='hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc'){
|
||||
//除去全部机构这层的第一层 也就是实际意义的顶层
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{ //顶级节点
|
||||
this.orgDetail='';
|
||||
this.canDel=false;
|
||||
this.canEdit=false;
|
||||
}
|
||||
this.queryDetail();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user