TG.WXCRM.V4/WEB/Views/Control/_ExcelUploadToolUC.cshtml

357 lines
16 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=11;IE=10; IE=9; IE=8; IE=7; IE=EDGE">
@Styles.Render("~/Content/themes/blue/css")
<script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
@RenderSection("scripts", required: false)
<script src="@Url.Content("~/Scripts/op/jquery.rewrite.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.form.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/op/main_op.js")"></script>
@Styles.Render("~/Content/css")
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jQuery.validator.noinput.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.easyui.plus.js")"></script>
<script src="@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")"></script>
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Common.css")" />
<link href="~/Content/main.css" rel="stylesheet" />
<style>
.ncontent {
padding: 4px 10px;
}
</style>
</head>
<body style="overflow-y:scroll;">
<script>
window.parent.SetIframeScrolling(window.location.href, true);
$(function () {
$('#uploadForm').ajaxForm({
dataType: 'json',
beforeSend: ForEverajaxLoading,
complete: ForEverajaxLoadEnd,
success: function (data) {
$("#fileName").val(data.fileName);
if (data.type == 1) {
ShowStep(2);//进入第二部
}
ShowResult(data);
}
});
var step = '@ViewBag.step';
if (step != "1")
ShowStep(step);
});
function UploadClick() {
var ImpType = "@ViewBag.ImpTypeConfig";
var fileControlName = "";
var fileControlName2 = "";
if (ImpType == "0")
fileControlName = "uploadFile";
else if (ImpType == "1") {
fileControlName = "uploadFile";
fileControlName2 = "uploadFile2";
} else {
fileControlName = "uploadFile2";
}
var str = $("#" + fileControlName).val();
if (str == null || str == "") {
$.messager.alert("警告", "文件不能为空!", "error");
return;
}
var pos = str.lastIndexOf(".");
var lastname = str.substring(pos, str.length);
var resultName = lastname.toLowerCase();
if ('.csv' != resultName.toString() && '.xls' != resultName.toString() && '.xlsx' != resultName.toString()) {
$.messager.alert("警告", '只能上传csv或xls或xlsx文件您上传的文件类型为' + lastname + ',请重新上传', "error");
return;
}
if (ImpType == "1") {
str = $("#" + fileControlName2).val();
if (str == null || str == "") {
$.messager.alert("警告", "新文件不能为空!", "error");
return;
}
pos = str.lastIndexOf(".");
lastname = str.substring(pos, str.length);
resultName = lastname.toLowerCase();
if ('.csv' != resultName.toString() && '.xls' != resultName.toString() && '.xlsx' != resultName.toString()) {
$.messager.alert("警告", '只能上传csv或xls或xlsx文件您上传的文件类型为' + lastname + ',请重新上传', "error");
return;
}
}
$('#uploadForm').submit();
}
function LoadData(pageIndex) {
$.r_ajax({
url: "/Control/GetDataTableByCache",
type: "Post",
data: { dataType: '@ViewBag.dataType', pageIndex: pageIndex },
dataType: "json",
loading: true,
success: function (data) {
ShowResult(data);
}
});
}
///显示结果(公用)
function ShowResult(data) {
if (data.type == 1) {
$("#neirong").html("");
$("#neirong").append(data.tabHtml);
} else {
$.messager.alert("警告", data.message, "error");
}
}
//放弃导入
function btn_GiveUpImport_Click() {
$.messager.confirm("提示", "您确定要放弃导入吗?", function (r) {
if (!r)
return;
$.r_ajax({
url: "/Control/SaveOrGiveUPToDatabase",
type: "Post",
data: { dataType: '@ViewBag.dataType', type: 0, fileName: $("#fileName").val(), importId: $("#importId").val() },
dataType: "json",
loading: true,
success: function (data) {
if (data.type) {
ShowStep(1);//放弃导入回到第一步
}
}
});
})
}
//数据导入
function btn_DataImport_Click() {
$.r_ajax({
url: "/Control/SaveOrGiveUPToDatabase",
type: "Post",
data: { dataType: '@ViewBag.dataType', type: 1, fileName: $("#fileName").val(), importId: $("#importId").val() },
dataType: "json",
loading: true,
success: function (data) {
if (data.type == 1) {
$.messager.alert("提示", "数据导入成功!", "info");
$("#importId").val(data.importId);
ShowStep(4);//进入到了第三部
} else {
$.messager.alert("警告", data.message, "error");
$("#btn_DataImport").val("重试");
$("#btn_GiveUpImport").val("放弃");
}
}
});
}
//数据验证
function btn_DataCheck_Click() {
$.r_ajax({
url: "/Control/CheckExcelUploadDataTable",
type: "Post",
data: { dataType: '@ViewBag.dataType', pageIndex: 1 },
dataType: "json",
loading: true,
success: function (data) {
if (data.type == 1) {
ShowResult(data);
ShowStep(3);
if (data.valid == 0) {
$("#spErroMsg").html("信息提示:<br />&nbsp;&nbsp;&nbsp;<font color='red'>验证不通过请修改核定excel正确后再次上传导入下面是错误记录</font>");
$("#btn_DataImport").css("display", "none");
} else if (data.valid == 2) {
$("#spErroMsg").html("信息提示:<br />&nbsp;&nbsp;&nbsp;<font color='red'>验证不通过!" + data.message + "</font>");
$("#btn_DataImport").css("display", "none");
}
else {
$("#spErroMsg").html("信息提示:<br />&nbsp;&nbsp;&nbsp;<font color='green'>验证已经通过!</span>");
}
} else {
$.messager.alert("警告", data.message, "error");
$("#btn_DataCheck").val("重试验证");
}
}
});
}
//生成业务数据
function btn_SyncBusinessData() {
$.r_ajax({
url: "/Control/SyncBusinessData",
type: "Post",
data: { dataType: '@ViewBag.dataType', importId: $("#importId").val() },
dataType: "json",
loading: true,
success: function (data) {
if (data.type == 1) {
$.messager.alert("提示", "此次导入文件数据成功!", "info");
$("#message").html("信息提示:<br>&nbsp;&nbsp;&nbsp;&nbsp;此次导入文件数据成功!<a href='javascript:window.location.href=window.location.href' title='点击返回第一步,继续导入!'>继续导入</a>");
$("#jieguo").css("display", "none")
} else {
$.messager.alert("警告", data.message, "error");
var giveUp = "";
$("#btn_SyncBusinessData").val("重试");
$("#btn_Give").css("display", "none");
}
}
});
}
//放弃生成业务数据
function btn_Give_Click() {
ShowStep(1);//放弃了回到第一步
}
//显示步骤
function ShowStep(step) {
$(".content_div").css("display", "none");
if (step == 1) {
window.location.href = window.location.href;//直接刷新页面
//$("#neirong").html("");
//$("#step1").css("display", "block");
} else if (step == 2) {
$("#step2").css("display", "block");
$("#neirong").css("display", "block");
} else if (step == 3) {
$("#step3").css("display", "block");
$("#neirong").css("display", "block");
}
else if (step == 4) {
$("#neirong").html("");
$("#step4").css("display", "block");
}
}
</script>
<div id="step1" class="content_div ncontent">
<table class="layui-table" style="width:100%">
<thead>
<tr>
<td>
第一步:<font color="#49afcd">@(ViewBag.name)</font>上传文件
&nbsp;
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
@{
string ImpTypeConfig = Convert.ToString(ViewBag.ImpTypeConfig);
if (string.IsNullOrEmpty(ImpTypeConfig))
{
ImpTypeConfig = "0";
}
}
@if (IsSectionDefined("content"))
{
@RenderSection("content", false)
}
else
{
<form name="uploadForm" action="/Control/CreateDataTableByExcel" method="post" id="uploadForm" enctype="multipart/form-data">
@if (ImpTypeConfig == "0")//旧方式
{
<input name="uploadFile" accept=".csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="uploadFile" type="file" />
}
else if (ImpTypeConfig == "1")//新旧综合方式
{
<br />
<span>旧文件:</span><input name="uploadFile" accept=".csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="uploadFile" type="file" /><br />
<span>新文件:</span><input name="uploadFile2" accept=".csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="uploadFile2" type="file" />
}
else//新方式
{
<span>新文件:</span><input name="uploadFile2" accept=".csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="uploadFile2" type="file" />
}
@*<input name="uploadFile" accept="application/vnd.ms-excel" id="uploadFile" type="file" />*@
<input name="dataType" type="hidden" value="@ViewBag.dataType" />
<input name="importId" id="importId" type="hidden" value="@ViewBag.importId" />
<input name="fileName" id="fileName" type="hidden" value="" />
<input value="上传" type="button" class="btn btn-primary" onclick="UploadClick()" id="btn_import" />
</form>
}
</td>
</tr>
@RenderSection("firstMessage", false)
</tbody>
</table>
</div>
<div id="step2" class="content_div ncontent" style="display:none;">
<table class="layui-table" style="width:100%">
<thead>
<tr>
<td>
第二步:<font color="#49afcd">@(ViewBag.name)</font>数据预览
&nbsp;
</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="100">
<input type="button" onclick="btn_GiveUpImport_Click()" id="btn_GiveUpImport" class="btn btn-danger" value="放弃导入">
&nbsp;&nbsp;&nbsp;
<input type="button" onclick="btn_DataCheck_Click()" id="btn_DataCheck" class="btn btn-primary" value="数据验证">
</td>
</tr>
</tbody>
</table>
</div>
<div id="step3" class="content_div ncontent" style="display:none;">
<table class="layui-table" style="width:100%">
<thead>
<tr>
<td>
第三步:<font color="#49afcd">@(ViewBag.name)</font>数据验证结果
&nbsp;
</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="100">
<input type="button" onclick="btn_GiveUpImport_Click()" id="btn_GiveUpImport2" class="btn btn-danger" value="放弃导入">
&nbsp;&nbsp;&nbsp;
<input type="button" onclick="btn_DataImport_Click()" id="btn_DataImport" class="btn btn-primary" value="导入">
</td>
</tr>
<tr>
<td id="spErroMsg"></td>
</tr>
</tbody>
</table>
</div>
<div id="neirong" class="content_div ncontent" style="display:none;"></div>
<div id="step4" class="content_div ncontent" style="display:none;">
<table class="layui-table" style="width:100%">
<thead>
<tr>
<td>
第四步:<font color="#49afcd">@(ViewBag.name)</font>生成业务数据
&nbsp;
</td>
</tr>
</thead>
<tbody>
<tr>
<td id="jieguo">
<input value='放弃' type='button' class='btn btn-danger' id='btn_Give' onclick='btn_Give_Click()' style="display:none" />&nbsp;&nbsp;&nbsp;
<input value='生成业务数据' type='button' class='btn btn-primary' id='btn_SyncBusinessData' onclick='btn_SyncBusinessData()' />
</td>
</tr>
<tr>
<td id="message">
信息提示:<br />&nbsp;&nbsp;&nbsp;<span style="color:green;">数据已经成功入库!您现在可以生成业务数据!</span>
</td>
</tr>
</tbody>
</table>
</div>
@RenderBody()
</body>
</html>