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.

943 lines
38 KiB

3 weeks ago
  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Form.cshtml";
  5. }
  6. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  7. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  8. <script src="~/Content/js/select2/select2.min.js"></script>
  9. <style>
  10. #Additem {
  11. margin-left: 45%;
  12. }
  13. #AddTemitem {
  14. margin-right: 45%;
  15. }
  16. </style>
  17. <script>
  18. var _Clos = new Array();
  19. var clears = new Array();
  20. var rfqcode = $.request("rfqcode");
  21. var ID = $.request("ID");
  22. var _LW = new Array();
  23. function GetDate() {
  24. let currentTime = new Date();
  25. let year = currentTime.getFullYear();
  26. let month = currentTime.getMonth() + 1; // 注意,月份是从0开始的,所以要加1
  27. let date = currentTime.getDate();
  28. let hours = currentTime.getHours();
  29. let minutes = currentTime.getMinutes();
  30. let seconds = currentTime.getSeconds();
  31. // 格式化时间,补全前导零
  32. month = month < 10 ? '0' + month : month;
  33. date = date < 10 ? '0' + date : date;
  34. hours = hours < 10 ? '0' + hours : hours;
  35. minutes = minutes < 10 ? '0' + minutes : minutes;
  36. seconds = seconds < 10 ? '0' + seconds : seconds;
  37. // 拼接时间字符串
  38. let formattedTime = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`;
  39. return formattedTime;
  40. }
  41. $(function(){
  42. SetCols();
  43. if (ID=='') {
  44. $(".MOPick").css('display', 'none');
  45. }
  46. var Muser = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  47. var date = GetDate();
  48. $("#txtMUSER").val(Muser);
  49. $("#txtMTIME").val(date);
  50. //判断是不是东辉特有的
  51. $.ajax({
  52. url: "/DHAY/ICSAccessoriesMOApply/GetDHCode?" + Math.random(),
  53. //data: { keyValue: keyValue },
  54. dataType: "json",
  55. async: false,
  56. success: function (data) {
  57. debugger;
  58. if (data.rows.length == 0) {
  59. InitControl();
  60. }
  61. else {
  62. InitControl6();
  63. }
  64. }
  65. });
  66. //InitControl();
  67. InitContro2();
  68. //InitContro3();
  69. InitContro4();
  70. InitContro5();
  71. ClearTemp();
  72. reloadData();
  73. GetUserDept()
  74. $("#sel_CodeType").change(function () {
  75. $.ajax({
  76. url: "/DHAY/ICSAccessoriesMOApply/GetBidCode" + "?" + Math.random(),
  77. dataType: "json",
  78. async: false,
  79. success: function (data) {
  80. if (data.Code != '') {
  81. $("#Code").val(data.Code);
  82. $("#Code").attr("disabled", "disabled");
  83. }
  84. }
  85. });
  86. });
  87. $("#sel_Dept").change(function () {
  88. var Dept = $("#sel_Dept option:selected").text();
  89. var CodeType = $("#sel_CodeType option:selected").text();
  90. if (Dept != '' && CodeType != '')
  91. {
  92. DocRequiredClear();
  93. DocRequired(Dept, CodeType);
  94. }
  95. });
  96. $("#sel_CodeType").change(function () {
  97. var Dept = $("#sel_Dept option:selected").text();
  98. var CodeType = $("#sel_CodeType option:selected").text();
  99. if (Dept != '' && CodeType != '') {
  100. DocRequiredClear();
  101. DocRequired(Dept, CodeType);
  102. }
  103. });
  104. $("#txt_CustomerName").on("keypress", function (e) {
  105. if (e.which === 13) { // 回车键(Enter)的键码是13
  106. searchCustomer();
  107. }
  108. });
  109. })
  110. function GetSelect_Project() {
  111. debugger;
  112. var Header = {
  113. TypeName:"项目",
  114. OrgCode: '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  115. }
  116. var str = "";
  117. $.ajax({
  118. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9CodeType?" + Math.random(),
  119. dataType: "json",
  120. data: { key1: JSON.stringify(Header) },
  121. async: false,
  122. async: false,
  123. success: function (data) {
  124. var jsonobj = eval(data);
  125. var length = jsonobj.length;
  126. for (var i = 0; i < length; i++) {
  127. if (i != length - 1) {
  128. str += jsonobj[i].Code + ":" + jsonobj[i].Name + ";";
  129. } else {
  130. str += jsonobj[i].Code + ":" + jsonobj[i].Name;// 这里是option里面的 value:label
  131. }
  132. var objFiledName = {
  133. Code: jsonobj[i].Code,
  134. Name: jsonobj[i].Name,
  135. }
  136. _LW.push(objFiledName);
  137. }
  138. }
  139. });
  140. return str;
  141. }
  142. function SetCols() {
  143. $.ajax({
  144. url: "/Print/SelectColumnName?" + Math.random(),
  145. dataType: "json",
  146. async: false,
  147. success: function (data) {
  148. var cols = new Array();
  149. var collast = { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true };
  150. cols.push(collast);
  151. var collast = { label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true };
  152. cols.push(collast);
  153. //var collast = {
  154. // label: '查看', width: 100, align: 'left',
  155. // formatter: btnLook
  156. //};
  157. // cols.push(collast);
  158. var collast = { label: '料品编码', name: 'InvCode', width: 100, align: 'left', editable: true};
  159. cols.push(collast);
  160. var collast = { label: '料品名称', name: 'INVNAME', width: 100, align: 'left' };
  161. cols.push(collast);
  162. var collast = { label: '规格型号', name: 'InvStd', width: 100, align: 'left' };
  163. cols.push(collast);
  164. var collast = { label: '仓库编码', name: 'WHCode', width: 100, align: 'left', hidden: true };
  165. cols.push(collast);
  166. var collast = { label: '仓库名称', name: 'WHCodeName', width: 100, align: 'left', editable: true };
  167. cols.push(collast);
  168. var collast = { label: '批号', name: 'Batch', width: 100, align: 'left', editable: true };
  169. cols.push(collast);
  170. var collast = { label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } };
  171. cols.push(collast);
  172. var collast = { label: '单位', name: 'InvUnit', width: 100, align: 'left', editable: true };
  173. cols.push(collast);
  174. var collast = { label: '可用数量', name: 'KQuantity', width: 100, align: 'left', editable: true, hidden: true };
  175. cols.push(collast);
  176. var collast = { label: '受益项目', name: 'SYproject', width: 100, align: 'left', editable: true, edittype: 'select', editoptions: { value: GetSelect_Project() } };
  177. cols.push(collast);
  178. var collast = { label: '工单', name: 'SourceCode', width: 100, align: 'left', editable: true, editrules: true };
  179. cols.push(collast);
  180. var collast = { label: '回收数量', name: 'DetailReamrk', width: 150, align: 'left', editable: true };
  181. cols.push(collast);
  182. var collast = { label: '备注', name: 'DetailReamrk2', width: 150, align: 'left', editable: true };
  183. cols.push(collast);
  184. if (data != null && data.length > 0) {
  185. DateList = data;
  186. for (var i = 0; i < data.length; i++) {
  187. var ColName = data[i].ColName;
  188. var ColCode = data[i].ColCode;
  189. if (ColName!="批次") {
  190. var obj = new Array();
  191. obj = {
  192. label: ColName,
  193. name: ColCode,
  194. width: 80,
  195. align: "left"
  196. }
  197. cols.push(obj);
  198. }
  199. }
  200. }
  201. _Clos = cols;
  202. }
  203. });
  204. }
  205. function reloadData() {
  206. //document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> <div id="gridPager"></div>';//重置grid
  207. $("#gridList").dataGrid({
  208. url: "/WMS/ProductionIssue/GetICSReturnTemporary?rfqno=" + $("#txtApplyNegCode").val() + "&" + Math.random(),
  209. //postData: { rfqno: $("#RFQNO").val() },
  210. height: $(window).height() - 300,
  211. width: $(window).width(),
  212. cellEdit: true,
  213. colModel: _Clos,
  214. cellsubmit: "clientArray",
  215. width: "100%",
  216. //autowidth: true,
  217. rownumbers: true,
  218. viewrecords: true,
  219. ondblClickRow: function (rowid, cellname, value) {
  220. var colModel = $("#gridList").jqGrid("getGridParam", "colModel");
  221. var cellIndex = $("#gridList").jqGrid("getGridParam", "iCol");
  222. var cellname = colModel[cellIndex].name;
  223. if (cellname == "InvCode") {
  224. //$.modalOpen({
  225. // id: "InvCodeSelect",
  226. // title: "选择物料信息",
  227. // url: "/DHAY/ICSAccessoriesMOApply/GetInvCode",
  228. // width: "50%",
  229. // height: "50%",
  230. // callBack: function (iframeId) {
  231. // debugger;
  232. // var obj = top.frames[iframeId].submitForm();
  233. // $("#gridList").jqGrid('setCell', rowid, 'InvCode', obj.INVCODE, 'review-' + rowid);
  234. // $("#gridList").jqGrid('setCell', rowid, 'INVNAME', obj.INVNAME, 'review-' + rowid);
  235. // $("#gridList").jqGrid('setCell', rowid, 'InvStd', obj.InvStd, 'review-' + rowid);
  236. // $("#gridList").jqGrid('setCell', rowid, 'KQuantity', obj.Quantity, 'review-' + rowid);
  237. // $("#gridList").jqGrid('setCell', rowid, 'InvUnit', obj.InvUnit, 'review-' + rowid);
  238. // $("#gridList").jqGrid("saveCell", rowid, 1);
  239. // $("#gridList").jqGrid("saveCell", rowid, 2);
  240. // $("#gridList").jqGrid("saveCell", rowid, 3);
  241. // $("#gridList").jqGrid("saveCell", rowid, 4);
  242. // $("#gridList").jqGrid("saveCell", rowid, 5);
  243. // $("#gridList").jqGrid("saveCell", rowid, 6);
  244. // $("#gridList").jqGrid("saveCell", rowid, 7);
  245. // $("#gridList").jqGrid("saveCell", rowid, 8);
  246. // $("#gridList").jqGrid("saveCell", rowid, 9);
  247. // top.frames[iframeId].Close();
  248. // }
  249. //});
  250. } else if (cellname == "WHCodeName") {
  251. $.modalOpen({
  252. id: "GetWHCode",
  253. title: "选择仓库",
  254. url: "/DHAY/ICSCustomerSuppliedReturn/GetWHCode",
  255. width: "50%",
  256. height: "50%",
  257. callBack: function (iframeId) {
  258. debugger;
  259. var obj = top.frames[iframeId].submitForm();
  260. $("#gridList").jqGrid('setCell', rowid, 'WHCode', obj.WarehouseCode, 'review-' + rowid);
  261. $("#gridList").jqGrid('setCell', rowid, 'WHCodeName', obj.WarehouseName, 'review-' + rowid);
  262. $("#gridList").jqGrid("saveCell", rowid, 1);
  263. $("#gridList").jqGrid("saveCell", rowid, 2);
  264. $("#gridList").jqGrid("saveCell", rowid, 3);
  265. $("#gridList").jqGrid("saveCell", rowid, 4);
  266. $("#gridList").jqGrid("saveCell", rowid, 5);
  267. $("#gridList").jqGrid("saveCell", rowid, 6);
  268. $("#gridList").jqGrid("saveCell", rowid, 7);
  269. $("#gridList").jqGrid("saveCell", rowid, 8);
  270. $("#gridList").jqGrid("saveCell", rowid, 9);
  271. top.frames[iframeId].Close();
  272. }
  273. });
  274. } else if (cellname == "Batch") {
  275. var invCode = $("#gridList").jqGrid("getRowData", rowid).InvCode;
  276. $.modalOpen({
  277. id: "InvCodeSelect",
  278. title: "选择批次信息",
  279. url: "/DHAY/ICSSDN/GetBatch?InvCode=" + invCode,
  280. width: "50%",
  281. height: "50%",
  282. callBack: function (iframeId) {
  283. debugger;
  284. var obj = top.frames[iframeId].submitForm();
  285. $("#gridList").jqGrid('setCell', rowid, 'Batch', obj.BatchCode, 'review-' + rowid);
  286. $("#gridList").jqGrid("saveCell", rowid, 1);
  287. $("#gridList").jqGrid("saveCell", rowid, 2);
  288. $("#gridList").jqGrid("saveCell", rowid, 3);
  289. $("#gridList").jqGrid("saveCell", rowid, 4);
  290. $("#gridList").jqGrid("saveCell", rowid, 5);
  291. $("#gridList").jqGrid("saveCell", rowid, 6);
  292. $("#gridList").jqGrid("saveCell", rowid, 7);
  293. $("#gridList").jqGrid("saveCell", rowid, 8);
  294. $("#gridList").jqGrid("saveCell", rowid, 9);
  295. top.frames[iframeId].Close();
  296. }
  297. });
  298. }
  299. }, afterSaveCell: function (rowid, celname, value, iRow, iCol) {// var datatime = '';
  300. debugger;
  301. if (celname == "InvCode") {
  302. //清空内容
  303. $.ajax({
  304. url: "/DHAY/ICSAccessoriesMOApply/GetItemListInv?InvCode=" + value ,
  305. //data: { keyValue: keyValue },
  306. dataType: "json",
  307. async: false,
  308. success: function (data) {
  309. debugger;
  310. if (data.rows.length > 0) {
  311. $("#gridList").jqGrid('setCell', rowid, 'InvCode', data.rows[0].INVCODE, 'review-' + rowid);
  312. $("#gridList").jqGrid('setCell', rowid, 'INVNAME', data.rows[0].INVNAME, 'review-' + rowid);
  313. $("#gridList").jqGrid('setCell', rowid, 'InvStd', data.rows[0].InvStd, 'review-' + rowid);
  314. $("#gridList").jqGrid('setCell', rowid, 'KQuantity', data.rows[0].Quantity, 'review-' + rowid);
  315. $("#gridList").jqGrid('setCell', rowid, 'InvUnit', data.rows[0].InvUnit, 'review-' + rowid);
  316. }
  317. else {
  318. $("#gridList").jqGrid('setCell', rowid, 'InvCode', null, 'review-' + rowid);
  319. $("#gridList").jqGrid('setCell', rowid, 'INVNAME', null, 'review-' + rowid);
  320. $("#gridList").jqGrid('setCell', rowid, 'InvStd', null, 'review-' + rowid);
  321. $("#gridList").jqGrid('setCell', rowid, 'KQuantity', null, 'review-' + rowid);
  322. $("#gridList").jqGrid('setCell', rowid, 'InvUnit', null, 'review-' + rowid);
  323. }
  324. }
  325. });
  326. }
  327. // var aaa = "2999-12-31";
  328. if (celname == "Quantity") {
  329. var YLOTQTY = Number(value);
  330. var AllNumber = Number($("#gridList").jqGrid("getCell", rowid, 'KQuantity'));
  331. if (YLOTQTY > AllNumber)
  332. {
  333. $("#gridList").jqGrid("setCell", rowid, 'Quantity', null);
  334. $.modalAlertNew("WMSAPIInfo507");
  335. return;
  336. }
  337. }
  338. }
  339. });
  340. }
  341. function btnLook(cellvalue, options, rowObject) {
  342. return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">查看</a>";
  343. }
  344. function UpLoadClick(ID) {
  345. $.modalOpen({
  346. id: "selectDeatil",
  347. title: "查看修改物料",
  348. url: "/WMS/ProductionIssue/SeachInventory?ID=" + ID + "&" + Math.random(),
  349. width: "1000px",
  350. height: "1000px",
  351. callBack: function (iframeId) {
  352. var obj = top.frames[iframeId].submitForm();
  353. var rowData = $("#gridList").jqGrid('getRowData', ID);
  354. rowData.TLZID = obj.TLZID,
  355. rowData.ZJID = obj.ZJID,
  356. rowData.InvCode = obj.InvCode,
  357. rowData.InvName = obj.InvName,
  358. rowData.InvStd = obj.InvStd,
  359. rowData.InvUnit = obj.InvUnit,
  360. rowData.Quantity = obj.Quantity,
  361. rowData.IssueNegQuantity = obj.IssueQuantity,
  362. rowData.Amount = obj.Amount,
  363. rowData.ExtensionID = obj.ExtensionID,
  364. rowData.ProjectCode = obj.ProjectCode,
  365. rowData.BatchCode = obj.BatchCode,
  366. rowData.Version = obj.Version,
  367. rowData.Brand = obj.Brand,
  368. rowData.cFree1 = obj.cFree1,
  369. rowData.cFree2 = obj.cFree2,
  370. rowData.cFree3 = obj.cFree3,
  371. rowData.cFree4 = obj.cFree4,
  372. rowData.cFree5 = obj.cFree5,
  373. rowData.cFree6 = obj.cFree6,
  374. rowData.cFree7 = obj.cFree7,
  375. rowData.cFree8 = obj.cFree8,
  376. rowData.cFree9 = obj.cFree9,
  377. rowData.cFree10 = obj.cFree10
  378. $("#gridList").jqGrid('setRowData', ID, rowData);
  379. $(".unwritten").hide();
  380. top.frames[iframeId].Close();
  381. }
  382. });
  383. }
  384. function guid() {
  385. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  386. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  387. return v.toString(16);
  388. });
  389. }
  390. //最后一行新增数据
  391. function AddRowToLast() {
  392. var obj = {
  393. ID: guid(),
  394. WHCode: ""
  395. };
  396. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  397. $(".unwritten").hide();
  398. }
  399. function DeleteRowToLast() {
  400. debugger;
  401. var rowid = $("#gridList").jqGridRowValue().ID
  402. $("#gridList").delRowData(rowid);
  403. }
  404. //获取U9单据类型
  405. function InitControl() {
  406. var $CodeType = $("#sel_CodeType");
  407. $CodeType.select2({
  408. allowClear: true,
  409. escapeMarkup: function (m) {
  410. return m;
  411. }
  412. });
  413. $.ajax({
  414. url: "/DHAY/ICSAccessoriesMOApply/GetU9CodeType?type=杂发"+"&" + Math.random(),
  415. dataType: "json",
  416. async: false,
  417. success: function (data) {
  418. $CodeType.append("<option value=''></option>");
  419. $.each(data, function (index, item) {
  420. $CodeType.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  421. });
  422. }
  423. });
  424. }
  425. //东辉特有获取U9单据类型
  426. function InitControl6() {
  427. var $CodeType = $("#sel_CodeType");
  428. $CodeType.select2({
  429. allowClear: true,
  430. escapeMarkup: function (m) {
  431. return m;
  432. }
  433. });
  434. $.ajax({
  435. url: "/DHAY/ICSAccessoriesMOApply/GetFLDocType?Code=MOApplyCode" + "&" + Math.random(),
  436. dataType: "json",
  437. async: false,
  438. success: function (data) {
  439. $CodeType.append("<option value=''></option>");
  440. $.each(data, function (index, item) {
  441. $CodeType.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  442. });
  443. }
  444. });
  445. }
  446. //获取U9部门
  447. function InitContro2() {
  448. var $Dept = $("#sel_Dept");
  449. $Dept.select2({
  450. allowClear: true,
  451. escapeMarkup: function (m) {
  452. return m;
  453. }
  454. });
  455. $.ajax({
  456. url: "/DHAY/ICSAccessoriesMOApply/GetU9CodeType?type=部门" + "&" + Math.random(),
  457. dataType: "json",
  458. async: false,
  459. success: function (data) {
  460. $Dept.append("<option value=''></option>");
  461. $.each(data, function (index, item) {
  462. $Dept.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  463. });
  464. }
  465. });
  466. }
  467. //获取U9客户
  468. function InitContro3() {
  469. var $Custmer = $("#sel_Custmer");
  470. $Custmer.select2({
  471. allowClear: true,
  472. escapeMarkup: function (m) {
  473. return m;
  474. }
  475. });
  476. $.ajax({
  477. url: "/DHAY/ICSAccessoriesMOApply/GetU9CodeType?type=客户" + "&" + Math.random(),
  478. dataType: "json",
  479. async: false,
  480. success: function (data) {
  481. $Custmer.append("<option value=''></option>");
  482. $.each(data, function (index, item) {
  483. $Custmer.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  484. });
  485. }
  486. });
  487. }
  488. //获取U9项目
  489. function InitContro4() {
  490. var $Project = $("#sel_SYproject");
  491. $Project.select2({
  492. allowClear: true,
  493. escapeMarkup: function (m) {
  494. return m;
  495. }
  496. });
  497. $.ajax({
  498. url: "/DHAY/ICSAccessoriesMOApply/GetU9CodeType?type=项目" + "&" + Math.random(),
  499. dataType: "json",
  500. async: false,
  501. success: function (data) {
  502. $Project.append("<option value=''></option>");
  503. $.each(data, function (index, item) {
  504. $Project.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  505. });
  506. }
  507. });
  508. }
  509. //获取领用部门
  510. function InitContro5() {
  511. var $Dept = $("#sel_LYDept");
  512. $Dept.select2({
  513. allowClear: true,
  514. escapeMarkup: function (m) {
  515. return m;
  516. }
  517. });
  518. $.ajax({
  519. url: "/DHAY/ICSAccessoriesMOApply/GetLYDep?" + Math.random(),
  520. dataType: "json",
  521. async: false,
  522. success: function (data) {
  523. $Dept.append("<option value=''></option>");
  524. $.each(data, function (index, item) {
  525. $Dept.append("<option value='" + item.Code + "'>" + item.Name + "</option>");
  526. });
  527. }
  528. });
  529. }
  530. function ClearTemp() {
  531. $.ajax({
  532. url: "/WMS/ProductionIssue/ClearTemp?" + Math.random(),
  533. datatype: "json",
  534. async: false
  535. })
  536. }
  537. //查询单据必填项
  538. function DocRequired(Dept, CodeType) {
  539. $.ajax({
  540. url: "/DHAY/ICSAccessoriesMOApply/GetCodeInformation?Dept=" + Dept + "&CodeType=" + CodeType + "&" + Math.random(),
  541. dataType: "json",
  542. async: false,
  543. success: function (data) {
  544. debugger;
  545. if (data.Code != '') {
  546. var items = data.Code[0].F_Define2.split('|');
  547. items.forEach(value => {
  548. var inputElement = document.getElementById(value);
  549. if (inputElement) {
  550. // 如果元素存在,清除样式
  551. inputElement.setAttribute('required', 'required');
  552. } else {
  553. console.warn('找不到ID为', value, '的input元素');
  554. }
  555. });
  556. }
  557. }
  558. });
  559. }
  560. //清除单据必填项
  561. function DocRequiredClear() {
  562. $.ajax({
  563. url: "/DHAY/ICSAccessoriesMOApply/GetCodeInformation?" + Math.random(),
  564. dataType: "json",
  565. async: false,
  566. success: function (data) {
  567. debugger;
  568. if (data.Code != '') {
  569. for (var i = 0; i < data.Code.length; i++)
  570. {
  571. var items = data.Code[i].F_Define2.split('|');
  572. items.forEach(value => {
  573. var inputElement = document.getElementById(value);
  574. if (inputElement) {
  575. // 如果元素存在,(清除required属性)
  576. inputElement.removeAttribute('required');
  577. clears.append(value);
  578. } else {
  579. console.warn('找不到ID为', value, '的input元素');
  580. }
  581. });
  582. }
  583. }
  584. }
  585. });
  586. }
  587. //查询用户受益部门信息
  588. function GetUserDept() {
  589. debugger;
  590. $.ajax({
  591. url: "/DHAY/ICSAccessoriesMOApply/GetUserDept?" + Math.random(),
  592. dataType: "json",
  593. async: false,
  594. success: function (data) {
  595. debugger;
  596. if (data.Code != '') {
  597. var item = data.Code[0].F_Define1;
  598. if (item != '') {
  599. $("#sel_Dept").val(item).trigger("change");
  600. }
  601. }
  602. }
  603. });
  604. }
  605. ////清除单据必填项
  606. //function DocRequiredClear(Dept, CodeType) {
  607. // if (clears.length > 0) {
  608. // clears.forEach(value => {
  609. // var inputElement = document.getElementById(value);
  610. // if (inputElement) {
  611. // // 如果元素存在,(清除required属性)
  612. // inputElement.removeAttribute('required');
  613. // clears.append(value);
  614. // } else {
  615. // console.warn('找不到ID为', value, '的input元素');
  616. // }
  617. // });
  618. // clears.length = 0;
  619. // }
  620. //}
  621. function submitForm() {
  622. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
  623. debugger;
  624. if (!$('#form1').formValid()) {
  625. return false;
  626. }
  627. debugger;
  628. var SYprojectCode = '';
  629. var SYprojectName = '';
  630. var CodeType = $("#sel_CodeType").val();//单据类型
  631. var CodeTypeName = $("#sel_CodeType option:selected").text();//单据类型名称
  632. var Dept = $("#sel_Dept").val();//部门
  633. var DeptName = $("#sel_Dept option:selected").text();//部门
  634. var LYDept = $("#sel_LYDept").val();//部门
  635. var LYDeptName = $("#sel_LYDept option:selected").text();//部门
  636. var ApplyNegCode = $("#txtApplyNegCode").val();//在建项目
  637. var ApplyNegName = $("#txtApplyNegCode option:selected").text();//在建项目
  638. var Custmer = $("#txt_CustomerCode").val().trim();//客户
  639. var CustmerName = $("#txt_CustomerName").val().trim();//客户名称
  640. var Remarks = $("#Remarks").val();//备注
  641. var Remarks2 = $("#Remarks2").val();//备注
  642. var Remarks3 = $("#Remarks3").val();//备注
  643. var Code = $("#Code").val();//单据号
  644. var MTIME = $("#txtMTIME").val();//单据号
  645. //var SYproject = $("#sel_SYproject").val();//受益项目
  646. //var SYprojectName = $("#sel_SYproject").text();//受益项目
  647. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  648. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  649. var IDlist = "";
  650. var Details = [];
  651. SelPerson = "#SelBR_"
  652. var obj_vendor = $("#gridList");
  653. var rowIds_vendor = obj_vendor.getDataIDs();
  654. if ((Custmer == "" || Custmer == null) && (CustmerName != "" && CustmerName!=null))
  655. {
  656. $.modalAlertNew("WMS00127");
  657. return;
  658. }
  659. var arrayData_vendor = new Array();
  660. if (rowIds_vendor.length > 0) {
  661. for (var i = 0; i < rowIds_vendor.length; i++) {
  662. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  663. debugger;
  664. if (vendorRowData.Quantity == "" || vendorRowData.Quantity == 'undefined') {
  665. $.modalAlertNew("WMS00089");
  666. return;
  667. }
  668. //if (SYproject == "" || SYproject == 'undefined') {
  669. // $.modalAlertNew("WMS000100");
  670. // return;
  671. //}
  672. for (var s = 0; s < _LW.length; s++) {
  673. SYprojectName = _LW[s].Name;
  674. if (SYprojectName == vendorRowData.SYproject) {
  675. SYprojectCode = _LW[s].Code;
  676. }
  677. }
  678. /* var WHCode = $("" + SelPerson + "" + vendorRowData.ID + "").val();*/
  679. var obj = {
  680. ID: vendorRowData.ID,
  681. Sequence: i + 1,
  682. InvCode: vendorRowData.InvCode,
  683. Quantity: vendorRowData.Quantity,
  684. WHCode: vendorRowData.WHCode,
  685. SourceCode: vendorRowData.SourceCode,
  686. DetailReamrk: vendorRowData.DetailReamrk,
  687. DetailReamrk2: vendorRowData.DetailReamrk2,
  688. SYproject: SYprojectCode,
  689. SYprojectName: SYprojectName,
  690. Batch: vendorRowData.Batch
  691. };
  692. Details.push(obj);
  693. }
  694. var ICSASNs = {
  695. Dept: Dept,
  696. DeptName: DeptName,
  697. LYDept: LYDept,
  698. LYDeptName: LYDeptName,
  699. CodeType: CodeType,
  700. CodeTypeName: CodeTypeName,
  701. ApplyNegCode: ApplyNegCode,
  702. ApplyNegName: ApplyNegName,
  703. Custmer: Custmer,
  704. CustmerName: CustmerName,
  705. Remarks: Remarks,
  706. Remarks2: Remarks2,
  707. Remarks3: Remarks3,
  708. Code: Code,
  709. MTIME: MTIME,
  710. User: RoleEnCode,
  711. Detail: Details,
  712. }
  713. var ICSASN = [];
  714. ICSASN.push(ICSASNs);
  715. $.submitForm({
  716. url: "/DHAY/ICSAccessoriesMOApply/SaveICSMOApply?" + Math.random(),
  717. param: { ICSASN: JSON.stringify(ICSASN) },
  718. success: function () {
  719. $.currentWindow().$("#gridList").trigger("reloadGrid");
  720. }
  721. })
  722. }
  723. }
  724. function GetSelectPerson(ID, WHCode) {
  725. debugger;
  726. var str = "";
  727. $.ajax({
  728. url: "/DHAY/ICSCustomerSuppliedReturn/Select_ICSWHCode",
  729. dataType: "json",
  730. async: false,
  731. async: false,
  732. success: function (data) {
  733. if (data != null && data.length > 0) {
  734. $("#SelBR_" + ID + "").find("option").remove();
  735. for (var i = 0; i < data.length; i++) {
  736. $("#SelBR_" + ID + "").append("<option value='" + data[i].WarehouseCode + "'>" + data[i].WarehouseName + "</option>");
  737. }
  738. }
  739. }
  740. });
  741. }
  742. //$("#txt_CustomerCode").on("keypress", function (e) {
  743. // if (e.which === 13) { // 回车键(Enter)的键码是13
  744. // searchCustomer();
  745. // }
  746. //});
  747. // 查询客户信息
  748. function searchCustomer() {
  749. const code = $("#txt_CustomerName").val().trim();
  750. // 模拟AJAX请求 (实际项目中替换为真实API)
  751. $.ajax({
  752. url: "/DHAY/ICSAccessoriesMOApply/GetCustomer?Code=" + code,
  753. method: "GET",
  754. dataType: "json",
  755. success: function (data) {
  756. debugger;
  757. // 假设响应格式: { success: true, data: { name: "客户名称" } }
  758. if (data.length > 0) {
  759. // 回填客户名称到输入框
  760. $("#txt_CustomerName").val(data[0].Name);
  761. $("#txt_CustomerCode").val(code);
  762. // 如果需要保存客户ID等其他信息,可以使用隐藏字段
  763. // $("#customerId").val(response.data.id);
  764. } else {
  765. $("#txt_CustomerName").val("");
  766. $.modalAlertNew("WMSAPIInfo478");
  767. return;
  768. }
  769. }
  770. });
  771. }
  772. </script>
  773. <form id="form1">
  774. <div class="topPanel" style="height:10px">
  775. <div class="btn-group">
  776. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  777. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  778. </div>
  779. </div>
  780. <div style="margin-right: 20px;">
  781. <table class="form">
  782. <thead>主表信息</thead>
  783. <tr>
  784. <th class="formTitle">单据类型:</th>
  785. <td class="formValue">
  786. <select id="sel_CodeType" name="sel_CodeType" class="form-control select2 required" style="width: 230px" placeholder="请选择单据类型..."></select>
  787. <input type="hidden" id="hidetext" />
  788. </td>
  789. <th class="formTitle">单号:</th>
  790. <td class="formValue">
  791. <input id="Code" type="text" readonly="readonly" class="form-control required" />
  792. </td>
  793. </tr>
  794. <tr>
  795. <th class="formTitle">受益部门:</th>
  796. <td class="formValue">
  797. <select id="sel_Dept" name="sel_Dept" class="form-control select2 required" style="width: 230px" placeholder="请选择受益部门..."></select>
  798. <input type="hidden" id="sel_Dept" />
  799. </td>
  800. @*<th class="formTitle">受益项目:</th>
  801. <td class="formValue">
  802. <select id="sel_SYproject" name="sel_SYproject" class="form-control select2 required" style="width: 230px" placeholder="请选择受益项目..."></select>
  803. <input type="hidden" id="hidetext" />
  804. </td>*@
  805. <th class="formTitle">在建工程项目:</th>
  806. <td class="formValue">
  807. <input type="text" id="txtApplyNegCode" class="form-control" />
  808. </td>
  809. </tr>
  810. <tr>
  811. @*<th class="formTitle">客户:</th>
  812. <td class="formValue">
  813. <select id="sel_Custmer" name="sel_Custmer" class="form-control select2" style="width: 230px" placeholder="请选择客户..."></select>
  814. <input type="hidden" id="hidetext" />
  815. </td>*@
  816. <th class="formTitle">客户:</th>
  817. <td class="formValue">
  818. <div class="input-group" style="width: 100%" >
  819. <input type="text" id="txt_CustomerName" name="txt_CustomerName"
  820. class="form-control" style="width: 99%"
  821. placeholder="输入客户编码查询...">
  822. <input type="hidden" id="txt_CustomerCode" name="txt_CustomerCode"
  823. class="form-control" style="width: 1%"
  824. placeholder="输入客户编码查询..." >
  825. </div>
  826. <input type="hidden" id="hidetext" />
  827. </td>
  828. <th class="formTitle">RD编号:</th>
  829. <td class="formValue">
  830. <input type="text" id="Remarks" class="form-control" />
  831. </td>
  832. </tr>
  833. <tr>
  834. <th class="formTitle">项目编号:</th>
  835. <td class="formValue">
  836. <input type="text" id="Remarks2" class="form-control" />
  837. </td>
  838. <th class="formTitle">领用部门:</th>
  839. <td class="formValue">
  840. <select id="sel_LYDept" name="sel_LYDept" class="form-control select2 " style="width: 230px" placeholder="请选择领用部门..."></select>
  841. <input type="hidden" id="hidetext" />
  842. </td>
  843. </tr>
  844. <tr>
  845. <th class="formTitle">维护人:</th>
  846. <td class="formValue">
  847. <input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
  848. </td>
  849. <th class="formTitle">维护时间:</th>
  850. <td class="formValue">
  851. <input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
  852. </td>
  853. </tr>
  854. <tr>
  855. <th class="formTitle">备注:</th>
  856. <td class="formValue">
  857. <input type="text" id="Remarks3" class="form-control" />
  858. </td>
  859. </tr>
  860. </table>
  861. </div>
  862. <div class="gridPanel" id="gridPanel" style="margin-left:10px">
  863. <span><strong>子表信息</strong></span>
  864. <table id="gridList"></table>
  865. <div style="text-align:center">
  866. <button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
  867. <button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
  868. </div>
  869. </div>
  870. </form>