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.

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