Browse Source

[新增]中台组织机构绑定

test-assets
邵佳豪 6 months ago
parent
commit
0779b377a4
  1. 15
      src/app/pages/home/home.component.html
  2. 1
      src/app/pages/home/home.component.ts
  3. 35
      src/app/system-management/or-binding/or-binding-model/or-binding-model.component.html
  4. 258
      src/app/system-management/or-binding/or-binding-model/or-binding-model.component.scss
  5. 113
      src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts
  6. 32
      src/app/system-management/or-binding/or-binding.component.html
  7. 5
      src/app/system-management/or-binding/or-binding.component.scss
  8. 65
      src/app/system-management/or-binding/or-binding.component.ts

15
src/app/pages/home/home.component.html

@ -25,6 +25,18 @@
<!-- 登录信息按钮 -->
<div class="boxright">
<a style="margin-right: 8px;cursor: pointer; margin-top: 3px;" nz-dropdown [nzDropdownMenu]="usermenu"
[nzTrigger]="'click'" [nzBackdrop]='false'>
<i nz-icon nzType="swap" nzTheme="outline"></i>
</a>
<nz-dropdown-menu #usermenu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item (click)="switchUsers()">用户1</li>
<li nz-menu-item (click)="switchUsers()">用户2</li>
</ul>
</nz-dropdown-menu>
<i (click)="warningSwitch('voice')" nz-icon [ngClass]="{'grey': !isWarningVoice}" class="blue"
style="margin-top: 2px;" nz-tooltip nzTooltipTitle="预警声音开关" nzTooltipPlacement="bottom">
<svg width="20" height="20">
@ -57,6 +69,7 @@
<span style="margin: 0 12px;">|</span>
<span style="margin-right: 8px;"> {{surname}} </span>
<a nz-dropdown [nzDropdownMenu]="menu" [nzTrigger]="'click'" [nzBackdrop]='false'>
<img src="../../../assets/images/head.png" alt="">
</a>
@ -69,9 +82,11 @@
<li nz-menu-item (click)="signOut()">退出系统</li>
</ul>
</nz-dropdown-menu>
<span style="margin: 0 12px;" *ngIf="isGasStationBack">|</span>
<img style="cursor: pointer;" *ngIf="isGasStationBack" src="../../../assets/images/goback.png" alt=""
(click)="goback()">
</div>
</div>

1
src/app/pages/home/home.component.ts

@ -215,6 +215,7 @@ export class HomeComponent implements OnInit {
this.getWarningSwitch();
}
switchUsers() {}
initSelectedItem(event) {
// console.log(666, event);
if (event.url.indexOf("/homepage") !== -1) {

35
src/app/system-management/or-binding/or-binding-model/or-binding-model.component.html

@ -0,0 +1,35 @@
<div class="orbox">
<div class="topbox">
<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 [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandedKeys]="defaultExpandedKeys" [nzTreeTemplate]="nzTreeTemplate" nzBlockNode
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox">
<span class="name">{{ node.title }}</span>
<div class="operation">
<span class="blueColor" (click)="okbinding(node)">绑定机构</span>
</div>
</div>
</ng-template>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length !== 0">
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'"
class="ant-tree-switcher-line-icon"></i>
</ng-container>
</ng-template>
</div>
</div>

258
src/app/system-management/or-binding/or-binding-model/or-binding-model.component.scss

@ -1,224 +1,76 @@
.userBox {
width: 100%;
max-height: 680px;
background: #FFFFFF;
overflow: hidden;
.orbox {
width: 100%;
max-height: 600px;
overflow-y: auto;
margin-right: 10px;
display: flex;
flex-direction: column;
.treebox {
display: flex;
position: relative;
.treebox {
display: flex;
flex: 1;
overflow: auto;
flex-direction: column;
box-sizing: border-box;
padding: 10px 0;
}
.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;
padding-top: 20px;
display: flex;
overflow: auto;
flex-direction: column;
overflow: hidden;
box-sizing: border-box;
padding: 10px 0;
}
.topbox {
.topbox2 {
width: 100%;
height: 36px;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
margin-top: 20px;
.lefttop {
span:nth-child(1) {
color: #000D21;
margin-right: 16px;
}
span:nth-child(2) {
color: rgba(36, 36, 36, 0.24);
}
height: 36px;
line-height: 36px;
color: #000;
margin-right: 10px;
font-size: 15px;
}
.righttop {
flex: 1;
height: 36px;
display: flex;
button {
margin-left: 16px;
}
nz-input-group {
height: 32px;
height: 36px;
}
}
}
.tablebox {
flex: 1;
overflow-y: 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%;
.treeTitle {
width: 100%;
height: 55px;
line-height: 55px;
margin-top: 12px;
display: flex;
flex-direction: column;
justify-content: center;
justify-content: space-between;
color: #000d21;
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;
}
padding: 0 10px;
background: rgba(145, 204, 255, 0.2);
border: 1px solid rgba(145, 204, 255, 0.2);
span {
font-size: 14px;
}
.message {
margin-top: 20px;
i {
cursor: pointer;
}
i:hover {
color: #18bb18;
}
div {
flex: 1;
width: 100px;
margin-left: 55px;
}
}
.nodebox {
display: flex;
width: 100%;
justify-content: space-between;
}
}

113
src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts

@ -1,15 +1,116 @@
import { Component, OnInit } from '@angular/core';
import {
Component,
Input,
OnInit,
TemplateRef,
ViewChild,
ViewContainerRef,
} from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import {
NzFormatEmitEvent,
NzTreeComponent,
NzTreeNodeOptions,
} from "ng-zorro-antd/tree";
import { NzModalService } from "ng-zorro-antd/modal";
import { NzMessageService } from "ng-zorro-antd/message";
import { HttpClient } from "@angular/common/http";
import { TreeService } from "src/app/service/tree.service";
import { NzNotificationService } from "ng-zorro-antd/notification";
@Component({
selector: 'app-or-binding-model',
templateUrl: './or-binding-model.component.html',
styleUrls: ['./or-binding-model.component.scss']
selector: "app-or-binding-model",
templateUrl: "./or-binding-model.component.html",
styleUrls: ["./or-binding-model.component.scss"],
})
export class OrBindingModelComponent implements OnInit {
@Input() data?: any;
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() { }
level;
getAllUrl;
addUrl;
editUrl;
deleteUrl;
isAdmin: boolean;
ngOnInit(): void {
this.level = JSON.parse(
sessionStorage.getItem("userdata")
).organization.level;
this.getAllUrl = "/api/services/app/User/GetAll";
this.getAllOrganization();
}
nzSelectedKeys: any[] = [];
defaultExpandedKeys = [];
IsContainsChildren = true;
searchValue = "";
totalCount: string;
//获取所有用户
//获取所有组织机构
nodes: any = [];
organization;
async 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",
};
await new Promise<void>((resolve, reject) => {
this.http
.get("/api/services/app/Organization/GetAll", {
params: params,
})
.subscribe(async (data: any) => {
this.organization = data.result.items;
for (let index = 0; index < data.result.items.length; index++) {
if (data.result.items[index].id == OrganizationUnitId) {
data.result.items[index].parentId = null;
}
data.result.items[index].title =
data.result.items[index].displayName;
data.result.items[index].key = data.result.items[index].id;
}
this.nodes = [...this.toTree.toTree(data.result.items)];
this.defaultExpandedKeys = [this.nodes[0].id];
});
});
}
okbinding(item) {
console.log(this.data);
console.log(item);
this.modal.confirm({
nzTitle: "确定要绑定到此机构吗?",
nzOkText: "确定",
nzOkType: "primary",
nzOnOk: () => {
this.http
.post("/api/services/app/Organization/SetSinoOrgLocal", null, {
params: {
sinoOrgId: this.data.organId,
localOrgId: item.key,
},
})
.subscribe(() => {
this.message.create("success", "绑定成功");
});
},
nzCancelText: "取消",
nzOnCancel: () => console.log("Cancel"),
});
}
}

32
src/app/system-management/or-binding/or-binding.component.html

@ -3,21 +3,23 @@
<div class="topbox">
<div class="lefttop">
<span>中台组织机构列表</span>
<span><i nz-icon nzType="search"></i> {{listConfig.totalCount}}名用户</span>
<span><i nz-icon nzType="search"></i> {{listConfig.totalCount}}个组织</span>
</div>
<div class="righttop">
<button nz-button nzType="primary" style="margin-right: 12px;" (click)="sync()">同步数据</button>
<label class="isBinding" nz-checkbox [(ngModel)]="listConfig.IsBindingLocal"
(ngModelChange)="submitForm()">是否绑定本地用户</label>
(ngModelChange)="submitForm()">是否绑定本地机构</label>
<form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
<nz-form-item>
<!-- <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>
</nz-form-item> -->
</form>
</div>
</div>
@ -26,27 +28,19 @@
[nzPageSize]='16'>
<thead>
<tr>
<th [width]="'5%'"></th>
<th>账号</th>
<th>账号id</th>
<th>绑定的本地用户id</th>
<th [width]="'8%'">备注</th>
<th>机构名称</th>
<th>机构类型</th>
<th>已绑机构</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.loginName }}</td>
<td>{{ data.userId }}</td>
<td>
{{data.localUserId}}
</td>
<td>
{{data.detail}}
</td>
<td>{{ data.organName }}</td>
<td>{{ getOrganType(data.detail.organType) }}</td>
<td>{{ data.organization?.displayName || '' }}</td>
<td class="operation">
<span class="blueColor" (click)="binding(data)">绑定本地用户</span>
<span class="blueColor" (click)="binding(data)">绑定机构</span>
</td>
</tr>
</tbody>

5
src/app/system-management/or-binding/or-binding.component.scss

@ -87,11 +87,6 @@
}
tbody {
tr {
td:nth-child(1) {
text-align: right;
}
}
.operation {
i {

65
src/app/system-management/or-binding/or-binding.component.ts

@ -12,6 +12,7 @@ import { NzMessageService } from "ng-zorro-antd/message";
import { HttpClient } from "@angular/common/http";
import { TreeService } from "src/app/service/tree.service";
import { NzNotificationService } from "ng-zorro-antd/notification";
import { OrBindingModelComponent } from "./or-binding-model/or-binding-model.component";
// import { BindingComponent } from "./binding/binding.component";
@Component({
selector: "app-or-binding",
@ -25,6 +26,7 @@ export class OrBindingComponent implements OnInit {
private http: HttpClient,
private toTree: TreeService,
private modal: NzModalService,
private message: NzMessageService,
private viewContainerRef: ViewContainerRef
) {}
@ -33,7 +35,7 @@ export class OrBindingComponent implements OnInit {
search: [null],
});
this.getAllUsers();
this.getAllOr();
// this.getAllOrganization();
}
@ -46,7 +48,7 @@ export class OrBindingComponent implements OnInit {
OrganizationUnitId: "",
IsBindingLocal: true,
};
getAllUsers() {
getAllOr() {
this.listConfig.loading = true;
let params = {
Keyword: this.validateForm.value.search
@ -64,7 +66,10 @@ export class OrBindingComponent implements OnInit {
params: params,
})
.subscribe((data: any) => {
console.log("中台用户列表", data);
console.log("中台组织机构列表", data);
data.result.items.forEach((element) => {
element.detail = JSON.parse(element.detail);
});
this.listConfig.usersLIst = data.result.items;
this.listConfig.totalCount = data.result.totalCount;
this.listConfig.loading = false;
@ -75,9 +80,9 @@ export class OrBindingComponent implements OnInit {
MaxResultCount: number = 16;
pageChange($event) {
this.SkipCount = ($event - 1) * this.MaxResultCount;
this.getAllUsers();
this.getAllOr();
}
getAllUrl = "/api/services/app/User/GetSinochemUsers";
getAllUrl = "/api/services/app/Organization/GetSinochemOrgs";
//搜索框提交
submitForm(): void {
@ -85,22 +90,44 @@ export class OrBindingComponent implements OnInit {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
this.getAllUsers();
this.getAllOr();
}
getOrganType(type) {
let obj = {
"00": "总公司",
"01": "省公司",
"05": "管理部门",
"06": "大区公司",
"07": "模块",
"08": "管理区域",
"09": "省子公司",
"10": "油站网点/线上商城",
"11": "油库",
};
return obj[type];
}
binding(data) {
// const modal = this.modal.create({
// nzTitle: "绑定本地用户",
// nzContent: BindingComponent,
// nzViewContainerRef: this.viewContainerRef,
// nzWidth: 1500,
// nzFooter: null,
// nzMaskClosable: false,
// nzComponentParams: {
// data: JSON.parse(JSON.stringify(data)),
// },
// });
// const instance = modal.getContentComponent();
// modal.afterClose.subscribe((result) => this.getAllUsers());
const modal = this.modal.create({
nzTitle: "绑定本地机构",
nzContent: OrBindingModelComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 1500,
nzFooter: null,
nzMaskClosable: false,
nzComponentParams: {
data: JSON.parse(JSON.stringify(data)),
},
});
const instance = modal.getContentComponent();
modal.afterClose.subscribe((result) => this.getAllOr());
}
sync() {
this.http
.post("/api/services/app/OrganizationSync/AutoSinochemOrgRelate", null)
.subscribe((data: any) => {
this.message.create("success", "同步成功");
});
}
}

Loading…
Cancel
Save