Sapui5 ODATA忙指标对话框不显示

时间:2017-05-30 14:39:28

标签: javascript jquery odata sapui5

我的代码存在问题,当我点击"保存"时,我需要显示一个忙碌的对话框,但它没有显示我不知道为什么,我搜索了5天没有任何帮助我,我尝试了异步发布,延迟通话和其他事情来使这项工作。

Button

在图像上,当我点击按钮" Guardar"之后,我需要在服务器通信启动时显示一个忙碌的对话框,我所拥有的代码是下一个:

onSaveRaw: function(oEvent) {

        var that = this;
        var ILgort = this.byId("sAlmacen_id").getValue();
        var IWerks = this.byId("sCentro_id").getValue();
        var IFechaoper = this.byId("sDate_id").getValue();
        var RecTemm = this.byId("sTemm_id").getValue();
        var RecTemt = this.byId("sTemt_id").getValue();
        var RecDeno = this.byId("sDeno_id").getValue();
        var RecPorc = this.byId("sPorc_id").getValue();
        var RecPres = this.byId("sPres_id").getValue();
        var RecHume = this.getView().byId("_select0").getSelectedKey();
        var RecAgua = this.getView().byId("_select1").getSelectedKey();

        if (this.validarCampoRequerido(ILgort)) {
            return;
        }
        if (this.validarCampoRequerido(IWerks)) {
            return;
        }
        if (this.validarCampoRequerido(IFechaoper)) {
            return;
        }
        if (this.validarCampoRequerido(RecTemm)) {
            return;
        }
        if (this.validarCampoRequerido(RecTemt)) {
            return;
        }
        if (this.validarCampoRequerido(RecDeno)) {
            return;
        }
        if (this.validarCampoRequerido(RecPorc)) {
            return;
        }
        if (this.validarCampoRequerido(RecPres)) {
            return;
        }
        //Creación del catalogo de datos del formulario.
        var dialog = new sap.m.Dialog({
            title: "Confirmación",
            type: "Message",
            state: "Warning",
            content: new sap.m.Text({
                text: "Se generará el documento de inventario. ¿Desea continuar?"
            }),
            beginButton: new sap.m.Button({
                text: "Guardar",
                press: function() {
                    var oData = {
                        "ILgort": ILgort,
                        "IWerks": IWerks,
                        "IFechainv": IFechaoper,
                        "ICharact010": RecTemm,
                        "ICharact020": RecTemt,
                        "ICharact030": RecDeno,
                        "ICharact040": RecPorc,
                        "ICharact050": RecPres,
                        "ICharact080": RecHume,
                        "ICharact090": RecAgua
                    };
                    //console.log(oData);var _this = this;

                    //Se crea instancia del servicio
                    var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/XXXXXXXXX/");
                    var oGlobalBusyDialog = new sap.m.BusyDialog();
                    oGlobalBusyDialog.open();
                    oModel.create("/LECTURATANQUESet", oData, null, function(oResponse) {
                        sap.m.MessageBox.alert(oResponse.Message, {
                            title: "Exito",
                            textDirection: sap.ui.core.TextDirection.Inherit,
                            onClose: function() {
                                that.onRefresh();
                                that._navBack();
                            }
                        });
                    }, function(oError) {
                        var oNum = oError.response.statusCode;
                        if (oNum == "500") {
                            sap.m.MessageBox.alert("Error, Sesión Finalizada por tiempo de Conexión.", {
                                title: "Error",
                                textDirection: sap.ui.core.TextDirection.Inherit,
                                onClose: function() {}

                            });

                        } else if (oNum == "504") {
                            sap.m.MessageBox.alert("Error de gateway, vuelva a intentar por favor.", {
                                title: "Error",
                                textDirection: sap.ui.core.TextDirection.Inherit,
                                onClose: function() {}

                            });

                        } else {

                            var oMsg = $(oError.response.body).find("message").first().text();
                            sap.m.MessageBox.alert(oMsg, {
                                title: "Error",
                                textDirection: sap.ui.core.TextDirection.Inherit,
                                onClose: function() {}

                            });

                        }

                    });
                    oGlobalBusyDialog.close();
                    dialog.close();
                }
            }),
            endButton: new sap.m.Button({
                text: "Cancelar",
                press: function() {
                    dialog.close();
                }
            }),
            afterClose: function() {

            }
        });
        dialog.open();

    }

如果有人可以给我任何提示,我会非常感激。

2 个答案:

答案 0 :(得分:0)

您需要在oGlobalBusyDialog.close();函数的成功和错误回调中调用create。因此,当create函数完成(成功或错误)时,您将关闭忙碌对话框。

此外,您还要删除oGlobalBusyDialog.close();事件处理程序的倒数第二行中的press

编辑(重新阅读文档后更新如何使用create

像这样使用create

oModel.create("/LECTURATANQUESet",
    oData, {
        success: successCallback,
        error: errorCallbak
    }
)

答案 1 :(得分:0)

你使用错误的BusyIndi​​cator。试试这个:

sap.ui.define([
    "sap/ui/core/BusyIndicator"
],
function (BusyIndicator) {
    BusyIndicator.show();
    //...
    BusyIndicator.hide();
});