<div class="container-fluid edit-form-padding">
    <form id="importForm" class="form-horizontal" th:attr="action=${importUrl}"  method="post">
		<input type="hidden" th:value="${moduleName}" id="moduleName"/>
		<input type="hidden" th:value="${importUrl}" id="importUrl"/>
	    <div class="form-group">
	        <label class="col-xs-4 control-label">下载导入模版：</label>
	        <a class="col-xs-1 control-label" th:href="@{/csvData/downloadDataTemplate(moduleName=${moduleName})}">
	            下载
	        </a>
	    </div>
	    <div class="form-group">
	        <label class="col-xs-4 control-label">选择导入文件：</label>
	        <div class="col-xs-4">
	            <input class="control-label" type="file" name="file"/>
	        </div>
	    </div>
    </form>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        var moduleName = $('#moduleName').val();
        var importUrl = $('#importUrl').val();
        
        $("#importForm").validate({
            submitHandler: function (form) {
            	$("#importForm").attr('action',importUrl);
                $(form).ajaxSubmit({
                    success: function (e) {
                        if (e && e.success == true) {
                            sxUtil.msgbox.success('导入成功！');
                            $("#refresh").click();
                            sxUtil.dialog.close($(form).data('index'));
                        } else {
                        	 sxUtil.msgbox.error(e, e.msg);
                        }
                    }
                });
            }
        });
    });
</script>
