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

154 lines
6.1 KiB
Plaintext

@using YLErp.CustomizedBizLogic
@model trade
@{
ViewBag.Title = "计算管理 | 出入金导入";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section JS
{
<script type="text/javascript">
function uploadEntryexit() {
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();
// 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]);
//var tradeType = $("#TradeType").val();
//if (tradeType !== "香草期权" && tradeType !== "障碍期权" && tradeType !== "二元期权" && tradeType !== "亚式期权" && tradeType !== "彩虹期权") {
// showmiddlemessage("当前仅支持香草期权、障碍期权、二元期权、亚式期权、彩虹期权的导入!");
// return;
//}
$.ajax({
url: '/entryexit/UploadEntryexit', //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;
},
//Ajax事件
//beforeSend: beforeSendHandler,
success: function(data) {
try {
//parent.layer.closeAll();
//parent.changeunderlying();
if (data.success) {
//showmiddlemessage("共 {0} 条数据,导入成功 {1} 条数据!".template(data.totalNum, data.successNum));
(parent||window).main.message("导入成功!");
window.parent.SearchClick();
parent.layer.closeAll();
} else {
main.alert("导入失败:{0}".template(data.msg));
}
} catch (e) {
} finally {
$("#openFile").val("");
}
},
error: function (data) {
$("#openFile").val("");
showmiddlemessage("导入失败:{0}".template(data.msg));
},
// 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;
}
function closeuploadTradeWindow() {
try {
window.parent.layer.closeAll();
} catch (e) {
}
try {
window.parent.$('#modal-editcalendar .close').click();
} catch (e) {
}
try {
window.parent.$('#modal-calendarEditInner .close').click();
} catch (e) {
}
try {
if (window.parent.location.href.indexOf("calendarEdit") >= 0) {
window.close();
}
} catch (e) {
}
}
</script>
}
@using (Html.BeginForm("tradeEdit", "trade", 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,.xls"/>
</fieldset>
</div>
<div style="margin: 0px auto; padding: 10px;">
@MyControls.Btn("导入出入金", "uploadEntryexit()")
@MyControls.Btn("关闭", "closeuploadTradeWindow()")
@if (PS.Config.ErpElement.SupportEntryExitSimpleVersion)
{
@MyControls.Btn("导入模板下载(简洁版)", "main.downloadFiles('/App_Docs/出入金导入(简洁版).xlsx')")
}
@*@MyControls.Btn("导入模板下载(财务版)", "main.downloadFiles('/App_Docs/出入金导入(财务版).xlsx')")*@
</div>
}