From d818d2d0878732de2c3b3046b34cfcfda86c9129 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Mon, 14 Aug 2023 14:35:21 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E6=89=B9=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0workerTag=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.ts | 1 + .../analysis-of-the-host.component.html | 1 + .../analysis-of-the-host.component.scss | 3 +- .../analysis-of-the-host.component.ts | 17 +++ .../worker-tag/worker-tag.component.html | 17 +++ .../worker-tag/worker-tag.component.scss | 28 ++++ .../worker-tag/worker-tag.component.spec.ts | 25 ++++ .../worker-tag/worker-tag.component.ts | 132 ++++++++++++++++++ .../system-management.module.ts | 2 + src/index.html | 5 - 10 files changed, 224 insertions(+), 7 deletions(-) create mode 100644 src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.html create mode 100644 src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss create mode 100644 src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts create mode 100644 src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 883887d..c38bd52 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -13,5 +13,6 @@ export class AppComponent { //调用服务中的function刷新token this.token.startUp() } + console.log('更新日期:20230814') } } diff --git a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html index 2452983..82ae63f 100644 --- a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html +++ b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html @@ -12,6 +12,7 @@
组织机构 + 批量更新workerTag字段
+
+ +
+ +
+ +
+
+
+
+ + + +
+
\ No newline at end of file diff --git a/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss new file mode 100644 index 0000000..cab3666 --- /dev/null +++ b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss @@ -0,0 +1,28 @@ +.tagbox { + max-height: 600px; + display: flex; + flex-direction: column; +} + +.content { + flex: 1; + overflow-y: auto; + + .inputbox { + .inputItem { + display: flex; + margin:6px 0px; + } + } + +} + +.btnbox { + display: flex; + justify-content: flex-end; + align-items: center; + margin-top: 16px; + button{ + margin-left: 6px; + } +} diff --git a/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts new file mode 100644 index 0000000..a0e8296 --- /dev/null +++ b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WorkerTagComponent } from './worker-tag.component'; + +describe('WorkerTagComponent', () => { + let component: WorkerTagComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ WorkerTagComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(WorkerTagComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts new file mode 100644 index 0000000..28e0f46 --- /dev/null +++ b/src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts @@ -0,0 +1,132 @@ +import { HttpClient } from '@angular/common/http'; +import { Component, Input, OnInit, ViewChild } from '@angular/core'; +import { NzMessageService } from 'ng-zorro-antd/message'; +import { NzTreeComponent } from 'ng-zorro-antd/tree'; +import { TreeService } from 'src/app/service/tree.service'; + +@Component({ + selector: 'app-worker-tag', + templateUrl: './worker-tag.component.html', + styleUrls: ['./worker-tag.component.scss'], +}) +export class WorkerTagComponent implements OnInit { + @Input() tree: any; + @ViewChild('nzTreeComponent', { static: false }) + nzTreeComponent!: NzTreeComponent; + defaultCheckedKeys = []; + defaultExpandedKeys = []; + constructor( + private http: HttpClient, + private message: NzMessageService, + private toTree: TreeService + ) {} + + nodes = []; + + inputList = [{ value: '' }]; + + step = 1; + ngOnInit(): void { + this.getAllOrganization(); + } + + getAllOrganization() { + let params = { + ContainsChildren: true, + PageSize: 9999, + }; + this.http + .get('/api/Organizations', { + params: params, + }) + .subscribe((data: any) => { + data.items.forEach((element) => { + element.key = element.id; + element.title = element.name; + element.selectable = false; + if (element.isGasStation) { + element.isLeaf = true; + element.disableCheckbox = false; + } else { + element.disableCheckbox = true; + } + }); + this.nodes = [...this.toTree.toTree(data.items)]; + // this.defaultExpandedKeys = [this.nodes[0].id]; + // this.defaultExpandedKeys = [...this.defaultExpandedKeys]; + }); + } + + nextStep() { + this.step = 2; + } + back() { + this.step = 1; + } + addInput() { + this.inputList.push({ value: '' }); + } + ok() { + let ids = + this.nzTreeComponent.getCheckedNodeList().map((item) => { + return item.key; + }) || []; + + let workerTags = + this.inputList.map((item) => { + return item.value; + }) || []; + if (ids.length === 0) { + this.message.create('info', '请至少选择一个加油站'); + return; + } + if (this.inputList.find((v) => !v.value)) { + this.message.create('info', '请将所有输入框填写完整'); + return; + } + let _this = this; + function BatchModifyWorkerTags() { + var a = new Promise((resolve, reject) => { + _this.http + .put('/api/EdgeDevices/BatchModifyWorkerTags', ids, { + params: { workerTags: workerTags }, + }) + .subscribe({ + next: (data: any) => { + _this.message.create('success', '批量修改成功'); + resolve(data); + }, + error: (err) => { + _this.message.create('error', '批量修改失败,请重试'); + reject(err); + }, + }); + }); + return a; + } + function BatchPushFile() { + let b = new Promise((resolve, reject) => { + _this.http + .put('/api/EdgeDevices/Commands/BatchPushFile', ids, { + params: { fileName: 'data.yaml' }, + }) + .subscribe({ + next: (data: any) => { + _this.message.create('success', '批量推送成功'); + resolve(data); + }, + error: (err) => { + _this.message.create('error', '批量推送失败'); + reject(err); + }, + }); + }); + return b; + } + BatchModifyWorkerTags() + .then((data) => { + BatchPushFile(); + }) + .catch((err) => {}); + } +} diff --git a/src/app/system-management/system-management.module.ts b/src/app/system-management/system-management.module.ts index eb0bd52..026f6a0 100644 --- a/src/app/system-management/system-management.module.ts +++ b/src/app/system-management/system-management.module.ts @@ -51,6 +51,7 @@ import { ImageLabelAnxinComponent } from './image-label-anxin/image-label-anxin. import { AnxinConfigComponent } from './host-config/anxin-config/anxin-config.component'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { IframeComponent } from './iframe/iframe.component'; +import { WorkerTagComponent } from './analysis-of-the-host/worker-tag/worker-tag.component'; @NgModule({ declarations: [ OrganizationComponent, @@ -82,6 +83,7 @@ import { IframeComponent } from './iframe/iframe.component'; ImageLabelAnxinComponent, AnxinConfigComponent, IframeComponent, + WorkerTagComponent, ], imports: [ CommonModule, diff --git a/src/index.html b/src/index.html index 3adda8c..b0838a7 100644 --- a/src/index.html +++ b/src/index.html @@ -12,10 +12,5 @@ - \ No newline at end of file