Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
12 kB
1
Indexable
Never
initializePrestazioneForm() {
            if(this.wind3){
                this.prestazioneFields = [
                    {
                    name: 'Service_Point_Code__c',
                    label: 'POD',
                        visible: true,
                    value: this.opportunityServiceItem ? this.opportunityServiceItem.Service_Point_Code__c : this.pod,
                        valid: true,
                        required: true,
                        disabled: true,
                        type: {
                            type: 'text'
                        }
                    },
                    {
                        name: 'Commodity__c',
                        label: 'Commodity',
                        visible: true,
                        value: this.commodity,
                        valid: true,
                        required: true,
                        disabled: true,
                        type: {
                            type: 'text'
                        }
                    },
                    {
                        name: 'ContractType__c',
                        label: 'Tipo Contratto',
                        visible: true,
                        // value: this.opportunityServiceItem ? this.opportunityServiceItem.ContractType__c : this._account && this._account.RecordType && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this._account.VATNumber__c == undefined ? 'Persona fisica' : '',
                        value: this.contractTypeValue,
                        valid: true,
                        required: this._account && this._account.RecordType && this._account.RecordType.DeveloperName && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson',
                        disabled: this.opportunityServiceItemId || (this._account && this._account.RecordType.DeveloperName && this._account.RecordType.DeveloperName == 'CEP_RT_Organization') || (this._account && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this.opportunityRecord && this.opportunityRecord.fields && this.opportunityRecord.fields.VatNumber__c && this.opportunityRecord.fields.VatNumber__c.value == undefined),
                        type: {
                            type: 'picklist',
                            typeAttributes: {
                                objectName: 'OpportunityServiceItem__c',
                                fieldName: 'ContractType__c'
                            }
                        }
                    },
                    {
                        name: 'EffectiveDate__c',
                        label: 'Data decorrenza',
                    visible: this.isGasTrue,
                        value: this.opportunityServiceItem ? this.opportunityServiceItem.EffectiveDate__c : '',
                        valid: true,
                        required: false,
                        disabled: this.opportunityServiceItemId,
                        type: {
                            type: 'date',
                        }
                    },
                    {
                        name: 'PreviousProduct__c',
                        label: 'Offerta precedente',
                        visible: false,
                        value: this.previousProductName,
                        valid: true,
                        required: false,
                        disabled: true,
                        type: {
                            type: 'text',
                        }
                    },
                    {
                        name: 'PreviousProduct',
                        label: 'Ulteriori informazioni',
                        visible: false,
                        value: 'button',
                        required: false,
                        disabled: false,
                        type: {
                            type: 'button'
                        }
                    },
                    {
                        name: 'Process__c',
                        label: 'Prestazione',
                        visible: true,
                        value: this.opportunityServiceItem ? this.opportunityServiceItem.Process__c : this.process,
                        valid: true,
                        required: true,
                        disabled: this.opportunityServiceItemId,
                        type: {
                            type: 'picklist',
                            typeAttributes: {
                            options: this.prestazioni
                            //options: this.prestazioni ? this.prestazioni : (this.commodity && this.commodity === 'Gas' ? prestazioneGasOptionList : prestazioneElectricOptionList)
                            }
                        }
                    }
                ];
    
    
            }else{
                this.prestazioneFields = [
                    {
                    name: 'Service_Point_Code__c',
                    label: 'POD',
                        visible: true,
                    value: this.opportunityServiceItem ? this.opportunityServiceItem.Service_Point_Code__c : this.pod,
                        valid: true,
                        required: true,
                        disabled: true,
                        type: {
                            type: 'text'
                        }
                    },
                    {
                        name: 'Process__c',
                        label: 'Prestazione',
                        visible: true,
                    value: this.opportunityServiceItem ? this.opportunityServiceItem.Process__c : this.process,
                        valid: true,
                        required: true,
                        disabled: this.opportunityServiceItemId,
                        type: {
                            type: 'picklist',
                            typeAttributes: {
                            options: this.prestazioni
                            //options: this.prestazioni ? this.prestazioni : (this.commodity && this.commodity === 'Gas' ? prestazioneGasOptionList : prestazioneElectricOptionList)
                            }
                        }
                    },
                    {
                        name: 'Commodity__c',
                        label: 'Commodity',
                        visible: true,
                        value: this.commodity,
                        valid: true,
                        required: true,
                        disabled: true,
                        type: {
                            type: 'text'
                        }
                    },
                    {
                        name: 'ContractType__c',
                        label: 'Tipo Contratto',
                        visible: true,
                        // value: this.opportunityServiceItem ? this.opportunityServiceItem.ContractType__c : this._account && this._account.RecordType && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this._account.VATNumber__c == undefined ? 'Persona fisica' : '',
                        value: this.contractTypeValue,
                        valid: true,
                        required: this._account && this._account.RecordType && this._account.RecordType.DeveloperName && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson',
                        disabled: this.opportunityServiceItemId || (this._account && this._account.RecordType.DeveloperName && this._account.RecordType.DeveloperName == 'CEP_RT_Organization') || (this._account && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this.opportunityRecord && this.opportunityRecord.fields && this.opportunityRecord.fields.VatNumber__c && this.opportunityRecord.fields.VatNumber__c.value == undefined),
                        type: {
                            type: 'picklist',
                            typeAttributes: {
                                objectName: 'OpportunityServiceItem__c',
                                fieldName: 'ContractType__c'
                            }
                        }
                    },
                    {
                        name: 'EffectiveDate__c',
                        label: 'Data decorrenza',
                    visible: this.isGasTrue,
                        value: this.opportunityServiceItem ? this.opportunityServiceItem.EffectiveDate__c : '',
                        valid: true,
                        required: false,
                        disabled: this.opportunityServiceItemId,
                        type: {
                            type: 'date',
                        }
                    },
                    {
                        name: 'PreviousProduct__c',
                        label: 'Offerta precedente',
                        visible: false,
                        value: this.previousProductName,
                        valid: true,
                        required: false,
                        disabled: true,
                        type: {
                            type: 'text',
                        }
                    },
                    {
                        name: 'PreviousProduct',
                        label: 'Ulteriori informazioni',
                        visible: false,
                        value: 'button',
                        required: false,
                        disabled: false,
                        type: {
                            type: 'button'
                        }
                    },
                    
                ];
            }
     

            
        //if (!isLargeSmeUser && !isLargeAema && !isUmbriaEnergy && !isSmallBusinessUser && !isAgencyReseller && this._account && this._account.RecordType && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this._account.VATNumber__c == undefined) {
        //if (!isLargeSmeUser && !isLargeAema && !isUmbriaEnergy && !isSmallBusinessUser && !isAgencyReseller &&    && this._account && this._account.RecordType && this._account.RecordType.DeveloperName == 'CEP_RT_PhysicalPerson' && this.opportunityRecord && this.opportunityRecord.fields && this.opportunityRecord.fields.VatNumber__c && this.opportunityRecord.fields.VatNumber__c.value == undefined
        if (!isLargeSmeUser && !isLargeAema && !isUmbriaEnergy && !isSmallBusinessUser && !isAgencyReseller) {
            this.contractType = this.contractTypeValue //'Persona fisica'
        }

        // if (this.isCambioUso) {
        //     // SETTARE DIRETTAMENTE NELL'ARRAY
        //     this.prestazioneFields[0].type.typeAttributes.options = ['Cambio Uso'];
        //     this.prestazioneFields[0].disabled = this.isCambioUso;
        //     this.prestazioneFields[0].value = 'Cambio Uso';
        //     this.process = 'Cambio Uso'
        // }

        // if (!this.showCambioProdotto) {
        //     // let prestazioniNew = [];
        //     // if(this.isGas)
        //     //     prestazioniNew = ;
        //     // else prestazioniNew = prestazioneElectricOptionList.slice(0, 3);
        //     this.prestazioneFields[0].type.typeAttributes.options = this.prestazioni.filter(function (obj) {
        //         return obj.label.toLowerCase() != 'cambio prodotto';
        //     });
        //     console.log("Prestazioniiii " + JSON.stringify(this.prestazioni));
        // }

        /*cambioUsoProcess().then(result=>{
            this.prestazioneFields[1].value = result;
        });*/
        //this.prestazioneFields[1].value = 'Cambio Uso';

        if (this.isEditMode) {
            this.isPrestazioneFormValid = true;
        }

    }