appio.jsp 8.18 KB

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/mobilemode/init.jsp"%>
<%
if(!HrmUserVarify.checkUserRight("MobileModeSet:All", user)){
	return;
}
int subCompanyId = Util.getIntValue(request.getParameter("subCompanyId"),-1);
if(mmdetachable.equals("1")){
	if(subCompanyId == -1){
		subCompanyId=Util.getIntValue(Util.null2String(session.getAttribute("mobilemode_defaultSubCompanyId")),-1);
	    if(subCompanyId == -1){
	        subCompanyId = user.getUserSubCompany1();
	    }
	}
}else{
	subCompanyId = -1;
}
int operatelevel = getCheckRightSubCompanyParam("MobileModeSet:All",user,mmdetachable ,subCompanyId);//权限等级-> 2完全控制 1 编辑 0 只读
if(operatelevel < 2){
	response.sendRedirect("/notice/noright.jsp");
	return;
}
%>
<HTML><HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
*{
	font: 12px Microsoft YaHei;
}
html,body{
	height: 100%;
	margin: 0px;
	padding: 0px;
	overflow: hidden;
}
.divBtn{
    display: block;
    width: 100%;
    padding: 5px 0;
    background-color: #0066b1;
    color: #fff;
    font-family: 'Microsoft YaHei', Arial;
    font-size: 12px;
    line-height: 20px;
    margin-left: 1px;}
.divBtn.disabled {
	cursor: not-allowed;
	background-color: #ccc;
}
.divBtn:hover {
	opacity: .9;}
.btn-container {
    width: 100%;
    position: absolute;
    bottom: 20px;
    left: 0;
    padding: 0 24px;
    box-sizing: border-box;}
.divBtnDisabled{
	background-color: #E9E9E9 !important;
}
.subCompany-choose{
	font-size: 14px;
	text-align:center;
	margin-bottom:20px;
	display:table;
}
.subCompany-choose div{
	display:inline-block;
    height: 30px;
    line-height: 30px;
    padding: 0 5px;
    color:#000;
    display:table-cell;
}

.subCompany-choose div:nth-child(2){
	padding-right: 20px;
    background-image: url(/wui/theme/ecology8/skins/default/general/browser_wev8.png);
    background-position: right center;
    background-repeat: no-repeat;
    background-size: 16px;
    cursor:pointer;
    border-bottom: 1px solid #e8e8e8;
    min-width:50px;
}

.file {
    position: relative;
    color: #666;
    width: 100%;
    height: 115px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    line-height: 115px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px dashed #cfcfcf;}
.file:hover {
	text-decoration: underline;
	color: #666;}
.file input{
	position: absolute;
	left: 0;
	width: 100%;
	height: 100%;
	background-color:#fff;
	opacity: 0;
	cursor: pointer;
}
.loading {
    position: absolute;
	display: none;
    background-color: #fff;
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
    border: 2px solid #fff;
    border-bottom-color: transparent;
    height: 11px;
    width: 11px;
    bottom: 7px;
    left: calc(50% - 55px);
    border-radius: 100%;
    background: transparent !important;
    -webkit-animation: rotate 0.75s 0s linear infinite;
    animation: rotate 0.75s 0s linear infinite;}
@keyframes rotate {
	0% {
	    transform: rotate(0deg);
		-ms-transform: rotate(0deg);
		-webkit-transform: rotate(0deg);
	}
	50% {
	    transform: rotate(180deg);
		-ms-transform: rotate(180deg);
		-webkit-transform: rotate(180deg);
	}
	100% {
	    transform: rotate(360deg);
		-ms-transform: rotate(360deg);
		-webkit-transform: rotate(360deg);
	}	
}
</style>
<script>
function onClose(){
	top.closeTopDialog();
}

function importwf(e){
	if($(this).hasClass("disabled")) return;

	var parastr="filename";
	var filename = document.frmMain.filename.value;
	var pos = filename.length-4;
	<%if(mmdetachable.equals("1")){%>
	var subCompanyId = $("#subCompanyId").val();
	if(subCompanyId == ""){
		alert("<%=SystemEnv.getHtmlLabelName(82181,user.getLanguage())%>");//请选择分部
		return;
	}
	<%}%>
	if(filename==null||filename==''){
		alert("<%=SystemEnv.getHtmlLabelName(127672,user.getLanguage())%>");//请选择文件!
	}else{
		if(filename.lastIndexOf(".jar")==pos || filename.lastIndexOf(".zip")==pos){
			clearMessage();
			disabledBtn();
			changeBtnText(true);
			$('.loading').toggle();
			$.ajax({
				url: "/api/mobilemode/admin/app/import",
				data: new FormData(document.frmMain),
				type: 'post',
				processData: false,
				contentType: false,
				success: function(result) {
					result = JSON.parse(result);	
					
					if(!result.api_status) {
						$('.loading').toggle();
						changeBtnText(false);
						$("#filename").val("").trigger("change");
						alert("<%=SystemEnv.getHtmlLabelName(389565,user.getLanguage())%>")//"导入失败,请选择正确的应用文件!"
						return;
					}

					top.callTopDlgHookFn(result.data);
					top.closeTopDialog();
				}
			});
		}else{
			alert("<%=SystemEnv.getHtmlLabelName(81992,user.getLanguage())%>");//选择文件格式不正确,请选择zip文件!
			return;
		}
	}
}

function clearMessage(){
	var upload_faceico = document.getElementById("upload_faceico");
	var upload_faceicoDoc = upload_faceico.contentWindow.document;
	if(upload_faceicoDoc && upload_faceicoDoc.body){
		upload_faceicoDoc.body.innerHTML = "";
	}
}

function changeBtnText(isimport) {
	var $uploadBtn = $("#uploadBtn");

	if(!$uploadBtn.data("text")) $uploadBtn.data("text", $uploadBtn.text());

	if(isimport) return $uploadBtn.text("<%=SystemEnv.getHtmlLabelName(389566,user.getLanguage())%>");//"正在导入中..."

	$uploadBtn.text($uploadBtn.data("text"));
	
}

function disabledBtn(){
	$("#uploadBtn").addClass("disabled");
}

function enabledBtn(){
	$("#uploadBtn").removeClass("disabled");
}
function selectSubCompany(){
	var winHight = jQuery(window).height();
	var winWidth = jQuery(window).width();
	var dialog = new window.top.Dialog();
	dialog.currentWindow = window;
	dialog.Width = 580;
	dialog.Height = 630;
	dialog.normalDialog = false;
	dialog.URL = "/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser2.jsp?rightStr=MobileModeSet:All&isedit=1";
	dialog.callbackfun = function (paramobj, id1) {
		if(id1){
			var id = id1.id;
			var name = id1.name;
			
			$("#subCompanyName").html(name);
			$("#subCompanyId").val(id);
		}
	};
	dialog.Title = "<%=SystemEnv.getHtmlLabelName(33256,user.getLanguage())%>";//选择分部
	dialog.Drag = false;
	dialog.show();
}

$(function() {
	var _defaulTip = $(".file").find("span").text(); 

	$("#filename").change(function(e) {
		var $span = $(".file").find("span"),
			value = $(this).val();

		flag = !value;
		value = flag ? _defaulTip : value;

		$span.text(value);
		$(".divBtn").toggleClass("disabled", flag);
	}).click(function(e) {
		var $span = $(".file").find("span");

		$(this).val("").trigger("change");
	});

	$("#uploadBtn").click(importwf);
});
</script>
</HEAD>
<body>
<FORM style="MARGIN-TOP: 0px;padding:20px 25px" name=frmMain method=post action="" enctype="multipart/form-data" target="upload_faceico">
	<%if(mmdetachable.equals("1")){%>
	<div class="subCompany-choose">
		<div><%=SystemEnv.getHtmlLabelName(19799,user.getLanguage())%>:<!-- 所属分部 --></div>
		<div onclick="selectSubCompany()">
		<span id="subCompanyName"><%if(subCompanyId == -1){%>
			<%=SystemEnv.getHtmlLabelName(82181,user.getLanguage())%><!-- 请选择分部 -->
		<%}else{%>
			<%=SubCompanyComInfo.getSubCompanyname(""+subCompanyId) %>
		<% } %></span>
		<input type="hidden" id="subCompanyId" name="subCompanyId" value="<%=subCompanyId %>"/>
		</div>
	</div>
	<%}else{%>
	<input type="hidden" id="subCompanyId" name="subCompanyId" value="<%=subCompanyId %>"/>
	<%} %>
	
	<a class="file"><input  type="file"  name="filename" id="filename"><span><%=SystemEnv.getHtmlLabelName(383281,user.getLanguage())%><!-- 发布状态 --><div class="e8_label_desc"><%=SystemEnv.getHtmlLabelName(389567,user.getLanguage())%><!-- 点击这里选择需要上传的文件 --></span></a>
	
	<div class="btn-container"><button type="button" id="uploadBtn" class="divBtn disabled"><%=SystemEnv.getHtmlLabelName(25649,user.getLanguage())%><!-- 开始导入 --></button><span class="loading"></span></div>
</FORM>
<div style="overflow:hidden;height:200px;display:none;">
	<div style="float:left;height:100%;margin-left: 25px;vertical-align:middle;">Message:</div>
	<div style="float:left;height:100%;"><iframe id="upload_faceico" name="upload_faceico" style="height:100%;border:0px;"></iframe></div>
</div>
</body>
</html>