This commit is contained in:
saravanakumarkandasami 2018-11-08 14:13:35 +05:30
commit db1ff3b21b
4 changed files with 54 additions and 77 deletions

View File

@ -194,20 +194,20 @@
</div> </div>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none"> <div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<div fxFlex="33"> <div fxFlex="33">
<mat-checkbox formControlName="emi" [ngModel]="sup.get('emi').value === 1 ? true : false" <mat-checkbox formControlName="emi" [ngModel]="sup.get('emi').value === '1' ? true : false"
(ngModelChange)="sup.get('emi').value = $event ? 1 : 0">EMI</mat-checkbox> (ngModelChange)="sup.get('emi').value = $event ? '1' : '0'">EMI</mat-checkbox>
</div> </div>
<div *ngIf="sup.get('emi').value === 1" fxFlex="33"> <div *ngIf="sup.get('emi').value === '1'" fxFlex="33">
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<input matInput placeholder="EMI Paid" formControlName="emi_paid"> <input matInput placeholder="EMI Paid" formControlName="emi_paid">
</mat-form-field> </mat-form-field>
</div> </div>
<div *ngIf="sup.get('emi').value === 1" fxFlex="33"> <div *ngIf="sup.get('emi').value === '1'" fxFlex="33">
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<input matInput placeholder="Elapsed Tenure" formControlName="elapsed_tenure"> <input matInput placeholder="Elapsed Tenure" formControlName="elapsed_tenure">
</mat-form-field> </mat-form-field>
</div> </div>
<div *ngIf="sup.get('emi').value === 1" fxFlex="33"> <div *ngIf="sup.get('emi').value === '1'" fxFlex="33">
<mat-form-field class="ml-xs example-full-width"> <mat-form-field class="ml-xs example-full-width">
<input matInput placeholder="Balance Tenure" formControlName="balance_tenure"> <input matInput placeholder="Balance Tenure" formControlName="balance_tenure">
</mat-form-field> </mat-form-field>
@ -228,7 +228,7 @@
</div> </div>
</div> </div>
<div class="row" style="text-align:right;"> <div class="row" style="text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" type="reset"><mat-icon>settings_backup_restore</mat-icon></button> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset" matTooltipPosition="above" (click)="onReset(); false"><mat-icon>settings_backup_restore</mat-icon></button>
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button> <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
</div> </div>
</form> </form>

View File

@ -151,9 +151,13 @@ export class AssetsInfoComponent implements OnInit {
} }
] ]
private notifier: NotifierService;
constructor( constructor(
notifier: NotifierService,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private pdTrigerService: PdTrigerService) { } private pdTrigerService: PdTrigerService) {
this.notifier = notifier;
}
ngOnInit() { ngOnInit() {
@ -165,52 +169,9 @@ export class AssetsInfoComponent implements OnInit {
data => { data => {
if (data) { if (data) {
if (data.dataStatus) { if (data.dataStatus) {
this.formLoadData(data.records1) this.formLoadData(data.records);
} else { } else {
let data = this.formLoadData(null);
{
"records1":{
"pdid":"60",
"formid":"4",
"assets_details":[
{
"assets_mode":"1",
"details":[
{
"property_type":"1"
}
],
"approximate_market_value":"12000",
"name_of_the_owner":"xyz",
"year_of_purchase":"2010",
"emi":0,
"emi_paid":"",
"elapsed_tenure":"",
"balance_tenure":""
},
{
"assets_mode":"7",
"details":[
{
"investments_type":"1",
"amount_of_invest":"200000",
"bank_name":"mmm bank"
}
],
"approximate_market_value":"123333",
"name_of_the_owner":"msnc",
"year_of_purchase":"2013",
"emi":1,
"emi_paid":"fasdf",
"elapsed_tenure":"sdfasd",
"balance_tenure":"sdfasdf"
}
],
"fk_createdby":"1"
}
}
this.formLoadData(data.records1)
// this.formLoadData(null);
} }
this.apiLoadFinish = true; this.apiLoadFinish = true;
} else { } else {
@ -240,6 +201,7 @@ export class AssetsInfoComponent implements OnInit {
]) ])
}); });
} }
this.loadDetails = true;
} }
// convenience getter for easy access to form fields // convenience getter for easy access to form fields
@ -425,7 +387,7 @@ export class AssetsInfoComponent implements OnInit {
approximate_market_value: [data.approximate_market_value, Validators.compose([Validators.required])], approximate_market_value: [data.approximate_market_value, Validators.compose([Validators.required])],
name_of_the_owner: [data.name_of_the_owner, Validators.compose([Validators.required])], name_of_the_owner: [data.name_of_the_owner, Validators.compose([Validators.required])],
year_of_purchase: [data.year_of_purchase, Validators.compose([Validators.required])], year_of_purchase: [data.year_of_purchase, Validators.compose([Validators.required])],
emi: [data.year_of_purchase], emi: [data.emi || 0],
emi_paid: [data.emi_paid || ''], emi_paid: [data.emi_paid || ''],
elapsed_tenure: [data.elapsed_tenure || ''], elapsed_tenure: [data.elapsed_tenure || ''],
balance_tenure: [data.balance_tenure || ''] balance_tenure: [data.balance_tenure || '']
@ -442,7 +404,11 @@ loadDetails: boolean;
assets_mode: val.assets_mode, assets_mode: val.assets_mode,
approximate_market_value: val.approximate_market_value, approximate_market_value: val.approximate_market_value,
name_of_the_owner: val.name_of_the_owner, name_of_the_owner: val.name_of_the_owner,
year_of_purchase: val.year_of_purchase year_of_purchase: val.year_of_purchase,
emi: val.emi,
emi_paid: val.emi_paid,
elapsed_tenure: val.elapsed_tenure,
balance_tenure: val.balance_tenure
}; };
const control = <FormArray>this._assetsQuesFrom.controls['assets_details']; const control = <FormArray>this._assetsQuesFrom.controls['assets_details'];
control.push(this.initDetailsWithdata(vals)); control.push(this.initDetailsWithdata(vals));
@ -457,7 +423,8 @@ this.loadDetails = true;
// var data = Object.keys(datas).map(function (key) { // var data = Object.keys(datas).map(function (key) {
// return datas[key]; // return datas[key];
// }); // });
let data= datas[0]; // alert(JSON.stringify(datas));
let data = datas;
const arr = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray; const arr = (<FormArray>this._assetsQuesFrom.controls['assets_details']).at(val).get('details') as FormArray;
arr.controls.splice(0); arr.controls.splice(0);
switch (assets_details_mode) { switch (assets_details_mode) {
@ -533,29 +500,35 @@ this.loadDetails = true;
this.submitted = true; this.submitted = true;
// stop here if form is invalid // stop here if form is invalid
if (this._assetsQuesFrom.invalid) { if (this._assetsQuesFrom.invalid) {
alert()
return; return;
} else { } else {
var answerFormValues = this._assetsQuesFrom.value; var answerFormValues = this._assetsQuesFrom.value;
//To Remove The "Null" With Key also //To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]); Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
alert(JSON.stringify(answerFormValues)); answerFormValues.assets_details.map(val => {
if (val.emi == '0') {
val.emi_paid = '';
val.elapsed_tenure = '';
val.balance_tenure = '';
}
});
// Add BRANCH data with help Service File // Add BRANCH data with help Service File
this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe( this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if (dataresult.status == 200) {
// console.log(dataresult); // console.log(dataresult);
// this.notifier.notify('success', 'Record Saved Successfully.!'); this.notifier.notify('success', 'Record Saved Successfully.!');
// this.dialogRef.close(); // this.dialogRef.close();
// alert("sample alert for Saving"); // alert("sample alert for Saving");
} }
else { else {
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
// this.errorMessage = "Some Thing Wents Wrong Try Again !"; // this.errorMessage = "Some Thing Wents Wrong Try Again !";
} }
}, error => { }, error => {
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!'); this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
// this.errorMessage = "Something Wents Wrong Try Again !"; // this.errorMessage = "Something Wents Wrong Try Again !";
// this.dialogRef.close(); // this.dialogRef.close();
}); });
@ -566,9 +539,10 @@ this.loadDetails = true;
/** To Reset Popup Data */ /** To Reset Popup Data */
onReset() { onReset() {
// this._addQuesFrom.reset(); const arr = <FormArray>this._assetsQuesFrom.controls.assets_details;
arr.controls.splice(0);
this.getPdSupplierFormDetails();
} }
// { // {
// 'main_raw_materials': 'sdkjfal', // 'main_raw_materials': 'sdkjfal',
// 'supplier_details' ; [ // 'supplier_details' ; [
@ -579,5 +553,4 @@ this.loadDetails = true;
// } // }
// ] // ]
// } // }
} }

View File

@ -390,7 +390,11 @@
<ng-container *ngSwitchCase="3"> <ng-container *ngSwitchCase="3">
<app-personal-info [pdid]="startPD" [pd_all_details]="pdFullDetails"></app-personal-info> <app-personal-info [pdid]="startPD" [pd_all_details]="pdFullDetails"></app-personal-info>
</ng-container> </ng-container>
<!-- end personal type questions --> <ng-container *ngSwitchCase="4">
<app-assets-info [pdid]="startPD"></app-assets-info>
</ng-container>
<!-- end personal type questions
-->
</ng-container> </ng-container>
</div> </div>
<!-- end form based questions --> <!-- end form based questions -->

View File

@ -203,7 +203,7 @@ getPDFormDetailsWithID(pdID, formID ):Observable<any> {
// saveData[0].fk_updatedby = this._aws.getlocale(); // saveData[0].fk_updatedby = this._aws.getlocale();
// saveData[0].updatedon = currentdate; // saveData[0].updatedon = currentdate;
return this._http.post<any>(this.apiUrl+"savePDFormDetails",{"records1":saveData}) return this._http.post<any>(this.apiUrl+"savePDFormDetails",{"records":saveData})
.pipe( .pipe(
catchError(this.handleError('operation', [])) catchError(this.handleError('operation', []))
) )