99 lines
2.4 KiB
TypeScript
99 lines
2.4 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { HttpClientService } from '../../../services/http-client.service';
|
|
|
|
import 'ztree';
|
|
declare var $: any;
|
|
declare var jQuery: any;
|
|
|
|
@Component({
|
|
selector: 'app-user-management',
|
|
templateUrl: './user-management.component.html',
|
|
styleUrls: ['./user-management.component.scss','../../main.scss']
|
|
})
|
|
export class UserManagementComponent implements OnInit {
|
|
treeSelected:any; //树模型-当前选中项
|
|
public search:any={
|
|
page_index:'1',
|
|
page_size:'10',
|
|
real_name:'',
|
|
login_name:'',
|
|
orgId:'',
|
|
}
|
|
parentNode:any;
|
|
parentName:any;
|
|
isTreeTop:any=false; //判断是否为树最顶层
|
|
|
|
constructor(
|
|
private http:HttpClientService,
|
|
) { }
|
|
|
|
ngOnInit() {
|
|
this.initTree();
|
|
}
|
|
//树模型参数设置
|
|
public zNodes: any[];
|
|
setting = {
|
|
data: {
|
|
simpleData: {
|
|
enable: true
|
|
}
|
|
},
|
|
view: {
|
|
showLine: false,
|
|
dblClickExpand: false,
|
|
showIcon:true
|
|
},
|
|
callback: {
|
|
//节点点击事件
|
|
onClick: (event, treeId, treeNode, clickFlag) => {
|
|
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
|
zTree.expandNode(treeNode);
|
|
this.treeSelected=treeNode;
|
|
this.search.orgId=this.treeSelected.id;
|
|
this.parentNode=this.treeSelected.getParentNode();
|
|
if(!this.parentNode){
|
|
this.isTreeTop=true;
|
|
}else{
|
|
this.isTreeTop=false;
|
|
}
|
|
},
|
|
//节点展开事件
|
|
onExpand: (event, treeId, treeNode) => {
|
|
|
|
}
|
|
},
|
|
};
|
|
//新树模型
|
|
initTree(){
|
|
//获取目录列表
|
|
this.http.get("/sysapi/setting/organization/list",).subscribe(json=>{
|
|
if(json.is_success&&json.body){
|
|
let children=[];
|
|
for(var i=0;i<json.body.length;i++){
|
|
let option=json.body[i];
|
|
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',
|
|
})
|
|
|
|
}
|
|
|
|
this.zNodes=json.body;
|
|
$.fn.zTree.init($("#treeDemo"), this.setting, this.zNodes);
|
|
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
|
let node = zTree.getNodes();
|
|
})
|
|
|
|
}
|
|
}
|