找回密码
 立即注册

QQ登录

只需一步,快速开始

皮皮爸爸

注册会员

13

主题

37

帖子

98

积分

注册会员

积分
98
皮皮爸爸
注册会员   /  发表于:2022-1-18 21:36  /   查看:1486  /  回复:1
1金币
在spreadjs菜单栏中增加了保存按钮,在保存的时候,想用ajax的loading来做效果,使用了ajax的默认方法,结果不显示,求助
代码如下,红色代码为没有效果的地方,
var saveCommand = {
    "save":{
                    title: "保存",
                    iconClass: "ribbon-button-save",
                    commandName: "save",
                    execute: async (context, propertyName, fontItalicChecked) => {
                    var spread = context.getWorkbook();
                    var spreadJSON = JSON.stringify(spread.toJSON({ includeBindingSource: true }));
                    var zipJSON = gzipString(spreadJSON);
                    url = window.location.href;
                    var uid =  getParameter(url,1);
                    var accountCode =  getParameter(url,2);
                    var projectId =  getParameter(url,3);
                    $.ajax({
                            url: "/manuscript/updateAccountdraft",
                            data: {'content':zipJSON,'projectId':projectId,'accountCode':accountCode,'uid':uid},
                            dataType: "json",
                            type: "PUT",  
                            headers: {
                                "Content-Encoding": zipJSON.length>1000?"gzip":""
                            },
                            success: function (retObject) {
                                     if (retObject.code == "1") {
                                             var str = ungzipString(retObject.record);
                                     var json = JSON.parse(str);
                                     spread.fromJSON(json, { doNotRecalculateAfterLoad: true });
                                     alert(retObject.msg);
                                     }  
                            },
                           beforeSend:function(){
                            //在次如何写loading的效果
                               $.messager.progress(); //这样写的不会出现效果
                            },
                        complete: function() {
                                $.messager.progress('close');
                        }  
                    })  
                     
                    }
    },
        "excel":{
                title: "导出为Excel",
                iconClass: "ribbon-button-excel",
                commandName: "excel",
                execute: async (context, propertyName, fontItalicChecked) => {
                    var spread = context.getWorkbook();
                    var sheet = spread.getActiveSheet();
                    var selectionRange = sheet.getSelections();
                                 
                }
        }
}

var saveGroup = {
    "label": "操作",
    "thumbnailClass": "ribbon-button-save",
    "commandGroup": {
        "children": [
            {
                "direction": "vertical",
                "commands": ["save","excel"]
            }
    }
}


最佳答案

查看完整内容

你好,关于ajax的loading效果这部分属于你业务上的需求,建议搜索引擎查找相关相关资料进行实现哈。这边也找了几个相似的链接,可以参考一下,希望对你能有所帮助。 https://blog.csdn.net/tx1721110240/article/details/79726539 https://blog.csdn.net/weixin_33924312/article/details/93271821?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.pc_relev ...

1 个回复

倒序浏览
最佳答案
最佳答案
Derrick.Jiao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2022-1-18 21:36:52
来自 2#
你好,关于ajax的loading效果这部分属于你业务上的需求,建议搜索引擎查找相关相关资料进行实现哈。这边也找了几个相似的链接,可以参考一下,希望对你能有所帮助。

https://blog.csdn.net/tx1721110240/article/details/79726539

https://blog.csdn.net/weixin_339 ... tm_relevant_index=2

https://www.cnblogs.com/conswin/p/7251341.html
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部