Browse Source

[新增]中台登录配合修改

test-assets
邵佳豪 7 months ago
parent
commit
4a41bfafc0
  1. 11
      proxy.config.json
  2. 63
      src/app/app-routing.module.ts
  3. 2
      src/app/app.component.ts
  4. 5
      src/app/auth.guard.ts
  5. 2
      src/app/http-interceptors/base-interceptor.ts
  6. 3
      src/app/pages/pages.module.ts
  7. 121
      src/app/pages/singlelogin/singlelogin.component.html
  8. 234
      src/app/pages/singlelogin/singlelogin.component.scss
  9. 287
      src/app/pages/singlelogin/singlelogin.component.ts
  10. 4
      src/app/service/pattern.service.ts
  11. 8
      src/app/system-management/organization/organization.component.html
  12. 10
      src/app/system-management/organization/organization.component.ts
  13. 256
      src/app/system-management/user/edituser/edituser.component.ts
  14. 6
      src/app/system-management/user/user.component.html
  15. 9
      src/app/system-management/user/user.component.ts

11
proxy.config.json

@ -1,16 +1,21 @@
{
"/api": {
"target": "http://121.36.37.70:8906/",
"target": "http://192.168.1.43:8106",
"测试1": "http://121.36.37.70:8906/",
"测试2": "http://121.36.37.70:8906/",
"测试2": "https://znaq.sinochemoilmarketing.com/",
"测试3": "https://gas.anxincloud.cn/",
"secure": false,
"changeOrigin": true
},
"/signalr": {
"target": "http://121.36.37.70:8906/",
"target": "http://192.168.1.43:8106",
"secure": false,
"ws": true,
"logLevel": "debug"
},
"/p3p": {
"target": "https://test-uomsp.sinochemoilmarketing.com/sagframe-portal/",
"secure": false,
"changeOrigin": true
}
}

63
src/app/app-routing.module.ts

@ -1,35 +1,52 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './pages/login/login.component';
import { RegisterComponent } from './pages/register/register.component';
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { LoginComponent } from "./pages/login/login.component";
import { RegisterComponent } from "./pages/register/register.component";
//路由守卫
import { AuthGuard } from './auth.guard'
import { HomeComponent } from './pages/home/home.component';
import { NavigationComponent } from './system-management/navigation/navigation.component';
import { HomePageNologinComponent } from './pages/home-page-nologin/home-page-nologin.component';
import { AuthGuard } from "./auth.guard";
import { HomeComponent } from "./pages/home/home.component";
import { NavigationComponent } from "./system-management/navigation/navigation.component";
import { HomePageNologinComponent } from "./pages/home-page-nologin/home-page-nologin.component";
import { SingleloginComponent } from "./pages/singlelogin/singlelogin.component";
const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent }, //登录页
{ path: 'register', component: RegisterComponent }, //注册页
{ path: '', redirectTo: 'singlelogin', pathMatch: 'full' },
{ path: "singlelogin", component: SingleloginComponent }, //单点登录页
{ path: "login", component: LoginComponent }, //登录页
{ path: "register", component: RegisterComponent }, //注册页
// { path: 'homepagenologin', component: HomePageNologinComponent }, //注册页
{
path: '', component: HomeComponent, canActivate: [AuthGuard], children: [
{ path: '', loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule) }
]
path: "",
component: HomeComponent,
canActivate: [AuthGuard],
children: [
{
path: "",
loadChildren: () =>
import("./pages/pages.module").then((m) => m.PagesModule),
},
],
}, //首页
{
path: '', component: NavigationComponent, canActivate: [AuthGuard], children: [
{ path: 'system', loadChildren: () => import('./system-management/system-management.module').then(m => m.SystemManagementModule) }
]
}//系统管理
path: "",
component: NavigationComponent,
canActivate: [AuthGuard],
children: [
{
path: "system",
loadChildren: () =>
import("./system-management/system-management.module").then(
(m) => m.SystemManagementModule
),
},
],
}, //系统管理
];
@NgModule({
imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
exports: [RouterModule]
imports: [RouterModule.forRoot(routes, { relativeLinkResolution: "legacy" })],
exports: [RouterModule],
})
export class AppRoutingModule { }
export class AppRoutingModule {}

2
src/app/app.component.ts

@ -19,7 +19,7 @@ export class AppComponent {
public token: CacheTokenService,
private notificationService: NzNotificationService
) {}
VERSION = 20240521;
VERSION = 20240725;
ngOnInit(): void {
this.sayHello();
}

5
src/app/auth.guard.ts

@ -20,6 +20,7 @@ export class AuthGuard implements CanActivate {
state: RouterStateSnapshot
): Promise<boolean> {
console.log("路由守卫", next);
if (
next.queryParams.singleSignOn &&
next.queryParams.singleSignOn === "true"
@ -40,7 +41,7 @@ export class AuthGuard implements CanActivate {
}
//如果没有token,跳转登录页
this.router.navigate(["/login"]);
// this.router.navigate(["/login"]);
return false;
}
@ -94,4 +95,6 @@ export class AuthGuard implements CanActivate {
);
});
}
}

2
src/app/http-interceptors/base-interceptor.ts

@ -74,7 +74,7 @@ export class BaseInterceptor implements HttpInterceptor {
sessionStorage.clear()
localStorage.removeItem("isautologin")
this.message.create('error', `用户认证信息过期,请重新登录!`);
this.router.navigate(['/login'])
this.router.navigate(['/singlelogin'])
}
if (error.status === 403) {
this.message.create('error', `对不起,您无此权限!`);

3
src/app/pages/pages.module.ts

@ -94,10 +94,11 @@ import { HomePageNologinComponent } from './home-page-nologin/home-page-nologin.
import { DownImageComponent } from './down-image/down-image.component';
import { ImgLookComponent } from './audit/img-look/img-look.component';
import { AnxinImgLookComponent } from './oil-unloading-process/anxin-img-look/anxin-img-look.component';
import { SingleloginComponent } from './singlelogin/singlelogin.component';
@NgModule({
declarations: [LoginComponent, RegisterComponent, HomeComponent, PlanComponent, TodayWarningComponent, CriminalRecordsComponent,
TodayWarningAdminComponent, CriminalRecordsAdminComponent, LeftDomainComponent, EquipmentInfoComponent, OilStationInfoComponent,
AddequipmentComponent, EditequipmentComponent, PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent, ChangePasswordComponent, FacilitySortPipe, WarningStatisticsListComponent, DisposeequipmentComponent, NavBarComponent, InformComponent, UpdateCategoryComponent, FileCategoryComponent, HistoriesComponent, EditUpdateCategoryComponent, DetailsUpdateCategoryComponent, EditFileCategoryComponent, DetailsFileCategoryComponent, PdfWordLookComponent, OilStationListComponent, UpdateLicenseListComponent, FileLicenseListComponent, AuditNavComponent, AuditIngComponent, AuditRecordComponent, AuditInformTimeComponent, AuditDisposeComponent, EditInformTimeComponent, AuditDetailsInformTimeComponent, auditStatusPipe, GasBaseInfoComponent, notificationContent, licenseViolationType, handleState, AnnualInspectionComponent, EditAnnualInspectionComponent, RecordsNavComponent, UserDetailsComponent, AppealDetailsComponent, fileName, SystemModelComponent, ForgetComponent, HomePageNologinComponent, DownImageComponent, ImgLookComponent, AnxinImgLookComponent],
AddequipmentComponent, EditequipmentComponent, PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent, ChangePasswordComponent, FacilitySortPipe, WarningStatisticsListComponent, DisposeequipmentComponent, NavBarComponent, InformComponent, UpdateCategoryComponent, FileCategoryComponent, HistoriesComponent, EditUpdateCategoryComponent, DetailsUpdateCategoryComponent, EditFileCategoryComponent, DetailsFileCategoryComponent, PdfWordLookComponent, OilStationListComponent, UpdateLicenseListComponent, FileLicenseListComponent, AuditNavComponent, AuditIngComponent, AuditRecordComponent, AuditInformTimeComponent, AuditDisposeComponent, EditInformTimeComponent, AuditDetailsInformTimeComponent, auditStatusPipe, GasBaseInfoComponent, notificationContent, licenseViolationType, handleState, AnnualInspectionComponent, EditAnnualInspectionComponent, RecordsNavComponent, UserDetailsComponent, AppealDetailsComponent, fileName, SystemModelComponent, ForgetComponent, HomePageNologinComponent, DownImageComponent, ImgLookComponent, AnxinImgLookComponent, SingleloginComponent],
imports: [

121
src/app/pages/singlelogin/singlelogin.component.html

@ -0,0 +1,121 @@
<nz-modal nzWidth="1300px" [(nzVisible)]="isVisible" nzMaskClosable="false" nzTitle="请绑定用户"
(nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" :nzFooter=" " nzClosable="false" nzKeyboard="false">
<ng-container *nzModalContent>
<div class="userBox">
<div class="orbox">
<div class="topbox2">
<div class="lefttop">
组织机构
</div>
<div class="righttop">
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入机构名称" [(ngModel)]="searchValue" />
</nz-input-group>
</div>
</div>
<div class="treeTitle">
<span>组织机构</span>
<label nz-checkbox [(ngModel)]="IsContainsChildren"
(ngModelChange)="getAllOrganization()">包含子节点</label>
</div>
<div class="treebox">
<nz-tree [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandedKeys]="defaultExpandedKeys" [nzSelectedKeys]='nzSelectedKeys'
(nzClick)="nzClick($event)" [nzExpandedIcon]="multiExpandedIconTpl" [nzHideUnMatched]="true"
[nzTreeTemplate]="nzTreeTemplate">
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox">
<span class="name">{{ node.title }}</span>
<span class="name">({{node.origin.products? node.origin.products.usersCount : 0}})</span>
</div>
</ng-template>
<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>
</div>
</div>
<div class="box">
<div class="topbox">
<div class="lefttop">
<span>用户列表</span>
<span><i nz-icon nzType="search"></i> {{usersNum}}名用户</span>
</div>
<div class="righttop">
<form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
<nz-form-item>
<nz-form-control>
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入用户名" formControlName="search" />
</nz-input-group>
</nz-form-control>
<button style="display: none;" type="submit"></button>
</nz-form-item>
</form>
</div>
</div>
<div class="tablebox" #tablebox>
<nz-table #basicTable [nzLoading]="loading" [nzData]="usersLIst" [nzShowPagination]='false'
[nzPageSize]='16'>
<thead>
<tr>
<th></th>
<th>账号</th>
<th>姓名</th>
<th>角色/预警接收级别</th>
<th [width]="'13%'">所属机构</th>
<th [width]="'8%'">用户状态</th>
<th [width]="'8%'">备注</th>
<th [width]="'10%'">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td><img src="../../../assets/images/user.png" alt=""></td>
<td>{{ data.userName }}</td>
<td>{{ data.name }}</td>
<td nzBreakWord>
<span style="margin-right: 8px;"
*ngFor="let item of data.roleDisplayNames">{{item}}</span>
</td>
<td>
{{data.organizationName}}
</td>
<td>
<ng-container *ngIf="data.isActive; else elseTemplate">
<span class="greenColor2">已启用</span>
</ng-container>
<ng-template #elseTemplate>
<span class="redColor">已停用</span>
</ng-template>
</td>
<td>
{{data.note}}
</td>
<td class="operation">
<span class="blue">绑定</span>
</td>
</tr>
</tbody>
</nz-table>
</div>
<div class="pagination">
<nz-pagination [nzHideOnSinglePage]="false" [nzPageIndex]="1" [nzTotal]="usersNum" [nzPageSize]="16"
[nzShowTotal]="totalTemplate" nzShowQuickJumper (nzPageIndexChange)="pageChange($event)">
</nz-pagination>
<ng-template #totalTemplate let-total> 16条/页,共{{usersNum}}条 </ng-template>
</div>
</div>
</div>
</ng-container>
</nz-modal>

234
src/app/pages/singlelogin/singlelogin.component.scss

@ -0,0 +1,234 @@
.userBox {
width: 100%;
height: 100%;
min-height: 600px;
background: #ffffff;
box-sizing: border-box;
padding: 20px;
overflow: hidden;
display: flex;
position: relative;
.treebox {
display: flex;
flex: 1;
overflow: auto;
flex-direction: column;
box-sizing: border-box;
padding: 10px 0;
}
.check {
width: 100%;
float: right;
}
.topbox2 {
width: 100%;
height: 36px;
display: flex;
align-items: center;
margin-top: 20px;
.lefttop {
height: 36px;
line-height: 36px;
color: #000;
margin-right: 10px;
font-size: 15px;
}
.righttop {
flex: 1;
height: 36px;
display: flex;
nz-input-group {
height: 36px;
}
}
}
.orbox {
width: 260px;
min-width: 250px;
overflow-y: auto;
margin-right: 10px;
display: flex;
flex-direction: column;
}
.treeTitle {
width: 100%;
height: 55px;
line-height: 55px;
margin-top: 12px;
display: flex;
justify-content: space-between;
color: #000d21;
box-sizing: border-box;
padding: 0 10px;
background: rgba(145, 204, 255, 0.2);
border: 1px solid rgba(145, 204, 255, 0.2);
span {
font-size: 14px;
}
div {
flex: 1;
width: 100px;
margin-left: 55px;
}
}
.nodebox {
display: flex;
justify-content: space-between;
}
tbody {
tr {
td:nth-child(1) {
text-align: right;
}
}
.operation {
i {
cursor: pointer;
margin-right: 8px;
}
}
}
}
.box {
flex: 1;
// overflow: auto;
padding-top: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
height: 100%;
}
.topbox {
width: 100%;
height: 36px;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
.lefttop {
span:nth-child(1) {
color: #000d21;
margin-right: 16px;
}
span:nth-child(2) {
color: rgba(36, 36, 36, 0.24);
}
}
.righttop {
display: flex;
button {
margin-left: 16px;
}
nz-input-group {
height: 32px;
}
}
}
.tablebox {
flex: 1;
overflow-y: auto;
overflow: auto;
}
.pagination {
margin: 15px 0;
display: flex;
align-items: center;
justify-content: center;
}
.ortype {
width: 36px;
height: 20px;
background: #2399ff;
opacity: 1;
border-radius: 2px;
font-size: 12px;
margin-right: 8px;
color: #fff;
text-align: center;
}
.resetPasswordContent {
z-index: 999;
width: 380px;
height: 138px;
position: absolute;
left: 30%;
top: 30%;
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
padding-left: 40px;
color: #000;
border-radius: 5px;
border-radius: 2px;
box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%),
0 9px 28px 8px rgb(0 0 0 / 5%);
background: #fff;
.titlebox {
display: flex;
align-items: center;
position: relative;
span {
font-size: 18px;
font-weight: 600;
}
i {
font-size: 26px;
margin-right: 6px;
}
.close {
position: absolute;
right: 2px;
top: -22px;
font-size: 16px;
cursor: pointer;
}
.move {
position: absolute;
left: -32px;
top: -22px;
cursor: move;
}
}
.message {
margin-top: 20px;
i {
cursor: pointer;
}
i:hover {
color: #18bb18;
}
}
}

287
src/app/pages/singlelogin/singlelogin.component.ts

@ -0,0 +1,287 @@
import { HttpClient } from "@angular/common/http";
import { ActivatedRoute } from "@angular/router";
import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core";
import { FormBuilder, FormGroup } from "@angular/forms";
import { NzFormatEmitEvent } from "ng-zorro-antd/tree";
import { TreeService } from "src/app/service/tree.service";
@Component({
selector: "app-singlelogin",
templateUrl: "./singlelogin.component.html",
styleUrls: ["./singlelogin.component.scss"],
})
export class SingleloginComponent implements OnInit {
constructor(
public route: ActivatedRoute,
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService
) {}
async ngOnInit(): Promise<void> {
console.log("查询参数", this.route.snapshot.queryParams.page);
this.bindingUser();
// await this.getCurrentUserInfo();
// await this.getAuthOrganInfos();
if (this.CurrentUserInfo && this.AuthOrganInfos) {
// await this.getSinochemUsers(this.CurrentUserInfo.name);
}
let userdata = JSON.parse(sessionStorage.getItem("userdata"));
if (userdata.userName == "admin") {
//是superadmin,是内部制作账号
this.isAdmin = true;
} else {
this.isAdmin = false;
}
this.validateForm = this.fb.group({
search: [null],
});
this.level = JSON.parse(
sessionStorage.getItem("userdata")
).organization.level;
this.getAllUrl = "/api/services/app/User/GetAll";
this.CountsByOrganizations =
"/api/services/app/User/GetCountsByOrganizations";
this.getAllOrganization();
}
CurrentUserInfo;
AuthOrganInfos;
//获取当前登录用户信息
getCurrentUserInfo() {
return new Promise<void>((resolve, reject) => {
this.http
.get("/p3p/auth/getCurrentUserInfo", {
params: {
token:
"czQre5c933Q_WgQaad1c8HFmLDV9SgiowfLLJgcZnuw8GdpKs6RwCbNdwLnVKmpQ==",
},
})
.subscribe(
(data: any) => {
this.CurrentUserInfo = data;
console.log("当前登录用户信息", this.CurrentUserInfo);
resolve();
},
(err) => {
reject();
}
);
});
}
//获取当前登录用户授权机构
getAuthOrganInfos() {
return new Promise<void>((resolve, reject) => {
this.http
.get("/p3p/auth/getAuthOrganInfos", {
params: {
token:
"czQre5c933Q_WgQaad1c8HFmLDV9SgiowfLLJgcZnuw8GdpKs6RwCbNdwLnVKmpQ==",
},
})
.subscribe(
(data: any) => {
this.AuthOrganInfos = data;
console.log("当前登录用户授权机构", this.CurrentUserInfo);
resolve();
},
(err) => {
reject();
}
);
});
}
//确认中化是否绑定了我们的用户
getSinochemUsers(Keyword) {
return new Promise<void>((resolve, reject) => {
this.http
.get("/api/services/app/User/GetSinochemUsers", {
params: {
Keyword: Keyword,
},
})
.subscribe(
(data: any) => {
console.log("中化用户信息", data);
resolve(data);
},
(err) => {
reject();
}
);
});
}
//中化用户登录获得自己的token信息
SinochemLogin() {
return new Promise<void>((resolve, reject) => {
this.CurrentUserInfo.data.userId = this.CurrentUserInfo.data.id;
delete this.CurrentUserInfo.data.id;
let body = {
user: this.CurrentUserInfo.data,
org: this.AuthOrganInfos.data[0],
sinochemOrgs: this.AuthOrganInfos.data,
};
this.http.post("/api/TokenAuth/SinochemLogin", body).subscribe(
(data: any) => {
console.log("信息验证", data);
resolve();
},
(err) => {
reject();
}
);
});
}
isVisible = false;
//绑定我们自己的用户弹出框
bindingUser() {
this.isVisible = true;
}
handleOk(): void {
console.log("Button ok clicked!");
this.isVisible = false;
}
handleCancel(): void {
console.log("Button cancel clicked!");
this.isVisible = false;
}
level;
getAllUrl;
CountsByOrganizations;
isAdmin: boolean;
nzSelectedKeys: any[] = [];
defaultExpandedKeys = [];
IsContainsChildren = true;
searchValue = "";
totalCount: string;
//获取所有用户
usersLIst: any = [];
usersNum: string;
OrganizationUnitId;
loading: boolean;
organizationsList = [];
validateForm!: FormGroup;
getAllUsers() {
this.loading = true;
let params = {
Keyword: this.validateForm.value.search
? this.validateForm.value.search
: "",
SkipCount: String(this.SkipCount),
MaxResultCount: String(this.MaxResultCount),
OrganizationUnitId: this.OrganizationUnitId,
IsContainsChildren: String(this.IsContainsChildren),
// Sorting: 'BuildingBasicInfo.Id asc'
};
this.http
.get(this.getAllUrl, {
params: params,
})
.subscribe((data: any) => {
this.usersLIst = data.result.items;
this.usersNum = data.result.totalCount;
this.loading = false;
});
}
SkipCount: number = 0; //0 16 32 48
MaxResultCount: number = 16;
pageChange($event) {
this.SkipCount = ($event - 1) * this.MaxResultCount;
this.getAllUsers();
}
//获取所有组织机构
nodes: any = [];
organization;
getAllOrganization() {
let OrganizationUnitId =
sessionStorage.getItem("isGasStation") == "true"
? JSON.parse(sessionStorage.getItem("userdataOfgasstation"))
.organization.id
: JSON.parse(sessionStorage.getItem("userdata")).organization.id;
console.log("OrganizationUnitId", OrganizationUnitId);
let params = {
OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true",
};
this.http
.get("/api/services/app/Organization/GetAll", {
params: params,
})
.subscribe(async (data: any) => {
console.log("获得组织机构", data);
this.organization = data.result.items;
await this.getCountsOr(data.result.items);
this.getAllUsers();
});
}
async getCountsOr(e) {
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",
IsUsersCountContainsChildren: String(this.IsContainsChildren),
};
await new Promise<void>((resolve, reject) => {
this.http
.get(this.CountsByOrganizations, {
params: params,
})
.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++) {
if (arrs[index].id == OrganizationUnitId) {
arrs[index].parentId = null;
}
arrs[index].title = arrs[index].displayName;
arrs[index].key = arrs[index].id;
}
this.nodes = [...this.toTree.toTree(arrs)];
this.defaultExpandedKeys = [this.nodes[0].id];
this.nzSelectedKeys = [this.nodes[0].id];
this.OrganizationUnitId = [this.nodes[0].id];
});
});
}
//搜索框提交
submitForm(): void {
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
this.getAllUsers();
}
nzClick(event: NzFormatEmitEvent) {
this.nzSelectedKeys[0] = event.node.origin.id;
this.nzSelectedKeys = [...this.nzSelectedKeys];
this.OrganizationUnitId = event.node.origin.id;
this.getAllUsers();
}
}

4
src/app/service/pattern.service.ts

@ -4,9 +4,9 @@ import { Injectable } from "@angular/core";
providedIn: "root",
})
export class PatternService {
static isProd: any = true;
static isProd: any = false;
constructor() {}
public isProd: boolean = true; //是否是生产环境
public isProd: boolean = false; //是否是生产环境
}

8
src/app/system-management/organization/organization.component.html

@ -12,7 +12,7 @@
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入单位" [(ngModel)]="searchValue" />
</nz-input-group>
<button nz-button nzType="primary" (click)="addOr()"><i nz-icon nzType="plus-circle"
<button *ngIf="isAdmin" nz-button nzType="primary" (click)="addOr()"><i nz-icon nzType="plus-circle"
nzTheme="outline"></i>新增</button>
</div>
</div>
@ -21,8 +21,8 @@
<span>操作</span>
</div>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" [nzTreeTemplate]="nzTreeTemplate" nzDraggable
nzBlockNode (nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop" [nzExpandedIcon]="multiExpandedIconTpl">
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" [nzTreeTemplate]="nzTreeTemplate"
nzBlockNode [nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox">
@ -31,7 +31,7 @@
<span *ngIf="!node.origin.isGasStation">({{node.origin.products? node.origin.products.stationsCount :
0}})</span>
</span>
<span class="operation" *ngIf="level === 1">
<span class="operation" *ngIf="level === 1 && isAdmin">
<span (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span>
<span (click)="waring(node)" *ngIf="node.origin.isGasStation">配置预警事件</span>
<span (click)="editOr(node)">编辑</span>

10
src/app/system-management/organization/organization.component.ts

@ -38,8 +38,18 @@ export class OrganizationComponent implements OnInit {
private viewContainerRef: ViewContainerRef
) {}
isAdmin: boolean;
level: number; //当前登录账号的组织机构等级
ngOnInit(): void {
let userdata = JSON.parse(sessionStorage.getItem("userdata"));
if (userdata.userName == "admin") {
//是superadmin,是内部制作账号
this.isAdmin = true;
} else {
this.isAdmin = false;
}
this.level = JSON.parse(
sessionStorage.getItem("userdata")
).organization.level;

256
src/app/system-management/user/edituser/edituser.component.ts

@ -1,34 +1,40 @@
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';
import { NzMessageService } from 'ng-zorro-antd/message';
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";
import { NzMessageService } from "ng-zorro-antd/message";
@Component({
selector: 'app-edituser',
templateUrl: './edituser.component.html',
styleUrls: ['./edituser.component.scss']
selector: "app-edituser",
templateUrl: "./edituser.component.html",
styleUrls: ["./edituser.component.scss"],
})
export class EdituserComponent implements OnInit {
@Input() data?: any;
@Input() listOfData?: any;
@Input() listOfData2?: any;
@Input() nodes?: any;
@Input() editUrl?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private message: NzMessageService) { }
constructor(
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService,
private message: NzMessageService
) {}
isAdmin: boolean;
ngOnInit(): void {
console.log(this.data)
let roleData1 = []
let roleData2 = []
this.data.roleNames.forEach(element => {
if (element.indexOf('LEVEL') != -1) {
roleData2.push(element)
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)
roleData1.push(element);
}
});
this.validateForm = this.fb.group({
@ -38,93 +44,122 @@ export class EdituserComponent implements OnInit {
role: [roleData1, [Validators.required]],
role2: [roleData2],
phonenum: [null, [Validators.required]],
note: [null]
note: [null],
});
let userdata = JSON.parse(sessionStorage.getItem("userdata"));
if (userdata.userName == "admin") {
//是superadmin,是内部制作账号
this.isAdmin = true;
} else {
this.isAdmin = false;
this.validateForm.get("account").disable();
this.validateForm.get("name").disable();
this.validateForm.get("organization").disable();
this.validateForm.get("phonenum").disable();
}
if (this.listOfData.length == 0) {
this.getAllRoles()
this.getAllRoles();
}
if (this.listOfData2.length == 0) {
this.getAllRoles2()
this.getAllRoles2();
}
if (this.nodes.length == 0) {
this.getAllOrganization()
this.getAllOrganization();
}
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
this.modal.destroy({ data: "this the result data" });
}
//获取角色列表
async getAllRoles() {
let params = {
SkipCount: '0',
MaxResultCount: '999'
}
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
})
})
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'
}
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
})
})
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
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"
}
IsContainsChildren: "true",
};
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.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.nodes = [...this.toTree.toTree(data.result.items)]
resolve(data)
})
})
});
}
isLoading = false
isLoading = false;
//确定
async ok() {
this.isLoading = true
this.isLoading = true;
if (this.validateForm.valid) {
return await new Promise(resolve => {
for (let index = 0; index < this.validateForm.value.role2.length; index++) {
return await new Promise((resolve) => {
for (
let index = 0;
index < this.validateForm.value.role2.length;
index++
) {
const element = this.validateForm.value.role2[index];
if (element.indexOf('HANDLE') != -1) {
this.validateForm.value.role2.splice(index, 1)
index--
if (element.indexOf("HANDLE") != -1) {
this.validateForm.value.role2.splice(index, 1);
index--;
}
}
let roleNames = [...this.validateForm.value.role, ...this.validateForm.value.role2]
let roleNames = [
...this.validateForm.value.role,
...this.validateForm.value.role2,
];
let body = {
id: this.data.id,
userName: this.validateForm.value.account,
@ -132,22 +167,25 @@ export class EdituserComponent implements OnInit {
organizationUnitId: this.validateForm.value.organization,
roleNames: roleNames,
phoneNumber: this.validateForm.value.phonenum,
note:this.validateForm.value.note,
isActive: true
}
this.http.put(this.editUrl, body).subscribe((data:any) => {
resolve(data)
this.data.auditStatus = data.result.auditStatus
this.isLoading = false
this.message.create('success', '保存成功!');
}, err => {
resolve(err)
this.isLoading = false
this.message.create('warning', '保存失败');
})
})
note: this.validateForm.value.note,
isActive: true,
};
this.http.put(this.editUrl, body).subscribe(
(data: any) => {
resolve(data);
this.data.auditStatus = data.result.auditStatus;
this.isLoading = false;
this.message.create("success", "保存成功!");
},
(err) => {
resolve(err);
this.isLoading = false;
this.message.create("warning", "保存失败");
}
);
});
} else {
this.message.create('warning', '请填写完整!');
this.message.create("warning", "请填写完整!");
}
}
//取消
@ -156,28 +194,38 @@ export class EdituserComponent implements OnInit {
}
//提交审核
async audit(type) {
if (type && this.data.auditStatus == 5) {//提交审核
this.message.create('warning', '审核完成的不能重复提交,请编辑后提交');
return
if (type && this.data.auditStatus == 5) {
//提交审核
this.message.create("warning", "审核完成的不能重复提交,请编辑后提交");
return;
}
if(type){
await this.ok()
if (type) {
await this.ok();
}
this.isLoading = true
let url
type ? url = '/api/services/app/EdittingUser/Commit' : url = '/api/services/app/EdittingUser/Uncommit'
this.http.post(url, '', {
params: {
id: this.data.id
}
}).subscribe((data: any) => {
this.data.auditStatus = data.result.auditStatus
this.isLoading = false
this.message.create('success', type ? '提交审核成功' : '撤销审核成功');
}, err => {
this.isLoading = false
this.message.create('error', type ? '提交审核失败' : '撤销审核失败');
})
this.isLoading = true;
let url;
type
? (url = "/api/services/app/EdittingUser/Commit")
: (url = "/api/services/app/EdittingUser/Uncommit");
this.http
.post(url, "", {
params: {
id: this.data.id,
},
})
.subscribe(
(data: any) => {
this.data.auditStatus = data.result.auditStatus;
this.isLoading = false;
this.message.create(
"success",
type ? "提交审核成功" : "撤销审核成功"
);
},
(err) => {
this.isLoading = false;
this.message.create("error", type ? "提交审核失败" : "撤销审核失败");
}
);
}
}

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

@ -82,7 +82,7 @@
<button style="display: none;" type="submit"></button>
</nz-form-item>
</form>
<button nz-button nzType="primary" (click)="addUser()"><i nz-icon nzType="plus-circle"
<button *ngIf="isAdmin" nz-button nzType="primary" (click)="addUser()"><i nz-icon nzType="plus-circle"
nzTheme="outline"></i>新增</button>
</div>
</div>
@ -143,8 +143,8 @@
nzTooltipTitle="启用" (click)="cancel(data,true)"></i>
<i *ngIf="data.isActive" class="redColor" nz-icon nzType="stop" nzTheme="outline" nz-tooltip
nzTooltipTitle="停用" (click)="cancel(data,false)"></i>
<i class="redColor" nz-icon nzType="poweroff" nzTheme="outline" nz-tooltip nzTooltipTitle="注销"
(click)="delete(data)"></i>
<i *ngIf="isAdmin" class="redColor" nz-icon nzType="poweroff" nzTheme="outline" nz-tooltip
nzTooltipTitle="注销" (click)="delete(data)"></i>
</td>
</tr>
</tbody>

9
src/app/system-management/user/user.component.ts

@ -46,7 +46,16 @@ export class UserComponent implements OnInit {
editUrl;
deleteUrl;
CountsByOrganizations;
isAdmin: boolean;
ngOnInit(): void {
let userdata = JSON.parse(sessionStorage.getItem("userdata"));
if (userdata.userName == "admin") {
//是superadmin,是内部制作账号
this.isAdmin = true;
} else {
this.isAdmin = false;
}
this.validateForm = this.fb.group({
search: [null],
});

Loading…
Cancel
Save