This commit is contained in:
saravanakumarkandasami 2018-10-23 18:11:45 +05:30
commit 2bbce82f42
6 changed files with 2205 additions and 1945 deletions

File diff suppressed because it is too large Load Diff

View File

@ -36,15 +36,14 @@
<mat-error *ngIf="!_pdTeamForm.controls['fk_city'].valid && _pdTeamForm.controls['fk_city'].touched" class="mat-text-warn">City Name Requried.</mat-error> <mat-error *ngIf="!_pdTeamForm.controls['fk_city'].valid && _pdTeamForm.controls['fk_city'].touched" class="mat-text-warn">City Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedCityDatas.length != 0"> The Selected Cities are., </h6>
<ul *ngFor="let data of selectedCityDatas"> <ul *ngFor="let data of selectedCityDatas">
<h6> The Selected Cities are., </h6> <!-- <h6> The Selected Cities are., </h6> -->
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>
</div> </div>
<h6>Products</h6> <hr> <br> <h6>Products</h6> <hr> <br>
@ -57,9 +56,9 @@
<mat-error *ngIf="!_pdTeamForm.controls['fk_product'].valid && _pdTeamForm.controls['fk_product'].touched" class="mat-text-warn">Product Name Requried.</mat-error> <mat-error *ngIf="!_pdTeamForm.controls['fk_product'].valid && _pdTeamForm.controls['fk_product'].touched" class="mat-text-warn">Product Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedProductDatas.length != 0"> The Selected Products are., </h6>
<ul *ngFor="let data of selectedProductDatas"> <ul *ngFor="let data of selectedProductDatas">
<h6> The Selected Products are., </h6> <!-- <h6> The Selected Products are., </h6> -->
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>
@ -77,9 +76,9 @@
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedSegmentDatas.length != 0"> The Selected Customer segment are., </h6>
<ul *ngFor="let data of selectedSegmentDatas"> <ul *ngFor="let data of selectedSegmentDatas">
<h6> The Selected Customer segment are., </h6> <!-- <h6> The Selected Customer segment are., </h6> -->
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>

View File

@ -36,8 +36,9 @@ customerSegmentdatas: any[];
//This Type Of Array Declaration //This Type Of Array Declaration
pdTeamCityArray:any= []; pdTeamCityArray:any= [];
pdTeamProductArray: Array<{teamid: number, productid: number}> = []; CityValidation:any= [];
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = []; //pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
//pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
//This Type Of Array Declaration for Local Purpose and List the data in html page //This Type Of Array Declaration for Local Purpose and List the data in html page
selectedCityDatas : any=[]; selectedCityDatas : any=[];
@ -71,7 +72,7 @@ this._pdTeamService.getAllPdTeamCityMapping()
/** To Display The City Data For City DropDown */ /** To Display The City Data For City DropDown */
this._masterService.getAllMasterData('CITY').subscribe( this._masterService.getAllMasterData('CITY').subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if(dataresult.dataStatus == true){
this.citydatas = dataresult.records; this.citydatas = dataresult.records;
this.citydatas = this.citydatas.filter(city=>city.isactive == 1 ); this.citydatas = this.citydatas.filter(city=>city.isactive == 1 );
} }
@ -81,7 +82,7 @@ this._masterService.getAllMasterData('CITY').subscribe(
/** To Display The Entities Data For Entities DropDown */ /** To Display The Entities Data For Entities DropDown */
this._masterService.getAllMasterData('ENTITY').subscribe( this._masterService.getAllMasterData('ENTITY').subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if(dataresult.dataStatus == true){
this.lenderdatas = dataresult.records; this.lenderdatas = dataresult.records;
this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 ); this.lenderdatas = this.lenderdatas.filter(entity=>entity.isactive == 1 );
} }
@ -90,7 +91,7 @@ this._masterService.getAllMasterData('ENTITY').subscribe(
/** To Display The Entities Data For Entities DropDown */ /** To Display The Entities Data For Entities DropDown */
this._masterService.getAllMasterData('PRODUCTS').subscribe( this._masterService.getAllMasterData('PRODUCTS').subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if(dataresult.dataStatus == true) {
this.productdatas = dataresult.records; this.productdatas = dataresult.records;
this.productdatas = this.productdatas.filter(product=>product.isactive == 1 ); this.productdatas = this.productdatas.filter(product=>product.isactive == 1 );
} }
@ -99,7 +100,7 @@ this._masterService.getAllMasterData('PRODUCTS').subscribe(
/** To Display The Entities Data For Entities DropDown */ /** To Display The Entities Data For Entities DropDown */
this._masterService.getAllMasterData('CUSTOMERSEGMENT').subscribe( this._masterService.getAllMasterData('CUSTOMERSEGMENT').subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if(dataresult.dataStatus == true) {
this.customerSegmentdatas = dataresult.records; this.customerSegmentdatas = dataresult.records;
this.customerSegmentdatas = this.customerSegmentdatas.filter(segment=>segment.isactive == 1 ); this.customerSegmentdatas = this.customerSegmentdatas.filter(segment=>segment.isactive == 1 );
} }
@ -144,7 +145,7 @@ onSubmit() {
this._pdTeamService.addPdTeamDetail(this._pdTeamForm.value).subscribe( this._pdTeamService.addPdTeamDetail(this._pdTeamForm.value).subscribe(
dataresult => { dataresult => {
if (dataresult.status == 200) { if(dataresult.dataStatus == true) {
//this.notifier.notify('success', 'Record Saved Successfully.!'); //this.notifier.notify('success', 'Record Saved Successfully.!');
Swal('Record Saved Successfully.!','success'); Swal('Record Saved Successfully.!','success');
this._pdTeamForm.reset(); this._pdTeamForm.reset();
@ -176,41 +177,84 @@ onChangeCustomerSegmentDatas($event){
} }
/**on change function for City to display the as List in html page */ /**on change function for City to display the as List in html page */
onChangeCityDatas($event){ // onChangeCityDatas($event){
var mycheck = 0 ; // var mycheck = 0 ;
//let cityName = $event.source.value; // //let cityName = $event.source.value;
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0]; // let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];
if($event.source._selected === true ){ // if($event.source._selected === true ){
for(let Duplication_City of this.pdTeamCityArray){ // for(let Duplication_City of this.pdTeamCityArray){
let teamname = Duplication_City.team_name; // let teamname = Duplication_City.team_name;
let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value); // let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value);
if(dup_cityname != ''){ // if(dup_cityname != ''){
for(let data of dup_cityname){ // for(let data of dup_cityname){
if(data.name == cityName.name){ // if(data.name == cityName.name){
alert('"'+data.name+'" Already Existing with "'+ teamname +'"'); // alert('"'+data.name+'" Already Existing with "'+ teamname +'"');
$event.source._selected = false; // $event.source._selected = false;
mycheck++; // mycheck++;
} // }
} // }
} // }
} // }
if(mycheck == 0){ // if(mycheck == 0){
this.selectedCityDatas.push(cityName.name); // this.selectedCityDatas.push(cityName.name);
} // }
// }
// else if($event.source._selected === false ){
// let index = this.selectedCityDatas.indexOf(cityName.name);
// this.selectedCityDatas.splice(index,1);
// }
// }
onChangeCityDatas($event){
var mycheck = 0 ;
let lenderId = this._pdTeamForm.value['fk_lender'];
if(lenderId != null){
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];//city array
// console.log(cityName);
// console.log($event.source.value);
if($event.source._selected === true ){
this._pdTeamService.getLenderData(lenderId).subscribe(
dataresult => {
if(dataresult.dataStatus == true) {
this.CityValidation = dataresult.records;
}
}, error => this.errorMessage = <any> error);
if(this.CityValidation != ''){
for(let data of this.CityValidation){
if(data['fk_city_id'] == $event.source.value){
Swal('<h5>"'+data['city_name']+'" already existing with "'+ data['team_name'] +'"</h5>');
$event.source._selected = false;
mycheck = 1;
}
}
}
if(mycheck == 0){
this.selectedCityDatas.push(cityName.name);
}
} }
else if($event.source._selected === false ){ else if($event.source._selected === false ){
$event.source._selected = false;
let index = this.selectedCityDatas.indexOf(cityName.name); let index = this.selectedCityDatas.indexOf(cityName.name);
this.selectedCityDatas.splice(index,1); this.selectedCityDatas.splice(index,1);
} }
}
else{
Swal('Pick Up The Lender Name');
$event.source._selected = false;
}
} }
/**on change function for Product to display the data as List in html page */ /**on change function for Product to display the data as List in html page */

View File

@ -5,7 +5,8 @@
<h2 mat-dialog-title style="width: 50%;">PD TEAM</h2> <h2 mat-dialog-title style="width: 50%;">PD TEAM</h2>
<div style="width: 20%;"></div> <div style="width: 20%;"></div>
<div style="width: 30%;text-align:right;"> <div style="width: 30%;text-align:right;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button> <!-- <button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" (click)="onNoClick()"><mat-icon>close</mat-icon></button> -->
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div> </div>
</div> </div>
@ -13,14 +14,16 @@
<div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start"> <div fxLayout="row wrap" fxLayoutGap="32px" fxLayoutAlign="flex-start">
<mat-form-field fxFlex="0 1 auto" class="ml-xs"> <mat-form-field fxFlex="0 1 auto" class="ml-xs">
<input matInput type="text" placeholder="Team Name" required formControlName="team_name"> <input matInput type="text" placeholder="Team Name" required formControlName="team_name">
<mat-error *ngIf="submitted && f.team_name.hasError('required')" class="mat-text-warn">You must Include Team Name.</mat-error> <!-- <mat-error *ngIf="submitted && f.team_name.hasError('required')" class="mat-text-warn">You must Include Team Name.</mat-error> -->
<mat-error *ngIf="!_pdTeamForm.controls['team_name'].valid && _pdTeamForm.controls['team_name'].touched" class="mat-text-warn">Team Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field fxFlex="0 1 auto" class="ml-xs"> <mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="Lender" required formControlName="fk_lender"> <mat-select placeholder="Lender" required formControlName="fk_lender">
<mat-option *ngFor="let ld of lenderdatas" [value]="ld.entity_id" >{{ ld.short_name }} {{ ld.full_name }} </mat-option> <mat-option *ngFor="let ld of lenderdatas" [value]="ld.entity_id" >{{ ld.short_name }} {{ ld.full_name }} </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="submitted && f.fk_lender.hasError('required')" class="mat-text-warn">You must Select Lender Name.</mat-error> <!-- <mat-error *ngIf="submitted && f.fk_lender.hasError('required')" class="mat-text-warn">You must Select Lender Name.</mat-error> -->
<mat-error *ngIf="!_pdTeamForm.controls['fk_lender'].valid && _pdTeamForm.controls['fk_lender'].touched" class="mat-text-warn">Lender Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -29,13 +32,15 @@
<mat-form-field fxFlex="0 1 auto" class="ml-xs"> <mat-form-field fxFlex="0 1 auto" class="ml-xs">
<mat-select placeholder="City" required formControlName="fk_city" multiple> <mat-select placeholder="City" required formControlName="fk_city" multiple>
<mat-option *ngFor="let cd of citydatas " [value]="cd.city_id" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option> <mat-option *ngFor="let cd of citydatas " [value]="cd.city_id" (onSelectionChange)="onChangeCityDatas($event)" >{{ cd.name }} </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error> <!-- <mat-error *ngIf="submitted && f.fk_city.hasError('required')" class="mat-text-warn">You must Select Cities.</mat-error> -->
<mat-error *ngIf="!_pdTeamForm.controls['fk_city'].valid && _pdTeamForm.controls['fk_city'].touched" class="mat-text-warn">City Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedCityDatas.length != 0"> The Selected Cities are., </h6>
<ul *ngFor="let data of selectedCityDatas"> <ul *ngFor="let data of selectedCityDatas">
<h6> The Selected Cities are., </h6>
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>
@ -50,12 +55,13 @@
<mat-select placeholder="Product" required formControlName="fk_product" multiple> <mat-select placeholder="Product" required formControlName="fk_product" multiple>
<mat-option *ngFor="let pd of productdatas " [value]="pd.product_id" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option> <mat-option *ngFor="let pd of productdatas " [value]="pd.product_id" (onSelectionChange)="onChangeProductDatas($event)" >{{ pd.name }} </mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error> <!-- <mat-error *ngIf="submitted && f.fk_product.hasError('required')" class="mat-text-warn">You must Select Product.</mat-error> -->
<mat-error *ngIf="!_pdTeamForm.controls['fk_product'].valid && _pdTeamForm.controls['fk_product'].touched" class="mat-text-warn">Product Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedProductDatas.length != 0"> The Selected Products are., </h6>
<ul *ngFor="let data of selectedProductDatas"> <ul *ngFor="let data of selectedProductDatas">
<h6> The Selected Products are., </h6>
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>
@ -68,12 +74,13 @@
<mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple> <mat-select placeholder="Customer Segment" required formControlName="fk_customer_segment" multiple>
<mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd.customer_segment_id" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option> <mat-option *ngFor="let csd of customerSegmentdatas" [value]="csd.customer_segment_id" (onSelectionChange)="onChangeCustomerSegmentDatas($event)">{{csd.name}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error> <!-- <mat-error *ngIf="submitted && f.fk_customer_segment.hasError('required')" class="mat-text-warn">You must Select Customer Segment.</mat-error> -->
<mat-error *ngIf="!_pdTeamForm.controls['fk_customer_segment'].valid && _pdTeamForm.controls['fk_customer_segment'].touched" class="mat-text-warn">CustomerSegment Name Requried.</mat-error>
</mat-form-field> </mat-form-field>
<span fxFlex="0 1 auto" class="ml-xs"> <span fxFlex="0 1 auto" class="ml-xs">
<h6 *ngIf="selectedSegmentDatas.length != 0"> The Selected Customer segment are., </h6>
<ul *ngFor="let data of selectedSegmentDatas"> <ul *ngFor="let data of selectedSegmentDatas">
<h6> The Selected Customer segment are., </h6>
<li>{{data}}</li> <li>{{data}}</li>
</ul> </ul>
</span> </span>
@ -82,7 +89,8 @@
<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" 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" type="button" (click)="onResetForEdit($event)" ><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" type="button" (click)="onResetForEdit($event)" ><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> -->
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Save" matTooltipPosition="above" type="submit" [disabled]="!_pdTeamForm.valid"><mat-icon>save</mat-icon></button>
</div> </div>
</mat-card> </mat-card>
</form> </form>

View File

@ -1,16 +1,12 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { FormBuilder, import { FormBuilder,
FormGroup, FormGroup,
Validators, Validators,
FormControl } from '@angular/forms'; FormControl } from '@angular/forms';
/** Service */ /** Service */
import { MastersService } from '../../service/masters/masters.service'; import { MastersService } from '../../service/masters/masters.service';
import { PdTeamService } from '../../service/masters/pd-team.service'; import { PdTeamService } from '../../service/masters/pd-team.service';
import { NotifierService } from 'angular-notifier'; import { NotifierService } from 'angular-notifier';
/** Here this component is like as a partent component */ /** Here this component is like as a partent component */
import { PdTeamListComponent } from './../pd-team-list/pd-team-list.component'; import { PdTeamListComponent } from './../pd-team-list/pd-team-list.component';
/**sweet alert */ /**sweet alert */
@ -25,6 +21,7 @@ export class PdTeamEditComponent implements OnInit {
public _pdTeamForm: FormGroup; public _pdTeamForm: FormGroup;
public submitted = false; public submitted = false;
public listView: any = true;
private notifier: NotifierService; private notifier: NotifierService;
color = 'primary'; color = 'primary';
errorMessage:string; errorMessage:string;
@ -40,9 +37,15 @@ export class PdTeamEditComponent implements OnInit {
//This Type Of Array Declaration for Validation //This Type Of Array Declaration for Validation
pdTeamCityArray:any= []; pdTeamCityArray:any= [];
pdTeamProductArray: Array<{teamid: number, productid: number}> = []; CityValidation:any= [];
pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = []; //pdTeamProductArray: Array<{teamid: number, productid: number}> = [];
//pdTeamCustomerSegmentArray: Array<{teamid: number, customerid: number}> = [];
//This Type Of Array Declaration to Check the Existing Data
DBCityDatas:any=[];
DBProductDatas:any=[];
DBCustomerSegmentDatas:any=[];
//This Type Of Array Declaration for Local Purpose and List the data in html page //This Type Of Array Declaration for Local Purpose and List the data in html page
selectedCityDatas : any=[]; selectedCityDatas : any=[];
selectedProductDatas : any=[]; selectedProductDatas : any=[];
@ -133,22 +136,42 @@ export class PdTeamEditComponent implements OnInit {
} }
let PdTeamProduct:any = []; let PdTeamProduct:any = [];
for(let ptp of this.childMessage[0].PRODUCTS){ // for(let ptp of this.childMessage[0].PRODUCTS){
PdTeamProduct.push(ptp.product_id); // PdTeamProduct.push(ptp.product_id);
} // }
this._pdTeamService.getProductData(this.childMessage[0].pdteam_id).subscribe(
dataresult => {
if (dataresult.dataStatus == true) {
for(let ptp of dataresult.records){
this.DBProductDatas.push(ptp.fk_product_id);
this.selectedProductDatas.push(ptp.name);
this._pdTeamForm.controls['fk_product'].setValue(this.DBProductDatas);
}
}
}, error => this.errorMessage = <any> error);
let PdTeamCS:any = []; let PdTeamCS:any = [];
for(let ptcs of this.childMessage[0].CUSTOMERSEGMENT){ // for(let ptcs of this.childMessage[0].CUSTOMERSEGMENT){
PdTeamCS.push(ptcs.customer_segment_id); // PdTeamCS.push(ptcs.customer_segment_id);
} // }
this._pdTeamService.getCustomerSegmentData(this.childMessage[0].pdteam_id).subscribe(
dataresult => {
if (dataresult.dataStatus == true) {
for(let ptcs of dataresult.records){
this.DBCustomerSegmentDatas.push(ptcs.customer_segment_id);
this.selectedSegmentDatas.push(ptcs.name);
this._pdTeamForm.controls['fk_customer_segment'].setValue(this.DBCustomerSegmentDatas);
}
}
}, error => this.errorMessage = <any> error);
this._pdTeamForm = this._formBuilder.group({ this._pdTeamForm = this._formBuilder.group({
pdteam_id: [this.childMessage[0].pdteam_id, Validators.compose([Validators.required])], pdteam_id: [this.childMessage[0].pdteam_id, Validators.compose([Validators.required])],
team_name: [this.childMessage[0].team_name, Validators.compose([Validators.required])], team_name: [this.childMessage[0].team_name, Validators.compose([Validators.required])],
fk_lender: [this.childMessage[0].fk_lender_id, Validators.compose([Validators.required])], fk_lender: [this.childMessage[0].fk_lender_id, Validators.compose([Validators.required])],
fk_city: [PdTeamCity, Validators.compose([Validators.required])], fk_city: [PdTeamCity, Validators.compose([Validators.required])],
fk_customer_segment: [PdTeamCS, Validators.compose([Validators.required])], fk_customer_segment: [this.DBCustomerSegmentDatas, Validators.compose([Validators.required])],
fk_product:[PdTeamProduct, Validators.compose([Validators.required])], fk_product:[this.DBProductDatas, Validators.compose([Validators.required])],
}); });
@ -166,73 +189,189 @@ export class PdTeamEditComponent implements OnInit {
// onResetForEdit(){ // onResetForEdit(){
// this.PdTeamFormDatas(); // this.PdTeamFormDatas();
// } // }
/**on change function for customer segment to dispaly the as List in html page */ /**on change function for customer segment to dispaly the as List in html page */
onChangeCustomerSegmentDatas($event){ onChangeCustomerSegmentDatas($event){
//let CustomerSegmentName = $event.source.value.name; if($event.isUserInput != false){
let CustomerSegmentName = this.customerSegmentdatas.filter(cs=>cs.customer_segment_id == $event.source.value)[0]; let CustomerSegmentName = this.customerSegmentdatas.filter(cs=>cs.customer_segment_id == $event.source.value)[0];
if($event.source._selected === true ){
this.selectedSegmentDatas.push(CustomerSegmentName.name); if($event.source._selected === true ){
}
else if($event.source._selected === false ){ this.selectedSegmentDatas.push(CustomerSegmentName.name);
}
else if($event.isUserInput != false && $event.source._selected === false ){
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name); let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);
this.selectedSegmentDatas.splice(index,1); this.selectedSegmentDatas.splice(index,1);
let data;
this._masterService.getAllMasterData('PDTEAMCUSTOMERSEGMENT').subscribe(
dataresult => {
if (dataresult.dataStatus == true) {
data = dataresult.records;
data = data.filter(pdteamcustomer=>pdteamcustomer.fk_cs_id == $event.source.value && pdteamcustomer.isactive == 1);
data = data.filter(pdteamcustomer=>pdteamcustomer.fk_pdteam_id == this._pdTeamForm.value.pdteam_id)[0];
let ActiveDatas = { 'pdteam_customer_segment_id':data.pdteam_customer_segment_id,'isactive': '0'} ;
this._pdTeamService.editPdTeamchildDetails(ActiveDatas,'PDTEAMCUSTOMERSEGMENT')
.subscribe(dataresult=>{
if (dataresult.dataStatus == true){
//alert('InActive Changes Done in cs');
let index = this.selectedSegmentDatas.indexOf(CustomerSegmentName.name);
this.selectedSegmentDatas.splice(index,1);
}else{}
});
}
}, error => this.errorMessage = <any> error);
}
} }
} }
/**on change function for City to display the as List in html page */ /**on change function for City to display the as List in html page */
onChangeCityDatas($event){ // onChangeCityDatas($event){
var mycheck = 0 ; // var mycheck = 0 ;
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0]; // let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];
if($event.source._selected == true ){ // if($event.source._selected == true ){
for(let Duplication_City of this.pdTeamCityArray){ // for(let Duplication_City of this.pdTeamCityArray){
let teamname = Duplication_City.team_name; // let teamname = Duplication_City.team_name;
let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value); // let dup_cityname = Duplication_City.CITYMAP.filter(city=>city.city_id == $event.source.value);
if(dup_cityname != ''){ // if(dup_cityname != ''){
for(let data of dup_cityname){ // for(let data of dup_cityname){
if(data.name == cityName.name){ // if(data.name == cityName.name){
Swal('<h5>"'+data.name+'" already existing with "'+ teamname +'"</h5>'); // Swal('<h5>"'+data.name+'" already existing with "'+ teamname +'"</h5>');
$event.source._selected = false; // $event.source._selected = false;
mycheck=1; // mycheck=1;
} // }
} // }
} // }
} // }
if(mycheck == 0){ // if(mycheck == 0){
this.selectedCityDatas.push(cityName.name); // this.selectedCityDatas.push(cityName.name);
} // }
// }
// else if($event.source._selected === false ){
// let index = this.selectedCityDatas.indexOf(cityName.name);
// this.selectedCityDatas.splice(index,1);
// }
// }
onChangeCityDatas($event){
//console.log('inside the function Event');
var mycheck = 0 ;
let lenderId = this._pdTeamForm.value['fk_lender'];
let cityName = this.citydatas.filter(city=>city.city_id == $event.source.value)[0];//city array
if($event.isUserInput != false){
// console.log(cityName);
// console.log($event.source.value);
if($event.source._selected === true ){
this._pdTeamService.getLenderData(lenderId).subscribe(
dataresult => {
if(dataresult.dataStatus == true){
this.CityValidation = dataresult.records;
}
}, error => this.errorMessage = <any> error);
if(this.CityValidation != ''){
for(let data of this.CityValidation){
if(data['fk_city_id'] == $event.source.value){
Swal('<h5>"'+data['city_name']+'" already existing with "'+ data['team_name'] +'"</h5>');
$event.source._selected = false;
mycheck = 1;
}
}
}
if(mycheck == 0){
this.selectedCityDatas.push(cityName.name);
}
} }
else if($event.source._selected === false ){ else if($event.source._selected === false ){
let index = this.selectedCityDatas.indexOf(cityName.name);
this.selectedCityDatas.splice(index,1); console.log('Return False for city Selection Data');
} let index = this.selectedCityDatas.indexOf(cityName.name);
} this.selectedCityDatas.splice(index,1);
//$event.source._selected = false;
let data;
this._masterService.getAllMasterData('PDTEAMCITY').subscribe(
dataresult => {
if (dataresult.dataStatus == true) {
data = dataresult.records;
console.log('data',data);
data = data.filter(pdteamcity=>pdteamcity.fk_city_id == $event.source.value);
data = data.filter(pdteamcity=>pdteamcity.fk_pdteam_id == this._pdTeamForm.value.pdteam_id)[0];
console.log(data.pdteam_city_id);
this._pdTeamService.deletePDteamCity($event.source.value).subscribe(data=>{
if (dataresult.dataStatus == true) {//alert('Deleted');
let index = this.selectedCityDatas.indexOf(cityName.name);
this.selectedCityDatas.splice(index,1);
//this._PdTeamListComponent.changeListView();
}
});
}
}, error => this.errorMessage = <any> error);
//console.log(data);
}
}
else if($event.isUserInput != true && $event.source._selected == true) {
this.selectedCityDatas.push(cityName.name);
}
}
/**on change function for Product to display the data as List in html page */ /**on change function for Product to display the data as List in html page */
onChangeProductDatas($event){ onChangeProductDatas($event){
if($event.isUserInput != false){
//let productName = $event.source.value.name; //let productName = $event.source.value.name;
let productName = this.productdatas.filter(product=>product.product_id == $event.source.value )[0]; let productName = this.productdatas.filter(product=>product.product_id == $event.source.value )[0];
if($event.source._selected === true ){
this.selectedProductDatas.push(productName.name); if($event.source._selected === true ){
this.selectedProductDatas.push(productName.name);
}
else if($event.isUserInput != false && $event.source._selected === false ){
let index = this.selectedProductDatas.indexOf(productName.name);
this.selectedProductDatas.splice(index,1);
let data;
this._masterService.getAllMasterData('PDTEAMPRODUCT').subscribe(
dataresult => {
if (dataresult.dataStatus == true) {
data = dataresult.records;
console.log('data',data);
data = data.filter(pdteamproduct=>pdteamproduct.fk_product_id == $event.source.value && pdteamproduct.isactive == 1);
data = data.filter(pdteamcity=>pdteamcity.fk_pdteam_id == this._pdTeamForm.value.pdteam_id)[0];
console.log(data.pdteam_city_id);
let ActiveDatas = { 'pdteam_product_id':data.pdteam_product_id,'isactive': '0'} ;
this._pdTeamService.editPdTeamchildDetails(ActiveDatas,'PDTEAMPRODUCT')
.subscribe(dataresult=>{
if (dataresult.dataStatus == true){
//alert('InActive Changes Done in product');
let index = this.selectedProductDatas.indexOf(productName.name);
this.selectedProductDatas.splice(index,1);
}
else{
//alert("Sorry Try Again !");
}
});
}
}, error => this.errorMessage = <any> error);
}
} }
else if($event.source._selected === false ){
let index = this.selectedProductDatas.indexOf(productName.name);
this.selectedProductDatas.splice(index,1);
}
} }
/** To Edited form Data */ /** To Edited form Data */
@ -242,18 +381,17 @@ export class PdTeamEditComponent implements OnInit {
Object.keys(pdTeamFormValues).forEach( Object.keys(pdTeamFormValues).forEach(
(key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]); (key) => ( pdTeamFormValues[key] == null) && delete pdTeamFormValues[key]);
this._pdTeamService.editPdTeamDetail(pdTeamFormValues).subscribe( this._pdTeamService.editPdTeamDetail(pdTeamFormValues).subscribe(
dataresult=>{
dataresult=>{ if (dataresult.dataStatus == true){
if (dataresult.dataStatus == true){ Swal("Data Edited Successfully");
Swal("Data Edited Successfully"); this.notifier.notify('success', 'Record Edited Successfully.!');
this.notifier.notify('success', 'Record Edited Successfully.!'); }
} else{
else{ Swal("SomeThing Wents Wrong Try Again !");
Swal("SomeThing Wents Wrong Try Again !"); this.notifier.notify('warning', 'SomeThing Wents Wrong Try Again !');
this.notifier.notify('warning', 'SomeThing Wents Wrong Try Again !'); }
} });
});
} }

View File

@ -65,12 +65,24 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
var ArrayData = { "records": Records } var ArrayData = { "records": Records }
console.log(ArrayData); console.log(ArrayData);
return this._http.post(this.apiUrl+'savePDTeam',ArrayData) //return this._http.post(this.apiUrl+'savePDTeam',ArrayData)
return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
.pipe( .pipe(
catchError(this.handleError('role', [])) catchError(this.handleError('role', []))
) )
} }
editPdTeamchildDetails(Records: any,MasterName:string): Observable<any> {
var ArrayData = { "master_name":MasterName,
"records": Records }
var data = this._http.post(this.apiUrl+'saveMaster',ArrayData);
return data;
}
/** /**
@ -99,21 +111,66 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
// } // }
//To delete PDTeam Mapping Details //To delete PDTeam Mapping Details
deletePdTeamMapDetails(Records:any){ deletePDteamCity(id:any): Observable<any> {
Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated var ArrayData = { "pdteam_city_id": id};
console.log('service data',ArrayData);
var ArrayData = { "records": [Records]};
return this._http.post<any>(this.apiUrl+"deletePdTeamMapping", ArrayData).pipe(
// console.log(ArrayData);
// console.log('PdTeamMapDetails in service');
return this._http.post(this.apiUrl+"deletePdTeamMapping",ArrayData).pipe(
catchError(this.handleError('role', [])) catchError(this.handleError('role', []))
); );
}
// deletePdTeamMapDetails(Records:any){
// Records.fk_updatedby = this._aws.getlocale();//to get user id for who is update the record
// Records.updatedon = currentdate;//to get Current date and Time for when the Record is updated
// var ArrayData = { "records": [Records]};
// // console.log(ArrayData);
// // console.log('PdTeamMapDetails in service');
// return this._http.post(this.apiUrl+"deletePdTeamMapping",ArrayData).pipe(
// catchError(this.handleError('role', []))
// );
// }
getLenderData(lenderId: any): Observable<any> {
var ArrayData = {"lender_id":lenderId }
return this._http.post(this.apiUrl+"getLender",ArrayData)
.pipe(
catchError(this.handleError('role', []))
)
}
getProductData(TeamId: any): Observable<any> {
var ArrayData = {"team_id":TeamId }
return this._http.post(this.apiUrl+"getProduct",ArrayData)
.pipe(
catchError(this.handleError('role', []))
)
}
getCustomerSegmentData(TeamId: any): Observable<any> {
var ArrayData = {"team_id":TeamId }
return this._http.post(this.apiUrl+"getCustomerSegment",ArrayData)
.pipe(
catchError(this.handleError('role', []))
)
}
getExistingCityDatas(){
return this._http.get<any>(this.apiUrl+'getExistingCityDatas')
.pipe(
catchError(this.handleError('role', []))
)
} }
@ -143,7 +200,7 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
) )
} }
getAllPDTeamWithPDTeamID(Primarykey): Observable<any> { getAllPDTeamWithPDTeamID(Primarykey: any): Observable<any> {
var pk = { "primary_key":Primarykey } var pk = { "primary_key":Primarykey }
return this._http.post<any>(this.apiUrl+'getListOfPDTeam',pk) return this._http.post<any>(this.apiUrl+'getListOfPDTeam',pk)
@ -153,7 +210,7 @@ return this._http.post<any>(this.apiUrl+"savePDTeam", ArrayData)
} }
// /** Get All PD Team Child Data using API call Based on Primary Key */ // /** Get All PD Team Child Data using API call Based on Primary Key */
getAllPdTeamMapListWithPK(Primarykey): Observable<any> { getAllPdTeamMapListWithPK(Primarykey: any): Observable<any> {
var pk = { "primary_key":Primarykey } var pk = { "primary_key":Primarykey }
//var Primar = Primarykey //var Primar = Primarykey