From 697f701d5fd13732dd82f58624edd3c0aaa765a5 Mon Sep 17 00:00:00 2001 From: Sjh <55341701@qq.com> Date: Fri, 9 Aug 2024 11:20:11 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E5=A4=9A=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=9C=BA=E6=9E=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy.config.json | 5 +- .../audit/audit-ing/audit-ing.component.ts | 14 +- .../audit-record/audit-record.component.ts | 494 ++++---- .../pages/home-page/home-page.component.ts | 2 +- .../file-license-list.component.ts | 14 +- .../pages/plan-admin/plan-admin.component.ts | 230 ++-- .../update-license-list.component.ts | 17 +- .../criminal-records-admin.component.ts | 24 +- .../oil-unloading-process-list.component.ts | 26 +- .../warning-statistics-list.component.ts | 1013 ++++++++++------- .../singlelogin/singlelogin.component.ts | 4 +- .../today-warning-admin.component.ts | 26 +- .../algorithm-config.component.ts | 21 +- .../analysis-of-the-host.component.ts | 384 ++++--- .../or-binding-model.component.ts | 28 +- .../organization/organization.component.ts | 29 +- .../user-binding/binding/binding.component.ts | 29 +- .../user/adduser/adduser.component.ts | 122 +- .../user/edituser/edituser.component.ts | 24 +- .../user/user.component.html | 8 +- .../system-management/user/user.component.ts | 29 +- src/theme.less | 12 +- 22 files changed, 1503 insertions(+), 1052 deletions(-) diff --git a/proxy.config.json b/proxy.config.json index 947c2a5..3bf5489 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -1,14 +1,15 @@ { "/api": { - "target": "http://121.36.37.70:8906/", + "target": "http://10.156.134.54:8906/", "测试1": "http://121.36.37.70:8906/", "测试2": "https://znaq.sinochemoilmarketing.com/", "测试3": "https://gas.anxincloud.cn/", + "中台": "http://10.156.134.54:8906/", "secure": false, "changeOrigin": true }, "/signalr": { - "target": "http://121.36.37.70:8906/", + "target": "http://10.156.134.54:8906/", "secure": false, "ws": true, "logLevel": "debug" diff --git a/src/app/pages/audit/audit-ing/audit-ing.component.ts b/src/app/pages/audit/audit-ing/audit-ing.component.ts index 1cd3527..6c47b78 100644 --- a/src/app/pages/audit/audit-ing/audit-ing.component.ts +++ b/src/app/pages/audit/audit-ing/audit-ing.component.ts @@ -438,8 +438,10 @@ export class AuditIngComponent implements OnInit { async getAllOrganization() { let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) .organization.id; + let OrganizationUnitIds = JSON.parse( + sessionStorage.getItem("userdata") + ).organizations.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; await new Promise((resolve, reject) => { @@ -449,8 +451,14 @@ export class AuditIngComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; diff --git a/src/app/pages/audit/audit-record/audit-record.component.ts b/src/app/pages/audit/audit-record/audit-record.component.ts index 581d42c..cd5ff2c 100644 --- a/src/app/pages/audit/audit-record/audit-record.component.ts +++ b/src/app/pages/audit/audit-record/audit-record.component.ts @@ -1,42 +1,60 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, ElementRef, OnInit, ViewContainerRef } from '@angular/core'; -import { FormBuilder, FormGroup } from '@angular/forms'; -import { NzModalService } from 'ng-zorro-antd/modal'; -import { Observable, fromEvent } from 'rxjs'; -import { debounceTime } from 'rxjs/operators'; -import { TreeService } from 'src/app/service/tree.service'; -import { DetailsFileCategoryComponent } from '../../license/file-category/details-file-category/details-file-category.component'; -import { DetailsUpdateCategoryComponent } from '../../license/update-category/details-update-category/details-update-category.component'; -import { AuditDetailsInformTimeComponent } from '../audit-inform-time/audit-details-inform-time/audit-details-inform-time.component'; -import { AppealDetailsComponent } from '../audit-ing/appeal-details/appeal-details.component'; -import { UserDetailsComponent } from '../audit-ing/user-details/user-details.component'; -import { GasBaseInfoComponent } from '../gas-base-info/gas-base-info.component'; +import { HttpClient } from "@angular/common/http"; +import { Component, ElementRef, OnInit, ViewContainerRef } from "@angular/core"; +import { FormBuilder, FormGroup } from "@angular/forms"; +import { NzModalService } from "ng-zorro-antd/modal"; +import { Observable, fromEvent } from "rxjs"; +import { debounceTime } from "rxjs/operators"; +import { TreeService } from "src/app/service/tree.service"; +import { DetailsFileCategoryComponent } from "../../license/file-category/details-file-category/details-file-category.component"; +import { DetailsUpdateCategoryComponent } from "../../license/update-category/details-update-category/details-update-category.component"; +import { AuditDetailsInformTimeComponent } from "../audit-inform-time/audit-details-inform-time/audit-details-inform-time.component"; +import { AppealDetailsComponent } from "../audit-ing/appeal-details/appeal-details.component"; +import { UserDetailsComponent } from "../audit-ing/user-details/user-details.component"; +import { GasBaseInfoComponent } from "../gas-base-info/gas-base-info.component"; @Component({ - selector: 'app-audit-record', - templateUrl: './audit-record.component.html', - styleUrls: ['./audit-record.component.scss'] + selector: "app-audit-record", + templateUrl: "./audit-record.component.html", + styleUrls: ["./audit-record.component.scss"], }) export class AuditRecordComponent implements OnInit { validateForm!: FormGroup; - constructor(private element: ElementRef, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private toTree: TreeService, private http: HttpClient, private fb: FormBuilder) { } + constructor( + private element: ElementRef, + private modal: NzModalService, + private viewContainerRef: ViewContainerRef, + private toTree: TreeService, + private http: HttpClient, + private fb: FormBuilder + ) {} - list = [] - level = false - tableScrollHeight - resizeListener - startdate - enddate + list = []; + level = false; + tableScrollHeight; + resizeListener; + startdate; + enddate; async ngOnInit(): Promise { - if (JSON.parse(sessionStorage.getItem('userdata')).organization.level == 1) { - this.level = true + if ( + JSON.parse(sessionStorage.getItem("userdata")).organization.level == 1 + ) { + this.level = true; } - this.tableScrollHeight = '100px' + this.tableScrollHeight = "100px"; // 页面监听 - this.resizeListener = fromEvent(window, 'resize').pipe(debounceTime(100)).subscribe((event) => { - let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight - this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' - }); + this.resizeListener = fromEvent(window, "resize") + .pipe(debounceTime(100)) + .subscribe((event) => { + let tableHeader = + this.element.nativeElement.querySelector( + `.ant-table-header` + ).clientHeight; + this.tableScrollHeight = + document.getElementById("tablebox").clientHeight - + tableHeader - + 10 + + "px"; + }); this.validateForm = this.fb.group({ type: [null], info: [null], @@ -50,172 +68,214 @@ export class AuditRecordComponent implements OnInit { let nowY = myDate.getFullYear(); let nowM = myDate.getMonth() + 1; let nowD = myDate.getDate(); - this.enddate = nowY + "-" + (nowM < 10 ? "0" + nowM : nowM) + "-" + (nowD < 10 ? "0" + nowD : nowD);//当前日期 + this.enddate = + nowY + + "-" + + (nowM < 10 ? "0" + nowM : nowM) + + "-" + + (nowD < 10 ? "0" + nowD : nowD); //当前日期 //获取三十天前日期 - let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 29);//最后一个数字30可改,30天的意思 + let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 29); //最后一个数字30可改,30天的意思 let lastY = lw.getFullYear(); let lastM = lw.getMonth() + 1; let lastD = lw.getDate(); - this.startdate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);//三十天之前日期 - - this.getTypeList() - await this.getAllOrganization() - this.getRecordList() + this.startdate = + lastY + + "-" + + (lastM < 10 ? "0" + lastM : lastM) + + "-" + + (lastD < 10 ? "0" + lastD : lastD); //三十天之前日期 + this.getTypeList(); + await this.getAllOrganization(); + this.getRecordList(); - this.warningType() + this.warningType(); } ngOnDestroy(): void { - this.resizeListener.unsubscribe() + this.resizeListener.unsubscribe(); } submitForm(): void { if (this.validateForm.value.datePicker[0].toLocaleDateString) { - this.validateForm.value.datePicker[0] = this.validateForm.value.datePicker[0].toLocaleDateString() + this.validateForm.value.datePicker[0] = + this.validateForm.value.datePicker[0].toLocaleDateString(); } if (this.validateForm.value.datePicker[1].toLocaleDateString) { - this.validateForm.value.datePicker[1] = this.validateForm.value.datePicker[1].toLocaleDateString() + this.validateForm.value.datePicker[1] = + this.validateForm.value.datePicker[1].toLocaleDateString(); } - this.list = [] - this.SkipCount = '0' - this.getRecordList() + this.list = []; + this.SkipCount = "0"; + this.getRecordList(); } resetForm(e: MouseEvent): void { e.preventDefault(); this.validateForm.reset(); this.validateForm.patchValue({ - organization: JSON.parse(sessionStorage.getItem('userdata')).organization.id, + organization: JSON.parse(sessionStorage.getItem("userdata")).organization + .id, datePicker: [this.startdate, this.enddate], }); - this.list = [] - this.SkipCount = '0' - this.getRecordList() + this.list = []; + this.SkipCount = "0"; + this.getRecordList(); } //获取所有组织机构 - nodes: any = [] + nodes: any = []; async getAllOrganization() { - let OrganizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id + let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) + .organization.id; + let OrganizationUnitIds = JSON.parse( + sessionStorage.getItem("userdata") + ).organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, - IsContainsChildren: "true" - } + IsContainsChildren: "true", + }; await new Promise((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.nodes = [...this.toTree.toTree(data.result.items)] - this.validateForm.patchValue({ - organization: JSON.parse(sessionStorage.getItem('userdata')).organization.id, - datePicker: [this.startdate, this.enddate], + this.http + .get("/api/services/app/Organization/GetAll", { + params: params, + }) + .subscribe((data: any) => { + data.result.items.forEach((element) => { + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } + } + element.key = element.id; + element.title = element.displayName; + }); + this.nodes = [...this.toTree.toTree(data.result.items)]; + this.validateForm.patchValue({ + organization: JSON.parse(sessionStorage.getItem("userdata")) + .organization.id, + datePicker: [this.startdate, this.enddate], + }); + resolve(data); }); - resolve(data) - - }) - }) - + }); } //证照类型 - typeLoading - typeList + typeLoading; + typeList; - typeListOfUsers - typeListOfStationData - typeListOfUpdate - typeListOfFile + typeListOfUsers; + typeListOfStationData; + typeListOfUpdate; + typeListOfFile; getTypeList() { - this.typeLoading = true - let promiseArr = [] - let api = ['/api/services/app/ValidityLicenseType/GetAll', '/api/services/app/FileLicenseType/GetAll'] - api.forEach(element => { + this.typeLoading = true; + let promiseArr = []; + let api = [ + "/api/services/app/ValidityLicenseType/GetAll", + "/api/services/app/FileLicenseType/GetAll", + ]; + api.forEach((element) => { promiseArr.push( new Promise((resolve, reject) => { - this.http.get(element, { - params: { - SkipCount: '0', - MaxResultCount: '999' - } - }).subscribe({ - next: (data) => { - resolve(data) - }, - error: err => { - reject(err) - } - }) + this.http + .get(element, { + params: { + SkipCount: "0", + MaxResultCount: "999", + }, + }) + .subscribe({ + next: (data) => { + resolve(data); + }, + error: (err) => { + reject(err); + }, + }); }) - ) + ); }); - Promise.all(promiseArr).then((result) => { - // console.log('审批类型', result) - this.typeListOfUsers = [{ licenseName: '用户信息' }] - this.typeListOfStationData = [{ licenseName: '油站信息' }] - this.typeListOfUpdate = result[0].result.items - this.typeListOfFile = result[1].result.items - this.typeList = [...this.typeListOfUsers, ...this.typeListOfStationData, ...this.typeListOfUpdate, ...this.typeListOfFile] - this.typeLoading = false - }).catch((error) => { - - }) + Promise.all(promiseArr) + .then((result) => { + // console.log('审批类型', result) + this.typeListOfUsers = [{ licenseName: "用户信息" }]; + this.typeListOfStationData = [{ licenseName: "油站信息" }]; + this.typeListOfUpdate = result[0].result.items; + this.typeListOfFile = result[1].result.items; + this.typeList = [ + ...this.typeListOfUsers, + ...this.typeListOfStationData, + ...this.typeListOfUpdate, + ...this.typeListOfFile, + ]; + this.typeLoading = false; + }) + .catch((error) => {}); } - warningTypesDetails - warningTypesDetailsCopy + warningTypesDetails; + warningTypesDetailsCopy; //获得所有预警事件 warningType() { - this.http.get('/api/services/app/Violation/GetAllList').subscribe((data: any) => { - - data.result = data.result.filter((item) => { - return item.eventSystemName != '设备报废临期提醒' && item.eventSystemName != '设备维保临期提醒' && item.eventSystemName != '证照有效期办理提醒' && item.eventSystemName != '证照有效期临期提醒' && item.eventSystemName != '证照年检办理提醒' && item.eventSystemName != '证照年检临期提醒' - }) + this.http + .get("/api/services/app/Violation/GetAllList") + .subscribe((data: any) => { + data.result = data.result.filter((item) => { + return ( + item.eventSystemName != "设备报废临期提醒" && + item.eventSystemName != "设备维保临期提醒" && + item.eventSystemName != "证照有效期办理提醒" && + item.eventSystemName != "证照有效期临期提醒" && + item.eventSystemName != "证照年检办理提醒" && + item.eventSystemName != "证照年检临期提醒" + ); + }); - this.warningTypesDetails = JSON.parse(JSON.stringify(data.result)) - this.warningTypesDetailsCopy = JSON.parse(JSON.stringify(data.result)) //原始数据备份 - // console.log('所有预警事件', this.warningTypesDetailsCopy) - }) + this.warningTypesDetails = JSON.parse(JSON.stringify(data.result)); + this.warningTypesDetailsCopy = JSON.parse(JSON.stringify(data.result)); //原始数据备份 + // console.log('所有预警事件', this.warningTypesDetailsCopy) + }); } - - infoChange(e) { - if (e == '0') { - this.typeList = this.typeListOfStationData - } else if (e == '1') { - this.typeList = this.typeListOfUpdate - } else if (e == '2') { - this.typeList = this.typeListOfUpdate - } else if (e == '3') { - this.typeList = this.typeListOfFile - } else if (e == '4') { - this.typeList = this.typeListOfUsers - } else if (e == '5') { - this.typeList = [...this.warningTypesDetailsCopy] + if (e == "0") { + this.typeList = this.typeListOfStationData; + } else if (e == "1") { + this.typeList = this.typeListOfUpdate; + } else if (e == "2") { + this.typeList = this.typeListOfUpdate; + } else if (e == "3") { + this.typeList = this.typeListOfFile; + } else if (e == "4") { + this.typeList = this.typeListOfUsers; + } else if (e == "5") { + this.typeList = [...this.warningTypesDetailsCopy]; } else { - this.typeList = [...this.typeListOfStationData, ...this.typeListOfUpdate, ...this.typeListOfFile] + this.typeList = [ + ...this.typeListOfStationData, + ...this.typeListOfUpdate, + ...this.typeListOfFile, + ]; } } //历史记录列表 - totalCount//列表总数 - tableSpin = true - SkipCount: string = '0' - MaxResultCount: string = '50' + totalCount; //列表总数 + tableSpin = true; + SkipCount: string = "0"; + MaxResultCount: string = "50"; getRecordList() { - this.tableSpin = true - let endTime = this.validateForm.value.datePicker[1] + ' 23:59:59' - console.log('结束时间', endTime) + this.tableSpin = true; + let endTime = this.validateForm.value.datePicker[1] + " 23:59:59"; + console.log("结束时间", endTime); let params = { - IsContainsChildren: 'true', + IsContainsChildren: "true", OrganizationUnitId: this.validateForm.value.organization, AuditTitle: this.validateForm.value.type, AuditType: this.validateForm.value.info, @@ -226,119 +286,145 @@ export class AuditRecordComponent implements OnInit { Sorting: null, SkipCount: this.SkipCount, MaxResultCount: this.MaxResultCount, - } - this.http.get('/api/services/app/ContentAuditLog/GetHistory', { params }).subscribe((data: any) => { - data.result.items.forEach(element => { - element.itemData = JSON.parse(element.itemData) + }; + this.http + .get("/api/services/app/ContentAuditLog/GetHistory", { params }) + .subscribe((data: any) => { + data.result.items.forEach((element) => { + element.itemData = JSON.parse(element.itemData); + }); + this.list = this.list.concat(data.result.items); + this.list = [...this.list]; + this.totalCount = data.result.totalCount; + this.tableSpin = false; + console.log("审核历史纪录", this.list); + setTimeout(() => { + let tableHeader = + this.element.nativeElement.querySelector( + `.ant-table-header` + ).clientHeight; + this.tableScrollHeight = + document.getElementById("tablebox").clientHeight - + tableHeader - + 10 + + "px"; + }, 0); }); - this.list = this.list.concat(data.result.items); - this.list = [...this.list] - this.totalCount = data.result.totalCount - this.tableSpin = false - console.log('审核历史纪录', this.list) - setTimeout(() => { - let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight - this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' - }, 0); - }) } details(item) { - console.log('点击的item', item) - let component + console.log("点击的item", item); + let component; if (item.auditType == 0) { - component = GasBaseInfoComponent + component = GasBaseInfoComponent; } else if (item.auditType == 1) { - component = AuditDetailsInformTimeComponent + component = AuditDetailsInformTimeComponent; } else if (item.auditType == 2) { - component = DetailsUpdateCategoryComponent + component = DetailsUpdateCategoryComponent; } else if (item.auditType == 4) { - component = UserDetailsComponent + component = UserDetailsComponent; } else if (item.auditType == 5) { - component = AppealDetailsComponent + component = AppealDetailsComponent; } else if (item.auditType) { - component = DetailsFileCategoryComponent + component = DetailsFileCategoryComponent; } - this.getData(item).then(res => { - item.getData = res + this.getData(item).then((res) => { + item.getData = res; if (item.auditType == 1) { - item.getData.organization = item.organization + item.getData.organization = item.organization; } const modal = this.modal.create({ nzContent: component, nzViewContainerRef: this.viewContainerRef, nzWidth: item.auditType == 0 ? 700 : 450, nzBodyStyle: { - 'border': '1px solid #91CCFF', - 'border-radius': '0px', - 'padding': '7px', - 'box-shadow': '0 0 8px 0 #fff', - 'background-image': 'linear-gradient(#003665, #000f25)' + border: "1px solid #91CCFF", + "border-radius": "0px", + padding: "7px", + "box-shadow": "0 0 8px 0 #fff", + "background-image": "linear-gradient(#003665, #000f25)", }, nzStyle: { - 'top': '50px', + top: "50px", }, nzComponentParams: { data: item.getData, }, - nzKeyboard:false, + nzKeyboard: false, nzFooter: null, nzClosable: false, }); - }) + }); } //获取证照类data getData(item) { - let url - if (item.auditType == 0) { //油站基本信息 + let url; + if (item.auditType == 0) { + //油站基本信息 return new Promise((resolve, reject) => { - let organization = { organizationId: item.organizationId } - resolve(organization) - }) + let organization = { organizationId: item.organizationId }; + resolve(organization); + }); } else if (item.auditType == 1) { - url = '/api/services/app/OrganizationValidityLicenseRule/Get' + url = "/api/services/app/OrganizationValidityLicenseRule/Get"; } else if (item.auditType == 2) { - url = '/api/services/app/StationValidityLicense/Get' + url = "/api/services/app/StationValidityLicense/Get"; } else if (item.auditType == 4) { - url = '/api/services/app/EdittingUser/Get' + url = "/api/services/app/EdittingUser/Get"; } else if (item.auditType == 5) { return new Promise((resolve, reject) => { - resolve(item) - }) + resolve(item); + }); } else if (item.auditType) { - url = '/api/services/app/StationFileLicense/Get' + url = "/api/services/app/StationFileLicense/Get"; } return new Promise((resolve, reject) => { - let params = { id: item.itemId } + let params = { id: item.itemId }; this.http.get(url, { params }).subscribe((data: any) => { - let auditLog = { rejectReason: item.rejectReason } - let organization = { displayName: item.organization ? item.organization.displayName : "" } + let auditLog = { rejectReason: item.rejectReason }; + let organization = { + displayName: item.organization ? item.organization.displayName : "", + }; if (item.auditType == 1) { - data.result.auditLog = auditLog - data.result.organization = organization - data.result.handleRemindDaysDefault = data.result.licenseType.handleRemindDays - data.result.closingRemindDaysDefault = data.result.licenseType.closingRemindDays + data.result.auditLog = auditLog; + data.result.organization = organization; + data.result.handleRemindDaysDefault = + data.result.licenseType.handleRemindDays; + data.result.closingRemindDaysDefault = + data.result.licenseType.closingRemindDays; } if (item.auditType == 2 || item.auditType == 3) { - data.result.auditLogId = item.id + data.result.auditLogId = item.id; } if (item.auditType == 4) { - data.result.auditLog = auditLog + data.result.auditLog = auditLog; } - resolve(data.result) - }) - }) + resolve(data.result); + }); + }); } ngAfterViewInit(): void { - fromEvent(this.element.nativeElement.querySelector(`.ant-table-body`) as HTMLCanvasElement, 'scroll').pipe(debounceTime(100)).subscribe((event: any) => { //监听 DOM 滚动事件 - if (event.target.scrollHeight - (event.target.scrollTop + event.target.clientHeight) <= 10) { - if (this.totalCount > this.list.length) { - this.SkipCount = String(Number(this.SkipCount) + 50) - this.getRecordList() + fromEvent( + this.element.nativeElement.querySelector( + `.ant-table-body` + ) as HTMLCanvasElement, + "scroll" + ) + .pipe(debounceTime(100)) + .subscribe((event: any) => { + //监听 DOM 滚动事件 + if ( + event.target.scrollHeight - + (event.target.scrollTop + event.target.clientHeight) <= + 10 + ) { + if (this.totalCount > this.list.length) { + this.SkipCount = String(Number(this.SkipCount) + 50); + this.getRecordList(); + } } - } - }); + }); } } diff --git a/src/app/pages/home-page/home-page.component.ts b/src/app/pages/home-page/home-page.component.ts index 7ebebf7..8ccf9dc 100644 --- a/src/app/pages/home-page/home-page.component.ts +++ b/src/app/pages/home-page/home-page.component.ts @@ -801,7 +801,7 @@ export class HomePageComponent implements OnInit { ? (this.isSpinOfEventWarning = true) : (this.isSpinOfOilDischarge = true); let params = { - OrganizationUnitId: this.organizationUnitId, + // OrganizationUnitId: this.organizationUnitId, IsContainsChildren: true, ViolationTypes: type ? data : null, EventSystemNames: type ? null : data, diff --git a/src/app/pages/plan-admin/file-license-list/file-license-list.component.ts b/src/app/pages/plan-admin/file-license-list/file-license-list.component.ts index 110c1c1..536f893 100644 --- a/src/app/pages/plan-admin/file-license-list/file-license-list.component.ts +++ b/src/app/pages/plan-admin/file-license-list/file-license-list.component.ts @@ -88,8 +88,10 @@ export class FileLicenseListComponent implements OnInit { async getAllOrganization() { let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) .organization.id; + let OrganizationUnitIds = JSON.parse( + sessionStorage.getItem("userdata") + ).organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; await new Promise((resolve, reject) => { @@ -99,8 +101,14 @@ export class FileLicenseListComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; diff --git a/src/app/pages/plan-admin/plan-admin.component.ts b/src/app/pages/plan-admin/plan-admin.component.ts index f584e51..1f9ce81 100644 --- a/src/app/pages/plan-admin/plan-admin.component.ts +++ b/src/app/pages/plan-admin/plan-admin.component.ts @@ -1,161 +1,181 @@ -import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { TreeService } from 'src/app/service/tree.service'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { NzContextMenuService, NzDropdownMenuComponent } from 'ng-zorro-antd/dropdown'; -import { NzFormatEmitEvent, NzTreeComponent, NzTreeNode } from 'ng-zorro-antd/tree'; -import { Router } from '@angular/router'; -import { NavChangeService } from 'src/app/service/navChange.service'; -import { fromEvent } from 'rxjs'; -import { debounceTime } from 'rxjs/operators'; -import { OilStationListComponent } from './oil-station-list/oil-station-list.component'; -import { UpdateLicenseListComponent } from './update-license-list/update-license-list.component'; -import { FileLicenseListComponent } from './file-license-list/file-license-list.component'; +import { Component, OnInit, ViewChild, ElementRef } from "@angular/core"; +import { HttpClient } from "@angular/common/http"; +import { TreeService } from "src/app/service/tree.service"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; +import { + NzContextMenuService, + NzDropdownMenuComponent, +} from "ng-zorro-antd/dropdown"; +import { + NzFormatEmitEvent, + NzTreeComponent, + NzTreeNode, +} from "ng-zorro-antd/tree"; +import { Router } from "@angular/router"; +import { NavChangeService } from "src/app/service/navChange.service"; +import { fromEvent } from "rxjs"; +import { debounceTime } from "rxjs/operators"; +import { OilStationListComponent } from "./oil-station-list/oil-station-list.component"; +import { UpdateLicenseListComponent } from "./update-license-list/update-license-list.component"; +import { FileLicenseListComponent } from "./file-license-list/file-license-list.component"; @Component({ - selector: 'app-plan-admin', - templateUrl: './plan-admin.component.html', - styleUrls: ['./plan-admin.component.scss'] + selector: "app-plan-admin", + templateUrl: "./plan-admin.component.html", + styleUrls: ["./plan-admin.component.scss"], }) export class PlanAdminComponent implements OnInit { - - @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; - @ViewChild('child') oilStationListComponent!: OilStationListComponent;; - @ViewChild('child2') updateLicenseListComponent!: UpdateLicenseListComponent;; - @ViewChild('child3') fileLicenseListComponent!: FileLicenseListComponent;; - constructor(private element: ElementRef, private navChangeService: NavChangeService, private http: HttpClient, private toTree: TreeService, private fb: FormBuilder, private nzContextMenuService: NzContextMenuService, private router: Router) { } + @ViewChild("nzTreeComponent", { static: false }) + nzTreeComponent!: NzTreeComponent; + @ViewChild("child") oilStationListComponent!: OilStationListComponent; + @ViewChild("child2") updateLicenseListComponent!: UpdateLicenseListComponent; + @ViewChild("child3") fileLicenseListComponent!: FileLicenseListComponent; + constructor( + private element: ElementRef, + private navChangeService: NavChangeService, + private http: HttpClient, + private toTree: TreeService, + private fb: FormBuilder, + private nzContextMenuService: NzContextMenuService, + private router: Router + ) {} ngOnInit(): void { - this.getAllOrganization() + this.getAllOrganization(); } - - //选择右侧tab页 - selectedTab = 0 + selectedTab = 0; selectTab(index) { - this.selectedTab = index + this.selectedTab = index; if (this.selectedTab == 0) { setTimeout(() => { - this.oilStationListComponent.list = [] - this.oilStationListComponent.SkipCount = '0' - this.oilStationListComponent.onChildMethod() + this.oilStationListComponent.list = []; + this.oilStationListComponent.SkipCount = "0"; + this.oilStationListComponent.onChildMethod(); }, 0); } if (this.selectedTab == 1) { setTimeout(() => { - this.updateLicenseListComponent.list = [] - this.updateLicenseListComponent.SkipCount = '0' - this.updateLicenseListComponent.onChildMethod() + this.updateLicenseListComponent.list = []; + this.updateLicenseListComponent.SkipCount = "0"; + this.updateLicenseListComponent.onChildMethod(); }, 0); } if (this.selectedTab == 2) { setTimeout(() => { - this.fileLicenseListComponent.list = [] - this.fileLicenseListComponent.SkipCount = '0' - this.fileLicenseListComponent.onChildMethod() + this.fileLicenseListComponent.list = []; + this.fileLicenseListComponent.SkipCount = "0"; + this.fileLicenseListComponent.onChildMethod(); }, 0); } } - //获取所有组织机构 - nodes: any = [] - nzExpandAll = false - nzSelectedKeys: any = [] - orSpin: boolean = false - organization: any + nodes: any = []; + nzExpandAll = false; + nzSelectedKeys: any = []; + orSpin: boolean = false; + organization: any; getAllOrganization() { - this.orSpin = true - let OrganizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id + this.orSpin = true; + let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) + .organization.id; let params = { - OrganizationUnitId: OrganizationUnitId, - IsContainsChildren: "true" - } - this.http.get('/api/services/app/Organization/GetAll', { - params: params - }).subscribe((data: any) => { - data.result.items = data.result.items.filter((item, i) => { - return !item.isGasStation + // OrganizationUnitId: OrganizationUnitId, + IsContainsChildren: "true", + }; + this.http + .get("/api/services/app/Organization/GetAll", { + params: params, }) - this.organization = data.result.items - this.getStationsNum(data.result.items) - }) + .subscribe((data: any) => { + data.result.items = data.result.items.filter((item, i) => { + return !item.isGasStation; + }); + this.organization = data.result.items; + this.getStationsNum(data.result.items); + }); } - //获得组织机构下有多少油站 - stationsList + stationsList; getStationsNum(e) { - let OrganizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id - this.http.get('/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true').subscribe((data: any) => { - this.stationsList = data.result - const arrs = e.map(item => { - 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 + let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) + .organization.id; + let OrganizationUnitIds = JSON.parse( + sessionStorage.getItem("userdata") + ).organizations.map((v) => v.id); + this.http + .get( + "/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true" + ) + .subscribe((data: any) => { + this.stationsList = data.result; + const arrs = e.map((item) => { + 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 (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(arrs[index].id)) { + arrs[index].parentId = null; + } + } else { + if (arrs[index].id == OrganizationUnitId) { + 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.orSpin = false - this.nodes = [...this.toTree.toTree(arrs)] - this.nzExpandedKeys = [OrganizationUnitId] - this.nzSelectedKeys = [OrganizationUnitId] - sessionStorage.setItem('planAdminOrid', OrganizationUnitId) - this.oilStationListComponent.onChildMethod() - }) + this.orSpin = false; + this.nodes = [...this.toTree.toTree(arrs)]; + + console.log("树形结构", this.nodes); + this.nzExpandedKeys = [OrganizationUnitId]; + this.nzSelectedKeys = [OrganizationUnitId]; + sessionStorage.setItem("planAdminOrid", OrganizationUnitId); + this.oilStationListComponent.onChildMethod(); + }); } - - - - - nzExpandedKeys: any = [] + nzExpandedKeys: any = []; activatedNode?: NzTreeNode; //点击tree节点 activeNode(data: NzFormatEmitEvent): void { this.activatedNode = data.node!; - sessionStorage.setItem('planAdminOrid', data.node.origin.id) + sessionStorage.setItem("planAdminOrid", data.node.origin.id); if (this.selectedTab == 0) { setTimeout(() => { - this.oilStationListComponent.list = [] - this.oilStationListComponent.SkipCount = '0' - this.oilStationListComponent.onChildMethod() + this.oilStationListComponent.list = []; + this.oilStationListComponent.SkipCount = "0"; + this.oilStationListComponent.onChildMethod(); }, 0); } if (this.selectedTab == 1) { setTimeout(() => { - this.updateLicenseListComponent.list = [] - this.updateLicenseListComponent.SkipCount = '0' - this.updateLicenseListComponent.onChildMethod() + this.updateLicenseListComponent.list = []; + this.updateLicenseListComponent.SkipCount = "0"; + this.updateLicenseListComponent.onChildMethod(); }, 0); } if (this.selectedTab == 2) { setTimeout(() => { - this.fileLicenseListComponent.list = [] - this.fileLicenseListComponent.SkipCount = '0' - this.fileLicenseListComponent.onChildMethod() + this.fileLicenseListComponent.list = []; + this.fileLicenseListComponent.SkipCount = "0"; + this.fileLicenseListComponent.onChildMethod(); }, 0); } } - - - - - - - expand(e, node) { - e.stopPropagation() - node.isExpanded = !node.isExpanded + e.stopPropagation(); + node.isExpanded = !node.isExpanded; } - } diff --git a/src/app/pages/plan-admin/update-license-list/update-license-list.component.ts b/src/app/pages/plan-admin/update-license-list/update-license-list.component.ts index 9a50940..47791c2 100644 --- a/src/app/pages/plan-admin/update-license-list/update-license-list.component.ts +++ b/src/app/pages/plan-admin/update-license-list/update-license-list.component.ts @@ -84,8 +84,11 @@ export class UpdateLicenseListComponent implements OnInit { async getAllOrganization() { let OrganizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) .organization.id; + + let OrganizationUnitIds = JSON.parse( + sessionStorage.getItem("userdata") + ).organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; await new Promise((resolve, reject) => { @@ -95,8 +98,14 @@ export class UpdateLicenseListComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; @@ -287,7 +296,7 @@ export class UpdateLicenseListComponent implements OnInit { }, nzFooter: null, nzClosable: false, - nzKeyboard:false, + nzKeyboard: false, nzOnOk: async () => {}, }); const instance = modal.getContentComponent(); diff --git a/src/app/pages/records/criminal-records-admin/criminal-records-admin.component.ts b/src/app/pages/records/criminal-records-admin/criminal-records-admin.component.ts index 455c366..55c645e 100644 --- a/src/app/pages/records/criminal-records-admin/criminal-records-admin.component.ts +++ b/src/app/pages/records/criminal-records-admin/criminal-records-admin.component.ts @@ -476,13 +476,15 @@ export class CriminalRecordsAdminComponent implements OnInit { //获取所有组织机构 nodes: any = []; getAllOrganization() { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; this.http @@ -491,8 +493,14 @@ export class CriminalRecordsAdminComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; diff --git a/src/app/pages/records/oil-unloading-process-list/oil-unloading-process-list.component.ts b/src/app/pages/records/oil-unloading-process-list/oil-unloading-process-list.component.ts index 1cf8792..d907553 100644 --- a/src/app/pages/records/oil-unloading-process-list/oil-unloading-process-list.component.ts +++ b/src/app/pages/records/oil-unloading-process-list/oil-unloading-process-list.component.ts @@ -143,7 +143,7 @@ export class OilUnloadingProcessListComponent implements OnInit { let nowY = myDate.getFullYear(); let nowM = myDate.getMonth() + 1; let nowD = myDate.getDate(); - + this.enddate = nowY + "-" + @@ -698,13 +698,15 @@ export class OilUnloadingProcessListComponent implements OnInit { //获取所有组织机构 nodes: any = []; getAllOrganization() { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; this.http @@ -713,8 +715,14 @@ export class OilUnloadingProcessListComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; diff --git a/src/app/pages/records/warning-statistics-list/warning-statistics-list.component.ts b/src/app/pages/records/warning-statistics-list/warning-statistics-list.component.ts index 0c9c63c..52c875e 100644 --- a/src/app/pages/records/warning-statistics-list/warning-statistics-list.component.ts +++ b/src/app/pages/records/warning-statistics-list/warning-statistics-list.component.ts @@ -1,196 +1,258 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, ViewContainerRef, ElementRef } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import * as echarts from 'echarts'; -import { NzModalService } from 'ng-zorro-antd/modal'; -import * as moment from 'moment'; -import { fromEvent } from 'rxjs'; -import { debounceTime, filter } from 'rxjs/operators'; -import { Router } from '@angular/router'; -import { TreeService } from 'src/app/service/tree.service'; -import { DisposeequipmentComponent } from './disposeequipment/disposeequipment.component'; -import { NzMessageService } from 'ng-zorro-antd/message'; -import { GetOutOfLineDetailsComponent } from '../../today-warning/get-out-of-line-details/get-out-of-line-details.component'; +import { HttpClient } from "@angular/common/http"; +import { Component, OnInit, ViewContainerRef, ElementRef } from "@angular/core"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; +import * as echarts from "echarts"; +import { NzModalService } from "ng-zorro-antd/modal"; +import * as moment from "moment"; +import { fromEvent } from "rxjs"; +import { debounceTime, filter } from "rxjs/operators"; +import { Router } from "@angular/router"; +import { TreeService } from "src/app/service/tree.service"; +import { DisposeequipmentComponent } from "./disposeequipment/disposeequipment.component"; +import { NzMessageService } from "ng-zorro-antd/message"; +import { GetOutOfLineDetailsComponent } from "../../today-warning/get-out-of-line-details/get-out-of-line-details.component"; @Component({ - selector: 'app-warning-statistics-list', - templateUrl: './warning-statistics-list.component.html', - styleUrls: ['./warning-statistics-list.component.scss'] + selector: "app-warning-statistics-list", + templateUrl: "./warning-statistics-list.component.html", + styleUrls: ["./warning-statistics-list.component.scss"], }) export class WarningStatisticsListComponent implements OnInit { - validateForm!: FormGroup; - constructor(private toTree: TreeService, private message: NzMessageService, private http: HttpClient, private fb: FormBuilder, private router: Router, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private element: ElementRef) { } - - myChart: any //左侧饼图 - mybarChart: any //柱状图 - isEcharts: boolean = true + constructor( + private toTree: TreeService, + private message: NzMessageService, + private http: HttpClient, + private fb: FormBuilder, + private router: Router, + private modal: NzModalService, + private viewContainerRef: ViewContainerRef, + private element: ElementRef + ) {} + + myChart: any; //左侧饼图 + mybarChart: any; //柱状图 + isEcharts: boolean = true; isEchartsShow() { - this.isEcharts = !this.isEcharts + this.isEcharts = !this.isEcharts; setTimeout(() => { - let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight - this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' + let tableHeader = + this.element.nativeElement.querySelector( + `.ant-table-header` + ).clientHeight; + this.tableScrollHeight = + document.getElementById("tablebox").clientHeight - + tableHeader - + 10 + + "px"; }, 0); } - startdate - enddate + startdate; + enddate; - isOrShow: boolean + isOrShow: boolean; - isMisinformation: boolean = false//误报按钮的显隐 - button = false - tableScrollHeight - resizeListener + isMisinformation: boolean = false; //误报按钮的显隐 + button = false; + tableScrollHeight; + resizeListener; ngOnInit(): void { - this.getLicense() - this.tableScrollHeight = '100px' + this.getLicense(); + this.tableScrollHeight = "100px"; // 页面监听 - this.resizeListener = fromEvent(window, 'resize').pipe(debounceTime(100)).subscribe((event) => { - let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight - this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' - }); + this.resizeListener = fromEvent(window, "resize") + .pipe(debounceTime(100)) + .subscribe((event) => { + let tableHeader = + this.element.nativeElement.querySelector( + `.ant-table-header` + ).clientHeight; + this.tableScrollHeight = + document.getElementById("tablebox").clientHeight - + tableHeader - + 10 + + "px"; + }); - let loginUserInfo - if (sessionStorage.getItem('isGasStation') == 'true') { - loginUserInfo = JSON.parse(sessionStorage.getItem('userdataOfgasstation')) - this.returnLastMenus(true) + let loginUserInfo; + if (sessionStorage.getItem("isGasStation") == "true") { + loginUserInfo = JSON.parse( + sessionStorage.getItem("userdataOfgasstation") + ); + this.returnLastMenus(true); } else { - loginUserInfo = JSON.parse(sessionStorage.getItem('userdata')) - this.returnLastMenus(false) + loginUserInfo = JSON.parse(sessionStorage.getItem("userdata")); + this.returnLastMenus(false); } - if (loginUserInfo.roles.find((item) => { - return item.name == 'ViolationPositiveCensorer' - })) { - this.isMisinformation = true + if ( + loginUserInfo.roles.find((item) => { + return item.name == "ViolationPositiveCensorer"; + }) + ) { + this.isMisinformation = true; } else { - this.isMisinformation = false + this.isMisinformation = false; } //当前日期 let myDate: any = new Date(); let nowY = myDate.getFullYear(); let nowM = myDate.getMonth() + 1; let nowD = myDate.getDate(); - this.enddate = JSON.parse(JSON.stringify(nowY + "-" + (nowM < 10 ? "0" + nowM : nowM) + "-" + (nowD < 10 ? "0" + nowD : nowD)));//当前日期 + this.enddate = JSON.parse( + JSON.stringify( + nowY + + "-" + + (nowM < 10 ? "0" + nowM : nowM) + + "-" + + (nowD < 10 ? "0" + nowD : nowD) + ) + ); //当前日期 //获取三十天前日期 - let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 29);//最后一个数字30可改,30天的意思 + let lw = new Date(myDate - 1000 * 60 * 60 * 24 * 29); //最后一个数字30可改,30天的意思 let lastY = lw.getFullYear(); let lastM = lw.getMonth() + 1; let lastD = lw.getDate(); - this.startdate = JSON.parse(JSON.stringify(lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD)));//三十天之前日期 + this.startdate = JSON.parse( + JSON.stringify( + lastY + + "-" + + (lastM < 10 ? "0" + lastM : lastM) + + "-" + + (lastD < 10 ? "0" + lastD : lastD) + ) + ); //三十天之前日期 this.validateForm = this.fb.group({ type: null, eventSystemName: null, organization: [null], licenseType: [null], - datePicker: [[this.startdate, this.enddate]] + datePicker: [[this.startdate, this.enddate]], }); setTimeout(() => { // 饼图 - this.myChart = echarts.init(document.getElementById('piechart')); + this.myChart = echarts.init(document.getElementById("piechart")); //柱状折线图 - this.mybarChart = echarts.init(document.getElementById('barchart')); + this.mybarChart = echarts.init(document.getElementById("barchart")); }, 0); - this.tableSpin = true - this.getAllOrganization() - this.getAggregations() - if (this.router.url.indexOf('petrolStation') != -1) { - this.isOrShow = false + this.tableSpin = true; + this.getAllOrganization(); + this.getAggregations(); + if (this.router.url.indexOf("petrolStation") != -1) { + this.isOrShow = false; } else { - this.isOrShow = true + this.isOrShow = true; } } ngOnDestroy(): void { - this.resizeListener.unsubscribe() + this.resizeListener.unsubscribe(); } returnLastMenus(e) { - let userMenu + let userMenu; if (e) { - userMenu = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).menus + userMenu = JSON.parse( + sessionStorage.getItem("userdataOfgasstation") + ).menus; } else { - userMenu = JSON.parse(sessionStorage.getItem('userdata')).menus + userMenu = JSON.parse(sessionStorage.getItem("userdata")).menus; } for (let index = 0; index < userMenu.length; index++) { for (let k = 0; k < userMenu.length; k++) { if (userMenu[index].name == "证照预警统计") { if (userMenu[index].id == userMenu[k].parentId) { - this.button = true + this.button = true; } } } } - return + return; } - listOfData//证照列表 + listOfData; //证照列表 //获取证照列表 getLicense() { let params = { - SkipCount: '0', - MaxResultCount: '999' - } - this.http.get('/api/services/app/ValidityLicenseType/GetAll', { - params: params - }).subscribe((data: any) => { - console.log('证照列表', data.result.items) - this.listOfData = data.result.items - }) + SkipCount: "0", + MaxResultCount: "999", + }; + this.http + .get("/api/services/app/ValidityLicenseType/GetAll", { + params: params, + }) + .subscribe((data: any) => { + console.log("证照列表", data.result.items); + this.listOfData = data.result.items; + }); } - isListOfData = false + isListOfData = false; typeChange1(e) { if (e) { - if (e == '证照') { - this.isListOfData = true - this.eventSystemNameOption = [...this.eventSystemNameOptionOfLicense] - } else if (e == '设备') { - this.isListOfData = false + if (e == "证照") { + this.isListOfData = true; + this.eventSystemNameOption = [...this.eventSystemNameOptionOfLicense]; + } else if (e == "设备") { + this.isListOfData = false; this.validateForm.patchValue({ - licenseType: [] + licenseType: [], }); - this.eventSystemNameOption = [...this.eventSystemNameOptionOfEquipment] + this.eventSystemNameOption = [...this.eventSystemNameOptionOfEquipment]; } } else { - this.isListOfData = false + this.isListOfData = false; this.validateForm.patchValue({ - licenseType: [] + licenseType: [], }); - this.eventSystemNameOption = [...this.eventSystemNameOptionOfEquipment, ...this.eventSystemNameOptionOfLicense] + this.eventSystemNameOption = [ + ...this.eventSystemNameOptionOfEquipment, + ...this.eventSystemNameOptionOfLicense, + ]; } } typeChange2(e) { if (e) { - let obj - this.eventSystemNameOption.forEach(item => { + let obj; + this.eventSystemNameOption.forEach((item) => { if (item.id == e) { - obj = item + obj = item; } - }) - if (obj.name.indexOf('证照') != -1) { - this.isListOfData = true + }); + if (obj.name.indexOf("证照") != -1) { + this.isListOfData = true; } else { - this.isListOfData = false + this.isListOfData = false; this.validateForm.patchValue({ - licenseType: [] + licenseType: [], }); } } else { - this.isListOfData = false + this.isListOfData = false; this.validateForm.patchValue({ - licenseType: [] + licenseType: [], }); } } //刷新饼图图表数据 - num - echartsData: any + num; + echartsData: any; //一级饼图 oilchartpieOption = { - color: ['#91CCFF', '#46DFFF', '#36A2FF', '#FF6181', '#B4C3FF', '#FF9963', '#5A9CFF', '#4BFFD4', '#46DFFF', '#91CCFF'], + color: [ + "#91CCFF", + "#46DFFF", + "#36A2FF", + "#FF6181", + "#B4C3FF", + "#FF9963", + "#5A9CFF", + "#4BFFD4", + "#46DFFF", + "#91CCFF", + ], tooltip: { - trigger: 'item'//触发类型 + trigger: "item", //触发类型 }, // legend: { // bottom: '12%', @@ -219,109 +281,120 @@ export class WarningStatisticsListComponent implements OnInit { // }, series: [ { - type: 'pie', - radius: ['50%', '60%'], + type: "pie", + radius: ["50%", "60%"], // bottom: '10%', - avoidLabelOverlap: false,//防止标签重叠策略 - label: {//每一个标签外网延伸的引导说明 + avoidLabelOverlap: false, //防止标签重叠策略 + label: { + //每一个标签外网延伸的引导说明 show: false, - position: 'outside' + position: "outside", }, data: [], - tooltip: {//鼠标移入提示 - position: 'right', + tooltip: { + //鼠标移入提示 + position: "right", padding: [14, 19], - backgroundColor: 'rgba(28, 129, 218, 0.4)', + backgroundColor: "rgba(28, 129, 218, 0.4)", textStyle: { - color: '#fff', - fontSize: 12 - } - } - } - ] + color: "#fff", + fontSize: 12, + }, + }, + }, + ], }; - oilchartpieOptionPieData1: any + oilchartpieOptionPieData1: any; //一级柱状图 oilchartbarOption = { xAxis: { - type: 'category', + type: "category", data: [], axisLine: { show: false, lineStyle: { - color: '#91CCFF' - } + color: "#91CCFF", + }, }, - axisTick: {//刻度线 - show: false + axisTick: { + //刻度线 + show: false, }, - inverse: true + inverse: true, }, yAxis: { - type: 'value', + type: "value", nameTextStyle: { - color: '#C4E2FC' + color: "#C4E2FC", }, - splitLine: {//分割线 + splitLine: { + //分割线 lineStyle: { - color: ['#0f4374'], - width: 2 - } + color: ["#0f4374"], + width: 2, + }, }, - axisTick: {//刻度线 - show: false + axisTick: { + //刻度线 + show: false, }, - axisLine: {//轴线 + axisLine: { + //轴线 show: false, lineStyle: { - color: '#C4E2FC' - } - } + color: "#C4E2FC", + }, + }, }, tooltip: { // trigger: 'axis' }, series: [ { - name: '预警事件', + name: "预警事件", data: [], - type: 'bar', + type: "bar", itemStyle: { color: { - type: 'linear', + type: "linear", x: 0, y: 0, x2: 0, y2: 1, - colorStops: [{ - offset: 0, color: '#23F0FF' // 0% 处的颜色 - }, { - offset: 1, color: 'rgba(35, 153, 255, 0.1)' // 100% 处的颜色 - }], - global: false // 缺省为 false - } + colorStops: [ + { + offset: 0, + color: "#23F0FF", // 0% 处的颜色 + }, + { + offset: 1, + color: "rgba(35, 153, 255, 0.1)", // 100% 处的颜色 + }, + ], + global: false, // 缺省为 false + }, }, - barWidth: '25%' + barWidth: "25%", }, { - name: '预警事件', + name: "预警事件", data: [], - type: 'line', - symbol: 'circle', + type: "line", + symbol: "circle", symbolSize: 8, label: { - show: true + show: true, }, itemStyle: { - color: '#fff', - shadowColor: '#fff', - shadowBlur: 10 + color: "#fff", + shadowColor: "#fff", + shadowBlur: 10, }, lineStyle: { - color: '#FFCC8A', - width: 1 - } - } + color: "#FFCC8A", + width: 1, + }, + }, ], // legend: { // selectedMode: false, // 是否允许点击 @@ -335,54 +408,57 @@ export class WarningStatisticsListComponent implements OnInit { // itemHeight: 8, // }, grid: { - left: '42px', - right: '30px', - bottom: '38px', - top: '80px' - } + left: "42px", + right: "30px", + bottom: "38px", + top: "80px", + }, }; - - - isgoback: boolean = false + isgoback: boolean = false; //获取统计信息 - chartsSpin: boolean = false + chartsSpin: boolean = false; getAggregations() { - this.chartsSpin = true - let organizationUnitId - if (this.router.url.indexOf('petrolStation') != -1) { - organizationUnitId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id + this.chartsSpin = true; + 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 + organizationUnitId = JSON.parse(sessionStorage.getItem("userdata")) + .organization.id; } let params: any = { OrganizationUnitId: organizationUnitId, - IsContainsChildren: 'true' - } - this.http.get('/api/services/app/ViolateRecord/LicenseSummary', { params: params }).subscribe((data: any) => { - this.chartsSpin = false - this.echartsData = data.result - this.refreshEchartsData1(this.echartsData) - }) + IsContainsChildren: "true", + }; + this.http + .get("/api/services/app/ViolateRecord/LicenseSummary", { params: params }) + .subscribe((data: any) => { + this.chartsSpin = false; + this.echartsData = data.result; + this.refreshEchartsData1(this.echartsData); + }); } refreshEchartsData1(data) { // console.log('echarts信息', data) //饼图 - let totalCount = 0 - data.violationList.forEach(element => { - element.name = element.eventSystemName - element.value = element.count - totalCount += element.count + let totalCount = 0; + data.violationList.forEach((element) => { + element.name = element.eventSystemName; + element.value = element.count; + totalCount += element.count; }); - this.num = totalCount - this.oilchartpieOptionPieData1 = data.violationList - this.oilchartpieOption.series[0].data = this.oilchartpieOptionPieData1 + this.num = totalCount; + this.oilchartpieOptionPieData1 = data.violationList; + this.oilchartpieOption.series[0].data = this.oilchartpieOptionPieData1; this.myChart.setOption(this.oilchartpieOption); - this.myChart.off('legendselectchanged') - this.myChart.off('click') - this.myChart.on('click', (params) => { - if (params.name == '证照预警') { - console.log('点击myChart') + this.myChart.off("legendselectchanged"); + this.myChart.off("click"); + this.myChart.on("click", (params) => { + if (params.name == "证照预警") { + console.log("点击myChart"); // this.validateForm.patchValue({ // state: '0' // }); @@ -393,190 +469,260 @@ export class WarningStatisticsListComponent implements OnInit { }); //柱状图 - let monthArr = [] - let valuedata = [] - data.timeList.forEach(element => { - monthArr.push(moment(element.key).format('MM.DD')) - valuedata.push(element.count) + let monthArr = []; + let valuedata = []; + data.timeList.forEach((element) => { + monthArr.push(moment(element.key).format("MM.DD")); + valuedata.push(element.count); }); - this.oilchartbarOption.xAxis.data = monthArr - this.oilchartbarOption.series[0].data = valuedata - this.oilchartbarOption.series[1].data = valuedata + this.oilchartbarOption.xAxis.data = monthArr; + this.oilchartbarOption.series[0].data = valuedata; + this.oilchartbarOption.series[1].data = valuedata; this.mybarChart.setOption(this.oilchartbarOption); } - //预警类型接口 - licenseId - equipmentId - defaultOrId: string + licenseId; + equipmentId; + defaultOrId: string; //获取所有组织机构 - nodes: any = [] - eventSystemNameOption = [] //最终展示的预警类型 - eventSystemNameOptionOfEquipment = [] //最终展示的预警类型 - eventSystemNameOptionOfLicense = [] //最终展示的预警类型 + nodes: any = []; + eventSystemNameOption = []; //最终展示的预警类型 + eventSystemNameOptionOfEquipment = []; //最终展示的预警类型 + eventSystemNameOptionOfLicense = []; //最终展示的预警类型 - warningTypes = []//预警类型 + warningTypes = []; //预警类型 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" + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); } - 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)] - this.defaultOrId = JSON.parse(sessionStorage.getItem('userdata')).organization.id - this.validateForm.value.organization = JSON.parse(sessionStorage.getItem('userdata')).organization.id - this.validateForm.patchValue({ - datePicker: [this.startdate, this.enddate] - }); - this.http.get('/api/services/app/Violation/GetAllList').subscribe((data: any) => { - data.result.forEach(element => { - if (element.violationType == '设备监测') { - this.eventSystemNameOptionOfEquipment.push( - { id: element.id, name: element.eventSystemName } - ) - } - if (element.violationType == '证照资质') { - this.eventSystemNameOptionOfLicense.push( - { id: element.id, name: element.eventSystemName } - ) + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); + let params = { + IsContainsChildren: "true", + }; + this.http + .get("/api/services/app/Organization/GetAll", { + params: params, + }) + .subscribe((data: any) => { + data.result.items.forEach((element) => { + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } + element.key = element.id; + element.title = element.displayName; }); - this.eventSystemNameOption = [...this.eventSystemNameOptionOfEquipment, ...this.eventSystemNameOptionOfLicense] - this.list = [] - this.SkipCount = '0' - this.getLicenseList() - }) - - }) + this.nodes = [...this.toTree.toTree(data.result.items)]; + this.defaultOrId = JSON.parse( + sessionStorage.getItem("userdata") + ).organization.id; + this.validateForm.value.organization = JSON.parse( + sessionStorage.getItem("userdata") + ).organization.id; + this.validateForm.patchValue({ + datePicker: [this.startdate, this.enddate], + }); + this.http + .get("/api/services/app/Violation/GetAllList") + .subscribe((data: any) => { + data.result.forEach((element) => { + if (element.violationType == "设备监测") { + this.eventSystemNameOptionOfEquipment.push({ + id: element.id, + name: element.eventSystemName, + }); + } + if (element.violationType == "证照资质") { + this.eventSystemNameOptionOfLicense.push({ + id: element.id, + name: element.eventSystemName, + }); + } + }); + this.eventSystemNameOption = [ + ...this.eventSystemNameOptionOfEquipment, + ...this.eventSystemNameOptionOfLicense, + ]; + this.list = []; + this.SkipCount = "0"; + this.getLicenseList(); + }); + }); } - //获得卸油记录列表 - SkipCount: string = '0' - MaxResultCount: string = '50' - list: any = [] - totalCount: string - tableSpin: boolean = false - isLoading = false + SkipCount: string = "0"; + MaxResultCount: string = "50"; + list: any = []; + totalCount: string; + tableSpin: boolean = false; + isLoading = false; //获得证照预警 getLicenseList() { - this.isLoading = true - this.tableSpin = true + this.isLoading = true; + this.tableSpin = true; for (const key in this.validateForm.controls) { this.validateForm.controls[key].markAsPristine(); this.validateForm.controls[key].updateValueAndValidity(); } - let organizationUnitId - if (this.router.url.indexOf('petrolStation') != -1) { - organizationUnitId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id + let organizationUnitId; + if (this.router.url.indexOf("petrolStation") != -1) { + organizationUnitId = JSON.parse( + sessionStorage.getItem("userdataOfgasstation") + ).organization.id; } else { - organizationUnitId = this.validateForm.value.organization + organizationUnitId = this.validateForm.value.organization; } - let ViolationIds = [] + let ViolationIds = []; if (this.validateForm.value.eventSystemName) { - ViolationIds.push(this.validateForm.value.eventSystemName) + ViolationIds.push(this.validateForm.value.eventSystemName); } - if (this.validateForm.value.type && !this.validateForm.value.eventSystemName) { - if (this.validateForm.value.type == '证照') { - this.eventSystemNameOptionOfLicense.forEach(i => { - ViolationIds.push(i.id) - }) + if ( + this.validateForm.value.type && + !this.validateForm.value.eventSystemName + ) { + if (this.validateForm.value.type == "证照") { + this.eventSystemNameOptionOfLicense.forEach((i) => { + ViolationIds.push(i.id); + }); } - if (this.validateForm.value.type == '设备') { - this.eventSystemNameOptionOfEquipment.forEach(i => { - ViolationIds.push(i.id) - }) + if (this.validateForm.value.type == "设备") { + this.eventSystemNameOptionOfEquipment.forEach((i) => { + ViolationIds.push(i.id); + }); } } - if (!this.validateForm.value.type && !this.validateForm.value.eventSystemName) { - this.eventSystemNameOptionOfLicense.forEach(i => { - ViolationIds.push(i.id) - }) - this.eventSystemNameOptionOfEquipment.forEach(i => { - ViolationIds.push(i.id) - }) + if ( + !this.validateForm.value.type && + !this.validateForm.value.eventSystemName + ) { + this.eventSystemNameOptionOfLicense.forEach((i) => { + ViolationIds.push(i.id); + }); + this.eventSystemNameOptionOfEquipment.forEach((i) => { + ViolationIds.push(i.id); + }); } let params = { ViolationIds: ViolationIds, organizationUnitId: organizationUnitId, - ViolateTime: (this.validateForm.value.datePicker[0] && this.validateForm.value.datePicker[1]) ? [moment(this.validateForm.value.datePicker[0]).format('yyyy-MM-DD') + ' 00:00:00', moment(this.validateForm.value.datePicker[1]).format('yyyy-MM-DD') + ' 23:59:59'] : null, - IsContainsChildren: 'true', + ViolateTime: + this.validateForm.value.datePicker[0] && + this.validateForm.value.datePicker[1] + ? [ + moment(this.validateForm.value.datePicker[0]).format( + "yyyy-MM-DD" + ) + " 00:00:00", + moment(this.validateForm.value.datePicker[1]).format( + "yyyy-MM-DD" + ) + " 23:59:59", + ] + : null, + IsContainsChildren: "true", SkipCount: this.SkipCount, ValidityLicenseTypeIds: this.validateForm.value.licenseType, - MaxResultCount: '50', - IsLicense: true - } - this.http.get('/api/services/app/ViolateRecord/GetAll', { - params: params - }).subscribe((data: any) => { - console.log('证照预警列表', data.result.items) - this.tableSpin = false - data.result.items.forEach(element => { - element.violatedItemSnapshotObj = JSON.parse(element.violatedItemSnapshot) + MaxResultCount: "50", + IsLicense: true, + }; + this.http + .get("/api/services/app/ViolateRecord/GetAll", { + params: params, + }) + .subscribe((data: any) => { + console.log("证照预警列表", data.result.items); + this.tableSpin = false; + data.result.items.forEach((element) => { + element.violatedItemSnapshotObj = JSON.parse( + element.violatedItemSnapshot + ); + }); + this.list = this.list.concat(data.result.items); + this.list = [...this.list]; + this.totalCount = data.result.totalCount; + this.isLoading = false; + + setTimeout(() => { + let tableHeader = + this.element.nativeElement.querySelector( + `.ant-table-header` + ).clientHeight; + this.tableScrollHeight = + document.getElementById("tablebox").clientHeight - + tableHeader - + 10 + + "px"; + }, 0); }); - this.list = this.list.concat(data.result.items); - this.list = [...this.list] - this.totalCount = data.result.totalCount - this.isLoading = false - - setTimeout(() => { - let tableHeader = this.element.nativeElement.querySelector(`.ant-table-header`).clientHeight - this.tableScrollHeight = (document.getElementById('tablebox').clientHeight - tableHeader - 10) + 'px' - }, 0); - }) } exportExcel() { - let organizationUnitId - if (this.router.url.indexOf('petrolStation') != -1) { - organizationUnitId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id + let organizationUnitId; + if (this.router.url.indexOf("petrolStation") != -1) { + organizationUnitId = JSON.parse( + sessionStorage.getItem("userdataOfgasstation") + ).organization.id; } else { - organizationUnitId = this.validateForm.value.organization + organizationUnitId = this.validateForm.value.organization; } - let ViolationIds = [] + let ViolationIds = []; if (this.validateForm.value.eventSystemName) { - ViolationIds.push(this.validateForm.value.eventSystemName) + ViolationIds.push(this.validateForm.value.eventSystemName); } else { - this.eventSystemNameOption.forEach(element => { - ViolationIds.push(element.id) + this.eventSystemNameOption.forEach((element) => { + ViolationIds.push(element.id); }); } const httpOptions = { - responseType: 'blob' as 'json', + responseType: "blob" as "json", params: { ViolationIds: ViolationIds, organizationUnitId: organizationUnitId, - ViolateTime: (this.validateForm.value.datePicker[0] && this.validateForm.value.datePicker[1]) ? [moment(this.validateForm.value.datePicker[0]).format('yyyy-MM-DD') + ' 00:00:00', moment(this.validateForm.value.datePicker[1]).format('yyyy-MM-DD') + ' 23:59:59'] : null - } + ViolateTime: + this.validateForm.value.datePicker[0] && + this.validateForm.value.datePicker[1] + ? [ + moment(this.validateForm.value.datePicker[0]).format( + "yyyy-MM-DD" + ) + " 00:00:00", + moment(this.validateForm.value.datePicker[1]).format( + "yyyy-MM-DD" + ) + " 23:59:59", + ] + : null, + }, }; - this.http.get(`/api/services/app/ViolateRecord/LicenseExportExcel`, httpOptions).subscribe((data: any) => { - // console.log('导出成功') - // 文件名中有中文 则对文件名进行转码 - const link = document.createElement('a'); - const blob = new Blob([data], { type: 'application/vnd.ms-excel' }); - link.setAttribute('href', window.URL.createObjectURL(blob)); - link.setAttribute('download', '证照预警记录' + '.xls'); - link.style.visibility = 'hidden'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - this.message.create('success', `导出成功`); - }, err => { - this.message.create('error', `导出失败`); - }) + this.http + .get(`/api/services/app/ViolateRecord/LicenseExportExcel`, httpOptions) + .subscribe( + (data: any) => { + // console.log('导出成功') + // 文件名中有中文 则对文件名进行转码 + const link = document.createElement("a"); + const blob = new Blob([data], { type: "application/vnd.ms-excel" }); + link.setAttribute("href", window.URL.createObjectURL(blob)); + link.setAttribute("download", "证照预警记录" + ".xls"); + link.style.visibility = "hidden"; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + this.message.create("success", `导出成功`); + }, + (err) => { + this.message.create("error", `导出失败`); + } + ); } submitForm(): void { @@ -584,10 +730,10 @@ export class WarningStatisticsListComponent implements OnInit { this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].updateValueAndValidity(); } - this.totalCount = null - this.list = [] - this.SkipCount = '0' - this.getLicenseList() + this.totalCount = null; + this.list = []; + this.SkipCount = "0"; + this.getLicenseList(); } resetForm(e: MouseEvent): void { @@ -601,52 +747,67 @@ export class WarningStatisticsListComponent implements OnInit { datePicker: [this.startdate, this.enddate], eventSystemName: null, licenseType: [], - organization: JSON.parse(sessionStorage.getItem('userdata')).organization.id + organization: JSON.parse(sessionStorage.getItem("userdata")).organization + .id, }); - this.totalCount = null - this.list = [] - this.SkipCount = '0' - this.getLicenseList() + this.totalCount = null; + this.list = []; + this.SkipCount = "0"; + this.getLicenseList(); } ngAfterViewInit(): void { - fromEvent(this.element.nativeElement.querySelector(`.ant-table-body`) as HTMLCanvasElement, 'scroll').pipe(debounceTime(100)).subscribe(async (event: any) => { //监听 DOM 滚动事件 - if (event.target.scrollHeight - (event.target.scrollTop + event.target.clientHeight) <= 10) { - if (this.totalCount > this.list.length) { - console.log('需要加载数据了', event) - this.SkipCount = String(Number(this.SkipCount) + 50) - this.getLicenseList() + fromEvent( + this.element.nativeElement.querySelector( + `.ant-table-body` + ) as HTMLCanvasElement, + "scroll" + ) + .pipe(debounceTime(100)) + .subscribe(async (event: any) => { + //监听 DOM 滚动事件 + if ( + event.target.scrollHeight - + (event.target.scrollTop + event.target.clientHeight) <= + 10 + ) { + if (this.totalCount > this.list.length) { + console.log("需要加载数据了", event); + this.SkipCount = String(Number(this.SkipCount) + 50); + this.getLicenseList(); + } } - } - }); + }); } look(item) { - console.log(item) - if (item.violation.violationType == '证照资质') { + console.log(item); + if (item.violation.violationType == "证照资质") { const modal = this.modal.create({ nzContent: GetOutOfLineDetailsComponent, nzWrapClassName: "vertical-center-modal", nzViewContainerRef: this.viewContainerRef, - nzWidth: (document.documentElement.clientHeight < 650 || document.documentElement.clientWidth < 1400) ? 1000 : 1200, + nzWidth: + document.documentElement.clientHeight < 650 || + document.documentElement.clientWidth < 1400 + ? 1000 + : 1200, nzClosable: false, - nzClassName: 'modelnobg', + nzClassName: "modelnobg", nzBodyStyle: { - 'border-radius': '0px', - 'padding': '0px', + "border-radius": "0px", + padding: "0px", }, nzComponentParams: { - data: item + data: item, }, nzFooter: null, nzOnOk: async () => { // console.log(99999, instance.content) - } + }, }); const instance = modal.getContentComponent(); } else { - this.dispose(item) + this.dispose(item); } - - } //处置消防设施 dispose(item) { @@ -655,100 +816,126 @@ export class WarningStatisticsListComponent implements OnInit { nzViewContainerRef: this.viewContainerRef, nzWidth: 380, nzBodyStyle: { - 'border': '1px solid #91CCFF', - 'border-radius': '0px', - 'padding': '7px', - 'box-shadow': '0 0 8px 0 #fff', - 'background-image': 'linear-gradient(#003665, #000f25)' + border: "1px solid #91CCFF", + "border-radius": "0px", + padding: "7px", + "box-shadow": "0 0 8px 0 #fff", + "background-image": "linear-gradient(#003665, #000f25)", }, nzComponentParams: { - data: item + data: item, }, nzFooter: null, nzClosable: false, nzOnOk: async () => { if (instance.isScrap) { - await new Promise(resolve => { + await new Promise((resolve) => { let body = { id: item.violatedItemSnapshotObj.id, name: instance.copydata2.violatedItemSnapshotObj.name, - storageLocation: instance.copydata2.violatedItemSnapshotObj.storageLocation, - productionDate: moment(instance.copydata2.violatedItemSnapshotObj.productionDate).format('yyyy-MM-DD'), - maintenanceDate: moment(instance.copydata2.violatedItemSnapshotObj.maintenanceDate).format('yyyy-MM-DD'), - validityEndTime: moment(instance.copydata2.violatedItemSnapshotObj.validityEndTime).format('yyyy-MM-DD'), + storageLocation: + instance.copydata2.violatedItemSnapshotObj.storageLocation, + productionDate: moment( + instance.copydata2.violatedItemSnapshotObj.productionDate + ).format("yyyy-MM-DD"), + maintenanceDate: moment( + instance.copydata2.violatedItemSnapshotObj.maintenanceDate + ).format("yyyy-MM-DD"), + validityEndTime: moment( + instance.copydata2.violatedItemSnapshotObj.validityEndTime + ).format("yyyy-MM-DD"), isScrapped: true, - organizationUnitId: item.violatedItemSnapshotObj.organizationUnitId - } - this.http.put('/api/services/app/FireEquipment/Update', body).subscribe((data: any) => { - let body = { - id: item.id, - handleRecord: '报废成功!' - } - this.http.post('/api/services/app/ViolateRecord/HandleViolateRecord', body).subscribe(data => { - resolve(data) - this.message.create('success', '报废成功!'); - item.handleTime = new Date() - return true - }) - }) - }) - + organizationUnitId: + item.violatedItemSnapshotObj.organizationUnitId, + }; + this.http + .put("/api/services/app/FireEquipment/Update", body) + .subscribe((data: any) => { + let body = { + id: item.id, + handleRecord: "报废成功!", + }; + this.http + .post( + "/api/services/app/ViolateRecord/HandleViolateRecord", + body + ) + .subscribe((data) => { + resolve(data); + this.message.create("success", "报废成功!"); + item.handleTime = new Date(); + return true; + }); + }); + }); } else { if (instance.validateForm.valid) { - await new Promise(resolve => { + await new Promise((resolve) => { let body = { id: item.violatedItemSnapshotObj.id, name: instance.validateForm.value.name, storageLocation: instance.validateForm.value.storageLocation, - productionDate: moment(instance.validateForm.value.productionDate).format('yyyy-MM-DD'), - maintenanceDate: moment(instance.validateForm.value.maintenanceDate).format('yyyy-MM-DD'), - validityEndTime: moment(instance.validateForm.value.validityEndTime).format('yyyy-MM-DD'), - organizationUnitId: item.violatedItemSnapshotObj.organizationUnitId - } - this.http.put('/api/services/app/FireEquipment/Update', body).subscribe((data: any) => { - let body = { - id: item.id, - handleRecord: '维保成功!' - } - this.http.post('/api/services/app/ViolateRecord/HandleViolateRecord', body).subscribe(data => { - resolve(data) - this.message.create('success', '维保成功!'); - item.handleTime = new Date() - return true - }) - }) - }) + productionDate: moment( + instance.validateForm.value.productionDate + ).format("yyyy-MM-DD"), + maintenanceDate: moment( + instance.validateForm.value.maintenanceDate + ).format("yyyy-MM-DD"), + validityEndTime: moment( + instance.validateForm.value.validityEndTime + ).format("yyyy-MM-DD"), + organizationUnitId: + item.violatedItemSnapshotObj.organizationUnitId, + }; + this.http + .put("/api/services/app/FireEquipment/Update", body) + .subscribe((data: any) => { + let body = { + id: item.id, + handleRecord: "维保成功!", + }; + this.http + .post( + "/api/services/app/ViolateRecord/HandleViolateRecord", + body + ) + .subscribe((data) => { + resolve(data); + this.message.create("success", "维保成功!"); + item.handleTime = new Date(); + return true; + }); + }); + }); } else { - this.message.create('warning', '请填写完整!'); - return false + this.message.create("warning", "请填写完整!"); + return false; } } - } + }, }); const instance = modal.getContentComponent(); } - goOilList() { - if (this.router.url.indexOf('petrolStation') != -1) { - this.router.navigate(['/records/petrolStation/oliunloadinglist']) + if (this.router.url.indexOf("petrolStation") != -1) { + this.router.navigate(["/records/petrolStation/oliunloadinglist"]); } else { - this.router.navigate(['/records/oliunloadinglist']) + this.router.navigate(["/records/oliunloadinglist"]); } - } gorecordList() { - if (this.router.url.indexOf('petrolStation') != -1) { - this.router.navigate(['/records/petrolStation']) + if (this.router.url.indexOf("petrolStation") != -1) { + this.router.navigate(["/records/petrolStation"]); } else { - this.router.navigate(['/records']) + this.router.navigate(["/records"]); } } goMisinformationList() { - if (this.router.url.indexOf('petrolStation') != -1) { - this.router.navigate(['records/petrolStation/misinformationList']) + if (this.router.url.indexOf("petrolStation") != -1) { + this.router.navigate(["records/petrolStation/misinformationList"]); } else { - this.router.navigate(['records/misinformationList']) + this.router.navigate(["records/misinformationList"]); } } } diff --git a/src/app/pages/singlelogin/singlelogin.component.ts b/src/app/pages/singlelogin/singlelogin.component.ts index 4a0df9a..27dbe56 100644 --- a/src/app/pages/singlelogin/singlelogin.component.ts +++ b/src/app/pages/singlelogin/singlelogin.component.ts @@ -93,6 +93,7 @@ export class SingleloginComponent implements OnInit { resolve(); }, (err) => { + alert("token无效"); reject(); } ); @@ -114,6 +115,7 @@ export class SingleloginComponent implements OnInit { resolve(); }, (err) => { + alert("token无效"); reject(); } ); @@ -162,7 +164,7 @@ export class SingleloginComponent implements OnInit { resolve(); }, (err) => { - alert("未绑定本地用户!"); + alert("SinochemLogin失败"); reject(); } ); diff --git a/src/app/pages/today-warning-admin/today-warning-admin.component.ts b/src/app/pages/today-warning-admin/today-warning-admin.component.ts index 2e5605f..5e6ef2b 100644 --- a/src/app/pages/today-warning-admin/today-warning-admin.component.ts +++ b/src/app/pages/today-warning-admin/today-warning-admin.component.ts @@ -183,13 +183,15 @@ export class TodayWarningAdminComponent implements OnInit { //获取所有组织机构 nodes: any = []; getAllOrganization() { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; this.http @@ -198,8 +200,14 @@ export class TodayWarningAdminComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; @@ -245,7 +253,7 @@ export class TodayWarningAdminComponent implements OnInit { ViolateTime = [ "2023-9-1", moment(this.validateForm.value.datePickerEnd).format("yyyy-MM-DD"), - ]; + ]; } else { this.validateForm.value.datePickerEnd && this.validateForm.value.datePickerStart diff --git a/src/app/system-management/algorithm-config/algorithm-config.component.ts b/src/app/system-management/algorithm-config/algorithm-config.component.ts index d7cc519..0f0030c 100644 --- a/src/app/system-management/algorithm-config/algorithm-config.component.ts +++ b/src/app/system-management/algorithm-config/algorithm-config.component.ts @@ -51,7 +51,6 @@ export class AlgorithmConfigComponent implements OnInit { organizationList; //组织机构列表 getAllOrganization() { let params = { - OrganizationUnitId: this.OrganizationUnitId, IsContainsChildren: "true", }; this.http @@ -73,6 +72,14 @@ export class AlgorithmConfigComponent implements OnInit { nzExpandedKeys = []; nzSelectedKeys: any[] = []; getStationsNum(e) { + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); this.http .get( "/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true" @@ -90,8 +97,14 @@ export class AlgorithmConfigComponent implements OnInit { }); for (let index = 0; index < arrs.length; index++) { arrs[index].isLeaf = true; - if (arrs[index].id == this.OrganizationUnitId) { - arrs[index].parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(arrs[index].id)) { + arrs[index].parentId = null; + } + } else { + if (arrs[index].id == OrganizationUnitId) { + arrs[index].parentId = null; + } } arrs[index].title = arrs[index].displayName + @@ -166,7 +179,7 @@ export class AlgorithmConfigComponent implements OnInit { } pageSizeChange($event) { // console.log($event); - this.MaxResultCount = $event + this.MaxResultCount = $event; this.SkipCount = 0; this.nzPageIndex = 1; this.getStationViolationConfigList(); diff --git a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts index 1930227..5b4ac7e 100644 --- a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts +++ b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts @@ -1,284 +1,326 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, OnInit, AfterViewInit, ViewChild, ViewContainerRef } from '@angular/core'; -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 { NzModalService } from 'ng-zorro-antd/modal'; -import { NzMessageService } from 'ng-zorro-antd/message'; -import { AddhostComponent } from './addhost/addhost.component'; -import { AddcameraComponent } from './addcamera/addcamera.component'; -import { EdithostComponent } from './edithost/edithost.component'; -import { EditcameraComponent } from './editcamera/editcamera.component'; +import { HttpClient } from "@angular/common/http"; +import { + Component, + OnInit, + AfterViewInit, + ViewChild, + ViewContainerRef, +} from "@angular/core"; +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 { NzModalService } from "ng-zorro-antd/modal"; +import { NzMessageService } from "ng-zorro-antd/message"; +import { AddhostComponent } from "./addhost/addhost.component"; +import { AddcameraComponent } from "./addcamera/addcamera.component"; +import { EdithostComponent } from "./edithost/edithost.component"; +import { EditcameraComponent } from "./editcamera/editcamera.component"; @Component({ - selector: 'app-analysis-of-the-host', - templateUrl: './analysis-of-the-host.component.html', - styleUrls: ['./analysis-of-the-host.component.scss'] + selector: "app-analysis-of-the-host", + templateUrl: "./analysis-of-the-host.component.html", + styleUrls: ["./analysis-of-the-host.component.scss"], }) export class AnalysisOfTheHostComponent implements OnInit { - - 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 + ) {} ngOnInit(): void { - this.getAllOrganization() + this.getAllOrganization(); } - //获取所有组织机构 - searchValue = ''; + searchValue = ""; nzExpandAll = false; - totalCount: string + totalCount: string; 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" + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); } - this.http.get('/api/services/app/Organization/GetAll', { - params: params - }).subscribe((data: any) => { - this.totalCount = data.result.totalCount - data.result.items.forEach(element => { - if (element.id == OrganizationUnitId) { - element.parentId = null - } - element.key = element.id - element.title = element.displayName - element.selectable = false + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); + let params = { + IsContainsChildren: "true", + }; + this.http + .get("/api/services/app/Organization/GetAll", { + params: params, + }) + .subscribe((data: any) => { + this.totalCount = data.result.totalCount; + data.result.items.forEach((element) => { + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } + } + element.key = element.id; + element.title = element.displayName; + element.selectable = false; + }); + this.nodes = [...this.toTree.toTree(data.result.items)]; + this.defaultExpandedKeys = [this.nodes[0].id]; + this.defaultExpandedKeys = [...this.defaultExpandedKeys]; }); - this.nodes = [...this.toTree.toTree(data.result.items)] - this.defaultExpandedKeys = [this.nodes[0].id] - this.defaultExpandedKeys = [...this.defaultExpandedKeys] - }) } - - @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; + @ViewChild("nzTreeComponent", { static: false }) + nzTreeComponent!: NzTreeComponent; defaultExpandedKeys = []; - nodes: any[] = [] - nzSelectedKeys: any[] = [] - selectedOilStation: any + nodes: any[] = []; + nzSelectedKeys: any[] = []; + selectedOilStation: any; nzClick(event: NzFormatEmitEvent): void { console.log(event.node.origin); - if (event.node.origin.isGasStation) {//如果点击的是加油站才生效 - this.nzSelectedKeys[0] = event.node.origin.id - this.nzSelectedKeys = [...this.nzSelectedKeys] - this.selectedOilStation = event.node.origin - this.getHost() - this.getCamera() + if (event.node.origin.isGasStation) { + //如果点击的是加油站才生效 + this.nzSelectedKeys[0] = event.node.origin.id; + this.nzSelectedKeys = [...this.nzSelectedKeys]; + this.selectedOilStation = event.node.origin; + this.getHost(); + this.getCamera(); } else { - this.message.info('只有加油站才可以增加主机'); + this.message.info("只有加油站才可以增加主机"); } } //获得加油站的主机 listOfData: any[] = []; getHost() { - this.http.get('/api/services/app/EdgeDevice/GetAll', { - params: { - organizationUnitId: this.selectedOilStation.id, - SkipCount: '0', - MaxResultCount: '100', - } - }).subscribe((data: any) => { - console.log('主机列表', data.result.items) - this.listOfData = data.result.items - }) + this.http + .get("/api/services/app/EdgeDevice/GetAll", { + params: { + organizationUnitId: this.selectedOilStation.id, + SkipCount: "0", + MaxResultCount: "100", + }, + }) + .subscribe((data: any) => { + console.log("主机列表", data.result.items); + this.listOfData = data.result.items; + }); } - //获得加油站摄像头 listOfDataCamera: any[] = []; getCamera() { - this.http.get('/api/services/app/Camera/GetAll', { - params: { - organizationUnitId: this.selectedOilStation.id, - SkipCount: '0', - MaxResultCount: '100', - } - }).subscribe((data: any) => { - // console.log('摄像头列表', data) - this.listOfDataCamera = data.result.items - }) + this.http + .get("/api/services/app/Camera/GetAll", { + params: { + organizationUnitId: this.selectedOilStation.id, + SkipCount: "0", + MaxResultCount: "100", + }, + }) + .subscribe((data: any) => { + // console.log('摄像头列表', data) + this.listOfDataCamera = data.result.items; + }); } - - ngAfterViewInit(): void { - - } + ngAfterViewInit(): void {} //新增分析主机 addHost() { - console.log(this.selectedOilStation) + console.log(this.selectedOilStation); const modal = this.modal.create({ - nzTitle: '新增加油站主机', + nzTitle: "新增加油站主机", nzContent: AddhostComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 288, nzComponentParams: {}, nzOnOk: async () => { if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) + await new Promise((resolve) => { + console.log("表单信息", instance.validateForm); let body = { hostIPAddress: instance.validateForm.value.ip, - organizationUnitId: this.selectedOilStation.id - } - this.http.post('/api/services/app/EdgeDevice/Create', body).subscribe(data => { - resolve(data) - this.message.create('success', '创建成功!'); - this.getHost() - return true - }) - }) + organizationUnitId: this.selectedOilStation.id, + }; + this.http + .post("/api/services/app/EdgeDevice/Create", body) + .subscribe((data) => { + resolve(data); + this.message.create("success", "创建成功!"); + this.getHost(); + return true; + }); + }); } else { - this.message.create('warning', '请填写完整!'); - return false + this.message.create("warning", "请填写完整!"); + return false; } - } + }, }); const instance = modal.getContentComponent(); } edit(data) { - console.log(data) + console.log(data); const modal = this.modal.create({ - nzTitle: '编辑加油站主机', + nzTitle: "编辑加油站主机", nzContent: EdithostComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 288, nzComponentParams: { - ip: data.hostIPAddress + ip: data.hostIPAddress, }, nzOnOk: async () => { if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) - data.hostIPAddress = instance.validateForm.value.ip, - this.http.put('/api/services/app/EdgeDevice/Update', data).subscribe(data => { - resolve(data) - this.message.create('success', '修改成功!'); - this.getHost() - return true - }) - }) + await new Promise((resolve) => { + console.log("表单信息", instance.validateForm); + (data.hostIPAddress = instance.validateForm.value.ip), + this.http + .put("/api/services/app/EdgeDevice/Update", data) + .subscribe((data) => { + resolve(data); + this.message.create("success", "修改成功!"); + this.getHost(); + return true; + }); + }); } else { - this.message.create('warning', '请填写完整!'); - return false + this.message.create("warning", "请填写完整!"); + return false; } - } + }, }); const instance = modal.getContentComponent(); } delete(item) { - console.log(item) + console.log(item); this.modal.confirm({ nzTitle: `确定要删除${item.name}这个主机吗?`, - nzOkText: '确定', - nzOkType: 'primary', + nzOkText: "确定", + nzOkType: "primary", nzOnOk: () => { - this.http.delete('/api/services/app/EdgeDevice/Delete', { - params: { - Id: item.id - } - }).subscribe(data => { - this.message.create('success', '删除成功!'); - this.getHost() - }) + this.http + .delete("/api/services/app/EdgeDevice/Delete", { + params: { + Id: item.id, + }, + }) + .subscribe((data) => { + this.message.create("success", "删除成功!"); + this.getHost(); + }); }, - nzCancelText: '取消' + nzCancelText: "取消", }); } - //摄像头 addCamera() { - console.log(this.selectedOilStation) + console.log(this.selectedOilStation); const modal = this.modal.create({ - nzTitle: '新增加油站摄像头', + nzTitle: "新增加油站摄像头", nzContent: AddcameraComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 288, nzComponentParams: {}, nzOnOk: async () => { if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) + await new Promise((resolve) => { + console.log("表单信息", instance.validateForm); let body = { organizationUnitId: this.selectedOilStation.id, ipAdress: instance.validateForm.value.ip, code: instance.validateForm.value.code, name: instance.validateForm.value.name, // description: "", - } - this.http.post('/api/services/app/Camera/Create', body).subscribe(data => { - resolve(data) - this.message.create('success', '创建成功!'); - this.getCamera() - return true - }, err => { - return false - }) - }) + }; + this.http.post("/api/services/app/Camera/Create", body).subscribe( + (data) => { + resolve(data); + this.message.create("success", "创建成功!"); + this.getCamera(); + return true; + }, + (err) => { + return false; + } + ); + }); } else { - this.message.create('warning', '请填写完整!'); - return false + this.message.create("warning", "请填写完整!"); + return false; } - } + }, }); const instance = modal.getContentComponent(); } editCamera(data) { - - console.log(data) + console.log(data); const modal = this.modal.create({ - nzTitle: '编辑加油站摄像头', + nzTitle: "编辑加油站摄像头", nzContent: EditcameraComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 288, nzComponentParams: { - data: data + data: data, }, nzOnOk: async () => { if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) - data.name = instance.validateForm.value.name - data.code = instance.validateForm.value.code - data.ipAdress = instance.validateForm.value.ip - this.http.put('/api/services/app/Camera/Update', data).subscribe(data => { - resolve(data) - this.message.create('success', '编辑成功!'); - this.getCamera() - return true - }, err => { - return false - }) - }) + await new Promise((resolve) => { + console.log("表单信息", instance.validateForm); + data.name = instance.validateForm.value.name; + data.code = instance.validateForm.value.code; + data.ipAdress = instance.validateForm.value.ip; + this.http.put("/api/services/app/Camera/Update", data).subscribe( + (data) => { + resolve(data); + this.message.create("success", "编辑成功!"); + this.getCamera(); + return true; + }, + (err) => { + return false; + } + ); + }); } else { - this.message.create('warning', '请填写完整!'); - return false + this.message.create("warning", "请填写完整!"); + return false; } - } + }, }); const instance = modal.getContentComponent(); } deleteCamera(item) { - console.log(item) + console.log(item); this.modal.confirm({ nzTitle: `确定要删除${item.name}这个摄像头吗?`, - nzOkText: '确定', - nzOkType: 'primary', + nzOkText: "确定", + nzOkType: "primary", nzOnOk: () => { - this.http.delete('/api/services/app/Camera/Delete', { - params: { - Id: item.id - } - }).subscribe(data => { - this.message.create('success', '删除成功!'); - this.getCamera() - }) + this.http + .delete("/api/services/app/Camera/Delete", { + params: { + Id: item.id, + }, + }) + .subscribe((data) => { + this.message.create("success", "删除成功!"); + this.getCamera(); + }); }, - nzCancelText: '取消' + nzCancelText: "取消", }); } } diff --git a/src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts b/src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts index b53dcf9..2629cd6 100644 --- a/src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts +++ b/src/app/system-management/or-binding/or-binding-model/or-binding-model.component.ts @@ -60,13 +60,15 @@ export class OrBindingModelComponent implements OnInit { 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 userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; await new Promise((resolve, reject) => { @@ -77,8 +79,18 @@ export class OrBindingModelComponent implements OnInit { .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; + // if (data.result.items[index].id == OrganizationUnitId) { + // data.result.items[index].parentId = null; + // } + + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(data.result.items[index].id)) { + data.result.items[index].parentId = null; + } + } else { + if (data.result.items[index].id == OrganizationUnitId) { + data.result.items[index].parentId = null; + } } data.result.items[index].title = data.result.items[index].displayName; diff --git a/src/app/system-management/organization/organization.component.ts b/src/app/system-management/organization/organization.component.ts index f76dde1..f100fbb 100644 --- a/src/app/system-management/organization/organization.component.ts +++ b/src/app/system-management/organization/organization.component.ts @@ -76,13 +76,7 @@ export class OrganizationComponent implements OnInit { isLoading = false; getAllOrganization() { this.isLoading = true; - 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", }; this.http @@ -99,11 +93,14 @@ export class OrganizationComponent implements OnInit { //获得组织机构下有多少油站 stationsList; getStationsNum(e) { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); this.http .get( "/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true" @@ -120,8 +117,14 @@ export class OrganizationComponent implements OnInit { }; }); for (let index = 0; index < arrs.length; index++) { - if (arrs[index].id == OrganizationUnitId) { - arrs[index].parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(arrs[index].id)) { + arrs[index].parentId = null; + } + } else { + if (arrs[index].id == OrganizationUnitId) { + arrs[index].parentId = null; + } } arrs[index].title = arrs[index].displayName; arrs[index].key = arrs[index].id; diff --git a/src/app/system-management/user-binding/binding/binding.component.ts b/src/app/system-management/user-binding/binding/binding.component.ts index f5ea11a..a829acd 100644 --- a/src/app/system-management/user-binding/binding/binding.component.ts +++ b/src/app/system-management/user-binding/binding/binding.component.ts @@ -100,13 +100,7 @@ export class BindingComponent implements OnInit { 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((resolve, reject) => { @@ -123,11 +117,14 @@ export class BindingComponent implements OnInit { }); } async getuser(e) { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", @@ -152,8 +149,14 @@ export class BindingComponent implements OnInit { }); for (let index = 0; index < arrs.length; index++) { - if (arrs[index].id == OrganizationUnitId) { - arrs[index].parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(arrs[index].id)) { + arrs[index].parentId = null; + } + } else { + if (arrs[index].id == OrganizationUnitId) { + arrs[index].parentId = null; + } } arrs[index].title = arrs[index].displayName; arrs[index].key = arrs[index].id; diff --git a/src/app/system-management/user/adduser/adduser.component.ts b/src/app/system-management/user/adduser/adduser.component.ts index 53abb72..f660205 100644 --- a/src/app/system-management/user/adduser/adduser.component.ts +++ b/src/app/system-management/user/adduser/adduser.component.ts @@ -1,19 +1,23 @@ -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 { 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"; @Component({ - selector: 'app-adduser', - templateUrl: './adduser.component.html', - styleUrls: ['./adduser.component.scss'] + selector: "app-adduser", + templateUrl: "./adduser.component.html", + styleUrls: ["./adduser.component.scss"], }) export class AdduserComponent implements OnInit { - @Input() title?: string; @Input() subtitle?: string; validateForm!: FormGroup; - constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { } + constructor( + private modal: NzModalRef, + private fb: FormBuilder, + private http: HttpClient, + private toTree: TreeService + ) {} ngOnInit(): void { this.validateForm = this.fb.group({ @@ -23,15 +27,15 @@ export class AdduserComponent implements OnInit { role: [[], [Validators.required]], role2: [[]], phonenum: [null, [Validators.required]], - note:[null] + note: [null], }); - this.getAllRoles() - this.getAllRoles2() - this.getAllOrganization() + this.getAllRoles(); + this.getAllRoles2(); + this.getAllOrganization(); } destroyModal(): void { - this.modal.destroy({ data: 'this the result data' }); + this.modal.destroy({ data: "this the result data" }); } listOfData: any[] = []; @@ -39,49 +43,67 @@ export class AdduserComponent implements OnInit { //获取角色列表 getAllRoles() { let params = { - SkipCount: '0', - MaxResultCount: '999' - } - this.http.get('/api/services/app/Role/GetAll', { - params: params - }).subscribe((data: any) => { - // console.log('角色列表', data.result.items) - this.listOfData = data.result.items - }) + SkipCount: "0", + MaxResultCount: "999", + }; + this.http + .get("/api/services/app/Role/GetAll", { + params: params, + }) + .subscribe((data: any) => { + // console.log('角色列表', data.result.items) + this.listOfData = data.result.items; + }); } //获取角色列表 getAllRoles2() { let params = { - SkipCount: '0', - MaxResultCount: '999', - IsViolationRoles:'true' - } - this.http.get('/api/services/app/Role/GetAll', { - params: params - }).subscribe((data: any) => { - // console.log('角色列表', data.result.items) - this.listOfData2 = data.result.items - }) + SkipCount: "0", + MaxResultCount: "999", + IsViolationRoles: "true", + }; + this.http + .get("/api/services/app/Role/GetAll", { + params: params, + }) + .subscribe((data: any) => { + // console.log('角色列表', data.result.items) + this.listOfData2 = data.result.items; + }); } //获取所有组织机构 - nodes: any = [] + nodes: any = []; 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" + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); } - 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 + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); + let params = { + IsContainsChildren: "true", + }; + this.http + .get("/api/services/app/Organization/GetAll", { + params: params, + }) + .subscribe((data: any) => { + data.result.items.forEach((element) => { + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } + } + element.key = element.id; + element.title = element.displayName; + }); + this.nodes = [...this.toTree.toTree(data.result.items)]; }); - this.nodes = [...this.toTree.toTree(data.result.items)] - }) } } diff --git a/src/app/system-management/user/edituser/edituser.component.ts b/src/app/system-management/user/edituser/edituser.component.ts index 99b1ef7..2d821fe 100644 --- a/src/app/system-management/user/edituser/edituser.component.ts +++ b/src/app/system-management/user/edituser/edituser.component.ts @@ -112,13 +112,15 @@ export class EdituserComponent implements OnInit { //获取所有组织机构 async getAllOrganization() { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { - OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", }; await new Promise((resolve, reject) => { @@ -128,8 +130,14 @@ export class EdituserComponent implements OnInit { }) .subscribe((data: any) => { data.result.items.forEach((element) => { - if (element.id == OrganizationUnitId) { - element.parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(element.id)) { + element.parentId = null; + } + } else { + if (element.id == OrganizationUnitId) { + element.parentId = null; + } } element.key = element.id; element.title = element.displayName; diff --git a/src/app/system-management/user/user.component.html b/src/app/system-management/user/user.component.html index 329cb63..db05751 100644 --- a/src/app/system-management/user/user.component.html +++ b/src/app/system-management/user/user.component.html @@ -129,7 +129,7 @@ - + - - + diff --git a/src/app/system-management/user/user.component.ts b/src/app/system-management/user/user.component.ts index deeef8b..ed41951 100644 --- a/src/app/system-management/user/user.component.ts +++ b/src/app/system-management/user/user.component.ts @@ -161,13 +161,7 @@ export class UserComponent implements OnInit { 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((resolve, reject) => { @@ -184,11 +178,14 @@ export class UserComponent implements OnInit { }); } async getuser(e) { - let OrganizationUnitId = - sessionStorage.getItem("isGasStation") == "true" - ? JSON.parse(sessionStorage.getItem("userdataOfgasstation")) - .organization.id - : JSON.parse(sessionStorage.getItem("userdata")).organization.id; + let userData = null; + if (sessionStorage.getItem("isGasStation") == "true") { + userData = JSON.parse(sessionStorage.getItem("userdataOfgasstation")); + } else { + userData = JSON.parse(sessionStorage.getItem("userdata")); + } + let OrganizationUnitId = userData.organization.id; + let OrganizationUnitIds = userData.organizations?.map((v) => v.id); let params = { OrganizationUnitId: OrganizationUnitId, IsContainsChildren: "true", @@ -213,8 +210,14 @@ export class UserComponent implements OnInit { }); for (let index = 0; index < arrs.length; index++) { - if (arrs[index].id == OrganizationUnitId) { - arrs[index].parentId = null; + if (OrganizationUnitIds && OrganizationUnitIds.length !== 0) { + if (OrganizationUnitIds.includes(arrs[index].id)) { + arrs[index].parentId = null; + } + } else { + if (arrs[index].id == OrganizationUnitId) { + arrs[index].parentId = null; + } } arrs[index].title = arrs[index].displayName; arrs[index].key = arrs[index].id; diff --git a/src/theme.less b/src/theme.less index 83d17b1..a2684fe 100644 --- a/src/theme.less +++ b/src/theme.less @@ -419,13 +419,13 @@ } nz-tree { - nz-tree-node { - margin-left: 20px; - } + // nz-tree-node { + // margin-left: 20px; + // } - nz-tree-node:nth-child(1) { - margin-left: 0px; - } + // nz-tree-node:nth-child(1) { + // margin-left: 0px; + // } } .ant-table table {