<%@page import="org.activiti.engine.repository.ProcessDefinition"%>
<%@page import="org.activiti.engine.repository.Deployment"%>
<%@page import="com.blueland.bpm.engine.config.model.*"%>
<%@page import="com.blueland.bpm.common.page.*"%>
<%@page import="com.blueland.bpm.common.util.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/commons/meta.jsp"%>
<link href="${ctx}/resource/js/plugins/loadmask/jquery.loadmask.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='${ctx}/resource/js/plugins/loadmask/jquery.loadmask.js'></script>
<base href="<%=basePath%>">
<title>导入流程模型</title>
<script>
	$(document).ready(function() {
		$('#file').ace_file_input({
			no_file : '请您选择本地BPMN文件！ ...',
			btn_choose : '选 择',
			btn_change : '选 择',
			droppable : false,
			onchange : null,
			thumbnail : false
		//| true | large
		//whitelist:'gif|png|jpg|jpeg'
		//blacklist:'exe|php'
		//onchange:''
		//
		});
		var flashSuccess = $("#flashSuccess").attr("value");
		if (flashSuccess == "导入成功!") {
			alert(flashSuccess);
			art.dialog.opener.location.reload();
			art.dialog.close();
		} else {
			if (flashSuccess != "") {
				alert(flashSuccess);
			}
			//bindMask();
		}
	});

	function onSubmit() {
		if ($("#file").val() == "" || $("#file").val().length == 0) {
			//unBindMask();
			alert("请您选择本地文件！");
			return false;
		}
		if(!getFileFormat()){
			alert("请上传符合要求的文件!");
			return false;
		}
		//else{
		//	alert("文件符合要求");
		//	return false;
		//}
		setMask("main-container");
		document.getElementById("deployFieldForm").submit();
	}
	
	//判断文件的格式与文件的大小
	function getFileFormat(){
		//var aa = "*.zip、*.bar、*.bpmn\bpmn20.xml";
		var obj = document.getElementById('file');
		var fileName = obj.value;
	    var fileExt=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
	    if(fileExt=='.zip' || fileExt=='.bar' || fileExt=='.bpmn' || fileName.indexOf("bpmn20.xml") > 0){
	    	return true;
	    }else{
		     return false;
	    }
	}
</script>
</head>
<body>
	<%@ include file="/commons/messages.jsp"%>
	<div class="main-container" id="main-container">
		<div class="widget-box">
			<div class="widget-body">
				<div class="widget-main no-padding">
					<form id="deployFieldForm" name="deployFieldForm" action="${ctx}/procModelMgr/importBpmnFile.do" method="post" enctype="multipart/form-data">
						<!-- <legend>Form</legend> -->
						<fieldset>
							<ol>
								<li class="text-success"><b>暂只支持导入格式为*.zip、*.bar、*.bpmn\bpmn20.xml的模型文件，不支持批量导入。</b></li>
								<li class="text-success"><b>导入成功后可在(流程定义->已部署流程定义)菜单中管理该流程。</b></li>
							</ol>
							<div class="space-18"></div>
							<input type="hidden" id="flashSuccess" value="${flashSuccess }" />
								<input type="file" id="file" name="file"/>
						</fieldset>

						<div class="form-actions center">
							<button type="button" class="btn btn-sm btn-primary"
								id="submitButton" onclick="onSubmit();">
								导入
								<i class="ace-icon fa fa-cloud-upload bigger-110"></i>
							</button> 
							<button
								onclick="art.dialog.close();" type="button"
								class="btn btn-sm btn-primary">
								关闭
								<i class="ace-icon fa fa-times bigger-110"></i>
							</button>

						</div>
					</form>
				</div>
			</div>
		</div>
</body>
</html>



