Browse Source

[完善]编辑框打开时loading控制

dev
邵佳豪 3 years ago
parent
commit
79e429ee8d
  1. 3
      src/app/system-management/role/editrole/editrole.component.ts
  2. 3
      src/app/system-management/role/role.component.ts
  3. 2
      src/app/system-management/user/adduser/adduser.component.html
  4. 2
      src/app/system-management/user/edituser/edituser.component.html
  5. 22
      src/app/system-management/user/edituser/edituser.component.ts
  6. 4
      src/app/system-management/user/user.component.ts

3
src/app/system-management/role/editrole/editrole.component.ts

@ -31,7 +31,8 @@ export class EditroleComponent implements OnInit {
loadMore() { loadMore() {
this.http.get('/api/services/app/Role/GetAllPermissions').subscribe((data:any) => { this.http.get('/api/services/app/Role/GetAllPermissions').subscribe((data:any) => {
this.optionList = data.result.items this.optionList = data.result.items
console.log('所有权限',data) this.modal.containerInstance.config.nzOkLoading = false
// console.log('所有权限',data)
}) })
} }

3
src/app/system-management/role/role.component.ts

@ -75,7 +75,8 @@ export class RoleComponent implements OnInit {
nzTitle: '编辑角色', nzTitle: '编辑角色',
nzContent: EditroleComponent, nzContent: EditroleComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 288, nzWidth: 325,
nzOkLoading: true,
nzComponentParams: { nzComponentParams: {
data: item data: item
}, },

2
src/app/system-management/user/adduser/adduser.component.html

@ -24,7 +24,7 @@
<nz-form-item> <nz-form-item>
<nz-form-control> <nz-form-control>
<nz-select formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple"> <nz-select formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple">
<nz-option *ngFor="let item of listOfData" [nzValue]="item.name" [nzLabel]="item.displayName"></nz-option> <nz-option *ngFor="let item of listOfData" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"></nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>

2
src/app/system-management/user/edituser/edituser.component.html

@ -24,7 +24,7 @@
<nz-form-item> <nz-form-item>
<nz-form-control> <nz-form-control>
<nz-select [(ngModel)]="data.roleNames" formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple"> <nz-select [(ngModel)]="data.roleNames" formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple">
<nz-option *ngFor="let item of listOfData" [nzValue]="item.name" [nzLabel]="item.displayName"></nz-option> <nz-option *ngFor="let item of listOfData" [nzValue]="item.normalizedName" [nzLabel]="item.displayName"></nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>

22
src/app/system-management/user/edituser/edituser.component.ts

@ -23,11 +23,9 @@ export class EdituserComponent implements OnInit {
role: [null, [Validators.required]], role: [null, [Validators.required]],
phonenum: [null, [Validators.required]] phonenum: [null, [Validators.required]]
}); });
Promise.all([this.getAllRoles(), this.getAllOrganization()]).then(()=>{
this.modal.containerInstance.config.nzOkLoading = false
console.log(this.data) })
this.getAllRoles()
this.getAllOrganization()
} }
destroyModal(): void { destroyModal(): void {
this.modal.destroy({ data: 'this the result data' }); this.modal.destroy({ data: 'this the result data' });
@ -36,20 +34,23 @@ export class EdituserComponent implements OnInit {
listOfData: any[] = []; listOfData: any[] = [];
//获取角色列表 //获取角色列表
getAllRoles() { async getAllRoles() {
await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Role/GetAll').subscribe((data: any) => { this.http.get('/api/services/app/Role/GetAll').subscribe((data: any) => {
console.log('角色列表', data.result.items) resolve(data)
this.listOfData = data.result.items this.listOfData = data.result.items
}) })
})
} }
//获取所有组织机构 //获取所有组织机构
nodes:any = [] nodes: any = []
getAllOrganization() { async getAllOrganization() {
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id
let params = { let params = {
OrganizationUnitId: OrganizationUnitId, OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true" IsContainsChildren: "true"
} }
await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Organization/GetAll', { this.http.get('/api/services/app/Organization/GetAll', {
params: params params: params
}).subscribe((data: any) => { }).subscribe((data: any) => {
@ -58,7 +59,8 @@ export class EdituserComponent implements OnInit {
element.title = element.displayName element.title = element.displayName
}); });
this.nodes = [...this.toTree.toTree(data.result.items)] this.nodes = [...this.toTree.toTree(data.result.items)]
resolve(data)
})
}) })
} }
} }

4
src/app/system-management/user/user.component.ts

@ -71,6 +71,7 @@ export class UserComponent implements OnInit {
subtitle: '' subtitle: ''
}, },
nzOnOk: async () => { nzOnOk: async () => {
// console.log(instance.validateForm.value)
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise(resolve => { await new Promise(resolve => {
let body = { let body = {
@ -114,6 +115,7 @@ export class UserComponent implements OnInit {
nzContent: EdituserComponent, nzContent: EdituserComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 288, nzWidth: 288,
nzOkLoading: true,
nzComponentParams: { nzComponentParams: {
data: data, data: data,
}, },
@ -122,7 +124,7 @@ export class UserComponent implements OnInit {
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise(resolve => { await new Promise(resolve => {
let body = { let body = {
id:data.id, id: data.id,
userName: instance.validateForm.value.account, userName: instance.validateForm.value.account,
name: instance.validateForm.value.name, name: instance.validateForm.value.name,
organizationUnitId: instance.validateForm.value.organization, organizationUnitId: instance.validateForm.value.organization,

Loading…
Cancel
Save