Browse Source

[完善]防抖函数

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
f972f0f8fd
  1. 5
      src/app/home/task/zhi-indicators/zhi-indicators.component.html
  2. 38
      src/app/home/task/zhi-indicators/zhi-indicators.component.ts

5
src/app/home/task/zhi-indicators/zhi-indicators.component.html

@ -129,8 +129,9 @@
22
</td>
<td style="padding:0 2px!important;">
<!-- <textarea [appDebounceInput]="700" (debounceInput)="dealInput($event)"
style="border: 0;" rows="1" nz-input placeholder="一段简短的说明文字..."></textarea> -->
<textarea [(ngModel)]="item.explain" style="border: 0;" rows="1" nz-input
placeholder="一段简短的说明文字..."
(ngModelChange)="saveItem()"></textarea>
</td>
</tr>
</tbody>

38
src/app/home/task/zhi-indicators/zhi-indicators.component.ts

@ -1,28 +1,32 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Directive, HostListener, Input, EventEmitter, Output, OnDestroy } from '@angular/core';
import { TreeService } from 'src/app/service/tree.service';
import { debounceTime } from 'rxjs/operators';
import { Subject, Subscription } from 'rxjs';
import { fromEvent, Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators'; // 引入debounceTime、Subject
@Component({
selector: 'app-zhi-indicators',
templateUrl: './zhi-indicators.component.html',
styleUrls: ['./zhi-indicators.component.scss']
})
export class ZhiIndicatorsComponent implements OnInit {
@Input('appDebounceInput') debounceTime = 500;
@Output() debounceInput = new EventEmitter();
private inputs = new Subject<any>();
private subscription: Subscription;
@HostListener('input', ['event'])
validateForm!: FormGroup;
constructor(private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
private valueChange = new Subject<string>();
ngOnInit(): void {
this.getAllOrganization()
//保存防抖
this.valueChange.pipe(debounceTime(1000)).subscribe(data => {
console.log(data);
});
}
saveItem() {
this.valueChange.next('xxxx');
}
months = [
{ name: '1月', isable: true },
{ name: '2月', isable: true },
@ -52,7 +56,9 @@ export class ZhiIndicatorsComponent implements OnInit {
search2: '',//选择单位气泡卡片---组织选择列表
search2Value: [],
selectedMenu: 1,//选择单位气泡卡片
data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],//表格数据
data: [
{ explain: '' }
],//表格数据
nodes: []
}
@ -68,6 +74,10 @@ export class ZhiIndicatorsComponent implements OnInit {
data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],//表格数据
nodes: []
}
isPopover(data) {
data.isPopover = !data.isPopover
}
@ -83,9 +93,7 @@ export class ZhiIndicatorsComponent implements OnInit {
data.isExpand = !data.isExpand
}
ngOnInit(): void {
this.getAllOrganization()
}
nzExpandAll = false;
totalCount: string

Loading…
Cancel
Save