起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1256|回复: 1

[结贴] attachmentSimple.js组件改进建议

[复制链接]

53

主题

267

帖子

896

积分

高级会员

Rank: 4

积分
896
QQ
发表于 2016-2-19 20:17:43 | 显示全部楼层 |阅读模式
本帖最后由 ajun007_cn 于 2016-2-19 20:34 编辑

attachmentSimple组件,在3.3版本中,加了actionUrl属性,很好,可以使用自己的上传服务,但不允许自定义的参数传入比较麻烦,如:
actionUrl="/baas/WeixinService/Weixin/simpleFileStore?OrgID="+this.getContext().getCurrentOgnID();
我要传入OrgID参数,然后按机构代码新建目录,存放图片文件。
现在attachmentSimple.js中代码:
getFileUrl : function(realFileName,storeFileName,ownerID,operateType){
                var url = this.actionUrl + '?realFileName=' + realFileName + '&storeFileName='+storeFileName + '&ownerID='+ownerID + '&operateType=' + operateType+ '&OrgID='+this.getModelOrgID();
                return require.toUrl(url);
        },

是不允许代入“?OrgID=”会原代码冲突,出现错误码,建议:在所有URL中的代码中加入一个判断: if (this.actionUrl .indexOf("?")=-1)
改为以下:
getFileUrl : function(realFileName,storeFileName,ownerID,operateType){
                var url = "";
               if (this.actionUrl .indexOf("?")=-1){
                url =this.actionUrl + '?realFileName=' + realFileName + '&storeFileName='+storeFileName + '&ownerID='+ownerID + '&operateType=' + operateType;
              } else {
              url =this.actionUrl + '&realFileName=' + realFileName + '&storeFileName='+storeFileName + '&ownerID='+ownerID + '&operateType=' + operateType;
}
                return require.toUrl(url);
        },



        copyFile:function(ownerID,storeFileName,currentOwnerID){
               var url = "";
               if (this.actionUrl .indexOf("?")=-1){

                url = this.actionUrl + '?targetOwnerID=' + currentOwnerID + '&storeFileName=' + storeFileName + '&ownerID=' + ownerID + '&operateType=copy';
              } else {
                url = this.actionUrl + '&targetOwnerID=' + currentOwnerID + '&storeFileName=' + storeFileName + '&ownerID=' + ownerID + '&operateType=copy';
}
                url = require.toUrl(url);
                $.ajax({
                        url:url,
                        cache:false,
                        async:false
                }).fail(function(){
                        throw "copyFile error";
                });
        },

另外:我按坛子里的贴子:http://bbs.wex5.com/forum.php?mod=viewthread&tid=85096&highlight=SimpleFileStore中说的方法修改attachmentSimple.js中代码,并进行重新合并,提示core.min.js有错误,导致attachmentSimple组件无法使用。头大,望起步公司的大神们改进attachmentSimple组件,允许自己导入自定义参数,这样就不用改attachmentSimple.js源代码,会方便很多。谢谢……还有:attachmentSimple组件不能动态new出来,不知为何?demo里面也没有attachmentSimple组件相关的示例。

attachmentSimple组件也不能动态给actionUrl赋值,只能在设计时。
东莞相思鸟软件 专业X5开发团队 长期招收学徒 推荐工作
http://www.leiothrixsoft.com QQ:402807176
发表于 2016-2-22 09:23:04 | 显示全部楼层
你好楼主,attachmentSimple自定义参数这个特性目前版本不支持,已作为产品功能建议提交(内部编号:2016022200001),感谢楼主的支持与配合。

actionUrl本来就是只要设计时选择就行了,如果使用UIServer就选择.J(模式3打包) 如果使用baasServer就选择另一值(模式1.2.3打包都可以)!服务不可能好动态切换的!

案例:/UI2/system/components/justep/attachment/demo/demoSimple.w

qq:1912779713
WeX5教程--WeX5下载
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-4-26 00:35 , Processed in 0.067835 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表