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.

562 lines
23 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 SDNCode = $.request("SDNCode");
  33. //定义客户
  34. var Cus = '';
  35. $(function(){
  36. SetCols();
  37. var Muser = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  38. var now = new Date();
  39. var date = now.toLocaleDateString();
  40. InitControl();
  41. InitContro2();
  42. InitContro3();
  43. if (!!SDNCode) {
  44. $.ajax({
  45. url: "/DHAY/ICSSDN/GetICSSDNBySDNCode?SDNCode=" + SDNCode,
  46. //data: { keyValue: keyValue },
  47. dataType: "json",
  48. async: false,
  49. success: function (data) {
  50. debugger;
  51. $("#sel_CodeType").val([data.rows[0].EATTRIBUTE1]).trigger("change");//单据类型
  52. $("#Code").val(data.rows[0].SDNCode);//单号
  53. $("#Remarks").val(data.rows[0].EATTRIBUTE2);//备注
  54. $("#Remarks2").val(data.rows[0].EATTRIBUTE4);//备注
  55. $("#txtMUSER").val(Muser);
  56. $("#txtMTIME").val(date);
  57. }
  58. })
  59. }
  60. reloadData();
  61. })
  62. function SetCols() {
  63. $.ajax({
  64. url: "/Print/SelectColumnName?" + Math.random(),
  65. dataType: "json",
  66. async: false,
  67. success: function (data) {
  68. var cols = new Array();
  69. var collast = { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true };
  70. cols.push(collast);
  71. var collast = { label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true };
  72. cols.push(collast);
  73. var collast = { label: '销售订单编码', name: 'SOCode', width: 100, align: 'left' };
  74. cols.push(collast);
  75. var collast = { label: '项次', name: 'Project', width: 100, align: 'left' };
  76. cols.push(collast);
  77. var collast = { label: '客户订单', name: 'CusDoc', width: 100, align: 'left' };
  78. cols.push(collast);
  79. var collast = { label: '料品编码', name: 'INVCODE', width: 100, align: 'left' };
  80. cols.push(collast);
  81. var collast = { label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } };
  82. cols.push(collast);
  83. var collast = { label: '客户编码', name: 'CusCode', width: 100, align: 'left' };
  84. cols.push(collast);
  85. var collast = { label: '客户名称', name: 'CusName', width: 100, align: 'left' };
  86. cols.push(collast);
  87. var collast = { label: '料品名称', name: 'INVNAME', width: 100, align: 'left' };
  88. cols.push(collast);
  89. //var collast = { label: '规格型号', name: 'InvStd', width: 100, align: 'left' };
  90. // cols.push(collast);
  91. var collast = { label: '仓库编码', name: 'WHCode', width: 100, align: 'left', hidden: true };
  92. cols.push(collast);
  93. var collast = { label: '仓库名称', name: 'WareHouseName', width: 100, align: 'left', editable: true };
  94. cols.push(collast);
  95. var collast = { label: '批号', name: 'Batch', width: 100, align: 'left', editable: true };
  96. cols.push(collast);
  97. var collast = { label: '可用数量', name: 'KQuantity', width: 100, align: 'left', editable: true, hidden: true };
  98. cols.push(collast);
  99. var collast = { label: '订单剩余数量', name: 'SQuantity', width: 100, align: 'left', editable: true, hidden: true };
  100. cols.push(collast);
  101. var collast = { label: '备注1', name: 'DetailReamrk', width: 150, align: 'left', editable: true };
  102. cols.push(collast);
  103. var collast = { label: '备注2', name: 'DetailReamrk2', width: 150, align: 'left', editable: true };
  104. cols.push(collast);
  105. var collast = { label: '行号', name: 'Sequence', width: 100, align: 'left' };
  106. cols.push(collast);
  107. var collast = { label: '销售订行号', name: 'SOSequence', width: 100, align: 'left' };
  108. cols.push(collast);
  109. if (data != null && data.length > 0) {
  110. DateList = data;
  111. for (var i = 0; i < data.length; i++) {
  112. var ColName = data[i].ColName;
  113. var ColCode = data[i].ColCode;
  114. var obj = new Array();
  115. obj = {
  116. label: ColName,
  117. name: ColCode,
  118. width: 80,
  119. align: "left"
  120. }
  121. cols.push(obj);
  122. }
  123. }
  124. _Clos = cols;
  125. }
  126. });
  127. }
  128. function reloadData() {
  129. $("#gridList").dataGrid({
  130. url: "/DHAY/ICSSDN/GetICSReturnTemporary?rfqno=" + $("#Code").val() + "&" + Math.random(),
  131. height: $(window).height() - 200,
  132. width: $(window).width() - 300,
  133. cellEdit: true,
  134. colModel: _Clos,
  135. cellsubmit: "clientArray",
  136. shrinkToFit: false,//宽度自适应
  137. autoWidth: true,
  138. gridComplete: function () {
  139. debugger;
  140. //设置select
  141. //var RowDatas = $("#gridList").jqGrid('getDataIDs');
  142. //for (var j = 0; j < RowDatas.length; j++) {
  143. // var ID = $("#gridList").jqGrid("getCell", RowDatas[j], "ID");
  144. // var WHCode = $("#gridList").jqGrid("getCell", RowDatas[j], "WHCodeHHH");
  145. // GetSelectPerson(ID, WHCode);
  146. //}
  147. },
  148. pager: "#gridPager",
  149. sortorder: "desc",
  150. sortname: 'DNCode ',
  151. rowNum: 10000,
  152. viewrecords: true,
  153. multiselect: true,
  154. subGrid: false, // (1)开启子表格支持
  155. ondblClickRow: function (rowid, cellname, value) {
  156. var colModel = $("#gridList").jqGrid("getGridParam", "colModel");
  157. var cellIndex = $("#gridList").jqGrid("getGridParam", "iCol");
  158. var cellname = colModel[cellIndex].name;
  159. if (cellname == "SOCode") {
  160. $.modalOpen({
  161. id: "InvCodeSelect",
  162. title: "选择销售订单信息",
  163. url: "/DHAY/ICSSDN/GetInvCode?Cus=" + Cus,
  164. width: "80%",
  165. height: "80%",
  166. callBack: function (iframeId) {
  167. var objArr = top.frames[iframeId].submitForm();
  168. for (var j = 0; j < objArr.length; j++) {
  169. //for (var i = 0; i < arrayData.length; i++) {
  170. // if (objArr[j].ID == arrayData[i].ID) {
  171. // $.modalAlert("该子件已添加!请勿重复添加!");
  172. // return;
  173. // }
  174. //}
  175. $("#gridList").jqGrid('addRowData', objArr[j].ID, objArr[j], 'last');
  176. }
  177. top.frames[iframeId].Close();
  178. $("#gridList").delRowData(rowid);
  179. }
  180. });
  181. } else if (cellname == "WareHouseName") {
  182. $.modalOpen({
  183. id: "GetWHCode",
  184. title: "选择仓库",
  185. url: "/DHAY/ICSCustomerSuppliedReturn/GetWHCode",
  186. width: "50%",
  187. height: "50%",
  188. callBack: function (iframeId) {
  189. debugger;
  190. var obj = top.frames[iframeId].submitForm();
  191. $("#gridList").jqGrid('setCell', rowid, 'WHCode', obj.WarehouseCode, 'review-' + rowid);
  192. $("#gridList").jqGrid('setCell', rowid, 'WareHouseName', obj.WarehouseName, 'review-' + rowid);
  193. $("#gridList").jqGrid("saveCell", rowid, 1);
  194. $("#gridList").jqGrid("saveCell", rowid, 2);
  195. $("#gridList").jqGrid("saveCell", rowid, 3);
  196. $("#gridList").jqGrid("saveCell", rowid, 4);
  197. $("#gridList").jqGrid("saveCell", rowid, 5);
  198. $("#gridList").jqGrid("saveCell", rowid, 6);
  199. $("#gridList").jqGrid("saveCell", rowid, 7);
  200. $("#gridList").jqGrid("saveCell", rowid, 8);
  201. $("#gridList").jqGrid("saveCell", rowid, 9);
  202. top.frames[iframeId].Close();
  203. }
  204. });
  205. } else if (cellname == "Batch") {
  206. var invCode = $("#gridList").jqGrid("getRowData", rowid).INVCODE;
  207. $.modalOpen({
  208. id: "InvCodeSelect",
  209. title: "选择批次信息",
  210. url: "/DHAY/ICSSDN/GetBatch?InvCode=" + invCode,
  211. width: "50%",
  212. height: "50%",
  213. callBack: function (iframeId) {
  214. debugger;
  215. var obj = top.frames[iframeId].submitForm();
  216. $("#gridList").jqGrid('setCell', rowid, 'Batch', obj.BatchCode, 'review-' + rowid);
  217. $("#gridList").jqGrid("saveCell", rowid, 1);
  218. $("#gridList").jqGrid("saveCell", rowid, 2);
  219. $("#gridList").jqGrid("saveCell", rowid, 3);
  220. $("#gridList").jqGrid("saveCell", rowid, 4);
  221. $("#gridList").jqGrid("saveCell", rowid, 5);
  222. $("#gridList").jqGrid("saveCell", rowid, 6);
  223. $("#gridList").jqGrid("saveCell", rowid, 7);
  224. $("#gridList").jqGrid("saveCell", rowid, 8);
  225. $("#gridList").jqGrid("saveCell", rowid, 9);
  226. top.frames[iframeId].Close();
  227. }
  228. });
  229. }
  230. },afterSaveCell: function (rowid, celname, value, iRow, iCol) {// var datatime = '';
  231. debugger;
  232. // var aaa = "2999-12-31";
  233. if (celname == "Quantity") {
  234. var YLOTQTY = Number(value);
  235. var AllNumber = Number($("#gridList").jqGrid("getCell", rowid, 'KQuantity'));
  236. var ThisNumber = Number($("#gridList").jqGrid("getCell", rowid, 'Quantity'));
  237. var SNumber = Number($("#gridList").jqGrid("getCell", rowid, 'SQuantity'));
  238. if (YLOTQTY > AllNumber + ThisNumber || YLOTQTY > SNumber + ThisNumber) {
  239. $("#gridList").jqGrid('setCell', rowid, 'Quantity', null);
  240. $.modalAlertNew("WMSAPIInfo507");
  241. return;
  242. }
  243. }
  244. }
  245. /* footerrow: true,//启用底部行(对列汇总时要启用)第一步*/
  246. });
  247. }
  248. function btnLook(cellvalue, options, rowObject) {
  249. return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "')\">查看</a>";
  250. }
  251. function UpLoadClick(ID) {
  252. $.modalOpen({
  253. id: "selectDeatil",
  254. title: "查看修改物料",
  255. url: "/WMS/ProductionIssue/SeachInventory?ID=" + ID + "&" + Math.random(),
  256. width: "1000px",
  257. height: "1000px",
  258. callBack: function (iframeId) {
  259. var obj = top.frames[iframeId].submitForm();
  260. var rowData = $("#gridList").jqGrid('getRowData', ID);
  261. rowData.TLZID=obj.TLZID,
  262. rowData.ZJID= obj.ZJID,
  263. rowData.InvCode= obj.InvCode,
  264. rowData.InvName= obj.InvName,
  265. rowData.InvStd= obj.InvStd,
  266. rowData.InvUnit= obj.InvUnit,
  267. rowData.Quantity= obj.Quantity,
  268. rowData.IssueNegQuantity= obj.IssueQuantity,
  269. rowData.Amount= obj.Amount,
  270. rowData.ExtensionID= obj.ExtensionID,
  271. rowData.ProjectCode= obj.ProjectCode,
  272. rowData.BatchCode= obj.BatchCode,
  273. rowData.Version= obj.Version,
  274. rowData.Brand= obj.Brand,
  275. rowData.cFree1= obj.cFree1,
  276. rowData.cFree2= obj.cFree2,
  277. rowData.cFree3= obj.cFree3,
  278. rowData.cFree4= obj.cFree4,
  279. rowData.cFree5= obj.cFree5,
  280. rowData.cFree6= obj.cFree6,
  281. rowData.cFree7= obj.cFree7,
  282. rowData.cFree8= obj.cFree8,
  283. rowData.cFree9= obj.cFree9,
  284. rowData.cFree10= obj.cFree10
  285. $("#gridList").jqGrid('setRowData', ID, rowData);
  286. $(".unwritten").hide();
  287. top.frames[iframeId].Close();
  288. }
  289. });
  290. }
  291. function guid() {
  292. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  293. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  294. return v.toString(16);
  295. });
  296. }
  297. //最后一行新增数据
  298. function AddRowToLast() {
  299. var obj = {
  300. ID: guid(),
  301. WHCode:""
  302. };
  303. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  304. $(".unwritten").hide();
  305. }
  306. function DeleteRowToLast() {
  307. debugger;
  308. var rowid = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  309. for (var i = rowid.length - 1; i >= 0; i--) {
  310. $("#gridList").delRowData(rowid[i]);
  311. }
  312. if ($("#gridList").jqGrid('getGridParam', 'records') == 0) {
  313. Cus = '';
  314. }
  315. }
  316. //获取U9单据类型
  317. function InitControl() {
  318. var $CodeType = $("#sel_CodeType");
  319. $CodeType.select2({
  320. allowClear: true,
  321. escapeMarkup: function (m) {
  322. return m;
  323. }
  324. });
  325. $.ajax({
  326. url: "/DHAY/ICSAccessoriesMOApply/GetU9CodeType?type=标准出货" + "&" + Math.random(),
  327. dataType: "json",
  328. async: false,
  329. success: function (data) {
  330. $.each(data, function (index, item) {
  331. $CodeType.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  332. });
  333. }
  334. });
  335. }
  336. //获取U9部门
  337. function InitContro2() {
  338. var $Dept = $("#sel_Dept");
  339. $Dept.select2({
  340. allowClear: true,
  341. escapeMarkup: function (m) {
  342. return m;
  343. }
  344. });
  345. $.ajax({
  346. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9Department" + "?" + Math.random(),
  347. dataType: "json",
  348. async: false,
  349. success: function (data) {
  350. $.each(data, function (index, item) {
  351. $Dept.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  352. });
  353. }
  354. });
  355. }
  356. //获取U9客户
  357. function InitContro3() {
  358. var $Custmer = $("#sel_Custmer");
  359. $Custmer.select2({
  360. allowClear: true,
  361. escapeMarkup: function (m) {
  362. return m;
  363. }
  364. });
  365. $.ajax({
  366. url: "/DHAY/ICSCustomerSuppliedReturn/GetU9Customer" + "?" + Math.random(),
  367. dataType: "json",
  368. async: false,
  369. success: function (data) {
  370. $.each(data, function (index, item) {
  371. $Custmer.append("<option value='" + item.Code + "'>&nbsp;" + item.Name + "</option>");
  372. });
  373. }
  374. });
  375. }
  376. function submitForm() {
  377. $("#gridList").find($("td[aria-describedby='gridList_rn']")).click();
  378. debugger;
  379. if (!$('#form1').formValid()) {
  380. return false;
  381. }
  382. var CodeType = $("#sel_CodeType").val();//单据类型
  383. var Dept = $("#sel_Dept").val();//部门
  384. var ApplyNegCode = $("#txtApplyNegCode").val();//在建项目
  385. var Custmer = $("#sel_Custmer").val();//客户
  386. var Remarks = $("#Remarks").val();//备注
  387. var Remarks2 = $("#Remarks2").val();//备注
  388. var Code = $("#Code").val();//单据号
  389. var MTIME = $("#txtMTIME").val();//单据号
  390. var SYproject = $("#txtSYproject").val();//受益项目
  391. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  392. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  393. var IDlist = "";
  394. var Details = [];
  395. SelPerson = "#SelBR_"
  396. var obj_vendor = $("#gridList");
  397. var rowIds_vendor = obj_vendor.getDataIDs();
  398. var arrayData_vendor = new Array();
  399. if (rowIds_vendor.length > 0) {
  400. for (var i = 0; i < rowIds_vendor.length; i++) {
  401. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  402. if (vendorRowData.Quantity == "" || vendorRowData.Quantity == 'undefined'||vendorRowData.Quantity-0 == 0) {
  403. $.modalAlertNew("WMS00089");
  404. return;
  405. }
  406. /* var WHCode = $("" + SelPerson + "" + vendorRowData.ID + "").val();*/
  407. var obj = {
  408. ID: vendorRowData.ID,
  409. Sequence: i + 1,
  410. InvCode: vendorRowData.INVCODE,
  411. Quantity: vendorRowData.Quantity,
  412. WHCode: vendorRowData.WHCode,
  413. DetailReamrk: vendorRowData.DetailReamrk,
  414. DetailReamrk2: vendorRowData.DetailReamrk2,
  415. Batch: vendorRowData.Batch,
  416. CusCode: vendorRowData.CusCode,
  417. CusName: vendorRowData.CusName,
  418. CusDoc: vendorRowData.CusDoc,
  419. ArriveDate: vendorRowData.ArriveDate,
  420. SOCode: vendorRowData.SOCode,
  421. SOSequence: vendorRowData.SOSequence,
  422. Project: vendorRowData.Project
  423. };
  424. Details.push(obj);
  425. }
  426. var ICSASNs = {
  427. CodeType: CodeType,
  428. Remarks: Remarks,
  429. Remarks2: Remarks2,
  430. Code: Code,
  431. MTIME: MTIME,
  432. User: RoleEnCode,
  433. Detail: Details,
  434. }
  435. //var ICSASN = [];
  436. //ICSASN.push(ICSASNs);
  437. $.submitForm({
  438. url: "/DHAY/ICSSDN/UpdateICSSDN?" + Math.random(),
  439. param: { ICSASN: JSON.stringify(ICSASNs) },
  440. success: function () {
  441. $.currentWindow().$("#gridList").trigger("reloadGrid");
  442. }
  443. })
  444. }
  445. }
  446. function GetSelectPerson( ID, WHCode) {
  447. var str = "";
  448. $.ajax({
  449. url: "/DHAY/ICSCustomerSuppliedIn/Select_ICSWHCode?" + Math.random(),
  450. dataType: "json",
  451. async: false,
  452. async: false,
  453. success: function (data) {
  454. if (data != null && data.length > 0) {
  455. $("#SelBR_" + ID + "").find("option").remove();
  456. for (var i = 0; i < data.length; i++) {
  457. $("#SelBR_" + ID + "").append("<option value='" + data[i].WarehouseCode + "'>" + data[i].WarehouseName + "</option>");
  458. }
  459. }
  460. }
  461. });
  462. $("#SelBR_" + ID + "").selectpicker('refresh');
  463. $("#SelBR_" + ID + "").selectpicker('val', WHCode);
  464. }
  465. </script>
  466. <form id="form1">
  467. <div class="topPanel" style="height:10px">
  468. <div class="btn-group">
  469. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  470. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  471. </div>
  472. </div>
  473. <div style="margin-right: 20px;">
  474. <table class="form">
  475. <thead>主表信息</thead>
  476. <tr>
  477. <th class="formTitle">单据类型:</th>
  478. <td class="formValue">
  479. <select id="sel_CodeType" name="sel_CodeType" class="form-control select2 required" style="width: 230px" placeholder="请选择单据类型..."></select>
  480. <input type="hidden" id="hidetext" />
  481. </td>
  482. <th class="formTitle">单号:</th>
  483. <td class="formValue">
  484. <input id="Code" type="text" readonly="readonly" class="form-control required" />
  485. </td>
  486. </tr>
  487. <tr>
  488. <th class="formTitle">快递单号:</th>
  489. <td class="formValue">
  490. <input type="text" id="Remarks" class="form-control" />
  491. </td>
  492. <th class="formTitle">备注2:</th>
  493. <td class="formValue">
  494. <input type="text" id="Remarks2" class="form-control" />
  495. </td>
  496. </tr>
  497. <tr>
  498. <th class="formTitle">维护人:</th>
  499. <td class="formValue">
  500. <input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
  501. </td>
  502. <th class="formTitle">维护时间:</th>
  503. <td class="formValue">
  504. <input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
  505. </td>
  506. </tr>
  507. </table>
  508. </div>
  509. <div class="gridPanel" style="margin-left:10px">
  510. <span><strong>子表信息</strong></span>
  511. <table id="gridList"></table>
  512. <div style="text-align:center">
  513. <button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
  514. <button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
  515. </div>
  516. </div>
  517. </form>