jingbowen 2 years ago
parent
commit
16dbbe4534
  1. 23
      src/app/pages/home-page/home-page.component.ts
  2. 2
      src/app/system-management/organization/organization.component.html
  3. 390
      src/app/system-management/organization/organization.component.ts
  4. 7
      src/app/system-management/push/push.component.html
  5. 236
      src/app/system-management/push/push.component.ts

23
src/app/pages/home-page/home-page.component.ts

@ -494,9 +494,6 @@ export class HomePageComponent implements OnInit {
this.getHomeAggregation() this.getHomeAggregation()
this.getUnreadNotification() this.getUnreadNotification()
// this.getAggregations()
setTimeout(() => { setTimeout(() => {
this.getHomeAggregation() this.getHomeAggregation()
}, 10 * 6000); }, 10 * 6000);
@ -576,6 +573,8 @@ export class HomePageComponent implements OnInit {
}) })
} }
//预警图表 //预警图表
equipmentechartdata equipmentechartdata
tools1 tools1
@ -698,23 +697,7 @@ export class HomePageComponent implements OnInit {
} }
this.oilchartbar.setOption(this.oilchartbarOption); this.oilchartbar.setOption(this.oilchartbarOption);
} }
//获取统计信息
getAggregations() {
let organizationUnitId
if (this.router.url.indexOf('petrolStation') != -1) {
organizationUnitId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id
} else {
organizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id
}
let params: any = {
OrganizationUnitId: organizationUnitId,
IsContainsChildren: 'true'
}
this.http.get('/api/services/app/OilUnloadingProcess/GetAllCountByDays', { params: params }).subscribe((data: any) => {
console.log('统计信息', data)
this.refreshEchartsData1(data.result)
})
}
timer timer
rollStart() { rollStart() {
var ROLL_SPEED = 100 var ROLL_SPEED = 100

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

@ -31,7 +31,7 @@
<span *ngIf="!node.origin.isGasStation">({{node.origin.products? node.origin.products.stationsCount : <span *ngIf="!node.origin.isGasStation">({{node.origin.products? node.origin.products.stationsCount :
0}})</span> 0}})</span>
</span> </span>
<span class="operation"> <span class="operation" *ngIf="level === 1">
<span (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span> <span (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span>
<span (click)="waring(node)" *ngIf="node.origin.isGasStation">配置预警事件</span> <span (click)="waring(node)" *ngIf="node.origin.isGasStation">配置预警事件</span>
<span (click)="editOr(node)">编辑</span> <span (click)="editOr(node)">编辑</span>

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

@ -1,31 +1,52 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from "@angular/common/http";
import { Component, OnInit, AfterViewInit, ViewChild, ViewContainerRef } from '@angular/core'; import {
import { TreeService } from 'src/app/service/tree.service'; Component,
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree'; OnInit,
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; AfterViewInit,
import { ModalButtonOptions, NzModalService } from 'ng-zorro-antd/modal'; ViewChild,
import { NzMessageService } from 'ng-zorro-antd/message'; ViewContainerRef,
import { AddorComponent } from './addor/addor.component'; } from "@angular/core";
import { EditorComponent } from './editor/editor.component'; import { TreeService } from "src/app/service/tree.service";
import {
NzFormatEmitEvent,
NzTreeComponent,
NzTreeNodeOptions,
} from "ng-zorro-antd/tree";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { ModalButtonOptions, NzModalService } from "ng-zorro-antd/modal";
import { NzMessageService } from "ng-zorro-antd/message";
import { AddorComponent } from "./addor/addor.component";
import { EditorComponent } from "./editor/editor.component";
import { NzFormatBeforeDropEvent } from 'ng-zorro-antd/tree'; import { NzFormatBeforeDropEvent } from "ng-zorro-antd/tree";
import { Observable, of } from 'rxjs'; import { Observable, of } from "rxjs";
import { delay } from 'rxjs/operators'; import { delay } from "rxjs/operators";
import { WarningEventsComponent } from './warning-events/warning-events.component'; import { WarningEventsComponent } from "./warning-events/warning-events.component";
@Component({ @Component({
selector: 'app-organization', selector: "app-organization",
templateUrl: './organization.component.html', templateUrl: "./organization.component.html",
styleUrls: ['./organization.component.scss'] styleUrls: ["./organization.component.scss"],
}) })
export class OrganizationComponent implements OnInit { export class OrganizationComponent implements OnInit {
validateForm!: FormGroup; validateForm!: FormGroup;
constructor(private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { } constructor(
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService,
private modal: NzModalService,
private message: NzMessageService,
private viewContainerRef: ViewContainerRef
) {}
level: number; //当前登录账号的组织机构等级
ngOnInit(): void { ngOnInit(): void {
this.level = JSON.parse(
sessionStorage.getItem("userdata")
).organization.level;
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
search: [null] search: [null],
}); });
this.getAllOrganization() this.getAllOrganization();
} }
//搜索框提交 //搜索框提交
submitForm(): void { submitForm(): void {
@ -36,69 +57,85 @@ export class OrganizationComponent implements OnInit {
} }
//获取所有组织机构 //获取所有组织机构
searchValue = ''; searchValue = "";
nzExpandAll = false; nzExpandAll = false;
totalCount: string totalCount: string;
allOrList: any allOrList: any;
organization: any organization: any;
isLoading = false isLoading = false;
getAllOrganization() { getAllOrganization() {
this.isLoading = true this.isLoading = true;
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",
} };
this.http.get('/api/services/app/Organization/GetAll', { this.http
params: params .get("/api/services/app/Organization/GetAll", {
}).subscribe((data: any) => { params: params,
this.organization = data.result.items })
this.getStationsNum(data.result.items) .subscribe((data: any) => {
this.totalCount = data.result.totalCount this.organization = data.result.items;
}) this.getStationsNum(data.result.items);
this.totalCount = data.result.totalCount;
});
} }
//获得组织机构下有多少油站 //获得组织机构下有多少油站
stationsList stationsList;
getStationsNum(e) { getStationsNum(e) {
let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id let OrganizationUnitId =
this.http.get('/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true').subscribe((data: any) => { sessionStorage.getItem("isGasStation") == "true"
this.stationsList = data.result ? JSON.parse(sessionStorage.getItem("userdataOfgasstation"))
const arrs = e.map(item => { .organization.id
const data = this.stationsList.find(i => item.id == i.organizationId) : JSON.parse(sessionStorage.getItem("userdata")).organization.id;
return { this.http
...item, .get(
products: data ? data : false "/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true"
} )
}) .subscribe((data: any) => {
for (let index = 0; index < arrs.length; index++) { this.stationsList = data.result;
if (arrs[index].id == OrganizationUnitId) { const arrs = e.map((item) => {
arrs[index].parentId = null const data = this.stationsList.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;
arrs[index].selectable = false;
} }
arrs[index].title = arrs[index].displayName this.nodes = [...this.toTree.toTree(arrs)];
arrs[index].key = arrs[index].id this.defaultExpandedKeys.length == 0
arrs[index].selectable = false ? (this.defaultExpandedKeys = [this.nodes[0].id])
} : (this.defaultExpandedKeys = [...this.defaultExpandedKeys]);
this.nodes = [...this.toTree.toTree(arrs)] this.isLoading = false;
this.defaultExpandedKeys.length == 0 ? this.defaultExpandedKeys = [this.nodes[0].id] : this.defaultExpandedKeys = [...this.defaultExpandedKeys] });
this.isLoading = false
})
} }
@ViewChild("nzTreeComponent", { static: false })
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; nzTreeComponent!: NzTreeComponent;
defaultExpandedKeys = []; defaultExpandedKeys = [];
nodes: any[] = [] nodes: any[] = [];
addOr(node?: any) { addOr(node?: any) {
// console.log(node) // console.log(node)
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: node ? '新增组织机构' : '新增一级组织机构', nzTitle: node ? "新增组织机构" : "新增一级组织机构",
nzContent: AddorComponent, nzContent: AddorComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 288, nzWidth: 288,
@ -106,42 +143,48 @@ export class OrganizationComponent implements OnInit {
nzOnOk: async () => { nzOnOk: async () => {
// console.log('hhhhhhh', instance.validateForm) // console.log('hhhhhhh', instance.validateForm)
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise(resolve => { await new Promise((resolve) => {
let isGasStation let isGasStation;
instance.validateForm.value.OrgnizationLevel == 4 ? isGasStation = true : isGasStation = false instance.validateForm.value.OrgnizationLevel == 4
? (isGasStation = true)
: (isGasStation = false);
let body = { let body = {
parentId: node ? Number(node.key) : null, parentId: node ? Number(node.key) : null,
displayName: instance.validateForm.value.name, displayName: instance.validateForm.value.name,
isGasStation: isGasStation, isGasStation: isGasStation,
isSkipAudit: !instance.validateForm.value.isParticipationAudit, isSkipAudit: !instance.validateForm.value.isParticipationAudit,
level: instance.validateForm.value.OrgnizationLevel, level: instance.validateForm.value.OrgnizationLevel,
} };
this.http.post('/api/services/app/Organization/Create', body).subscribe(data => { this.http
resolve(data) .post("/api/services/app/Organization/Create", body)
this.message.create('success', '创建成功!'); .subscribe(
this.nzTreeComponent.getExpandedNodeList().forEach((item) => { (data) => {
this.defaultExpandedKeys.push(item.key) resolve(data);
}) this.message.create("success", "创建成功!");
this.getAllOrganization() this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
return true this.defaultExpandedKeys.push(item.key);
}, err => { });
resolve(err) this.getAllOrganization();
this.message.create('warning', '创建失败'); return true;
return false },
}) (err) => {
}) resolve(err);
this.message.create("warning", "创建失败");
return false;
}
);
});
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create("warning", "请填写完整!");
return false return false;
} }
} },
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
editOr(node) { editOr(node) {
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '编辑组织机构', nzTitle: "编辑组织机构",
nzContent: EditorComponent, nzContent: EditorComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 288, nzWidth: 288,
@ -151,102 +194,106 @@ export class OrganizationComponent implements OnInit {
nzOnOk: async () => { nzOnOk: async () => {
// console.log('hhhhhhh', instance.validateForm) // console.log('hhhhhhh', instance.validateForm)
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise(resolve => { await new Promise((resolve) => {
let isGasStation let isGasStation;
instance.validateForm.value.OrgnizationLevel == 4 ? isGasStation = true : isGasStation = false instance.validateForm.value.OrgnizationLevel == 4
? (isGasStation = true)
: (isGasStation = false);
let body = { let body = {
id: node.origin.id, id: node.origin.id,
parentId: node.origin.parentId, parentId: node.origin.parentId,
displayName: instance.validateForm.value.name, displayName: instance.validateForm.value.name,
isGasStation: isGasStation, isGasStation: isGasStation,
isSkipAudit: !instance.validateForm.value.isParticipationAudit, isSkipAudit: !instance.validateForm.value.isParticipationAudit,
level: instance.validateForm.value.OrgnizationLevel level: instance.validateForm.value.OrgnizationLevel,
} };
this.http.put('/api/services/app/Organization/Update', body).subscribe(data => { this.http
resolve(data) .put("/api/services/app/Organization/Update", body)
this.message.create('success', '编辑成功!'); .subscribe(
this.nzTreeComponent.getExpandedNodeList().forEach((item) => { (data) => {
this.defaultExpandedKeys.push(item.key) resolve(data);
}) this.message.create("success", "编辑成功!");
this.getAllOrganization() this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
return true this.defaultExpandedKeys.push(item.key);
}, err => { });
resolve(err) this.getAllOrganization();
this.message.create('warning', '编辑失败'); return true;
return false },
}) (err) => {
}) resolve(err);
this.message.create("warning", "编辑失败");
return false;
}
);
});
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create("warning", "请填写完整!");
return false return false;
} }
} },
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
waring(node) { waring(node) {
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '油站预警事件接收情况', nzTitle: "油站预警事件接收情况",
nzContent: WarningEventsComponent, nzContent: WarningEventsComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 388, nzWidth: 388,
nzClassName: 'WarningEvents', nzClassName: "WarningEvents",
nzFooter: null, nzFooter: null,
nzMaskClosable: false, nzMaskClosable: false,
nzComponentParams: { nzComponentParams: {
data: node.origin, data: node.origin,
}, },
nzOnOk: () => { nzOnOk: () => {},
}
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
deleteOr(item) { deleteOr(item) {
console.log(item) console.log(item);
if (item.origin.children && item.origin.children.length != 0) { if (item.origin.children && item.origin.children.length != 0) {
this.message.create('warning', '请先删除所有子节点'); this.message.create("warning", "请先删除所有子节点");
} else { } else {
this.modal.confirm({ this.modal.confirm({
nzTitle: `确定要删除${item.title}这个机构吗?`, nzTitle: `确定要删除${item.title}这个机构吗?`,
nzOkText: '确定', nzOkText: "确定",
nzOkType: 'primary', nzOkType: "primary",
nzOnOk: () => { nzOnOk: () => {
this.http.delete('/api/services/app/Organization/Delete', { this.http
params: { .delete("/api/services/app/Organization/Delete", {
Id: item.origin.id params: {
} Id: item.origin.id,
}).subscribe(data => { },
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
}) })
this.getAllOrganization() .subscribe((data) => {
this.message.create('success', '删除成功!'); this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
}) this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
this.message.create("success", "删除成功!");
});
}, },
nzCancelText: '取消', nzCancelText: "取消",
nzOnCancel: () => { nzOnCancel: () => {},
}
}); });
} }
} }
nzEvent(event: NzFormatEmitEvent): void { nzEvent(event: NzFormatEmitEvent): void {
console.log('event', event) console.log("event", event);
if (this.isDrag) { if (this.isDrag) {
let parentId let parentId;
if (this.pos == 0) {//目标节点内部 if (this.pos == 0) {
parentId = event.node.key //目标节点内部
parentId = event.node.key;
} else { } else {
if (event.node.level == 0) { if (event.node.level == 0) {
parentId = null parentId = null;
} else { } else {
parentId = event.node.origin.parentId parentId = event.node.origin.parentId;
} }
} }
@ -256,24 +303,28 @@ export class OrganizationComponent implements OnInit {
// code: instance.validateForm.value.code, // code: instance.validateForm.value.code,
// displayName: event.dragNode.origin.displayName, // displayName: event.dragNode.origin.displayName,
// isGasStation: event.dragNode.origin.isGasStation // isGasStation: event.dragNode.origin.isGasStation
} };
this.http.post('/api/services/app/Organization/Move', null, { this.http
params: { .post("/api/services/app/Organization/Move", null, {
id: event.dragNode.key, params: {
parentId: parentId, id: event.dragNode.key,
} parentId: parentId,
}).subscribe(data => { },
this.message.create('success', '拖拽成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
}) })
this.getAllOrganization() .subscribe(
return true (data) => {
}, err => { this.message.create("success", "拖拽成功!");
this.message.create('warning', '拖拽失败'); this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
return false this.defaultExpandedKeys.push(item.key);
}) });
this.getAllOrganization();
return true;
},
(err) => {
this.message.create("warning", "拖拽失败");
return false;
}
);
// console.log('this.allOrList', this.allOrList) // console.log('this.allOrList', this.allOrList)
// let orders = {} // let orders = {}
@ -302,7 +353,6 @@ export class OrganizationComponent implements OnInit {
// } // }
// } // }
// let idArr = [] // let idArr = []
// targetNodeData.forEach(i => { // targetNodeData.forEach(i => {
// idArr.push(i.id) // idArr.push(i.id)
@ -323,7 +373,7 @@ export class OrganizationComponent implements OnInit {
// if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个 // if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个
// // console.log("最后") // // console.log("最后")
// array.push(event.dragNode.origin) // array.push(event.dragNode.origin)
// } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个 // } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个
// // console.log("第一") // // console.log("第一")
// array.unshift(event.dragNode.origin) // array.unshift(event.dragNode.origin)
// } else {//如果移入中间位置 // } else {//如果移入中间位置
@ -349,23 +399,21 @@ export class OrganizationComponent implements OnInit {
// this.snackBar.open('排序成功', '确定', config) // this.snackBar.open('排序成功', '确定', config)
// this.refurbishTreeData() // this.refurbishTreeData()
// }) // })
} }
} }
isDrag //是否可以拖动 isDrag; //是否可以拖动
pos//放置位置 pos; //放置位置
beforeDrop = (arg: NzFormatBeforeDropEvent) => { beforeDrop = (arg: NzFormatBeforeDropEvent) => {
console.log('arg', arg) console.log("arg", arg);
if (arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点 if (arg.node.level === 0) {
this.message.create('warning', '不允许拖拽到一级节点'); //如果为数据节点则不允许拖到一级节点
this.isDrag = false this.message.create("warning", "不允许拖拽到一级节点");
this.isDrag = false;
return of(false); return of(false);
} else { } else {
this.isDrag = true this.isDrag = true;
this.pos = arg.pos this.pos = arg.pos;
return of(true) return of(true);
} }
} };
} }

7
src/app/system-management/push/push.component.html

@ -2,7 +2,8 @@
<div class="topbox"> <div class="topbox">
<div class="lefttop"> <div class="lefttop">
<span>通知推送权限配置</span> <span>通知推送权限配置</span>
<label nz-checkbox [(ngModel)]="checked" (ngModelChange)='changeNotePush($event)'>是否开启短信推送</label> <label *ngIf="level === 1" nz-checkbox [(ngModel)]="checked"
(ngModelChange)='changeNotePush($event)'>是否开启短信推送</label>
</div> </div>
<div class="righttop"> <div class="righttop">
<form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()"> <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
@ -26,7 +27,7 @@
<th style="width: 25%;">预警推送范围</th> <th style="width: 25%;">预警推送范围</th>
<!-- <th style="width: 25%;">预警处置范围</th> --> <!-- <th style="width: 25%;">预警处置范围</th> -->
<th style="width: 25%;">短信推送范围</th> <th style="width: 25%;">短信推送范围</th>
<th style="width: 10%;">操作</th> <th style="width: 10%;" *ngIf="level === 1">操作</th>
</tr> </tr>
<tr *ngFor="let item of list"> <tr *ngFor="let item of list">
<td>{{item.eventSystemName}}</td> <td>{{item.eventSystemName}}</td>
@ -40,7 +41,7 @@
<td> <td>
<span class="name" *ngFor="let i of item.noteRoleNames">{{i}}</span> <span class="name" *ngFor="let i of item.noteRoleNames">{{i}}</span>
</td> </td>
<td> <td *ngIf="level === 1">
<span style="color: #2399FF;cursor: pointer;" (click)="edititem(item)">编辑</span> <span style="color: #2399FF;cursor: pointer;" (click)="edititem(item)">编辑</span>
</td> </td>
</tr> </tr>

236
src/app/system-management/push/push.component.ts

@ -1,107 +1,123 @@
import { HttpClient } from '@angular/common/http'; import { HttpClient } from "@angular/common/http";
import { Component, OnInit, ViewContainerRef } from '@angular/core'; import { Component, OnInit, ViewContainerRef } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { NzModalService } from 'ng-zorro-antd/modal'; import { NzModalService } from "ng-zorro-antd/modal";
import { NzMessageService } from 'ng-zorro-antd/message'; import { NzMessageService } from "ng-zorro-antd/message";
import { EditPushItemComponent } from './edit-push-item/edit-push-item.component'; import { EditPushItemComponent } from "./edit-push-item/edit-push-item.component";
@Component({ @Component({
selector: 'app-push', selector: "app-push",
templateUrl: './push.component.html', templateUrl: "./push.component.html",
styleUrls: ['./push.component.scss'] styleUrls: ["./push.component.scss"],
}) })
export class PushComponent implements OnInit { export class PushComponent implements OnInit {
validateForm!: FormGroup; validateForm!: FormGroup;
constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, private http: HttpClient, private message: NzMessageService) { } constructor(
checked private modal: NzModalService,
private viewContainerRef: ViewContainerRef,
private fb: FormBuilder,
private http: HttpClient,
private message: NzMessageService
) {}
checked;
level: number; //当前登录账号的组织机构等级
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
this.level = JSON.parse(
sessionStorage.getItem("userdata")
).organization.level;
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
search: [null] search: [null],
}); });
await this.getPutRoles() await this.getPutRoles();
// await this.getHandleRoles() // await this.getHandleRoles()
await this.getNoteRoles() await this.getNoteRoles();
this.getViolation() this.getViolation();
this.getSetting() this.getSetting();
} }
//获取短信推送状态 //获取短信推送状态
getSetting() { getSetting() {
let params = { let params = {
settingName: 'ViolationSmsSwitch', settingName: "ViolationSmsSwitch",
} };
this.http.get('/api/services/app/Configuration/GetSetting', { params: params }).subscribe((data: any) => { this.http
// console.log('获取短信推送状态', data) .get("/api/services/app/Configuration/GetSetting", { params: params })
data.result == 'true' ? this.checked = true : this.checked = false .subscribe((data: any) => {
}) // console.log('获取短信推送状态', data)
data.result == "true" ? (this.checked = true) : (this.checked = false);
});
} }
changeNotePush(e) { changeNotePush(e) {
console.log(e) console.log(e);
let params = { let params = {
settingName: 'ViolationSmsSwitch', settingName: "ViolationSmsSwitch",
value: e value: e,
} };
this.http.post('/api/services/app/Configuration/SetSetting', '', { params: params }).subscribe((data: any) => { this.http
// console.log('设置短信推送状态成功', data) .post("/api/services/app/Configuration/SetSetting", "", {
if (e) { params: params,
this.message.create('success', '开启成功!'); })
} else { .subscribe((data: any) => {
this.message.create('success', '关闭成功!'); // console.log('设置短信推送状态成功', data)
} if (e) {
}) this.message.create("success", "开启成功!");
} else {
this.message.create("success", "关闭成功!");
}
});
} }
//获取预警类型 //获取预警类型
list: any list: any;
getViolation() { getViolation() {
this.http.get('/api/services/app/Violation/GetAllList').subscribe((data: any) => { this.http
.get("/api/services/app/Violation/GetAllList")
data.result.forEach(element => { .subscribe((data: any) => {
element.pushRoleNames = [] data.result.forEach((element) => {
element.pushRoleIds.forEach(item => { element.pushRoleNames = [];
this.pushRoleIds.forEach(i => { element.pushRoleIds.forEach((item) => {
if (i.id == item) { this.pushRoleIds.forEach((i) => {
element.pushRoleNames.push(i.displayName) if (i.id == item) {
} element.pushRoleNames.push(i.displayName);
}
});
}); });
}); // element.handleRoleNames = []
// element.handleRoleNames = [] // element.handleRoleIds.forEach(item => {
// element.handleRoleIds.forEach(item => { // this.handleRoleIds.forEach(i => {
// this.handleRoleIds.forEach(i => { // if (i.id == item) {
// if (i.id == item) { // element.handleRoleNames.push(i.displayName)
// element.handleRoleNames.push(i.displayName) // }
// } // });
// }); // });
// }); element.noteRoleNames = [];
element.noteRoleNames = [] element.smsPushRoleIds.forEach((item) => {
element.smsPushRoleIds.forEach(item => { this.noteRoleIds.forEach((i) => {
this.noteRoleIds.forEach(i => { if (i.id == item) {
if (i.id == item) { element.noteRoleNames.push(i.displayName);
element.noteRoleNames.push(i.displayName) }
} });
}); });
}); });
this.list = data.result;
console.log("预警类型", this.list);
}); });
this.list = data.result
console.log('预警类型', this.list)
})
} }
//获取推送的角色列表 //获取推送的角色列表
pushRoleIds pushRoleIds;
async getPutRoles() { async getPutRoles() {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Violation/GetPutRoles').subscribe((data: any) => { this.http
this.pushRoleIds = data.result .get("/api/services/app/Violation/GetPutRoles")
resolve(data) .subscribe((data: any) => {
console.log('推送角色', data) this.pushRoleIds = data.result;
}) resolve(data);
}) console.log("推送角色", data);
});
});
} }
// handleRoleIds // handleRoleIds
// //获取处置的角色列表 // //获取处置的角色列表
@ -114,25 +130,24 @@ export class PushComponent implements OnInit {
// }) // })
// }) // })
// } // }
noteRoleIds noteRoleIds;
//获取处置的角色列表 //获取处置的角色列表
async getNoteRoles() { async getNoteRoles() {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
this.http.get('/api/services/app/Violation/GetSmsPutRoles').subscribe((data: any) => { this.http
this.noteRoleIds = data.result .get("/api/services/app/Violation/GetSmsPutRoles")
resolve(data) .subscribe((data: any) => {
console.log('短信角色', data) this.noteRoleIds = data.result;
}) resolve(data);
}) console.log("短信角色", data);
});
});
} }
edititem(item) { edititem(item) {
console.log(item) console.log(item);
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '编辑推送设置', nzTitle: "编辑推送设置",
nzContent: EditPushItemComponent, nzContent: EditPushItemComponent,
nzViewContainerRef: this.viewContainerRef, nzViewContainerRef: this.viewContainerRef,
nzWidth: 400, nzWidth: 400,
@ -145,37 +160,37 @@ export class PushComponent implements OnInit {
nzOnOk: async () => { nzOnOk: async () => {
if (instance.validateForm.valid) { if (instance.validateForm.valid) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
console.log('表单信息', instance.validateForm) console.log("表单信息", instance.validateForm);
let body = { let body = {
id: item.id, id: item.id,
pushRoleIds: instance.validateForm.value.push, pushRoleIds: instance.validateForm.value.push,
// handleRoleIds: instance.validateForm.value.handle, // handleRoleIds: instance.validateForm.value.handle,
smsPushRoleIds: instance.validateForm.value.note smsPushRoleIds: instance.validateForm.value.note,
} };
this.http.put('/api/services/app/Violation/UpdateRoles', body).subscribe({ this.http
next: data => { .put("/api/services/app/Violation/UpdateRoles", body)
resolve(data) .subscribe({
this.message.create('success', '修改成功!'); next: (data) => {
this.getViolation() resolve(data);
return true this.message.create("success", "修改成功!");
}, this.getViolation();
error: err => { return true;
this.message.create('success', '修改失败!'); },
reject(err) error: (err) => {
} this.message.create("success", "修改失败!");
}) reject(err);
}) },
});
});
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create("warning", "请填写完整!");
return false return false;
} }
} },
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
//搜索框提交 //搜索框提交
submitForm(): void { submitForm(): void {
for (const i in this.validateForm.controls) { for (const i in this.validateForm.controls) {
@ -185,11 +200,10 @@ export class PushComponent implements OnInit {
if (this.validateForm.value.search) { if (this.validateForm.value.search) {
this.list = this.list.filter((item) => { this.list = this.list.filter((item) => {
return item.violationType.indexOf(this.validateForm.value.search) != -1 return item.violationType.indexOf(this.validateForm.value.search) != -1;
}) });
} else { } else {
this.getViolation() this.getViolation();
} }
} }
} }

Loading…
Cancel
Save