merge : kms

This commit is contained in:
gandhimathi 2019-01-08 13:20:11 +05:30
parent 742b938f75
commit 16486140de
7 changed files with 725 additions and 165 deletions

View File

@ -1,79 +1,146 @@
<div > <div>
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="end"> <div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="end">
<div style="text-align:right;"> <div style="text-align:right;">
<button mat-raised-button mat-icon-button color="primary" class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above" <button mat-raised-button mat-icon-button color="primary" class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above"
type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button> type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div> </div>
</div> </div>
<mat-card style="padding: 12px 8px;">
<form [formGroup]="tatForm" (submit)="onSubmit()"> <div>
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start"> <mat-dialog-content class="mat-typography">
<mat-form-field> <mat-card style="padding: 6px;">
<input placeholder="TAT Value 1" matInput formControlName="toppings4"> <mat-tab-group>
<mat-error *ngIf="submitted && f.toppings4.hasError('required')" class="mat-text-warn">TAT 1 Value Required.!</mat-error> <mat-tab label="Add TAT">
</mat-form-field> <div style="margin: 12px;" *ngIf="!listShow">
<mat-form-field> <form [formGroup]="tatForm" (submit)="onSubmit()">
<input placeholder="TAT Value 2" matInput formControlName="toppings5"> <div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
<mat-error *ngIf="submitted && f.toppings5.hasError('required')" class="mat-text-warn">TAT 2 Value Required.!</mat-error> <mat-form-field>
</mat-form-field> <input placeholder="TAT Value 1" matInput formControlName="toppings4">
</div> <mat-error *ngIf="submitted && f.toppings4.hasError('required')" class="mat-text-warn">TAT 1 Value Required.!</mat-error>
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start"> </mat-form-field>
<div> <mat-form-field>
<mat-form-field> <input placeholder="TAT Value 2" matInput formControlName="toppings5">
<mat-select (selectionChange)="selectedPD($event)" placeholder="PD Type" formControlName="toppings1" multiple> <mat-error *ngIf="submitted && f.toppings5.hasError('required')" class="mat-text-warn">TAT 2 Value Required.!</mat-error>
<mat-option *ngFor="let pd of m_pdType" [value]="pd.id">{{pd.name}}</mat-option> </mat-form-field>
</mat-select> </div>
<mat-error *ngIf="submitted && f.toppings1.hasError('required')" class="mat-text-warn">PD Type Required.!</mat-error> <div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
</mat-form-field> <div>
<div style="height: 160px; overflow: auto;"> <mat-form-field>
<ul style="list-style: none; margin: 0px;padding: 0px;"> <mat-select (selectionChange)="selectedPD($event)" placeholder="PD Type" formControlName="toppings1" multiple>
<li *ngFor="let pdName of selectedItem"> <mat-option *ngFor="let pd of m_pdType" [value]="pd.pd_type_id">{{pd.type_name}}</mat-option>
<mat-chip>{{pdName.name}}</mat-chip> </mat-select>
</li> <mat-error *ngIf="submitted && f.toppings1.hasError('required')" class="mat-text-warn">PD Type Required.!</mat-error>
</ul> </mat-form-field>
</div> <div style="height: 160px; overflow: auto;">
</div> <ul style="list-style: none; margin: 0px;padding: 0px;">
<div> <li *ngFor="let pdName of selectedItem">
<mat-form-field> <mat-chip>{{pdName.type_name}}</mat-chip>
<mat-select (selectionChange)="selectedProduct($event)" placeholder="Product" formControlName="toppings2" multiple> </li>
<mat-option *ngFor="let prdct of m_product" [value]="prdct.id">{{prdct.name}}</mat-option> </ul>
</mat-select> </div>
<mat-error *ngIf="submitted && f.toppings2.hasError('required')" class="mat-text-warn">Product Required.!</mat-error> </div>
</mat-form-field> <div>
<div style="height: 160px; overflow: auto;"> <mat-form-field>
<ul style="list-style: none; margin: 0px;padding: 0px;"> <mat-select (selectionChange)="selectedProduct($event)" placeholder="Product" formControlName="toppings2" multiple>
<li *ngFor="let prdcName of selectedProductItem" style="padding: 2px;"> <mat-option *ngFor="let prdct of m_product" [value]="prdct.product_id">{{prdct.name}}</mat-option>
<mat-chip>{{prdcName.name}}</mat-chip> </mat-select>
</li> <mat-error *ngIf="submitted && f.toppings2.hasError('required')" class="mat-text-warn">Product Required.!</mat-error>
</ul> </mat-form-field>
</div> <div style="height: 160px; overflow: auto;">
</div> <ul style="list-style: none; margin: 0px;padding: 0px;">
<div> <li *ngFor="let prdcName of selectedProductItem" style="padding: 2px;">
<mat-form-field> <mat-chip>{{prdcName.name}}</mat-chip>
<mat-select (selectionChange)="selectedCity($event)" placeholder="City" formControlName="toppings3" multiple> </li>
<mat-option *ngFor="let city of m_city" [value]="city.id">{{city.name}}</mat-option> </ul>
</mat-select> </div>
<mat-error *ngIf="submitted && f.toppings3.hasError('required')" class="mat-text-warn">City Required.!</mat-error> </div>
</mat-form-field> <div>
<div style="height: 160px; overflow: auto;"> <mat-form-field>
<ul style="list-style: none; margin: 0px;padding: 0px;"> <mat-select (selectionChange)="selectedCity($event)" placeholder="City" formControlName="toppings3" multiple>
<li *ngFor="let cityName of selectedCityItem" style="padding: 2px;"> <mat-option *ngFor="let city of m_city" [value]="city.city_id">{{city.name}}</mat-option>
<mat-chip>{{cityName.name}}</mat-chip> </mat-select>
</li> <mat-error *ngIf="submitted && f.toppings3.hasError('required')" class="mat-text-warn">City Required.!</mat-error>
</ul> </mat-form-field>
</div> <div style="height: 160px; overflow: auto;">
</div> <ul style="list-style: none; margin: 0px;padding: 0px;">
</div> <li *ngFor="let cityName of selectedCityItem" style="padding: 2px;">
<mat-chip>{{cityName.name}}</mat-chip>
</li>
</ul>
</div>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="end">
<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>
</div>
<div *ngIf="listShow">
<div>
<h4 fxLayout="row" fxLayoutAlign="center">Before Submit , Pleast Verify your selected values as below.</h4>
<mat-card fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
<div><label> Tat Value 1</label>
<div>{{tatValue1}}</div>
</div>
<div><label> Tat Value 2</label>
<div>{{tatValue2}}</div>
</div>
</mat-card>
</div>
<div>
<mat-card class="example-container">
<table mat-table [dataSource]="transactions" class="mat-elevation-z8">
<!-- Checkbox Column -->
<ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef>
<mat-checkbox (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" [indeterminate]="selection.hasValue() && !isAllSelected()">
</mat-checkbox>
</th>
<td mat-cell *matCellDef="let row">
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
</mat-checkbox>
</td>
</ng-container>
<ng-container matColumnDef="pd">
<th mat-header-cell *matHeaderCellDef> Pd Type </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.pd_type.name}} </td>
</ng-container>
<ng-container matColumnDef="product">
<th mat-header-cell *matHeaderCellDef> Product </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.product.name}} </td>
</ng-container>
<ng-container matColumnDef="city">
<th mat-header-cell *matHeaderCellDef> City </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.city.name}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
<!--<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>-->
</table>
</mat-card>
</div>
<div fxLayout="row" fxLayoutAlign="end">
<button *ngIf="selection.selected.length == 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
matTooltipPosition="above" type="button" (click)="onDataSubmit()"><mat-icon>save</mat-icon></button>
<button *ngIf="selection.selected.length > 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
matTooltipPosition="above" type="button" (click)="onDelete()"><mat-icon>delete</mat-icon></button>
</div>
</div>
</mat-tab>
</mat-tab-group>
</mat-card>
</mat-dialog-content>
<!--<mat-dialog-actions align="end">
<div fxLayout="row" fxLayoutAlign="end"> <div fxLayout="row" fxLayoutAlign="end">
<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> </div>
<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> </mat-dialog-actions>-->
</div> </div>
</form>
<div *ngIf="existValArray.length > 0">
<h5><b>Note : </b> Following are already exist for this Entity.</h5>
<ul>
<li *ngFor="let val of existValArray">{{ val }}</li>
</ul>
</div>
</mat-card>
</div> </div>

View File

@ -0,0 +1,111 @@
<div style="width: inherit;">
<div class="ml-xs mr-xs" style="width: 100%;" fxLayout="row" fxLayoutAlign="end">
<div style="text-align:right;">
<button mat-raised-button mat-icon-button color="primary" class="mr-1 mb-1 hover-icon" matTooltip="Close" matTooltipPosition="above"
type="button" (click)="onNoClick()"><mat-icon>close</mat-icon></button>
</div>
</div>
<div>
<mat-dialog-content class="mat-typography">
<mat-card style="padding: 6px;">
<mat-tab-group>
<mat-tab label="TAT Details">
<mat-card>
<form [formGroup]="tatListEditForm" (submit)="onSubmit()">
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
<mat-form-field>
<input placeholder="TAT Value 1" matInput formControlName="tat1">
<mat-error *ngIf="submitted && f.tat1.hasError('required')" class="mat-text-warn">TAT 1 Value Required.!</mat-error>
</mat-form-field>
<mat-form-field>
<input placeholder="TAT Value 2" matInput formControlName="tat2">
<mat-error *ngIf="submitted && f.tat2.hasError('required')" class="mat-text-warn">TAT 2 Value Required.!</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="end">
<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>
<table *ngIf="dataSource.length > 0" mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef>
<mat-checkbox (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" [indeterminate]="selection.hasValue() && !isAllSelected()">
</mat-checkbox>
</th>
<td mat-cell *matCellDef="let row">
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
</mat-checkbox>
</td>
</ng-container>
<ng-container matColumnDef="pd">
<th mat-header-cell *matHeaderCellDef> Pd Type </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.pd_type.name}} </td>
</ng-container>
<ng-container matColumnDef="product">
<th mat-header-cell *matHeaderCellDef> Product </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.product.name}} </td>
</ng-container>
<ng-container matColumnDef="city">
<th mat-header-cell *matHeaderCellDef> City </th>
<td mat-cell *matCellDef="let transaction"> {{transaction.city.name}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<button *ngIf="selection?.selected.length > 0" mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Reset"
matTooltipPosition="above" type="button" (click)="onDelete()"><mat-icon>delete</mat-icon></button>
</mat-tab>
<mat-tab label="Add TAT">
<div style="margin: 12px;" *ngIf="!listShow">
<form [formGroup]="tatEditAddForm" (submit)="onSubmitEditAddForm()">
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="6px" fxLayoutAlign="start">
<div>
<mat-form-field>
<mat-select (selectionChange)="selectedDetails($event)" placeholder="PD Type" formControlName="pd_type" >
<mat-option *ngFor="let pd of m_pdType" [value]="pd.pd_type_id">{{pd.type_name}}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.toppings1.hasError('required')" class="mat-text-warn">PD Type Required.!</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select (selectionChange)="selectedDetails($event)" placeholder="Product" formControlName="product">
<mat-option *ngFor="let prdct of m_product" [value]="prdct.product_id">{{prdct.name}}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.toppings2.hasError('required')" class="mat-text-warn">Product Required.!</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select (selectionChange)="selectedDetails($event)" placeholder="City" formControlName="city">
<mat-option *ngFor="let city of m_city" [value]="city.city_id">{{city.name}}</mat-option>
</mat-select>
<mat-error *ngIf="submitted && f.toppings3.hasError('required')" class="mat-text-warn">City Required.!</mat-error>
</mat-form-field>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="end">
<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>
</div>
</mat-tab>
</mat-tab-group>
<!--<pre>
{{ selection?.selected.length}}
</pre>-->
</mat-card>
</mat-dialog-content>
<mat-dialog-actions align="end">
<div fxLayout="row" fxLayoutAlign="end">
</div>
</mat-dialog-actions>
</div>
</div>

View File

@ -1,24 +1,24 @@
<div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="end" style="padding-top:1%"> <div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="end" style="padding-top:1%">
<div fxFlex="20%" style="text-align:right;"> <div fxFlex="20%" style="text-align:right;">
<button mat-fab class="mr-1 mb-1" color="primary"matTooltip="Add More TAT Details" matTooltipPosition="above" (click)="addNewTatDetails()"><mat-icon>add</mat-icon></button> <button mat-fab class="mr-1 mb-1" color="primary" matTooltip="Add More TAT Details" matTooltipPosition="above" (click)="addNewTatDetails()"><mat-icon>add</mat-icon></button>
</div> </div>
</div> </div>
<mat-card *ngFor="let data of entityTatListDetails"> <mat-card *ngFor="let data of listOfTatDetails">
<div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="2%" fxLayoutAlign="center center"> <div fxLayout="row wrap" fxLayout.xs="column" fxLayoutGap="2%" fxLayoutAlign="center center">
<div fxFlex="48%"> <div fxFlex="48%">
<div class="text-line-limit"> <div class="text-line-limit">
<div *ngFor="let comb of data.tatCombinations; let last = last">{{comb.pd.name}} - {{comb.product.name}} - {{comb.city.name}} <span *ngIf="!last">,</span></div> <div *ngFor="let comb of data.child; let last = last">{{comb.pd_type.name}} - {{comb.product.name}} - {{comb.city.name}} <span *ngIf="!last">,</span></div>
</div> </div>
</div> </div>
<div fxFlex="9%"> <div fxFlex="9%">
{{data.tatVal1}} {{data.tat1}}
</div> </div>
<div fxFlex="9%"> <div fxFlex="9%">
{{data.tatVal2}} {{data.tat2}}
</div> </div>
<div fxFlex="18%"> <div fxFlex="18%">
<button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editDetails(data)"><mat-icon>edit</mat-icon></button> <button mat-button mat-icon-button class="mr-1 mb-1 hover-icon" matTooltip="Edit" matTooltipPosition="above" (click)="editTatInfoDetails(data)"><mat-icon>edit</mat-icon></button>
</div> </div>
</div> </div>
</mat-card> </mat-card>

View File

@ -13,4 +13,12 @@
// width: 160px; // width: 160px;
// height: 1.2em; // height: 1.2em;
// white-space: nowrap; // white-space: nowrap;
} }
table {
width: 100%;
}
tr.mat-footer-row {
font-weight: bold;
}

View File

@ -4,12 +4,12 @@ import { FormGroup, FormControl, FormBuilder, Validators, FormArray } from '@ang
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { DataSource } from '@angular/cdk/table'; import { DataSource } from '@angular/cdk/table';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { NotifierService } from 'angular-notifier'; import { NotifierService } from 'angular-notifier';
import { MastersService } from './../../../service/masters/masters.service'; import { MastersService } from './../../../service/masters/masters.service';
import { EntityService } from './../../../service/entity/entity.service'; import { EntityService } from './../../../service/entity/entity.service';
import { SelectionModel } from '@angular/cdk/collections';
@Component({ @Component({
selector: 'app-entity-edit-tat', selector: 'app-entity-edit-tat',
templateUrl: './entity-edit-tat.component.html', templateUrl: './entity-edit-tat.component.html',
@ -17,7 +17,7 @@ import { EntityService } from './../../../service/entity/entity.service';
}) })
export class EntityEditTatComponent implements OnInit { export class EntityEditTatComponent implements OnInit {
@Input() public entityId: number; @Input() public entityId: number;
/** /**
@ -25,6 +25,8 @@ export class EntityEditTatComponent implements OnInit {
*/ */
private notifier: NotifierService; private notifier: NotifierService;
listOfTatDetails = [];
constructor(notifier: NotifierService, constructor(notifier: NotifierService,
private entityService: EntityService, private entityService: EntityService,
private mastersService: MastersService, private mastersService: MastersService,
@ -32,55 +34,51 @@ export class EntityEditTatComponent implements OnInit {
this.notifier = notifier; this.notifier = notifier;
} }
ngOnInit() { ngOnInit() {
this.getListofEntityTATInfo();
} }
getListofEntityTATInfo() {
this.entityService.getEntityTATInfoDetails(this.entityId).subscribe(data => {
if (data.dataStatus) {
this.listOfTatDetails = data.records;
} else {
}
}, err => {
})
}
addNewTatDetails() { addNewTatDetails() {
const dialogRef = this.dialog.open(DialogEntityAddTatComponent, { const dialogRef = this.dialog.open(DialogEntityAddTatComponent, {
data: {entity_id: this.entityId}, data: { entity_id: this.entityId },
disableClose: true disableClose: true,
maxWidth: '100vw',
maxHeight: '100vh',
height: '100%',
width: '100%'
}); });
dialogRef.afterClosed() dialogRef.afterClosed()
.subscribe(dataresult => { .subscribe(dataresult => {
this.getListofEntityTATInfo();
}); });
} }
entityTatListDetails: any = [ { editTatInfoDetails(details) {
'm_id': 1, const dialogRef = this.dialog.open(DialogEntityEditListTatComponent, {
'tatVal1': 3, data: { entity_id: this.entityId, tat_details: details },
'tatVal2':10, disableClose: true,
"tatCombinations" : [ maxWidth: '100vw',
{ maxHeight: '100vh',
'c_id': 1, height: '100%',
'pd': { width: '100%'
'id': 1, });
'name': 'PD Type 1' dialogRef.afterClosed()
}, .subscribe(dataresult => {
'product': { this.getListofEntityTATInfo();
'id': 2, });
'name': 'Product 2' }
},
'city' : {
'id': 3,
'name': 'City 3'
}
},
{
'c_id': 2,
'pd': {
'id': 2,
'name': 'PD Type 2'
},
'product': {
'id': 1,
'name': 'Product 1'
},
'city' : {
'id': 1,
'name': 'City 1'
}
}
]
}]
} }
@ -96,9 +94,233 @@ export class EntityEditTatComponent implements OnInit {
// var exist = result1.filter(a => valueApi.indexOf(a) > -1); // var exist = result1.filter(a => valueApi.indexOf(a) > -1);
// console.log("exit :" + exist); // console.log("exit :" + exist);
@Component({
selector: 'dialog-entity-edit-list-tat',
styles: [`
table {
width: 100%;
}
tr.mat-footer-row {
font-weight: bold;
}
`
],
templateUrl: './entity-edit-list-tat.component.html'
})
export class DialogEntityEditListTatComponent implements OnInit {
tatListEditForm: FormGroup;
tatEditAddForm: FormGroup;
submitted: Boolean = false;
/**
* Notifier service
*/
private notifier: NotifierService;
masterDataCombination = [];
constructor(notifier: NotifierService,
private entityService: EntityService,
private mastersService: MastersService,
public dialogRef: MatDialogRef<DialogEntityAddTatComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private _formBuilder: FormBuilder) {
this.notifier = notifier;
this.dataSource = this.data.tat_details.child;
this.tatListEditForm = this._formBuilder.group({
tat1: [this.data.tat_details.tat1, Validators.compose([Validators.required])],
tat2: [this.data.tat_details.tat2, Validators.compose([Validators.required])],
});
this.tatEditAddForm = this._formBuilder.group({
pd_type: ['', Validators.compose([Validators.required])],
product: ['', Validators.compose([Validators.required])],
city: ['', Validators.compose([Validators.required])]
})
this.masterDataCombination = this.dataSource.map(data => {
return data.pd_type.id + '' + data.product.id + '' + data.city.id;
});
}
m_pdType = [];
m_product = [];
m_city = [];
// m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }];
// m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }];
// m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }];
ngOnInit(): void {
this.getCityMasters();
this.getProductMasters();
this.getPdTypeMasters();
}
getCityMasters() {
this.mastersService.getAllMasterData('CITY').subscribe(
data => {
this.m_city = data.records;
},
error => {
this.notifier.notify('warning', 'No City Master Records Found.!');
// this.errorMessage = "No Region Master Record Found.";
}
);
}
getProductMasters() {
this.mastersService.getAllMasterData('PRODUCTS').subscribe(
data => {
this.m_product = data.records;
},
error => {
this.notifier.notify('warning', 'No City Master Records Found.!');
// this.errorMessage = "No Region Master Record Found.";
}
);
}
getPdTypeMasters() {
this.mastersService.getAllMasterData('PDTYPE').subscribe(
data => {
this.m_pdType = data.records;
},
error => {
this.notifier.notify('warning', 'No City Master Records Found.!');
// this.errorMessage = "No Region Master Record Found.";
}
);
}
get f() { return this.tatListEditForm.controls };
get f1() { return this.tatEditAddForm.controls };
onSubmit() {
this.submitted = true;
if (this.tatListEditForm.invalid) {
return;
} else {
}
}
onSubmitEditAddForm() {
let finalArr = [];
let data = this.tatEditAddForm.value;
finalArr.push(data.pd_type + '' + data.product + '' + data.city);
if (this.masterDataCombination.length > 0) {
finalArr.map(d => {
// alert(this.masterDataCombination.indexOf(d));
if(this.masterDataCombination.indexOf(d) > -1){
finalArr.splice(this.masterDataCombination.indexOf(d), 1);
}
});
}
this.selection.clear();
let record: any = {};
record.tat1 = this.data.tat_details.tat1;
record.tat2 = this.data.tat_details.tat2;
record.entity_tat_master_id = this.data.tat_details.entity_tat_master_id;
record.fk_entity_id = this.data.entity_id;
record.child = finalArr;
this.entityService.saveEntityTATInfo(record).subscribe(data=>{
if(data.dataStatus){
this.notifier.notify('success', 'Your Changes Updated.!');
this.dialogRef.close();
} else {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
}
}, err => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
})
}
onNoClick(): void {
this.dialogRef.close();
}
dataSource: Transaction[] = [];
/** Whether the number of selected elements matches the total number of rows. */
isAllSelected() {
const numSelected = this.selection.selected.length;
const numRows = this.dataSource.length;
return numSelected === numRows;
}
/** Selects all rows if they are not all selected; otherwise clear selection. */
masterToggle() {
this.isAllSelected() ?
this.selection.clear() :
this.dataSource.forEach(row => this.selection.select(row));
}
selection = new SelectionModel<Transaction>(true, []);
displayedColumns: string[] = ['select', 'pd', 'product', 'city'];
onDelete() {
let data = this.selection.selected.map(x => x['entity_tat_child_id']);
let record: any = {};
record.entity_tat_master_id = this.data.tat_details.entity_tat_master_id;
record.fk_entity_id = this.data.entity_id;
record.entity_tat_child_id_details = data;
this.entityService.deleteTATInfoDetails(record).subscribe(data=>{
if(data.dataStatus){
this.notifier.notify('success', 'Your Changes Updated.!');
this.dialogRef.close();
} else {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
}
} , err => {
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!');
})
// alert(JSON.stringify(record));
// if(data.length > 0){
// } else {
// }
}
selectedDetails(e) {
}
}
@Component({ @Component({
selector: 'dialog-entity-add-tat', selector: 'dialog-entity-add-tat',
styles: [`` styles: [`
table {
width: 100%;
}
tr.mat-footer-row {
font-weight: bold;
}
.example-container {
height: 400px;
overflow: auto;
}
`
], ],
templateUrl: './entity-add-tat.component.html' templateUrl: './entity-add-tat.component.html'
}) })
@ -123,9 +345,13 @@ export class DialogEntityAddTatComponent implements OnInit {
toppingList1: any[] = [{ 'id': 1, 'name': 'Extra cheese' }, { 'id': 2, 'name': 'Mushroom' }, { 'id': 3, 'name': 'Onion' }]; toppingList1: any[] = [{ 'id': 1, 'name': 'Extra cheese' }, { 'id': 2, 'name': 'Mushroom' }, { 'id': 3, 'name': 'Onion' }];
m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }]; m_pdType = [];
m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }]; m_product = [];
m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }]; m_city = [];
// m_pdType = [{ 'id': 1, 'name': 'PD Type 1' }, { 'id': 2, 'name': 'PD Type 2' }];
// m_product = [{ 'id': 1, 'name': 'Product 1' }, { 'id': 2, 'name': 'Product 2' }, { 'id': 3, 'name': 'Product 3' }];
// m_city = [{ 'id': 1, 'name': 'City 1' }, { 'id': 2, 'name': 'City 2' }, { 'id': 3, 'name': 'City 3' }];
/** /**
* Notifier service * Notifier service
*/ */
@ -148,7 +374,9 @@ export class DialogEntityAddTatComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.getCityMasters();
this.getProductMasters();
this.getPdTypeMasters();
} }
get f() { return this.tatForm.controls }; get f() { return this.tatForm.controls };
@ -157,19 +385,19 @@ export class DialogEntityAddTatComponent implements OnInit {
selectedPD(e) { selectedPD(e) {
this.selectedArr = [...e.value]; this.selectedArr = [...e.value];
this.selectedItem = this.m_pdType.filter(val => this.selectedArr.indexOf(val.id) > -1) this.selectedItem = this.m_pdType.filter(val => this.selectedArr.indexOf(val.pd_type_id) > -1)
} }
selectedProductItem: any; selectedProductItem: any;
selectedProduct(e) { selectedProduct(e) {
this.selectedProductArr = [...e.value]; this.selectedProductArr = [...e.value];
this.selectedProductItem = this.m_product.filter(val => this.selectedProductArr.indexOf(val.id) > -1) this.selectedProductItem = this.m_product.filter(val => this.selectedProductArr.indexOf(val.product_id) > -1)
} }
selectedCityItem: any; selectedCityItem: any;
selectedCity(e) { selectedCity(e) {
this.selectedCityArr = [...e.value]; this.selectedCityArr = [...e.value];
this.selectedCityItem = this.m_city.filter(val => this.selectedCityArr.indexOf(val.id) > -1) this.selectedCityItem = this.m_city.filter(val => this.selectedCityArr.indexOf(val.city_id) > -1)
} }
getEntityIdCityDetails() { getEntityIdCityDetails() {
@ -201,34 +429,84 @@ export class DialogEntityAddTatComponent implements OnInit {
); );
} }
getProductMasters() {
this.mastersService.getAllMasterData('PRODUCTS').subscribe(
data => {
this.m_product = data.records;
},
error => {
this.notifier.notify('warning', 'No City Master Records Found.!');
// this.errorMessage = "No Region Master Record Found.";
}
);
}
getPdTypeMasters() {
this.mastersService.getAllMasterData('PDTYPE').subscribe(
data => {
this.m_pdType = data.records;
},
error => {
this.notifier.notify('warning', 'No City Master Records Found.!');
// this.errorMessage = "No Region Master Record Found.";
}
);
}
resultApi = ['123', '211']; resultApi = ['123', '211'];
getIdPdName(id) { getIdPdName(id) {
let pdF = this.m_pdType.filter(a => a.id == id); let pdF = this.m_pdType.filter(a => a.pd_type_id == id);
return pdF[0].name; let data = {
id: id,
name: pdF[0].type_name
}
return data;
} }
getIdProductName(id) { getIdProductName(id) {
let pdF = this.m_product.filter(a => a.id == id); let pdF = this.m_product.filter(a => a.product_id == id);
return pdF[0].name; let data = {
id: id,
name: pdF[0].name
}
return data;
} }
getIdCityName(id) { getIdCityName(id) {
let pdF = this.m_city.filter(a => a.id == id); let pdF = this.m_city.filter(a => a.city_id == id);
return pdF[0].name; let data = {
id: id,
name: pdF[0].name
}
return data;
} }
public existValArray:any = []; public existValArray: any = [];
// transactions : [] = new MatTableDataSource<Transaction>(this.existValArray);
listShow: Boolean = false;
transactions: Transaction[] = [];
tatValue1 = '';
tatValue2 = '';
onSubmit() { onSubmit() {
this.submitted = true; this.submitted = true;
if (this.tatForm.invalid) { if (this.tatForm.invalid) {
return return
} else { } else {
this.listShow = true;
let arr1 = this.tatForm.controls['toppings1'].value; let arr1 = this.tatForm.controls['toppings1'].value;
let arr2 = this.tatForm.controls['toppings2'].value; let arr2 = this.tatForm.controls['toppings2'].value;
let arr3 = this.tatForm.controls['toppings3'].value let arr3 = this.tatForm.controls['toppings3'].value;
this.tatValue1 = this.tatForm.controls['toppings4'].value;
this.tatValue2 = this.tatForm.controls['toppings5'].value;
let array1 = [...arr1]; let array1 = [...arr1];
let array2 = [...arr2]; let array2 = [...arr2];
let array3 = [...arr3]; let array3 = [...arr3];
@ -236,24 +514,102 @@ export class DialogEntityAddTatComponent implements OnInit {
a1.concat(array2.map(w => v1 + "" + w)), []).reduce((a2, v2, i3) => a1.concat(array2.map(w => v1 + "" + w)), []).reduce((a2, v2, i3) =>
a2.concat(array3.map(u => v2 + "" + u)), []); a2.concat(array3.map(u => v2 + "" + u)), []);
let exist = this.resultApi.filter(a => result1.indexOf(a) > -1); let exist = this.resultApi.filter(a => result1.indexOf(a) > -1);
if(exist){ if (exist) {
// alert(result1); this.existValArray = [];
// alert(exist); result1.forEach(a => {
this.existValArray = []; let pdName = this.getIdPdName(a[0]);
exist.forEach(a=>{ let productName = this.getIdProductName(a[1]);
let pdName = this.getIdPdName(a[0]); let cityName = this.getIdCityName(a[2]);
let productName = this.getIdProductName(a[1]); let data = {
let cityName = this.getIdCityName(a[2]); pd_type: pdName,
this.existValArray.push(`${pdName}, ${productName}, ${cityName}`); product: productName,
}); city: cityName
} else { }
// api add new here this.existValArray.push(data);
});
this.transactions = this.existValArray;
} else {
// api add new here
} }
} }
} }
onDelete() {
this.selection.selected.map(data => {
let inx = this.transactions.indexOf(data);
this.transactions.splice(inx, 1);
});
let dataTS = JSON.stringify(this.transactions);
this.transactions.length = 0;
this.transactions = JSON.parse(dataTS);
this.selection.clear();
}
onDataSubmit() {
let record: any = {};
record.fk_entity_id = this.data.entity_id;
record.tat1 = this.tatForm.controls['toppings4'].value;
record.tat2 = this.tatForm.controls['toppings5'].value;
record.child = this.transactions.map(data => {
return `${data.pd_type.id}${data.product.id}${data.city.id}`
});
this.entityService.saveEntityTATInfo(record).subscribe(data => {
if (data.dataStatus) {
this.dialogRef.close();
this.notifier.notify('success', 'Your Changes Updated.!');
} else {
this.notifier.notify('warning', 'No City Master Records Found.!');
}
}, err => {
this.notifier.notify('warning', 'No City Master Records Found.!');
})
}
onNoClick(): void { onNoClick(): void {
this.dialogRef.close(); this.dialogRef.close();
} }
/** Whether the number of selected elements matches the total number of rows. */
isAllSelected() {
const numSelected = this.selection.selected.length;
const numRows = this.transactions.length;
return numSelected === numRows;
}
/** Selects all rows if they are not all selected; otherwise clear selection. */
masterToggle() {
this.isAllSelected() ?
this.selection.clear() :
this.transactions.forEach(row => this.selection.select(row));
}
selection = new SelectionModel<Transaction>(true, []);
displayedColumns: string[] = ['select', 'pd', 'product', 'city'];
// transactions: Transaction[] = [
// {item: { name :'Beach ball'}, cost: 4},
// // {item: 'Towel', cost: 5},
// // {item: 'Frisbee', cost: 2},
// // {item: 'Sunscreen', cost: 4},
// // {item: 'Cooler', cost: 25},
// // {item: 'Swim suit', cost: 15},
// ];
}
export interface Transaction {
pd_type: {
name: string,
id: any
},
product: {
name: string,
id: any
},
city: {
name: string,
id: any
}
} }

View File

@ -31,7 +31,7 @@ import { EntityService } from './../service/entity/entity.service';
import { EntityEditRegionComponent } from './entity-edit/entity-edit-region/entity-edit-region.component'; import { EntityEditRegionComponent } from './entity-edit/entity-edit-region/entity-edit-region.component';
import { EntityEditTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component'; import { EntityEditTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component';
import { DialogEntityAddTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component'; import { DialogEntityAddTatComponent, DialogEntityEditListTatComponent } from './entity-edit/entity-edit-tat/entity-edit-tat.component';
import { EntityEditPriceComponent } from './entity-edit/entity-edit-price/entity-edit-price.component'; import { EntityEditPriceComponent } from './entity-edit/entity-edit-price/entity-edit-price.component';
import { EntityEditBillingInfoComponent } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component'; import { EntityEditBillingInfoComponent } from './entity-edit/entity-edit-billing-info/entity-edit-billing-info.component';
@ -113,6 +113,7 @@ const customNotifierOptions: NotifierOptions = {
EntityEditRegionComponent, EntityEditRegionComponent,
EntityEditTatComponent, EntityEditTatComponent,
DialogEntityAddTatComponent, DialogEntityAddTatComponent,
DialogEntityEditListTatComponent,
EntityEditPriceComponent, EntityEditPriceComponent,
EntityEditBillingInfoComponent, EntityEditBillingInfoComponent,
DialogAddEditBillingInfo, DialogAddEditBillingInfo,
@ -123,6 +124,7 @@ const customNotifierOptions: NotifierOptions = {
EntityEditComponent, EntityEditComponent,
DialogAddEditBillingInfo, DialogAddEditBillingInfo,
DialogEntityAddTatComponent, DialogEntityAddTatComponent,
DialogEntityEditListTatComponent,
EntityAddComponent EntityAddComponent
], ],
providers : [ providers : [

View File

@ -186,6 +186,22 @@ export class EntityService {
return this._http.post<any[]>(this.apiUrl + "saveLenderBranches", {'records': Records }); return this._http.post<any[]>(this.apiUrl + "saveLenderBranches", {'records': Records });
} }
saveEntityTATInfo(Records: any): Observable<any>{
Records.fk_updatedby = this._aws.getlocale();
Records.fk_createdby = this._aws.getlocale();
console.log(JSON.stringify(Records));
return this._http.post<any[]>(this.apiUrl + "saveTATInfo", {'records': Records });
}
getEntityTATInfoDetails(entity_id): Observable<any>{
return this._http.post<any[]>(this.apiUrl + "getFullTATInfo", {'records': {"fk_entity_id" : entity_id }});
}
deleteTATInfoDetails(record): Observable<any>{
record.fk_updatedby = this._aws.getlocale();
return this._http.post<any[]>(this.apiUrl + "deleteTATCombimaion", {'records': record});
}
/** /**
* TO Handle The Error * TO Handle The Error