cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title>添加文件</title>
[#include "/business/pages/include/static.html" /]
<script src="${common_static}/static/plugins/plupload/plupload.full.min.js"></script>
<style>
    /* #file-list{ width: 350px; margin: 20px auto;}
    #file-list li{ margin-bottom: 10px;}
    .file-name{ line-height: 30px;}*/
    .progress{ height: 4px; font-size: 0; line-height: 4px; background: orange; width: 0;} 
</style>
<body>
 
<div style="width: 90%">
       <div class="deal_switch_con" style="display:block;">
        <div>
            <input type="button" value="选择文件..." id="browse" />
            <input type="button" value="开始上传" id="upload-btn" />
        </div>
        <ul id="file-list"></ul>
    </div>
    <div id="main" style="margin-top:40px;"></div>
</div>
 
 
</body>
<script type="text/javascript">
    var uploader = new plupload.Uploader({ //实例化一个plupload上传对象
        browse_button : 'browse',
        url : '${base}/business/pages/dsl/addDslFile.html',
        flash_swf_url : '${common_static}/static/plugins/plupload/Moxie.swf',
        silverlight_xap_url : '${common_static}/static/plugins/plupload/Moxie.xap',
        multipart_params: {
                'configureId':'${RequestParameters.configureId}',
                'secondDslId':'${RequestParameters.secondDslId}', 
                'orderId':'${RequestParameters.orderId}' 
        }
    });
    uploader.init(); //初始化
    
    //绑定文件添加进队列事件
    uploader.bind('FilesAdded',function(uploader,files){
        for(var i = 0, len = files.length; i<len; i++){
            var file_name = files[i].name; //文件名
            //构造html来更新UI
            var html = '<li id="file-' + files[i].id +'"><p class="blue_txt lb_button">' + file_name + '</p><p class="progress"></p></li>';
            $(html).appendTo('#file-list');
        }
    });
    
    //绑定文件上传完成事件
    uploader.bind('UploadComplete',function(uploader,files){
        synFile();
    });
    
    //绑定文件上传进度事件
    uploader.bind('UploadProgress',function(uploader,file){
        $('#file-'+file.id+' .progress').css('width',file.percent + '%');//控制进度条
    });
    
    //上传按钮
    $('#upload-btn').click(function(){
        uploader.start(); //开始上传
    });
 
    function query() {
        var configureId = '${RequestParameters.configureId}';
        var orderId = '${RequestParameters.orderId}';
        var secondDslId = '${RequestParameters.secondDslId}';
        $.post("${base}/business/pages/dsl/secondDslFileList.html",{'configureId':configureId,'orderId':orderId,'secondDslId':secondDslId},function(data,textStatus) {
            $("#main").html(data);
        })
    }
    
    $(function() {
        query();
    })
    
    function synFile(){
        query();
        var configureId = '${RequestParameters.configureId}';
        var orderId = '${RequestParameters.orderId}';
        var secondDslId = '${RequestParameters.secondDslId}';
        $.post("${base}/business/pages/dsl/allSecondDslFileList.html",{'configureId':configureId,'orderId':orderId,'secondDslId':secondDslId},function(data){
            var htmlStr = "";
            var basePath = "${base}";
            for(var i=0; i<data.length; i++){ 
                htmlStr= htmlStr + 
                "<a class='blue_txt lb_button' href='"+basePath+"/business/pages/file/downloadFile.html?fileId="+data[i].ID+"'><span>"+data[i].FILE_NAME+"</span></a>";
            }
            $("#"+secondDslId,parent.document).html(htmlStr);  
        },'json');
    }
    
    function delFile(fileId) {
        window.top.confirmInfo('提示', '确定要删除吗?', function(){
            $.post("${base}/business/pages/dsl/delFile.html",{"fileId":fileId},function(data,textStatus) {
                if(data==1) {
                    synFile();
                    window.top.popupTips("删除成功");
                } else {
                    window.top.popupTips("删除失败");
                }
            });
        })
    }
</script>
</html>