用户管理-列表开发

This commit is contained in:
liweijin
2018-11-19 20:58:55 +08:00
parent 5b29727f7f
commit 074d4b7409
12 changed files with 269 additions and 49 deletions
@@ -12,16 +12,22 @@ declare var jQuery: any;
})
export class UserManagementComponent implements OnInit {
treeSelected:any; //树模型-当前选中项
collectionSize:any ;
statusParamsTable:any={ //获取目录树接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
status:1,
}
statusParamsTree:any={ //获取机构接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据
status:1,
}
public search:any={
page_index:'1',
page_size:'10',
real_name:'',
login_name:'',
orgId:'',
orgId:'',
}
parentNode:any;
parentName:any;
isTreeTop:any=false; //判断是否为树最顶层
isLoading:false;
public tableData:any=[];
constructor(
private http:HttpClientService,
@@ -29,17 +35,31 @@ export class UserManagementComponent implements OnInit {
ngOnInit() {
this.initTree();
this.queryTable();
}
//获取列表
queryTable():void{
this.statusParamsTable.status=1;
this.http.get('/sysapi/setting/user/list',this.search).subscribe((json)=>{
if(json.is_success){
this.tableData=json.body.list;
this.statusParamsTable.status=3;
this.collectionSize=json.body.total;
}else{
this.statusParamsTable.status=0;
}
})
}
//树模型参数设置
public zNodes: any[];
setting = {
data: {
simpleData: {
enable: true
enable: true
}
},
view: {
showLine: false,
showLine: true,
dblClickExpand: false,
showIcon:true
},
@@ -47,47 +67,50 @@ export class UserManagementComponent implements OnInit {
//节点点击事件
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;
let isTopNode=this.treeSelected.getParentNode(); //是否为顶级节点 true不是顶级节点 false 为顶级节点
if(isTopNode){ //子节点
this.search.orgId=this.treeSelected.id;
}else{ //顶级节点
this.search.orgId='';
}
this.queryTable();
},
//节点展开事件
onExpand: (event, treeId, treeNode) => {
}
},
};
//新树模型
initTree(){
//获取目录列表
this.statusParamsTree.status=1;
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';
if(json.is_success){
if(json.body.length>0){
this.statusParamsTree.status=3;
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',
})
}else{
//数据为空
this.statusParamsTree.status=4;
}
json.body.push({
name:"全部机构",
isParent:true,
open:true,
id:'hsfuhiw34239j89sauf98992h3indshv98h392hf9mplsd032fs2a2313fc',
})
}else{
//请求失败
this.statusParamsTree.status=0;
}
this.zNodes=json.body;
$.fn.zTree.init($("#treeDemo"), this.setting, this.zNodes);
var zTree = $.fn.zTree.getZTreeObj("treeDemo");