From bf60f04153d0a3ec1cc66dfaf0d44c90ee6733af Mon Sep 17 00:00:00 2001
From: SHAOJIAHAO <55341701@qq.com>
Date: Wed, 10 Aug 2022 13:49:08 +0800
Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E7=94=A8=E6=88=B7=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system-management/role/role.component.ts | 25 +-
.../system-management.component.ts | 3 +-
.../user/adduser/adduser.component.html | 25 +-
.../user/adduser/adduser.component.ts | 66 ++----
.../user/edituser/edituser.component.html | 45 ++--
.../user/edituser/edituser.component.ts | 101 ++------
.../user/user.component.html | 63 +++--
.../user/user.component.scss | 33 ++-
.../system-management/user/user.component.ts | 217 +++++++++++++-----
src/theme.less | 5 +
10 files changed, 311 insertions(+), 272 deletions(-)
diff --git a/src/app/home/system-management/role/role.component.ts b/src/app/home/system-management/role/role.component.ts
index 020feb1..d4b2018 100644
--- a/src/app/home/system-management/role/role.component.ts
+++ b/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) => {
diff --git a/src/app/home/system-management/system-management.component.ts b/src/app/home/system-management/system-management.component.ts
index 035baec..17d2579 100644
--- a/src/app/home/system-management/system-management.component.ts
+++ b/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');
+
}
-
}
diff --git a/src/app/home/system-management/user/adduser/adduser.component.html b/src/app/home/system-management/user/adduser/adduser.component.html
index bb95809..21d9de4 100644
--- a/src/app/home/system-management/user/adduser/adduser.component.html
+++ b/src/app/home/system-management/user/adduser/adduser.component.html
@@ -1,18 +1,26 @@
diff --git a/src/app/home/system-management/user/adduser/adduser.component.ts b/src/app/home/system-management/user/adduser/adduser.component.ts
index fa3827f..b6ac817 100644
--- a/src/app/home/system-management/user/adduser/adduser.component.ts
+++ b/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
})
}
+
}
diff --git a/src/app/home/system-management/user/edituser/edituser.component.html b/src/app/home/system-management/user/edituser/edituser.component.html
index 3dce691..21d9de4 100644
--- a/src/app/home/system-management/user/edituser/edituser.component.html
+++ b/src/app/home/system-management/user/edituser/edituser.component.html
@@ -1,19 +1,26 @@
\ No newline at end of file
diff --git a/src/app/home/system-management/user/edituser/edituser.component.ts b/src/app/home/system-management/user/edituser/edituser.component.ts
index 4e3ecdf..ea91816 100644
--- a/src/app/home/system-management/user/edituser/edituser.component.ts
+++ b/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
((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((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((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
})
}
diff --git a/src/app/home/system-management/user/user.component.html b/src/app/home/system-management/user/user.component.html
index 6d4cedc..d687c08 100644
--- a/src/app/home/system-management/user/user.component.html
+++ b/src/app/home/system-management/user/user.component.html
@@ -6,51 +6,66 @@
-
- 账号 |
- 姓名 |
- 角色/预警接收级别 |
+ 登陆账号 |
+ 真实姓名 |
所属机构 |
- 审核状态 |
- 用户状态 |
- 操作 |
+ 角色 |
+ 创建时间 |
+ 操作 |
- 2 |
- 3 |
-
- 4
+ |
+ {{item.username}}
|
- item
- 5
+ |
+ {{item.name}}
+ |
+
+ {{item.organizationName}}
|
- 6
+
+ {{i.name}}
+
|
- 8
+ {{item.creationTime | date:"yyyy-MM-dd"}}
|
编辑
重置密码
- 启用
-
+
删除
|
@@ -58,10 +73,10 @@
\ No newline at end of file
diff --git a/src/app/home/system-management/user/user.component.scss b/src/app/home/system-management/user/user.component.scss
index fa6a0e6..1571578 100644
--- a/src/app/home/system-management/user/user.component.scss
+++ b/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;
+ }
}
}
diff --git a/src/app/home/system-management/user/user.component.ts b/src/app/home/system-management/user/user.component.ts
index 4672e0a..f506a2a 100644
--- a/src/app/home/system-management/user/user.component.ts
+++ b/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((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: '取消'
+ });
}
}
diff --git a/src/theme.less b/src/theme.less
index 639308e..d9f8e38 100644
--- a/src/theme.less
+++ b/src/theme.less
@@ -79,3 +79,8 @@
}
}
+
+
+.maxHeightTreeSelect {
+ max-height: 280px;
+}