You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
10 KiB
Plaintext

11 months ago
<!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>
<title>数据导入</title>
<link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
<link href="../../Scripts/SyntaxHighlighter/Styles/shCoreDefault.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/SyntaxHighlighter/shCore.js" type="text/javascript"></script>
<script src="../../Scripts/SyntaxHighlighter/shBrushCSharp.js" type="text/javascript"></script>
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../Scripts/QueryString.js"></script>
<script type="text/javascript" src="../../Scripts/config.js"></script>
<script type="text/javascript" src="../../Comm/Gener.js"></script>
<script type="text/javascript">
var frmID;
$(function () {
frmID = GetQueryString("FrmID");
var mapData = new Entity("BP.Sys.MapData");
mapData.No = frmID;
mapData.RetrieveFromDBSources();
if (mapData != null) {
$("#title").html(mapData.Name + ":信息导入");
}
var mapAttrs = new Entities("BP.Sys.MapAttrs");
mapAttrs.Retrieve("FK_MapData", frmID,"Idx");
var cols = "<table>";
cols += "<tr>";
for (var i = 0; i < mapAttrs.length; i++) {
var attr = mapAttrs[i];
if (attr.UIIsVisable == false)
continue;
//排除OID主键
if(attr.KeyOfEn == 'OID')
continue;
cols += "<th>"+ attr.Name + "</th>";
}
cols += "</tr>";
for (var idx = 0; idx < 3; idx++) {
cols += "<tr>";
for (var i = 0; i < mapAttrs.length; i++) {
var attr = mapAttrs[i];
if (attr.UIIsVisable == false)
continue;
cols += "<td></td>";
}
cols += "</tr>";
}
$("#cols").html(cols);
});
//数据导入.
function Imp_Done() {
var impWay = GetRadioValue("RB_ImpType");
var fileValue = $("#File_Upload").val();
//必须要选择文件
if (fileValue == "") {
$.messager.alert("提示", "没有选择要导入信息的Execl表。");
return;
}
//扩展名
var index = fileValue.lastIndexOf('.');
var fileExt = fileValue.substring(index);
if (fileExt.toLowerCase() != ".xls" && fileExt.toLowerCase() != ".xlsx") {
$.messager.alert("提示", "所选不是excel文件请重新选择。");
return;
}
//页面按钮失效
//$("#File_Upload").attr("disabled",true);
$("#Button1").attr("disabled", true);
$("input[name='RB_ImpType']").attr("disabled", "disabled");
//URL 路径
var doMethod = "ImpData_Done";
var httpHandlerName = "BP.CCBill.WF_CCBill";
var url = dynamicHandler + "?DoType=HttpHandler&DoMethod=" + doMethod + "&HttpHandlerName=" + httpHandlerName + "&ImpWay=" + impWay + "&FrmID=" + frmID;
//提交数据
$("#cc").form("submit", {
type: 'POST',
dataType: 'html',
url: url,
onSubmit: function (param) {
//return false; //这里可以做表单的验证如果验证失败就return false 来终止表单提交
},
success: function (data) {
$("#Button1").attr("disabled", false);
$("input[name='RB_ImpType']").attr("disabled", false);
if (data.indexOf("err@") != -1 && data.indexOf("errInfo=") == -1) {
alert(data);
$("#result").html('');
$("#result").append("<span style='color:red'>导入失败</span><br/>");
$("#result").append(data);
return;
}
$("#result").html('');
$("#result").append("<span>导入成功</span><br/>")
var datas = data.split("@Split");
var waringInfo = datas[0].replace("errInfo=", "");
var count = datas[1].replace("count=", "");
var successInfo = datas[2].replace("successInfo=", "");
var changeCount = datas[3].replace("changeCount=", "");
$("#result").append("成功导入条数&nbsp;&nbsp;&nbsp;" + count + "<br/>");
if (impWay != 0)
$("#result").append("成功更新条数&nbsp;&nbsp;&nbsp;" + changeCount + "<br/>");
$("#result").append("成功导入数据<br/>");
$("#result").append(successInfo);
$("#result").append("<span style='color:red'>警告</span><br/>");
$("#result").append(waringInfo);
}
});
}
function downloadFile() {
var frmID = GetQueryString("FrmID");
var downloadUrl = "../../../DataUser/TempleteOfImp/" + frmID + ".xls";
var a = document.getElementById("downFileID");
a.href = downloadUrl;
a.download = frmID + ".xls";
a.click();
}
function Back() {
var frmID = GetQueryString("FrmID");
var EntityType = GetQueryString("EntityType");
var md = new Entity("BP.Sys.MapData", frmID);
EntityType = md.EntityType;
var url = "../SearchDict.htm?EnsName=" + frmID + "&FrmID=" + frmID;
if (EntityType == "2")
url = "../SearchBill.htm?EnsName=" + frmID + "&FrmID=" + frmID;
if (EntityType == "1")
url = "../SearchDict.htm?EnsName=" + frmID + "&FrmID=" + frmID;
SetHref(url);
}
</script>
</head>
<body>
<form id="cc" name="cc" action="" enctype="multipart/form-data" method="post">
<table style=" width:100%">
<caption id="title">设备信息导入 </caption>
<tr>
<td valign="top">
<fieldset>
<legend> 从本机导入 </legend>
<h3>操作步骤</h3>
<ul>
<li>
第1步:
<a href="#" onclick="downloadFile()">
<img style="width: 16px; height: 16px;" src="../../Img/Btn/Save.gif" border="0" />
下载导入数据模板
</a>
- 如果没有下载到模版,请通知管理员设计一个模版。 <b>请参考帮助设计一个模版</b>
</li>
<!--<li> 请下载模版<a href=""> </a></li>-->
<li>第2步:选择在模版里组织好要导入的数据. <font color="red">警告:如果要擅自修改表格里列名或修改excel的版本存储格式就会导致导入错误。</font></li>
<li>第3步:从本机导入请您选择Excel文件 点击导入按钮完成导入。</li>
<li> 请选择文件: <input type="file" id="File_Upload" name="File_Upload" /></li>
<li>
导入的方式:
<ul>
<li><input id="Import_0" type="radio" name="RB_ImpType" value="0" checked="true" /><label for="Import_0">清空方式导入.</label></li>
<li><input id="Import_1" type="radio" name="RB_ImpType" value="1" /><label for="Import_1">更新方式导入.</label></li>
<li><input id="Import_2" type="radio" name="RB_ImpType" value="2" /><label for="Import_2">追加方式导入.</label></li>
</ul>
</li>
</ul>
<div style=" text-align:center; padding:5px;">
<input type="button" id="Button1" value="执行导入" onclick="Imp_Done();" />
<input type="button" id="Button2" value="返回列表" onclick="Back();" />
</div>
<ul>
<li>如果导入失败:也许是服务器的环境问题,请在服务器上安装 <font color="red">AccessDatabaseEngine.exe</font>试试看。</li>
</ul>
</fieldset>
<fieldset>
<legend>数据模版制作说明</legend>
<ul>
<li>新建一个Excel文件比如 AAA.xls,</li>
<li>在excel的工具栏中找到文件另存为命令选择 (excel97-2003工作簿)格式. </li>
<li>在第一行数据填入如下列 </li>
<li> <div id="cols"></div></li>
<li>测试该模版是否可用,如果可用就把该文件放到 \DatUser\\TempleteOfImp\\</li>
<li> 如果不可用请尝试下载一个AccessDatabaseEngine.exe 文件安装到服务器上试试.</li>
</ul>
</fieldset>
<fieldset>
<legend>导入结果</legend>
<div id="result"></div>
</fieldset>
</td>
</tr>
</table>
<a id="downFileID" href="#" style="display:none"></a>
</form>
</body>
</html>