supplier form changes by : kms

This commit is contained in:
gandhimathi 2019-01-23 15:06:54 +05:30
parent 3c87df8853
commit 4beb721206
2 changed files with 168 additions and 59 deletions

View File

@ -16,30 +16,59 @@
<div *ngFor="let items of item.controls.main_raw_materials['controls']; let l=index" [formGroupName]="l">
<mat-card style="margin: 12px;">
<h6 style="margin: 12px;padding:10px !important;">Raw Material #{{l+1}}</h6>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 30%">
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 45%">
<input matInput placeholder="Raw Material Name" formControlName="manufacturing_raw_material_name">
</mat-form-field>
<mat-form-field style="width: 30%">
<mat-form-field style="width: 45%">
<input matInput placeholder="Supplier Name" formControlName="manufacturing_supplier_name">
</mat-form-field>
<mat-form-field style="width: 30%">
<input matInput placeholder="Contact Person Name" formControlName="manufacturing_contact_person_name">
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 30%">
<input matInput placeholder="Contact Person Mobile Number" formControlName="manufacturing_contact_person_mobile_number">
</mat-form-field>
<mat-form-field style="width: 30%">
<mat-select (selectionChange)="selectedPM($event)" placeholder="Payment Type" formControlName="manufacturing_payment_type">
<mat-option *ngFor="let pm of m_paymentModeType" [value]="pm.id">{{ pm.name }}</mat-option>
<div fxLayout="row nowrap">
<mat-form-field style="width: 15%">
<mat-select placeholder="Title" formControlName="person_title_name">
<mat-option *ngFor="let tl of titleList" [value]="tl.title_id">
{{tl.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 35%">
<input matInput placeholder="Contact Person Name" formControlName="manufacturing_contact_person_name" maxlength="10">
</mat-form-field>
<mat-form-field style="width: 35%">
<mat-select placeholder="Contact Person Designation" formControlName="person_designation">
<mat-option>Select</mat-option>
<mat-option *ngFor="let comrelShip of companyRelationShipList" [value]="comrelShip.company_relationship_id">
{{comrelShip.name}}
</mat-option>
<mat-option value="1" > Not Applicable </mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 30%" *ngIf="items.get('manufacturing_payment_type').value == 3">
<input matInput placeholder="Number of days of credit provided" formControlName="manufacturing_credit_days">
</mat-form-field>
</div>
</div>
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 35%">
<input matInput placeholder="Contact Person Mobile Number" autocomplete="off" formControlName="manufacturing_contact_person_mobile_number" (keypress)="keyPress($event)" maxlength="10">
</mat-form-field>
<mat-form-field style="width: 15%">
<input matInput autocomplete="off" placeholder="STD Code" formControlName="person_stdcode" type="text" (keypress)="keyPress($event)">
</mat-form-field> &nbsp; - &nbsp;
<mat-form-field style="width: 35%">
<input matInput autocomplete="off" placeholder="Contact Person Landline Number" formControlName="person_landline" type="text" (keypress)="keyPress($event)">
</mat-form-field>
</div>
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 45%">
<mat-select (selectionChange)="selectedPM($event)" placeholder="Payment Type" formControlName="manufacturing_payment_type">
<mat-option *ngFor="let pm of m_paymentModeType" [value]="pm.id">{{ pm.name }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 45%" *ngIf="items.get('manufacturing_payment_type').value == 3">
<input matInput placeholder="No.of days of Credit provided by Supplier" formControlName="manufacturing_credit_days">
</mat-form-field>
</div>
<div align="end">
<span *ngIf="item.controls.main_raw_materials.controls.length > 1" (click)="removeRawMaterials(l)">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" color="primary" matTooltip="Delete" matTooltipPosition="above"><mat-icon>delete</mat-icon></button>
@ -49,14 +78,19 @@
</div>
</div>
<div>
<mat-form-field style="width: 100%">
<input matInput placeholder="What % of total purchase is done on Credit?" formControlName="main_raw_materials_total_payments_percent_on_credit"
type="text" (keypress)="keyPress($event)" maxlength="3">
</mat-form-field>
<div fxFlex="100" align="end">
<button mat-raised-button mat-icon-button mat-button color="primary" matTooltip="Add More Supplier Details" matTooltipPosition="above"
class="mr-1 mb-1 hover-icon" (click)="addMoreRawMaterials($event); false"><mat-icon>add</mat-icon></button>
<div fxLayout="row">
<div fxFlex="100" align="center">
<button color="primary" mat-flat-button matTooltip="Add More" matTooltipPosition="above" type="button"
class="mr-1 mb-1 hover-icon" (click)="addMoreRawMaterials($event); false"><strong>Add More Supplier</strong></button>
</div>
</div>
<div fxLayout="row">
<mat-form-field style="width: 100%">
<input matInput placeholder="What % of Total Purchase is Done on Credit?" formControlName="main_raw_materials_total_payments_percent_on_credit"
type="number" autocomplete="off" (keypress)="keyPress($event)" maxlength="3">
</mat-form-field>
</div>
</div>
</div>
</div>
@ -69,28 +103,55 @@
<div *ngFor="let items of item.controls.trading_products['controls']; let l=index" [formGroupName]="l">
<mat-card style="margin: 12px;">
<h6 style="margin: 12px;padding:10px !important;">Trading Product #{{l+1}}</h6>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 30%">
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 45%">
<input matInput placeholder="Trade Product Name" formControlName="trade_product_name">
</mat-form-field>
<mat-form-field style="width: 30%">
<mat-form-field style="width: 45%">
<input matInput placeholder="Supplier Name" formControlName="trade_supplier_name">
</mat-form-field>
<mat-form-field style="width: 30%">
</div>
<div fxLayout="row nowrap">
<mat-form-field style="width: 15%">
<mat-select placeholder="Title" formControlName="person_title_name">
<mat-option *ngFor="let tl of titleList" [value]="tl.title_id">
{{tl.name}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 35%">
<input matInput placeholder="Contact Person Name" formControlName="trade_product_contact_person_name" maxlength="10">
</mat-form-field>
<mat-form-field style="width: 35%">
<mat-select placeholder="Contact Person Designation" formControlName="person_designation">
<mat-option>Select</mat-option>
<mat-option *ngFor="let comrelShip of companyRelationShipList" [value]="comrelShip.company_relationship_id">
{{comrelShip.name}}
</mat-option>
<mat-option value="1" > Not Applicable </mat-option>
</mat-select>
</mat-form-field>
</div>
<div fxLayout="row wrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 30%">
<input matInput placeholder="Contact Person Mobile Number" formControlName="trade_product_contact_person_mobile_number" (keypress)="keyPress($event)">
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 35%">
<input matInput placeholder="Contact Person Mobile Number" autocomplete="off" formControlName="trade_product_contact_person_mobile_number" (keypress)="keyPress($event)" maxlength="10">
</mat-form-field>
<mat-form-field style="width: 30%">
<mat-form-field style="width: 15%">
<input matInput autocomplete="off" placeholder="STD Code" formControlName="person_stdcode" type="text" (keypress)="keyPress($event)">
</mat-form-field> &nbsp; - &nbsp;
<mat-form-field style="width: 35%">
<input matInput autocomplete="off" placeholder="Contact Person Landline Number" formControlName="person_landline" type="text" (keypress)="keyPress($event)">
</mat-form-field>
</div>
<div fxLayout="row nowrap" fxLayoutGap="2px" fxLayoutAlign="start none">
<mat-form-field style="width: 45%">
<mat-select (selectionChange)="selectedPM($event)" placeholder="Payment Type" formControlName="trade_product_payment_type">
<mat-option *ngFor="let pm of m_paymentModeType" [value]="pm.id">{{ pm.name }}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field style="width: 30%" *ngIf="items.get('trade_product_payment_type').value == 3">
<input matInput placeholder="Number of days of credit provided" formControlName="trade_product_credit_days">
<mat-form-field style="width: 45%" *ngIf="items.get('trade_product_payment_type').value == 3">
<input matInput placeholder="No.of Days of Credit Provided by Supplier" autocomplete="off" formControlName="trade_product_credit_days" (keypress)="keyPress($event)">
</mat-form-field>
</div>
<div align="end">
@ -102,14 +163,19 @@
</div>
</div>
<div>
<mat-form-field style="width: 100%">
<input matInput placeholder="% of total trading product credit values" formControlName="trading_products_total_payments_percent_on_credit"
type="number">
</mat-form-field>
<div fxFlex="100" align="end">
<button mat-raised-button mat-icon-button mat-button color="primary" matTooltip="Add More Supplier Details" matTooltipPosition="above"
class="mr-1 mb-1 hover-icon" (click)="addMoretradeProduct($event); false"><mat-icon>add</mat-icon></button>
<div fxlayout="row">
<div fxFlex="100" align="center">
<button mat-flat-button color="primary" matTooltip="Add More" matTooltipPosition="above" type="button"
class="mr-1 mb-1 hover-icon" (click)="addMoretradeProduct($event); false"><strong>Add More Supplier</strong></button>
</div>
</div>
<div fxlayout="row">
<mat-form-field style="width: 90%">
<input matInput placeholder="% of total trading product credit values" formControlName="trading_products_total_payments_percent_on_credit"
type="number" autocomplete="off">
</mat-form-field>
</div>
</div>
</div>
</div>

View File

@ -43,16 +43,18 @@ export class SupplierInfoComponent implements OnInit {
public m_paymentModeType = [];
private notifier: NotifierService;
titleList: any=[];
companyRelationShipList: any=[];
constructor(
notifier: NotifierService,
private _formBuilder: FormBuilder,
private pdTrigerService: PdTrigerService,
@Inject(MAT_DIALOG_DATA) public pd_all_details: any) {
@Inject(MAT_DIALOG_DATA) public pd_all_details: any, private dialogRef: MatDialogRef<SupplierInfoComponent>) {
this.pdid = this.pd_all_details.pdmaster_details.pd_id;
this.form_id = 1;
this.company_id = this.pd_all_details.company_id
this.notifier = notifier;
}
public viewerOptions: any = {
navbar: false,
@ -112,6 +114,8 @@ export class SupplierInfoComponent implements OnInit {
// this.getM_FreqOfPurchase();
this.getM_PaymentModeType();
// this.getPdSupplierFormDetails();
this.getMasterDetails('COMPANYRELATIONSHIPS',1);
this.getMasterDetails('TITLES',2);
}
@ -136,7 +140,7 @@ export class SupplierInfoComponent implements OnInit {
supplier_info_form_remark: [dataForm.supplier_info_form_remark || null]
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
let arr = record.filter(data => data.type_of_activity_id == 1);
let arr = record.filter(data => data.type_of_activity_id == 2);
if(arr.length > 0) {
// let api_main_raw_materials = Object.keys(dataForm.main_raw_materials).map(function (key) {
// return dataForm.main_raw_materials[key];
@ -146,7 +150,7 @@ export class SupplierInfoComponent implements OnInit {
this.initManufacturingProductsDetails(api_main_raw_materials);
this._supplierQuesFrom.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(dataForm.manufacturing_details[0].main_raw_materials_total_payments_percent_on_credit || null);
}
let arr1 = record.filter(data => data.type_of_activity_id == 2 || 3);
let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id ==4);
if(arr1.length > 0) {
// let api_trading_products = Object.keys(dataForm.trading_products).map(function (key) {
// return dataForm.trading_products[key];
@ -166,19 +170,19 @@ export class SupplierInfoComponent implements OnInit {
supplier_info_form_remark: [dataForm.supplier_info_form_remark || null]
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
let arr = record.filter(data => data.type_of_activity_id == 1);
let arr = record.filter(data => data.type_of_activity_id == 2);
if(arr.length > 0) {
this.initManufacturingProductsDetails(null);
this._supplierQuesFrom.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null);
}
let arr1 = record.filter(data => data.type_of_activity_id == 2 || 3);
let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4);
if(arr1.length > 0) {
this.initTradingProductsDetails(null);
this._supplierQuesFrom.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(dataForm.trading_products_total_payments_percent_on_credit || null);
}
this.noRecordsFound = true;
}
let arr2 = record.filter(data => data.type_of_activity_id == 4);
let arr2 = record.filter(data => data.type_of_activity_id == 5);
if(arr2.length > 0) {
this.serviceProviderForm = true;
}
@ -186,22 +190,23 @@ export class SupplierInfoComponent implements OnInit {
this._supplierQuesFrom = this._formBuilder.group({
pdid: [this.pdid],
formid: ['1'],
company_id: [this.company_id],
manufacturing_details: this._formBuilder.array([this.manufacturingFormCreation(record)]),
trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
supplier_info_form_remark: []
// wholesale_trade_details: this._formBuilder.array([this.tradingFormCreation(record)]),
});
let arr = record.filter(data => data.type_of_activity_id == 1);
let arr = record.filter(data => data.type_of_activity_id == 2);
if(arr.length > 0) {
this.initManufacturingProductsDetails(null);
this._supplierQuesFrom.controls['manufacturing_details']['controls'][0].controls['main_raw_materials_total_payments_percent_on_credit'].setValue(null);
}
let arr1 = record.filter(data => data.type_of_activity_id == 2 || 3);
let arr1 = record.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id== 4);
if(arr1.length > 0) {
this.initTradingProductsDetails(null);
this._supplierQuesFrom.controls['trade_details']['controls'][0].controls['trading_products_total_payments_percent_on_credit'].setValue(null);
}
let arr2 = record.filter(data => data.type_of_activity_id == 4);
let arr2 = record.filter(data => data.type_of_activity_id == 5);
if(arr2.length > 0) {
this.serviceProviderForm = true;
}
@ -216,7 +221,7 @@ export class SupplierInfoComponent implements OnInit {
manufacturingForm: Boolean = false;
manufacturingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id == 1);
let arr = val.filter(data => data.type_of_activity_id == 2);
if (arr.length > 0) {
this.manufacturingForm = true;
return this._formBuilder.group({
@ -231,7 +236,7 @@ export class SupplierInfoComponent implements OnInit {
tradingForm: Boolean = false;
tradingFormCreation(val) {
let arr = val.filter(data => data.type_of_activity_id == 2 || 3);
let arr = val.filter(data => data.type_of_activity_id == 3 || data.type_of_activity_id == 4);
if (arr.length > 0) {
this.tradingForm = true;
return this._formBuilder.group({
@ -259,21 +264,30 @@ export class SupplierInfoComponent implements OnInit {
return this._formBuilder.group({
manufacturing_raw_material_name: [''],
manufacturing_supplier_name: [''],
person_title_name:[''],
person_designation:[''],
manufacturing_contact_person_name: [''],
manufacturing_contact_person_mobile_number: [''],
manufacturing_contact_person_mobile_number: ['',Validators.compose([Validators.minLength(10),Validators.maxLength(10)])],
manufacturing_payment_type: [''],
manufacturing_credit_days: [''],
manufacturing_frequency_of_purchase: [''],
person_stdcode:['', Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])],
person_landline:['', Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])],
})
} else {
return this._formBuilder.group({
manufacturing_raw_material_name: [records.manufacturing_raw_material_name || null],
manufacturing_supplier_name: [records.manufacturing_supplier_name || null],
person_title_name:[records.person_title_name || null],
person_designation:[records.person_title_name || null],
manufacturing_contact_person_name: [records.manufacturing_contact_person_name || null],
manufacturing_contact_person_mobile_number: [records.manufacturing_contact_person_mobile_number || null],
manufacturing_contact_person_mobile_number: [records.manufacturing_contact_person_mobile_number || null,Validators.compose([Validators.minLength(10),Validators.maxLength(10)])],
manufacturing_payment_type: [records.manufacturing_payment_type || null],
manufacturing_credit_days: [records.manufacturing_credit_days || null],
manufacturing_frequency_of_purchase: [records.manufacturing_frequency_of_purchase || null],
person_stdcode:[records.person_stdcode || null, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])],
person_landline:[records.person_landline || null, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])],
})
}
}
@ -294,8 +308,12 @@ export class SupplierInfoComponent implements OnInit {
return this._formBuilder.group({
trade_product_name: [''],
trade_supplier_name: [''],
person_title_name:[''],
person_designation:[],
trade_product_contact_person_name: [''],
trade_product_contact_person_mobile_number: [''],
trade_product_contact_person_mobile_number: ['',Validators.compose([Validators.minLength(10),Validators.maxLength(10)])],
person_stdcode:[null, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])],
person_landline:[null, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])],
trade_product_payment_type: [''],
trade_product_frequency_of_purchase: [''],
trade_product_credit_days: [''],
@ -303,9 +321,13 @@ export class SupplierInfoComponent implements OnInit {
} else {
return this._formBuilder.group({
trade_product_name: [records.trade_product_name],
person_title_name:[records.person_title_name],
person_designation:[records.person_designation],
trade_supplier_name: [records.trade_supplier_name],
trade_product_contact_person_name: [records.trade_product_contact_person_name],
trade_product_contact_person_mobile_number: [records.trade_product_contact_person_mobile_number],
trade_product_contact_person_mobile_number: [records.trade_product_contact_person_mobile_number, Validators.compose([Validators.minLength(10),Validators.maxLength(10)])],
person_stdcode:[records.person_stdcode, Validators.compose([Validators.minLength(3),Validators.maxLength(5),Validators.pattern('^[0-9]*$')])],
person_landline:[records.person_landline, Validators.compose([Validators.minLength(6),Validators.maxLength(8),Validators.pattern('^[0-9]*$')])],
trade_product_payment_type: [records.trade_product_payment_type],
trade_product_frequency_of_purchase: [records.trade_product_frequency_of_purchase],
trade_product_credit_days: [records.trade_product_credit_days],
@ -337,6 +359,25 @@ export class SupplierInfoComponent implements OnInit {
control.removeAt(inx);
}
// get all master details
getMasterDetails(table:string,type:number){
this.pdTrigerService.getAllMasterDatas(table).subscribe(
data => {
if (data.dataStatus) {
if(type==1){
this.companyRelationShipList=data.records.filter(item => item.name != 'Others');
}
if(type==2){
this.titleList=data.records.filter(val=>val.isactive==1);
}
}
}, error => this.errorMessage = <any> error);
}
// ==================
//getM_FreqOfPurchase() {
@ -377,15 +418,17 @@ export class SupplierInfoComponent implements OnInit {
//To Remove The "Null" With Key also
Object.keys(answerFormValues).forEach((key) => (answerFormValues[key] == null) && delete answerFormValues[key]);
console.log(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.notifier.notify('success', 'Saved Successfully.!');
// this.dialogRef.close();
// alert("sample alert for Saving");
setTimeout(() =>{
this.dialogRef.close();
},3000);
}
else {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');