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

121 lines
4.6 KiB
Plaintext

@model trade
@{
ViewBag.Title = "计算管理 | 行权批量执行";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section JS
{
<script type="text/javascript">
function upload() {
if (!checkData()) return false;
if ($("#openFile").val() === "" || $("#openFile").val() == null || $("#openFile").val() === "undefined") {
showmiddlemessage("请选择要导入的文件!");
return false;
}
var imgName = $("#openFile").val();
var ext, idx;
if (imgName == '') {
main.alert("请选择需要上传的文件!");
return false;
} else {
idx = imgName.lastIndexOf(".");
if (idx != -1) {
ext = imgName.substr(idx + 1).toUpperCase();
ext = ext.toLowerCase();
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: '/trade_cash/UploadFinishedTrades', //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");
},
//Ajax事件
//beforeSend: beforeSendHandler,
success: function (data) {
try {
if (data.success) {
//showmiddlemessage("共 {0} 条数据,导入成功 {1} 条数据!".template(data.totalNum, data.successNum));
window.parent.main.message("批量了结导入成功!");
window.parent.SearchClick();
parent.layer.closeAll();
} else {
main.alert(data.msg);
}
} catch (e) {
} finally {
main.waitMe("hide");
}
},
error: function (data) {
main.message("导入失败:{0}".template(data.msg));
main.waitMe("hide");
},
complete() {
$("#openFile").val('');
},
// 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 checkData() {
var pass = $('#tradeUploadForm').valid();
return pass;
}
</script>
}
@using (Html.BeginForm("UploadFinishedTrades", "trade_cash", FormMethod.Post, new { id = "tradeUploadForm" }))
{
<div class="well" style="margin:0px auto;margin-top:10px;">
<fieldset>
<legend>选择文件</legend>
<!--目前框架新增和修改同一界面,造成的问题就是输入的字段新增和修改都一样-->
@if (Model != null)
{
<input type="hidden" value="@Model.id" name="id" id="id" />
}
<input type="file" id="openFile" name="file" accept=".xlsx" />
</fieldset>
</div>
<div style="margin:0px auto;padding:10px;">
@MyControls.Btn("批量了结导入", "upload()")
<a class="btn btn-primary" href="/download/ImportTemplate/批量了结模板" target="_blank">
批量了结模板下载
</a>
@MyControls.Btn("关闭", "layer.closeMe()")
</div>
}