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.

369 lines
15 KiB

  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Index.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. var OApplyNegCode = $.request("OApplyNegCode");
  22. var WHCode = $.request("WHCode");
  23. $(function () {
  24. SetCols();
  25. InitControl();
  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. $("#txtApplyNegCode").val(OApplyNegCode);
  32. $("#sel_WHCode").val([WHCode]).trigger("change");
  33. ClearTemp();
  34. reloadData();
  35. })
  36. function SetCols() {
  37. $.ajax({
  38. url: "/Print/SelectColumnName?" + Math.random(),
  39. dataType: "json",
  40. async: false,
  41. success: function (data) {
  42. var cols = new Array();
  43. var collast = { label: '主键', name: 'ID', width: 150, align: 'left', hidden: true, key: true };
  44. cols.push(collast);
  45. var collast = { label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true };
  46. cols.push(collast);
  47. var collast = {
  48. label: '查看', width: 100, align: 'left',
  49. formatter: btnLook
  50. };
  51. cols.push(collast);
  52. var collast = { label: '退料子ID', name: 'TLZID', width: 150, align: 'left', hidden: true };
  53. cols.push(collast);
  54. var collast = { label: '退料单号', name: 'OApplyNegCode', width: 150, align: 'left' };
  55. cols.push(collast);
  56. var collast = { label: '料品编码', name: 'InvCode', width: 100, align: 'left' };
  57. cols.push(collast);
  58. var collast = { label: '料品名称', name: 'InvName', width: 100, align: 'left' };
  59. cols.push(collast);
  60. var collast = { label: '规格型号', name: 'InvStd', width: 100, align: 'left' };
  61. cols.push(collast);
  62. var collast = { label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } };
  63. cols.push(collast);
  64. var collast = { label: '辅计量数量', name: 'Amount', width: 150, align: 'left' };
  65. cols.push(collast);
  66. var collast = { label: '自由项ID', name: 'ExtensionID', hidden: true };
  67. cols.push(collast);
  68. var collast = { label: '单位', name: 'InvUnit', width: 100, align: 'left' };
  69. cols.push(collast);
  70. var collast = { label: '已发数量', name: 'IssueNegQuantity', width: 100, align: 'left' };
  71. cols.push(collast);
  72. var collast = { label: '已退数量', name: 'tuinum', width: 100, align: 'left' };
  73. cols.push(collast);
  74. var collast = { label: '子件ID', name: 'ZJID', width: 100, align: 'left' };
  75. cols.push(collast);
  76. if (data != null && data.length > 0) {
  77. DateList = data;
  78. for (var i = 0; i < data.length; i++) {
  79. var ColName = data[i].ColName;
  80. var ColCode = data[i].ColCode;
  81. var obj = new Array();
  82. obj = {
  83. label: ColName,
  84. name: ColCode,
  85. width: 80,
  86. align: "left"
  87. }
  88. cols.push(obj);
  89. }
  90. }
  91. _Clos = cols;
  92. }
  93. });
  94. }
  95. function reloadData() {
  96. $("#gridList").dataGrid({
  97. url: "/WMS/WWMaterialsDeliveredRTM/GetICSMOApplyNegDetailTemp?OApplyNegCode=" + $("#txtApplyNegCode").val() + "&" + Math.random(),
  98. //postData: { rfqno: $("#RFQNO").val() },
  99. height: $(window).height() - 200,
  100. width: $(window).width(),
  101. cellEdit: true,
  102. colModel: _Clos,
  103. // colModel: [
  104. //{ label: '主键', name: 'ID', width: 150, align: 'left' ,hidden: true, key: true },
  105. //{ label: 'ID', name: 'ID', width: 150, align: 'left', hidden: true },
  106. // {
  107. // label: '查看', width: 100, align: 'left',
  108. // formatter: btnLook
  109. // },
  110. //{ label: '退料子ID', name: 'TLZID', width: 150, align: 'left', hidden: true },
  111. //{ label: '退料单号', name: 'OApplyNegCode', width: 150, align: 'left' },
  112. //{ label: '料品编码', name: 'InvCode', width: 100, align: 'left' },
  113. //{ label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  114. //{ label: '规格型号', name: 'InvStd', width: 100, align: 'left' },
  115. //{ label: '数量', name: 'Quantity', width: 100, align: 'left', editable: true, editrules: { number: true } },
  116. //{ label: '辅计量数量', name: 'Amount', width: 150, align: 'left' },
  117. //{ label: '自由项ID', name: 'ExtensionID', hidden: true },
  118. //{ label: '单位', name: 'InvUnit', width: 100, align: 'left' },
  119. //{ label: '已发数量', name: 'IssueNegQuantity', width: 100, align: 'left' },
  120. //{ label: '已退数量', name: 'tuinum', width: 100, align: 'left' },
  121. //{ label: '子件ID', name: 'ZJID', width: 100, align: 'left' },
  122. // ],
  123. cellsubmit: "clientArray",
  124. width: "100%",
  125. autowidth: true,
  126. rownumbers: true,
  127. viewrecords: true,
  128. });
  129. }
  130. function btnLook(cellvalue, options, rowObject) {
  131. return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"UpLoadClick('" + rowObject.ID + "','" + rowObject.TLZID + "')\">查看</a>";
  132. }
  133. function UpLoadClick(ID,TLZID) {
  134. debugger;
  135. $.modalOpen({
  136. id: "selectDeatil",
  137. title: "查看修改物料",
  138. url: "/WMS/WWMaterialsDeliveredRTM/WWSeachMDInventory?TLZID=" + TLZID + "&Type=" + 1 + "&TLZID=" + TLZID + "&" + Math.random(),
  139. width: "1000px",
  140. height: "1000px",
  141. callBack: function (iframeId) {
  142. var obj = top.frames[iframeId].submitForm();
  143. var rowData = $("#gridList").jqGrid('getRowData', ID);
  144. rowData.TLZID = obj.TLZID,
  145. rowData.ZJID = obj.ZJID,
  146. rowData.InvCode = obj.InvCode,
  147. rowData.InvName = obj.InvName,
  148. rowData.InvStd = obj.InvStd,
  149. rowData.InvUnit = obj.InvUnit,
  150. rowData.Quantity = obj.Quantity,
  151. rowData.Amount = obj.Amount,
  152. rowData.IssueNegQuantity = obj.IssueQuantity,
  153. rowData.ExtensionID = obj.ExtensionID,
  154. rowData.tuinum = obj.tuinum,
  155. rowData.ProjectCode = obj.ProjectCode,
  156. rowData.BatchCode = obj.BatchCode,
  157. rowData.Version = obj.Version,
  158. rowData.Brand = obj.Brand,
  159. rowData.cFree1 = obj.cFree1,
  160. rowData.cFree2 = obj.cFree2,
  161. rowData.cFree3 = obj.cFree3,
  162. rowData.cFree4 = obj.cFree4,
  163. rowData.cFree5 = obj.cFree5,
  164. rowData.cFree6 = obj.cFree6,
  165. rowData.cFree7 = obj.cFree7,
  166. rowData.cFree8 = obj.cFree8,
  167. rowData.cFree9 = obj.cFree9,
  168. rowData.cFree10 = obj.cFree10
  169. $("#gridList").jqGrid('setRowData', ID, rowData);
  170. $(".unwritten").hide();
  171. top.frames[iframeId].Close();
  172. }
  173. });
  174. }
  175. function guid() {
  176. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  177. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  178. return v.toString(16);
  179. });
  180. }
  181. //最后一行新增数据
  182. function AddRowToLast() {
  183. var obj = {
  184. ID: guid(),
  185. };
  186. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  187. $(".unwritten").hide();
  188. }
  189. function DeleteRowToLast() {
  190. debugger;
  191. var rowid = $("#gridList").jqGridRowValue().ID
  192. $("#gridList").delRowData(rowid);
  193. }
  194. function InitControl() {
  195. var $VenCode = $("#sel_WHCode");
  196. $VenCode.select2({
  197. allowClear: true,
  198. escapeMarkup: function (m) {
  199. return m;
  200. }
  201. });
  202. $.ajax({
  203. url: "/WMS/ProductionIssue/GetWHCode" + "?" + Math.random(),
  204. dataType: "json",
  205. async: false,
  206. success: function (data) {
  207. $.each(data, function (index, item) {
  208. $VenCode.append("<option value='" + item.WarehouseCode + "'>&nbsp;" + item.WarehouseName + "</option>");
  209. });
  210. }
  211. });
  212. }
  213. function ClearTemp() {
  214. $.ajax({
  215. url: "/WMS/WWMaterialsDeliveredRTM/ClearTemp?" + Math.random(),
  216. datatype: "json",
  217. async: false
  218. })
  219. }
  220. function submitForm() {
  221. var WHCode = $("#sel_WHCode").val();
  222. if (WHCode == "") {
  223. $.modalAlertNew("WMS00041");
  224. return;
  225. }
  226. debugger;
  227. var IDlist = "";
  228. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  229. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  230. var myDate = new Date();
  231. var year = myDate.getFullYear(); //获取当前年
  232. var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
  233. var dates = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
  234. var hours = myDate.getHours() + 1 < 10 ? "0" + myDate.getHours() : myDate.getHours(); //获取当前小时
  235. var minutes = myDate.getMinutes() + 1 < 10 ? "0" + myDate.getMinutes() : myDate.getMinutes(); //获取当前分钟
  236. var seconds = myDate.getSeconds() + 1 < 10 ? "0" + myDate.getSeconds() : myDate.getSeconds(); //获取当前秒
  237. var date = year + "-" + mon + "-" + dates + ' ' + hours + ':' + minutes + ':' + seconds;
  238. var Details = [];
  239. var obj_vendor = $("#gridList");
  240. var rowIds_vendor = obj_vendor.getDataIDs();
  241. var arrayData_vendor = new Array();
  242. if (rowIds_vendor.length > 0) {
  243. for (var i = 0; i < rowIds_vendor.length; i++) {
  244. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  245. if (vendorRowData.Quantity == '0' || vendorRowData.Quantity == 0) {
  246. $.modalAlertNew("WMS00089");
  247. return;
  248. }
  249. var Code = vendorRowData.InvCode;
  250. var Quantity = Number(vendorRowData.Quantity);
  251. var IssueNegQuantity = Number(vendorRowData.IssueNegQuantity);
  252. var tuinum = Number(vendorRowData.tuinum);
  253. //if (IssueNegQuantity - tuinum <= 0) {
  254. // $.modalAlert("料品:'" + Code + "',已发数'" + IssueNegQuantity + "',已全部退货!");
  255. // return;
  256. //}
  257. var obj = {
  258. Sequence: i + 1,
  259. DetailID:vendorRowData.TLZID,
  260. InvCode: vendorRowData.InvCode,
  261. Quantity: vendorRowData.Quantity,
  262. Amount: vendorRowData.Amount,
  263. SourceDetailID: vendorRowData.ZJID,
  264. ExtensionID: vendorRowData.ExtensionID,
  265. };
  266. Details.push(obj);
  267. }
  268. var ICSASNs = {
  269. ID:ID,
  270. WHCode: WHCode,
  271. User: RoleEnCode,
  272. MTIME: date,
  273. WorkPoint: WorkPoint,
  274. Type:'3',
  275. Detail: Details,
  276. }
  277. var ICSASN = [];
  278. ICSASN.push(ICSASNs);
  279. $.submitForm({
  280. url: "/WMS/WWMaterialsDeliveredRTM/UpdateICSMOApplyNeg?" + Math.random(),
  281. param: { ICSASN: JSON.stringify(ICSASN) },
  282. success: function () {
  283. $.currentWindow().$("#gridList").trigger("reloadGrid");
  284. }
  285. })
  286. }
  287. }
  288. </script>
  289. <form id="form1">
  290. <div class="topPanel" style="height:10px">
  291. <div class="btn-group">
  292. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  293. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  294. </div>
  295. </div>
  296. <div style="margin-right: 20px;">
  297. <table class="form">
  298. <thead>主表信息</thead>
  299. <tr>
  300. <th class="formTitle MOPick">委外退料单号:</th>
  301. <td class="formValue MOPick">
  302. <input type="text" id="txtApplyNegCode" class="form-control" />
  303. </td>
  304. <th class="formTitle">仓库编码:</th>
  305. <td class="formValue">
  306. <select id="sel_WHCode" name="sel_WHCode" class="form-control select2" style="width: 230px" placeholder="请选择供应商编码..."></select>
  307. <input type="hidden" id="hidetext" />
  308. </td>
  309. </tr>
  310. <tr>
  311. <th class="formTitle">维护人:</th>
  312. <td class="formValue">
  313. <input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
  314. </td>
  315. <th class="formTitle">维护时间:</th>
  316. <td class="formValue">
  317. <input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
  318. </td>
  319. </tr>
  320. </table>
  321. </div>
  322. <div class="gridPanel" style="margin-left:10px">
  323. <span><strong>子表信息</strong></span>
  324. <table id="gridList"></table>
  325. <div style="text-align:center">
  326. <button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
  327. <button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
  328. </div>
  329. </div>
  330. </form>