123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- (function($){
- $.upload = function(form,option,fun,before,going){
- var settings = {
- type:'image'
- };
- if(option){
- var path = option.path;
- if(path.indexOf("images") >= 0 ) {
- var url = '/api/common/upload/image';
- }
- if(path.indexOf("files") >= 0 ) {
- var url = '/api/common/upload/file';
- }
- $.extend(settings,option)
- }
- new AjaxUpload(form,{
- action:url,
- name:$(form).attr('name'),
- data:settings,
- responseType:'json',
-
- onSubmit:function(file,ext){
- if(ext && /^(doc|xls)$/.test(ext)){
- var af = this._input.files;
- var byteSize = af[0].size;
- if ((byteSize / 1024) > (10 * 1024)) {
- disapperTooltip("remind", '文件大小超出范围');
- return false;
- } else {
- if(before && !1 == before()) return !1;
-
- form.disabled = "disabled";
- }
- if(before && !1 == before()) return !1;
- form.disabled = "disabled";
- } else {
- disapperTooltip("remind", '仅支持doc,xls文件');
- return false;
- }
- if(before && !1 == before()) return !1;
- form.disabled = "disabled";
- },
- onComplete:function(file,result){
- form.disabled = "";
- if(result.message=='OK'){
- fun && fun(result);
- }else{
- $.each(result,function (key,val) {
- disapperTooltip("remind", val[0]);
- return false;
- });
- }
- }
- });
- };
- })(jQuery);
|