From 1d250e81a517511499cc9ca2c7cbf3f0aa6f55bf Mon Sep 17 00:00:00 2001 From: liweijin <610336687@qq.com> Date: Wed, 21 Nov 2018 17:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E3=80=81=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/main.scss | 2 +- .../user-management-modify.component.html | 69 ++++- .../user-management-modify.component.scss | 16 ++ .../user-management-modify.component.ts | 236 ++++++++++++++++-- .../user-management.component.html | 10 +- .../user-management.component.ts | 20 +- 6 files changed, 314 insertions(+), 39 deletions(-) diff --git a/src/app/pages/main.scss b/src/app/pages/main.scss index ae745e3..5884cbd 100644 --- a/src/app/pages/main.scss +++ b/src/app/pages/main.scss @@ -3,7 +3,7 @@ margin-right: 10px; } .red{ - color: red; + color: #f5222d; } .orange{ color: orange; diff --git a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.html b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.html index 42ad053..bfbb3a6 100644 --- a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.html +++ b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.html @@ -1,6 +1,6 @@
-
+ 姓名 @@ -9,14 +9,14 @@ - 统一身份认证账号 + 系统账号 - - 请输入统一身份认证账号 + + 请输入系统账号 - 本系统密码 + 系统密码 请输入密码 @@ -25,8 +25,23 @@ 所属机构 - - 请选择所属机构 + + {{orgDetail.organization}} + + 修改选择 + 请选择所属机构 + + + + 所属角色 + +
+ +
+ + + + 请选择所属角色
@@ -47,12 +62,48 @@
- + + 性别 + + + + + + + + + - + +
+
+ +
+ + +
+ +
    + +
    +
    \ No newline at end of file diff --git a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.scss b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.scss index e69de29..63d221c 100644 --- a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.scss +++ b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.scss @@ -0,0 +1,16 @@ +.ztree{ + padding-bottom: 40px; + padding-right: 16px; +} +.drawer-footer{ + display: inline-block; + position: relative; + left: 50%; + bottom: 20px; + transform: translate(-50%) +} +.relative{ + position: relative; + width: 120px; + height: 40px; +} \ No newline at end of file diff --git a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.ts b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.ts index b636eb9..30ed3e1 100644 --- a/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.ts +++ b/src/app/pages/system-management/user-management/user-management-modify/user-management-modify.component.ts @@ -1,5 +1,12 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder,FormControl,FormGroup,Validators} from '@angular/forms'; +import { HttpClientService } from '../../../../services/http-client.service'; +import { Router,ActivatedRoute } from '@angular/router'; +import { NzMessageService } from 'ng-zorro-antd'; + +import 'ztree'; +declare var $: any; +declare var jQuery: any; @Component({ selector: 'app-user-management-modify', @@ -7,40 +14,225 @@ import { FormBuilder,FormControl,FormGroup,Validators} from '@angular/forms'; styleUrls: ['./user-management-modify.component.scss','../../../main.scss'] }) export class UserManagementModifyComponent implements OnInit { - validateForm: FormGroup; - - constructor( - private fb: FormBuilder + validateForm: FormGroup; + statusParamsTree:any={ //获取机构接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据 + status:1, + } + statusParamsRole:any={ //获取机构接口的状态,0请求失败 1请求前 2请求中 3请求成功,有数据 4请求成功,无数据 + status:1, + } + visible = false; //控制抽屉显示 + treeSelected:any; + orgDetail:any=''; //所选机构详情 + orgList:any=[]; //机构列表 + orgSeletedBtn:any=true; //控制机构选择按钮 + nodeList:any=[]; + saveCheck:any=false; //保存检查,保存验证表单 false 还未验证 true 触发了验证 + roleList:any=[]; //保存所选角色 + listOfRole:any=[]; //角色列表 + constructor( + private fb: FormBuilder, + private http:HttpClientService, + private route:ActivatedRoute, + private router:Router, + private message: NzMessageService, ) { } ngOnInit() { + this.queryRole(); this.validateForm = this.fb.group({ - real_name:[ null, [ Validators.required ] ], - loginId:[ null, [ Validators.required ] ], - password:[ null, [ Validators.required ] ], - identify_num:[ null], - email:[ null], - mobile:[ null], + real_name:[ '', [ Validators.required ] ], + login_name:[ '', [ Validators.required ] ], + password:[ '', [ Validators.required ] ], + identify_num:[ ''], + email:[ ''], + mobile:[ ''], + sex:['m'], + status:['1'], + role:[''] }); + //取路由参数 + this.route.queryParams.subscribe(routeParams=>{ + //routeParams 1新增 2修改 + if(routeParams.operateType==2){ + + + } + }) + } + checkName(){ + console.log(334343) + } + //机构树,搜索功能 + searchNode() { + var zTree = $.fn.zTree.getZTreeObj("treeDemo"); + zTree.cancelSelectedNode() + + var key = $("#key"); + var value = $.trim(key.get(0).value); + var keyType = "name"; + this.nodeList = zTree.getNodesByParamFuzzy(keyType, value); + if (value) { + for (var i = this.nodeList.length - 1; i >= 0; i--) { + zTree.selectNode(this.nodeList[i], true, false); + } + } + + } + //删除机构标签 + tagClose(event){ + this.orgSeletedBtn=true; + this.orgDetail=''; + } + //保存选择机构 + treeSave(){ + if(this.treeSelected){ + this.orgDetail=this.treeSelected; + this.visible = false; + this.orgSeletedBtn=false; + }else{ + //如果没有选择机构,提示请选择机构 + this.message.create('warning', `请选择所属机构!`,{ nzDuration: 2000 }); + } + } + //打开机构树抽屉 + open(): void { + this.treeSelected=''; + this.statusParamsTree.status=1; + this.visible = true; + this.initTree(); + + } + //关闭机构选择页面 + close(): void { + this.visible = false; + } submitForm(): void { + this.saveCheck=true; for (const i in this.validateForm.controls) { this.validateForm.controls[ i ].markAsDirty(); this.validateForm.controls[ i ].updateValueAndValidity(); } - } - updateConfirmValidator(): void { - /** wait for refresh value */ - Promise.resolve().then(() => this.validateForm.controls.checkPassword.updateValueAndValidity()); - } + if(this.validateForm.valid&&this.orgDetail&&this.roleList.length>0){ + let item=this.validateForm.value; + let params={ + real_name: item.real_name, + login_name: item.login_name, + password: item.password, + mobile: item.mobile, + sex: item.sex, + identify_num: item.identify_num, + email: item.email, + status: item.status, + orgList: [], + roleList: [], + }; + this.roleList.forEach(option=>{ + params.roleList.push({ + rid:option + }) + }) + this.orgList.forEach(option=>{ + if(option.id==this.orgDetail.id){ + params.orgList.push(option) + } + }) + console.log(params) + this.http.post('/sysapi/setting/user/add', params).subscribe((json) => { + if (json.is_success) { + this.message.success(`新增成功`); + this.router.navigate(['app/system/users']) + } else { + this.message.error(`新增失败`) + } + }) + } - confirmationValidator = (control: FormControl): { [ s: string ]: boolean } => { - if (!control.value) { - return { required: true }; - } else if (control.value !== this.validateForm.controls.password.value) { - return { confirm: true, error: true }; - } - }; + + } + //取消 返回列表页 + cancel(){ + this.router.navigate(['app/system/users']) + } + //获取角色列表 + queryRole(): void { + this.statusParamsRole.status=1; + this.http.get('/sysapi/setting/role/list', {page_index: '1',page_size: '100',}).subscribe((json) => { + if (json.is_success) { + this.listOfRole = json.body.list; + if(json.body.list&&json.body.list.length>0){ + this.statusParamsRole.status=3; + }else{ + this.statusParamsRole.status=4; + } + } else { + this.statusParamsRole.status=0; + } + }) + } + //树模型参数设置 + public zNodes: any[]; + setting = { + data: { + simpleData: { + enable: true + } + }, + view: { + showLine: true, + dblClickExpand: false, + showIcon:true + }, + callback: { + //节点点击事件 + onClick: (event, treeId, treeNode, clickFlag) => { + var zTree = $.fn.zTree.getZTreeObj("treeDemo"); + this.treeSelected=treeNode; + }, + }, + }; + //获取机构列表,树模型数据处理 + initTree(){ + //获取目录列表 + this.statusParamsTree.status=1; + this.http.get("/sysapi/setting/organization/list",).subscribe(json=>{ + if(json.is_success){ + if(json.body.length>0){ + this.orgList=json.body; + this.statusParamsTree.status=3; + let children=[]; + for(var i=0;i - + @@ -90,16 +90,16 @@
    - 统一身份认证账号 - {{userDetail.loginId}} - + 系统账号 + {{userDetail.login_name}} +
    - 本系统密码 + 系统密码 {{userDetail.password}} diff --git a/src/app/pages/system-management/user-management/user-management.component.ts b/src/app/pages/system-management/user-management/user-management.component.ts index 4f24574..925818e 100644 --- a/src/app/pages/system-management/user-management/user-management.component.ts +++ b/src/app/pages/system-management/user-management/user-management.component.ts @@ -1,6 +1,7 @@ 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; @@ -38,19 +39,34 @@ export class UserManagementComponent implements OnInit { constructor( private http:HttpClientService, private router:Router, + private message: NzMessageService, ) { } ngOnInit() { this.initTree(); this.queryTable(); + } + //删除 + delectConfirm(item){ + this.http.delete('/sysapi/setting/user/deleteById/'+item.uid).subscribe((json)=>{ + if(json.is_success){ + this.message.success(`删除成功!`); + this.queryTable(); + }else{ + this.message.error(`删除失败`) + } + }) + } + //取消删除 + delectCancel(){ + } //新增、修改 1新增 2修改 addModify(type,item?){ if(type==1){ - console.log(222) this.router.navigate(['app/system/users/modify'],{queryParams:{operateType:1}}) }else if(type==2){ - + this.router.navigate(['app/system/users/modify'],{queryParams:{operateType:2,id:item.uid}}) } } //打开详情页面