Browse Source

[完善]用户管理对接接口

非煤矿山灾害智能感知和预警系统
邵佳豪 3 years ago
parent
commit
bf60f04153
  1. 25
      src/app/home/system-management/role/role.component.ts
  2. 3
      src/app/home/system-management/system-management.component.ts
  3. 25
      src/app/home/system-management/user/adduser/adduser.component.html
  4. 66
      src/app/home/system-management/user/adduser/adduser.component.ts
  5. 45
      src/app/home/system-management/user/edituser/edituser.component.html
  6. 101
      src/app/home/system-management/user/edituser/edituser.component.ts
  7. 63
      src/app/home/system-management/user/user.component.html
  8. 33
      src/app/home/system-management/user/user.component.scss
  9. 217
      src/app/home/system-management/user/user.component.ts
  10. 5
      src/theme.less

25
src/app/home/system-management/role/role.component.ts

@ -19,8 +19,6 @@ export class RoleComponent implements OnInit {
this.getAllRoles()
}
//获取角色列表
isLoading = false
async getAllRoles() {
@ -40,7 +38,6 @@ export class RoleComponent implements OnInit {
})
}
addRole() {
const modal = this.modal.create({
nzTitle: '新增角色',
@ -56,14 +53,15 @@ export class RoleComponent implements OnInit {
}
this.http.post('/api/Roles', body).subscribe({
next: async (data) => {
await this.getAllRoles()
this.message.create('success', '创建成功');
resolve(data)
await this.getAllRoles()
return true
},
error: (err) => {
this.isLoading = false
this.message.create('warning', '创建失败');
return true
}
})
})
@ -84,7 +82,7 @@ export class RoleComponent implements OnInit {
nzViewContainerRef: this.viewContainerRef,
nzWidth: 400,
nzComponentParams: {
data: item
data: JSON.parse(JSON.stringify(item))
},
nzMaskClosable: false,
nzOnOk: async () => {
@ -95,9 +93,10 @@ export class RoleComponent implements OnInit {
}
this.http.patch(`/api/Roles/${item.id}`, body).subscribe({
next: async (data) => {
await this.getAllRoles()
resolve(data)
this.message.create('success', '修改成功');
await this.getAllRoles()
return true
},
error: (err) => {
@ -124,7 +123,8 @@ export class RoleComponent implements OnInit {
}
this.http.patch(`/api/Roles/${item.id}`, body).subscribe({
next: async (data) => {
await this.getAllRoles()
this.isLoading = false
item.enabled = type
this.message.create('success', '修改成功');
},
error: (err) => {
@ -139,9 +139,16 @@ export class RoleComponent implements OnInit {
nzOkText: '确定',
nzOkType: 'primary',
nzOnOk: () => {
this.isLoading = true
this.http.delete(`/api/Roles/${item.id}`).subscribe({
next: async (data) => {
await this.getAllRoles()
next: (data) => {
this.isLoading = false
this.listOfData.forEach((element, index) => {
if (element.id == item.id) {
this.listOfData.splice(index, 1)
this.listOfData = [...this.listOfData]
}
});
this.message.create('success', '删除成功');
},
error: (err) => {

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

@ -10,7 +10,6 @@ export class SystemManagementComponent implements OnInit {
constructor() { }
ngOnInit(): void {
// CustomReuseStrategy.deleteRouteSnapshot('/basicInfo/unit');
}
}

25
src/app/home/system-management/user/adduser/adduser.component.html

@ -1,18 +1,26 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="账号">账号</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="登陆账号">登陆账号</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="account" placeholder="请输入账号" />
<input nz-input type="text" formControlName="account" placeholder="请输入登陆账号" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="姓名">姓名</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="真实姓名">真实姓名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="name" placeholder="请输入姓名" />
<input nz-input type="text" formControlName="name" placeholder="请输入真实姓名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="电子邮箱">电子邮箱</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="email" placeholder="请输入电子邮箱" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
@ -35,11 +43,12 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="手机号">手机号</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="角色">角色</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="phonenum" placeholder="请输入手机号" />
</nz-input-group>
<nz-select formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple">
<nz-option *ngFor="let item of listOfData" [nzValue]="item.id" [nzLabel]="item.name">
</nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</form>

66
src/app/home/system-management/user/adduser/adduser.component.ts

@ -11,77 +11,43 @@ import { TreeService } from 'src/app/service/tree.service';
})
export class AdduserComponent implements OnInit {
@Input() title?: string;
@Input() subtitle?: string;
@Input() nodes?: any;
@Input() roleList?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
ngOnInit(): void {
this.validateForm = this.fb.group({
account: [null, [Validators.required]],
name: [null, [Validators.required]],
email: [null],
organization: [null, [Validators.required]],
role: [[], [Validators.required]],
role2: [[]],
phonenum: [null, [Validators.required]]
role: [[], [Validators.required]]
});
this.getAllRoles()
this.getAllRoles2()
this.getAllOrganization()
if (this.roleList.length == 0) {
this.getAllRoles()
} else {
this.listOfData = this.roleList
}
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
listOfData: any[] = [];
listOfData2: any[] = [];
//获取角色列表
getAllRoles() {
let params = {
SkipCount: '0',
MaxResultCount: '999'
}
this.http.get('/api/services/app/Role/GetAll', {
params: params
}).subscribe((data: any) => {
// console.log('角色列表', data.result.items)
this.listOfData = data.result.items
})
}
//获取角色列表
getAllRoles2() {
let params = {
SkipCount: '0',
MaxResultCount: '999',
IsViolationRoles:'true'
}
this.http.get('/api/services/app/Role/GetAll', {
params: params
}).subscribe((data: any) => {
// console.log('角色列表', data.result.items)
this.listOfData2 = data.result.items
})
}
//获取所有组织机构
nodes: any = []
getAllOrganization() {
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id
let params = {
OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true"
PageNumber: 1,
PageSize: 100
}
this.http.get('/api/services/app/Organization/GetAll', {
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
data.result.items.forEach(element => {
if (element.id == OrganizationUnitId) {
element.parentId = null
}
element.key = element.id
element.title = element.displayName
});
this.nodes = [...this.toTree.toTree(data.result.items)]
this.listOfData = data.items
})
}
}

45
src/app/home/system-management/user/edituser/edituser.component.html

@ -1,19 +1,26 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="账号">账号</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="登陆账号">登陆账号</nz-form-label>
<nz-form-control>
<nz-input-group>
<input [(ngModel)]="data.userName" nz-input type="text" formControlName="account"
placeholder="请输入账号" />
<input nz-input type="text" formControlName="account" placeholder="请输入登陆账号" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="姓名">姓名</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="真实姓名">真实姓名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input [(ngModel)]="data.name" nz-input type="text" formControlName="name" placeholder="请输入姓名" />
<input nz-input type="text" formControlName="name" placeholder="请输入真实姓名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="电子邮箱">电子邮箱</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="email" placeholder="请输入电子邮箱" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
@ -21,8 +28,8 @@
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="所属机构">所属机构</nz-form-label>
<nz-form-control>
<nz-tree-select [nzShowSearch]='true' [nzDropdownClassName]="'maxHeightTreeSelect'"
[(ngModel)]="data.organizationUnitId" formControlName="organization" [nzNodes]="nodes"
nzPlaceHolder="请选择所属机构" [nzExpandedIcon]="multiExpandedIconTpl">
formControlName="organization" [nzNodes]="nodes" nzPlaceHolder="请选择所属机构"
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree-select>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
@ -35,34 +42,14 @@
</ng-template>
</nz-form-control>
</nz-form-item>
<!-- <nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="角色">角色</nz-form-label>
<nz-form-control>
<nz-select formControlName="role" nzPlaceHolder="请选择角色" nzMode="multiple">
<nz-option *ngFor="let item of listOfData" [nzValue]="item.normalizedName"
[nzLabel]="item.displayName">
</nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="预警接收级别">预警接收级别</nz-form-label>
<nz-form-control>
<nz-select formControlName="role2" nzPlaceHolder="请选择预警接收级别" nzMode="multiple">
<nz-option *ngFor="let item of listOfData2" [nzValue]="item.normalizedName"
[nzLabel]="item.displayName">
<nz-option *ngFor="let item of listOfData" [nzValue]="item.id" [nzLabel]="item.name">
</nz-option>
</nz-select>
</nz-form-control>
</nz-form-item> -->
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="手机号">手机号</nz-form-label>
<nz-form-control>
<nz-input-group>
<input [(ngModel)]="data.phoneNumber" nz-input type="text" formControlName="phonenum"
placeholder="请输入手机号" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
</form>
</div>

101
src/app/home/system-management/user/edituser/edituser.component.ts

@ -2,8 +2,6 @@ import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
@Component({
selector: 'app-edituser',
templateUrl: './edituser.component.html',
@ -11,101 +9,46 @@ import { TreeService } from 'src/app/service/tree.service';
})
export class EdituserComponent implements OnInit {
@Input() data?: any;
@Input() listOfData?: any;
@Input() listOfData2?: any;
@Input() nodes?: any;
@Input() data?: any;
@Input() roleList?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
ngOnInit(): void {
console.log(this.data)
let roleData1 = []
let roleData2 = []
this.data.roleNames.forEach(element => {
if (element.indexOf('LEVEL') != -1) {
roleData2.push(element)
} else {
roleData1.push(element)
}
let rolesId = []
this.data.roles.forEach(element => {
rolesId.push(element.id)
});
this.validateForm = this.fb.group({
account: [null, [Validators.required]],
name: [null, [Validators.required]],
organization: [null, [Validators.required]],
role: [roleData1, [Validators.required]],
role2: [roleData2],
phonenum: [null, [Validators.required]]
account: [this.data.username, [Validators.required]],
name: [this.data.name, [Validators.required]],
email: [this.data.email],
organization: [this.data.organizationId, [Validators.required]],
role: [rolesId, [Validators.required]]
});
if (this.listOfData.length == 0) {
if (this.roleList.length == 0) {
this.getAllRoles()
}
if (this.listOfData2.length == 0) {
this.getAllRoles2()
}
if (this.nodes.length == 0) {
this.getAllOrganization()
} else {
this.listOfData = this.roleList
}
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
listOfData: any[] = [];
//获取角色列表
async getAllRoles() {
let params = {
SkipCount: '0',
MaxResultCount: '999'
}
await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Role/GetAll', {
params: params
}).subscribe((data: any) => {
resolve(data)
this.listOfData = data.result.items
})
})
}
//获取角色列表
async getAllRoles2() {
let params = {
SkipCount: '0',
MaxResultCount: '999',
IsViolationRoles: 'true'
}
await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Role/GetAll', {
params: params
}).subscribe((data: any) => {
resolve(data)
this.listOfData2 = data.result.items
})
})
}
//获取所有组织机构
async getAllOrganization() {
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id
getAllRoles() {
let params = {
OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true"
PageNumber: 1,
PageSize: 100
}
await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Organization/GetAll', {
params: params
}).subscribe((data: any) => {
data.result.items.forEach(element => {
if (element.id == OrganizationUnitId) {
element.parentId = null
}
element.key = element.id
element.title = element.displayName
});
this.nodes = [...this.toTree.toTree(data.result.items)]
resolve(data)
})
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
this.listOfData = data.items
})
}

63
src/app/home/system-management/user/user.component.html

@ -6,51 +6,66 @@
</div>
<div class="searchbox">
<div class="search">
<input type="text" nz-input placeholder="用户账号" [(ngModel)]="searchForm.id" />
<input type="text" nz-input placeholder="用户姓名" [(ngModel)]="searchForm.name" />
<input type="text" nz-input placeholder="所属机构" [(ngModel)]="searchForm.or" />
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>查询</button>
<button nz-button nzType="default"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button>
<nz-tree-select [nzExpandedKeys]="expandKeys" [nzNodes]="nodes" nzShowSearch nzPlaceHolder="所属机构"
[(ngModel)]="searchForm.or" [nzExpandedIcon]="multiExpandedIconTpl"
[nzDropdownClassName]="'maxHeightTreeSelect'" [nzAllowClear]="false"></nz-tree-select>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
</ng-container>
<ng-template #elseTemplate>
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'"
class="ant-tree-switcher-line-icon"></i>
</ng-template>
</ng-template>
<button (click)="search()" nz-button nzType="primary"><i nz-icon nzType="search"
nzTheme="outline"></i>查询</button>
<button (click)="reset()" nz-button nzType="default"><i nz-icon nzType="reload"
nzTheme="outline"></i>重置</button>
</div>
<button nz-button nzType="primary" (click)="addUser()"><i nz-icon nzType="plus-circle" nzTheme="outline"></i>创建用户</button>
<button nz-button nzType="primary" (click)="addUser()"><i nz-icon nzType="plus-circle"
nzTheme="outline"></i>创建用户</button>
</div>
<div class="content">
<div class="tablebox">
<nz-table nzBordered #basicTable [nzLoading]="loading" [nzData]="usersLIst" [nzShowPagination]='false'
<nz-table nzBordered #basicTable [nzLoading]="isLoading" [nzData]="userList" [nzShowPagination]='false'
[nzPageSize]='16'>
<thead>
<tr>
<th>账号</th>
<th>姓名</th>
<th [width]="'30%'">角色/预警接收级别</th>
<th>登陆账号</th>
<th>真实姓名</th>
<th>所属机构</th>
<th>审核状态</th>
<th>用户状态</th>
<th [width]="'25%'">操作</th>
<th>角色</th>
<th>创建时间</th>
<th [width]="'20%'">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of basicTable.data">
<td>2</td>
<td>3</td>
<td nzBreakWord>
4
<td>
{{item.username}}
</td>
<td>item
5
<td>
{{item.name}}
</td>
<td>
{{item.organizationName}}
</td>
<td>
6
<span *ngFor="let i of item.roles">
{{i.name}}
</span>
</td>
<td>
8
{{item.creationTime | date:"yyyy-MM-dd"}}
</td>
<td class="operation">
<a (click)="editUser(item)">编辑</a>
<a (click)="resetPassword(item)">重置密码</a>
<a class="green" (click)="cancel(item,true)">启用</a>
<!-- <a *ngIf="item.isActive" class="redColor" (click)="cancel(item,false)">禁用</a> -->
<!-- <a *ngIf="!item.enabled" class="green" (click)="cancel(item,true)">启用</a>
<a *ngIf="item.enabled" class="redColor" (click)="cancel(item,false)">禁用</a> -->
<a class="red" (click)="delete(item)">删除</a>
</td>
</tr>
@ -58,10 +73,10 @@
</nz-table>
</div>
<div class="pagination">
<nz-pagination [nzHideOnSinglePage]="false" [nzPageIndex]="1" [nzTotal]="usersNum" [nzPageSize]="16"
<nz-pagination [nzHideOnSinglePage]="false" [nzPageIndex]="1" [nzTotal]="totalCount" [nzPageSize]="16"
[nzShowTotal]="totalTemplate" nzShowQuickJumper (nzPageIndexChange)="pageChange($event)">
</nz-pagination>
<ng-template #totalTemplate let-total> 16条/页,共{{usersNum}}条 </ng-template>
<ng-template #totalTemplate let-total> 16条/页,共{{totalCount}}条 </ng-template>
</div>
</div>
</div>

33
src/app/home/system-management/user/user.component.scss

@ -21,32 +21,45 @@
}
}
.searchbox{
.searchbox {
height: 70px;
display: flex;
justify-content: space-between;
padding: 0 20px;
align-items: center;
.search{
width: 60%;
display: flex;
input{
margin-right: 16px;
}
button{
margin-right: 16px;
}
.search {
width: 50%;
display: flex;
input,
nz-tree-select {
text-align: left;
width: 250px;
margin-right: 16px;
}
button {
margin-right: 16px;
}
}
}
.content {
flex: 1;
box-sizing: border-box;
padding: 18px;
padding-top: 0px;
.operation {
a {
margin-right: 16px;
}
}
.pagination {
display: flex;
// justify-content: flex-start;
}
}
}

217
src/app/home/system-management/user/user.component.ts

@ -14,56 +14,146 @@ import { TreeService } from 'src/app/service/tree.service';
})
export class UserComponent implements OnInit {
validateForm!: FormGroup;
constructor(private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { }
searchForm = {
id: '',
name: '',
or: ''
}
usersNum
loading
usersLIst = [1]
userList = []
ngOnInit(): void {
this.getAllOrganization()
this.getAllRoles()
}
//获取角色列表
roleList
getAllRoles() {
let params = {
PageNumber: 1,
PageSize: 100
}
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
this.roleList = data.items
})
}
pageChange($event) {
this.PageNumber = $event
this.getAllUsers()
}
//获取用户列表
isLoading = false
totalCount
PageNumber = 1
PageSize = 16
async getAllUsers() {
this.isLoading = true
let params = {
Name: this.searchForm.name,
OrganizationId: this.searchForm.or,
PageNumber: this.PageNumber,
PageSize: this.PageSize,
ContainsChildren: 'true'
}
await new Promise<void>((resolve, reject) => {
this.http.get('/api/Users', {
params: params
}).subscribe((data: any) => {
this.isLoading = false
this.userList = data.items
this.totalCount = data.totalCount
console.log('用户列表', data)
resolve(data)
})
})
}
search() {
this.PageNumber = 1
this.getAllUsers()
}
reset() {
this.PageNumber = 1
this.searchForm = {
name: '',
or: JSON.parse(sessionStorage.getItem('userData')).organizationId
}
this.getAllUsers()
}
expandKeys
defaultOrId: string
//获取所有组织机构
nodes: any = []
getAllOrganization() {
let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
let params = {
OrganizationId: organizationId || '',
ContainsChildren: "true",
PageNumber: 1,
PageSize: 9999
}
this.http.get('/api/Organizations', {
params: params
}).subscribe((data: any) => {
console.log('xxx', data)
data.items.forEach(element => {
if (element.id == organizationId) {
element.parentId = null
}
element.key = element.id
element.title = element.name
});
this.nodes = [...this.toTree.toTree(data.items)]
this.searchForm.or = JSON.parse(sessionStorage.getItem('userData')).organizationId
this.getAllUsers()
})
}
//新增用户
addUser(): void {
if (this.nodes.length == 0) {
this.message.create('warning', '请组织机构加载完毕后重试');
return
}
const modal = this.modal.create({
nzTitle: '新增用户',
nzContent: AdduserComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 460,
nzWidth: 485,
nzMaskClosable: false,
nzComponentParams: {
title: '',
subtitle: ''
nodes: this.nodes,
roleList: this.roleList
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
let roleNames = [...instance.validateForm.value.role, ...instance.validateForm.value.role2]
await new Promise((resolve, reject) => {
let body = {
userName: instance.validateForm.value.account,
username: instance.validateForm.value.account,
name: instance.validateForm.value.name,
organizationUnitId: Number(instance.validateForm.value.organization),
roleNames: roleNames,
phoneNumber: instance.validateForm.value.phonenum,
isActive: true
email: instance.validateForm.value.email,
organizationId: instance.validateForm.value.organization,
roleIds: instance.validateForm.value.role,
}
// this.http.post(this.addUrl, body).subscribe(data => {
// resolve(data)
// this.message.create('success', '创建成功!');
// this.SkipCount = 0
// this.getAllUsers()
// return true
// }, err => {
// resolve(err)
// this.message.create('warning', err.error.error.message);
// return false
// })
this.http.post('/api/Users', body).subscribe({
next: async (data) => {
this.message.create('success', '创建成功');
resolve(data)
await this.getAllUsers()
return true
},
error: (err) => {
this.isLoading = false
this.message.create('warning', '创建失败');
reject(err)
return false
}
})
})
} else {
this.message.create('warning', '请填写完整!');
@ -77,48 +167,45 @@ export class UserComponent implements OnInit {
}
//编辑用户
editUser(data): void {
console.log(data)
editUser(item): void {
if (this.nodes.length == 0) {
this.message.create('warning', '请组织机构加载完毕后重试');
return
}
const modal = this.modal.create({
nzTitle: '编辑用户',
nzContent: EdituserComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 460,
nzWidth: 485,
nzMaskClosable: false,
nzComponentParams: {
data: data
nodes: this.nodes,
data: JSON.parse(JSON.stringify(item)),
roleList: this.roleList
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
for (let index = 0; index < instance.validateForm.value.role2.length; index++) {
const element = instance.validateForm.value.role2[index];
if (element.indexOf('HANDLE') != -1) {
instance.validateForm.value.role2.splice(index, 1)
index--
}
}
let roleNames = [...instance.validateForm.value.role, ...instance.validateForm.value.role2]
let body = {
id: data.id,
userName: instance.validateForm.value.account,
username: instance.validateForm.value.account,
name: instance.validateForm.value.name,
organizationUnitId: instance.validateForm.value.organization,
roleNames: roleNames,
phoneNumber: instance.validateForm.value.phonenum,
isActive: true
email: instance.validateForm.value.email,
organizationId: instance.validateForm.value.organization,
roleIds: instance.validateForm.value.role,
}
// this.http.put(this.editUrl, body).subscribe(data => {
// resolve(data)
// this.message.create('success', '编辑成功!');
// this.getAllUsers()
// return true
// }, err => {
// resolve(err)
// this.message.create('warning', '编辑失败');
// return false
// })
this.http.patch(`/api/Users/${item.id}`, body).subscribe({
next: async (data) => {
this.message.create('success', '创建成功');
resolve(data)
await this.getAllUsers()
return true
},
error: (err) => {
this.isLoading = false
this.message.create('warning', '创建失败');
return true
}
})
})
} else {
this.message.create('warning', '请填写完整!');
@ -131,16 +218,12 @@ export class UserComponent implements OnInit {
//重置密码
resetPassword(item) {
console.log(item)
this.modal.confirm({
nzTitle: `确定要重置${item.userName}这个账户的密码吗?`,
nzTitle: `确定要重置${item.name}这个账户的密码吗?`,
nzOkText: '确定',
nzOkType: 'primary',
nzOnOk: () => {
let body = {
userId: item.id
}
this.http.post('/api/services/app/User/ResetPassword', body).subscribe(data => {
this.http.patch(`/api/Users/${item.id}/Password`, null).subscribe(data => {
this.message.create('success', '重置成功!');
})
},
@ -150,10 +233,22 @@ export class UserComponent implements OnInit {
}
});
}
//禁用
cancel(item, type) {
}
delete(item) {
this.modal.confirm({
nzTitle: `确定要删除${item.name}这个用户吗?`,
nzOkText: '确定',
nzOkType: 'default',
nzOnOk: () => {
this.http.delete(`/api/Users/${item.id}`).subscribe(data => {
this.message.create('success', '删除成功!');
this.getAllUsers()
})
},
nzCancelText: '取消'
});
}
}

5
src/theme.less

@ -79,3 +79,8 @@
}
}
.maxHeightTreeSelect {
max-height: 280px;
}

Loading…
Cancel
Save