簡體   English   中英

當點擊按鈕“重新安排預定服務”時,微調器繼續加載

[英]when clicked on button "reschedule scheduled service" spinner keeps on loading

試圖重新安排 calim 但是當點擊按鈕微調器繼續旋轉並且無法重新安排

查看錯誤的屏幕截圖

Creatfurniturecontroller.js

({
verifyIndependentServicerPermset : function(component, event, helper) {
    var independentServicerAccessAction = component.get('c.hasAccessToIndependentServicerPermset');
    independentServicerAccessAction.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            var hasPermset = response.getReturnValue();
            component.set('v.hasPermsetForIndependentServicer', hasPermset);                
        } else {
            console.log(response.getError());
        }
    });
    $A.enqueueAction(independentServicerAccessAction);
},
fetchCaseData : function(component, event, helper) {
    var caseRecord = component.get('v.caseRecord');
    var newCaseId = caseRecord.recordId; 
    var retrieveCaseAction = component.get('c.retrieveCaseObject');
    var actionParams = {'caseId':newCaseId};
    retrieveCaseAction.setParams(actionParams);
    retrieveCaseAction.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            var result = response.getReturnValue();
            //console.log('RESULT: ' + JSON.stringify(result));
            var currentCaseRecord = component.get('v.caseRecord');
            result.label = currentCaseRecord.label;
            result.recordId = currentCaseRecord.recordId;
            component.set('v.caseRecord', result);
            component.set('v.isLoading', false);
        } else {
            console.log(response.getError());
        }
    });
    $A.enqueueAction(retrieveCaseAction);
},
getScheduleServiceWrapperInfo : function(component) {
    component.set('v.isLoading',true);
    var claimRecordId = component.get('v.recordId');
    var action = component.get('c.getScheduleServiceWrapper');
    action.setParams({
        "claimRecordId":claimRecordId
    });
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            var scheduleServiceWrapper = response.getReturnValue();
            component.set('v.scheduleService',scheduleServiceWrapper);

            component.set('v.scheduleService.Comments','');
            if(scheduleServiceWrapper.Servicer){
                component.set('v.isIndependentServicerChecked',true);
            } else {
                this.getFurnitureServiceRoutesInfo(component);
            }
            this.isIndependentServicerCheckedChanged(component);
        } else {
            console.log(response.getError());
        }
    });
    $A.enqueueAction(action);
},
closeModal: function(component, event, helper) {
    component.set("v.showModal", false);
},
getFurnitureServiceRoutesInfo : function(component) {
    component.set('v.isLoading',true);
    
    var startDate = component.get('v.scheduleService.StartDate');
    var numberOfDays = component.get('v.scheduleService.NumberOfDays');
    var zipCode = component.get('v.scheduleService.ZipCode');

    var action = component.get('c.getFurnitureServiceRoutes');
    action.setParams({
        "startDate":startDate,
        "numberOfDays" : numberOfDays,
        "zipCode" : zipCode
    });
    action.setCallback(this, function(response) {
        component.set('v.isLoading',false);
        var state = response.getState();
        if (state === "SUCCESS") {
            var furnitureServiceRoutesList = response.getReturnValue();
            if(furnitureServiceRoutesList && furnitureServiceRoutesList.length > 0){
                var routeCodesList = [];
                var routeCodeObjectMap = new Map();
                var i = 0;
                for (i = 0; i < furnitureServiceRoutesList.length; i++) {
                    routeCodesList.push(
                        {
                            'label' : furnitureServiceRoutesList[i].RouteCode__c + ' | ' + furnitureServiceRoutesList[i].RouteDescription__c,
                            'value' : furnitureServiceRoutesList[i].RouteCode__c
                        }
                    );
                    routeCodeObjectMap.set(furnitureServiceRoutesList[i].RouteCode__c, furnitureServiceRoutesList[i]);
                }
                component.set('v.routeCodeObjectMap', routeCodeObjectMap);
                component.set('v.routeCodesList',routeCodesList);
                component.set('v.selectedRouteCode',routeCodesList[0].value);
                component.set('v.routeCodeDescription',routeCodeObjectMap.get(routeCodesList[0].value).RouteDescription__c);
                this.getFurnitureServiceAppointmentsInfo(component);
            } else {
                this.displayToast('Warning', 'No routes were found for that combination.','warning');
            }
        } else {
            console.log(response.getError());
        }
    });
    $A.enqueueAction(action);
},
getFurnitureServiceAppointmentsInfo : function(component) {
    //component.set('v.isLoading',true);
    
    var startDate = component.get('v.scheduleService.StartDate');
    var numberOfDays = component.get('v.scheduleService.NumberOfDays');
    var zipCode = component.get('v.scheduleService.ZipCode');
    var routeCode = component.get('v.selectedRouteCode');

    var action = component.get('c.getFurnitureServiceAppointments');
    action.setParams({
        "startDate":startDate,
        "numberOfDays" : numberOfDays,
        "zipCode" : zipCode,
        "routeCode" : routeCode
    });
    action.setCallback(this, function(response) {
        component.set('v.isLoading',false);
        var state = response.getState();
        if (state === "SUCCESS") {
            var furnitureServiceAppointmentsList = response.getReturnValue();
            if(furnitureServiceAppointmentsList && furnitureServiceAppointmentsList.length > 0){
                var serviceDatesObjectList = [];
                var i = 0;
                for (i = 0; i < furnitureServiceAppointmentsList.length; i++) {
                    var serviceDate = furnitureServiceAppointmentsList[i].ServiceDate__c.substring(0,10);
                    serviceDatesObjectList.push(
                        {
                            'date' : this.formatServiceDate(serviceDate),
                            'value' : furnitureServiceAppointmentsList[i].ServiceDate__c.substring(0,10),
                            'weekday' : this.getDayOfWeek(serviceDate),
                            'appointmentUnits' : furnitureServiceAppointmentsList[i].AppointmentUnits__c
                        }
                    );
                }
                component.set('v.serviceDatesObjectList',serviceDatesObjectList);
            }
        } else {
            console.log(response.getError());
        }
    });
    $A.enqueueAction(action);
},

createFurnitureServiceInfo : function(component) {
    var scheduleServiceWrapper = component.get('v.scheduleService');
    var scheduleServiceWrappperComments = scheduleServiceWrapper.Comments.replace(/\\/g, '');
    var escapedComments = this.encodeSpecialCharacters(scheduleServiceWrappperComments);
    scheduleServiceWrapper.Comments = escapedComments;
    scheduleServiceWrapper.ButtonLabel = component.get('v.buttonLabel');
    component.set('v.isLoading',true);
    var isIndependentServicer = component.get('v.isIndependentServicerChecked');
    var independentServicer = component.get('v.independentServicer');
    var action = component.get('c.createFurnitureServices');
    var parameters = {
        "scheduleServiceJSON": JSON.stringify(scheduleServiceWrapper),
        "independentServicerJSON": JSON.stringify(independentServicer),
        "isIndependentServicer": isIndependentServicer
    };
    //console.log('params: ' + JSON.stringify(parameters));
    action.setParams(parameters);
    action.setCallback(this, function(response) {
        component.set('v.isLoading',false);
        var state = response.getState();
        if (state === "SUCCESS") {
            this.displayToast('Success', 'The service has been successfully scheduled.','success');
            var navEvt = $A.get("e.force:navigateToSObject");
            navEvt.setParams({
                "recordId": response.getReturnValue(),
                "slideDevName": "detail"
            });
            this.closeModal(component);

            this.refreshFurnitureServiceRecord();
            navEvt.fire();
        } else {
            console.error(response.getError());
            this.displayToast('Error', 'Something went wrong, the service was NOT scheduled. Please verify zip code and additional address fields.','error');
        }            
    });
    $A.enqueueAction(action);
},
refreshFurnitureServiceRecord : function() {
    window.setTimeout(
        $A.getCallback(function() {
            var refreshFurnitureServiceEvent = $A.get("e.c:refreshFurnitureServiceEvent");
            refreshFurnitureServiceEvent.fire();
        }), 2000
    );
},
getDayOfWeek : function(serviceDate) {
    var momentDate = moment(serviceDate);
    var weekDay = momentDate.format('dddd');
    return weekDay;
},
formatServiceDate : function(serviceDate) {
    return serviceDate.substring(5, 7) + '/' + serviceDate.substring(8, 10) + '/' + serviceDate.substring(0, 4);
},
displayToast : function(title, message, type, mode){
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        title : title,
        message: message,
        duration:' 5000',
        key: 'info_alt',
        type: type,
        mode: mode ? mode : 'pester'
    });
    toastEvent.fire();
},
getRelatedCase : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.getFocusedTabInfo().then(function(response) {
        //console.log(JSON.parse(JSON.stringify(response)));
        var parentTabId = response.parentTabId;
        workspaceAPI.getTabInfo({
            tabId: parentTabId
        }).then(function(parentTabResponse) {
            var parentTabObjectAPIName = parentTabResponse.pageReference.attributes.objectApiName;
            //console.log(parentTabObjectAPIName);
            // If the parent tab is a Case record
            if(parentTabObjectAPIName === "Case"){
                var caseRecord = {
                    "recordId" : parentTabResponse.recordId,
                    "label" : parentTabResponse.title
                }
                component.set('v.caseRecord',caseRecord);
            } else {
                // If the parent tab is not a Case record
                var relatedSubTabs = parentTabResponse.subtabs;
                for (let i = 0; i < relatedSubTabs.length; i++) {
                    var subtab = relatedSubTabs[i];
                    var subTabObjectAPIName = subtab.pageReference.attributes.objectApiName;
                    if(subTabObjectAPIName === "Case"){
                        var caseRecord = {
                            "recordId" : subtab.recordId,
                            "label" : subtab.title
                        }
                        component.set('v.caseRecord',caseRecord);
                    }
                }
            }
            helper.fetchCaseData(component, event, helper);
        });
    })
    .catch(function(error) {
        console.log(error);
    });
},

isValidToSave : function(component, event, helper) {
    var validityErrors = [];
    var notPopulatedRequiredFields = [];
    var isIndependentServicer = component.get('v.isIndependentServicerChecked');
    try {  
        // validation for both: regular and independent servicer scheduling 
        let serviceDateField = isIndependentServicer ? component.find('serviceDate2') : component.find('serviceDate');
        serviceDateField.reportValidity();
        if (!serviceDateField.get('v.value')) validityErrors.push('Service Date must be selected.');
        let addressField = isIndependentServicer ? component.find('addressField2a') : component.find('addressField');
        addressField.reportValidity();
        if (!addressField.get('v.value')) notPopulatedRequiredFields.push('address');
        let zipCodeField = isIndependentServicer ? component.find('zipCodeField2') : component.find('zipCodeField');
        zipCodeField.reportValidity();
        if (!zipCodeField.get('v.value')) notPopulatedRequiredFields.push('zip code');
        let stateField = isIndependentServicer ? component.find('stateField2') : component.find('stateField');
        stateField.reportValidity();
        if (!stateField.get('v.value')) notPopulatedRequiredFields.push('state');
        let cityField = isIndependentServicer ? component.find('cityField2') : component.find('cityField');
        cityField.reportValidity();
        if (!cityField.get('v.value')) notPopulatedRequiredFields.push('city');
        // validation for independent servicer scheduling
        if (isIndependentServicer) {            
            var caseRecord = component.get('v.caseRecord');
            if (!caseRecord || !caseRecord.Id) validityErrors.push('Selecting case related to service is required.');
            if (!caseRecord.Independent_Servicer__r) {
                validityErrors.push('Independent Servicer needs to be assigned to the selected Case.');
            } else if (!caseRecord.Independent_Servicer__r.Servicer_Id__c)  {
                validityErrors.push('Independent Servicer assigned to the selected Case needs to have Servicer Id value.');
            }
            let callBackContactField = component.find('callBackContact');
            callBackContactField.reportValidity();
            if (!callBackContactField.get('v.value')) notPopulatedRequiredFields.push('contact');
            let callBackNumberField = component.find('callBackNumber');
            callBackNumberField.reportValidity();
            if (!callBackNumberField.get('v.value')) {
                notPopulatedRequiredFields.push('phone');
            } else if (callBackNumberField.get('v.value').length != 10) {
                validityErrors.push('Phone field must be 10 digits long.');
            }
        } else {
            // validation for regular scheduling
            var routeCode = component.get('v.selectedRouteCode');
            if($A.util.isUndefinedOrNull(routeCode) || $A.util.isEmpty(routeCode) || routeCode.trim() == ''){
                validityErrors.push('A Route code is required.');
            }
            var selectedAvailableAppointmentUnits = Number(component.get('v.selectedAppointmentUnits'));
            var availableUnits = Number(component.get('v.scheduleService.AppointmentUnits'));
            if(availableUnits > selectedAvailableAppointmentUnits){
                validityErrors.push('There is not enough appointment units available for the selected service date.');
            }
        }
        if (isIndependentServicer) {            
            if (notPopulatedRequiredFields.length > 0) validityErrors.push('You need to populate those fields on the selected case: ' + notPopulatedRequiredFields.join(', ') + '.');
        } else {
            if (notPopulatedRequiredFields.length > 0) validityErrors.push('You need to populate those fields: ' + notPopulatedRequiredFields.join(', ') + '.');
        }
    } catch(err) {
        console.error(err);
    }
    return validityErrors;
},
isIndependentServicerCheckedChanged : function(component, event, helper) {
    let checkboxValue = component.get('v.isIndependentServicerChecked');
    try{
        // If the checkbox was checked
        if(checkboxValue){
            // Set service date as current date
            component.set('v.selectedServiceDate', new Date().toISOString().slice(0, 10));
            let caseRecord = component.get('v.caseRecord');
            let scheduleService = component.get('v.scheduleService');
            // If this property is already filled, it means the service was already scheduled once, so we should consider data from POPS
            if(scheduleService.Servicer){
                let independentServicer = {
                    CustomerName  : scheduleService.CustomerName,
                    Address : scheduleService.Address,
                    ZipCode :  scheduleService.ZipCode,
                    State :  scheduleService.State,
                    City :  scheduleService.City,
                    ContactPhone :  scheduleService.ContactPhone,
                    ContactPhoneExtension :  scheduleService.ContactPhoneExtension,
                    Servicer : caseRecord.Independent_Servicer__r.Servicer_Id__c,
                    CaseId : caseRecord.Id
                };
                component.set('v.independentServicer',independentServicer);
            } else {
                // This means it's the first time creating the independent servicer furniture service, so we should consider data from the associated Case
                let independentServicer = {
                    CustomerName  : caseRecord.Call_Back_Contact__c,
                    Address : caseRecord.Shipping_Address_1__c,
                    ZipCode : caseRecord.Shipping_Postal_Code__c,
                    State :  caseRecord.Shipping_State__c,
                    City :  caseRecord.Shipping_City__c,
                    ContactPhone :  caseRecord.Requested_Call_Back_Number__c,
                    ContactPhoneExtension :  caseRecord.Requested_Call_Back_Number_Ext__c,
                    Servicer : caseRecord.Independent_Servicer__r.Servicer_Id__c,
                    CaseId : caseRecord.Id
                };
                component.set('v.independentServicer',independentServicer);
            }
        } else {
            component.set('v.selectedServiceDate', null);
        }
    } catch (err) {
        console.error(err);
    }
    
}

})

單擊重新安排微調器時不應連續旋轉

在此處輸入圖像描述

在此處輸入圖像描述

應該可以改期

需要更多信息(但評論時間太長)。

單擊該按鈕(快速操作?)時調用哪個 JS function? 看起來您沒有遵循習慣的{.c.doInit}命名約定。

您粘貼了很多代碼, servicer_id__c出現在 3 個地方。 下次嘗試削減無用的部分,直到剩下Minimal Reproducible Example

檢查 Apex Developer Console 是否有錯誤/問題,也許其中一個函數真正返回 null/拋出錯誤:

  • 缺少運行此頂點的權限 class
  • 非常糟糕的數據(沒有填充一些查找的情況?)
  • 也許你小心地創建了一個包裝器 class 來保存從頂點返回的東西 - 但你忘了將每個字段標記為公共和@AuraEnabled

我懷疑錯誤代碼出現在caseRecord.Independent_Servicer__r.Servicer_Id__c中的 caseRecord.Independent_Servicer__r.Servicer_Id__c 等地方。 您不檢查中間部分是否為 null。三元運算符或可選鏈接可以使其更容易被發現。

啟用設置 -> 調試模式(如果尚未完成),下次只需單擊 JavaScript 控制台中記錄的錯誤。 您將被帶到源代碼中它發生的那一行。 它看起來不像您的源代碼(SF 稍微轉譯並將多個文件合並為 1 個文件)但它應該足夠接近以便您識別並修復錯誤。 或者至少放置一些斷點/手表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM