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.

524 lines
21 KiB

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