|
|
@{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Index.cshtml";}<script> var STNO = $.request("STNO"); var WorkPoint = $.request("WorkPoint"); var Type = $.request("Type"); $(function () { if (Type=='1') { gridList(); } else { gridList2(); }
}) function gridList() { document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> <div id="gridPager"></div> ';//重置grid var $gridList = $("#gridList"); var queryJson = { } $gridList.dataGrid({ url: "/SRM/ASNManage/GetGridJsonUpload" + "?" + Math.random() + "&WorkPoint=" + WorkPoint + "&STNO=" + STNO, postData: { queryJson: JSON.stringify(queryJson) }, height: $(window).height() - 200, width: $(window).width() - 180, colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '物料编码', name: 'InvCode', width: 200, align: 'left' }, { label: '物料名称', name: 'InvName', width: 200, align: 'left' }, { label: '批次', name: 'BatchCode', width: 150, align: 'left' }, { label: '批次数量', name: 'BatchCodeNum', width: 150, align: 'left' }, { label: '供应商编码', name: 'VenCode', width: 150, align: 'left' }, { label: '供应商名称', name: 'VenName', width: 150, align: 'left' }, { label: '出货报告', name: 'FileName', width: 150, align: 'left', formatter: function (cellvalue, options, rowObject) { var html = ""; if (cellvalue != "" && cellvalue != null) { html = " <a href='../../../File/VendorFile/" + rowObject.VenCode + "/" + STNO + rowObject.InvCode + rowObject.BatchCode + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>"; } return html; } }, { label: '上传时间', name: 'CerateTime', width: 150, align: 'left' },
], shrinkToFit: true,//宽度自适应 gridComplete: function () { }, pager: "#gridPager", sortorder: "desc", sortname: 'CerateTime ', viewrecords: true, multiselect: true,
});
$("#warehouse a.btn-default").click(function () { $("#warehouse a.btn-default").removeClass("active"); $(this).addClass("active"); $('#btn_search').trigger("click"); }); $("#btn_search").click(function () { var warehouse = $("#warehouse a.active").attr('data-value'); var queryJson = { } $gridList.jqGrid('setGridParam', { postData: { queryJson: JSON.stringify(queryJson) }, page: 1 }).trigger('reloadGrid'); }); }
function gridList2() { document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> <div id="gridPager"></div> ';//重置grid var $gridList = $("#gridList"); var queryJson = { } $gridList.dataGrid({ url: "/SRM/ASNManage/GetGridJsonUpload2" + "?" + Math.random() + "&WorkPoint=" + WorkPoint + "&STNO=" + STNO, postData: { queryJson: JSON.stringify(queryJson) }, height: $(window).height() - 200, width: $(window).width() - 180, colModel: [ { label: "主键", name: "ID", hidden: true, key: true }, { label: '物料编码', name: 'InvCode', width: 200, align: 'left' }, { label: '物料名称', name: 'InvName', width: 200, align: 'left' }, { label: '批次', name: 'BatchCode', width: 150, align: 'left' }, { label: '批次数量', name: 'BatchCodeNum', width: 150, align: 'left' }, { label: '供应商编码', name: 'VenCode', width: 150, align: 'left' }, { label: '供应商名称', name: 'VenName', width: 150, align: 'left' }, { label: '出货报告', name: 'FileName', width: 150, align: 'left', formatter: function (cellvalue, options, rowObject) { var html = ""; if (cellvalue != "" && cellvalue != null) { html = " <a href='../../../File/VendorFile/" + rowObject.VenCode + "/" + STNO + rowObject.InvCode + rowObject.BatchCode + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>"; } return html; } }, { label: '上传时间', name: 'CerateTime', width: 150, align: 'left' },
], shrinkToFit: true,//宽度自适应 gridComplete: function () { }, pager: "#gridPager", sortorder: "desc", sortname: 'CerateTime ', viewrecords: true, multiselect: true,
});
$("#warehouse a.btn-default").click(function () { $("#warehouse a.btn-default").removeClass("active"); $(this).addClass("active"); $('#btn_search').trigger("click"); }); $("#btn_search").click(function () { var warehouse = $("#warehouse a.active").attr('data-value'); var queryJson = { } $gridList.jqGrid('setGridParam', { postData: { queryJson: JSON.stringify(queryJson) }, page: 1 }).trigger('reloadGrid'); }); }
function Close() { $.modalClose(); } function reloadData() {
}
function UpLoadFiles(STNO) { $("#FileUp").click(); } function UpLoadFile(fileinfo) { debugger; var InvCode; var InvName; var BatchCode; var VenCode; var BatchCodeNum; var innerhtml = ''; var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据 if (ids.length != 1) { $.modalAlert("请选择一行数据进行上传!"); return; } for (var i in ids) { var rowData = jQuery("#gridList").jqGrid("getRowData", ids[i]); InvCode = rowData.InvCode; InvName = rowData.InvName; BatchCode = rowData.BatchCode; VenCode = rowData.VenCode; BatchCodeNum = rowData.BatchCodeNum; }
var UserCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode' var files = fileinfo.files; var fileName = ""; for (var i = 0; i < files.length; i++) { var regex = /\s/; if (regex.test(files[i].name)) { $.modalAlert("文件名:<span style='color: red;'>" + files[i].name + "</span>,包含空格,上传失败,请修改后重新上传!", "warning"); var file = document.getElementById('FileUp'); file.value = ""; return false; } fileName += "" + files[i].name + ";"; if (fileName != null && fileName != "") { var data = new FormData(); jQuery.each(jQuery('#FileUp')[0].files, function (i, file) { data.append('file-' + i, file); }); $.ajax({ url: "/SRM/ASNManage/UpLoadFile?STNO=" + STNO + "&InvCode=" + InvCode + "&BatchCodeNum=" + BatchCodeNum + "&BatchCode=" + BatchCode + "&VenCode=" + VenCode + "&Type=" + Type + "&" + Math.random(), type: "post", data: data, dataType: "json", contentType: false, processData: false, success: function (data) { debugger; if (data.state == "success") { if (Type == '1') { gridList(); } else { gridList2(); } $.modalMsg(data.message, data.state); //$("#fileName").val(fileName); } else { $.modalAlert("异常:" + data.message, data.state); } } });
} } document.getElementById("FileUp").value = ""; }
</script>
<form id="form1"> <div class="topPanel"> <div class="toolbar"> <div class="btn-group"> <input id='FileUp' type='file' style="display: none" onchange="UpLoadFile(this)" multiple="multiple" /> <a id="btn_FileUp" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="UpLoadFiles(this)"><i class="fa fa-pencil-square-o"></i>上传出货报告</a> </div> </div> @*<div class="search"> <table> <tr> <td> <span class="input-group-btn"> <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button> </span> </td> </tr> </table> </div>*@ </div> <div class="gridPanel" id="gridPanel"> <table id="gridList"></table> <div id="gridPager"></div> </div></form>
|