Files
zszq-trs/YLErpWeb/Views/clientbalance/TradeMarketReportConfigureImport.cshtml
T
2024-05-09 14:06:26 +08:00

119 lines
4.5 KiB
Plaintext

@model YLErp.Modules.MarginModule.MarginParamsImportResult
@{
ViewBag.Title = "报告配置导入";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section CSS{
<style>
.templateTip dd, .templateTip dt {
line-height: 22px;
letter-spacing: 2px;
margin-bottom: 5px;
}
</style>
}
@section JS{
<script type="text/javascript">
function upload() {
if ($("#openFile").val() === "" || $("#openFile").val() == null || $("#openFile").val() === "undefined") {
showmiddlemessage("请选择要导入的文件!");
return false;
}
var fileName = $("#openFile").val();
var ext, idx;
if (fileName == '') {
main.alert("请选择需要上传的文件!");
return false;
} else {
idx = fileName.lastIndexOf(".");
if (idx != -1) {
ext = fileName.substr(idx + 1).toUpperCase();
ext = ext.toLowerCase();
// alert("ext="+ext);
if (ext != 'xlsx') {
main.alert("只能上传.xlsx类型的文件!");
return false;
}
} else {
main.alert("只能上传.xlsx类型的文件!");
return false;
}
}
main.confirm("确定导入?", function () {
var formData = new FormData($('form')[0]);
$.ajax({
url: '/clientbalance/ImportMarketReportConfigure', //server script to process data
type: 'POST',
xhr: function () { // custom xhr
myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // check if upload property exists
myXhr.upload.addEventListener('progress', progressHandlingFunction, false); // for handling the progress of the upload
}
return myXhr;
},
beforeSend: function () {
main.waitMe("show");
},
success: function (data) {
try {
if (data.success) {
(parent || window).main.message("导入成功!");
if (window.parent && window.parent.reloadConfigure) {
window.parent.reloadConfigure();
}
parent.layer.closeAll();
} else {
main.alert(data.msg);
}
} catch (e) {
} finally {
main.waitMe("hide");
$('#openFile').val('');
}
},
error: function (data) {
main.message("导入失败:{0}".template(data.msg));
main.waitMe("hide");
},
// Form数据
data: formData,
//Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: false,
processData: false
});
});
}
function progressHandlingFunction(e) {
if (e.lengthComputable) {
$('progress').attr({ value: e.loaded, max: e.total });
}
}
function closeMarketReportConfigureImportWindow() {
try { window.parent.layer.closeAll(); } catch (e) { }
}
</script>
}
@using (Html.BeginForm("TradeMarketReportConfigureImport", "clientbalance", FormMethod.Post, new { id = "MarketReportConfigureImportForm" }))
{
<div class="well" style="margin:0px auto;margin-top:10px;">
<fieldset>
<legend>选择文件</legend>
<input type="file" id="openFile" name="file" accept=".xlsx" />
</fieldset>
</div>
<div style="margin:0px auto;padding:10px;">
@MyControls.Btn("批量报告配置导入", "upload()")
@MyControls.Btn("批量报告配置模板下载", "main.downloadFiles('/App_Docs/结算报告配置导入模板.xlsx')")
@MyControls.Btn("关闭", "closeMarketReportConfigureImportWindow()")
</div>
}