You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1317 lines
56 KiB

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Index.cshtml";
}
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script src="~/Content/js/select2/select2.min.js"></script>
<style>
.ui-jqgrid .ui-jqgrid-btable tbody tr.jqgrow td {
overflow: inherit;
word-wrap: break-word;
height: 34px;
}
.ui-jqgrid tr.jqgrow td {
white-space: normal !important;
/*height: auto;*/
}
</style>
<script>
var rfqcode = $.request("rfqcode");
var status = $.request("status");
var PURORG = decodeURI($.request("PURORG"));
var PURTEAM = decodeURI($.request("PURTEAM"));
$(function () {
var UserName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName'
var myDate = new Date();
var year = myDate.getFullYear(); //获取当前年
var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
var date = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
$("#RFQdate").val(year + "-" + mon + "-" + date);
//getWorkPoint();
InitControl();
SelHASCOSTDETAILS();
GetSORRVenDorFile();
ClearTemp();
reloadData();
$.ajax({
url: "/SRM/BicDoc_Publish/GetWorkPointByUser" + "?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$("#Workpoint").val(data.rows[0].F_Location).trigger("change");
}
});
$("#POorg option:contains('" + PURORG + "')").attr('selected', true).trigger("change");
$("#PoOrgName option:contains('" + PURTEAM + "')").attr('selected', true).trigger("change");
})
function GetSORRVenDorFile() {
var Fules = '';
$.ajax({
//url: "/SRM/BicDoc_Seller/GetICSBidDoc" + "?" + Math.random() + "&BidCode=" + BidCode + "&WorkPoint=" + WorkPoints,
url: "/SRM/PriceInquiry/GetICSSORRFQRequestFromVenDorFile?rfqcode=" + rfqcode,
dataType: "json",
async: false,
success: function (data) {
if (data.rows.length > 0) {
Fules = data.rows[0].Filename;
}
}
});
debugger
var innerhtml = '';
if (Fules != "" && Fules != null) {
//Fules = Fules.substring(0, Fules.length - 1);
var File = Fules.split(';');
for (var i = 0; i < File.length; i++) {
innerhtml += " <a href='../../../File/SORRFQFile/" + rfqcode + "/" + File[i] + "' download='" + File[i] + "' style='color:blue;'>" + File[i] + "</a>";
}
$("#hidbtn").html(innerhtml);
$("#fileName").val(Fules);
}
}
//function getWorkPoint() {
// var $VenCode = $("#Workpoint");
// $VenCode.select2({
// allowClear: true,
// escapeMarkup: function (m) {
// return m;
// }
// });
// $.ajax({
// url: "/SRM/ASNAdd/GetVendors" + "?" + Math.random(),
// dataType: "json",
// async: false,
// success: function (data) {
// $.each(data, function (index, item) {
// $VenCode.append("<option value='" + item.WorkPointCode + "'>&nbsp;" + item.WorkPointName + "</option>");
// });
// }
// });
//}
function InitControl() {
var OrgName = $("#PoOrgName");
var Workpoint = $("#Workpoint");
OrgName.select2({
placeholder: "请选择",
placeholderOption: "first",
allowClear: true,
escapeMarkup: function (m) {
return m;
}
})
Workpoint.select2({
placeholder: "请选择",
placeholderOption: "first",
allowClear: true,
escapeMarkup: function (m) {
return m;
}
})
OrgName.change(function () {
$("#POorg").select2("val", "");
$("#POorg").html("");
var value = $("#PoOrgName option:selected").val()
$.ajax({
url: "/SRM/RFQAdd/GetPurTeam?code=" + value + "&" + Math.random,
async: false,
success: function (data) {
var datas = JSON.parse(data);
$("#POorg").append("<option value=''>&nbsp;请选择</option>")
$.each(datas, function (index, item) {
$("#POorg").append("<option value='" + item.purchugcode + "'>&nbsp;" + item.purchugname + "</option>")
})
}
})
})
$("#INVType").select2({
placeholder: "请选择",
placeholderOption: "first",
allowClear: true,
escapeMarkup: function (m) {
return m;
}
})
$("#POorg").select2({
placeholder: "请选择",
placeholderOption: "first",
allowClear: true,
escapeMarkup: function (m) {
return m;
}
})
$.ajax({
url: "/SRM/RFQAdd/GetInvType?" + Math.random,
datatype: "json",
async: false,
success: function (data) {
var datas = JSON.parse(data);
$("#INVType").append("<option value=''>&nbsp;请选择</option>")
$.each(datas, function (index, item) {
$("#INVType").append("<option value='" + item.F_ItemName + "'>&nbsp;" + item.F_ItemName + "</option>")
})
}
})
$.ajax({
url: "/SRM/ASNAdd/GetVendors" + "?" + Math.random(),
dataType: "json",
async: false,
success: function (data) {
$.each(data, function (index, item) {
$("#Workpoint").append("<option value='" + item.WorkPointCode + "'>&nbsp;" + item.WorkPointName + "</option>");
});
}
});
$("#POorg").change(function () {
if ($("#Workpoint").children('option:selected').val() == '') {
$.modalAlert("请先选择站点!", "warning");
return;
}
}
)
Workpoint.change(function () {
debugger;
OrgName.empty();
var zd = Workpoint.find("option:selected").val();
$.ajax({
url: "/SRM/RFQAdd/GetPUROrganize?workpoint=" + zd + "&" + Math.random,
datatype: "json",
async: false,
success: function (data) {
var datas = JSON.parse(data)
//OrgName.append("<option value=''>&nbsp;请选择</option>")
if (status != "1") {
$.each(datas, function (index, item) {
OrgName.append("<option value='" + item.purchugcode + "'>&nbsp;" + item.purchugname + "</option>");
$("#PoOrgName").val([item.purchugcode]).trigger("change");
});
} else {
$.each(datas, function (index, item) {
OrgName.append("<option value='" + item.purchugcode + "'>&nbsp;" + item.purchugname + "</option>");
});
}
}
})
if (rfqcode == ""|| rfqcode == null || rfqcode == undefined) {
$.ajax({
url: "/SRM/RFQAdd/GetSercode?workpoint=" + zd + "&" + Math.random,
datatype: "json",
async: false,
success: function (data) {
$("#RFQNO").attr("value", data);
$("#RFQName").attr("value", "询价单" + data);
}
})
}
})
//$("#PoOrgName").change(function () {
// var OrgNamess = OrgName.find("option:selected").val();
// $.ajax({
// url: "/SRM/RFQAdd/GetPurTeam?" + OrgNamess + "&" + Math.random,
// datatype: "json",
// async: false,
// success: function (data) {
// var datas = JSON.parse(data);
// $("#POorg").append("<option value=''>&nbsp;请选择</option>")
// $.each(datas, function (index, item) {
// $("#POorg").append("<option value='" + item.purchugsoncode + "'>&nbsp;" + item.name + "</option>")
// })
// }
// })
//});
if (rfqcode != "" && rfqcode != null && rfqcode != undefined) {
$.ajax({
url: "/SRM/PriceInquiry/GetICSSORRFQRequestFromrow?rfqcode=" + rfqcode + "&" + Math.random(),
async: false,
success: function (data) {
var newdata = eval("(" + data + ")");
var row1 = newdata.Table;
$.each(row1, function (index, row) {
if (row.rfqcode == rfqcode) {
$("#Workpoint").val([row.workpoint]).trigger("change");
//$("#Workpoint").trigger("change");
//var PoOrgName = $("#PoOrgName").select2();
//PoOrgName.val(row.purchugcode).trigger("change");
$("#PoOrgName").val([row.purchugcode]).trigger("change");
$("#POorg").val([row.purteam]).trigger("change");
$("#Remarks").val(row.memo);
$("#RFQNO").attr("value", rfqcode);
$("#RFQName").attr("value", row.rfqname);
$("#RFQdate").attr("value", row.createdate);
$("#fileName").val(row.FileName);
$("#Sel_HASCOSTDETAILS").val(row.HASCOSTDETAILS).trigger("change");//是否上传模板
//var innerhtml = '';
//if (row.FileName != "" && row.FileName != null) {
//
// var File = row.FileName.split(';');
// for (var i = 0; i < File.length; i++) {
// innerhtml += " <a href='../../../File/SORRFQFile/" + row.RFQCODE + "/" + File[i] + "' download='" + File[i] + "' style='color:blue;'>" + File[i] + "</a><br>";
// }
//}
}
})
}
})
}
}
function SelHASCOSTDETAILS() {
var $HASCOSTDETAILS = $("#Sel_HASCOSTDETAILS");
$HASCOSTDETAILS.select2({
allowClear: true,
escapeMarkup: function (m) {
return m;
}
});
//$WhetheProdDevCapability.append("<option value=''>&nbsp;</option>");
$HASCOSTDETAILS.append("<option value='0'>&nbsp;否</option>");
$HASCOSTDETAILS.append("<option value='1'>&nbsp;是</option>");
$("#Sel_HASCOSTDETAILS").val([1]).trigger("change");//是否上市公司
}
function ClearTemp() {
$.ajax({
url: "/SRM/InvAdd/ClearInvTemp?" + Math.random(),
datatype: "json",
async: false
})
}
//加载jqGrid
function reloadData() {
document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> ';//重置grid
var SelectPerson = GetSelectBuiess();
$("#gridList").dataGrid({
url: "/SRM/PriceInquiry/GetInvTabICSSORRFQRequestFrom?" + Math.random(),
postData: { rfqno: $("#RFQNO").val() },
height: $(window).height() - 300,
width: $(window).width(),
cellEdit: true,
colModel: [
{ label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true },
{ label: '物料代码', name: '物料代码', width: 180, align: 'left' },
{ label: '物料描述', name: '物料名称', width: 150, align: 'left' },
{ label: '物料规格', name: '物料规格', width: 150, align: 'lreft' },
{ label: '物料类型', name: '物料类型', width: 150, align: 'left', hidden: true },
{ label: '单位', name: '单位', width: 50, align: 'left' },
{ label: '询价备注', name: '备注', width: 100, align: 'left',editable: true,hidden:true },
{ label: '参考价格', name: '参考价格', width: 100, align: 'left', editable: true, edittype: 'text', editrules: { number: true },hidden:true },
{ label: '需求数量', name: '预计需求量', width: 60, align: 'left', edittype: 'text', editrules: { number: true } },
{
label: '是否需上传成本明细', name: '成本明细', width: 150, align: 'left', editable: true, edittype: 'select', editoptions: { value: GetItemCode(), },
formatter: function (cellvalue) {
if (cellvalue == "undefined" || cellvalue == "" || cellvalue == undefined) {
return "";
} else if (cellvalue == "1") {
return "是";
} else if (cellvalue == "0") {
return "否";
}
},hidden:true
},
{ label: '是否含税', name: '是否含税', width: 100, align: 'left', editable: true, edittype: 'select', editoptions: { value: GetItemCode(), },hidden:true },
{ label: '币种', name: '币种', width: 150, align: 'left', editable: true,hidden:true },
{ label: 'HiddenFile', name: 'HiddenFile', align: 'left', hidden: true },
{ label: '备注', name: '备注', width: 180, align: 'left' },
{
label: '技术要求文件', name: '文件路径', width: 200, align: 'left',
formatter: function (cellvalue, options, rowObject) {
var RFQNO = $("#RFQNO").val();
var html = "";
if (cellvalue != "" && cellvalue != null) {
html = " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + cellvalue + "' download='" + cellvalue + "' style='color:#1281C1;'>" + cellvalue + "</a>";
//html = " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>";
}
return html;
}
},
{ label: '物料描述', name: '物料描述', width: 180, align: 'left', hidden: true },
{ label: '制造商', name: '制造商', width: 180, align: 'left', hidden: true },
{ label: '制造商编码', name: '制造商编码', width: 180, align: 'left', hidden: true },
{ label: '年用量', name: '年用量', width: 180, align: 'left', hidden: true },
{ label: '项目信息', name: '项目信息', width: 180, align: 'left', hidden: true },
{ label: '物料等级', name: '物料等级', width: 180, align: 'left', hidden: true },
{ label: '是否为客户指定', name: '是否为客户指定', width: 180, align: 'left', hidden: true },
{ label: 'Purchasing', name: 'Purchasing', width: 180, align: 'left', hidden: true },
{ label: '技术负责人', name: '技术负责人', width: 180, align: 'left', hidden: true },
{
label: '分配采购员', name: '分配采购员', width: 180, align: 'left',
formatter: function (cellvalue, options, rowObject) {
debugger;
if (rowObject.ID != null) {
var ID = str = rowObject.ID.replace(/[^\w\s]/gi, '');
}
var html = "";
html += ' <select id="SelPersonSUM_' + ID + '" data-live-search ="true" Title=\"未选择\" class="selectpicker" data-width="150px">';
html += SelectPerson;
html += ' </select>';
return cellvalue = html;
}
},
{ label: ' ', width: 80, align: 'center', formatter: btnModifys },
],
cellsubmit: "clientArray",
rowNum: 10000,
gridComplete: function () {
debugger;
//设置select
var RowDatas = $("#gridList").jqGrid('getDataIDs');
//var ISTou = $("#gridList1").jqGrid("getCell", RowDatas[0], "IsTou");
for (var j = 0; j < RowDatas.length; j++) {
debugger;
var ID = $("#gridList").jqGrid("getCell", RowDatas[j], "ID").replace(/[^\w\s]/gi, '');
var Purchasing = $("#gridList").jqGrid("getCell", RowDatas[j], "Purchasing");
var VenCode = $("#gridList").jqGrid("getCell", RowDatas[j], "物料代码");
var colr = "SelPersonSUM_" + ID;
// alert(ECNDocNO + "!" + Transfer + "!" + colr);
if (Purchasing != "") {
$("#" + colr).selectpicker('refresh');
$("#" + colr).selectpicker('val', Purchasing);
} else {
$.ajax({
url: "/SRM/PriceInquiry/GetPurchasing",
dataType: "json",
data: { VenCode: VenCode },
async: false,
success: function (data) {
$("#" + colr).selectpicker('refresh');
$("#" + colr).selectpicker('val', data.mass);
}
})
}
}
},
});
}
//下拉选项
function GetItemCode() {
var str = "0:否;1:是";
/*debugger;*/
return str;
}
//获取采购信息
function GetSelectBuiess() {
var html = '';
var WorkPoint = $("#Workpoint").children('option:selected').val();
//var BidCode = $("#txt_BidCode").val();
$.ajax({
url: "/SRM/PriceInquiry/GetSelectBuiess?" + Math.random() + "&WorkPoint=" + WorkPoint,
dataType: "json",
async: false,
success: function (data) {
debugger;
//html = ' <option value="">未选择</option> ';
if (data != false && data != null && data.length > 0) {
for (var i = 0; i < data.length; i++) {
html += ' <option value="' + data[i].F_Account + '">' + data[i].F_RealName + '</option> ';
}
}
}
});
return html;
}
//操作按钮上传文件
function btnModifys(cellvalue, options, rowObject) {
return cellvalue = "<a class=\"btn btn-danger dropdown-text\" onclick=\"Back('" + rowObject.ID + "')\">退回</a>";
}
//上传触发控件
function UpLoadFilestechnicalrequirement(ID, GGUID) {
$("#gridList").find($("td[aria-describedby='gridList_rn']")).click();//提交取消编辑状态
var rowData = $("#gridListVENDORCERTIFICATE").jqGrid('getRowData', ID);
$("#FileUpBYRZinp").val(ID);
//$("#FileUpBYRZEndDate").val(rowData.ENDDATE);
//$("#FileUpBYRZEndCQ").val(rowData.ADDITION1);
//$("#FileUpBYGGUID").val(GGUID);
$("#FileUpBYRZ").click();
}
//上传文件方法
function UpLoadFileBYRZ(fileinfo) {
var ID = $("#FileUpBYRZinp").val();
var RFQNO = $("#RFQNO").val();
var files = fileinfo.files;
var fileName = files[0].name;
if (fileName != null && fileName != "") {
var regex = /\s/;
if (regex.test(fileName)) {
$.modalAlert("文件名:<span style='color: red;'>" + fileName + "</span>,包含空格,上传失败,请修改后重新上传!", "warning");
var file = document.getElementById('FileUpBYRZ');
file.value = "";
return false;
}
var data = new FormData();
jQuery.each(jQuery('#FileUpBYRZ')[0].files, function (i, file) {
data.append('file-' + i, file);
});
$.modalConfirm("确定上传文件吗?", function (r) {
if (r) {
$.ajax({
url: "/SRM/RFQAdd/UpLoadFileImport" + "?" + Math.random() + "&ID=" + ID + "&RFQNO=" + RFQNO,
type: "post",
data: data,
dataType: "json",
contentType: false,
processData: false,
success: function (data) {
if (data.state == 'error') {
$.modalAlert("上传失败!");
} else if (data.state == 'success') {
//var FileName = data.FileName;
//var PathName = data.PathName;
//$("#AEquipment").text(FileName);
//$('#AEquipment').attr('href', '../../File/VendorFile/' + RoleEnCode + '/' + FileName + '');
$("#gridList").jqGrid('setCell', ID, "文件路径", fileName);
$("#gridList").jqGrid('setCell', ID, "HiddenFile", fileName);
$.modalMsg("上传成功", "success");
}
},
error: function (aa) {
//$.modalAlert("上传失败:" + aa);
$.modalMsg("上传失败", "error");
}
});
}
});
}
var file = document.getElementById('FileUpBYRZ');
file.value = "";
}
//查看
function btnLook(cellvalue, options, rowObject) {
return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">查看</a>";
}
function btnLook1(cellvalue, options, rowObject) {
return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick1('" + rowObject.ID + "')\">查看</a>";
}
function UpLoadClick(ID) {
var sfqcode = $("#RFQNO").val();
var zd = $("#Workpoint").children('option:selected').val();
$.modalOpen2({
id: "InvUpdate",
title: "查看修改物料",
url: "/SRM/InvAdd/Index" + "?type=''&SFQCODE=" + sfqcode + "" + "&workpoint=" + zd + "&id=" + ID + "&" + Math.random(),
width: "95%",
height: "95%",
callBack: function (iframeId) {
top.frames[iframeId].submitForm();
top.frames[iframeId].Close();
$("#gridList").jqGrid().setGridParam({ datatype: 'json' }, { postData: { rfqno: $("#RFQNO").val() } }).trigger('reloadGrid');
}
});
}
function UpLoadClick1(ID) {
var sfqcode = $("#RFQNO").val();
var zd = $("#Workpoint").children('option:selected').val();
$.modalOpen2({
id: "SupUpdate",
title: "查看修改供应商",
url: "/SRM/SupplierAdd/Index" + "?SFQCODE=" + sfqcode + "" + "&workpoint=" + zd + "&id=" + ID + "&" + Math.random(),
width: "700px",
height: "450px",
callBack: function (iframeId) {
top.frames[iframeId].submitForm();
top.frames[iframeId].Close();
$("#gridList2").jqGrid().setGridParam({ datatype: 'json' }, { postData: { rfqno: $("#RFQNO").val() } }).trigger('reloadGrid');
}
});
}
function AddInv(type) {
if ($("#RFQNO").val() == "") {
$.modalAlert("请先填写站点信息!", "warning")
return;
}
if ($("#RFQdate").val() == "") {
$.modalAlert("请先填写单据日期!", "warning")
return;
}
if (status != "1") {
if ($("#PoOrgName").children('option:selected').val() == "") {
$.modalAlert("请先选择采购组织!", "warning")
return;
}
}
var sfqcode = $("#RFQNO").val();
var WorkPoint = $("#Workpoint").children('option:selected').val();
var index = layer.open({
id: "Formitem",
type: 2,
shade: 0.3,
title: "新增物料",
fix: false,
area: ["900px", "600px"],
content: "/SRM/InvAdd/Invmes?" + Math.random() + "&workpoint=" + WorkPoint,
btn: ['确定', '关闭'],
btnclass: ['btn btn-primary', 'btn btn-danger'],
maxmin: true,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
var arrayData = getJQAllData("#gridList");
for (var j = 0; j < objArr.length; j++) {
for (var i = 0; i < arrayData.length; i++) {
if (objArr[j].物料代码 == arrayData[i].物料代码) {
$.modalAlert("已添加物料!请勿重复添加!", "warning");
return;
}
}
$("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
$(".unwritten").hide();
}
layer.close(index);
}, cancel: function () {
return true;
}
});
}
function getJQAllData(list) {
//拿到grid对象
var obj = $(list);
//获取grid表中所有的rowid值
var rowIds = obj.getDataIDs();
//初始化一个数组arrayData容器,用来存放rowData
var arrayData = new Array();
if (rowIds.length > 0) {
for (var i = 0; i < rowIds.length; i++) {
//rowData=obj.getRowData(rowid);//这里rowid=rowIds[i];
arrayData.push(obj.getRowData(rowIds[i]));
}
}
return arrayData;
}
function AddSupplier(type) {
if ($("#RFQNO").val() == "") {
$.modalAlert("请先填写站点信息!", "warning")
return;
}
if ($("#RFQdate").val() == "") {
$.modalAlert("请先填写单据日期!", "warning")
return;
}
if (status != "1") {
if ($("#PoOrgName").children('option:selected').val() == "") {
$.modalAlert("请先选择采购组织!", "warning")
return;
}
}
var sfqcode = $("#RFQNO").val();
var zd = $("#Workpoint").children('option:selected').val();
var index = layer.open({
id: "Formitem",
type: 2,
shade: 0.3,
title: "新增供应商",
fix: false,
area: ["900px", "600px"],
content: "/SRM/SupplierAdd/CustomerMes" + "?SFQCODE=" + sfqcode + "" + "&workpoint=" + zd + "&" + Math.random(),
btn: ['确定', '关闭'],
btnclass: ['btn btn-primary', 'btn btn-danger'],
maxmin: true,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
var arrayData = getJQAllData("#gridList2");
for (var j = 0; j < objArr.length; j++) {
for (var i = 0; i < arrayData.length; i++) {
if (objArr[j].供应商代码 == arrayData[i].供应商代码) {
$.modalAlert("已添供应商!请勿重复添加!", "warning");
return;
}
}
$("#gridList2").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
$(".unwritten").hide();
}
layer.close(index);
}, cancel: function () {
return true;
}
});
}
function Close() {
ClearTemp();
$.modalClose();
}
function deleteInv() {
var ids = $('#gridList').jqGrid('getGridParam', 'selarrrow');
if (ids.lenth <= 0) {
$.modalAlert("请选择要删除的数据!", "warning");
return;
}
var rowid = "";
var WorkPoint = $("#sel_WorkPoint option:checked").val();
var objArr = "";
//var objList = $("#gridList1").jqGrid('getGridParam', 'selrow');
//if (objList.length == 0) {
// $.modalAlert("请选择要删除的标的数据!");
// return;
//}
//for (var i = 0; i < objList.length; i++) {
// var rowId = objList[i];
// var rowData = $("#gridList1").jqGrid('getRowData', rowId);
// objArr += "'" + rowData.ID + "',";
// rowid += rowData.ID + ",";
//}
//rowid = rowid.trimEnd(',');
//var rowid1 = rowid.split(',');
$.deleteForm({
url: "/SRM/InvAdd/DeleteInvRow" + "?" + Math.random(),
param: { keyValue: $("#gridList").jqGridRowValue().ID },
success: function () {
$("#gridList").delRowData($("#gridList").jqGridRowValue().ID);
//$.currentWindow().$("#gridList1").trigger("reloadGrid");
//for (var i = 0; i < rowid1.length; i++) {
// $("#gridList1").delRowData(rowid1[i]);
//}
var obj_item = $("#gridList");
var rowIds_item = obj_item.getDataIDs();
if (rowIds_item.length <= 0) {
reloadData();
}
}
})
}
function DeleteSup() {
var ids = $('#gridList2').jqGrid('getGridParam', 'selarrrow');
if (ids.lenth <= 0) {
$.modalAlert("请选择要删除的数据!", "warning");
return;
}
var rowid = "";
var WorkPoint = $("#sel_WorkPoint option:checked").val();
var objArr = "";
$.deleteForm({
url: "/SRM/SupplierAdd/Delete" + "?" + Math.random(),
param: { keyValue: $("#gridList2").jqGridRowValue().ID },
success: function () {
$("#gridList2").delRowData($("#gridList2").jqGridRowValue().ID);
//$.currentWindow().$("#gridList1").trigger("reloadGrid");
//for (var i = 0; i < rowid1.length; i++) {
// $("#gridList1").delRowData(rowid1[i]);
//}
var obj_item = $("#gridList2");
var rowIds_item = obj_item.getDataIDs();
if (rowIds_item.length <= 0) {
reloadData();
}
}
})
}
//保存 提交
function submitForm() {
$("#gridList2").find($("td[aria-describedby='gridList2_rn']")).click();
$("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
var FKID = '';
if ($("#RFQNO").val() == "") {
$.modalAlert("请先选择站点!", "warning");
return;
}
//if ($("#PoOrgName").text() == "") {
// $.modalAlert("采购组织名称不能为空!", "warning");
// return;
//}
if ($("#RFQdate").val() == "") {
$.modalAlert("单据日期不能为空!", "warning");
return;
}
var gridList = $("#gridList");
var gridListrowIds = gridList.getDataIDs();
if (gridListrowIds.length <= 0) {
$.modalAlert("请选择物料再提交!", "warning");
return;
}
var gridList2 = $("#gridList2");
var gridList2rowIds = gridList2.getDataIDs();
//if (gridList2rowIds.length <= 0) {
// $.modalAlert("请选择供应商再提交!", "warning");
// return;
//}
//if (gridList2rowIds.length > 0) {
// for (var i = 0; i < gridList2rowIds.length; i++) {
// var gridList2RowData = gridList2.getRowData(gridList2rowIds[i]);
// FKID += "" + gridList2RowData.ID + ",";
// if (gridList2RowData.供应商付款条件 == '') {
// $.modalAlert("第" + (i + 1).toString() + "行,未输入付款条件!");
// return false;
// }
// if (gridList2RowData.是否显示参考价 == '') {
// $.modalAlert("第" + (i + 1).toString() + "行,未选择是否显示参考价!");
// return false;
// }
// }
//}
var code = $("#RFQNO").val();
var FileName = $("#fileName").val();
debugger;
var Orgcode = $("#PoOrgName").val();
var Name = $("#RFQName").val();
var now = new Date();
//var CreateDate = now.getFullYear() + "-" + ((now.getMonth() + 1) < 10 ? "0" : "") + (now.getMonth() + 1) + "-" + (now.getDate() < 10 ? "0" : "") + now.getDate();
//var CreateTime = (now.getHours() < 10 ? "0" : "") + now.getHours() + ":" + (now.getMinutes() < 10 ? "0" : "") + now.getMinutes() + ":" + (now.getSeconds() < 10 ? "0" : "") + now.getSeconds();
var Workpoint = $("#Workpoint").val();
var Purteam = $("#POorg").val();
var begindate = $("#RFQdate").val();
var COSTANALYSISTEMPLATE = "~/File/报价模板.xlsx";
var COSTTYPE = "Common";
var ISUNIFYANALYSISTEMPLATE = "1";
var memo = $("#Remarks").val();
var status = "0";
var ID = FKID;
var HASCOSTDETAILS = '';
var HASCOSTDETAILS = $("#Sel_HASCOSTDETAILS").val();
//if (HASCOSTDETAILS == "是") {
// HASCOSTDETAILS = 1
//} else {
// HASCOSTDETAILS = 0
//}
//物料
SelPerson = "#SelPersonSUM_"
var obj_item = $("#gridList");
var rowIds_item = obj_item.getDataIDs();
var arrayData_item = new Array();
if (rowIds_item.length > 0) {
for (var i = 0; i < rowIds_item.length; i++) {
var itemRowData = obj_item.getRowData(rowIds_item[i]);
if (itemRowData.预计需求量 == '' || itemRowData.预计需求量 == null) {
$.modalAlert("请维护物料" + itemRowData.物料代码 + "计划采购数量", "warning")
return false;
}
if (itemRowData.是否显示参考价 == "是") {
ISSHOWPRICE = 1
} else {
ISSHOWPRICE = 0
}
//if (itemRowData.DeliveryTime == '' || itemRowData.DeliveryTime == null) {
// $.modalAlert("请维护物料" + itemRowData.INVCODE + "交期", "warning")
// return false;
//}
var obj = {
ID: itemRowData.ID,
RFQCODE: code,
ITEMCODE: itemRowData.物料代码,
ITEMNAME: itemRowData.物料名称,
InvStd: itemRowData.物料规格,
ITEMTYPE: itemRowData.物料类型,
UNIT: itemRowData.单位,
MEMO: itemRowData.备注,
Requirements: itemRowData.技术要求,
REFERPRICE: itemRowData.参考价格,
REQUESTQUANTITY: itemRowData.预计需求量,
HASCOSTDETAILS: HASCOSTDETAILS,//是否需上传成本明细
ISINCLUDETAX: itemRowData.是否含税,
CURRENCY: itemRowData.币种,
RFQITEMREFERCODE: itemRowData.HiddenFile,
Workpoint: Workpoint,
InvDesc: itemRowData.物料描述,
ManuFacturer: itemRowData.制造商,
ManuFacturerInvCode: itemRowData.制造商编码,
YearQty: itemRowData.年用量,
ProjectInfo: itemRowData.项目信息,
MaterialGrade: itemRowData.物料等级,
CustomerSpecified: itemRowData.是否为客户指定,
TechnicalDirector: itemRowData.技术负责人,
Purchasing: $("" + SelPerson + "" + itemRowData.ID.replace(/[^\w\s]/gi, '') + "").val()//采购员
};
arrayData_item.push(obj);
}
} else {
$.modalAlert("请选择标的信息!", "warning")
return false;
}
//供应商
//标的
//var obj_VenCode = $("#gridList2");
//var rowIds_VenCode = obj_VenCode.getDataIDs();
//var arrayData_VenCode = new Array();
//if (rowIds_VenCode.length > 0) {
// for (var i = 0; i < rowIds_VenCode.length; i++) {
// var VenCodeRowData = obj_VenCode.getRowData(rowIds_VenCode[i]);
// var obj = {
// ID: VenCodeRowData.ID,
// RFQCODE: code,
// VENDORCODE: VenCodeRowData.供应商代码,
// VENDORTYPE: VenCodeRowData.供应商类型,
// TAXRATE: VenCodeRowData.供应商税率,
// CURRENCY:VenCodeRowData.供应商币别,
// PAYMENTCONDITION:VenCodeRowData.供应商付款条件,
// ISSHOWPRICE: ISSHOWPRICE,
// CauseOff: VenCodeRowData.关闭原因,
// Workpoint: Workpoint
// };
// arrayData_VenCode.push(obj);
// }
//} else {
// $.modalAlert("请选择应标供应商!", "warning")
// return false;
//}
var arrayitem = JSON.stringify(arrayData_item);
/* var arrayVenCode = JSON.stringify(arrayData_VenCode);*/
$.ajax({
url: "/SRM/PriceInquiry/AddRFQByPNPurchasing?" + Math.random(),
data: {
RFQCODE: code,
PURCHUGCODE: Orgcode,
RFQNAME: Name,
//CreateDate1: CreateDate,
//CreateTime1: CreateTime,
HASCOSTDETAILS: HASCOSTDETAILS,//是否需上传成本明细
FileName: FileName,
RFQstatus:status,
Workpoint: Workpoint,
PURTeam: Purteam,
BEGINDATE: begindate,
//COSTANALYSISTEMPLATE1: COSTANALYSISTEMPLATE,
COSTTYPE: COSTTYPE,
ISUNIFYANALYSISTEMPLATE1: ISUNIFYANALYSISTEMPLATE,
//COSTTYPE1: COSTTYPE,
MEMO: memo,
STATUS: status,
ID: ID,
arrayBidDocBD: arrayitem,
/* arrayBidDocGYS: arrayVenCode,*/
},
type: "post",
dataType: "json",
success: function (data) {
if (data.state == "success") {
layer.msg(data.message);
$.currentWindow().$("#gridList").trigger("reloadGrid");
$.modalClose();
return true;
} else {
layer.msg(data.message);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.msg(errorThrown);
},
beforeSend: function () {
},
complete: function () {
$.loading(false);
}
});
}
function UpdateTime() {
if ($("#Workpoint").children('option:selected').val() == "") {
$.modalAlert("请先选择站点!", "warning");
return;
}
$("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
var obj_Item1 = $("#gridList");
var rowIds_Item1 = obj_Item1.getDataIDs();
if (rowIds_Item1.length > 0) {
for (var i = 0; i < rowIds_Item1.length; i++) {
var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]);
var RowData_Item1Date = obj_Item1.getRowData(rowIds_Item1[0]);
var Qty = RowData_Item1Date.预计需求量
if (Qty == "") {
$.modalAlert("请先填写第一个数量再同步");
return;
}
//RowData_Item1.DeliveryTime = Datetime
//$('#gridList1').jqGrid('setRowData', i, RowData_Item1);
//给单元格赋值
$("#gridList").jqGrid('setCell', rowIds_Item1[i], "预计需求量", Qty);
}
}
}
function AddPU() {
if ($("#Workpoint").children('option:selected').val() == "") {
$.modalAlert("请先选择站点!", "warning");
return;
}
if ($("#PoOrgName").children('option:selected').val() == "") {
$.modalAlert("请先选择采购组织!", "warning")
return;
}
if ($("#POorg").children('option:selected').val() == "") {
$.modalAlert("请先选择采购负责人!", "warning")
return;
}
var WorkPoint = $("#Workpoint").children('option:selected').val();
var index = layer.open({
id: "ICSSORRFQByPU",
type: 2,
shade: 0.3,
title: "请购单添加",
fix: false,
area: ["1000px", "600px"],
content: "/SRM/RFQAdd/ICSSORRFQByPU?" + Math.random() + "&WorkPoint=" + WorkPoint,
btn: ['确定', '关闭'],
btnclass: ['btn btn-primary', 'btn btn-danger'],
maxmin: true,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
var arrayData = getJQAllData("#gridList");
for (var j = 0; j < objArr.length; j++) {
for (var i = 0; i < arrayData.length; i++) {
if (objArr[j].物料代码 == arrayData[i].物料代码) {
$.modalAlert("已添加标的!请勿重复添加!");
return;
}
}
$("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
$(".unwritten").hide();
}
layer.close(index);
}, cancel: function () {
return true;
}
});
}
function AddPoMain() {
if ($("#Workpoint").children('option:selected').val() == "") {
$.modalAlert("请先选择站点!", "warning");
return;
}
if ($("#PoOrgName").children('option:selected').val() == "") {
$.modalAlert("请先选择采购组织!", "warning")
return;
}
if ($("#POorg").children('option:selected').val() == "") {
$.modalAlert("请先选择采购负责人!", "warning")
return;
}
var WorkPoint = $("#Workpoint").children('option:selected').val();
var index = layer.open({
id: "ICSSORRFQByPO",
type: 2,
shade: 0.3,
title: "采购订单添加",
fix: false,
area: ["1200px", "600px"],
content: "/SRM/RFQAdd/ICSSORRFQByPO?" + Math.random() + "&WorkPoint=" + WorkPoint,
btn: ['确定', '关闭'],
btnclass: ['btn btn-primary', 'btn btn-danger'],
maxmin: true,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
var arrayData = getJQAllData("#gridList");
for (var j = 0; j < objArr.length; j++) {
for (var i = 0; i < arrayData.length; i++) {
if (objArr[j].物料代码 == arrayData[i].物料代码) {
$.modalAlert("已添加标的!请勿重复添加!");
return;
}
}
$("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
$(".unwritten").hide();
}
layer.close(index);
}, cancel: function () {
return true;
}
});
}
function UpLoadFile(fileinfo) {
//$("#CurrentPoCode").val(poCode);
var files = fileinfo.files;
var RFQNO = $("#RFQNO").val();
var fileName = '';
var innerhtml = '';
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);
});
//data.append("STNO", $("#CurrentSTNO").val());
//var info = document.getElementById("form1");
//var formData = new FormData(info);
$.modalConfirm("确定上传文件吗?", function (r) {
if (r) {
$.ajax({
url: "/SRM/RFQAdd/UpLoadFileImport" + "?" + Math.random() + "&RFQNO=" + RFQNO,
type: "post",
data: data,
dataType: "json",
contentType: false,
processData: false,
success: function (data) {
if (data.state == "success") {
$.modalMsg(data.message, data.state);
$("#fileName").val(fileName);
//$.currentWindow().$("#gridList").trigger("reloadGrid");
}
else {
$.modalAlert("异常:" + data.message, data.state);
}
}
});
}
});
}
}
fileName = fileName.substring(0, fileName.length - 1);
let arr1 = fileName.split(";");
for (var k = 0; k < arr1.length; k++) {
innerhtml += " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + arr1[k] + "' download='" + arr1[k] + "' style='color:blue;'>" + arr1[k] + "</a>";
}
$("#hidbtn").html(innerhtml);
var file = document.getElementById('FileUp');
file.value = "";
}
//上传按钮触发事件
function UpLoadFiles(STNO) {
$("#FileUp").click();
}
function AdditemFSC() {
var WorkPoint = $("#Workpoint option:checked").val();
if (WorkPoint == "") {
$.modalAlert("请填写站点", "warning")
return false;
}
if ($("#ENDDATE").val() == "") {
$.modalAlert("请先填写截止日期!", "warning");
return;
}
var WorkPoint = $("#Workpoint option:checked").val();
var index = layer.open({
id: "AddFCS",
type: 2,
shade: 0.3,
title: "新增非生产标的",
fix: false,
area: ["600px", "650px"],
content: "/SRM/PriceInquiry/NoProductionMaterialAdd?" + Math.random() + "&WorkPoint=" + WorkPoint,
btn: ['确定', '关闭'],
btnclass: ['btn btn-primary', 'btn btn-danger'],
maxmin: true,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
var arrayData = getJQAllData("#gridList");
for (var j = 0; j < objArr.length; j++) {
for (var i = 0; i < arrayData.length; i++) {
if (objArr[j].INVCODE == arrayData[i].INVCODE) {
$.modalAlert("已添加标的!请勿重复添加!");
return;
}
}
$("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
$(".unwritten").hide();
}
layer.close(index);
}, cancel: function () {
return true;
}
});
}
//退回
function Back(ID) {
if (ID=="") {
$.modalAlert("请选择要退回的数据!", "warning");
return;
}
var RFQNO = $("#RFQNO").val();
$.submitForm({
url: "/SRM/PriceInquiry/InvCodeBack" + "?" + Math.random(),
param: { keyValue: ID, RFQNO: RFQNO },
success: function () {
var obj_item = $("#gridList");
var rowIds_item = obj_item.getDataIDs();
if (rowIds_item.length <= 0) {
reloadData();
}
}
})
}
</script>
<form id="form1">
<input id="FileUpBYRZinp" hidden="hidden">
<input id='FileUpBYRZ' type='file' style="display: none" onchange="UpLoadFileBYRZ(this)" multiple="multiple" />
<div class="topPanel" style="height:10px">
<div class="btn-group">
@*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
<a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
</div>
</div>
<div style="margin-right: 20px;">
<table class="form">
<tr>
<th class="formTitle">
站点:
</th>
<td class="formValue">
<select id="Workpoint" name="Workpoint" class="select2 form-control " placeholder="请选择站点.." style="width:32px" disabled></select>
</td>
@*<th class="formTitle">
采购组织:
</th>
<td class="formValue">
<select id="PoOrgName" name="PoOrgName" class="select2 form-control " placeholder="请选择采购组织.."></select>
<input type="hidden" id="hidetext" />
</td>
<th class="formTitle">采购负责人:</th>
<td class="formValue">
<select id="POorg" name="POorg" class="select2 form-control " placeholder="请选择采购负责人.." style="width:32px"></select>
</td>*@
<th class="formTitle">询价单编号:</th>
<td class="formValue">
<input type="text" id="RFQNO" class="form-control" readonly="readonly" style="width: 98%" disabled/>
</td>
<th class="formTitle">询价单名称:</th>
<td class="formValue">
<input type="text" id="RFQName" class="form-control" style="width: 98%" disabled/>
</td>
</tr>
<tr>
<th class="formTitle">单据日期:</th>
<td class="formValue">
<input type="text" id="RFQdate" class="form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" style="width: 98%" disabled/>
</td>
<th class="formTitle">
是否需上传成本明细:
</th>
<td class="formValue">
<select id="Sel_HASCOSTDETAILS" name="Sel_HASCOSTDETAILS" class="select2 form-control " placeholder="是否需上传成本明细.." style="width:32px" disabled></select>
</td>
</tr>
<tr>
<th class="formTitle">备注:</th>
<td class="formValue" colspan="3">
<textarea id="Remarks" name="Remarks" cols="200" class="form-control" style="height:32px;line-height:32px" disabled></textarea>
</td>
</tr>
<tr>
<th class="formTitle">附件名称:</th>
<td class="formValue" colspan="3">
<input id="fileName" name="fileName" style="display:none">
<div id="hidbtn" style=" border: 1px #edeff3 solid"></div>
</td>
<td class="formValue">
<input id='FileUp' type='file' style="display: none" onchange="UpLoadFile(this)" multiple="multiple" />
@*<button id="btn_FileUp" class="btn btn-info" type="button" onclick="UpLoadFiles(this)">上传附件</button>*@
</td>
</tr>
</table>
</div>
<div class="gridPanel" style="margin-left:10px">
<span><strong>询价物料清单</strong></span>
<div id="gridPanel">
<table id="gridList"></table>
</div>
<div style="text-align:center">
<!--<button id="Additem" class="btn btn-info" type="button" onclick="AddInv('zs')">添加正式物料</button>
<button id="Additem" class="btn btn-info" type="button" onclick="AddPU()">请购添加标的</button>
<button id="Additem" class="btn btn-info" type="button" onclick="AddPoMain()">采购添加标的</button>
<button id="AdditemFSC_ID" class="btn btn-info" type="button" onclick="AdditemFSC()">添加非生产标的</button>-->
@*<button id="AddTemitem" class="btn btn-primary" type="button" onclick="AddInv('ls')">添加临时物料</button>*@
<!--<button id="deleteitem" class="btn btn-danger" type="button" onclick="deleteInv()">删除物料</button>
<button id="btn_UpdateTime" class="btn btn-info" type="button" onclick="UpdateTime()">一键同步</button>-->
@*<button id="btn_Back" class="btn btn-info" type="button" onclick="Back()">退回</button>*@
</div>
</div>
<div class="gridPane2" style="margin-left:10px;display:none">
<span style="display:block;margin-top:20px">
<strong>询价供应商清单</strong>
</span>
<table id="gridList2"></table>
<div style="text-align:center">
<button id="Addsupply" class="btn btn-info" type="button" onclick="AddSupplier()">添加供应商</button>
<button id="deletesupply" type="button" class="btn btn-danger" onclick="DeleteSup()">删除供应商</button>
</div>
</div>
</form>