Browse Source

[完善]批量更新oilin_sleep_m

master
邵佳豪 4 hours ago
parent
commit
b4539f72bd
  1. 4
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html
  2. 12
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss
  3. 5
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts
  4. 12
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.html
  5. 62
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts

4
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html

@ -12,9 +12,11 @@
</div>
<div class="treeTitle">
<span>组织机构</span>
<a (click)="workerTag()">批量更新workerTag字段</a>
</div>
<div class="treebox">
<a (click)="workerTag(1)">批量更新workerTag</a>
<a (click)="workerTag(2)">批量更新oilin_sleep_m</a>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" [nzSelectedKeys]='nzSelectedKeys'
(nzClick)="nzClick($event)">

12
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss

@ -8,7 +8,6 @@
font-size: 15px;
}
.orbox {
width: 375px;
height: 100%;
@ -27,7 +26,7 @@
.lefttop {
span {
color: #000D21;
color: #000d21;
margin-right: 16px;
}
@ -56,15 +55,17 @@
line-height: 36px;
display: flex;
justify-content: space-between;
color: #000D21;
color: #000d21;
box-sizing: border-box;
padding:0 30px;
padding: 0 30px;
background: rgba(145, 204, 255, 0.2);
border: 1px solid rgba(145, 204, 255, 0.2);
}
.treebox {
flex: 1;
display: flex;
flex-direction: column;
overflow-y: auto;
border: 1px solid rgba(145, 204, 255, 0.2);
border-top: 0px;
@ -72,7 +73,6 @@
padding: 10px 6px;
tr {
th,
td {
text-align: center !important;
@ -94,6 +94,6 @@
margin-top: 16px;
}
.red:hover{
.red:hover {
color: red;
}

5
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts

@ -305,13 +305,14 @@ export class AnalysisOfTheHostComponent implements OnInit {
});
}
workerTag() {
workerTag(type: number) {
this.modal.create({
nzTitle: '修改workerTag字段',
nzTitle: type == 1 ? '批量更新workerTag' : '批量更新oilin_sleep_m',
nzContent: WorkerTagComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 500,
nzComponentParams: {
type: type,
tree: this.nodes,
},
nzFooter: null,

12
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.html

@ -3,9 +3,15 @@
<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 *ngIf="type==1">
<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 *ngIf="type==2">
<input nz-input [(ngModel)]="oldValue" placeholder="老值" />
<input nz-input [(ngModel)]="newValue" placeholder="新值" />
</div>
</div>
</div>

62
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts

@ -11,6 +11,7 @@ import { TreeService } from 'src/app/service/tree.service';
})
export class WorkerTagComponent implements OnInit {
@Input() tree: any;
@Input() type: number;
@ViewChild('nzTreeComponent', { static: false })
nzTreeComponent!: NzTreeComponent;
defaultCheckedKeys = [];
@ -66,6 +67,9 @@ export class WorkerTagComponent implements OnInit {
addInput() {
this.inputList.push({ value: '' });
}
oldValue: string;
newValue: string;
ok() {
let ids =
this.nzTreeComponent.getCheckedNodeList().map((item) => {
@ -80,9 +84,17 @@ export class WorkerTagComponent implements OnInit {
this.message.create('info', '请至少选择一个加油站');
return;
}
if (this.inputList.find((v) => !v.value)) {
this.message.create('info', '请将所有输入框填写完整');
return;
if (this.type == 1) {
if (this.inputList.find((v) => !v.value)) {
this.message.create('info', '请将所有输入框填写完整');
return;
}
}
if (this.type == 2) {
if (!this.oldValue || !this.newValue) {
this.message.create('info', '请将所有输入框填写完整');
return;
}
}
let _this = this;
function BatchModifyWorkerTags() {
@ -104,6 +116,30 @@ export class WorkerTagComponent implements OnInit {
});
return a;
}
function BatchModifyoi() {
var a = new Promise<void>((resolve, reject) => {
let obj = {
replaceString: _this.newValue,
targetString: _this.oldValue,
};
_this.http
.put('/api/EdgeDevices/BatchModifyConfig', ids, {
params: obj,
})
.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
@ -123,10 +159,20 @@ export class WorkerTagComponent implements OnInit {
});
return b;
}
BatchModifyWorkerTags()
.then((data) => {
BatchPushFile();
})
.catch((err) => {});
if (this.type == 1) {
BatchModifyWorkerTags()
.then((data) => {
BatchPushFile();
})
.catch((err) => {});
}
if (this.type == 2) {
BatchModifyoi()
.then((data) => {
BatchPushFile();
})
.catch((err) => {});
}
}
}

Loading…
Cancel
Save