|
|
@ -1,179 +1,224 @@ |
|
|
|
import { Component, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core'; |
|
|
|
import { |
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
Component, |
|
|
|
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree'; |
|
|
|
OnInit, |
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal'; |
|
|
|
TemplateRef, |
|
|
|
import { AdduserComponent } from './adduser/adduser.component'; |
|
|
|
ViewChild, |
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
ViewContainerRef, |
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
} from "@angular/core"; |
|
|
|
import { EdituserComponent } from './edituser/edituser.component'; |
|
|
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; |
|
|
|
import { TreeService } from 'src/app/service/tree.service'; |
|
|
|
import { |
|
|
|
import { NzNotificationService } from 'ng-zorro-antd/notification'; |
|
|
|
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 { NzNotificationService } from "ng-zorro-antd/notification"; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-user', |
|
|
|
selector: "app-user", |
|
|
|
templateUrl: './user.component.html', |
|
|
|
templateUrl: "./user.component.html", |
|
|
|
styleUrls: ['./user.component.scss'] |
|
|
|
styleUrls: ["./user.component.scss"], |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class UserComponent implements OnInit { |
|
|
|
export class UserComponent implements OnInit { |
|
|
|
|
|
|
|
@ViewChild("newPassword", { static: false }) |
|
|
|
@ViewChild('newPassword', { static: false }) newPasswordtemplate?: TemplateRef<{}>; |
|
|
|
newPasswordtemplate?: TemplateRef<{}>; |
|
|
|
|
|
|
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
validateForm!: FormGroup; |
|
|
|
constructor(private fb: FormBuilder, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService, private notification: NzNotificationService, private notificationService: NzNotificationService) { } |
|
|
|
constructor( |
|
|
|
|
|
|
|
private fb: FormBuilder, |
|
|
|
|
|
|
|
private modal: NzModalService, |
|
|
|
|
|
|
|
private viewContainerRef: ViewContainerRef, |
|
|
|
|
|
|
|
private message: NzMessageService, |
|
|
|
|
|
|
|
private http: HttpClient, |
|
|
|
|
|
|
|
private toTree: TreeService, |
|
|
|
|
|
|
|
private notification: NzNotificationService, |
|
|
|
|
|
|
|
private notificationService: NzNotificationService |
|
|
|
|
|
|
|
) {} |
|
|
|
|
|
|
|
|
|
|
|
level |
|
|
|
level; |
|
|
|
getAllUrl |
|
|
|
getAllUrl; |
|
|
|
addUrl |
|
|
|
addUrl; |
|
|
|
editUrl |
|
|
|
editUrl; |
|
|
|
deleteUrl |
|
|
|
deleteUrl; |
|
|
|
CountsByOrganizations |
|
|
|
CountsByOrganizations; |
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
this.validateForm = this.fb.group({ |
|
|
|
search: [null] |
|
|
|
search: [null], |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.level = JSON.parse(sessionStorage.getItem("userdata")).organization.level |
|
|
|
this.level = JSON.parse( |
|
|
|
|
|
|
|
sessionStorage.getItem("userdata") |
|
|
|
|
|
|
|
).organization.level; |
|
|
|
if (this.level == 1) { |
|
|
|
if (this.level == 1) { |
|
|
|
this.getAllUrl = '/api/services/app/User/GetAll' |
|
|
|
this.getAllUrl = "/api/services/app/User/GetAll"; |
|
|
|
this.addUrl = '/api/services/app/User/Create' |
|
|
|
this.addUrl = "/api/services/app/User/Create"; |
|
|
|
this.editUrl = '/api/services/app/User/Update' |
|
|
|
this.editUrl = "/api/services/app/User/Update"; |
|
|
|
this.deleteUrl = '/api/services/app/User/Delete' |
|
|
|
this.deleteUrl = "/api/services/app/User/Delete"; |
|
|
|
this.CountsByOrganizations = '/api/services/app/User/GetCountsByOrganizations' |
|
|
|
this.CountsByOrganizations = |
|
|
|
|
|
|
|
"/api/services/app/User/GetCountsByOrganizations"; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.getAllUrl = '/api/services/app/EdittingUser/GetAll' |
|
|
|
this.getAllUrl = "/api/services/app/EdittingUser/GetAll"; |
|
|
|
this.addUrl = '/api/services/app/EdittingUser/Create' |
|
|
|
this.addUrl = "/api/services/app/EdittingUser/Create"; |
|
|
|
this.editUrl = '/api/services/app/EdittingUser/Update' |
|
|
|
this.editUrl = "/api/services/app/EdittingUser/Update"; |
|
|
|
this.deleteUrl = '/api/services/app/EdittingUser/Delete' |
|
|
|
this.deleteUrl = "/api/services/app/EdittingUser/Delete"; |
|
|
|
this.CountsByOrganizations = '/api/services/app/EdittingUser/GetCountsByOrganizations' |
|
|
|
this.CountsByOrganizations = |
|
|
|
|
|
|
|
"/api/services/app/EdittingUser/GetCountsByOrganizations"; |
|
|
|
} |
|
|
|
} |
|
|
|
this.getAllOrganization() |
|
|
|
this.getAllOrganization(); |
|
|
|
this.getAllRoles() |
|
|
|
this.getAllRoles(); |
|
|
|
this.getAllRoles2() |
|
|
|
this.getAllRoles2(); |
|
|
|
} |
|
|
|
} |
|
|
|
nzSelectedKeys: any[] = [] |
|
|
|
nzSelectedKeys: any[] = []; |
|
|
|
defaultExpandedKeys = []; |
|
|
|
defaultExpandedKeys = []; |
|
|
|
IsContainsChildren = true |
|
|
|
IsContainsChildren = true; |
|
|
|
searchValue = ''; |
|
|
|
searchValue = ""; |
|
|
|
totalCount: string |
|
|
|
totalCount: string; |
|
|
|
//获取所有用户
|
|
|
|
//获取所有用户
|
|
|
|
usersLIst: any = [] |
|
|
|
usersLIst: any = []; |
|
|
|
usersNum: string |
|
|
|
usersNum: string; |
|
|
|
OrganizationUnitId |
|
|
|
OrganizationUnitId; |
|
|
|
loading: boolean; |
|
|
|
loading: boolean; |
|
|
|
organizationsList = [] |
|
|
|
organizationsList = []; |
|
|
|
getAllUsers() { |
|
|
|
getAllUsers() { |
|
|
|
this.loading = true |
|
|
|
this.loading = true; |
|
|
|
let params = { |
|
|
|
let params = { |
|
|
|
Keyword: this.validateForm.value.search ? this.validateForm.value.search : '', |
|
|
|
Keyword: this.validateForm.value.search |
|
|
|
|
|
|
|
? this.validateForm.value.search |
|
|
|
|
|
|
|
: "", |
|
|
|
SkipCount: String(this.SkipCount), |
|
|
|
SkipCount: String(this.SkipCount), |
|
|
|
MaxResultCount: String(this.MaxResultCount), |
|
|
|
MaxResultCount: String(this.MaxResultCount), |
|
|
|
OrganizationUnitId: this.OrganizationUnitId, |
|
|
|
OrganizationUnitId: this.OrganizationUnitId, |
|
|
|
IsContainsChildren: String(this.IsContainsChildren), |
|
|
|
IsContainsChildren: String(this.IsContainsChildren), |
|
|
|
// Sorting: 'BuildingBasicInfo.Id asc'
|
|
|
|
// Sorting: 'BuildingBasicInfo.Id asc'
|
|
|
|
} |
|
|
|
}; |
|
|
|
this.http.get(this.getAllUrl, { |
|
|
|
this.http |
|
|
|
params: params |
|
|
|
.get(this.getAllUrl, { |
|
|
|
}).subscribe((data: any) => { |
|
|
|
params: params, |
|
|
|
this.usersLIst = data.result.items |
|
|
|
}) |
|
|
|
this.usersNum = data.result.totalCount |
|
|
|
.subscribe((data: any) => { |
|
|
|
console.log('所有用户', this.usersLIst) |
|
|
|
this.usersLIst = data.result.items; |
|
|
|
this.loading = false |
|
|
|
this.usersNum = data.result.totalCount; |
|
|
|
}) |
|
|
|
console.log("所有用户", this.usersLIst); |
|
|
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
SkipCount: number = 0 //0 16 32 48
|
|
|
|
SkipCount: number = 0; //0 16 32 48
|
|
|
|
MaxResultCount: number = 16 |
|
|
|
MaxResultCount: number = 16; |
|
|
|
pageChange($event) { |
|
|
|
pageChange($event) { |
|
|
|
this.SkipCount = ($event - 1) * this.MaxResultCount |
|
|
|
this.SkipCount = ($event - 1) * this.MaxResultCount; |
|
|
|
this.getAllUsers() |
|
|
|
this.getAllUsers(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listOfData: any = [] |
|
|
|
listOfData: any = []; |
|
|
|
listOfData2: any = [] |
|
|
|
listOfData2: any = []; |
|
|
|
//获取角色列表
|
|
|
|
//获取角色列表
|
|
|
|
async getAllRoles() { |
|
|
|
async getAllRoles() { |
|
|
|
let params = { |
|
|
|
let params = { |
|
|
|
SkipCount: '0', |
|
|
|
SkipCount: "0", |
|
|
|
MaxResultCount: '999' |
|
|
|
MaxResultCount: "999", |
|
|
|
} |
|
|
|
}; |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
this.http.get('/api/services/app/Role/GetAll', { |
|
|
|
this.http |
|
|
|
params: params |
|
|
|
.get("/api/services/app/Role/GetAll", { |
|
|
|
}).subscribe((data: any) => { |
|
|
|
params: params, |
|
|
|
resolve(data) |
|
|
|
}) |
|
|
|
this.listOfData = data.result.items |
|
|
|
.subscribe((data: any) => { |
|
|
|
}) |
|
|
|
resolve(data); |
|
|
|
}) |
|
|
|
this.listOfData = data.result.items; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
async getAllRoles2() { |
|
|
|
async getAllRoles2() { |
|
|
|
let params = { |
|
|
|
let params = { |
|
|
|
SkipCount: '0', |
|
|
|
SkipCount: "0", |
|
|
|
MaxResultCount: '999', |
|
|
|
MaxResultCount: "999", |
|
|
|
IsViolationRoles: 'true' |
|
|
|
IsViolationRoles: "true", |
|
|
|
} |
|
|
|
}; |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
this.http.get('/api/services/app/Role/GetAll', { |
|
|
|
this.http |
|
|
|
params: params |
|
|
|
.get("/api/services/app/Role/GetAll", { |
|
|
|
}).subscribe((data: any) => { |
|
|
|
params: params, |
|
|
|
resolve(data) |
|
|
|
}) |
|
|
|
this.listOfData2 = data.result.items |
|
|
|
.subscribe((data: any) => { |
|
|
|
}) |
|
|
|
resolve(data); |
|
|
|
}) |
|
|
|
this.listOfData2 = data.result.items; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
//获取所有组织机构
|
|
|
|
//获取所有组织机构
|
|
|
|
nodes: any = [] |
|
|
|
nodes: any = []; |
|
|
|
organization |
|
|
|
organization; |
|
|
|
async 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) => { |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
this.http.get('/api/services/app/Organization/GetAll', { |
|
|
|
this.http |
|
|
|
params: params |
|
|
|
.get("/api/services/app/Organization/GetAll", { |
|
|
|
}).subscribe(async (data: any) => { |
|
|
|
params: params, |
|
|
|
this.organization = data.result.items |
|
|
|
}) |
|
|
|
await this.getuser(data.result.items) |
|
|
|
.subscribe(async (data: any) => { |
|
|
|
resolve(data) |
|
|
|
this.organization = data.result.items; |
|
|
|
this.getAllUsers() |
|
|
|
await this.getuser(data.result.items); |
|
|
|
}) |
|
|
|
resolve(data); |
|
|
|
}) |
|
|
|
this.getAllUsers(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
async getuser(e) { |
|
|
|
async getuser(e) { |
|
|
|
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", |
|
|
|
IsUsersCountContainsChildren: String(this.IsContainsChildren) |
|
|
|
IsUsersCountContainsChildren: String(this.IsContainsChildren), |
|
|
|
} |
|
|
|
}; |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
await new Promise<void>((resolve, reject) => { |
|
|
|
this.http.get(this.CountsByOrganizations, { |
|
|
|
this.http |
|
|
|
params: params |
|
|
|
.get(this.CountsByOrganizations, { |
|
|
|
}).subscribe((data: any) => { |
|
|
|
params: params, |
|
|
|
resolve(data) |
|
|
|
|
|
|
|
this.organizationsList = data.result |
|
|
|
|
|
|
|
const arrs = e.map(item => { |
|
|
|
|
|
|
|
const data = this.organizationsList.find(i => item.id == i.organizationId) |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...item, |
|
|
|
|
|
|
|
products: data ? data : false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
.subscribe((data: any) => { |
|
|
|
|
|
|
|
resolve(data); |
|
|
|
|
|
|
|
this.organizationsList = data.result; |
|
|
|
|
|
|
|
const arrs = e.map((item) => { |
|
|
|
|
|
|
|
const data = this.organizationsList.find( |
|
|
|
|
|
|
|
(i) => item.id == i.organizationId |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...item, |
|
|
|
|
|
|
|
products: data ? data : false, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
for (let index = 0; index < arrs.length; index++) { |
|
|
|
for (let index = 0; index < arrs.length; index++) { |
|
|
|
if (arrs[index].id == OrganizationUnitId) { |
|
|
|
if (arrs[index].id == OrganizationUnitId) { |
|
|
|
arrs[index].parentId = null |
|
|
|
arrs[index].parentId = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
arrs[index].title = arrs[index].displayName; |
|
|
|
|
|
|
|
arrs[index].key = arrs[index].id; |
|
|
|
} |
|
|
|
} |
|
|
|
arrs[index].title = arrs[index].displayName |
|
|
|
|
|
|
|
arrs[index].key = arrs[index].id |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.nodes = [...this.toTree.toTree(arrs)] |
|
|
|
this.nodes = [...this.toTree.toTree(arrs)]; |
|
|
|
this.defaultExpandedKeys = [this.nodes[0].id] |
|
|
|
this.defaultExpandedKeys = [this.nodes[0].id]; |
|
|
|
this.nzSelectedKeys = [this.nodes[0].id] |
|
|
|
this.nzSelectedKeys = [this.nodes[0].id]; |
|
|
|
this.OrganizationUnitId = [this.nodes[0].id] |
|
|
|
this.OrganizationUnitId = [this.nodes[0].id]; |
|
|
|
console.log(this.nodes, 9000); |
|
|
|
console.log(this.nodes, 9000); |
|
|
|
}) |
|
|
|
}); |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//搜索框提交
|
|
|
|
//搜索框提交
|
|
|
@ -182,72 +227,86 @@ export class UserComponent implements OnInit { |
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
this.validateForm.controls[i].markAsDirty(); |
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
this.validateForm.controls[i].updateValueAndValidity(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.getAllUsers() |
|
|
|
this.getAllUsers(); |
|
|
|
} |
|
|
|
} |
|
|
|
nzClick(event: NzFormatEmitEvent) { |
|
|
|
nzClick(event: NzFormatEmitEvent) { |
|
|
|
console.log(event); |
|
|
|
console.log(event); |
|
|
|
this.nzSelectedKeys[0] = event.node.origin.id |
|
|
|
this.nzSelectedKeys[0] = event.node.origin.id; |
|
|
|
this.nzSelectedKeys = [...this.nzSelectedKeys] |
|
|
|
this.nzSelectedKeys = [...this.nzSelectedKeys]; |
|
|
|
this.OrganizationUnitId = event.node.origin.id |
|
|
|
this.OrganizationUnitId = event.node.origin.id; |
|
|
|
this.getAllUsers() |
|
|
|
this.getAllUsers(); |
|
|
|
} |
|
|
|
} |
|
|
|
//新增用户
|
|
|
|
//新增用户
|
|
|
|
addUser(): void { |
|
|
|
addUser(): void { |
|
|
|
const modal = this.modal.create({ |
|
|
|
const modal = this.modal.create({ |
|
|
|
nzTitle: '新增用户', |
|
|
|
nzTitle: "新增用户", |
|
|
|
nzContent: AdduserComponent, |
|
|
|
nzContent: AdduserComponent, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzWidth: 460, |
|
|
|
nzWidth: 460, |
|
|
|
nzMaskClosable: false, |
|
|
|
nzMaskClosable: false, |
|
|
|
nzComponentParams: { |
|
|
|
nzComponentParams: { |
|
|
|
title: '', |
|
|
|
title: "", |
|
|
|
subtitle: '' |
|
|
|
subtitle: "", |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzOnOk: async () => { |
|
|
|
nzOnOk: async () => { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
if (instance.validateForm.valid) { |
|
|
|
await new Promise(resolve => { |
|
|
|
await new Promise((resolve) => { |
|
|
|
let roleNames = [...instance.validateForm.value.role, ...instance.validateForm.value.role2] |
|
|
|
let roleNames = [ |
|
|
|
|
|
|
|
...instance.validateForm.value.role, |
|
|
|
|
|
|
|
...instance.validateForm.value.role2, |
|
|
|
|
|
|
|
]; |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
|
userName: instance.validateForm.value.account, |
|
|
|
userName: instance.validateForm.value.account, |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
name: instance.validateForm.value.name, |
|
|
|
organizationUnitId: Number(instance.validateForm.value.organization), |
|
|
|
organizationUnitId: Number( |
|
|
|
|
|
|
|
instance.validateForm.value.organization |
|
|
|
|
|
|
|
), |
|
|
|
roleNames: roleNames, |
|
|
|
roleNames: roleNames, |
|
|
|
phoneNumber: instance.validateForm.value.phonenum, |
|
|
|
phoneNumber: instance.validateForm.value.phonenum, |
|
|
|
isActive: true |
|
|
|
isActive: true, |
|
|
|
} |
|
|
|
}; |
|
|
|
this.http.post(this.addUrl, body).subscribe((data: any) => { |
|
|
|
this.http.post(this.addUrl, body).subscribe( |
|
|
|
resolve(data) |
|
|
|
(data: any) => { |
|
|
|
this.message.create('success', '创建成功!'); |
|
|
|
resolve(data); |
|
|
|
this.SkipCount = 0 |
|
|
|
this.message.create("success", "创建成功!"); |
|
|
|
this.getAllUsers() |
|
|
|
this.SkipCount = 0; |
|
|
|
this.notification.blank( |
|
|
|
this.getAllUsers(); |
|
|
|
'用户' + data.result.userName + '创建成功', |
|
|
|
this.notification.blank( |
|
|
|
'当前密码为:' + data.result.newPassword, |
|
|
|
"用户" + data.result.userName + "创建成功", |
|
|
|
{ nzDuration: 0, nzPlacement: 'top', nzClass: 'resetPassword' } |
|
|
|
"当前密码为:" + data.result.newPassword, |
|
|
|
); |
|
|
|
{ |
|
|
|
return true |
|
|
|
nzDuration: 0, |
|
|
|
}, err => { |
|
|
|
nzPlacement: "top", |
|
|
|
resolve(err) |
|
|
|
nzClass: "resetPassword", |
|
|
|
this.message.create('warning', err.error.error.message); |
|
|
|
} |
|
|
|
return false |
|
|
|
); |
|
|
|
}) |
|
|
|
return true; |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
(err) => { |
|
|
|
|
|
|
|
resolve(err); |
|
|
|
|
|
|
|
this.message.create("warning", err.error.error.message); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.message.create('warning', '请填写完整!'); |
|
|
|
this.message.create("warning", "请填写完整!"); |
|
|
|
return false |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!')); |
|
|
|
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(data): void { |
|
|
|
editUser(data): void { |
|
|
|
console.log(data) |
|
|
|
console.log(data); |
|
|
|
const modal = this.modal.create({ |
|
|
|
const modal = this.modal.create({ |
|
|
|
nzTitle: '编辑用户', |
|
|
|
nzTitle: "编辑用户", |
|
|
|
nzContent: EdituserComponent, |
|
|
|
nzContent: EdituserComponent, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
nzWidth: 460, |
|
|
|
nzWidth: 460, |
|
|
@ -258,150 +317,172 @@ export class UserComponent implements OnInit { |
|
|
|
listOfData: this.listOfData, |
|
|
|
listOfData: this.listOfData, |
|
|
|
listOfData2: this.listOfData2, |
|
|
|
listOfData2: this.listOfData2, |
|
|
|
nodes: this.nodes, |
|
|
|
nodes: this.nodes, |
|
|
|
editUrl: this.editUrl |
|
|
|
editUrl: this.editUrl, |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
const instance = modal.getContentComponent(); |
|
|
|
modal.afterClose.subscribe(result => this.getAllUsers()); |
|
|
|
modal.afterClose.subscribe((result) => this.getAllUsers()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//重置密码
|
|
|
|
//重置密码
|
|
|
|
isShowNewPassword: boolean |
|
|
|
isShowNewPassword: boolean; |
|
|
|
newPasswordObj: any |
|
|
|
newPasswordObj: any; |
|
|
|
resetPassword(item) { |
|
|
|
resetPassword(item) { |
|
|
|
// console.log(item)
|
|
|
|
// console.log(item)
|
|
|
|
this.modal.confirm({ |
|
|
|
this.modal.confirm({ |
|
|
|
nzTitle: `确定要重置${item.userName}这个账户的密码吗?`, |
|
|
|
nzTitle: `确定要重置${item.userName}这个账户的密码吗?`, |
|
|
|
nzOkText: '确定', |
|
|
|
nzOkText: "确定", |
|
|
|
nzOkType: 'primary', |
|
|
|
nzOkType: "primary", |
|
|
|
nzOnOk: () => { |
|
|
|
nzOnOk: () => { |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
|
userId: item.id |
|
|
|
userId: item.id, |
|
|
|
} |
|
|
|
}; |
|
|
|
this.http.post('/api/services/app/User/ResetPassword', body).subscribe((data: any) => { |
|
|
|
this.http |
|
|
|
this.isShowNewPassword = true |
|
|
|
.post("/api/services/app/User/ResetPassword", body) |
|
|
|
let obj = { |
|
|
|
.subscribe((data: any) => { |
|
|
|
userName: item.userName, |
|
|
|
this.isShowNewPassword = true; |
|
|
|
newPassword: data.result.newPassword |
|
|
|
let obj = { |
|
|
|
} |
|
|
|
userName: item.userName, |
|
|
|
this.newPasswordObj = obj |
|
|
|
newPassword: data.result.newPassword, |
|
|
|
// this.openNewPassword(obj)
|
|
|
|
}; |
|
|
|
}) |
|
|
|
this.newPasswordObj = obj; |
|
|
|
|
|
|
|
// this.openNewPassword(obj)
|
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzCancelText: '取消', |
|
|
|
nzCancelText: "取消", |
|
|
|
nzOnCancel: () => { |
|
|
|
nzOnCancel: () => {}, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
close() { |
|
|
|
close() { |
|
|
|
this.isShowNewPassword = false |
|
|
|
this.isShowNewPassword = false; |
|
|
|
} |
|
|
|
} |
|
|
|
openNewPassword(data) { |
|
|
|
openNewPassword(data) { |
|
|
|
this.notificationService.template(this.newPasswordtemplate, { nzData: data, nzDuration: 0, nzPlacement: 'top', nzClass: 'resetPassword' }); |
|
|
|
this.notificationService.template(this.newPasswordtemplate, { |
|
|
|
|
|
|
|
nzData: data, |
|
|
|
|
|
|
|
nzDuration: 0, |
|
|
|
|
|
|
|
nzPlacement: "top", |
|
|
|
|
|
|
|
nzClass: "resetPassword", |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleCopyValue(text) { |
|
|
|
handleCopyValue(text) { |
|
|
|
//浏览器禁用了非安全域的 navigator.clipboard 对象
|
|
|
|
//浏览器禁用了非安全域的 navigator.clipboard 对象
|
|
|
|
//在线上环境会报错 TypeError: Cannot read properties of undefined (reading 'writeText')
|
|
|
|
//在线上环境会报错 TypeError: Cannot read properties of undefined (reading 'writeText')
|
|
|
|
if (!navigator.clipboard && window.isSecureContext) { |
|
|
|
if (!navigator.clipboard && window.isSecureContext) { |
|
|
|
return navigator.clipboard.writeText(text) |
|
|
|
return navigator.clipboard.writeText(text); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 判断是否支持拷贝
|
|
|
|
// 判断是否支持拷贝
|
|
|
|
if (!document.execCommand('copy')) return Promise.reject() |
|
|
|
if (!document.execCommand("copy")) return Promise.reject(); |
|
|
|
// 创建标签,并隐藏
|
|
|
|
// 创建标签,并隐藏
|
|
|
|
const textArea = document.createElement('textarea') |
|
|
|
const textArea = document.createElement("textarea"); |
|
|
|
textArea.style.position = 'fixed' |
|
|
|
textArea.style.position = "fixed"; |
|
|
|
textArea.style.top = textArea.style.left = '-100vh' |
|
|
|
textArea.style.top = textArea.style.left = "-100vh"; |
|
|
|
textArea.style.opacity = '0' |
|
|
|
textArea.style.opacity = "0"; |
|
|
|
textArea.value = text |
|
|
|
textArea.value = text; |
|
|
|
document.body.appendChild(textArea) |
|
|
|
document.body.appendChild(textArea); |
|
|
|
// 聚焦、复制
|
|
|
|
// 聚焦、复制
|
|
|
|
textArea.focus() |
|
|
|
textArea.focus(); |
|
|
|
textArea.select() |
|
|
|
textArea.select(); |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// 不知为何,必须写这个三目,不然copy不上
|
|
|
|
// 不知为何,必须写这个三目,不然copy不上
|
|
|
|
document.execCommand('copy') ? resolve(0) : reject() |
|
|
|
document.execCommand("copy") ? resolve(0) : reject(); |
|
|
|
textArea.remove() |
|
|
|
textArea.remove(); |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copy() { |
|
|
|
copy() { |
|
|
|
this.handleCopyValue(this.newPasswordObj.newPassword) |
|
|
|
let str = |
|
|
|
|
|
|
|
"用户" + |
|
|
|
|
|
|
|
this.newPasswordObj.userName + |
|
|
|
|
|
|
|
"的密码重置成功,当前密码为" + |
|
|
|
|
|
|
|
this.newPasswordObj.newPassword; |
|
|
|
|
|
|
|
this.handleCopyValue(str) |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
this.message.create('success', '复制成功!'); |
|
|
|
this.message.create("success", "复制成功!"); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
.catch(() => { |
|
|
|
this.message.create('success', '自动复制失败,请手动复制!'); |
|
|
|
this.message.create("success", "自动复制失败,请手动复制!"); |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提交审核
|
|
|
|
//提交审核
|
|
|
|
audit(data, type) { |
|
|
|
audit(data, type) { |
|
|
|
if (type && data.auditStatus == 5) {//提交审核
|
|
|
|
if (type && data.auditStatus == 5) { |
|
|
|
this.message.create('warning', '审核完成的不能重复提交,请编辑后提交'); |
|
|
|
//提交审核
|
|
|
|
return |
|
|
|
this.message.create("warning", "审核完成的不能重复提交,请编辑后提交"); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
let url |
|
|
|
let url; |
|
|
|
type ? url = '/api/services/app/EdittingUser/Commit' : url = '/api/services/app/EdittingUser/Uncommit' |
|
|
|
type |
|
|
|
this.http.post(url, '', { |
|
|
|
? (url = "/api/services/app/EdittingUser/Commit") |
|
|
|
params: { |
|
|
|
: (url = "/api/services/app/EdittingUser/Uncommit"); |
|
|
|
id: data.id |
|
|
|
this.http |
|
|
|
} |
|
|
|
.post(url, "", { |
|
|
|
}).subscribe(data => { |
|
|
|
params: { |
|
|
|
this.message.create('success', type ? '提交审核成功' : '撤销审核成功'); |
|
|
|
id: data.id, |
|
|
|
this.getAllUsers() |
|
|
|
}, |
|
|
|
}, err => { |
|
|
|
}) |
|
|
|
this.message.create('error', type ? '提交审核失败' : '撤销审核失败'); |
|
|
|
.subscribe( |
|
|
|
}) |
|
|
|
(data) => { |
|
|
|
|
|
|
|
this.message.create( |
|
|
|
|
|
|
|
"success", |
|
|
|
|
|
|
|
type ? "提交审核成功" : "撤销审核成功" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
this.getAllUsers(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
(err) => { |
|
|
|
|
|
|
|
this.message.create("error", type ? "提交审核失败" : "撤销审核失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//停用启用
|
|
|
|
//停用启用
|
|
|
|
cancel(data, type) { |
|
|
|
cancel(data, type) { |
|
|
|
let url |
|
|
|
let url; |
|
|
|
if (this.level == 1) { |
|
|
|
if (this.level == 1) { |
|
|
|
type ? url = '/api/services/app/User/Activate' : url = '/api/services/app/User/DeActivate' |
|
|
|
type |
|
|
|
|
|
|
|
? (url = "/api/services/app/User/Activate") |
|
|
|
|
|
|
|
: (url = "/api/services/app/User/DeActivate"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
type ? url = '/api/services/app/EdittingUser/Activate' : url = '/api/services/app/EdittingUser/DeActivate' |
|
|
|
type |
|
|
|
|
|
|
|
? (url = "/api/services/app/EdittingUser/Activate") |
|
|
|
|
|
|
|
: (url = "/api/services/app/EdittingUser/DeActivate"); |
|
|
|
} |
|
|
|
} |
|
|
|
let body = { |
|
|
|
let body = { |
|
|
|
id: data.id |
|
|
|
id: data.id, |
|
|
|
} |
|
|
|
}; |
|
|
|
this.http.post(url, body).subscribe(data => { |
|
|
|
this.http.post(url, body).subscribe( |
|
|
|
this.message.create('success', type ? '启用成功' : '停用成功'); |
|
|
|
(data) => { |
|
|
|
this.getAllUsers() |
|
|
|
this.message.create("success", type ? "启用成功" : "停用成功"); |
|
|
|
}, err => { |
|
|
|
this.getAllUsers(); |
|
|
|
this.message.create('error', type ? '启用失败' : '停用失败'); |
|
|
|
}, |
|
|
|
}) |
|
|
|
(err) => { |
|
|
|
|
|
|
|
this.message.create("error", type ? "启用失败" : "停用失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除
|
|
|
|
//删除
|
|
|
|
delete(item) { |
|
|
|
delete(item) { |
|
|
|
this.modal.confirm({ |
|
|
|
this.modal.confirm({ |
|
|
|
nzTitle: `确定要注销${item.userName}这个账户吗?`, |
|
|
|
nzTitle: `确定要注销${item.userName}这个账户吗?`, |
|
|
|
nzOkText: '确定', |
|
|
|
nzOkText: "确定", |
|
|
|
nzOkType: 'primary', |
|
|
|
nzOkType: "primary", |
|
|
|
nzOnOk: () => { |
|
|
|
nzOnOk: () => { |
|
|
|
this.http.delete(this.deleteUrl, { |
|
|
|
this.http |
|
|
|
params: { |
|
|
|
.delete(this.deleteUrl, { |
|
|
|
Id: item.id |
|
|
|
params: { |
|
|
|
} |
|
|
|
Id: item.id, |
|
|
|
}).subscribe(data => { |
|
|
|
}, |
|
|
|
this.message.create('success', '注销成功!'); |
|
|
|
}) |
|
|
|
this.getAllUsers() |
|
|
|
.subscribe((data) => { |
|
|
|
}) |
|
|
|
this.message.create("success", "注销成功!"); |
|
|
|
|
|
|
|
this.getAllUsers(); |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
nzCancelText: '取消', |
|
|
|
nzCancelText: "取消", |
|
|
|
nzOnCancel: () => { |
|
|
|
nzOnCancel: () => {}, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|