This commit is contained in:
wangshiming
2022-04-26 16:57:34 +08:00
parent c9afdb19d4
commit 58d0023b4d

View File

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