supplier changes details : kdk
This commit is contained in:
parent
215de92b41
commit
1db3a58fa8
@ -1,3 +1,81 @@
|
|||||||
<p>
|
<!--<pre> {{ m_group | json}}</pre>-->
|
||||||
client-info works!
|
<mat-card style="padding: 12px;">
|
||||||
</p>
|
<form *ngIf="apiLoadFinish" [formGroup]="_supplierQuesFrom" (submit)="onSubmit()" novalidate>
|
||||||
|
<div fxLayout="row" fxLayoutAlign="start none">
|
||||||
|
<div formArrayName="supplier_details" fxFill>
|
||||||
|
<div *ngFor="let sup of _supplierQuesFrom.controls.supplier_details['controls']; let i=index">
|
||||||
|
<div [formGroupName]="i">
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="12px" fxLayoutAlign="start none">
|
||||||
|
<div>
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="Supplier Name" formControlName="supplier_name">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="Contact Person Name" formControlName="contact_person">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="Contact Mobile Number" formControlName="mobile_number">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div fxLayout="row wrap" fxLayoutGap="12px" fxLayoutAlign="start none">
|
||||||
|
<div>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-select (selectionChange)="selectedPM($event)" placeholder="Select Payment Mode" formControlName="payment_mode">
|
||||||
|
<mat-option *ngFor="let pm of m_paymentModeType" [value]="pm.id">{{ pm.name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="sup.get('payment_mode').value == 1 || sup.get('payment_mode').value == 3">
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="% of immediate / Advance Payment Purchase to Total Purchase?" formControlName="per_of_immediate_advance_payment">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="sup.get('payment_mode').value == 2 || sup.get('payment_mode').value == 3">
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="Credit Period" formControlName="credit_period">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div fxLayout="row" fxLayoutGap="12px" fxLayoutAlign="start none">
|
||||||
|
<div>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-select (selectionChange)="selectedFreqPurchase($event)" placeholder="Select Frequency of Purchase" formControlName="frequency_of_purchase">
|
||||||
|
<mat-option *ngFor="let feq of m_freqOfPurchase" [value]="feq.id">{{ feq.name }}</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="sup.get('frequency_of_purchase').value == 8">
|
||||||
|
<mat-form-field class="ml-xs example-full-width">
|
||||||
|
<input matInput placeholder="Others Details" formControlName="freq_purchase_others_text_value">
|
||||||
|
<!--<mat-error *ngIf="submitted && f.supplier_name.hasError('required')" class="mat-text-warn">You must Include Supplier Name.</mat-error>-->
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div fxFlex="20">
|
||||||
|
<span *ngIf="_supplierQuesFrom.controls.supplier_details.controls.length > 1" (click)="removeLanguage(i)">
|
||||||
|
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button mat-raised-button mat-icon-button mat-button color="primary" matTooltip="Add More Answer" matTooltipPosition="above"
|
||||||
|
class="mr-1 mb-1 hover-icon" (click)="addSupplierDetails($event); false"><mat-icon>add</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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="Save" matTooltipPosition="above" type="submit"><mat-icon>save</mat-icon></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</mat-card>
|
||||||
@ -1,5 +1,27 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
/** Common Imports */
|
||||||
|
import {
|
||||||
|
Component,
|
||||||
|
OnInit,
|
||||||
|
Inject,
|
||||||
|
Input
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
FormBuilder,
|
||||||
|
FormGroup,
|
||||||
|
Validators,
|
||||||
|
FormArray,
|
||||||
|
} from '@angular/forms';
|
||||||
|
|
||||||
|
import { NotifierService } from 'angular-notifier';
|
||||||
|
|
||||||
|
import {
|
||||||
|
MatDialog,
|
||||||
|
MatDialogRef,
|
||||||
|
MAT_DIALOG_DATA
|
||||||
|
} from '@angular/material';
|
||||||
|
/** Service */
|
||||||
|
import { PdTrigerService } from '../../../../../pd-service/pd-triger.service';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-client-info',
|
selector: 'app-client-info',
|
||||||
templateUrl: './client-info.component.html',
|
templateUrl: './client-info.component.html',
|
||||||
@ -7,9 +29,233 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class ClientInfoComponent implements OnInit {
|
export class ClientInfoComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
@Input() pdid: number;
|
||||||
|
|
||||||
|
public _supplierQuesFrom: FormGroup;
|
||||||
|
public submitted = false;
|
||||||
|
public m_paymentModeType= [
|
||||||
|
{
|
||||||
|
'id': "1",
|
||||||
|
'name': 'Immediate Or Advanced Payment'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "2",
|
||||||
|
'name': 'Credit'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "3",
|
||||||
|
'name': 'Combination of Both'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
public m_freqOfPurchase= [
|
||||||
|
{
|
||||||
|
'id': "1",
|
||||||
|
'name': 'Daily'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "2",
|
||||||
|
'name': 'Weekly'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "3",
|
||||||
|
'name': 'Monthly'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "4",
|
||||||
|
'name': 'Every 3 months'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "5",
|
||||||
|
'name': 'Half yearly'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "6",
|
||||||
|
'name': 'Yearly'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "7",
|
||||||
|
'name': 'As and when required'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'id': "8",
|
||||||
|
'name': 'Others'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _formBuilder: FormBuilder,
|
||||||
|
private pdTrigerService: PdTrigerService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
|
this.getPdSupplierFormDetails();
|
||||||
|
}
|
||||||
|
apiLoadFinish: boolean = false;
|
||||||
|
getPdSupplierFormDetails() {
|
||||||
|
this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '1').subscribe(
|
||||||
|
data => {
|
||||||
|
if (data) {
|
||||||
|
if(data.dataStatus){
|
||||||
|
this.formLoadData(data.records)
|
||||||
|
} else {
|
||||||
|
this.formLoadData(null)
|
||||||
|
}
|
||||||
|
this.apiLoadFinish = true;
|
||||||
|
} else {
|
||||||
|
// this.noRecordFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formLoadData(val) {
|
||||||
|
if(val !== null) {
|
||||||
|
let value = val;
|
||||||
|
this._supplierQuesFrom = this._formBuilder.group({
|
||||||
|
pdid: [this.pdid],
|
||||||
|
formid: ['1'],
|
||||||
|
main_raw_materials: [value.main_raw_materials, Validators.compose([Validators.required])],
|
||||||
|
supplier_details: this._formBuilder.array([
|
||||||
|
// this.initDetails(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
this.addSupplierDetailsWithData(value.supplier_details);
|
||||||
|
} else {
|
||||||
|
this._supplierQuesFrom = this._formBuilder.group({
|
||||||
|
pdid: [this.pdid],
|
||||||
|
formid: ['1'],
|
||||||
|
main_raw_materials: [null, Validators.compose([Validators.required])],
|
||||||
|
supplier_details: this._formBuilder.array([
|
||||||
|
this.initDetails(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convenience getter for easy access to form fields
|
||||||
|
get f() { return this._supplierQuesFrom.controls; }
|
||||||
|
|
||||||
|
// Dynamic Form field creation Functionality : START ===>
|
||||||
|
initDetails() {
|
||||||
|
return this._formBuilder.group({
|
||||||
|
supplier_name: ['', Validators.compose([Validators.required])],
|
||||||
|
contact_person: ['', Validators.compose([Validators.required])],
|
||||||
|
mobile_number: ['', Validators.compose([Validators.required])],
|
||||||
|
payment_mode: ['', Validators.compose([Validators.required])],
|
||||||
|
per_of_immediate_advance_payment:[''],
|
||||||
|
credit_period:[''],
|
||||||
|
frequency_of_purchase: ['', Validators.compose([Validators.required])],
|
||||||
|
freq_purchase_others_text_value: ['']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initDetailsWithdata(data) {
|
||||||
|
return this._formBuilder.group({
|
||||||
|
supplier_name: [data.supplier_name, Validators.compose([Validators.required])],
|
||||||
|
contact_person: [data.contact_person, Validators.compose([Validators.required])],
|
||||||
|
mobile_number: [data.mobile_number, Validators.compose([Validators.required])],
|
||||||
|
payment_mode: [data.payment_mode, Validators.compose([Validators.required])],
|
||||||
|
per_of_immediate_advance_payment:[data.per_of_immediate_advance_payment || ''],
|
||||||
|
credit_period:[data.credit_period || ''],
|
||||||
|
frequency_of_purchase: [data.frequency_of_purchase, Validators.compose([Validators.required])],
|
||||||
|
freq_purchase_others_text_value: [data.freq_purchase_others_text_value || '']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addSupplierDetailsWithData(supp_data) {
|
||||||
|
|
||||||
|
var result = Object.keys(supp_data).map(function(key) {
|
||||||
|
return supp_data[key];
|
||||||
|
});
|
||||||
|
if (result.length > 0) {
|
||||||
|
for (let val of result) {
|
||||||
|
let vals = {
|
||||||
|
supplier_name: val.supplier_name,
|
||||||
|
contact_person: val.contact_person,
|
||||||
|
mobile_number: val.mobile_number,
|
||||||
|
payment_mode: val.payment_mode,
|
||||||
|
per_of_immediate_advance_payment: val.per_of_immediate_advance_payment,
|
||||||
|
credit_period: val.credit_period,
|
||||||
|
frequency_of_purchase: val.frequency_of_purchase,
|
||||||
|
freq_purchase_others_text_value: val.freq_purchase_others_text_value
|
||||||
|
};
|
||||||
|
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
||||||
|
control.push(this.initDetailsWithdata(vals));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addSupplierDetails(e) {
|
||||||
|
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
||||||
|
control.push(this.initDetails());
|
||||||
|
}
|
||||||
|
removeLanguage(i: number) {
|
||||||
|
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
||||||
|
control.removeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public paymentModeTextBox: number;
|
||||||
|
selectedPM(e) {
|
||||||
|
this.paymentModeTextBox = e.value;
|
||||||
|
// this.f.supplier_details.controls.get('payment_mode_value');
|
||||||
|
}
|
||||||
|
|
||||||
|
public freqPurchaseTextBox: number;
|
||||||
|
selectedFreqPurchase(e){
|
||||||
|
this.freqPurchaseTextBox = e.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** To Save/Edited Popup Data */
|
||||||
|
onSubmit() {
|
||||||
|
this.submitted = true;
|
||||||
|
// stop here if form is invalid
|
||||||
|
if (this._supplierQuesFrom.invalid) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
var answerFormValues = this._supplierQuesFrom.value;
|
||||||
|
|
||||||
|
//To Remove The "Null" With Key also
|
||||||
|
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
|
||||||
|
alert(JSON.stringify(answerFormValues));
|
||||||
|
//Add BRANCH data with help Service File
|
||||||
|
this.pdTrigerService.savePDFormDetailsWithID(answerFormValues).subscribe(
|
||||||
|
dataresult => {
|
||||||
|
if (dataresult.status == 200) {
|
||||||
|
// console.log(dataresult);
|
||||||
|
// this.notifier.notify('success', 'Record Saved Successfully.!');
|
||||||
|
// this.dialogRef.close();
|
||||||
|
// alert("sample alert for Saving");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
// this.errorMessage = "Some Thing Wents Wrong Try Again !";
|
||||||
|
}
|
||||||
|
}, error => {
|
||||||
|
// this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
|
||||||
|
// this.errorMessage = "Something Wents Wrong Try Again !";
|
||||||
|
// this.dialogRef.close();
|
||||||
|
});
|
||||||
|
//After Saving the BRANCH data then popup close
|
||||||
|
// this.dialogRef.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** To Reset Popup Data */
|
||||||
|
onReset() {
|
||||||
|
// this._addQuesFrom.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
|
// 'main_raw_materials': 'sdkjfal',
|
||||||
|
// 'supplier_details' ; [
|
||||||
|
// {
|
||||||
|
// 'supplier_name':'ldskjfalks',
|
||||||
|
// 'payment_mode': '1',
|
||||||
|
// 'payment_mode_value':''
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<!--<pre> {{ m_group | json}}</pre>-->
|
<!--<pre> {{ m_group | json}}</pre>-->
|
||||||
<mat-card style="padding: 12px;">
|
<mat-card style="padding: 12px;">
|
||||||
<form [formGroup]="_supplierQuesFrom" (submit)="onSubmit()" novalidate>
|
<form *ngIf="apiLoadFinish" [formGroup]="_supplierQuesFrom" (submit)="onSubmit()" novalidate>
|
||||||
<div fxLayout="row" fxLayoutAlign="start none">
|
<div fxLayout="row" fxLayoutAlign="start none">
|
||||||
<div class="example-full-width">
|
<div class="example-full-width">
|
||||||
<mat-form-field fxFill>
|
<mat-form-field fxFill>
|
||||||
|
|||||||
@ -35,50 +35,50 @@ export class SupplierInfoComponent implements OnInit {
|
|||||||
public submitted = false;
|
public submitted = false;
|
||||||
public m_paymentModeType= [
|
public m_paymentModeType= [
|
||||||
{
|
{
|
||||||
'id': 1,
|
'id': "1",
|
||||||
'name': 'Immediate Or Advanced Payment'
|
'name': 'Immediate Or Advanced Payment'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 2,
|
'id': "2",
|
||||||
'name': 'Credit'
|
'name': 'Credit'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 3,
|
'id': "3",
|
||||||
'name': 'Combination of Both'
|
'name': 'Combination of Both'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
public m_freqOfPurchase= [
|
public m_freqOfPurchase= [
|
||||||
{
|
{
|
||||||
'id': 1,
|
'id': "1",
|
||||||
'name': 'Daily'
|
'name': 'Daily'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 2,
|
'id': "2",
|
||||||
'name': 'Weekly'
|
'name': 'Weekly'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 3,
|
'id': "3",
|
||||||
'name': 'Monthly'
|
'name': 'Monthly'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 4,
|
'id': "4",
|
||||||
'name': 'Every 3 months'
|
'name': 'Every 3 months'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 5,
|
'id': "5",
|
||||||
'name': 'Half yearly'
|
'name': 'Half yearly'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 6,
|
'id': "6",
|
||||||
'name': 'Yearly'
|
'name': 'Yearly'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 7,
|
'id': "7",
|
||||||
'name': 'As and when required'
|
'name': 'As and when required'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 8,
|
'id': "8",
|
||||||
'name': 'Others'
|
'name': 'Others'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -88,25 +88,20 @@ export class SupplierInfoComponent implements OnInit {
|
|||||||
private pdTrigerService: PdTrigerService) { }
|
private pdTrigerService: PdTrigerService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._supplierQuesFrom = this._formBuilder.group({
|
|
||||||
main_raw_materials: [null, Validators.compose([Validators.required])],
|
|
||||||
supplier_details: this._formBuilder.array([
|
|
||||||
this.initDetails(),
|
|
||||||
])
|
|
||||||
});
|
|
||||||
this.getPdSupplierFormDetails();
|
this.getPdSupplierFormDetails();
|
||||||
}
|
}
|
||||||
|
apiLoadFinish: boolean = false;
|
||||||
getPdSupplierFormDetails() {
|
getPdSupplierFormDetails() {
|
||||||
this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '1').subscribe(
|
this.pdTrigerService.getPDFormDetailsWithID(this.pdid, '1').subscribe(
|
||||||
data => {
|
data => {
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.records) {
|
if(data.dataStatus){
|
||||||
// this.noRecordFound = false;
|
this.formLoadData(data.records)
|
||||||
// this.entityBillingInfoRecord = data.records;
|
} else {
|
||||||
} else {
|
this.formLoadData(null)
|
||||||
// this.noRecordFound = true;
|
}
|
||||||
}
|
this.apiLoadFinish = true;
|
||||||
} else {
|
} else {
|
||||||
// this.noRecordFound = true;
|
// this.noRecordFound = true;
|
||||||
}
|
}
|
||||||
@ -114,6 +109,30 @@ export class SupplierInfoComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formLoadData(val) {
|
||||||
|
if(val !== null) {
|
||||||
|
let value = val;
|
||||||
|
this._supplierQuesFrom = this._formBuilder.group({
|
||||||
|
pdid: [this.pdid],
|
||||||
|
formid: ['1'],
|
||||||
|
main_raw_materials: [value.main_raw_materials, Validators.compose([Validators.required])],
|
||||||
|
supplier_details: this._formBuilder.array([
|
||||||
|
// this.initDetails(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
this.addSupplierDetailsWithData(value.supplier_details);
|
||||||
|
} else {
|
||||||
|
this._supplierQuesFrom = this._formBuilder.group({
|
||||||
|
pdid: [this.pdid],
|
||||||
|
formid: ['1'],
|
||||||
|
main_raw_materials: [null, Validators.compose([Validators.required])],
|
||||||
|
supplier_details: this._formBuilder.array([
|
||||||
|
this.initDetails(),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// convenience getter for easy access to form fields
|
// convenience getter for easy access to form fields
|
||||||
get f() { return this._supplierQuesFrom.controls; }
|
get f() { return this._supplierQuesFrom.controls; }
|
||||||
|
|
||||||
@ -131,6 +150,42 @@ export class SupplierInfoComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initDetailsWithdata(data) {
|
||||||
|
return this._formBuilder.group({
|
||||||
|
supplier_name: [data.supplier_name, Validators.compose([Validators.required])],
|
||||||
|
contact_person: [data.contact_person, Validators.compose([Validators.required])],
|
||||||
|
mobile_number: [data.mobile_number, Validators.compose([Validators.required])],
|
||||||
|
payment_mode: [data.payment_mode, Validators.compose([Validators.required])],
|
||||||
|
per_of_immediate_advance_payment:[data.per_of_immediate_advance_payment || ''],
|
||||||
|
credit_period:[data.credit_period || ''],
|
||||||
|
frequency_of_purchase: [data.frequency_of_purchase, Validators.compose([Validators.required])],
|
||||||
|
freq_purchase_others_text_value: [data.freq_purchase_others_text_value || '']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
addSupplierDetailsWithData(supp_data) {
|
||||||
|
|
||||||
|
var result = Object.keys(supp_data).map(function(key) {
|
||||||
|
return supp_data[key];
|
||||||
|
});
|
||||||
|
if (result.length > 0) {
|
||||||
|
for (let val of result) {
|
||||||
|
let vals = {
|
||||||
|
supplier_name: val.supplier_name,
|
||||||
|
contact_person: val.contact_person,
|
||||||
|
mobile_number: val.mobile_number,
|
||||||
|
payment_mode: val.payment_mode,
|
||||||
|
per_of_immediate_advance_payment: val.per_of_immediate_advance_payment,
|
||||||
|
credit_period: val.credit_period,
|
||||||
|
frequency_of_purchase: val.frequency_of_purchase,
|
||||||
|
freq_purchase_others_text_value: val.freq_purchase_others_text_value
|
||||||
|
};
|
||||||
|
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
||||||
|
control.push(this.initDetailsWithdata(vals));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addSupplierDetails(e) {
|
addSupplierDetails(e) {
|
||||||
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
const control = <FormArray>this._supplierQuesFrom.controls['supplier_details'];
|
||||||
control.push(this.initDetails());
|
control.push(this.initDetails());
|
||||||
@ -164,26 +219,26 @@ export class SupplierInfoComponent implements OnInit {
|
|||||||
//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));
|
alert(JSON.stringify(answerFormValues));
|
||||||
// //Add BRANCH data with help Service File
|
//Add BRANCH data with help Service File
|
||||||
// this.questionsService.addQuestionMasterDetails(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();
|
||||||
// });
|
});
|
||||||
// //After Saving the BRANCH data then popup close
|
//After Saving the BRANCH data then popup close
|
||||||
// // this.dialogRef.close();
|
// this.dialogRef.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -383,7 +383,7 @@
|
|||||||
|
|
||||||
<!-- start client type questions -->
|
<!-- start client type questions -->
|
||||||
<ng-container *ngSwitchCase="2">
|
<ng-container *ngSwitchCase="2">
|
||||||
<p>client</p>
|
<app-client-info [pdid]="startPD"></app-client-info>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<!-- end client type questions -->
|
<!-- end client type questions -->
|
||||||
|
|
||||||
|
|||||||
@ -191,7 +191,7 @@ export class PdTrigerService {
|
|||||||
|
|
||||||
// common Pd form details get for the Pd Process
|
// common Pd form details get for the Pd Process
|
||||||
getPDFormDetailsWithID(pdID, formID ):Observable<any> {
|
getPDFormDetailsWithID(pdID, formID ):Observable<any> {
|
||||||
return this._http.post<any>(this.apiUrl+"getPDFormDetails",{"pdid":pdID,"pd_form_id" : formID})
|
return this._http.post<any>(this.apiUrl+"getPDFormDetails",{"pd_id":pdID,"pd_form_id" : formID})
|
||||||
.pipe(
|
.pipe(
|
||||||
catchError(this.handleError('operation', []))
|
catchError(this.handleError('operation', []))
|
||||||
)
|
)
|
||||||
@ -200,7 +200,6 @@ getPDFormDetailsWithID(pdID, formID ):Observable<any> {
|
|||||||
// save Pd form details
|
// save Pd form details
|
||||||
savePDFormDetailsWithID(saveData: any): Observable<any> {
|
savePDFormDetailsWithID(saveData: any): Observable<any> {
|
||||||
saveData.fk_createdby = this._aws.getlocale();
|
saveData.fk_createdby = this._aws.getlocale();
|
||||||
saveData.fk_createdon = currentdate;
|
|
||||||
// saveData[0].fk_updatedby = this._aws.getlocale();
|
// saveData[0].fk_updatedby = this._aws.getlocale();
|
||||||
// saveData[0].updatedon = currentdate;
|
// saveData[0].updatedon = currentdate;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user