This commit is contained in:
sriram-at-840620226347 2020-01-21 18:16:54 +05:30
commit d5502ca3eb
7 changed files with 104 additions and 23 deletions

View File

@ -14,7 +14,7 @@
</mat-card-header>
<mat-card-content>
<mat-form-field style="width: 28%">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson();getProCusPDType($event.value)">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson(1);getProCusPDType($event.value)">
<!-- (selectionChange)="getBillingDetails(pdMain.fk_lender_id.value)" -->
<mat-option> Select </mat-option>
<mat-option (click)="selectedLender(LL)" *ngFor="let LL of lenderList" [value]="LL.entity_id" >

View File

@ -852,8 +852,10 @@ export class AddPdComponent implements OnInit, OnDestroy {
}
});
}
getContactPerson(){
getContactPerson(flag?){
if(flag == 1){ //FOR IDENTIFY THE LENDER NAME CHANGE TO RESET THE BRANCH
this._PDtriggerForm.controls['pd_branch_id'].setValue(null);
}
if(this._PDtriggerForm.value.fk_lender_id !=null ){
let lender_filter= this.checkLender(this._PDtriggerForm.value.fk_lender_id)
@ -884,14 +886,23 @@ export class AddPdComponent implements OnInit, OnDestroy {
}
// if( this._PDtriggerForm.value.pd_branch_id !=null){
let param={fk_lender_id:this._PDtriggerForm.value.fk_lender_id}
let param={fk_lender_id:this._PDtriggerForm.value.fk_lender_id,pd_branch_id:null}
if( this._PDtriggerForm.value.pd_branch_id !=null){
param.pd_branch_id=this._PDtriggerForm.value.pd_branch_id
}
this._pd.getLenderContactPersons(param).subscribe(result=>{
if(result['dataStatus']){
let records=result['records']
if(records.length >0){
this.sales_and_credit_person.sales_person=records.filter(val=>val.role_type == "SALES")
this.sales_and_credit_person.credit_person=records.filter(val=>val.role_type == "CREDIT")
if(this.sales_and_credit_person.credit_person.length > 0){
this._PDtriggerForm.controls['lender_credit_person'].setValue(this.sales_and_credit_person.credit_person[0].userid)
}
else{
this._PDtriggerForm.controls['lender_credit_person'].setValue(null)
}
}
}
else{

View File

@ -21,7 +21,7 @@
</mat-card-header> -->
<mat-card-content>
<mat-form-field style="width: 29%">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson();getProCusPDType($event.value)">
<mat-select placeholder="Lender Name" formControlName="fk_lender_id" (selectionChange)="getContactPerson(1);getProCusPDType($event.value)">
<mat-option>
Select
</mat-option>

View File

@ -769,8 +769,10 @@ validateAllFormFields(formGroup: any) {
}
getContactPerson(){
getContactPerson(flag?){
if(flag == 1){ //FOR IDENTIFY THE LENDER NAME CHANGE TO RESET THE BRANCH
this._EditPDtriggerForm.controls['pd_branch_id'].setValue(null);
}
if(this._EditPDtriggerForm.value.fk_lender_id !=null ){
let lender_filter= this.checkLender(this._EditPDtriggerForm.value.fk_lender_id)
@ -803,13 +805,22 @@ getContactPerson(){
}
// if(this._EditPDtriggerForm.value.pd_branch_id !=null ){
let param={fk_lender_id:this._EditPDtriggerForm.value.fk_lender_id}
let param={fk_lender_id:this._EditPDtriggerForm.value.fk_lender_id,pd_branch_id:null}
if( this._EditPDtriggerForm.value.pd_branch_id !=null){
param.pd_branch_id=this._EditPDtriggerForm.value.pd_branch_id
}
this._pd.getLenderContactPersons(param).subscribe(result=>{
if(result['dataStatus']){
let records=result['records']
if(records.length >0){
this.sales_and_credit_person.sales_person=records.filter(val=>val.role_type == "SALES")
this.sales_and_credit_person.credit_person=records.filter(val=>val.role_type == "CREDIT")
// if(this.sales_and_credit_person.credit_person.length > 0){
// this._EditPDtriggerForm.controls['lender_credit_person'].setValue(this.sales_and_credit_person.credit_person[0].userid)
// }
// else{
// this._EditPDtriggerForm.controls['lender_credit_person'].setValue(null)
// }
}
}
else{

View File

@ -184,6 +184,7 @@ export class UserService {
"fk_updatedby":updateby,
"createdon":createdon,
"updatedon":updateon,
"fk_lender_branch_id":users.fk_lender_branch_id
};
//console.log(roles);
formData.append('records',JSON.stringify(records));
@ -230,5 +231,11 @@ export class UserService {
getprofilepic(users){
return this.http.post(apiurl+'getSingedProfilePicURL',users);
}
// get lenders list
getLenderDetails(): Observable<any> {
return this.http.get<any>(apiurl + 'getListOfLenders');
}
}

View File

@ -110,7 +110,7 @@
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" *ngIf="typeValue == '2'">
<mat-select matInput placeholder="Lender Name" [formControl]="regForm.controls['lenVenName']" >
<mat-select matInput placeholder="Lender Name" [formControl]="regForm.controls['lenVenName']" (selectionChange)="getBranch()">
<mat-option>--</mat-option>
<mat-option *ngFor="let ent of entities" [value]="ent">
{{ent.full_name}}
@ -130,7 +130,7 @@
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" >
<mat-select matInput placeholder="Role" (selectionChange)="toggleAllSelection($event,regForm.controls['type'].value)" [formControl]="regForm.controls['role']" >
<mat-select matInput placeholder="Role" (selectionChange)="toggleAllSelection($event.value,regForm.controls['type'].value)" [formControl]="regForm.controls['role']" >
<mat-option *ngFor="let role of roles" [value]="role" >
{{role.role_name}}
</mat-option>
@ -140,6 +140,15 @@
<mat-error *ngIf="regForm.controls['role'].hasError('required') && regForm.controls['role'].touched" class="mat-text-warn">User Role Required</mat-error>
<mat-error *ngIf="regForm.controls['role'].errors?.phone && regForm.controls['role'].touched" class="mat-text-warn">User Role Required</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" *ngIf="enableBranch">
<mat-select matInput placeholder="Branch" [formControl]="regForm.controls['fk_lender_branch_id']" >
<mat-option *ngFor="let branch of branchList" [value]="branch.entity_lender_branch_id" >
{{branch.branch_name}}
</mat-option>
</mat-select>
<mat-error *ngIf="regForm.controls['fk_lender_branch_id'].hasError('required')" class="mat-text-warn">Branch is Required</mat-error>
</mat-form-field>
<mat-form-field dividerColor="primary" class="ml-xs mr-xs" *ngIf="roleAccess">
<mat-select matInput placeholder="PD Team" [formControl]="regForm.controls['pdteam']" >
<mat-option>--</mat-option>

View File

@ -60,6 +60,9 @@ export class RegisterComponent implements OnInit {
entitiesDetails:any;
entities:any;
notifier:NotifierService;
entity_for_branch: any;
branchList: any;
enableBranch: boolean=false;
constructor(
private router: Router, public fb: FormBuilder, public AWS: AwsService, private cd: ChangeDetectorRef
,private elementRef: ElementRef,public users:UserService,notifier:NotifierService) {
@ -90,7 +93,7 @@ export class RegisterComponent implements OnInit {
isactive: [true],
pdteam:[null],
pdtype:[null],
fk_lender_branch_id:[null]
});
this.userupdate();
@ -154,6 +157,12 @@ export class RegisterComponent implements OnInit {
this.entitiesDetails = this.entitiesDetails.records;
}
})
this.users.getLenderDetails().subscribe(res=>{
this.entity_for_branch=res
if(this.entity_for_branch.dataStatus == true){
this.entity_for_branch = this.entity_for_branch.records;
}
})
}
@ -246,8 +255,8 @@ console.log("cog",userData,this.usersData)
}
}
toggleAllSelection(e,enitiyid) {
// console.log(enitiyid);
toggleAllSelection(e,enitiyid,flag?) {
console.log(enitiyid,e);
// if(e.value){
// if(e.value.role_name == pdoff && enitiyid.entity_type_id == 1){
@ -257,23 +266,48 @@ console.log("cog",userData,this.usersData)
// this.roleAccess = false;
// }
// }
if (this.usersData != '' && this.usersData !==undefined || e.value.role_name == pdoff && enitiyid.entity_type_id == 1 || e.value.role_name == pdexu && enitiyid.entity_type_id == 1) {
if (this.usersData != '' && this.usersData !==undefined || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1) {
if(e.role_name == pdoff && enitiyid.entity_type_id == 1 ||e.role_name == pdexu && enitiyid.entity_type_id == 1 || e.value.role_name == pdoff && enitiyid.entity_type_id == 1 || e.value.role_name == pdexu && enitiyid.entity_type_id == 1){
if(e.role_name == pdoff && enitiyid.entity_type_id == 1 ||e.role_name == pdexu && enitiyid.entity_type_id == 1 || e.role_name == pdoff && enitiyid.entity_type_id == 1 || e.role_name == pdexu && enitiyid.entity_type_id == 1){
this.roleAccess = true;
}else{
this.roleAccess = false;
}
}else{
}else{
this.roleAccess = false;
}
this.getBranch(flag);
}
getBranch(flag?){
if(this.regForm.value.role != null && (this.regForm.value.role.role_name == "Branch Credit" || this.regForm.value.role.role_name == "Branch Sales") && this.regForm.value.lenVenName != null){
console.log(this.regForm.value.role,this.entity_for_branch,this.regForm.value.lenVenName);
if(this.entity_for_branch.length > 0){
this.enableBranch=true
// this.branchList=this.entity_for_branch
this.branchList=this.entity_for_branch.filter(val=>val.short_name == this.regForm.value.lenVenName.short_name).map(b=>b.branches)
console.log("dgg",this.branchList)
if(this.branchList.length > 0){
this.branchList=this.branchList[0]
if(flag == 1){ // for edit purpose
console.log(this.usersData.fk_lender_branch_id)
this.regForm.controls['fk_lender_branch_id'].setValue(this.usersData.fk_lender_branch_id)
}
else{
this.regForm.controls['fk_lender_branch_id'].setValue(null);
}
this.regForm.controls['fk_lender_branch_id'].setValidators(Validators.required)
}
}
}
else{
this.regForm.controls['fk_lender_branch_id'].clearValidators()
this.enableBranch=false
this.branchList=[]
this.regForm.controls['fk_lender_branch_id'].setValue(null);
}
}
getcity(e){
// console.log(e);
// console.log(this.Cities);
@ -355,6 +389,14 @@ console.log("cog",userData,this.usersData)
this.regForm.controls['pdtype'].setValue(pdtype);
}
});
this.users.getLenderDetails().subscribe(res=>{
this.entity_for_branch=res
if(this.entity_for_branch.dataStatus == true){
this.entity_for_branch = this.entity_for_branch.records;
// this.getBranch(1); //for edit functionality
}
})
let users= {
'userid':this.usersData.userid,
@ -399,6 +441,7 @@ console.log("cog",userData,this.usersData)
* params are flag are if 1 - add and 2 - edit
**/
callrole(flag,type,usersData){
console.log(this.usersData)
this.users.roles().subscribe(res=>{
this.roleload = false;
@ -413,7 +456,7 @@ callrole(flag,type,usersData){
let role = this.role.filter(role=>role.role_type == usersData.fk_entity_type_id && role.role_id == usersData.user_role)[0];
this.regForm.controls['role'].setValue(role);
this.toggleAllSelection(role,type);
this.toggleAllSelection(role,type,1);
// this.regForm.controls['role'].setValue(role);
}