fix bug
This commit is contained in:
@ -10,7 +10,14 @@ import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
|
||||
styleUrls: ['./rebate-table.component.less']
|
||||
})
|
||||
export class RebateTableComponent implements OnInit {
|
||||
data: any[] = [];
|
||||
data: any[] = [
|
||||
{
|
||||
gradeConfigId: '',
|
||||
startAmount: 0,
|
||||
endAmount: 0,
|
||||
managementFeeRatio: 0,
|
||||
}
|
||||
];
|
||||
headers: any[] = [];
|
||||
formatterDollar = (value: number): string => `${value}`;
|
||||
changeSub = new Subject<string>();
|
||||
@ -18,70 +25,57 @@ export class RebateTableComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadData();
|
||||
this.changeEndKmAction();
|
||||
this.changeendAmountAction();
|
||||
}
|
||||
|
||||
loadData() {
|
||||
this.service.request('/api/mdc/cuc/insuranceConfig/list').subscribe(res => {
|
||||
if (res) {
|
||||
console.log(res);
|
||||
this.data = res;
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
});
|
||||
this.service.request('/api/mdc/pbc/sysConfigItem/findItemValueByItemKeys', [
|
||||
"rebate.config.minrebatePrice"
|
||||
]).subscribe(res => {
|
||||
if (res) {
|
||||
console.log(res);
|
||||
}
|
||||
});
|
||||
// this.service.request('/api/mdc/cuc/insuranceConfig/list').subscribe(res => {
|
||||
// if (res) {
|
||||
// console.log(res);
|
||||
// this.data = res;
|
||||
// this.cdr.detectChanges();
|
||||
// }
|
||||
// });
|
||||
// this.service.request('/api/mdc/pbc/sysConfigItem/findItemValueByItemKeys', [
|
||||
// "rebate.config.minrebatePrice"
|
||||
// ]).subscribe(res => {
|
||||
// if (res) {
|
||||
// console.log(res);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改结束车长
|
||||
* @param event 车长
|
||||
* @param i 下标
|
||||
*/
|
||||
changeEndLength(event: any, i: number) {
|
||||
if (event <= this.headers[i].startLength) {
|
||||
this.headers[i].endLength = this.headers[i].startLength + 1;
|
||||
this.changeNextStartLength(event, i + 1);
|
||||
return;
|
||||
}
|
||||
this.headers[i].endLength = event;
|
||||
this.changeNextStartLength(event, i + 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改结束公里数
|
||||
* @param event 车长
|
||||
* @param i 下标
|
||||
*/
|
||||
changeEndKm(event: any, i: number) {
|
||||
changeendAmount(event: any, i: number) {
|
||||
if (event) {
|
||||
console.log(event);
|
||||
|
||||
this.changeSub.next(`${event},${i}`);
|
||||
}
|
||||
}
|
||||
changeEndKmAction() {
|
||||
changeendAmountAction() {
|
||||
this.changeSub.pipe(debounceTime(500)).subscribe((res: string) => {
|
||||
if (res) {
|
||||
const paras = res.split(',');
|
||||
const num = Number(paras[0]);
|
||||
const i = Number(paras[1]);
|
||||
|
||||
if (num <= this.data[i].startKm) {
|
||||
this.data[i].endKm = null;
|
||||
if (num <= this.data[i].startAmount) {
|
||||
this.data[i].endAmount = null;
|
||||
setTimeout(() => {
|
||||
this.data[i].endKm = this.data[i].startKm + 1 ;
|
||||
this.data[i].endAmount = this.data[i].startAmount + 1 ;
|
||||
}, 0);
|
||||
this.changeNextStartKm(this.data[i].startKm + 1, i + 1);
|
||||
this.changeNextstartAmount(this.data[i].startAmount + 1, i + 1);
|
||||
return;
|
||||
}
|
||||
this.data[i].endKm = num;
|
||||
this.changeNextStartKm(num, i + 1);
|
||||
this.data[i].endAmount = num;
|
||||
this.changeNextstartAmount(num, i + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -90,14 +84,14 @@ export class RebateTableComponent implements OnInit {
|
||||
console.log(this.data);
|
||||
|
||||
const tem = this.data[this.data?.length - 1];
|
||||
if (tem && tem.endKm) {
|
||||
if (tem) {
|
||||
this.data.push({
|
||||
endKm: '',
|
||||
startKm: tem.endKm
|
||||
gradeConfigId: '',
|
||||
startAmount: 0,
|
||||
endAmount: 0,
|
||||
managementFeeRatio: 0,
|
||||
});
|
||||
this.data = [...this.data];
|
||||
} else {
|
||||
this.service.msgSrv.warning('请填写完整公里数');
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,32 +119,18 @@ export class RebateTableComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历同步后置位车长
|
||||
* @param event 车长
|
||||
* @param i 下标
|
||||
*/
|
||||
private changeNextStartLength(event: number, i: number) {
|
||||
if (this.headers[i]) {
|
||||
this.headers[i].startLength = event;
|
||||
if (this.headers[i].endLength <= event) {
|
||||
this.headers[i].endLength = this.headers[i].startLength + 0.5;
|
||||
this.changeNextStartLength(event + 0.5, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历同步后置位公里数
|
||||
* @param event 车长
|
||||
* @param i 下标
|
||||
*/
|
||||
private changeNextStartKm(event: number, i: number) {
|
||||
private changeNextstartAmount(event: number, i: number) {
|
||||
if (this.data[i]) {
|
||||
this.data[i].startKm = event;
|
||||
if (this.data[i].endKm <= event) {
|
||||
this.data[i].endKm = this.data[i].startKm + 1;
|
||||
this.changeNextStartKm(event + 1, i + 1);
|
||||
this.data[i].startAmount = event;
|
||||
if (this.data[i].endAmount <= event) {
|
||||
this.data[i].endAmount = this.data[i].startAmount + 1;
|
||||
this.changeNextstartAmount(event + 1, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user