<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>全链条精准导购系统</title>
</head>
<body>

<div class="row${fluid} index-row" style="margin-top: 10px;">

    <div class="span11 offset1">
        <div id="browserMessage">请先下载数据模板，填充数据后进行上传，否则会导致数据显示不正常！</div>

        <div id="browserMessage"><a href="${ctx}/resources/excel.xls">下载Excel模版</a></div>

        <div class="span10">
            报表1名称：<input type="text" name="report1" id="report1" maxlength="20" onblur="switchUplodify('1')" value="${reportFirst}">
            <a href="${fileOne}">${nameOne}</a>
            <br>
            数据报表：<input type="file" name="file1" id="file1">
        </div>
        <div class="span10">
            报表2名称：<input type="text" name="report2" id="report2" maxlength="20" onblur="switchUplodify('2')" value="${reportSec}">
            <a href="${fileTwo}">${nameTwo}</a>
            <br>
            数据报表：<input type="file" name="file2" id="file2">
        </div>
        <div class="span10">
            报表3名称：<input type="text" name="report3" id="report3" maxlength="20" onblur="switchUplodify('3')" value="${reportThd}">
            <a href="${fileThree}">${nameThree}</a>
            <br>
            数据报表：<input type="file" name="file3" id="file3">
        </div>
        <div class="span10">
            报表4名称：<input type="text" name="report4" id="report4" maxlength="20" onblur="switchUplodify('4')" value="${reportFour}">
            <a href="${fileFour}">${nameFour}</a>
            <br>
            数据报表：<input type="file" name="file4" id="file4">
        </div>

    </div>

</div>

<script src="${ctx}/resources/customize/uploadify/jquery.uploadify.min.js?1"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#file1').uploadify({
            'swf': '${ctx}/resources/customize/uploadify/uploadify.swf',
            'uploader': '${ctx}/uploadReport;jsessionid=${pageContext.session.id}',
            // Your options here
            'buttonText': '请选择Excel文件',
            // An object containing additional data to send via get or post with each file upload.
            'formData': {'reportIndex': '1', 'reportName': $("#report1").val()},
            'fileSizeLimit': '20MB',
            'fileTypeDesc': '请选择xls,xlsx文件',
            'fileTypeExts': '*.xls;*.xlsx',		// Multiple extensions should be separated by semi-colons (i.e. ‘*.jpg; *.png; *.gif’).
            'multi': false,
            'progressData': 'percentage',  // The two options are ‘percentage’ or ‘speed’.
            'removeCompleted': true,		// Set to false to keep files that have completed uploading in the queue.
            'removeTimeout': 0.1,			// The delay in seconds before a completed upload is removed from the queue.
            'successTimeout': 60,			// The time in seconds to wait for the server’s response when a file has completed uploading.After this amount of time,the SWF file will assume success.
            //'uploadLimit' : 1,			// The maximum number of files you are allowed to upload.When this number is reached or exceeded,the onUploadError event is triggered.
            // Triggered when the instance of Uploadify is disabled by calling the disable method.
            'onEnable': function () {
                $('#file1').uploadify('settings', 'buttonText', '请选择Excel文件');
                $('#file1').uploadify('settings', 'formData', {
                    'reportIndex': '1', 'reportName': $("#report1").val()
                });
            },
            // Triggered when the Flash object is loaded and ready.
            'onSWFReady': function () {
                $('#file1').uploadify('disable', false);
            },
            // Triggered for each file that successfully uploads.
            'onUploadSuccess': function (file, data, response) {
                //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                var json = $.parseJSON(data);
                // result -9:参数有误 -8:versionCode和versionName不能为空 -1:apk包非法  0:上传失败  1:上传成功且验证通过
                if (json.result == -9) {
                    alert("参数有误，请重试");
                    window.location.reload();
                    return;
                }
                window.location.reload();
            }
        });

        $('#file2').uploadify({
            'swf': '${ctx}/resources/customize/uploadify/uploadify.swf',
            'uploader': '${ctx}/uploadReport;jsessionid=${pageContext.session.id}',
            // Your options here
            'buttonText': '请选择Excel文件',
            // An object containing additional data to send via get or post with each file upload.
            'formData': {'reportIndex': '1', 'reportName': $("#report2").val()},
            'fileSizeLimit': '20MB',
            'fileTypeDesc': '请选择xls,xlsx文件',
            'fileTypeExts': '*.xls;*.xlsx',		// Multiple extensions should be separated by semi-colons (i.e. ‘*.jpg; *.png; *.gif’).
            'multi': false,
            'progressData': 'percentage',  // The two options are ‘percentage’ or ‘speed’.
            'removeCompleted': true,		// Set to false to keep files that have completed uploading in the queue.
            'removeTimeout': 0.1,			// The delay in seconds before a completed upload is removed from the queue.
            'successTimeout': 60,			// The time in seconds to wait for the server’s response when a file has completed uploading.After this amount of time,the SWF file will assume success.
            //'uploadLimit' : 1,			// The maximum number of files you are allowed to upload.When this number is reached or exceeded,the onUploadError event is triggered.
            // Triggered when the instance of Uploadify is disabled by calling the disable method.
            'onEnable': function () {
                $('#file2').uploadify('settings', 'buttonText', '请选择Excel文件');
                $('#file2').uploadify('settings', 'formData', {
                    'reportIndex': '2', 'reportName': $("#report2").val()
                });
            },
            // Triggered when the Flash object is loaded and ready.
            'onSWFReady': function () {
                $('#file2').uploadify('disable', false);
            },
            // Triggered for each file that successfully uploads.
            'onUploadSuccess': function (file, data, response) {
                //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                var json = $.parseJSON(data);
                // result -9:参数有误 -8:versionCode和versionName不能为空 -1:apk包非法  0:上传失败  1:上传成功且验证通过
                if (json.result == -9) {
                    alert("参数有误，请重试");
                    window.location.reload();
                    return;
                }
                window.location.reload();
            }
        });

        $('#file3').uploadify({
            'swf': '${ctx}/resources/customize/uploadify/uploadify.swf',
            'uploader': '${ctx}/uploadReport;jsessionid=${pageContext.session.id}',
            // Your options here
            'buttonText': '请选择Excel文件',
            // An object containing additional data to send via get or post with each file upload.
            'formData': {'reportIndex': '3', 'reportName': $("#report3").val()},
            'fileSizeLimit': '20MB',
            'fileTypeDesc': '请选择xls,xlsx文件',
            'fileTypeExts': '*.xls;*.xlsx',		// Multiple extensions should be separated by semi-colons (i.e. ‘*.jpg; *.png; *.gif’).
            'multi': false,
            'progressData': 'percentage',  // The two options are ‘percentage’ or ‘speed’.
            'removeCompleted': true,		// Set to false to keep files that have completed uploading in the queue.
            'removeTimeout': 0.1,			// The delay in seconds before a completed upload is removed from the queue.
            'successTimeout': 60,			// The time in seconds to wait for the server’s response when a file has completed uploading.After this amount of time,the SWF file will assume success.
            //'uploadLimit' : 1,			// The maximum number of files you are allowed to upload.When this number is reached or exceeded,the onUploadError event is triggered.
            // Triggered when the instance of Uploadify is disabled by calling the disable method.
            'onEnable': function () {
                $('#file3').uploadify('settings', 'buttonText', '请选择Excel文件');
                $('#file3').uploadify('settings', 'formData', {
                    'reportIndex': '3', 'reportName': $("#report3").val()
                });
            },
            // Triggered when the Flash object is loaded and ready.
            'onSWFReady': function () {
                $('#file3').uploadify('disable', false);
            },
            // Triggered for each file that successfully uploads.
            'onUploadSuccess': function (file, data, response) {
                //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                var json = $.parseJSON(data);
                // result -9:参数有误 -8:versionCode和versionName不能为空 -1:apk包非法  0:上传失败  1:上传成功且验证通过
                if (json.result == -9) {
                    alert("参数有误，请重试");
                    window.location.reload();
                    return;
                }
                window.location.reload();
            }
        });


        $('#file4').uploadify({
            'swf': '${ctx}/resources/customize/uploadify/uploadify.swf',
            'uploader': '${ctx}/uploadReport;jsessionid=${pageContext.session.id}',
            // Your options here
            'buttonText': '请选择Excel文件',
            // An object containing additional data to send via get or post with each file upload.
            'formData': {'reportIndex': '4', 'reportName': $("#report4").val()},
            'fileSizeLimit': '20MB',
            'fileTypeDesc': '请选择xls,xlsx文件',
            'fileTypeExts': '*.xls;*.xlsx',		// Multiple extensions should be separated by semi-colons (i.e. ‘*.jpg; *.png; *.gif’).
            'multi': false,
            'progressData': 'percentage',  // The two options are ‘percentage’ or ‘speed’.
            'removeCompleted': true,		// Set to false to keep files that have completed uploading in the queue.
            'removeTimeout': 0.1,			// The delay in seconds before a completed upload is removed from the queue.
            'successTimeout': 60,			// The time in seconds to wait for the server’s response when a file has completed uploading.After this amount of time,the SWF file will assume success.
            //'uploadLimit' : 1,			// The maximum number of files you are allowed to upload.When this number is reached or exceeded,the onUploadError event is triggered.
            // Triggered when the instance of Uploadify is disabled by calling the disable method.
            'onEnable': function () {
                $('#file4').uploadify('settings', 'buttonText', '请选择Excel文件');
                $('#file4').uploadify('settings', 'formData', {
                    'reportIndex': '4', 'reportName': $("#report4").val()
                });
            },
            // Triggered when the Flash object is loaded and ready.
            'onSWFReady': function () {
                $('#file4').uploadify('disable', false);
            },
            // Triggered for each file that successfully uploads.
            'onUploadSuccess': function (file, data, response) {
                //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                var json = $.parseJSON(data);
                // result -9:参数有误 -8:versionCode和versionName不能为空 -1:apk包非法  0:上传失败  1:上传成功且验证通过
                if (json.result == -9) {
                    alert("参数有误，请重试");
                    window.location.reload();
                    return;
                }
                window.location.reload();
            }
        });
    });

    function switchUplodify(index) {
        $('#file' + index).uploadify('disable', true);
        $('#file' + index).uploadify('disable', false);
    }

</script>
</body>
</html>

