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

91 lines
3.5 KiB
Plaintext

@model Salesman
@{
ViewBag.Title = "销售员导入";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section JS{
<script>
function uploadSalesmen() {
if ($("#openFile").val() === "" || $("#openFile").val() == null || $("#openFile").val() === "undefined") {
showmiddlemessage("请选择要导入的文件!");
return false;
}
main.confirm("确认导入?", function () {
var formData = new FormData($('form')[0]);
$.ajax({
url:'/SalesCommissionManage/UploadSalesmenMain', //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) {
window.parent.reloadSalesmen();
parent.layer.closeAll();
} else {
main.alert(data.msg)
}
} catch (e) {
} finally {
}
},
error: function (data) {
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 closeuploadSalesmenWindow() {
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("SalesmenEdit", "Commission", FormMethod.Post, new { id = "SalesmenUploadForm" }))
{
<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, .csv" />
</fieldset>
</div>
<div style="margin:0px auto;padding:10px;">
@MyControls.Btn("导入销售信息", "uploadSalesmen()")
@MyControls.Btn("关闭", "closeuploadSalesmenWindow()")
</div>
}