10 changed files with 224 additions and 7 deletions
@ -0,0 +1,17 @@ |
|||||||
|
<div class="tagbox"> |
||||||
|
<div class="content"> |
||||||
|
<nz-tree [hidden]="!(step === 1)" #nzTreeComponent [nzData]="nodes" nzCheckable |
||||||
|
[nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys"></nz-tree> |
||||||
|
<div class="inputbox" [hidden]="!(step === 2)"> |
||||||
|
<button (click)="addInput()" nz-button>增加一行</button> |
||||||
|
<div class="inputItem" *ngFor="let item of inputList;let key =index"> |
||||||
|
<input nz-input [(ngModel)]="item.value" [name]="key.toString()" /> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="btnbox"> |
||||||
|
<button nz-button nzType="primary" (click)="nextStep()" *ngIf="step === 1">下一步</button> |
||||||
|
<button nz-button nzType="primary" (click)="back()" *ngIf="step === 2">上一步</button> |
||||||
|
<button nz-button nzType="primary" (click)="ok()" *ngIf="step === 2">确定</button> |
||||||
|
</div> |
||||||
|
</div> |
@ -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; |
||||||
|
} |
||||||
|
} |
@ -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<WorkerTagComponent>; |
||||||
|
|
||||||
|
beforeEach(async () => { |
||||||
|
await TestBed.configureTestingModule({ |
||||||
|
declarations: [ WorkerTagComponent ] |
||||||
|
}) |
||||||
|
.compileComponents(); |
||||||
|
}); |
||||||
|
|
||||||
|
beforeEach(() => { |
||||||
|
fixture = TestBed.createComponent(WorkerTagComponent); |
||||||
|
component = fixture.componentInstance; |
||||||
|
fixture.detectChanges(); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should create', () => { |
||||||
|
expect(component).toBeTruthy(); |
||||||
|
}); |
||||||
|
}); |
@ -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<void>((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<void>((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) => {}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue