IT-KIMI_SHI\SINOIT.KIMI
2018-06-04 b12dfac6e495d6cf38df6b7e5222191f59762900
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
<!DOCTYPE html>
<html>
 <head>
     <title>Excel上载</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Pragma" content="no-cache"> 
    <meta http-equiv="Cache-Control" content="no-cache"> 
    <meta http-equiv="Expires" content="0">
    <link href="../../css/control.css" rel="stylesheet" />
    <link href="../../css/importer.css" rel="stylesheet">
    <script src="../../js/jquery-1.7.2.min.js"></script>
    <script src="../../js/core.js"></script>
    <script src="../../js/control.js"></script>
    <style>
        .dropArea{
            margin-left: 10px;
            width:600px;
            border-style: groove;
        }
        .taskline {
                border-bottom: 1px #CCC dashed;
                height: 28px;
                width: 800px;
                font-size: 15px;
                font-family: 微软雅黑;
                color: #333;
                margin: 5px 0px 0px 50px;
        }
        progress::-webkit-progress-bar { background: #ccc; }
        progress::-webkit-progress-value  { background: #18bf5c; }
        progress {
            margin-left:220px;
            display:block;
            width:500px;
            background:#ccc;
        }
        ie {
            height:100%;
            width:0%;
            display:block;
            background: #18bf5c;
        }
    </style> 
           
    <script type="text/javascript" >
        var fileSelector, edt_fileName, btn_select; 
        var lbl_fileSize, lbl_progress, img_progress;
        var dropArea, logdata, message, timer, progress;
        var step_0, step_1;
    
        function changeProgressValue(val) {
            $("#progress").value = val;
        }
/////////////////////选择上传文件//////////////////////    
        function selectFile() {
            fileSelector.val("");
            fileSelector.click();    
        }        
 
        function onSelectFile() {
            var value = fileSelector.val();
            edt_fileName.val(value);
 
            var file = fileSelector[0].files[0];
            var filename = file.name.toLowerCase();
            if (filename.indexOf('.xlsx') == -1 && filename.indexOf('.xls') == -1) {
                alert("您选择的不是Excel文件!");
                return false;
            }
 
            upload(file);    
        }
                
        function upload(file){
            pos = file.name.lastIndexOf("\\");
            var filename = file.name.substring(pos + 1);
            
            Dialog.confirm("信息提示", "确定上载[" + filename + "]中的数据?", function(result){
                if (result) {
                    lbl_fileSize.text(formatFileSize(file.size));
                    
                    Server.upload("root/file/uploaddata/2017-02-24", file, function(event){
                        btn_select.attr("disabled", true);
                        lbl_progress.html(formatFileSize(event.loaded) + "/" + formatFileSize(event.total));
                        img_progress.css("width", (event.loaded / event.total) * 100 + "%");
                        
                        if (event.loaded != event.total) {
                            step_0.html("正在上载,请稍等...");
                        }
                        else {
                            step_0.html("上载完成 .");
                            step_1.html("正在进行后台处理,请稍等...");
                            timer = setInterval(refresh, 2000);
                        }
                    },            
                    function(result){
                        btn_select.attr("disabled", false);
                        step_1.html("后台处理完成 .");
                    });
                }
            });
        }
        
        //手动刷新日志
        function refresh(){
            Server.call("root/file/showmessages?notDebug=true", function(result) {
                var msg = result.arraylist;
                var str = "";
                for(var i = 0; i < msg.length; i++){
                    str += '<div class="taskline"><div>' + msg[i] + '</div></div>';
                }
                message.empty();
                message.append(str);
            });
            
            if(step_1.text() == "后台处理完成 ." && timer != null){
                clearInterval(timer);
            }
        }
        
//////////////////////////拖拽操作////////////////////////////////////
        function addDragEvent() {
            
            dropArea.on("dragover", function(e) {//拖来拖去
                e.preventDefault();        
            });
            
            dropArea.on("dragenter", function(e) {//拖拽进入
                e.preventDefault();
                dropArea.html("请放下文件");
            });
            
            dropArea.on("dragleave", function(e) {//拖拽移出
                e.preventDefault();
                dropArea.html("将Excel文件拖放到此处");
            });
            
            dropArea.on("drop", function(e) {//拖拽释放
                e.preventDefault();
                var filelist = e.originalEvent.dataTransfer.files;
                
                if (filelist.length == 0) {
                    return false;
                }
                
                if (filelist[0].name.indexOf('.xlsx') == -1 && filelist[0].name.indexOf('.xls') == -1) {
                    alert("您拖的不是Excel文件!");
                    return false;
                }
                
                upload(filelist[0]);
                dropArea.html("将Excel文件拖放到此处");
            });     
        }
        
//////////////////////////////////////////////
        $(document).ready(function() {
            try {
                //1.
                fileSelector = $("#fileSelector");
                edt_fileName = $("#edt_fileName");
                btn_select = $("#btn_select");
                            
                lbl_fileSize = $("#lbl_fileSize");
                lbl_progress = $("#lbl_progress");    
                dropArea = $("#dropArea");
                logdata = $("#logdata");
                message = $("#message");
                
                step_0 = $("#step_0");
                step_1 = $("#step_1");
                img_progress = $("#img_progress");
    
                //2.
                addDragEvent();            
            }
            finally {
                Loading.hide();
            }
        });        
    </script>
</head>
 
<body style="overflow: hidden;">
    
    <div style="margin: 20px; border: 1px #CCC dashed; font-family:微软雅黑;font-size:15px">
        <div style="margin: 0px 0px 0px 20px; width: 100%">
            <div style="height: 12px; opacity: 0;" >
                <input type="file" id="fileSelector" size="120" onchange="onSelectFile()" />
            </div>
            
            数据文件:&nbsp;
            <input type="text" id="edt_fileName" class="text_large" style="width: 435px;" disabled="disabled"></input>
            <input id="btn_select" type="button" style="width: 100px; margin: 0px 20px 0px 0px;" value="选择" onclick="selectFile()"></input>
            
            <span>文件大小:</span>
            <span id="lbl_fileSize">0M</span>
            <span style="margin-left: 20px;">上传进度:</span>
            <span id="lbl_progress">0M/0M</span>
        </div>          
                    
        <div id="dropArea" class="dropArea" style="height: 120px;" align="center">
            将Excel文件拖放到此处
        </div>
        <div style="margin: 10px">
            <div style="float: left; width:200px">当前任务:</div>
            <progress id="progress" value="50" max="100">
                <ie id="ie"></ie>
            </progress>
        </div>
        
        <!-- <div style="font-size: 20px; width: 100%; font-family: 微软雅黑 ; color: #69C; font-size: 18px; margin: 20px 0px 10px 10px; padding-left: 10px; ">
            <div style="float:left;">日志记录</div>
            <div style="line-height:18px;float:left;border:1px #e5e5e5 solid; width:398px;height:18px;margin:2px 0 0 20px;">
                <img id="img_progress" style="width:10%;height:18px" src="../../image/progress.jpg"/>
            </div>
            <input onclick="refresh();" style="float:left; margin-left:30px;" value="刷新日志" type="button"></input>
            <div style="clear: both"></div>
        </div> -->
        <div style="height: 420px; margin: 0px 10px 20px 10px; font: 16px 微软雅黑; border: 1px #CCC solid;" >
            <div id="logdata" style="margin-left: 20px; margin-top: 20px ">
                
                <!-- <div class="taskline">
                    <div style="float: left; width: 200px;">一.&nbsp;上载数据</div>
                    <div style="float: left; width: 200px;"><label id="step_0"></label></div>
                    <div style="clear: both;"></div>
                </div>
                
                <div class="taskline">
                    <div style="float: left; width: 200px;">二.&nbsp;后台处理</div>
                    <div style="float: left; width: 200px;"><label id="step_1"></label></div>
                    <div style="clear: both;"></div>
                </div> -->
                
                <!--动态日志-->
                <div id="message" style="margin-top:20px"></div>
                
            </div>
        </div>
    </div>
</body>
</html>