fix bug
This commit is contained in:
		| @ -1,8 +1,7 @@ | ||||
| import { debounceTime } from 'rxjs/operators'; | ||||
| import { Subject } from 'rxjs'; | ||||
| import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, Output, ViewChild } from '@angular/core'; | ||||
| import { ChangeDetectorRef, Component, Input, OnInit, Output } from '@angular/core'; | ||||
| import { BaseService } from '@shared'; | ||||
| import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; | ||||
| import { EventEmitter } from '@angular/core'; | ||||
| @Component({ | ||||
|   selector: 'app-rebate-table', | ||||
| @ -10,9 +9,9 @@ import { EventEmitter } from '@angular/core'; | ||||
|   styleUrls: ['./rebate-table.component.less'] | ||||
| }) | ||||
| export class RebateTableComponent implements OnInit { | ||||
|   @Input() data: any = []; | ||||
|   @Input() type: any; | ||||
|   @Input() hiden!: boolean; | ||||
|   @Input() data: any = [];     // 数据 | ||||
|   @Input() type: any;          // 配置类型 1全部等级 2不同等级 | ||||
|   @Input() hiden!: boolean;    // 判断新增/查看  | ||||
|   @Output() | ||||
|   private dataChange: EventEmitter<any> = new EventEmitter(); | ||||
|   emit() { | ||||
| @ -29,6 +28,7 @@ export class RebateTableComponent implements OnInit { | ||||
|     if (this.type == '2') { | ||||
|       this.loadData(); | ||||
|     } | ||||
|     // 新增-不同等级情况 | ||||
|     if (!this.hiden && this.type == '2') { | ||||
|       this.data = [ | ||||
|         { | ||||
| @ -38,6 +38,7 @@ export class RebateTableComponent implements OnInit { | ||||
|           managementFeeRatio: 0, | ||||
|         } | ||||
|       ]; | ||||
|     // 新增-全部等级情况 | ||||
|     } else if (!this.hiden && this.type == '1'){ | ||||
|       this.data = [ | ||||
|         { | ||||
| @ -48,17 +49,12 @@ export class RebateTableComponent implements OnInit { | ||||
|         } | ||||
|       ]; | ||||
|     } | ||||
|     | ||||
|     console.log(this.type); | ||||
|     console.log(this.data); | ||||
|  | ||||
|     this.changeendAmountAction(); | ||||
|   } | ||||
|  | ||||
|   loadData() { | ||||
|     this.service.request('/api/mdc/partnerGradeConfig/listPartnerGradeConfig').subscribe(res => { | ||||
|       if (res) { | ||||
|         console.log(res); | ||||
|         this.grage = res; | ||||
|         this.cdr.detectChanges(); | ||||
|       } | ||||
| @ -72,22 +68,17 @@ export class RebateTableComponent implements OnInit { | ||||
|    */ | ||||
|   changeendAmount(event: any, i: number) { | ||||
|     if (event) { | ||||
|       console.log(event); | ||||
|  | ||||
|       this.changeSub.next(`${event},${i}`); | ||||
|     } | ||||
|   } | ||||
|   changeendAmountAction() { | ||||
|     this.changeSub.pipe(debounceTime(500)).subscribe((res: string) => { | ||||
|       if (res) { | ||||
|         console.log(res); | ||||
|  | ||||
|         const paras = res.split(','); | ||||
|         const num = Number(paras[0]); | ||||
|         const i = Number(paras[1]); | ||||
|  | ||||
|         if (num <= this.data[i]?.startAmount) { | ||||
|           console.log(this.data[i].endAmount); | ||||
|           this.data[i].endAmount = null; | ||||
|           setTimeout(() => { | ||||
|             this.data[i].endAmount = this.data[i]?.startAmount + 1; | ||||
| @ -102,8 +93,6 @@ export class RebateTableComponent implements OnInit { | ||||
|   } | ||||
|  | ||||
|   add() { | ||||
|     console.log(this.data); | ||||
|  | ||||
|     const tem = this.data[this.data?.length - 1]; | ||||
|     if (tem) { | ||||
|       this.data.push({ | ||||
| @ -117,11 +106,9 @@ export class RebateTableComponent implements OnInit { | ||||
|   } | ||||
|  | ||||
|   deleteRow(index: number) { | ||||
|     console.log(index); | ||||
|     var newArr = this.data.concat(); | ||||
|     newArr.splice(this.data.length - 1, 1); | ||||
|     // this.data = this.data.pop() | ||||
|     console.log(newArr); | ||||
|     this.data = [...newArr]; | ||||
|   } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user