latest issues
This commit is contained in:
parent
1fce773507
commit
baa487c48f
@ -24,8 +24,7 @@ export class DynamicFormComponent implements OnInit {
|
|||||||
constructor(private _fb:FormBuilder,private questionService:QuesFormService) { }
|
constructor(private _fb:FormBuilder,private questionService:QuesFormService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
console.log('answers');
|
|
||||||
//console.log(this.json_answers[0].stakeholder_length)
|
|
||||||
this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions)
|
this.form_group_name=this.questionService.assignFormControl_array(this.form_group_name,this.questions_JSON.questions)
|
||||||
|
|
||||||
this.generateGroupControls();
|
this.generateGroupControls();
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { }
|
constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.parent_ques = this.currFormArrayObj
|
this.parent_ques = this.currFormArrayObj
|
||||||
if(this.parent_ques.type == '9' && this.parent_ques.answers && this.parent_ques.answers.length > 0) {
|
if(this.parent_ques.type == '9' && this.parent_ques.answers && this.parent_ques.answers.length > 0) {
|
||||||
this.autoCompleteAns =this.formGroupN.get(this.parent_ques.question_key).valueChanges.pipe(
|
this.autoCompleteAns =this.formGroupN.get(this.parent_ques.question_key).valueChanges.pipe(
|
||||||
@ -46,6 +47,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
|
//alert('ans');
|
||||||
this.parent_ques = this.currFormArrayObj
|
this.parent_ques = this.currFormArrayObj
|
||||||
|
|
||||||
this.json_answers1=[{
|
this.json_answers1=[{
|
||||||
@ -95,7 +97,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
company_name: 2},{
|
company_name: 2},{
|
||||||
stakeholder_name0: "SUMIT KHANDELWAL",
|
stakeholder_name0: "SUMIT KHANDELWAL",
|
||||||
share_holding0: 25,
|
share_holding0: 25,
|
||||||
vintage_in_current_biz0: 7,
|
vintage_in_current_biz0: 7,
|
||||||
total_work_exp0: 12,
|
total_work_exp0: 12,
|
||||||
started_biz0: "",
|
started_biz0: "",
|
||||||
|
|
||||||
@ -135,6 +137,8 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
|||||||
|
|
||||||
// debugger;
|
// debugger;
|
||||||
|
|
||||||
|
this.formGroupN.get(this.parent_ques.question_key)
|
||||||
|
|
||||||
this.whole_form.get(this.group_key).patchValue(this.json_answers)
|
this.whole_form.get(this.group_key).patchValue(this.json_answers)
|
||||||
if(this.json_answers.length > 1) {
|
if(this.json_answers.length > 1) {
|
||||||
this.generateGroupControls.emit()
|
this.generateGroupControls.emit()
|
||||||
|
|||||||
@ -14,6 +14,7 @@ export class QuesFormService {
|
|||||||
ques_data_company:any;
|
ques_data_company:any;
|
||||||
company_name:any;
|
company_name:any;
|
||||||
length:any;
|
length:any;
|
||||||
|
|
||||||
len:any;
|
len:any;
|
||||||
formanswers=null;
|
formanswers=null;
|
||||||
pd_all_details:any= {}
|
pd_all_details:any= {}
|
||||||
@ -41,13 +42,13 @@ export class QuesFormService {
|
|||||||
|
|
||||||
ques_length(length1: any)
|
ques_length(length1: any)
|
||||||
{
|
{
|
||||||
this.len=length1;
|
this.len=length1;
|
||||||
|
|
||||||
// return length1;
|
|
||||||
}
|
}
|
||||||
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
||||||
|
|
||||||
const control: any = formgroup
|
const control: any = formgroup
|
||||||
|
|
||||||
ques_data.forEach((val, index) => {
|
ques_data.forEach((val, index) => {
|
||||||
|
|
||||||
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
||||||
@ -60,19 +61,9 @@ export class QuesFormService {
|
|||||||
|
|
||||||
control.addControl(val.group_key, this._fb.array([]))
|
control.addControl(val.group_key, this._fb.array([]))
|
||||||
|
|
||||||
|
|
||||||
let childControl: any = control.get(val.group_key) as FormArray
|
let childControl: any = control.get(val.group_key) as FormArray
|
||||||
|
|
||||||
//let childControl1: any = control.get(val.value) as FormArray
|
|
||||||
// const formControlArray = [];
|
|
||||||
// FormArray.forEach(data => {
|
|
||||||
// formControlArray.push(new FormControl(data.value));
|
|
||||||
// })
|
|
||||||
// console.log('tamil');
|
|
||||||
// console.log(formControlArray);
|
|
||||||
//formgroup = new FormGroup ({
|
|
||||||
// data: this.fb.array(formControlArray)
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
// childControl.push(this._fb.group({ 'questions': this._fb.array([]) }))
|
// childControl.push(this._fb.group({ 'questions': this._fb.array([]) }))
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import { QuesFormService } from '../dynamic-form/ques-form/ques-form.service';
|
|||||||
styleUrls: ['./form.component.scss'],
|
styleUrls: ['./form.component.scss'],
|
||||||
})
|
})
|
||||||
export class FormComponent implements OnInit {
|
export class FormComponent implements OnInit {
|
||||||
|
anslength:any;
|
||||||
form_id: number;
|
form_id: number;
|
||||||
parent_pdid: any;
|
parent_pdid: any;
|
||||||
pdid: any;
|
pdid: any;
|
||||||
@ -29,7 +30,7 @@ export class FormComponent implements OnInit {
|
|||||||
image_doc_params: { pdid: any; form_id: any; company_id: string; };
|
image_doc_params: { pdid: any; form_id: any; company_id: string; };
|
||||||
questions_JSON: any = {questions:[],section_name:''};
|
questions_JSON: any = {questions:[],section_name:''};
|
||||||
commonFormGroup:FormGroup;
|
commonFormGroup:FormGroup;
|
||||||
form_answers: any;
|
|
||||||
@Input() json_answers:any;
|
@Input() json_answers:any;
|
||||||
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
|
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
|
||||||
is_loading: boolean = false;
|
is_loading: boolean = false;
|
||||||
@ -65,16 +66,93 @@ export class FormComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.loadTemplate()
|
|
||||||
console.log("answered",this.pd_all_details.is_answered)
|
if(this.pd_all_details.form_id=='5' && this.pd_all_details.pdmaster_details.product_abbr=='LFMP')
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let params = {"fk_pd_id":this.pd_all_details.pdmaster_details.pd_id,"fk_form_id":this.pd_all_details.form_id}
|
||||||
|
|
||||||
|
this.pdTriggerService.getSMCCreditPDSectionData(params).subscribe(result=>{
|
||||||
|
|
||||||
|
if(result['dataStatus']) {
|
||||||
|
|
||||||
|
|
||||||
|
let records = result['records']
|
||||||
|
let formValues:any ={};
|
||||||
|
|
||||||
|
if(records && records.hasOwnProperty('json') && records.json) {
|
||||||
|
formValues = JSON.parse(records.json)
|
||||||
|
if(formValues.key_stakeholders[0].stakeholder_length=='2')
|
||||||
|
{
|
||||||
|
let controlcount='2';
|
||||||
|
this.quesService.ques_length(controlcount)
|
||||||
|
this.loadTemplate()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let controlcount1='3';
|
||||||
|
this.quesService.ques_length(controlcount1)
|
||||||
|
this.loadTemplate()
|
||||||
|
}
|
||||||
|
// if(formValues.key_stakeholders[0].stakeholder_length=="undefined")
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
let params = {"pd_id":this.pd_all_details.pdmaster_details.pd_id,"random_string":this.pd_all_details.pdmaster_details.random_string,"form_id":this.pd_all_details.form_id}
|
||||||
|
this.pdTriggerService.loadDataFromExcel(params).subscribe(result=>{
|
||||||
|
if(result['dataStatus']) {
|
||||||
|
let records = result['records']
|
||||||
|
let formValues1:any ={};
|
||||||
|
if(records ) {
|
||||||
|
formValues1 = records
|
||||||
|
if(formValues1.key_stakeholders[0].stakeholder_length=='2')
|
||||||
|
{
|
||||||
|
let controlcount='2';
|
||||||
|
this.quesService.ques_length(controlcount)
|
||||||
|
this.loadTemplate()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let controlcount1='3';
|
||||||
|
this.quesService.ques_length(controlcount1)
|
||||||
|
this.loadTemplate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if(this.pd_all_details.is_answered == '1') {
|
if(this.pd_all_details.is_answered == '1') {
|
||||||
this.getSectionData()
|
this.getSectionData()
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.getExcelData();
|
this.getExcelData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
this.loadTemplate()
|
||||||
|
if(this.pd_all_details.is_answered == '1') {
|
||||||
|
this.getSectionData()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.getExcelData();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
loadTemplate() {
|
loadTemplate() {
|
||||||
|
|
||||||
this.is_loading = true
|
this.is_loading = true
|
||||||
// let localId = this.getLocalFormId()
|
// let localId = this.getLocalFormId()
|
||||||
// console.log("d",this.pd_all_details.form_id,Number(this.pd_all_details.form_id))
|
// console.log("d",this.pd_all_details.form_id,Number(this.pd_all_details.form_id))
|
||||||
@ -88,12 +166,13 @@ export class FormComponent implements OnInit {
|
|||||||
let question_template: any = result.records
|
let question_template: any = result.records
|
||||||
if (question_template && question_template != null && question_template != undefined
|
if (question_template && question_template != null && question_template != undefined
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// question_template = JSON.parse(question_template)
|
// question_template = JSON.parse(question_template)
|
||||||
if (question_template.hasOwnProperty('template') && question_template.template) {
|
if (question_template.hasOwnProperty('template') && question_template.template) {
|
||||||
question_template =JSON.parse(question_template.template);
|
question_template =JSON.parse(question_template.template);
|
||||||
this.commonFormGroup = new FormGroup({})
|
this.commonFormGroup = new FormGroup({})
|
||||||
this.questions_JSON = question_template;
|
this.questions_JSON = question_template;
|
||||||
// console.log(this.questions_JSON);
|
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
// this.covidAnswers = null
|
// this.covidAnswers = null
|
||||||
// console.log("cleared")
|
// console.log("cleared")
|
||||||
@ -138,20 +217,6 @@ export class FormComponent implements OnInit {
|
|||||||
if(records && records.hasOwnProperty('json') && records.json) {
|
if(records && records.hasOwnProperty('json') && records.json) {
|
||||||
formValues = JSON.parse(records.json)
|
formValues = JSON.parse(records.json)
|
||||||
|
|
||||||
console.log('getsectionn');
|
|
||||||
console.log(formValues);
|
|
||||||
console.log(formValues.key_stakeholders[0].stakeholder_length);
|
|
||||||
if(formValues.key_stakeholders[0].stakeholder_length=='2')
|
|
||||||
{
|
|
||||||
let controlcount='2';
|
|
||||||
this.quesService.ques_length(controlcount)
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
let controlcount1='3';
|
|
||||||
this.quesService.ques_length(controlcount1)
|
|
||||||
}
|
|
||||||
this.quesService.formanswers= formValues
|
this.quesService.formanswers= formValues
|
||||||
this.loaderService.showMatSpinnerDialog("")
|
this.loaderService.showMatSpinnerDialog("")
|
||||||
// setTimeout(()=>{
|
// setTimeout(()=>{
|
||||||
@ -178,20 +243,7 @@ export class FormComponent implements OnInit {
|
|||||||
let formValues:any ={};
|
let formValues:any ={};
|
||||||
if(records ) {
|
if(records ) {
|
||||||
formValues = records
|
formValues = records
|
||||||
console.log('excel');
|
|
||||||
console.log(formValues)
|
|
||||||
if(formValues.key_stakeholders[0].stakeholder_length=='2')
|
|
||||||
{
|
|
||||||
let controlcount='2';
|
|
||||||
this.quesService.ques_length(controlcount)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
let controlcount1='3';
|
|
||||||
this.quesService.ques_length(controlcount1)
|
|
||||||
}
|
|
||||||
let datalength=formValues.key_stakeholders[0]
|
|
||||||
console.log(Object.keys(datalength).length);
|
|
||||||
|
|
||||||
// records.forEach(val=>{
|
// records.forEach(val=>{
|
||||||
// if(val) {
|
// if(val) {
|
||||||
@ -314,7 +366,7 @@ export class FormComponent implements OnInit {
|
|||||||
saveForm() {
|
saveForm() {
|
||||||
|
|
||||||
|
|
||||||
console.log("values",this.commonFormGroup.getRawValue(),this.questions_JSON)
|
//console.log("values",this.commonFormGroup.getRawValue(),this.questions_JSON)
|
||||||
if(this.commonFormGroup.invalid) {
|
if(this.commonFormGroup.invalid) {
|
||||||
this.commonFormGroup.markAsDirty();
|
this.commonFormGroup.markAsDirty();
|
||||||
this.commonFormGroup.markAsTouched()
|
this.commonFormGroup.markAsTouched()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user