机构或角色删除后影响用户的问题修复

This commit is contained in:
zhouyuejun
2019-05-09 11:01:03 +08:00
parent 6704dca7f8
commit 833108cd0d
7 changed files with 99 additions and 52 deletions
+28 -2
View File
@@ -97,14 +97,34 @@
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>原密码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input type="password" nz-input formControlName="oldPassword" placeholder="原密码">
<nz-form-explain *ngIf="validateForm.get('oldPassword').dirty && validateForm.get('oldPassword').errors">请输入原密码</nz-form-explain>
<nz-form-explain *ngIf="validateForm.get('oldPassword').dirty && validateForm.get('oldPassword').errors">
<ng-container *ngIf="validateForm.get('oldPassword')?.hasError('required')">
请输入原密码!
</ng-container>
<ng-container *ngIf="validateForm.get('oldPassword')?.hasError('minlength')">
最小2个字符!
</ng-container>
<ng-container *ngIf="validateForm.get('oldPassword')?.hasError('maxlength')">
最大15个字符!
</ng-container>
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>新密码</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input type="password" nz-input formControlName="newPassword" placeholder="新密码" (ngModelChange)="updateConfirmValidator()">
<nz-form-explain *ngIf="validateForm.get('newPassword').dirty && validateForm.get('newPassword').errors">请输入新密码</nz-form-explain>
<nz-form-explain *ngIf="validateForm.get('newPassword').dirty && validateForm.get('newPassword').errors">
<ng-container *ngIf="validateForm.get('newPassword')?.hasError('required')">
请输入新密码!
</ng-container>
<ng-container *ngIf="validateForm.get('newPassword')?.hasError('minlength')">
最小2个字符!
</ng-container>
<ng-container *ngIf="validateForm.get('newPassword')?.hasError('maxlength')">
最大15个字符!
</ng-container>
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
@@ -118,6 +138,12 @@
<ng-container *ngIf="validateForm.get('confirmPassword')?.hasError('confirm')">
两次密码不一致!
</ng-container>
<ng-container *ngIf="validateForm.get('confirmPassword')?.hasError('minlength')">
最小2个字符!
</ng-container>
<ng-container *ngIf="validateForm.get('confirmPassword')?.hasError('maxlength')">
最大15个字符!
</ng-container>
</nz-form-explain>
</nz-form-control>
</nz-form-item>
+22 -15
View File
@@ -81,9 +81,9 @@ export class PagesComponent implements OnInit {
});
this.validateForm = this.fb.group({
oldPassword: ['', [Validators.required]],
newPassword: ['', [Validators.required]],
confirmPassword: ['', [Validators.required, this.confirmationValidator]],
oldPassword: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]],
newPassword: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]],
confirmPassword: ['', [Validators.required, this.confirmationValidator, Validators.minLength(2), Validators.maxLength(15)]],
});
}
@@ -111,19 +111,26 @@ export class PagesComponent implements OnInit {
}
modifyHandleOk(): void {
this.isConfirmLoading = true;
this.httpClient.post('/adminapi/xxxxx', this.validateForm.value).subscribe((response) => {
let params = {
"curPassword":this.validateForm.get('oldPassword').value,
"newPassword":this.validateForm.get('newPassword').value
}
this.httpClient.put('/sysapi/setting/user/cur/password', params).subscribe((response) => {
// console.log(response);
this.message.success('修改密码成功!');
this.validateForm.patchValue({
oldPassword: '',
newPassword: '',
confirmPassword: ''
})
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsPristine();
this.validateForm.controls[i].markAsUntouched();
this.validateForm.controls[i].updateValueAndValidity();
if(response.is_success){
this.message.success('修改密码成功!');
this.validateForm.patchValue({
oldPassword: '',
newPassword: '',
confirmPassword: ''
})
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsPristine();
this.validateForm.controls[i].markAsUntouched();
this.validateForm.controls[i].updateValueAndValidity();
}
}else{
this.message.error(response.err_msg + ',修改失败!');
}
this.modalIsVisible = false;
this.isConfirmLoading = false;
@@ -140,16 +140,23 @@ export class DepartmentManagementComponent implements OnInit {
nzTitle: '删除',
nzContent: '确定删除【' + this.orgDetail.organization + '】?',
nzOnOk: () => new Promise((resolve, reject) => {
this.http.delete('/sysapi/setting/organization/delOrgByid/' + this.orgDetail.id).subscribe((json) => {
if (json.is_success) {
resolve();
this.message.success(`删除成功!`);
this.initTree();
} else {
reject();
this.message.error(`删除失败!`);
}
})
if (this.userList && this.userList.length > 0) {
setTimeout(()=>{
this.message.error('删除失败,请删除此机构下的用户后再执行此操作!');
reject()
},500);
} else {
this.http.delete('/sysapi/setting/organization/delOrgByid/' + this.orgDetail.id).subscribe((json) => {
if (json.is_success) {
resolve();
this.message.success(`删除成功!`);
this.initTree();
} else {
reject();
this.message.error(`删除失败!`);
}
})
}
}).catch(() => console.log('Oops errors!'))
});
@@ -411,10 +418,10 @@ export class DepartmentManagementComponent implements OnInit {
this.orgDetail = treeNode;
this.oldLoginName = this.orgDetail.code;
this.queryUserById();
if(this.treeSelected.children&&this.treeSelected.children.length>0){
if (this.treeSelected.children && this.treeSelected.children.length > 0) {
this.canDel = false;
this.canEdit = true;
}else{
} else {
this.canDel = true;
this.canEdit = true;
}
@@ -27,10 +27,10 @@
</nz-form-control>
</nz-form-item>
<div class="user-table table-box" nz-row>
<nz-table nz-col nzXs="24" nzSm="20" nzMd="18" nzLg="14" nzXl="12" nzBordered [nzShowPagination]='false'
<nz-table nz-col nzXs="24" nzSm="20" nzMd="18" nzLg="14" nzXl="12" nzBordered [nzSize]="'middle'" [nzPageSize]="8"
#userDataSet [nzData]="userSelecteds">
<thead>
<tr>
<tr>
<th>姓名</th>
<th>用户名</th>
<th>电话</th>
@@ -142,9 +142,6 @@ export class RoleManagementModifyComponent implements OnInit {
item.disabled = false;
this.userSelecteds = [...this.userSelecteds, item];
})
} else {
}
})
}
@@ -186,18 +183,18 @@ export class RoleManagementModifyComponent implements OnInit {
this.visibleUsers = false;
}
//处理机构负责人选择和数据回填
userSelect() {
if (this.userData) {
this.userData.forEach(item => {
this.userSelecteds.forEach(option => {
if (item.uid == option.uid) {
item.checked = true;
item.disabled = true;
}
})
})
}
}
// userSelect() {
// if (this.userData) {
// this.userData.forEach(item => {
// this.userSelecteds.forEach(option => {
// if (item.uid == option.uid) {
// item.checked = true;
// item.disabled = true;
// }
// })
// })
// }
// }
//删除机构负责人
delectConfirm(item) {
this.userSelecteds = this.userSelecteds.filter(function (option) {
@@ -47,12 +47,22 @@ export class RoleManagementComponent implements OnInit {
}
//删除
delectConfirm(item) {
this.http.delete('/sysapi/setting/role/delete/' + item.rid).subscribe((json) => {
if (json.is_success) {
this.message.success(`删除成功!`);
this.queryTable();
this.http.get('/sysapi/setting/role/users/' + item.rid).subscribe((response) => {
if (response.is_success) {
if (response.body && response.body.length > 0) {
this.message.error('删除失败,请删除此角色下的用户后再执行此操作!')
} else {
this.http.delete('/sysapi/setting/role/delete/' + item.rid).subscribe((json) => {
if (json.is_success) {
this.message.success(`删除成功!`);
this.queryTable();
} else {
this.message.error(`删除失败!`)
}
})
}
} else {
this.message.error(`删除失败`)
this.message.error('获取此角色下的用户列表失败!')
}
})
}
@@ -76,7 +76,7 @@
<nz-form-label nzSpan="7" nzFor="identify_num">身份证号</nz-form-label>
<nz-form-control nzSpan="12">
<input nz-input id="identify_num" formControlName="identify_num" placeholder="请输入身份证号">
<nz-form-explain *ngIf="validateForm.get('identify_num').dirty && validateForm.get('identify_num').errors?.maxlength">身份证号最长20个字符</nz-form-explain>
<nz-form-explain *ngIf="validateForm.get('identify_num').dirty && validateForm.get('identify_num').errors?.maxlength">身份证号最长18个字符</nz-form-explain>
</nz-form-control>
</nz-form-item>
</div>