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) { }
|
||||
|
||||
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.generateGroupControls();
|
||||
|
||||
@ -34,6 +34,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
||||
constructor(private quesService:QuesFormService,private _fb:FormBuilder, private matDialog:MatDialog, private loaderService:LoaderService) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.parent_ques = this.currFormArrayObj
|
||||
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(
|
||||
@ -46,6 +47,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
//alert('ans');
|
||||
this.parent_ques = this.currFormArrayObj
|
||||
|
||||
this.json_answers1=[{
|
||||
@ -95,7 +97,7 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
||||
company_name: 2},{
|
||||
stakeholder_name0: "SUMIT KHANDELWAL",
|
||||
share_holding0: 25,
|
||||
vintage_in_current_biz0: 7,
|
||||
vintage_in_current_biz0: 7,
|
||||
total_work_exp0: 12,
|
||||
started_biz0: "",
|
||||
|
||||
@ -134,7 +136,9 @@ export class DynamicQuestionTemplateComponent implements OnInit {
|
||||
// this.formGroupN.patchValue((this.json_answers[this.group_key] || ''))
|
||||
|
||||
// debugger;
|
||||
|
||||
|
||||
this.formGroupN.get(this.parent_ques.question_key)
|
||||
|
||||
this.whole_form.get(this.group_key).patchValue(this.json_answers)
|
||||
if(this.json_answers.length > 1) {
|
||||
this.generateGroupControls.emit()
|
||||
|
||||
@ -14,6 +14,7 @@ export class QuesFormService {
|
||||
ques_data_company:any;
|
||||
company_name:any;
|
||||
length:any;
|
||||
|
||||
len:any;
|
||||
formanswers=null;
|
||||
pd_all_details:any= {}
|
||||
@ -41,13 +42,13 @@ export class QuesFormService {
|
||||
|
||||
ques_length(length1: any)
|
||||
{
|
||||
this.len=length1;
|
||||
this.len=length1;
|
||||
|
||||
// return length1;
|
||||
}
|
||||
assignFormControl_array(formgroup: FormGroup, ques_data: any) {
|
||||
|
||||
|
||||
const control: any = formgroup
|
||||
|
||||
ques_data.forEach((val, index) => {
|
||||
|
||||
if (val.hasOwnProperty('is_repeatable') && val.is_repeatable == '1') {
|
||||
@ -59,20 +60,10 @@ export class QuesFormService {
|
||||
// }))
|
||||
|
||||
control.addControl(val.group_key, this._fb.array([]))
|
||||
|
||||
|
||||
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([]) }))
|
||||
|
||||
@ -16,6 +16,7 @@ import { QuesFormService } from '../dynamic-form/ques-form/ques-form.service';
|
||||
styleUrls: ['./form.component.scss'],
|
||||
})
|
||||
export class FormComponent implements OnInit {
|
||||
anslength:any;
|
||||
form_id: number;
|
||||
parent_pdid: any;
|
||||
pdid: any;
|
||||
@ -29,7 +30,7 @@ export class FormComponent implements OnInit {
|
||||
image_doc_params: { pdid: any; form_id: any; company_id: string; };
|
||||
questions_JSON: any = {questions:[],section_name:''};
|
||||
commonFormGroup:FormGroup;
|
||||
form_answers: any;
|
||||
|
||||
@Input() json_answers:any;
|
||||
@ViewChild(DynamicFormComponent) formComponent:DynamicFormComponent
|
||||
is_loading: boolean = false;
|
||||
@ -64,17 +65,94 @@ export class FormComponent implements OnInit {
|
||||
}
|
||||
|
||||
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') {
|
||||
this.getSectionData()
|
||||
}
|
||||
else{
|
||||
this.getExcelData();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
this.loadTemplate()
|
||||
if(this.pd_all_details.is_answered == '1') {
|
||||
this.getSectionData()
|
||||
}
|
||||
else{
|
||||
this.getExcelData();
|
||||
}
|
||||
}
|
||||
}
|
||||
loadTemplate() {
|
||||
|
||||
this.is_loading = true
|
||||
// let localId = this.getLocalFormId()
|
||||
// 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
|
||||
if (question_template && question_template != null && question_template != undefined
|
||||
) {
|
||||
|
||||
// question_template = JSON.parse(question_template)
|
||||
if (question_template.hasOwnProperty('template') && question_template.template) {
|
||||
question_template =JSON.parse(question_template.template);
|
||||
this.commonFormGroup = new FormGroup({})
|
||||
this.questions_JSON = question_template;
|
||||
// console.log(this.questions_JSON);
|
||||
|
||||
// setTimeout(() => {
|
||||
// this.covidAnswers = null
|
||||
// console.log("cleared")
|
||||
@ -137,21 +216,7 @@ export class FormComponent implements OnInit {
|
||||
let formValues:any ={};
|
||||
if(records && records.hasOwnProperty('json') && 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.loaderService.showMatSpinnerDialog("")
|
||||
// setTimeout(()=>{
|
||||
@ -178,20 +243,7 @@ export class FormComponent implements OnInit {
|
||||
let formValues:any ={};
|
||||
if(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=>{
|
||||
// if(val) {
|
||||
@ -314,7 +366,7 @@ export class FormComponent implements OnInit {
|
||||
saveForm() {
|
||||
|
||||
|
||||
console.log("values",this.commonFormGroup.getRawValue(),this.questions_JSON)
|
||||
//console.log("values",this.commonFormGroup.getRawValue(),this.questions_JSON)
|
||||
if(this.commonFormGroup.invalid) {
|
||||
this.commonFormGroup.markAsDirty();
|
||||
this.commonFormGroup.markAsTouched()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user