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.

1107 lines
47 KiB

2 months ago
2 weeks ago
2 months ago
2 weeks ago
2 months ago
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  6. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  7. <script src="~/Content/js/select2/select2.min.js"></script>
  8. <script>
  9. var rfqcode = $.request("rfqcode");
  10. var status = $.request("status");
  11. $(function () {
  12. debugger;
  13. var UserName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName'
  14. var myDate = new Date();
  15. var year = myDate.getFullYear(); //获取当前年
  16. var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
  17. var date = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
  18. $("#RFQdate").val(year + "-" + mon + "-" + date);
  19. //getWorkPoint();
  20. SelHASCOSTDETAILS();
  21. InitControl();
  22. GetSORRVenDorFile();
  23. ClearTemp();
  24. reloadData();
  25. $.ajax({
  26. url: "/SRM/BicDoc_Publish/GetWorkPointByUser" + "?" + Math.random(),
  27. dataType: "json",
  28. async: false,
  29. success: function (data) {
  30. $("#Workpoint").val(data.rows[0].F_Location).trigger("change");
  31. }
  32. });
  33. debugger;
  34. $("#POorg option:contains('" + UserName + "')").attr('selected', true).trigger("change");
  35. })
  36. //文件显示
  37. function GetSORRVenDorFile() {
  38. debugger;
  39. var Fules = '';
  40. $.ajax({
  41. //url: "/SRM/BicDoc_Seller/GetICSBidDoc" + "?" + Math.random() + "&BidCode=" + BidCode + "&WorkPoint=" + WorkPoints,
  42. url: "/SRM/PriceInquiry/GetICSSORRFQRequestFromVenDorFile?rfqcode=" + rfqcode,
  43. dataType: "json",
  44. async: false,
  45. success: function (data) {
  46. debugger;
  47. if (data.rows.length > 0) {
  48. Fules = data.rows[0].Filename;
  49. }
  50. }
  51. });
  52. debugger
  53. var innerhtml = '';
  54. if (Fules != "" && Fules != null) {
  55. debugger;
  56. //Fules = Fules.substring(0, Fules.length - 1);
  57. var File = Fules.split(';');
  58. for (var i = 0; i < File.length; i++) {
  59. innerhtml += " <a href='../../../File/SORRFQFile/" + rfqcode + "/" + File[i] + "' download='" + File[i] + "' style='color:blue;'>" + File[i] + "</a>";
  60. }
  61. $("#hidbtn").html(innerhtml);
  62. $("#fileName").val(Fules);
  63. }
  64. }
  65. //下拉框加载
  66. function InitControl() {
  67. debugger;
  68. var OrgName = $("#PoOrgName");
  69. var Workpoint = $("#Workpoint");
  70. OrgName.select2({
  71. placeholder: "请选择",
  72. placeholderOption: "first",
  73. allowClear: true,
  74. escapeMarkup: function (m) {
  75. return m;
  76. }
  77. })
  78. Workpoint.select2({
  79. placeholder: "请选择",
  80. placeholderOption: "first",
  81. allowClear: true,
  82. escapeMarkup: function (m) {
  83. return m;
  84. }
  85. })
  86. OrgName.change(function () {
  87. $("#POorg").select2("val", "");
  88. $("#POorg").html("");
  89. var value = $("#PoOrgName option:selected").val()
  90. $.ajax({
  91. url: "/SRM/RFQAdd/GetPurTeam?code=" + value + "&" + Math.random,
  92. async: false,
  93. success: function (data) {
  94. var datas = JSON.parse(data);
  95. $("#POorg").append("<option value=''>&nbsp;请选择</option>")
  96. $.each(datas, function (index, item) {
  97. $("#POorg").append("<option value='" + item.purchugcode + "'>&nbsp;" + item.purchugname + "</option>")
  98. })
  99. }
  100. })
  101. })
  102. $("#INVType").select2({
  103. placeholder: "请选择",
  104. placeholderOption: "first",
  105. allowClear: true,
  106. escapeMarkup: function (m) {
  107. return m;
  108. }
  109. })
  110. $("#POorg").select2({
  111. placeholder: "请选择",
  112. placeholderOption: "first",
  113. allowClear: true,
  114. escapeMarkup: function (m) {
  115. return m;
  116. }
  117. })
  118. $.ajax({
  119. url: "/SRM/RFQAdd/GetInvType?" + Math.random,
  120. datatype: "json",
  121. async: false,
  122. success: function (data) {
  123. var datas = JSON.parse(data);
  124. $("#INVType").append("<option value=''>&nbsp;请选择</option>")
  125. $.each(datas, function (index, item) {
  126. $("#INVType").append("<option value='" + item.F_ItemName + "'>&nbsp;" + item.F_ItemName + "</option>")
  127. })
  128. }
  129. })
  130. $.ajax({
  131. url: "/SRM/ASNAdd/GetVendors" + "?" + Math.random(),
  132. dataType: "json",
  133. async: false,
  134. success: function (data) {
  135. $.each(data, function (index, item) {
  136. $("#Workpoint").append("<option value='" + item.WorkPointCode + "'>&nbsp;" + item.WorkPointName + "</option>");
  137. });
  138. }
  139. });
  140. $("#POorg").change(function () {
  141. if ($("#Workpoint").children('option:selected').val() == '') {
  142. $.modalAlert("请先选择站点!", "warning");
  143. return;
  144. }
  145. }
  146. )
  147. Workpoint.change(function () {
  148. debugger;
  149. OrgName.empty();
  150. var zd = Workpoint.find("option:selected").val();
  151. $.ajax({
  152. url: "/SRM/RFQAdd/GetPUROrganize?workpoint=" + zd + "&" + Math.random,
  153. datatype: "json",
  154. async: false,
  155. success: function (data) {
  156. var datas = JSON.parse(data)
  157. //OrgName.append("<option value=''>&nbsp;请选择</option>")
  158. $.each(datas, function (index, item) {
  159. OrgName.append("<option value='" + item.purchugcode + "'>&nbsp;" + item.purchugname + "</option>");
  160. $("#PoOrgName").val([item.purchugcode]).trigger("change");
  161. });
  162. debugger;
  163. }
  164. })
  165. if (rfqcode == ""|| rfqcode == null || rfqcode == undefined) {
  166. $.ajax({
  167. url: "/SRM/PriceInquiry/GetSercodeICSSORRFQRequestFrom?workpoint=" + zd + "&" + Math.random,
  168. datatype: "json",
  169. async: false,
  170. success: function (data) {
  171. $("#RFQNO").attr("value", data);
  172. $("#RFQName").attr("value", "申请单" + data);
  173. }
  174. })
  175. }
  176. })
  177. //$("#PoOrgName").change(function () {
  178. // var OrgNamess = OrgName.find("option:selected").val();
  179. // $.ajax({
  180. // url: "/SRM/RFQAdd/GetPurTeam?" + OrgNamess + "&" + Math.random,
  181. // datatype: "json",
  182. // async: false,
  183. // success: function (data) {
  184. // var datas = JSON.parse(data);
  185. // $("#POorg").append("<option value=''>&nbsp;请选择</option>")
  186. // $.each(datas, function (index, item) {
  187. // $("#POorg").append("<option value='" + item.purchugsoncode + "'>&nbsp;" + item.name + "</option>")
  188. // })
  189. // }
  190. // })
  191. //});
  192. if (rfqcode != "" && rfqcode != null && rfqcode != undefined) {
  193. debugger;
  194. $.ajax({
  195. url: "/SRM/PriceInquiry/GetICSSORRFQRequestFromrow?rfqcode=" + rfqcode + "&" + Math.random(),
  196. async: false,
  197. success: function (data) {
  198. var newdata = eval("(" + data + ")");
  199. var row1 = newdata.Table;
  200. $.each(row1, function (index, row) {
  201. if (row.rfqcode == rfqcode) {
  202. $("#Workpoint").val([row.workpoint]).trigger("change");
  203. //$("#Workpoint").trigger("change");
  204. //var PoOrgName = $("#PoOrgName").select2();
  205. //PoOrgName.val(row.purchugcode).trigger("change");
  206. $("#PoOrgName").val([row.purchugcode]).trigger("change");
  207. $("#POorg").val([row.purteam]).trigger("change");
  208. $("#Remarks").val(row.memo);
  209. $("#RFQNO").attr("value", rfqcode);
  210. $("#RFQName").attr("value", row.rfqname);
  211. $("#RFQdate").attr("value", row.createdate);
  212. $("#fileName").val(row.FileName);
  213. $("#Sel_HASCOSTDETAILS").val(row.HASCOSTDETAILS).trigger("change");//是否上传模板
  214. //var innerhtml = '';
  215. //if (row.FileName != "" && row.FileName != null) {
  216. // debugger;
  217. // var File = row.FileName.split(';');
  218. // for (var i = 0; i < File.length; i++) {
  219. // innerhtml += " <a href='../../../File/SORRFQFile/" + row.RFQCODE + "/" + File[i] + "' download='" + File[i] + "' style='color:blue;'>" + File[i] + "</a><br>";
  220. // }
  221. //}
  222. }
  223. })
  224. }
  225. })
  226. }
  227. }
  228. //是否上传成本明细下拉选项
  229. function SelHASCOSTDETAILS() {
  230. debugger;
  231. var $HASCOSTDETAILS = $("#Sel_HASCOSTDETAILS");
  232. $HASCOSTDETAILS.select2({
  233. allowClear: true,
  234. escapeMarkup: function (m) {
  235. return m;
  236. }
  237. });
  238. //$WhetheProdDevCapability.append("<option value=''>&nbsp;</option>");
  239. $HASCOSTDETAILS.append("<option value='0'>&nbsp;否</option>");
  240. $HASCOSTDETAILS.append("<option value='1'>&nbsp;是</option>");
  241. /* $("#Sel_HASCOSTDETAILS").val([1]).trigger("change");//是否上市公司*/
  242. }
  243. //清理
  244. function ClearTemp() {
  245. $.ajax({
  246. url: "/SRM/InvAdd/ClearInvTemp?" + Math.random(),
  247. datatype: "json",
  248. async: false
  249. })
  250. }
  251. //加载jqGrid
  252. function reloadData() {
  253. document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> ';//重置grid
  254. $("#gridList").dataGrid({
  255. url: "/SRM/PriceInquiry/GetInvTabICSSORRFQRequestFrom?" + Math.random(),
  256. postData: { rfqno: $("#RFQNO").val() },
  257. height: $(window).height() - 300,
  258. width: $(window).width(),
  259. cellEdit: true,
  260. colModel: [
  261. { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true },
  262. { label: '物料代码', name: '物料代码', width: 150, align: 'left' },
  263. { label: '物料描述', name: '物料名称', width: 150, align: 'left' },
  264. { label: '物料规格', name: '物料规格', width: 150, align: 'lreft' },
  265. { label: '物料类型', name: '物料类型', width: 150, align: 'left', hidden: true },
  266. { label: '单位', name: '单位', width: 50, align: 'left' },
  267. { label: '询价备注', name: '备注', width: 100, align: 'left',hidden:true },
  268. { label: '参考价格', name: '参考价格', width: 100, align: 'left', edittype: 'text', editrules: { number: true },hidden:true },
  269. { label: '需求数量', name: '预计需求量', width: 60, align: 'left', edittype: 'text', editrules: { number: true } },
  270. {
  271. label: '是否需上传成本明细', name: '成本明细', width: 150, align: 'left', edittype: 'select', editoptions: { value: GetItemCode(), },
  272. formatter: function (cellvalue) {
  273. debugger;
  274. if (cellvalue == "undefined" || cellvalue == "" || cellvalue == undefined) {
  275. return "";
  276. } else if (cellvalue == "1") {
  277. return "是";
  278. } else if (cellvalue == "0") {
  279. return "否";
  280. }
  281. },hidden:true
  282. },
  283. { label: '是否含税', name: '是否含税', width: 100, align: 'left', edittype: 'select', editoptions: { value: GetItemCode(), },hidden:true },
  284. { label: '币种', name: '币种', width: 150, align: 'left', hidden:true },
  285. { label: 'HiddenFile', name: 'HiddenFile', align: 'left', hidden: true },
  286. { label: '备注', name: '备注', width: 180, align: 'left' },
  287. {
  288. label: '技术要求文件', name: '文件路径', width: 350, align: 'left',
  289. formatter: function (cellvalue, options, rowObject) {
  290. var RFQNO = $("#RFQNO").val();
  291. var html = "";
  292. if (cellvalue != "" && cellvalue != null) {
  293. html = " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + cellvalue + "' download='" + cellvalue + "' style='color:#1281C1;'>" + cellvalue + "</a>";
  294. //html = " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>";
  295. }
  296. return html;
  297. }
  298. },
  299. { label: '物料描述', name: '物料描述', width: 180, align: 'left' },
  300. { label: '制造商', name: '制造商', width: 180, align: 'left', hidden: true },
  301. { label: '制造商编码', name: '制造商编码', width: 180, align: 'left', hidden: true },
  302. { label: '年用量', name: '年用量', width: 180, align: 'left' },
  303. { label: '项目信息', name: '项目信息', width: 180, align: 'left', hidden: true },
  304. { label: '物料等级', name: '物料等级', width: 180, align: 'left', hidden: true },
  305. { label: '是否为客户指定', name: '是否为客户指定', width: 180, align: 'left', hidden: true },
  306. { label: '技术负责人', name: '技术负责人', width: 180, align: 'left', hidden: true },
  307. { label: 'Status', name: 'Status', width: 180, align: 'left', hidden: true },
  308. ],
  309. cellsubmit: "clientArray",
  310. rowNum: 10000,
  311. gridComplete: function () {
  312. var strIds = $("#gridList").jqGrid("getDataIDs");
  313. for (var i = 0; i < strIds.length; i++) {
  314. var strValue = $("#gridList").jqGrid("getCell", strIds[i], "Status");//得到单元格数据
  315. if (strValue == "2") {
  316. $("#" + strIds[i]).find("td").css("background-color", "red");
  317. }
  318. }
  319. },
  320. });
  321. }
  322. //jqGrid中的下拉选项定于
  323. function GetItemCode() {
  324. var str = "0:否;1:是";
  325. /*debugger;*/
  326. return str;
  327. }
  328. //操作按钮上传文件
  329. function btnModifys(cellvalue, options, rowObject) {
  330. debugger;
  331. return cellvalue = "<a class=\"btn btn-info dropdown-text\" onclick=\"UpLoadFilestechnicalrequirement('" + rowObject.ID + "')\">上传文件</a>";
  332. }
  333. //上传触发控件
  334. function UpLoadFilestechnicalrequirement(ID, GGUID) {
  335. debugger;
  336. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();//提交取消编辑状态
  337. var rowData = $("#gridListVENDORCERTIFICATE").jqGrid('getRowData', ID);
  338. $("#FileUpBYRZinp").val(ID);
  339. //$("#FileUpBYRZEndDate").val(rowData.ENDDATE);
  340. //$("#FileUpBYRZEndCQ").val(rowData.ADDITION1);
  341. //$("#FileUpBYGGUID").val(GGUID);
  342. $("#FileUpBYRZ").click();
  343. }
  344. //上传文件方法
  345. function UpLoadFileBYRZ(fileinfo) {
  346. debugger;
  347. var ID = $("#FileUpBYRZinp").val();
  348. var RFQNO = $("#RFQNO").val();
  349. var files = fileinfo.files;
  350. var fileName = files[0].name;
  351. if (fileName != null && fileName != "") {
  352. var regex = /\s/;
  353. if (regex.test(fileName)) {
  354. $.modalAlert("文件名:<span style='color: red;'>" + fileName + "</span>,包含空格,上传失败,请修改后重新上传!", "warning");
  355. var file = document.getElementById('FileUpBYRZ');
  356. file.value = "";
  357. return false;
  358. }
  359. var data = new FormData();
  360. jQuery.each(jQuery('#FileUpBYRZ')[0].files, function (i, file) {
  361. data.append('file-' + i, file);
  362. });
  363. $.modalConfirm("确定上传文件吗?", function (r) {
  364. debugger;
  365. if (r) {
  366. $.ajax({
  367. url: "/SRM/RFQAdd/UpLoadFileImport" + "?" + Math.random() + "&ID=" + ID + "&RFQNO=" + RFQNO,
  368. type: "post",
  369. data: data,
  370. dataType: "json",
  371. contentType: false,
  372. processData: false,
  373. success: function (data) {
  374. debugger;
  375. if (data.state == 'error') {
  376. $.modalAlert("上传失败!");
  377. } else if (data.state == 'success') {
  378. //var FileName = data.FileName;
  379. //var PathName = data.PathName;
  380. //$("#AEquipment").text(FileName);
  381. //$('#AEquipment').attr('href', '../../File/VendorFile/' + RoleEnCode + '/' + FileName + '');
  382. $("#gridList").jqGrid('setCell', ID, "文件路径", fileName);
  383. $("#gridList").jqGrid('setCell', ID, "HiddenFile", fileName);
  384. $.modalMsg("上传成功", "success");
  385. }
  386. },
  387. error: function (aa) {
  388. //$.modalAlert("上传失败:" + aa);
  389. $.modalMsg("上传失败", "error");
  390. }
  391. });
  392. }
  393. });
  394. }
  395. var file = document.getElementById('FileUpBYRZ');
  396. file.value = "";
  397. }
  398. //添加正式物料
  399. function AddInv(type) {
  400. debugger;
  401. if ($("#RFQNO").val() == "") {
  402. $.modalAlert("请先填写站点信息!", "warning")
  403. return;
  404. }
  405. if ($("#RFQdate").val() == "") {
  406. $.modalAlert("请先填写单据日期!", "warning")
  407. return;
  408. }
  409. if (status != "1") {
  410. if ($("#PoOrgName").children('option:selected').val() == "") {
  411. $.modalAlert("请先选择采购组织!", "warning")
  412. return;
  413. }
  414. }
  415. var sfqcode = $("#RFQNO").val();
  416. var WorkPoint = $("#Workpoint").children('option:selected').val();
  417. var index = layer.open({
  418. id: "Formitem",
  419. type: 2,
  420. shade: 0.3,
  421. title: "新增物料",
  422. fix: false,
  423. area: ["900px", "600px"],
  424. content: "/SRM/InvAdd/Invmes?" + Math.random() + "&workpoint=" + WorkPoint,
  425. btn: ['确定', '关闭'],
  426. btnclass: ['btn btn-primary', 'btn btn-danger'],
  427. maxmin: true,
  428. yes: function (index, layero) {
  429. var body = layer.getChildFrame('body', index);
  430. var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  431. objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
  432. var arrayData = getJQAllData("#gridList");
  433. for (var j = 0; j < objArr.length; j++) {
  434. debugger;
  435. for (var i = 0; i < arrayData.length; i++) {
  436. if (objArr[j].物料代码 == arrayData[i].物料代码) {
  437. $.modalAlert("已添加物料!请勿重复添加!", "warning");
  438. return;
  439. }
  440. }
  441. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  442. $(".unwritten").hide();
  443. }
  444. layer.close(index);
  445. }, cancel: function () {
  446. return true;
  447. }
  448. });
  449. }
  450. function getJQAllData(list) {
  451. //拿到grid对象
  452. var obj = $(list);
  453. //获取grid表中所有的rowid值
  454. var rowIds = obj.getDataIDs();
  455. //初始化一个数组arrayData容器,用来存放rowData
  456. var arrayData = new Array();
  457. if (rowIds.length > 0) {
  458. for (var i = 0; i < rowIds.length; i++) {
  459. //rowData=obj.getRowData(rowid);//这里rowid=rowIds[i];
  460. arrayData.push(obj.getRowData(rowIds[i]));
  461. }
  462. }
  463. return arrayData;
  464. }
  465. //清理
  466. function Close() {
  467. ClearTemp();
  468. $.modalClose();
  469. }
  470. //删除物料信息
  471. function deleteInv() {
  472. debugger;
  473. var ids = $('#gridList').jqGrid('getGridParam', 'selarrrow');
  474. if (ids.lenth <= 0) {
  475. $.modalAlert("请选择要删除的数据!", "warning");
  476. return;
  477. }
  478. debugger;
  479. var rowid = "";
  480. var WorkPoint = $("#sel_WorkPoint option:checked").val();
  481. var objArr = "";
  482. //var objList = $("#gridList1").jqGrid('getGridParam', 'selrow');
  483. //if (objList.length == 0) {
  484. // $.modalAlert("请选择要删除的标的数据!");
  485. // return;
  486. //}
  487. //for (var i = 0; i < objList.length; i++) {
  488. // var rowId = objList[i];
  489. // var rowData = $("#gridList1").jqGrid('getRowData', rowId);
  490. // objArr += "'" + rowData.ID + "',";
  491. // rowid += rowData.ID + ",";
  492. //}
  493. //rowid = rowid.trimEnd(',');
  494. //var rowid1 = rowid.split(',');
  495. $.deleteForm({
  496. url: "/SRM/InvAdd/DeleteInvRowICSSORRFQRequestFrom" + "?" + Math.random(),
  497. param: { keyValue: $("#gridList").jqGridRowValue().ID },
  498. success: function () {
  499. $("#gridList").delRowData($("#gridList").jqGridRowValue().ID);
  500. //$.currentWindow().$("#gridList1").trigger("reloadGrid");
  501. //for (var i = 0; i < rowid1.length; i++) {
  502. // $("#gridList1").delRowData(rowid1[i]);
  503. //}
  504. var obj_item = $("#gridList");
  505. var rowIds_item = obj_item.getDataIDs();
  506. if (rowIds_item.length <= 0) {
  507. reloadData();
  508. }
  509. }
  510. })
  511. }
  512. //保存 提交
  513. function submitForm() {
  514. debugger;
  515. $("#gridList2").find($("td[aria-describedby='gridList2_rn']")).click();
  516. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
  517. var FKID = '';
  518. if ($("#RFQNO").val() == "") {
  519. $.modalAlert("请先选择站点!", "warning");
  520. return;
  521. }
  522. //if ($("#PoOrgName").text() == "") {
  523. // $.modalAlert("采购组织名称不能为空!", "warning");
  524. // return;
  525. //}
  526. if ($("#RFQdate").val() == "") {
  527. $.modalAlert("单据日期不能为空!", "warning");
  528. return;
  529. }
  530. var gridList = $("#gridList");
  531. var gridListrowIds = gridList.getDataIDs();
  532. if (gridListrowIds.length <= 0) {
  533. $.modalAlert("请选择物料再提交!", "warning");
  534. return;
  535. }
  536. //var gridList2 = $("#gridList2");
  537. //var gridList2rowIds = gridList2.getDataIDs();
  538. //if (gridList2rowIds.length <= 0) {
  539. // $.modalAlert("请选择供应商再提交!", "warning");
  540. // return;
  541. //}
  542. //if (gridList2rowIds.length > 0) {
  543. // for (var i = 0; i < gridList2rowIds.length; i++) {
  544. // var gridList2RowData = gridList2.getRowData(gridList2rowIds[i]);
  545. // FKID += "" + gridList2RowData.ID + ",";
  546. // if (gridList2RowData.供应商付款条件 == '') {
  547. // $.modalAlert("第" + (i + 1).toString() + "行,未输入付款条件!");
  548. // return false;
  549. // }
  550. // if (gridList2RowData.是否显示参考价 == '') {
  551. // $.modalAlert("第" + (i + 1).toString() + "行,未选择是否显示参考价!");
  552. // return false;
  553. // }
  554. // }
  555. //}
  556. var code = $("#RFQNO").val();
  557. var FileName = $("#fileName").val();
  558. /* var Orgcode = $("#PoOrgName").val();*/
  559. /* var Purteam = $("#POorg").val();*/
  560. var Name = $("#RFQName").val();
  561. var now = new Date();
  562. //var CreateDate = now.getFullYear() + "-" + ((now.getMonth() + 1) < 10 ? "0" : "") + (now.getMonth() + 1) + "-" + (now.getDate() < 10 ? "0" : "") + now.getDate();
  563. //var CreateTime = (now.getHours() < 10 ? "0" : "") + now.getHours() + ":" + (now.getMinutes() < 10 ? "0" : "") + now.getMinutes() + ":" + (now.getSeconds() < 10 ? "0" : "") + now.getSeconds();
  564. var Workpoint = $("#Workpoint").val();
  565. var begindate = $("#RFQdate").val();
  566. var COSTANALYSISTEMPLATE = "~/File/报价模板.xlsx";
  567. var COSTTYPE = "Common";
  568. var ISUNIFYANALYSISTEMPLATE = "1";
  569. var memo = $("#Remarks").val();
  570. var status = "0";
  571. var ID = FKID;
  572. var HASCOSTDETAILS = '';
  573. var HASCOSTDETAILS = $("#Sel_HASCOSTDETAILS").val();
  574. //if (HASCOSTDETAILS == "是") {
  575. // HASCOSTDETAILS = 1
  576. //} else {
  577. // HASCOSTDETAILS = 0
  578. //}
  579. //物料
  580. var obj_item = $("#gridList");
  581. var rowIds_item = obj_item.getDataIDs();
  582. var arrayData_item = new Array();
  583. if (rowIds_item.length > 0) {
  584. for (var i = 0; i < rowIds_item.length; i++) {
  585. var itemRowData = obj_item.getRowData(rowIds_item[i]);
  586. if (itemRowData.预计需求量 == '' || itemRowData.预计需求量 == null) {
  587. $.modalAlert("请维护物料" + itemRowData.物料代码 + "计划采购数量", "warning")
  588. return false;
  589. }
  590. if (itemRowData.是否显示参考价 == "是") {
  591. ISSHOWPRICE = 1
  592. } else {
  593. ISSHOWPRICE = 0
  594. }
  595. //if (itemRowData.DeliveryTime == '' || itemRowData.DeliveryTime == null) {
  596. // $.modalAlert("请维护物料" + itemRowData.INVCODE + "交期", "warning")
  597. // return false;
  598. //}
  599. var YearQty = itemRowData.年用量 == '' ? 0 : itemRowData.年用量;
  600. var obj = {
  601. ID: itemRowData.ID,
  602. RFQCODE: code,
  603. ITEMCODE: itemRowData.物料代码,
  604. ITEMNAME: itemRowData.物料名称,
  605. InvStd: itemRowData.物料规格,
  606. ITEMTYPE: itemRowData.物料类型,
  607. UNIT: itemRowData.单位,
  608. MEMO: itemRowData.备注,
  609. Requirements: itemRowData.技术要求,
  610. REFERPRICE: itemRowData.参考价格,
  611. REQUESTQUANTITY: itemRowData.预计需求量,
  612. HASCOSTDETAILS: HASCOSTDETAILS,//是否需上传成本明细
  613. ISINCLUDETAX: itemRowData.是否含税,
  614. CURRENCY: itemRowData.币种,
  615. RFQITEMREFERCODE: itemRowData.HiddenFile,
  616. Workpoint: Workpoint,
  617. InvDesc: itemRowData.物料描述,
  618. ManuFacturer: itemRowData.制造商,
  619. ManuFacturerInvCode: itemRowData.制造商编码,
  620. YearQty: YearQty,
  621. ProjectInfo: itemRowData.项目信息,
  622. MaterialGrade: itemRowData.物料等级,
  623. CustomerSpecified: itemRowData.是否为客户指定,
  624. TechnicalDirector: itemRowData.技术负责人,
  625. };
  626. arrayData_item.push(obj);
  627. }
  628. } else {
  629. $.modalAlert("请选择标的信息!", "warning")
  630. return false;
  631. }
  632. //供应商
  633. //标的
  634. //var obj_VenCode = $("#gridList2");
  635. //var rowIds_VenCode = obj_VenCode.getDataIDs();
  636. //var arrayData_VenCode = new Array();
  637. //if (rowIds_VenCode.length > 0) {
  638. // for (var i = 0; i < rowIds_VenCode.length; i++) {
  639. // var VenCodeRowData = obj_VenCode.getRowData(rowIds_VenCode[i]);
  640. // var obj = {
  641. // ID: VenCodeRowData.ID,
  642. // RFQCODE: code,
  643. // VENDORCODE: VenCodeRowData.供应商代码,
  644. // VENDORTYPE: VenCodeRowData.供应商类型,
  645. // TAXRATE: VenCodeRowData.供应商税率,
  646. // CURRENCY:VenCodeRowData.供应商币别,
  647. // PAYMENTCONDITION:VenCodeRowData.供应商付款条件,
  648. // ISSHOWPRICE: ISSHOWPRICE,
  649. // CauseOff: VenCodeRowData.关闭原因,
  650. // Workpoint: Workpoint
  651. // };
  652. // arrayData_VenCode.push(obj);
  653. // }
  654. //} else {
  655. // $.modalAlert("请选择应标供应商!", "warning")
  656. // return false;
  657. //}
  658. var arrayitem = JSON.stringify(arrayData_item);
  659. //var arrayVenCode = JSON.stringify(arrayData_VenCode);
  660. $.ajax({
  661. url: "/SRM/PriceInquiry/AddICSSORRFQRequestFromByPN?" + Math.random(),
  662. data: {
  663. RFQCODE: code,
  664. /*PURCHUGCODE: Orgcode,*/
  665. RFQNAME: Name,
  666. //CreateDate1: CreateDate,
  667. //CreateTime1: CreateTime,
  668. HASCOSTDETAILS: HASCOSTDETAILS,//是否需上传成本明细
  669. FileName: FileName,
  670. RFQstatus:status,
  671. Workpoint: Workpoint,
  672. /* PURTeam: Purteam,*/
  673. BEGINDATE: begindate,
  674. //COSTANALYSISTEMPLATE1: COSTANALYSISTEMPLATE,
  675. COSTTYPE: COSTTYPE,
  676. ISUNIFYANALYSISTEMPLATE1: ISUNIFYANALYSISTEMPLATE,
  677. //COSTTYPE1: COSTTYPE,
  678. MEMO: memo,
  679. STATUS: status,
  680. ID: ID,
  681. arrayBidDocBD: arrayitem,
  682. //arrayBidDocGYS: arrayVenCode,
  683. },
  684. type: "post",
  685. dataType: "json",
  686. success: function (data) {
  687. debugger;
  688. if (data.state == "success") {
  689. layer.msg(data.message);
  690. $.currentWindow().$("#gridList").trigger("reloadGrid");
  691. $.modalClose();
  692. return true;
  693. } else {
  694. layer.msg(data.message);
  695. }
  696. },
  697. error: function (XMLHttpRequest, textStatus, errorThrown) {
  698. layer.msg(errorThrown);
  699. },
  700. beforeSend: function () {
  701. },
  702. complete: function () {
  703. $.loading(false);
  704. }
  705. });
  706. }
  707. function UpdateTime() {
  708. if ($("#Workpoint").children('option:selected').val() == "") {
  709. $.modalAlert("请先选择站点!", "warning");
  710. return;
  711. }
  712. debugger;
  713. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
  714. var obj_Item1 = $("#gridList");
  715. var rowIds_Item1 = obj_Item1.getDataIDs();
  716. if (rowIds_Item1.length > 0) {
  717. for (var i = 0; i < rowIds_Item1.length; i++) {
  718. var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]);
  719. var RowData_Item1Date = obj_Item1.getRowData(rowIds_Item1[0]);
  720. var Qty = RowData_Item1Date.预计需求量
  721. if (Qty == "") {
  722. $.modalAlert("请先填写第一个数量再同步");
  723. return;
  724. }
  725. //RowData_Item1.DeliveryTime = Datetime
  726. //$('#gridList1').jqGrid('setRowData', i, RowData_Item1);
  727. //给单元格赋值
  728. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "预计需求量", Qty);
  729. }
  730. }
  731. }
  732. function AddPU() {
  733. if ($("#Workpoint").children('option:selected').val() == "") {
  734. $.modalAlert("请先选择站点!", "warning");
  735. return;
  736. }
  737. //if ($("#PoOrgName").children('option:selected').val() == "") {
  738. // $.modalAlert("请先选择采购组织!", "warning")
  739. // return;
  740. //}
  741. //if ($("#POorg").children('option:selected').val() == "") {
  742. // $.modalAlert("请先选择采购负责人!", "warning")
  743. // return;
  744. //}
  745. debugger;
  746. var WorkPoint = $("#Workpoint").children('option:selected').val();
  747. var index = layer.open({
  748. id: "ICSSORRFQByPU",
  749. type: 2,
  750. shade: 0.3,
  751. title: "请购单添加",
  752. fix: false,
  753. area: ["1000px", "600px"],
  754. content: "/SRM/RFQAdd/ICSSORRFQByPU?" + Math.random() + "&WorkPoint=" + WorkPoint,
  755. btn: ['确定', '关闭'],
  756. btnclass: ['btn btn-primary', 'btn btn-danger'],
  757. maxmin: true,
  758. yes: function (index, layero) {
  759. var body = layer.getChildFrame('body', index);
  760. var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  761. objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
  762. var arrayData = getJQAllData("#gridList");
  763. for (var j = 0; j < objArr.length; j++) {
  764. for (var i = 0; i < arrayData.length; i++) {
  765. if (objArr[j].物料代码 == arrayData[i].物料代码) {
  766. $.modalAlert("已添加标的!请勿重复添加!");
  767. return;
  768. }
  769. }
  770. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  771. $(".unwritten").hide();
  772. }
  773. layer.close(index);
  774. }, cancel: function () {
  775. return true;
  776. }
  777. });
  778. }
  779. function AddPoMain() {
  780. if ($("#Workpoint").children('option:selected').val() == "") {
  781. $.modalAlert("请先选择站点!", "warning");
  782. return;
  783. }
  784. //if ($("#PoOrgName").children('option:selected').val() == "") {
  785. // $.modalAlert("请先选择采购组织!", "warning")
  786. // return;
  787. //}
  788. //if ($("#POorg").children('option:selected').val() == "") {
  789. // $.modalAlert("请先选择采购负责人!", "warning")
  790. // return;
  791. //}
  792. debugger;
  793. var WorkPoint = $("#Workpoint").children('option:selected').val();
  794. var index = layer.open({
  795. id: "ICSSORRFQByPO",
  796. type: 2,
  797. shade: 0.3,
  798. title: "采购订单添加",
  799. fix: false,
  800. area: ["1200px", "600px"],
  801. content: "/SRM/RFQAdd/ICSSORRFQByPO?" + Math.random() + "&WorkPoint=" + WorkPoint,
  802. btn: ['确定', '关闭'],
  803. btnclass: ['btn btn-primary', 'btn btn-danger'],
  804. maxmin: true,
  805. yes: function (index, layero) {
  806. var body = layer.getChildFrame('body', index);
  807. var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  808. objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
  809. var arrayData = getJQAllData("#gridList");
  810. for (var j = 0; j < objArr.length; j++) {
  811. for (var i = 0; i < arrayData.length; i++) {
  812. if (objArr[j].物料代码 == arrayData[i].物料代码) {
  813. $.modalAlert("已添加标的!请勿重复添加!");
  814. return;
  815. }
  816. }
  817. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  818. $(".unwritten").hide();
  819. }
  820. layer.close(index);
  821. }, cancel: function () {
  822. return true;
  823. }
  824. });
  825. }
  826. function UpLoadFile(fileinfo) {
  827. debugger;
  828. //$("#CurrentPoCode").val(poCode);
  829. var files = fileinfo.files;
  830. var RFQNO = $("#RFQNO").val();
  831. var fileName = '';
  832. var innerhtml = '';
  833. for (var i = 0; i < files.length; i++) {
  834. var regex = /\s/;
  835. if (regex.test(files[i].name)) {
  836. $.modalAlert("文件名:<span style='color: red;'>" + files[i].name + "</span>,包含空格,上传失败,请修改后重新上传!", "warning");
  837. var file = document.getElementById('FileUp');
  838. file.value = "";
  839. return false;
  840. }
  841. fileName += "" + files[i].name + ";";
  842. if (fileName != null && fileName != "") {
  843. var data = new FormData();
  844. jQuery.each(jQuery('#FileUp')[0].files, function (i, file) {
  845. data.append('file-' + i, file);
  846. });
  847. //data.append("STNO", $("#CurrentSTNO").val());
  848. //var info = document.getElementById("form1");
  849. //var formData = new FormData(info);
  850. $.modalConfirm("确定上传文件吗?", function (r) {
  851. if (r) {
  852. $.ajax({
  853. url: "/SRM/RFQAdd/UpLoadFileImport" + "?" + Math.random() + "&RFQNO=" + RFQNO,
  854. type: "post",
  855. data: data,
  856. dataType: "json",
  857. contentType: false,
  858. processData: false,
  859. success: function (data) {
  860. debugger;
  861. if (data.state == "success") {
  862. $.modalMsg(data.message, data.state);
  863. $("#fileName").val(fileName);
  864. //$.currentWindow().$("#gridList").trigger("reloadGrid");
  865. }
  866. else {
  867. $.modalAlert("异常:" + data.message, data.state);
  868. }
  869. }
  870. });
  871. }
  872. });
  873. }
  874. }
  875. fileName = fileName.substring(0, fileName.length - 1);
  876. let arr1 = fileName.split(";");
  877. for (var k = 0; k < arr1.length; k++) {
  878. innerhtml += " <a href='../../../File/SORRFQFile/" + RFQNO + "/" + arr1[k] + "' download='" + arr1[k] + "' style='color:blue;'>" + arr1[k] + "</a>";
  879. }
  880. $("#hidbtn").html(innerhtml);
  881. var file = document.getElementById('FileUp');
  882. file.value = "";
  883. }
  884. //上传按钮触发事件
  885. function UpLoadFiles(STNO) {
  886. $("#FileUp").click();
  887. }
  888. function AdditemFSC() {
  889. var WorkPoint = $("#Workpoint option:checked").val();
  890. if (WorkPoint == "") {
  891. $.modalAlert("请填写站点", "warning")
  892. return false;
  893. }
  894. if ($("#ENDDATE").val() == "") {
  895. $.modalAlert("请先填写截止日期!", "warning");
  896. return;
  897. }
  898. debugger;
  899. var WorkPoint = $("#Workpoint option:checked").val();
  900. var index = layer.open({
  901. id: "AddFCS",
  902. type: 2,
  903. shade: 0.3,
  904. title: "新增非生产标的",
  905. fix: false,
  906. area: ["600px", "600px"],
  907. content: "/SRM/PriceInquiry/NoProductionMaterialAdd?" + Math.random() + "&WorkPoint=" + WorkPoint,
  908. btn: ['确定', '关闭'],
  909. btnclass: ['btn btn-primary', 'btn btn-danger'],
  910. maxmin: true,
  911. yes: function (index, layero) {
  912. var body = layer.getChildFrame('body', index);
  913. var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  914. objArr = iframeWin.submitForm();//执行iframe页的方法:iframeWin.method();
  915. var arrayData = getJQAllData("#gridList");
  916. for (var j = 0; j < objArr.length; j++) {
  917. for (var i = 0; i < arrayData.length; i++) {
  918. if (objArr[j].物料代码 == arrayData[i].物料代码) {
  919. debugger;
  920. $.modalAlert("已添加标的!请勿重复添加!");
  921. return;
  922. }
  923. }
  924. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  925. $(".unwritten").hide();
  926. }
  927. layer.close(index);
  928. }, cancel: function () {
  929. return true;
  930. }
  931. });
  932. }
  933. //导入
  934. function Import() {
  935. var WorkPoint = $("#Workpoint option:checked").val();
  936. if (WorkPoint == "") {
  937. $.modalAlert("请填写站点", "warning")
  938. return false;
  939. }
  940. debugger;
  941. var WorkPoint = $("#Workpoint option:checked").val();
  942. var RFQNO = $("#RFQNO").val();
  943. if (WorkPoint == "" || WorkPoint == null) {
  944. $.modalAlert("请选择站点后在上传标的!");
  945. return;
  946. } else if (RFQNO == "" || RFQNO == null) {
  947. $.modalAlert("请填写询价单号后在上传标的!");
  948. return;
  949. }
  950. $("#FileUpImport").click();
  951. }
  952. function btnUpLoad(up) {
  953. debugger;
  954. var BidCode = $("#txtBidCode").val();
  955. var GUID = $("#txtID").val();
  956. var WorkPoint = $("#Workpoint option:checked").val();
  957. var form = new FormData(document.getElementById("form1"));
  958. $.ajax({
  959. url: "/SRM/PriceInquiry/UploadFile?" + Math.random() + "&ID=" + ID + "&BidCode=" + BidCode + "&WorkPoint=" + WorkPoint,
  960. type: "post",
  961. data: form,
  962. contentType: false,
  963. processData: false,
  964. success: function (data) {
  965. var obj = eval('(' + data + ')');
  966. alert(obj.mass);
  967. InitControl11();
  968. },
  969. error: function (aa) {
  970. alert("上传失败:" + aa);
  971. }
  972. });
  973. }
  974. </script>
  975. <form id="form1">
  976. <input id="FileUpBYRZinp" hidden="hidden">
  977. <input id='FileUpBYRZ' type='file' style="display: none" onchange="UpLoadFileBYRZ(this)" multiple="multiple" />
  978. <div class="topPanel" style="height:10px">
  979. <div class="btn-group">
  980. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  981. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  982. </div>
  983. </div>
  984. <div style="margin-right: 20px;">
  985. <table class="form">
  986. <tr>
  987. <th class="formTitle">
  988. 站点:
  989. </th>
  990. <td class="formValue">
  991. <select id="Workpoint" name="Workpoint" class="select2 form-control " placeholder="请选择站点.." style="width:32px"></select>
  992. </td>
  993. @*<th class="formTitle">
  994. 采购组织:
  995. </th>
  996. <td class="formValue">
  997. <select id="PoOrgName" name="PoOrgName" class="select2 form-control " placeholder="请选择采购组织.."></select>
  998. <input type="hidden" id="hidetext" />
  999. </td>
  1000. <th class="formTitle">采购负责人:</th>
  1001. <td class="formValue">
  1002. <select id="POorg" name="POorg" class="select2 form-control " placeholder="请选择采购负责人.." style="width:32px"></select>
  1003. </td>*@
  1004. <th class="formTitle">询价单编号:</th>
  1005. <td class="formValue">
  1006. <input type="text" id="RFQNO" class="form-control" readonly="readonly" style="width: 98%" />
  1007. </td>
  1008. <th class="formTitle">询价单名称:</th>
  1009. <td class="formValue">
  1010. <input type="text" id="RFQName" readonly="readonly" class="form-control" style="width: 98%" />
  1011. </td>
  1012. </tr>
  1013. <tr>
  1014. <th class="formTitle">单据日期:</th>
  1015. <td class="formValue">
  1016. <input type="text" id="RFQdate" class="form-control" readonly="readonly" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" style="width: 98%" />
  1017. </td>
  1018. <th class="formTitle">
  1019. 是否需上传成本明细:
  1020. </th>
  1021. <td class="formValue">
  1022. <select id="Sel_HASCOSTDETAILS" name="Sel_HASCOSTDETAILS" class="select2 form-control " placeholder="是否需上传成本明细.." style="width:32px" disabled></select>
  1023. </td>
  1024. </tr>
  1025. <tr>
  1026. <th class="formTitle">备注:</th>
  1027. <td class="formValue" colspan="3">
  1028. <textarea id="Remarks" name="Remarks" readonly="readonly" cols="200" class="form-control" style="height:32px;line-height:32px"></textarea>
  1029. </td>
  1030. </tr>
  1031. @*<tr>
  1032. </tr>*@
  1033. <tr>
  1034. <th class="formTitle">附件名称:</th>
  1035. <td class="formValue" colspan="3">
  1036. <input id="fileName" name="fileName" style="display:none">
  1037. <div id="hidbtn" style=" border: 1px #edeff3 solid"></div>
  1038. </td>
  1039. <td class="formValue">
  1040. <input id='FileUp' type='file' style="display: none" onchange="UpLoadFile(this)" multiple="multiple" />
  1041. </td>
  1042. </tr>
  1043. </table>
  1044. </div>
  1045. <div class="gridPanel" style="margin-left:10px">
  1046. <span><strong>询价物料清单</strong></span>
  1047. <div id="gridPanel">
  1048. <table id="gridList"></table>
  1049. </div>
  1050. </div>
  1051. </form>