遍历表单
for (const [controlName, control] of Object.entries(this.journalBookCreateForm.controls)) {
if (controlName === 'receiptType' || controlName === 'receiptAmount' ) {
control.patchValue([]);
}
}
某个值不置空
for (const [controlName, control] of Object.entries(this.searchProductForm.controls)) {
if (controlName === 'approvalStatus') {
control.patchValue(3);
} else {
control.patchValue(null);
}
}
数据变化方法
this.journalBookCreateForm.get('paymentPlatformId').valueChanges.subscribe(value => {
if (value != null) {
this.getPaymentPlatformBalanceLoading = true;
this.financeService.getAccountBalanceAmount(value).subscribe(mage => {
if (mage.success) {
this.paymentPlatformBalance = mage.data.amount;
} else {
this.nzMessage.error('获取账户余额错误!' + Mage.getMsgText(mage));
}
this.getPaymentPlatformBalanceLoading = false;
});
} else {
this.paymentPlatformBalance = null;
this.getPaymentPlatformBalanceLoading = false;
}
});