diff --git a/projects/admin/src/app/components/role-permission/role-permission.component.ts b/projects/admin/src/app/components/role-permission/role-permission.component.ts
index 4683a0a..a20b78a 100644
--- a/projects/admin/src/app/components/role-permission/role-permission.component.ts
+++ b/projects/admin/src/app/components/role-permission/role-permission.component.ts
@@ -1,6 +1,6 @@
import { PermItemDTO, UserRoleDTO } from "@admin/app/dtos/user.dto";
import { ApiService } from "@admin/app/services";
-import { Component, Input, OnChanges, SimpleChanges } from "@angular/core";
+import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { AnyObject } from "@cdk/types";
import { NzMessageService } from "ng-zorro-antd/message";
@@ -18,6 +18,8 @@ export class RolePermissionComponent implements OnChanges {
@Input() role!: UserRoleDTO;
+ @Output() onReload = new EventEmitter();
+
loading = false;
ngOnChanges(changes: SimpleChanges): void {
@@ -36,10 +38,7 @@ export class RolePermissionComponent implements OnChanges {
}
if (changes["role"]?.currentValue) {
const role: UserRoleDTO = changes["role"].currentValue;
- let perms: number[] = [];
- try {
- perms = JSON.parse(role.roleItems);
- } catch (error) {}
+ let perms: number[] = role.roleItems ?? [];
this.hasPermissions.clear();
perms.forEach((p) => {
this.hasPermissions.add(p);
@@ -77,6 +76,7 @@ export class RolePermissionComponent implements OnChanges {
)
.subscribe((res) => {
this.msg.success(res.desc);
+ this.onReload.emit();
});
}
}
diff --git a/projects/admin/src/app/components/user-list/user-list.component.html b/projects/admin/src/app/components/user-list/user-list.component.html
index 8332532..0f1fedd 100644
--- a/projects/admin/src/app/components/user-list/user-list.component.html
+++ b/projects/admin/src/app/components/user-list/user-list.component.html
@@ -40,7 +40,7 @@
{{data.uid}} |
{{data.name}} |
{{data.roleName}} |
- {{data.roleName}} |
+ {{data.time | date:'yyyy-MM-dd HH:mm:ss'}} |
编辑
diff --git a/projects/admin/src/app/components/user-list/user-list.component.ts b/projects/admin/src/app/components/user-list/user-list.component.ts
index 4614a13..4319668 100644
--- a/projects/admin/src/app/components/user-list/user-list.component.ts
+++ b/projects/admin/src/app/components/user-list/user-list.component.ts
@@ -46,12 +46,12 @@ export class UserListComponent {
if (Utils.validateFormGroup(this.userFrom)) {
const user = { ...this.userFrom.value, roleId: this.role.id };
user["password"] = MD5(user.password!).toString().substring(16).toUpperCase();
- const check = await lastValueFrom(this.api.checkUid(user.uid!));
- if (check.success) {
- const res = await lastValueFrom(this.api.saveUser(user));
- this.msg.success(res.desc);
- return true;
- }
+ // const check = await lastValueFrom(this.api.checkUid(user.uid!));
+ // if (check.body) {
+ const res = await lastValueFrom(this.api.saveUser(user));
+ this.msg.success(res.desc);
+ return true;
+ // }
}
return false;
},
diff --git a/projects/admin/src/app/dtos/user.dto.ts b/projects/admin/src/app/dtos/user.dto.ts
index f80c4d4..ad2b699 100644
--- a/projects/admin/src/app/dtos/user.dto.ts
+++ b/projects/admin/src/app/dtos/user.dto.ts
@@ -1,6 +1,6 @@
export type UserRoleDTO = {
id: string;
- roleItems: string;
+ roleItems: number[];
roleName: string;
roleType: string;
vender: number;
@@ -19,4 +19,5 @@ export type UserDTO = {
roleId: number;
roleName: string;
uid: string;
+ time: string;
};
diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html
index 7d4c861..8ce50fe 100644
--- a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html
+++ b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html
@@ -15,10 +15,14 @@
单位Logo
-
diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts
index bb7faa3..0f18f2e 100644
--- a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts
+++ b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts
@@ -36,8 +36,13 @@ export class OrganizationFormComponent {
uploadLoading = false;
+ get icon() {
+ return this.formGroup.get("icon")?.value;
+ }
+
ngOnInit(): void {
this.formGroup = this.fb.group({
+ id: this.fb.control(""),
account: this.fb.control("", [FormValidators.required("账号不能为空")]),
password: this.fb.control("", [FormValidators.required("密码不能为空")]),
name: this.fb.control("", [FormValidators.required("单位名称不能为空")]),
@@ -51,6 +56,7 @@ export class OrganizationFormComponent {
console.log("this.state", this.state);
this.formGroup.patchValue(this.state);
}
+
async onSubmit() {
if (Utils.validateFormGroup(this.formGroup)) {
const org = { ...this.formGroup.value };
@@ -59,11 +65,11 @@ export class OrganizationFormComponent {
const account = await lastValueFrom(this.api.checkOrgAccount(org.account!));
const name = await lastValueFrom(this.api.checkOrgName(org.name!));
- if (account.body) {
+ if (!account.body) {
this.msg.error("账号重复");
return;
}
- if (name.body) {
+ if (!name.body) {
this.msg.error("单位名称重复");
return;
}
diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.html b/projects/admin/src/app/pages/system/user-manage/user-manage.component.html
index 01fbe9e..7873a82 100644
--- a/projects/admin/src/app/pages/system/user-manage/user-manage.component.html
+++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.html
@@ -53,14 +53,15 @@
+ [role]="role"
+ (onReload)="getRoleList()">
diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
index afd9add..369b7ef 100644
--- a/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
+++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
@@ -31,13 +31,15 @@ export class UserManageComponent {
public roleForm = new FormGroup({
roleId: new FormControl(""),
roleName: new FormControl("", [FormValidators.required("请输入角色名称")]),
- items: new FormControl("1"),
+ items: new FormControl([]),
});
public allPerms: PermItemDTO[] = [];
public userList: UserDTO[] = [];
+ public currentUserList: UserDTO[] = [];
+
roleList: UserRoleDTO[] = [];
ngOnInit(): void {
@@ -58,6 +60,7 @@ export class UserManageComponent {
const role = this.roleList.find((f) => f.id === roleId);
if (role) {
this.role = role;
+ this.onRoleChange(role.id);
return;
}
if (this.roleList.length > 0) {
@@ -69,13 +72,17 @@ export class UserManageComponent {
onRoleChange(roleId: string) {
const role = this.roleList.find((f) => f.id === roleId);
if (role) {
- this.role = role;
- this.router.navigate(["/system/user"], {
- queryParams: {
- roleId,
- },
- queryParamsHandling: "merge",
- });
+ this.router
+ .navigate(["/system/user"], {
+ queryParams: {
+ roleId,
+ },
+ queryParamsHandling: "merge",
+ })
+ .then(() => {
+ this.role = role;
+ this.currentUserList = this.userList.filter((f) => Number(f.roleId) === Number(role.id));
+ });
}
}
diff --git a/projects/admin/src/app/services/api.service.ts b/projects/admin/src/app/services/api.service.ts
index b41b11e..9d6a749 100644
--- a/projects/admin/src/app/services/api.service.ts
+++ b/projects/admin/src/app/services/api.service.ts
@@ -66,7 +66,7 @@ export class ApiService {
saveUser(user: AnyObject) {
const body = Utils.objectToFormData(user);
- const method = user["uid"] ? "post" : "put";
+ const method = user["id"] ? "post" : "put";
return this.http[method]("/api/user", body);
}
@@ -80,6 +80,7 @@ export class ApiService {
params,
});
}
+
checkOrgName(name: string) {
const params = new HttpParams().set("name", name);
return this.http.get>("/api/vender/check/name", {
diff --git a/projects/admin/src/app/services/http.interceptor.ts b/projects/admin/src/app/services/http.interceptor.ts
index 9b9b69b..5c12c86 100644
--- a/projects/admin/src/app/services/http.interceptor.ts
+++ b/projects/admin/src/app/services/http.interceptor.ts
@@ -68,6 +68,7 @@ export class HTTPInterceptor implements HttpInterceptor {
this.msg.error(error.desc);
switch (error.code) {
case 401:
+ localStorage.removeItem("account");
this.router.navigate(["/", "login"]);
break;
default:
diff --git a/projects/cdk/src/utils/index.ts b/projects/cdk/src/utils/index.ts
index ba51ea8..336b43f 100644
--- a/projects/cdk/src/utils/index.ts
+++ b/projects/cdk/src/utils/index.ts
@@ -66,7 +66,9 @@ export class Utils {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
- params.append(key, value);
+ if (![void 0, null, ""].includes(value)) {
+ params.append(key, value);
+ }
}
}
|