Browse Source

[新增]用户手机号

master
邵佳豪 2 weeks ago
parent
commit
2e9f15c5e9
  1. 3892
      package-lock.json
  2. 4
      package.json
  3. 7
      src/app/app.component.ts
  4. 3
      src/app/home/system-management/user/adduser/adduser.component.html
  5. 37
      src/app/home/system-management/user/adduser/adduser.component.ts
  6. 3
      src/app/home/system-management/user/edituser/edituser.component.html
  7. 49
      src/app/home/system-management/user/edituser/edituser.component.ts
  8. 6
      src/app/home/system-management/user/user.component.html
  9. 312
      src/app/home/system-management/user/user.component.ts
  10. 6
      src/app/home/task/da-monthly-task-overview/da-monthly-task-overview.component.html
  11. 2
      src/app/home/task/station-task-execution/station-task-execution.component.html

3892
package-lock.json generated

File diff suppressed because it is too large Load Diff

4
package.json

@ -30,6 +30,8 @@
"ngx-echarts": "^14.0.0",
"qs": "^6.11.0",
"rxjs": "~7.4.0",
"sm-crypto": "^0.3.13",
"sm-crypto-v2": "^1.9.3",
"tslib": "^2.3.0",
"viewerjs": "^1.10.5",
"zone.js": "~0.11.4"
@ -48,6 +50,6 @@
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"resize-observer-polyfill": "^1.5.1",
"typescript": "~4.5.2"
"typescript": "4.5"
}
}

7
src/app/app.component.ts

@ -4,14 +4,15 @@ import { CacheTokenService } from './service/cache-token.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
constructor(public token: CacheTokenService) { }
constructor(public token: CacheTokenService) {}
ngOnInit() {
console.log('更新时间', 20241118);
if (sessionStorage.getItem('token') && !this.token.timer) {
//调用服务中的function刷新token
this.token.startUp()
this.token.startUp();
}
}
}

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

@ -60,5 +60,8 @@
</nz-select>
</nz-form-control>
</nz-form-item>
</form>
<div (click)="addPhone()" style="cursor: pointer;">添加手机号</div>
<input *ngFor="let item of phone; let i = index" [(ngModel)]="item.num" nz-input type="text" placeholder="请添加手机号" />
</div>

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

@ -7,14 +7,17 @@ import { TreeService } from 'src/app/service/tree.service';
@Component({
selector: 'app-adduser',
templateUrl: './adduser.component.html',
styleUrls: ['./adduser.component.scss']
styleUrls: ['./adduser.component.scss'],
})
export class AdduserComponent implements OnInit {
@Input() nodes?: any;
@Input() roleList?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
constructor(
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient
) {}
ngOnInit(): void {
this.validateForm = this.fb.group({
@ -23,15 +26,14 @@ export class AdduserComponent implements OnInit {
email: [null],
organization: [null, [Validators.required]],
role: [[]],
posts: [[]]
posts: [[]],
});
if (this.roleList.length == 0) {
this.getAllRoles()
this.getAllRoles();
} else {
this.listOfData = this.roleList
this.listOfData = this.roleList;
}
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
@ -42,13 +44,18 @@ export class AdduserComponent implements OnInit {
getAllRoles() {
let params = {
PageNumber: 1,
PageSize: 100
}
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
this.listOfData = data.items
})
PageSize: 100,
};
this.http
.get('/api/Roles', {
params: params,
})
.subscribe((data: any) => {
this.listOfData = data.items;
});
}
phone = [];
addPhone() {
this.phone.push({ num: '' });
}
}

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

@ -60,5 +60,8 @@
</nz-select>
</nz-form-control>
</nz-form-item>
</form>
<div (click)="addPhone()" style="cursor: pointer;">添加手机号</div>
<input *ngFor="let item of phone; let i = index" [(ngModel)]="item.num" nz-input type="text" placeholder="请添加手机号" />
</div>

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

@ -5,21 +5,24 @@ import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-edituser',
templateUrl: './edituser.component.html',
styleUrls: ['./edituser.component.scss']
styleUrls: ['./edituser.component.scss'],
})
export class EdituserComponent implements OnInit {
@Input() nodes?: any;
@Input() data?: any;
@Input() roleList?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
constructor(
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient
) {}
ngOnInit(): void {
console.log(this.data)
let rolesId = []
this.data.roles.forEach(element => {
rolesId.push(element.id)
console.log(this.data);
let rolesId = [];
this.data.roles.forEach((element) => {
rolesId.push(element.id);
});
this.validateForm = this.fb.group({
account: [this.data.username, [Validators.required]],
@ -27,13 +30,19 @@ export class EdituserComponent implements OnInit {
email: [this.data.email],
organization: [this.data.organizationId, [Validators.required]],
role: [rolesId],
posts: [this.data.posts]
posts: [this.data.posts],
});
if (this.roleList.length == 0) {
this.getAllRoles()
this.getAllRoles();
} else {
this.listOfData = this.roleList
this.listOfData = this.roleList;
}
this.phone = this.data.phone.map((v) => {
return {
num: v,
};
});
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
@ -44,13 +53,19 @@ export class EdituserComponent implements OnInit {
getAllRoles() {
let params = {
PageNumber: 1,
PageSize: 100
}
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
this.listOfData = data.items
})
PageSize: 100,
};
this.http
.get('/api/Roles', {
params: params,
})
.subscribe((data: any) => {
this.listOfData = data.items;
});
}
phone = [];
addPhone() {
this.phone.push({ num: '' });
}
}

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

@ -39,6 +39,7 @@
<th>角色</th>
<th>职位</th>
<th>创建时间</th>
<th>绑定手机号</th>
<th>状态</th>
<th [width]="'18%'">操作</th>
</tr>
@ -67,6 +68,11 @@
<td>
{{item.creationTime | date:"yyyy-MM-dd"}}
</td>
<td>
<span *ngFor="let i of item.phone">
{{i}}
</span>
</td>
<td>
<ng-container *ngIf="item.enabled; else elseTemplate">
<span class="green">已启用</span>

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

@ -1,60 +1,78 @@
import { Component, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
import {
Component,
OnInit,
TemplateRef,
ViewContainerRef,
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree';
import {
NzFormatEmitEvent,
NzTreeComponent,
NzTreeNodeOptions,
} from 'ng-zorro-antd/tree';
import { NzModalService } from 'ng-zorro-antd/modal';
import { AdduserComponent } from './adduser/adduser.component';
import { NzMessageService } from 'ng-zorro-antd/message';
import { HttpClient } from '@angular/common/http';
import { EdituserComponent } from './edituser/edituser.component';
import { TreeService } from 'src/app/service/tree.service';
import { sm4 } from 'sm-crypto';
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.scss']
styleUrls: ['./user.component.scss'],
})
export class UserComponent implements OnInit {
constructor(private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { }
constructor(
private fb: FormBuilder,
private modal: NzModalService,
private viewContainerRef: ViewContainerRef,
private message: NzMessageService,
private http: HttpClient,
private toTree: TreeService
) {}
searchForm = {
Username: '',
RoleName: '',
name: '',
or: ''
}
or: '',
};
loading
userList = []
loading;
userList = [];
ngOnInit(): void {
this.getAllOrganization()
this.getAllRoles()
this.getAllOrganization();
this.getAllRoles();
}
//获取角色列表
roleList
roleList;
getAllRoles() {
let params = {
PageNumber: 1,
PageSize: 100
}
this.http.get('/api/Roles', {
params: params
}).subscribe((data: any) => {
this.roleList = data.items
})
PageSize: 100,
};
this.http
.get('/api/Roles', {
params: params,
})
.subscribe((data: any) => {
this.roleList = data.items;
});
}
pageChange($event) {
this.PageNumber = $event
this.getAllUsers()
this.PageNumber = $event;
this.getAllUsers();
}
//获取用户列表
isLoading = false
totalCount
PageNumber = 1
PageSize = 16
isLoading = false;
totalCount;
PageNumber = 1;
PageSize = 16;
async getAllUsers() {
this.isLoading = true
this.isLoading = true;
let params = {
Username: this.searchForm.Username,
RoleName: this.searchForm.RoleName,
@ -62,73 +80,90 @@ export class UserComponent implements OnInit {
OrganizationId: this.searchForm.or,
PageNumber: this.PageNumber,
PageSize: this.PageSize,
ContainsChildren: 'true'
}
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)
})
})
this.http
.get('/api/Users', {
params: params,
responseType: 'text',
})
.subscribe((res: any) => {
const key = '258e0ec35ea5c5d2479156be98e9b3e2';
function base64ToHex(base64: string): string {
const binary = atob(base64); // Base64 解码成二进制字符串
return Array.from(binary) // 转换成字节数组
.map((byte) => ('0' + byte.charCodeAt(0).toString(16)).slice(-2)) // 转16进制
.join('');
}
const publicKeyHex = base64ToHex(res);
const data = JSON.parse(sm4.decrypt(publicKeyHex, key) as any);
this.isLoading = false;
this.userList = data.items;
this.totalCount = data.totalCount;
console.log('用户列表', data);
resolve(data);
});
});
}
search() {
this.PageNumber = 1
this.getAllUsers()
this.PageNumber = 1;
this.getAllUsers();
}
reset() {
this.PageNumber = 1
this.PageNumber = 1;
this.searchForm = {
Username: '',
RoleName: '',
name: '',
or: JSON.parse(sessionStorage.getItem('userData')).organizationId
}
this.getAllUsers()
or: JSON.parse(sessionStorage.getItem('userData')).organizationId,
};
this.getAllUsers();
}
expandKeys
defaultOrId: string
expandKeys;
defaultOrId: string;
//获取所有组织机构
nodes: any = []
nodes: any = [];
getAllOrganization() {
let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
let organizationId = JSON.parse(
sessionStorage.getItem('userData')
).organizationId;
let params = {
ContainsChildren: "true",
ContainsChildren: 'true',
PageNumber: 1,
PageSize: 9999,
code: '0000'
}
this.http.get('/api/Organizations', {
params: params
}).subscribe((data: any) => {
console.log(data.items)
data.items.forEach(element => {
if (element.id == organizationId) {
element.parentId = null
}
element.key = element.id
element.title = element.name
if (element.level == 'squadron') {
element.isLeaf = true
}
code: '0000',
};
this.http
.get('/api/Organizations', {
params: params,
})
.subscribe((data: any) => {
console.log(data.items);
data.items.forEach((element) => {
if (element.id == organizationId) {
element.parentId = null;
}
element.key = element.id;
element.title = element.name;
if (element.level == 'squadron') {
element.isLeaf = true;
}
});
this.nodes = [...this.toTree.toTree(data.items)];
this.searchForm.or = JSON.parse(
sessionStorage.getItem('userData')
).organizationId;
this.getAllUsers();
});
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
return;
}
const modal = this.modal.create({
nzTitle: '新增用户',
@ -138,7 +173,7 @@ export class UserComponent implements OnInit {
nzMaskClosable: false,
nzComponentParams: {
nodes: this.nodes,
roleList: this.roleList
roleList: this.roleList,
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
@ -150,38 +185,40 @@ export class UserComponent implements OnInit {
organizationId: instance.validateForm.value.organization,
roleIds: instance.validateForm.value.role,
posts: instance.validateForm.value.posts,
}
};
this.http.post('/api/Users', body).subscribe({
next: async (data) => {
this.message.create('success', '创建成功');
resolve(data)
await this.getAllUsers()
return true
resolve(data);
await this.getAllUsers();
return true;
},
error: (err) => {
this.isLoading = false
this.isLoading = false;
this.message.create('warning', '创建失败');
reject(err)
return false
}
})
})
reject(err);
return false;
},
});
});
} else {
this.message.create('warning', '请填写完整!');
return false
return false;
}
}
},
});
const instance = modal.getContentComponent();
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
modal.afterClose.subscribe((result) =>
console.log('[afterClose] The result is:', result)
);
}
//编辑用户
editUser(item): void {
if (this.nodes.length == 0) {
this.message.create('warning', '请组织机构加载完毕后重试');
return
return;
}
const modal = this.modal.create({
nzTitle: '编辑用户',
@ -192,11 +229,12 @@ export class UserComponent implements OnInit {
nzComponentParams: {
nodes: this.nodes,
data: JSON.parse(JSON.stringify(item)),
roleList: this.roleList
roleList: this.roleList,
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
await new Promise((resolve) => {
let phoneArr = instance.phone.map((v) => v.num);
let body = {
username: instance.validateForm.value.account,
name: instance.validateForm.value.name,
@ -204,26 +242,27 @@ export class UserComponent implements OnInit {
organizationId: instance.validateForm.value.organization,
roleIds: instance.validateForm.value.role,
posts: instance.validateForm.value.posts,
}
phone: phoneArr,
};
this.http.patch(`/api/Users/${item.id}`, body).subscribe({
next: async (data) => {
this.message.create('success', '创建成功');
resolve(data)
await this.getAllUsers()
return true
this.message.create('success', '编辑成功');
resolve(data);
await this.getAllUsers();
return true;
},
error: (err) => {
this.isLoading = false
this.message.create('warning', '创建失败');
return true
}
})
})
this.isLoading = false;
this.message.create('warning', '编辑失败');
return true;
},
});
});
} else {
this.message.create('warning', '请填写完整!');
return false
return false;
}
}
},
});
const instance = modal.getContentComponent();
}
@ -235,31 +274,31 @@ export class UserComponent implements OnInit {
nzOkText: '确定',
nzOkType: 'primary',
nzOnOk: () => {
this.http.patch(`/api/Users/${item.id}/Password`, null).subscribe(data => {
this.message.create('success', '重置成功!');
})
this.http
.patch(`/api/Users/${item.id}/Password`, null)
.subscribe((data) => {
this.message.create('success', '重置成功!');
});
},
nzCancelText: '取消',
nzOnCancel: () => {
}
nzOnCancel: () => {},
});
}
//禁用
cancel(item, type) {
this.isLoading = true
this.isLoading = true;
let body = {
enabled: type
}
enabled: type,
};
this.http.patch(`/api/Users/${item.id}`, body).subscribe({
next: (data) => {
this.isLoading = false
item.enabled = type
this.isLoading = false;
item.enabled = type;
},
error: (err) => {
this.isLoading = false
}
})
this.isLoading = false;
},
});
}
delete(item) {
this.modal.confirm({
@ -267,12 +306,12 @@ export class UserComponent implements OnInit {
nzOkText: '确定',
nzOkType: 'default',
nzOnOk: () => {
this.http.delete(`/api/Users/${item.id}`).subscribe(data => {
this.http.delete(`/api/Users/${item.id}`).subscribe((data) => {
this.message.create('success', '删除成功!');
this.getAllUsers()
})
this.getAllUsers();
});
},
nzCancelText: '取消'
nzCancelText: '取消',
});
}
@ -283,22 +322,23 @@ export class UserComponent implements OnInit {
Name: this.searchForm.name,
OrganizationId: this.searchForm.or,
ContainsChildren: 'true',
ExportToExcel: 'true'
}
this.http.get('/api/Users', {
params: params,
responseType: 'blob' as 'json'
}).subscribe((data: any) => {
const link = document.createElement('a');
const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
link.setAttribute('href', window.URL.createObjectURL(blob));
link.setAttribute('download', '用户列表' + '.xls');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.message.create('success', '导出成功!');
})
ExportToExcel: 'true',
};
this.http
.get('/api/Users', {
params: params,
responseType: 'blob' as 'json',
})
.subscribe((data: any) => {
const link = document.createElement('a');
const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
link.setAttribute('href', window.URL.createObjectURL(blob));
link.setAttribute('download', '用户列表' + '.xls');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.message.create('success', '导出成功!');
});
}
}

6
src/app/home/task/da-monthly-task-overview/da-monthly-task-overview.component.html

@ -458,7 +458,7 @@
</span>
</div>
<div class="flexcol" style="flex: 2;">
<!-- <div class="flexcol" style="flex: 2;">
<span class="ellipsi">
<nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss"
[(ngModel)]="i.planTime" nzPlaceHolder="请选择检查日期" nzBorderless
@ -468,12 +468,12 @@
<span>
检查时间
</span>
</div>
</div> -->
<div class="flexcol" style="flex: 1;">
<span class="ellipsi">
<span style="cursor: pointer;margin-right: 5px;" (click)="look(i)">查看</span>
<span style="cursor: pointer;color: rgb(255, 64, 77);" (click)="deleteTask(item,i)">删除</span>
<!-- <span style="cursor: pointer;color: rgb(255, 64, 77);" (click)="deleteTask(item,i)">删除</span> -->
</span>
<span>
操作

2
src/app/home/task/station-task-execution/station-task-execution.component.html

@ -195,7 +195,7 @@
<a class="blue" (click)="complete(item)" style="margin-right: 5px;">完成</a>
<a *ngIf="item.creationType != '自主任务' && item.approvalStatus != '已检查' && item.approvalStatus != '检查中'"
class="red" (click)="cancel(item)">驳回</a>
<a *ngIf="item.creationType == '自主任务' && item.approvalStatus != '已检查' && item.approvalStatus != '检查中'"
<a
class="red" (click)="delete(item)">删除</a>
</span>
<span>

Loading…
Cancel
Save