多单位版国产化地质资料管理系统
zs
2025-12-18 4f0d9bde31a80f6279e26466250da7716eec627f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
//多图片上传 ImageUpload 
//前置插件jquery,webuploader(百度上传)
//用法:new ImageUpload({...})
//author:guye
//createdate: 2019/1/3
 
(function(global,$,WebUploader,factory){
    typeof exports=="object" && typeof module!="undefined" ?module.exports=factory():typeof define ==='function' && define.amd?define(factory):(global.ImageUpload=factory());
 
})(this,jQuery,WebUploader,function(){
 
var ImageUpload=function(options){ //构造函数
if(!(this instanceof ImageUpload)){
    console.log("ImageUpload 是一个构造函数,应该用new关键字调用");
    return;
}
 
    //默认配置参数
    var _DEFALUTS_={
        wrapId:"#uploader", //容器id,
        queueList:".queueList",//图片容器
        statusBar:".statusBar", //状态栏,包括进度和控制按钮
        info:".info", //文件总体选择信息
        uploadBtn:".uploadBtn", //上传按钮样式区块
        placeholder:".placeholder", //没选择文件之前的内容
        progress:".progress", //进度条
        ratio : window.devicePixelRatio || 1, // 优化retina, 在retina下这个值是2
        thumbnailWidth : 110,// 缩略图宽
        thumbnailHeight : 110,// 缩略图高
        duplicate:false,//去除重复
        arrImage: [], //初始化图片列表,arrImage传入格式如下:[{ "src": "/pic/示例图片1.jpg", "dataSize": "1100" }, { "src": "/pic/示例图片2.jpg", "dataSize": "2000" }]
        serverPath:'/plugins/ptimageupload/server/fileupload.php', //上传路径
        serverPreviewPath:'/plugins/ptimageupload/server/preview.php', //预览path
        dndId:"#dndArea", //拖动区域Id 
        pick:{
            id:"#filePicker", //指定选择文件的按钮容器,不指定则不创建按钮。id {Seletor|dom} 指定选择文件的按钮容器,不指定则不创建按钮。注意 这里虽然写的是 id, 但是不是只支持 id, 还支持 class, 或者 dom 节点。
            multiple:true ,//是否开起同时选择多个文件能力。
            innerHTML:"点击选择图片",//指定按钮文字。不指定时优先从指定的容器中看是否自带文字。
 
        },
        
 
        pick2:{ //图片上传控件需要第二个按钮点击选择文件
            id:"#filePicker2", //指定选择文件的按钮容器,不指定则不创建按钮。id {Seletor|dom} 指定选择文件的按钮容器,不指定则不创建按钮。注意 这里虽然写的是 id, 但是不是只支持 id, 还支持 class, 或者 dom 节点。
            multiple:true ,//是否开起同时选择多个文件能力。
            innerHTML:"继续添加",//指定按钮文字。不指定时优先从指定的容器中看是否自带文字。
 
        },
       
        compress:{ //当compress=null时,上传图片不压缩
             width: 1600,
             height: 1600,
             // 图片质量,只有type为`image/jpeg`的时候才有效。
             quality: 90,
             // 是否允许放大,如果想要生成小图的时候不失真,此选项应该设置为false.
             allowMagnify: false,
 
             // 是否允许裁剪。
             crop: false,
 
             // 是否保留头部meta信息。
             preserveHeaders: true,
 
             // 如果发现压缩后文件大小比原来还大,则使用原来图片
             // 此属性可能会影响图片自动纠正功能
             noCompressIfLarger: false,
 
             // 单位字节,如果图片大小小于此值,不会采用压缩。
             compressSize: 0
        }, 
        chunked: false,
        chunkSize: 512 * 1024,
       
        fileNumLimit: 300,
        fileSizeLimit: 200 * 1024 * 1024,    // 200 M
        fileSingleSizeLimit: 50 * 1024 * 1024,   // 50 M
         
         auto: false, // [默认值:false] 设置为 true 后,不需要手动调用上传,有文件选择即开始上传。 
         method:'POST',// {Object} [可选] [默认值:'POST'] 文件上传方式,POST或者GET。
        sendAsBinary:false, // {Object} [可选] [默认值:false] 是否已二进制的流的方式发送文件,这样整个上传内容php://input都为文件内容, 其他参数在$_GET数组中。   
        formData:{}, //上传的自定义参数
        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        },
        disableWidgets:undefined, // {String, Array} [可选] [默认值:undefined] 默认所有 Uploader.register 了的 widget 都会被加载,如果禁用某一部分,请通过此 option 指定黑名单。
        disableGlobalDnd:true,
        uploadSuccess:function(file,response){
 
        },
        
        uploadError:function(file,reason){
 
        }
 
 
    }
 
    $.extend(true,_DEFALUTS_, options||{});
 
    var $wrap = $( _DEFALUTS_.wrapId),
        // 图片容器
        $queue =$( '<ul class="filelist"></ul>' )
                .appendTo( $wrap.find( _DEFALUTS_.queueList ) ),
 
        // 状态栏,包括进度和控制按钮
        $statusBar = $wrap.find(_DEFALUTS_.statusBar),
 
        // 文件总体选择信息。
        $info = $statusBar.find( _DEFALUTS_.info ),
 
        // 上传按钮
        $upload = $wrap.find( _DEFALUTS_.uploadBtn ),
 
        // 没选择文件之前的内容。
        $placeHolder = $wrap.find( _DEFALUTS_.placeholder ),
 
        $progress = $statusBar.find( '.progress' ).hide(),
 
        
 
        // 优化retina, 在retina下这个值是2
        ratio = _DEFALUTS_.ratio,
 
        // 缩略图大小
        thumbnailWidth = _DEFALUTS_.thumbnailWidth*ratio,
        thumbnailHeight = _DEFALUTS_.thumbnailHeight*ratio;
    //初始化
    InitImgList(_DEFALUTS_.arrImage);
     // 添加的文件数量
     var fileCount = $queue.length == 0 ? 0 : $queue.children('li').length;
     //文件大小
     var fileSize=0;
     $queue.children('li').each(function (index, elem) {
         var $li = $(elem);
         var size = parseInt($li.attr("data-size"))
         fileSize += size;
         var $btns = $li.find(".file-panel");
         var file = $li.find("img")[0];
         var $wrap = $li.find(".imgWrap");
         $li.on('mouseenter', function () {
             $btns.stop().animate({ height: 30 });
         });
 
         $li.on('mouseleave', function () {
             $btns.stop().animate({ height: 0 });
         });
 
         $btns.on('click', 'span', function () {
             var index = $(this).index(),
                 deg;
             var ro = $(file).data("rotation");
             switch (index) {
                 case 0:
                     //uploader.removeFile( file );
                     //删除
                     fileCount--;
                     //大小减去
                     fileSize -= size;
                     updateStatus();
                     $li.remove();
                     if (fileCount <= 0) {
                         $placeHolder.removeClass('element-invisible');
                     }
                     return;
 
                 case 1:
 
                     if (ro) {
                         ro = parseInt(ro) + 90;
                         $(file).data("rotation", ro);
                     } else {
                         ro = 90;
                         $(file).data("rotation", ro);
                     }
 
                     break;
 
                 case 2:
                     if (ro) {
                         ro = parseInt(ro) - 90;
                         $(file).data("rotation", ro);
                     } else {
                         ro = -90;
                         $(file).data("rotation", ro);
                     }
                     break;
             }
 
             if (supportTransition) {
                 deg = 'rotate(' + ro + 'deg)';
                 $wrap.css({
                     '-webkit-transform': deg,
                     '-mos-transform': deg,
                     '-o-transform': deg,
                     'transform': deg
                 });
             } else {
                 $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
 
             }
 
 
         });
     });
 
    //info信息修改
     if (_DEFALUTS_.arrImage.length > 0) {
         updateStatus();
     }
 
     var state="pedding";//可能有pedding, ready, uploading, confirm, done 上传的状态
     var percentages={}; //所有文件的进度信息,key为file id
      // 判断浏览器是否支持图片的base64
     var isSupportBase64 = ( function() {
                var data = new Image();
                var support = true;
                data.onload = data.onerror = function() {
                    if( this.width != 1 || this.height != 1 ) {
                        support = false;
                    }
                }
                data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
                return support; 
            } )();
     //检测是否已经安装flash,检测flash的版本
     var flashVersion = ( function() {
                var version;
 
                try {
                    version = navigator.plugins[ 'Shockwave Flash' ];
                    version = version.description;
                } catch ( ex ) {
                    try {
                        version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                                .GetVariable('$version');
                    } catch ( ex2 ) {
                        version = '0.0';
                    }
                }
                version = version.match( /\d+/g );
                return parseFloat( version[ 0 ] + '.' + version[ 1 ], 10 );
            } )();
      //检查过渡形式      
        var supportTransition = (function(){
        var s = document.createElement('p').style,
            r = 'transition' in s ||
                    'WebkitTransition' in s ||
                    'MozTransition' in s ||
                    'msTransition' in s ||
                    'OTransition' in s;
        s = null;
        return r;
      })();
          //检查flash
     if ( !WebUploader.Uploader.support('flash') && WebUploader.browser.ie ) {
 
            // flash 安装了但是版本过低。
            if (flashVersion) {
                (function(container) {
                    window['expressinstallcallback'] = function( state ) {
                        switch(state) {
                            case 'Download.Cancelled':
                                alert('您取消了更新!')
                                break;
 
                            case 'Download.Failed':
                                alert('安装失败')
                                break;
 
                            default:
                                alert('安装已成功,请刷新!');
                                break;
                        }
                        delete window['expressinstallcallback'];
                    };
 
                    var swf = './expressInstall.swf';
                    // insert flash object
                    var html = '<object type="application/' +
                            'x-shockwave-flash" data="' +  swf + '" ';
 
                    if (WebUploader.browser.ie) {
                        html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
                    }
 
                    html += 'width="100%" height="100%" style="outline:0">'  +
                        '<param name="movie" value="' + swf + '" />' +
                        '<param name="wmode" value="transparent" />' +
                        '<param name="allowscriptaccess" value="always" />' +
                    '</object>';
 
                    container.html(html);
 
                })($wrap);
 
            // 压根就没有安转。
            } else {
                $wrap.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');
            }
 
            return;
        } else if (!WebUploader.Uploader.support()) {
            alert( 'Web Uploader 不支持您的浏览器!');
            return;
      }
 
    // 实例化
     var uploader = WebUploader.create({
            pick: _DEFALUTS_.pick,
            compress:_DEFALUTS_.compress,
            formData: _DEFALUTS_.formData,
            dnd: _DEFALUTS_.dndId,
            paste: _DEFALUTS_.wrapId,
            swf: 'static/plugins/ptimageupload/Uploader.swf',
            chunked: _DEFALUTS_.chunked,
            chunkSize: _DEFALUTS_.chunkSize,
            //server: 'server/fileupload.php',
            server: _DEFALUTS_.serverPath,
            auto:_DEFALUTS_.auto,
            duplicate:_DEFALUTS_.duplicate,
            
            
            fileNumLimit: _DEFALUTS_.fileNumLimit,
            fileSizeLimit: _DEFALUTS_.fileSizeLimit,    // 200 M
            fileSingleSizeLimit: _DEFALUTS_.fileSingleSizeLimit,   // 50 M
            // 只允许选择图片文件。
            accept: _DEFALUTS_.accept,
            disableWidgets:_DEFALUTS_.disableWidgets, 
            disableGlobalDnd:_DEFALUTS_.disableGlobalDnd
 
        });
 
        // 拖拽时不接受 js, txt 文件。
        uploader.on('dndAccept', function (items) {
            var denied = false,
                len = items.length,
                i = 0,
                // 修改js类型
                unAllowed = 'text/plain;application/javascript ';
 
            for (; i < len; i++) {
                // 如果在列表里面
                if (~unAllowed.indexOf(items[i].type)) {
                    denied = true;
                    break;
                }
            }
 
            return !denied;
        });
 
        uploader.on('dialogOpen', function () {
            //console.log('here');
 
        });
 
        // uploader.on('filesQueued', function() {
        //     uploader.sort(function( a, b ) {
        //         if ( a.name < b.name )
        //           return -1;
        //         if ( a.name > b.name )
        //           return 1;
        //         return 0;
        //     });
        // });
 
        // 添加“添加文件”的按钮,
        uploader.addButton(_DEFALUTS_.pick2);
 
        uploader.on('ready', function () {
            window.uploader = uploader;
        });
 
        // 当有文件添加进来时执行,负责view的创建
        function addFile(file) {
            var $li = $('<li id="' + file.id + '">' +
                '<p class="title">' + file.name + '</p>' +
                '<p class="imgWrap"></p>' +
                '<p class="progress"><span></span></p>' +
                '</li>'),
 
                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span>' ).appendTo($li),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find('p.imgWrap'),
                $info = $('<p class="error"></p>'),
 
                showError = function (code) {
                    switch (code) {
                        case 'exceed_size':
                            text = '文件大小超出';
                            break;
 
                        case 'interrupt':
                            text = '上传暂停';
                            break;
 
                        default:showError
                            text = '上传失败,请重试';
                            break;
                    }
 
                    $info.text(text).appendTo($li);
                };
 
            if (file.getStatus() === 'invalid') {
                showError(file.statusText);
            } else {
                // @todo lazyload
                $wrap.text('预览中');
                uploader.makeThumb(file, function (error, src) {
                    var img;
 
                    if (error) {
                        $wrap.text('不能预览');
                        return;
                    }
 
                    if (isSupportBase64) {
                        img = $('<img src="' + src + '">');
                        $wrap.empty().append(img);
                    } else {
                        $.ajax(_DEFALUTS_.serverPreviewPath, {
                            method: 'POST',
                            data: src,
                            dataType: 'json'
                        }).done(function (response) {
                            if (response.result) {
                                img = $('<img src="' + response.result + '">');
                                $wrap.empty().append(img);
                            } else {
                                $wrap.text("预览出错");
                            }
                        });
                    }
 
                    
                }, thumbnailWidth, thumbnailHeight);
 
                percentages[file.id] = [file.size, 0];
                file.rotation = 0;
            }
 
            file.on('statuschange', function (cur, prev) {
                if (prev === 'progress') {
                    $prgress.hide().width(0);
                } else if (prev === 'queued') {
                    // $li.off( 'mouseenter mouseleave' );
                    // $btns.remove();
                }
 
                // 成功
                if (cur === 'error' || cur === 'invalid') {
                    //console.log( file.statusText );
                    showError(file.statusText);
                    percentages[file.id][1] = 1;
                } else if (cur === 'interrupt') {
                    showError('interrupt');
                } else if (cur === 'queued') {
                    $info.remove();
                    $prgress.css('display', 'block');
                    percentages[file.id][1] = 0;
                } else if (cur === 'progress') {
                    $info.remove();
                    $prgress.css('display', 'block');
                } else if (cur === 'complete') {
                    $prgress.hide().width(0);
                    $li.append('<span class="success"></span>');
                }
 
                $li.removeClass('state-' + prev).addClass('state-' + cur);
            });
 
            $li.off('mouseenter').on('mouseenter', function () {
                $btns.stop().animate({ height: 30 });
            });
 
            $li.off('mouseleave').on('mouseleave', function () {
                $btns.stop().animate({ height: 0 });
            });
 
            $btns.off('click').on('click', 'span', function () {
                var index = $(this).index(),
                    deg;
 
                switch (index) {
                    case 0:
                        uploader.removeFile(file);
                        return;
                    case 1:
                        file.rotation += 90;
                        break;
 
                    case 2:
                        file.rotation -= 90;
                        break;
                    
                }
 
                if (supportTransition) {
                    deg = 'rotate(' + file.rotation + 'deg)';
                    $wrap.css({
                        '-webkit-transform': deg,
                        '-mos-transform': deg,
                        '-o-transform': deg,
                        'transform': deg
                    });
                } else {
                    $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                }
 
 
            });
 
            $li.appendTo($queue);
        }
 
        
        // 负责view的销毁
        function removeFile(file) {
            var $li = $('#' + file.id);
 
            delete percentages[file.id];
            updateTotalProgress();
            $li.off().find('.file-panel').off().end().remove();
        }
 
        function updateTotalProgress() {
            var loaded = 0,
                total = 0,
                spans = $progress.children(),
                percent;
 
            $.each(percentages, function (k, v) {
                total += v[0];
                loaded += v[0] * v[1];
            });
 
            percent = total ? loaded / total : 0;
 
 
            spans.eq(0).text(Math.round(percent * 100) + '%');
            spans.eq(1).css('width', Math.round(percent * 100) + '%');
            updateStatus();
        }
 
        function updateStatus() {
            var text = '', stats;
 
            if (state === 'ready') {
                text = '选中' + fileCount + '张图片,共' +
                    WebUploader.formatSize(fileSize) + '。';
            } else if (state === 'confirm') {
                stats = uploader.getStats();
                if (stats.uploadFailNum) {
                    text = '已成功上传' + stats.successNum + '张图片,' +
                        stats.uploadFailNum + '张图片上传失败,<a class="retry" href="#">重新上传</a>失败图片或<a class="ignore" href="#">忽略</a>'
                }
 
            } else {
                if (uploader) {
                    stats = uploader.getStats();
                    text = '共' + fileCount + '张(' +
                        WebUploader.formatSize(fileSize) +
                        '),已上传' + stats.successNum + '张';
 
                    if (stats.uploadFailNum) {
                        text += ',失败' + stats.uploadFailNum + '张';
                    }
                } else {
                    text = '共' + fileCount + '张(' +
                        WebUploader.formatSize(fileSize) +
                        '),已存在' + fileCount + '张';
                }
            }
 
            $info.html(text);
        }
 
        function setState(val) {
            var file, stats;
 
            if (val === state) {
                return;
            }
 
            $upload.removeClass('state-' + state);
            $upload.addClass('state-' + val);
            state = val;
 
            switch (state) {
                case 'pedding':
                    $placeHolder.removeClass('element-invisible');
                    $queue.hide();
                    $statusBar.addClass('element-invisible');
                    uploader.refresh();
                    break;
 
                case 'ready':
                    $placeHolder.addClass('element-invisible');
                    $(_DEFALUTS_.pick2.id).removeClass('element-invisible');
                    $queue.show();
                    $statusBar.removeClass('element-invisible');
                    uploader.refresh();
                    break;
 
                case 'uploading':
                    $(_DEFALUTS_.pick2.id).addClass('element-invisible');
                    $progress.show();
                    $upload.text('暂停上传');
                    break;
 
                case 'paused':
                    $progress.show();
                    $upload.text('继续上传');
                    break;
 
                case 'confirm':
                    $progress.hide();
                    $(_DEFALUTS_.pick2.id).removeClass('element-invisible');
                    $upload.text('开始上传');
 
                    stats = uploader.getStats();
                    if (stats.successNum && !stats.uploadFailNum) {
                        setState('finish');
                        return;
                    }
                    break;
                case 'finish':
                    stats = uploader.getStats();
                    if (stats.successNum) {
                        //alert('上传成功');
                        //parent.abp.notify.success("上传成功!", "提示");
                        //去掉图片上的进度条
                        $wrap.find("p.progress").hide();
 
 
                    } else {
                        // 没有成功的图片,重设
                        state = 'done';
                        location.reload();
                    }
                    break;
            }
 
            updateStatus();
        }
 
 
        uploader.on('uploadSuccess', function (file, response) {
 
            /*if (response.success) {
                $("#" + file.id).attr("address", response.result);
            }*/
 
            _DEFALUTS_.uploadSuccess&&_DEFALUTS_.uploadSuccess(file,response);
 
 
        });
 
        uploader.on("uploadAccept", function (object, ret) {
            if (ret.success == false) {
                console.log(ret.error.message);
                return false;
            }
        });
 
        uploader.on("uploadError", function (file, reason) {
            var $li = $('#' + file.id),
                $error = $li.find('div.error');
 
            // 避免重复创建
            if (!$error.length) {
                $error = $('<p class="error"></p>').appendTo($li);
            }
            
            $error.text('上传失败' + reason);
            _DEFALUTS_.uploadError && _DEFALUTS_.uploadError(file,reason);
        });
 
 
        uploader.onUploadProgress = function (file, percentage) {
 
            var $li = $('#' + file.id),
                $percent = $li.find('.progress span');
 
            $percent.css('width', percentage * 100 + '%');
            percentages[file.id][1] = percentage;
            updateTotalProgress();
        };
 
            
        uploader.onFileQueued = function (file) {
            fileCount++;
            fileSize += file.size;
 
            if (fileCount === 1) {
                $placeHolder.addClass('element-invisible');
                $statusBar.show();
            }
 
            addFile(file);
            setState('ready');
            updateTotalProgress();
        };
 
        uploader.onFileDequeued = function (file) {
            fileCount--;
            fileSize -= file.size;
 
            if (!fileCount) {
                setState('pedding');
            }
 
            removeFile(file);
            updateTotalProgress();
 
        };
 
        uploader.on('all', function (type) {
            var stats;
            switch (type) {
                case 'uploadFinished':
                    setState('confirm');
                    break;
 
                case 'startUpload':
                    setState('uploading');
                    break;
 
                case 'stopUpload':
                    setState('paused');
                    break;
 
            }
        });
 
        uploader.onError = function (code) {
            var codeMsg=code;
            switch(code){
                case "Q_EXCEED_NUM_LIMIT": codeMsg="文件数量超出"+fileCount+"个";
                    break;
                case "Q_EXCEED_SIZE_LIMIT":codeMsg="添加的文件总大小超出"+(_DEFALUTS_.fileSizeLimit/1024 * 1024)+"M";
                    break;
                case "Q_TYPE_DENIED": codeMsg = "文件类型不在范围(" + _DEFALUTS_.accept.extensions + ")里";
                    break;
                case 'F_EXCEED_SIZE':
                    codeMsg = "添加的文件大小超出" + (_DEFALUTS_.fileSingleSizeLimit / 1024 * 1024) + "M";
                    break;
 
            }
            alert('错误: ' + codeMsg);
        };
 
        $upload.on('click', function () {
            if ($(this).hasClass('disabled')) {
                return false;
            }
 
            if (state === 'ready') {
                uploader.upload();
            } else if (state === 'paused') {
                uploader.upload();
            } else if (state === 'uploading') {
                uploader.stop();
            }
        });
 
        $info.on('click', '.retry', function () {
            uploader.retry();
        });
 
        $info.on('click', '.ignore', function () {
            alert('todo');
        });
 
        $upload.addClass('state-' + state);
        //updateTotalProgress();
 
        /**
          *InitImgList:当已经存在传入的图片时修改结构,初始化图片列表
            参数arrImage传入格式如下:[{ "src": "/pic/示例图片1.jpg", "dataSize": "1100" }, { "src": "/pic/示例图片2.jpg", "dataSize": "2000" }]
        */
        function InitImgList(arrImage) {
            
            if (arrImage.length) {
                $.each(arrImage, function (i, elem) {
 
                    $li = $("<li address='" + elem.src + "' class='state-complete' data-size='" + (elem.dataSize ? elem.dataSize : 1000) + "'> <p class=\"title\"></p><p class=\"imgWrap\"><img src=\"" + elem.src + "\"></p><div class=\"file-panel\" style=\"height: 0px;\"><span class=\"cancel\">删除</span><span class=\"rotateRight\">向右旋转</span><span class=\"rotateLeft\">向左旋转</span></div><span class=\"success\"></span></li>");
                    $queue.append($li);
 
                });
                
                $placeHolder.addClass("element-invisible");
                $statusBar.show();
            }
            
         }
 
 
        }
 
 
 
return ImageUpload;
});