From 40f5bb97895538dde183622540f9b8ec78bc64da Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Thu, 3 Aug 2023 15:10:31 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E5=8A=9F=E8=83=BD=E5=88=A0?= =?UTF-8?q?=E5=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular.json | 2 - proxy.config.json | 5 +- src/app/app-routing.module.ts | 127 +- src/app/app.module.ts | 3 - .../basicinfo/basicinfo.component.html | 4 +- .../key-unit/basicinfo/basicinfo.component.ts | 2 +- .../edit-plan-info.component.html | 10 +- .../edit-unit-info.component.html | 24 +- .../edit-unit-info.component.ts | 7 +- .../key-unit-management.component.html | 2 +- .../view-unit-details-plan.component.html | 29 +- .../view-unit-details.component.html | 10 +- .../plan-record/plan-record.component.ts | 43 +- .../wait-examineer.component.ts | 37 +- .../entry-plan-look/AddPlanone.html | 4 +- .../entry-plan-look.component.html | 2 +- src/app/test/test.component.html | 8 - src/app/test/test.component.scss | 17 - src/app/test/test.component.spec.ts | 25 - src/app/test/test.component.ts | 56 - .../organization/organization.component.html | 30 +- .../ui/organization/organization.component.ts | 1025 +++++++++-------- src/index.html | 18 +- 23 files changed, 710 insertions(+), 780 deletions(-) delete mode 100644 src/app/test/test.component.html delete mode 100644 src/app/test/test.component.scss delete mode 100644 src/app/test/test.component.spec.ts delete mode 100644 src/app/test/test.component.ts diff --git a/angular.json b/angular.json index 46e73e8..b3321d4 100644 --- a/angular.json +++ b/angular.json @@ -34,8 +34,6 @@ ], "scripts": [ "node_modules/echarts/dist/echarts.js", - "src/assets/mTokenK1/mToken_K1.js", - "src/assets/kmap/kmap-service-main-kd.js", "./node_modules/swiper/js/swiper.min.js", "src/assets/chartstheme/westeros.js", "src/assets/chartstheme/walden.js", diff --git a/proxy.config.json b/proxy.config.json index e61e510..00b1fc8 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -1,9 +1,6 @@ { "/api": { - "target": "http://10.81.73.39:8000/", - "生产": "http://10.81.73.39:8000/", - "测试": "http://121.36.37.70:8201/", - "生产2": "http://183.194.244.232:8088/", + "target": "http://121.36.37.70:8223/", "secure": false, "changeOrigin": true } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index fa9e3a0..c2a896a 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,54 +1,107 @@ /* - * @Descripttion: - * @version: + * @Descripttion: + * @version: * @Author: sueRimn * @Date: 2021-01-11 14:48:03 * @LastEditors: sueRimn * @LastEditTime: 2021-07-29 10:26:58 */ -import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { LoginComponent } from './pages/login/login.component'; -import { NavigationComponent } from './navigation/navigation.component'; -import {HomeComponent} from './home/home.component' -import { PlanPassComponent } from '../app/plan-audit/plan-pass/plan-pass.component'; +import { NgModule } from "@angular/core"; +import { Routes, RouterModule } from "@angular/router"; +import { LoginComponent } from "./pages/login/login.component"; +import { NavigationComponent } from "./navigation/navigation.component"; +import { HomeComponent } from "./home/home.component"; +import { PlanPassComponent } from "../app/plan-audit/plan-pass/plan-pass.component"; //路由守卫 -import {AuthGuard} from './auth.guard' -import {MTokenK1Component} from './m-token-k1/m-token-k1.component' //K1秘钥 -import {ViewUnitDetailsPlanComponent} from './key-unit/view-unit-details-plan/view-unit-details-plan.component' -import { TestComponent } from './test/test.component'; -import { ExternalLinksPlanComponent } from './external-links-plan/external-links-plan.component'; -import { CreatePlanOnlineFiveComponent } from './plan-management/create-plan-online-five/create-plan-online-five.component' -import { ExportExcelComponent } from './export-excel/export-excel.component' +import { AuthGuard } from "./auth.guard"; +import { MTokenK1Component } from "./m-token-k1/m-token-k1.component"; //K1秘钥 +import { ViewUnitDetailsPlanComponent } from "./key-unit/view-unit-details-plan/view-unit-details-plan.component"; +import { ExternalLinksPlanComponent } from "./external-links-plan/external-links-plan.component"; +import { CreatePlanOnlineFiveComponent } from "./plan-management/create-plan-online-five/create-plan-online-five.component"; +import { ExportExcelComponent } from "./export-excel/export-excel.component"; const routes: Routes = [ - {path:'',redirectTo:'login',pathMatch:'full'}, + { path: "", redirectTo: "login", pathMatch: "full" }, { - path:'',component:NavigationComponent,canActivate: [AuthGuard],//守卫验证 - children:[ - {path:'ui',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)}, - {path:'keyUnit',loadChildren:() => import('./key-unit/key-unit.module').then(m => m.KeyUnitModule)}, - {path:'planManagement',loadChildren:() => import('./plan-management/plan-management.module').then(m => m.PlanManagementModule)}, - {path:'planAudit',loadChildren:() => import('./plan-audit/plan-audit.module').then(m => m.PlanAuditModule)}, - {path:'visualization',component: HomeComponent}, - {path:'gis',loadChildren:() => import('./gis-management/gis-management.module').then(m => m.GISManagementModule)}, - {path:'statisticanalysis',loadChildren:() => import('./statistic-analysis/statistic-analysis.module').then(m => m.StatisticAnalysisModule)}, - {path:'dataCollection',loadChildren:() => import('./data-collection/data-collection.module').then(m => m.DataCollectionModule)}, - ] + path: "", + component: NavigationComponent, + canActivate: [AuthGuard], //守卫验证 + children: [ + { + path: "ui", + loadChildren: () => import("./ui/ui.module").then((m) => m.UiModule), + }, + { + path: "keyUnit", + loadChildren: () => + import("./key-unit/key-unit.module").then((m) => m.KeyUnitModule), + }, + { + path: "planManagement", + loadChildren: () => + import("./plan-management/plan-management.module").then( + (m) => m.PlanManagementModule + ), + }, + { + path: "planAudit", + loadChildren: () => + import("./plan-audit/plan-audit.module").then( + (m) => m.PlanAuditModule + ), + }, + { path: "visualization", component: HomeComponent }, + { + path: "gis", + loadChildren: () => + import("./gis-management/gis-management.module").then( + (m) => m.GISManagementModule + ), + }, + { + path: "statisticanalysis", + loadChildren: () => + import("./statistic-analysis/statistic-analysis.module").then( + (m) => m.StatisticAnalysisModule + ), + }, + { + path: "dataCollection", + loadChildren: () => + import("./data-collection/data-collection.module").then( + (m) => m.DataCollectionModule + ), + }, + ], + }, + { path: "login", component: LoginComponent }, + { + path: "keyUnit/viewunitinfoplans", + component: ViewUnitDetailsPlanComponent, + canActivate: [AuthGuard], + }, + { + path: "getNoMToken", + component: MTokenK1Component, + canActivate: [AuthGuard], + }, //K1秘钥验证失败是跳转页面 + { + path: "planAudit/planpass", + component: PlanPassComponent, + canActivate: [AuthGuard], + }, + { path: "linksPlan", component: ExternalLinksPlanComponent }, + { path: "CreatePlanOnlineFive", component: CreatePlanOnlineFiveComponent }, + { + path: "exportExcel", + component: ExportExcelComponent, + canActivate: [AuthGuard], }, - {path:'login',component:LoginComponent}, - {path:'keyUnit/viewunitinfoplans', component:ViewUnitDetailsPlanComponent,canActivate: [AuthGuard],}, - {path:'getNoMToken',component:MTokenK1Component, canActivate: [AuthGuard],}, //K1秘钥验证失败是跳转页面 - {path:'planAudit/planpass', component: PlanPassComponent , canActivate: [AuthGuard]}, - {path:'test', component: TestComponent }, - {path:'linksPlan', component: ExternalLinksPlanComponent }, - {path:'CreatePlanOnlineFive',component:CreatePlanOnlineFiveComponent}, - {path:'exportExcel',component:ExportExcelComponent, canActivate: [AuthGuard]}, ]; @NgModule({ imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] + exports: [RouterModule], }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 338921c..58ae294 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,7 +9,6 @@ import { MatIconModule } from '@angular/material/icon'; import { MatSidenavModule } from '@angular/material/sidenav'; import { NavigationModule } from './navigation/navigation.module'; import { HomeComponent } from './home/home.component'; -import { TabbarComponent } from './tabbar/tabbar.component'; import { PagesModule } from './pages/pages.module'; import { FormsModule } from '@angular/forms'; import { UiModule } from './ui/ui.module'; @@ -22,7 +21,6 @@ import { CountdownModule } from 'ngx-countdown'; //倒计时插件 import { GISManagementModule } from './gis-management/gis-management.module'; import { DataCollectionModule } from './data-collection/data-collection.module'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; -import { TestComponent } from './test/test.component'; import { ExternalLinksPlanComponent } from './external-links-plan/external-links-plan.component'; import { SearchDownList } from '../modules/map/declare/component/SearchDownListPlugins/SearchDownList'; import { ExportExcelComponent } from './export-excel/export-excel.component'; @@ -34,7 +32,6 @@ registerLocaleData(zh); AppComponent, HomeComponent, MTokenK1Component, - TestComponent, ExternalLinksPlanComponent, SearchDownList, ExportExcelComponent diff --git a/src/app/key-unit/basicinfo/basicinfo.component.html b/src/app/key-unit/basicinfo/basicinfo.component.html index f4d62ab..d32a479 100644 --- a/src/app/key-unit/basicinfo/basicinfo.component.html +++ b/src/app/key-unit/basicinfo/basicinfo.component.html @@ -117,7 +117,7 @@
-
+
diff --git a/src/app/key-unit/basicinfo/basicinfo.component.ts b/src/app/key-unit/basicinfo/basicinfo.component.ts index bfabd90..4e01c37 100644 --- a/src/app/key-unit/basicinfo/basicinfo.component.ts +++ b/src/app/key-unit/basicinfo/basicinfo.component.ts @@ -413,7 +413,7 @@ export class BasicinfoComponent implements OnInit { } else {//未标注 _this.isMapLabel = false } - this.labelGis() + // this.labelGis() }) } ) diff --git a/src/app/key-unit/edit-plan-info/edit-plan-info.component.html b/src/app/key-unit/edit-plan-info/edit-plan-info.component.html index 80599ab..49eecf9 100644 --- a/src/app/key-unit/edit-plan-info/edit-plan-info.component.html +++ b/src/app/key-unit/edit-plan-info/edit-plan-info.component.html @@ -45,7 +45,7 @@ - + + - + - + diff --git a/src/app/key-unit/edit-unit-info/edit-unit-info.component.html b/src/app/key-unit/edit-unit-info/edit-unit-info.component.html index 62440f4..e3c55cc 100644 --- a/src/app/key-unit/edit-unit-info/edit-unit-info.component.html +++ b/src/app/key-unit/edit-unit-info/edit-unit-info.component.html @@ -1,10 +1,3 @@ - -
-
- -
-
- @@ -31,7 +24,7 @@ - + + - + - + - + - diff --git a/src/app/key-unit/edit-unit-info/edit-unit-info.component.ts b/src/app/key-unit/edit-unit-info/edit-unit-info.component.ts index 4a31d46..e772e10 100644 --- a/src/app/key-unit/edit-unit-info/edit-unit-info.component.ts +++ b/src/app/key-unit/edit-unit-info/edit-unit-info.component.ts @@ -1,9 +1,4 @@ import { Component, OnInit } from '@angular/core'; -// import { BasicinfoComponent } from '../basicinfo/basicinfo.component' -import { Router,ActivatedRoute } from '@angular/router' -import {MTokenK1Service} from '../../m-token-k1/m-token-k1.service' //引入服务 -import { CollectionToolsComponent } from '../../../app/ui/collection-tools/collection-tools.component' - @Component({ selector: 'app-edit-unit-info', @@ -12,7 +7,7 @@ import { CollectionToolsComponent } from '../../../app/ui/collection-tools/colle }) export class EditUnitInfoComponent implements OnInit { - constructor(private router:Router,private route:ActivatedRoute,public mToken: MTokenK1Service) { } + constructor() { } ngOnInit(): void { diff --git a/src/app/key-unit/key-unit-management/key-unit-management.component.html b/src/app/key-unit/key-unit-management/key-unit-management.component.html index 9b70d6c..f8ed90c 100644 --- a/src/app/key-unit/key-unit-management/key-unit-management.component.html +++ b/src/app/key-unit/key-unit-management/key-unit-management.component.html @@ -352,7 +352,7 @@ 操作 - 演练 + 查看详情 + @@ -24,7 +24,7 @@ - + + - + - + - + - - + + - + - - - + \ No newline at end of file diff --git a/src/app/key-unit/view-unit-details/view-unit-details.component.html b/src/app/key-unit/view-unit-details/view-unit-details.component.html index 008636b..5e87bd8 100644 --- a/src/app/key-unit/view-unit-details/view-unit-details.component.html +++ b/src/app/key-unit/view-unit-details/view-unit-details.component.html @@ -44,7 +44,7 @@
- + + - + - + diff --git a/src/app/plan-audit/plan-record/plan-record.component.ts b/src/app/plan-audit/plan-record/plan-record.component.ts index d293d38..3a3bfbc 100644 --- a/src/app/plan-audit/plan-record/plan-record.component.ts +++ b/src/app/plan-audit/plan-record/plan-record.component.ts @@ -9,8 +9,7 @@ import { import { HttpClient } from "@angular/common/http"; import { DomSanitizer } from "@angular/platform-browser"; import { Viewer } from "photo-sphere-viewer"; -declare var CryptoJS; - +import * as ViewerJs from "viewerjs"; @Component({ selector: "app-plan-record", templateUrl: "./plan-record.component.html", @@ -152,9 +151,9 @@ export class PlanRecordComponent implements OnInit { postlevel: any; bianzhi = false; tableClick(e, item) { + console.log(item); + this.showtype = -1; - //e.target.parentElement.bgColor='#2196F3' - // console.log(item) this.organizationName = ""; this.itemid = item.itemId; this.id = item.id; @@ -206,9 +205,9 @@ export class PlanRecordComponent implements OnInit { this.http .get(`/api/PlanComponents/${item.itemId}`) .subscribe((data: any) => { + console.log("预案详情", data); this.companyId = data.companyId; this.companyName = data.companyName; - //this.bianzhi = false if (data.planType != 2 && data.planType != 1) { if (data.planMode == 2) { this.showtype = 0; @@ -217,11 +216,17 @@ export class PlanRecordComponent implements OnInit { this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl( this.src ); - //this.src=`/keyUnit/viewunitinfoplan?id=${data.companyId}&orName=${data.company.organizationId}&orId=${data.company.organizationName}` } else { this.bianzhi = false; this.fetchUrl = data.attachmentUrls[0]; var index = this.fetchUrl.indexOf("/"); + let isImg; + if ( + this.fetchUrl.indexOf("png") !== -1 || + this.fetchUrl.indexOf("jpg") !== -1 + ) { + isImg = true; + } if (this.fetchUrl.substr(0, index) == "psw") { this.showtype = 1; var obj = document.getElementById("viewer"); @@ -234,6 +239,26 @@ export class PlanRecordComponent implements OnInit { panorama: "/api/Objects/PlanPlatform/" + this.fetchUrl, }); }); + } else if (isImg) { + let dom = document.getElementById(`viewerjs`); + let pObjs = dom.childNodes; + let node = document.createElement("img"); + node.style.display = "none"; + node.src = "/api/Objects/PlanPlatform/" + this.fetchUrl; + node.id = "img"; + dom.appendChild(node); + setTimeout(() => { + let viewer = new ViewerJs( + document.getElementById(`viewerjs`), + { + hidden: () => { + dom.removeChild(pObjs[0]); + viewer.destroy(); + }, + } + ); + node.click(); + }, 0); } else { this.lookWord(); } @@ -243,10 +268,6 @@ export class PlanRecordComponent implements OnInit { this.planData = data; this.handleData(); return; - - //this.src=`/planAudit/planpass?id=${data.companyId}&companyName=${data.companyName}&auditPlanId=${data.id}&auditStatus=${data.auditStatus}&planType=1` - //this.iframeSrc=this.sanitizer.bypassSecurityTrustResourceUrl(this.src); - //window.open(`/planAudit/planpass?id=${data.companyId}&companyName=${data.companyName}&auditPlanId=${data.id}&auditStatus=${data.auditStatus}&planType=1`) } }); } @@ -261,8 +282,6 @@ export class PlanRecordComponent implements OnInit { } } this.radioid = item.itemId; - /* this.chuorzhong=item.verifyState - this.radioid=item.itemId */ } //毕升 diff --git a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts index fad479a..661202b 100644 --- a/src/app/plan-audit/wait-examineer/wait-examineer.component.ts +++ b/src/app/plan-audit/wait-examineer/wait-examineer.component.ts @@ -18,9 +18,8 @@ import { HttpClient } from "@angular/common/http"; declare var CryptoJS; import { DomSanitizer } from "@angular/platform-browser"; import { Viewer as photoViewer } from "photo-sphere-viewer"; -import Viewer from "viewerjs"; declare var echarts: any; - +import * as ViewerJs from "viewerjs"; @Component({ selector: "app-wait-examineer", templateUrl: "./wait-examineer.component.html", @@ -111,7 +110,7 @@ export class WaitExamineerComponent implements OnInit { fetchUrl; companyName; plantypes; - IsNewData:any = [true, false]; + IsNewData: any = [true, false]; //获取表格数据 PageNumber = 1; @@ -197,8 +196,6 @@ export class WaitExamineerComponent implements OnInit { bianzhi = false; radioClick(e, item) { this.selectedItem = item; - - // console.log('当前选择的信息',JSON.parse(this.selectedItem.differentContent) ) if (item.contentType == 11 && this.selectedItem.differentContent) { let differentContent = JSON.parse(this.selectedItem.differentContent); @@ -272,9 +269,6 @@ export class WaitExamineerComponent implements OnInit { }); } } - - // console.log('功能分区', this.differentContentOfFunction) - this.showtype = -1; this.organizationName = ""; this.itemid = item.itemId; @@ -349,6 +343,13 @@ export class WaitExamineerComponent implements OnInit { this.bianzhi = false; this.fetchUrl = data.attachmentUrls[0]; var index = this.fetchUrl.indexOf("/"); + let isImg; + if ( + this.fetchUrl.indexOf("png") !== -1 || + this.fetchUrl.indexOf("jpg") !== -1 + ) { + isImg = true; + } if (this.fetchUrl.substr(0, index) == "psw") { this.showtype = 1; var obj = document.getElementById("viewer"); @@ -361,6 +362,26 @@ export class WaitExamineerComponent implements OnInit { panorama: "/api/Objects/PlanPlatform/" + this.fetchUrl, }); }); + } else if (isImg) { + let dom = document.getElementById(`viewerjs`); + let pObjs = dom.childNodes; + let node = document.createElement("img"); + node.style.display = "none"; + node.src = "/api/Objects/PlanPlatform/" + this.fetchUrl; + node.id = "img"; + dom.appendChild(node); + setTimeout(() => { + let viewer = new ViewerJs( + document.getElementById(`viewerjs`), + { + hidden: () => { + dom.removeChild(pObjs[0]); + viewer.destroy(); + }, + } + ); + node.click(); + }, 0); } else { this.lookWord(); } diff --git a/src/app/plan-management/entry-plan-look/AddPlanone.html b/src/app/plan-management/entry-plan-look/AddPlanone.html index 45e896c..f4ae373 100644 --- a/src/app/plan-management/entry-plan-look/AddPlanone.html +++ b/src/app/plan-management/entry-plan-look/AddPlanone.html @@ -61,12 +61,12 @@ (已上传) -
+ 查看 下载 diff --git a/src/app/test/test.component.html b/src/app/test/test.component.html deleted file mode 100644 index 16e1975..0000000 --- a/src/app/test/test.component.html +++ /dev/null @@ -1,8 +0,0 @@ -
- -
-
- -
-
- diff --git a/src/app/test/test.component.scss b/src/app/test/test.component.scss deleted file mode 100644 index c5e4774..0000000 --- a/src/app/test/test.component.scss +++ /dev/null @@ -1,17 +0,0 @@ -.box{ - width: 100%; - height: 100%; - display: flex; - #mapxxx{ - width: 500px; - height: 500px; - } - .img{ - width: 500px; - height: 500px; - img{ - width: 500px; - height: 500px; - } - } -} diff --git a/src/app/test/test.component.spec.ts b/src/app/test/test.component.spec.ts deleted file mode 100644 index ef4e38c..0000000 --- a/src/app/test/test.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { TestComponent } from './test.component'; - -describe('TestComponent', () => { - let component: TestComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ TestComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(TestComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts deleted file mode 100644 index 2fee582..0000000 --- a/src/app/test/test.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -declare var html2canvas: any; -declare var AMap: any; -@Component({ - selector: 'app-test', - templateUrl: './test.component.html', - styleUrls: ['./test.component.scss'] -}) -export class TestComponent implements OnInit { - - constructor() { } - map: any - ngOnInit(): void { - setTimeout(() => { - this.map = new AMap.Map('mapxxx', { - WebGLParams: { - preserveDrawingBuffer: true - } - }); - - this.map.setCity('上海市'); - }, 0); - } - //生成图片 - canvasImg - createimg() { - - // 使用html2canvas插件,将数据源中的数据转换成画布。 - html2canvas(document.querySelector("#mapxxx"), { - useCORS: true, - onrendered: function (canvas) { - var dataUrl = canvas.toDataURL("image/png"); - } - }).then(canvas => { - // 修改生成的宽度 - // canvas.style.width = "1000px"; - console.log(canvas, "生成的画布文件"); - this.canvasImg = canvas.toDataURL("image/png"); - // console.log(this.canvasImg) - }).then(() => { - this.downloadFile("导出图片", this.canvasImg); - - }) - - } - downloadFile(filename, content) { - var base64Img = content; - var oA = document.createElement('a'); - oA.href = base64Img; - oA.download = filename; - var event = document.createEvent('MouseEvents'); - event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); - oA.dispatchEvent(event); - } - -} diff --git a/src/app/ui/organization/organization.component.html b/src/app/ui/organization/organization.component.html index 37cdc29..4736180 100644 --- a/src/app/ui/organization/organization.component.html +++ b/src/app/ui/organization/organization.component.html @@ -1,4 +1,7 @@
+ + +
@@ -37,32 +40,5 @@
- -
- -
- ({{selectedOrg.name}})组织机构下属机关 - -
- -
-
    -
  • - {{item.officeName}} - - - - -
  • -
- - 暂无下属机关 - -
-
-
- -

努力加载中...

-
diff --git a/src/app/ui/organization/organization.component.ts b/src/app/ui/organization/organization.component.ts index fbfb589..2fac51f 100644 --- a/src/app/ui/organization/organization.component.ts +++ b/src/app/ui/organization/organization.component.ts @@ -1,485 +1,477 @@ -import { Component, OnInit, Inject } from '@angular/core'; -import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; -import {FlatTreeControl} from '@angular/cdk/tree'; -import { HttpClient } from '@angular/common/http'; -import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; -import {FormControl} from '@angular/forms'; -import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; -import { TreeService } from '../../http-interceptors/tree.service' +import { Component, OnInit, Inject } from "@angular/core"; +import { + MatTreeFlatDataSource, + MatTreeFlattener, +} from "@angular/material/tree"; +import { FlatTreeControl } from "@angular/cdk/tree"; +import { HttpClient } from "@angular/common/http"; +import { + MatDialog, + MatDialogRef, + MAT_DIALOG_DATA, +} from "@angular/material/dialog"; +import { FormControl } from "@angular/forms"; +import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar"; +import { TreeService } from "../../http-interceptors/tree.service"; @Component({ - selector: 'app-organization', - templateUrl: './organization.component.html', - styleUrls: ['./organization.component.scss'] + selector: "app-organization", + templateUrl: "./organization.component.html", + styleUrls: ["./organization.component.scss"], }) export class OrganizationComponent implements OnInit { - data:any =[] //存储所有组织机构 + data: any = []; //存储所有组织机构 newdata = []; - private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数 + private _transformer = (node, level: number) => { + //要给渲染节点传那些属性参数 return { expandable: !!node.children && node.children.length > 0, name: node.name, level: level, id: node.id, parentId: node.parentId, - enabled:node.enabled, - order:node.order, - children:node.children, - isTop:node.isTop, - isBottom:node.isBottom, - code:node.code, - division:node.division + enabled: node.enabled, + order: node.order, + children: node.children, + isTop: node.isTop, + isBottom: node.isBottom, + code: node.code, + division: node.division, }; - } - treeControl = new FlatTreeControl(node => node.level, node => node.expandable); - treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + }; + treeControl = new FlatTreeControl( + (node) => node.level, + (node) => node.expandable + ); + treeFlattener = new MatTreeFlattener( + this._transformer, + (node) => node.level, + (node) => node.expandable, + (node) => node.children + ); dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); - constructor(private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private tree: TreeService) { - } - isloading:any = false //loading效果 + constructor( + private http: HttpClient, + public dialog: MatDialog, + public snackBar: MatSnackBar, + private tree: TreeService + ) {} + isloading: any = false; //loading效果 //重新获取列表并且展开到上次位置的方法 - getlist = ():void=>{ - this.http.get('/api/Organizations').subscribe( - (data:any)=>{ - this.data = data; - this.newdata = this.tree.toTree(data) - - const nodes = this.treeControl.dataNodes; - const expandNodes = []; - nodes.forEach((item) => { - if(item.expandable && this.treeControl.isExpanded(item)){ - expandNodes.push(item.id); - } - }); - - - this.dataSource.data = this.newdata; - let newNodes = this.treeControl.dataNodes; - newNodes = newNodes.filter(n => { - return expandNodes.indexOf(n.id) >= 0; - }); - newNodes.forEach(item => { - this.treeControl.expand(item); - }); - this.isloading = false - - } - ) - } + getlist = (): void => { + this.http.get("/api/Organizations").subscribe((data: any) => { + this.data = data; + this.newdata = this.tree.toTree(data); + + const nodes = this.treeControl.dataNodes; + const expandNodes = []; + nodes.forEach((item) => { + if (item.expandable && this.treeControl.isExpanded(item)) { + expandNodes.push(item.id); + } + }); + + this.dataSource.data = this.newdata; + let newNodes = this.treeControl.dataNodes; + newNodes = newNodes.filter((n) => { + return expandNodes.indexOf(n.id) >= 0; + }); + newNodes.forEach((item) => { + this.treeControl.expand(item); + }); + this.isloading = false; + }); + }; //初始化视图 ngOnInit() { - this.http.get('/api/Organizations').subscribe( - (data:any)=>{ - this.data = data; - this.dataSource.data = this.tree.toTree(data); - this.treeControl.expand(this.treeControl.dataNodes[0]); - } - ) + this.http.get("/api/Organizations").subscribe((data: any) => { + this.data = data; + this.dataSource.data = this.tree.toTree(data); + this.treeControl.expand(this.treeControl.dataNodes[0]); + }); } hasChild = (_: number, node: any) => node.expandable; //创建组织按钮 - create(value){ - const dialogRef = this.dialog.open(CreateOrganization, {//调用open方法打开对话框并且携带参数过去 - width: '260px', - data: {id:value.id,childlength:value.children,level:value.level} + create(value) { + const dialogRef = this.dialog.open(CreateOrganization, { + //调用open方法打开对话框并且携带参数过去 + width: "260px", + data: { id: value.id, childlength: value.children, level: value.level }, }); - dialogRef.afterClosed().subscribe( - data=>{ - if(data){ - this.getlist() - } + dialogRef.afterClosed().subscribe((data) => { + if (data) { + this.getlist(); } - ); + }); } - //编辑组织按钮 - edit(node){ - const dialogRef = this.dialog.open(EditOrganization, {//调用open方法打开对话框并且携带参数过去 - data: node + createOne() { + const dialogRef = this.dialog.open(CreateOrganization, { + //调用open方法打开对话框并且携带参数过去 + width: "260px", + data: { id: "", childlength: "", level: "" }, }); - dialogRef.afterClosed().subscribe( - data=>{ - this.getlist() + dialogRef.afterClosed().subscribe((data) => { + if (data) { + this.getlist(); } - ); + }); + } + //编辑组织按钮 + edit(node) { + const dialogRef = this.dialog.open(EditOrganization, { + //调用open方法打开对话框并且携带参数过去 + data: node, + }); + dialogRef.afterClosed().subscribe((data) => { + this.getlist(); + }); } //删除组织按钮 - delete(value){ - var isdeleted = confirm("确定要删除此组织?") - if(isdeleted){ + delete(value) { + var isdeleted = confirm("确定要删除此组织?"); + if (isdeleted) { //请求删除接口 - this.isloading = true - this.http.delete(`/api/Organizations/${value.id}`).subscribe( data=>{ - this.getlist() - - }) + this.isloading = true; + this.http.delete(`/api/Organizations/${value.id}`).subscribe((data) => { + this.getlist(); + }); } } //禁用按钮 - disable(value){ - this.isloading = true - if(!value.enabled){ - this.http.put( - `/api/Organizations/${value.id}`, - { - id:value.id, - code:value.code, - name: value.name, - level:value.level, - order: value.order, - location: null, - enabled: true, - parentId: value.parentId - } - ).subscribe( - data=>{ + disable(value) { + this.isloading = true; + if (!value.enabled) { + this.http + .put(`/api/Organizations/${value.id}`, { + id: value.id, + code: value.code, + name: value.name, + level: value.level, + order: value.order, + location: null, + enabled: true, + parentId: value.parentId, + }) + .subscribe( + (data) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('启用成功','确定',config); - this.getlist() - + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("启用成功", "确定", config); + this.getlist(); }, - err=>{ + (err) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('操作无效','确定',config); - this.isloading = false + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("操作无效", "确定", config); + this.isloading = false; } - ) - - }else{ + ); + } else { // var isdeleted = confirm("确定要禁用此组织?") // if(isdeleted){ - this.http.put( - `/api/Organizations/${value.id}`, - { - id:value.id, - code:value.code, - name: value.name, - level:value.level, - order: value.order, - location: null, - enabled: false, - parentId: value.parentId - } - ).subscribe( - data=>{ + this.http + .put(`/api/Organizations/${value.id}`, { + id: value.id, + code: value.code, + name: value.name, + level: value.level, + order: value.order, + location: null, + enabled: false, + parentId: value.parentId, + }) + .subscribe( + (data) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('禁用成功','确定',config); - this.getlist() - + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("禁用成功", "确定", config); + this.getlist(); }, - err=>{ + (err) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('操作无效','确定',config); - this.isloading = false + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("操作无效", "确定", config); + this.isloading = false; } - ) + ); // } } - - } - //向上箭头 - updata = [] - up(node){ - this.isloading = true + updata = []; + up(node) { + this.isloading = true; var olddata = this.data; // console.log(1,olddata) // console.log(2,node) - this.updata = [] - olddata.forEach(item => { - if(item.id == node.parentId){ - this.updata = item.children + this.updata = []; + olddata.forEach((item) => { + if (item.id == node.parentId) { + this.updata = item.children; } }); // console.log(this.updata) - this.updata.forEach((item,index)=>{ - if(item.name == node.name){ - this.http.put(//更改点击的节点为上一节点的order - `/api/Organizations/${this.updata[index].id}`, - { - id:this.updata[index].id, - code:this.updata[index].code, - name: this.updata[index].name, - level: this.updata[index].level, - order: this.updata[index - 1].order, - location: null, - enabled: true, - parentId: this.updata[index].parentId, - } - ).subscribe( - data=>{ - // this.getlist() - this.http.put(//更改上一节点为点击节点的order - `/api/Organizations/${this.updata[index - 1].id}`, - { - id:this.updata[index - 1].id, - code:this.updata[index - 1].code, - name: this.updata[index - 1].name, - level: this.updata[index - 1].level, - order: this.updata[index].order, - location: null, - enabled: true, - parentId: this.updata[index].parentId, - } - ).subscribe( - data=>{ - this.getlist() - - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('更改order失败','确定',config); - this.isloading = false - } - ) - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('更改order失败','确定',config); - this.isloading = false - } - ) - - + this.updata.forEach((item, index) => { + if (item.name == node.name) { + this.http + .put( + //更改点击的节点为上一节点的order + `/api/Organizations/${this.updata[index].id}`, + { + id: this.updata[index].id, + code: this.updata[index].code, + name: this.updata[index].name, + level: this.updata[index].level, + order: this.updata[index - 1].order, + location: null, + enabled: true, + parentId: this.updata[index].parentId, + } + ) + .subscribe( + (data) => { + // this.getlist() + this.http + .put( + //更改上一节点为点击节点的order + `/api/Organizations/${this.updata[index - 1].id}`, + { + id: this.updata[index - 1].id, + code: this.updata[index - 1].code, + name: this.updata[index - 1].name, + level: this.updata[index - 1].level, + order: this.updata[index].order, + location: null, + enabled: true, + parentId: this.updata[index].parentId, + } + ) + .subscribe( + (data) => { + this.getlist(); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("更改order失败", "确定", config); + this.isloading = false; + } + ); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("更改order失败", "确定", config); + this.isloading = false; + } + ); } - - - - }) - + }); } - - //向下箭头 - downdata = [] - down(node){ - this.isloading = true + downdata = []; + down(node) { + this.isloading = true; var olddata = this.data; - this.downdata = [] - olddata.forEach(item => { - if(item.id == node.parentId){ - this.downdata = item.children + this.downdata = []; + olddata.forEach((item) => { + if (item.id == node.parentId) { + this.downdata = item.children; } }); // console.log(this.downdata) - this.downdata.forEach((item,index)=>{ - if(item.name == node.name){ - this.http.put(//更改点击的节点为下一节点的order - `/api/Organizations/${this.downdata[index].id}`, - { - id:this.downdata[index].id, - code:this.downdata[index].code, - name: this.downdata[index].name, - level: this.downdata[index].level, - order: this.downdata[index + 1].order, - location: null, - enabled: true, - parentId: this.downdata[index].parentId, - } - ).subscribe( - data=>{ - // this.getlist() - this.http.put(//更改上一节点为点击节点的order - `/api/Organizations/${this.downdata[index + 1].id}`, - { - id:this.downdata[index + 1].id, - code:this.downdata[index + 1].code, - name: this.downdata[index + 1].name, - level: this.downdata[index + 1].level, - order: this.downdata[index].order, - location: null, - enabled: true, - parentId: this.downdata[index].parentId, - } - ).subscribe( - data=>{ - this.getlist() - - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('更改order失败','确定',config); - this.isloading = false - } - ) - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('更改order失败','确定',config); - this.isloading = false - } - ) - - + this.downdata.forEach((item, index) => { + if (item.name == node.name) { + this.http + .put( + //更改点击的节点为下一节点的order + `/api/Organizations/${this.downdata[index].id}`, + { + id: this.downdata[index].id, + code: this.downdata[index].code, + name: this.downdata[index].name, + level: this.downdata[index].level, + order: this.downdata[index + 1].order, + location: null, + enabled: true, + parentId: this.downdata[index].parentId, + } + ) + .subscribe( + (data) => { + // this.getlist() + this.http + .put( + //更改上一节点为点击节点的order + `/api/Organizations/${this.downdata[index + 1].id}`, + { + id: this.downdata[index + 1].id, + code: this.downdata[index + 1].code, + name: this.downdata[index + 1].name, + level: this.downdata[index + 1].level, + order: this.downdata[index].order, + location: null, + enabled: true, + parentId: this.downdata[index].parentId, + } + ) + .subscribe( + (data) => { + this.getlist(); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("更改order失败", "确定", config); + this.isloading = false; + } + ); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("更改order失败", "确定", config); + this.isloading = false; + } + ); } - - - - }) + }); } - selectedOrg:any//当前选择的组织机构 - OfficesList:any //获得的下级列表 + selectedOrg: any; //当前选择的组织机构 + OfficesList: any; //获得的下级列表 //获得点击组织机构的下级机关单位 - getOffices(node){ + getOffices(node) { // console.log(node) - this.selectedOrg = node - this.http.get(`/api/OrganizationsOffices/${node.id}`).subscribe(data => { + this.selectedOrg = node; + this.http.get(`/api/OrganizationsOffices/${node.id}`).subscribe((data) => { // console.log("获取成功",data) - this.OfficesList = data - }) + this.OfficesList = data; + }); } //新增下属机关 - addOffices(){ - const dialogRef = this.dialog.open(addOffices, {//调用open方法打开对话框并且携带参数过去 - data: {selectedOrg:this.selectedOrg,OfficesList:this.OfficesList} + addOffices() { + const dialogRef = this.dialog.open(addOffices, { + //调用open方法打开对话框并且携带参数过去 + data: { selectedOrg: this.selectedOrg, OfficesList: this.OfficesList }, }); - dialogRef.afterClosed().subscribe( - data=>{ - if(data == '创建成功'){ - this.getOffices(this.selectedOrg) - } + dialogRef.afterClosed().subscribe((data) => { + if (data == "创建成功") { + this.getOffices(this.selectedOrg); } - ); + }); } //编辑机关 - editOffice(item){ - const dialogRef = this.dialog.open(editOffices, {//调用open方法打开对话框并且携带参数过去 - data: {item:item} + editOffice(item) { + const dialogRef = this.dialog.open(editOffices, { + //调用open方法打开对话框并且携带参数过去 + data: { item: item }, }); - dialogRef.afterClosed().subscribe( - data=>{ - if(data == '修改成功'){ - this.getOffices(this.selectedOrg) - } + dialogRef.afterClosed().subscribe((data) => { + if (data == "修改成功") { + this.getOffices(this.selectedOrg); } - ); + }); } //删除机关 - deleteOffice(item){ - let isDelete = window.confirm('确定要删除此机关吗?') - if(isDelete){ - this.http.delete(`/api/OrganizationsOffices/${item.id}`).subscribe(data => { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('删除成功','确定',config); - this.getOffices(this.selectedOrg) - }) + deleteOffice(item) { + let isDelete = window.confirm("确定要删除此机关吗?"); + if (isDelete) { + this.http + .delete(`/api/OrganizationsOffices/${item.id}`) + .subscribe((data) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("删除成功", "确定", config); + this.getOffices(this.selectedOrg); + }); } } - } - - - - //创建组织 @Component({ - selector: 'createorganization', - templateUrl: './createorganization.component.html', - styleUrls: ['./organization.component.scss'] + selector: "createorganization", + templateUrl: "./createorganization.component.html", + styleUrls: ["./organization.component.scss"], }) export class CreateOrganization { myControl = new FormControl(); - ishttp: boolean =false - constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data, - public snackBar: MatSnackBar) {} + ishttp: boolean = false; + constructor( + private http: HttpClient, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, + public snackBar: MatSnackBar + ) {} onNoClick(): void { this.dialogRef.close(); } - onSubmit(value){ - if(this.data.childlength){//如果点击节点存在children - this.http.post( - '/api/Organizations', - { - id:"", - code:value.number, - division:value.division, - name: value.name, - level:this.data.level + 1, - order: this.data.childlength[this.data.childlength.length -1].order + 1, - location: null, - enabled: true, - parentId: this.data.id, - } - ).subscribe( - data=>{ - this.dialogRef.close(data); - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('创建组织成功','确定',config); - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写正确格式','确定',config); - } - ) - }else{ - this.http.post( - '/api/Organizations', - { - id:"", - code:value.number, - division:value.division, - name: value.name, - level:this.data.level + 1, - order:0, - location: null, - enabled: true, - parentId: this.data.id, - } - ).subscribe( - data=>{ + onSubmit(value) { + let obj = { + id: "", + code: "12000000", + division: "12000000", + name: "天津总队", + level: 0, + order: null, + location: null, + enabled: true, + parentId: null, + }; + //如果点击节点存在children + this.http + .post("/api/Organizations", { + id: "", + code: value.number, + division: value.division, + name: value.name, + level: this.data.level + 1, + order: this.data.childlength + ? this.data.childlength[this.data.childlength.length - 1].order + 1 + : 0, + location: null, + enabled: true, + parentId: this.data.id, + }) + .subscribe( + (data) => { this.dialogRef.close(data); const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('创建组织成功','确定',config); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("创建组织成功", "确定", config); }, - err=>{ + (err) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写正确格式','确定',config); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("请填写正确格式", "确定", config); } - ) - } - + ); } } //编辑组件 @Component({ - selector: 'editorganization', - templateUrl: './editorganization.component.html', - styleUrls: ['./organization.component.scss'] + selector: "editorganization", + templateUrl: "./editorganization.component.html", + styleUrls: ["./organization.component.scss"], }) export class EditOrganization { newdata = []; @@ -490,170 +482,189 @@ export class EditOrganization { level: level, id: node.id, parentId: node.parentId, - children:node.children, - division:node.division + children: node.children, + division: node.division, }; - } - treeControl = new FlatTreeControl(node => node.level, node => node.expandable); - treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + }; + treeControl = new FlatTreeControl( + (node) => node.level, + (node) => node.expandable + ); + treeFlattener = new MatTreeFlattener( + this._transformer, + (node) => node.level, + (node) => node.expandable, + (node) => node.children + ); dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); myControl = new FormControl(); - organizationname:string=""//自己组织的名字 - organizationcode:any//自己组织的编号 - organizationName:any =''//上级组织的名字 - organizationId:any =''//上级组织的id - organizationLevel:number =null//上级组织的层级 - organizationchildlength:number = null - allOrganizations:any //所有组织机构 - division:any //区划 - constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data, - private tree:TreeService,public snackBar: MatSnackBar) {} + organizationname: string = ""; //自己组织的名字 + organizationcode: any; //自己组织的编号 + organizationName: any = ""; //上级组织的名字 + organizationId: any = ""; //上级组织的id + organizationLevel: number = null; //上级组织的层级 + organizationchildlength: number = null; + allOrganizations: any; //所有组织机构 + division: any; //区划 + constructor( + private http: HttpClient, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, + private tree: TreeService, + public snackBar: MatSnackBar + ) {} //获取所有组织机构 - getMechanism () { - this.http.get('/api/Organizations').subscribe( - (data:any)=>{ - this.allOrganizations = data - this.dataSource.data = this.tree.toTree(data); - data.forEach(item=>{ - if(item.id == this.data.parentId){ - this.organizationName = item.name - } - }) - } - ) + getMechanism() { + this.http.get("/api/Organizations").subscribe((data: any) => { + this.allOrganizations = data; + this.dataSource.data = this.tree.toTree(data); + data.forEach((item) => { + if (item.id == this.data.parentId) { + this.organizationName = item.name; + } + }); + }); } - + ngOnInit() { // console.log(this.data) - this.getMechanism() - this.organizationname = this.data.name - this.organizationcode = this.data.code - this.division = this.data.division + this.getMechanism(); + this.organizationname = this.data.name; + this.organizationcode = this.data.code; + this.division = this.data.division; } hasChild = (_: number, node: any) => node.expandable; onNoClick(): void { this.dialogRef.close(); } - add(e){ - this.organizationName=e.name - this.organizationId=e.id - this.organizationLevel=e.level - if(e.children){//如果点击的父组织有子节点 - this.organizationchildlength = e.children.length - }else{ - this.organizationchildlength = 0 + add(e) { + this.organizationName = e.name; + this.organizationId = e.id; + this.organizationLevel = e.level; + if (e.children) { + //如果点击的父组织有子节点 + this.organizationchildlength = e.children.length; + } else { + this.organizationchildlength = 0; } } - onSubmit(value){ - if(this.organizationLevel){//如果点击了右边的树 - this.http.put( - `/api/Organizations/${this.data.id}`, - { - id:this.data.id, - code:value.number, - division:value.division, + onSubmit(value) { + if (this.organizationLevel) { + //如果点击了右边的树 + this.http + .put(`/api/Organizations/${this.data.id}`, { + id: this.data.id, + code: value.number, + division: value.division, name: value.name, - level:this.organizationLevel + 1, - order: this.organizationchildlength, + level: this.organizationLevel + 1, + order: this.organizationchildlength, location: null, enabled: true, parentId: this.organizationId, - } - ).subscribe( - data=>{ - this.dialogRef.close(); - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('修改成功','确定',config); - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写正确格式','确定',config); - } - ) - }else{ //如果只改了姓名 - this.http.put( - `/api/Organizations/${this.data.id}`, - { - id:this.data.id, + }) + .subscribe( + (data) => { + this.dialogRef.close(); + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("修改成功", "确定", config); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("请填写正确格式", "确定", config); + } + ); + } else { + //如果只改了姓名 + this.http + .put(`/api/Organizations/${this.data.id}`, { + id: this.data.id, code: value.number, - division:value.division, + division: value.division, name: value.name, - level:this.data.level, + level: this.data.level, order: this.data.order, location: null, enabled: true, parentId: this.data.parentId, - } - ).subscribe( - data=>{ - this.dialogRef.close(); - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('修改成功','确定',config); - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写正确格式','确定',config); - } - ) + }) + .subscribe( + (data) => { + this.dialogRef.close(); + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("修改成功", "确定", config); + }, + (err) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("请填写正确格式", "确定", config); + } + ); } - } } - //增加下属机关 @Component({ - selector: 'addOffices', - templateUrl: './addOffices.html', - styleUrls: ['./organization.component.scss'] + selector: "addOffices", + templateUrl: "./addOffices.html", + styleUrls: ["./organization.component.scss"], }) export class addOffices { - - constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {} + constructor( + private http: HttpClient, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, + public snackBar: MatSnackBar + ) {} onNoClick(): void { this.dialogRef.close(); } - onSubmit(value){ + onSubmit(value) { // console.log(value) let body = { id: null, organizationId: this.data.selectedOrg.id, officeName: value.name, - order: this.data.OfficesList.length == 0 ? 0 : this.data.OfficesList[this.data.OfficesList.length - 1].order, - enabled: true - } - this.http.post('/api/OrganizationsOffices',body).subscribe(data => { + order: + this.data.OfficesList.length == 0 + ? 0 + : this.data.OfficesList[this.data.OfficesList.length - 1].order, + enabled: true, + }; + this.http.post("/api/OrganizationsOffices", body).subscribe((data) => { const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('创建成功','确定',config); - this.dialogRef.close('创建成功'); - }) + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("创建成功", "确定", config); + this.dialogRef.close("创建成功"); + }); } } - //编辑下属机关 @Component({ - selector: 'editOffices', - templateUrl: './editOffices.html', - styleUrls: ['./organization.component.scss'] + selector: "editOffices", + templateUrl: "./editOffices.html", + styleUrls: ["./organization.component.scss"], }) export class editOffices { - - constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {} - + constructor( + private http: HttpClient, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data, + public snackBar: MatSnackBar + ) {} ngOnInit(): void { // console.log(this.data) @@ -661,22 +672,24 @@ export class editOffices { onNoClick(): void { this.dialogRef.close(); } - officeName:any = this.data.item.officeName - onSubmit(value){ + officeName: any = this.data.item.officeName; + onSubmit(value) { // console.log(value) let body = { id: this.data.item.id, organizationId: this.data.item.organizationId, officeName: value.name, order: this.data.item.order, - enabled: true - } - this.http.put(`/api/OrganizationsOffices/${this.data.item.id}`,body).subscribe(data => { - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('修改成功','确定',config); - this.dialogRef.close('修改成功'); - }) + enabled: true, + }; + this.http + .put(`/api/OrganizationsOffices/${this.data.item.id}`, body) + .subscribe((data) => { + const config = new MatSnackBarConfig(); + config.verticalPosition = "top"; + config.duration = 3000; + this.snackBar.open("修改成功", "确定", config); + this.dialogRef.close("修改成功"); + }); } -} \ No newline at end of file +} diff --git a/src/index.html b/src/index.html index 3931af2..052f70a 100644 --- a/src/index.html +++ b/src/index.html @@ -6,7 +6,6 @@ 数字化预案编制管理平台 - @@ -17,22 +16,9 @@ - - - - - - - + \ No newline at end of file