纽威
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.

349 lines
14 KiB

2 years ago
2 years ago
  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. //top.frames[iframeId].submitForm();
  143. //top.frames[iframeId].Close();
  144. //$("#gridList").jqGrid().setGridParam({ datatype: 'json' }, { postData: { rfqno: $("#RFQNO").val() } }).trigger('reloadGrid');
  145. $("#gridList").jqGrid("delRowData", ID)
  146. var obj = top.frames[iframeId].submitForm();
  147. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  148. $(".unwritten").hide();
  149. top.frames[iframeId].Close();
  150. }
  151. });
  152. }
  153. function guid() {
  154. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  155. var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  156. return v.toString(16);
  157. });
  158. }
  159. //最后一行新增数据
  160. function AddRowToLast() {
  161. var obj = {
  162. ID: guid(),
  163. };
  164. $("#gridList").jqGrid('addRowData', obj.ID, obj, 'last');
  165. $(".unwritten").hide();
  166. }
  167. function DeleteRowToLast() {
  168. debugger;
  169. var rowid = $("#gridList").jqGridRowValue().ID
  170. $("#gridList").delRowData(rowid);
  171. }
  172. function InitControl() {
  173. var $VenCode = $("#sel_WHCode");
  174. $VenCode.select2({
  175. allowClear: true,
  176. escapeMarkup: function (m) {
  177. return m;
  178. }
  179. });
  180. $.ajax({
  181. url: "/WMS/ProductionIssue/GetWHCode" + "?" + Math.random(),
  182. dataType: "json",
  183. async: false,
  184. success: function (data) {
  185. $.each(data, function (index, item) {
  186. $VenCode.append("<option value='" + item.WarehouseCode + "'>&nbsp;" + item.WarehouseName + "</option>");
  187. });
  188. }
  189. });
  190. }
  191. function ClearTemp() {
  192. $.ajax({
  193. url: "/WMS/WWMaterialsDeliveredRTM/ClearTemp?" + Math.random(),
  194. datatype: "json",
  195. async: false
  196. })
  197. }
  198. function submitForm() {
  199. var WHCode = $("#sel_WHCode").val();
  200. if (WHCode == "") {
  201. $.modalAlertNew("WMS00041");
  202. return;
  203. }
  204. debugger;
  205. var IDlist = "";
  206. var RoleEnCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  207. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  208. var myDate = new Date();
  209. var year = myDate.getFullYear(); //获取当前年
  210. var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
  211. var dates = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
  212. var hours = myDate.getHours() + 1 < 10 ? "0" + myDate.getHours() : myDate.getHours(); //获取当前小时
  213. var minutes = myDate.getMinutes() + 1 < 10 ? "0" + myDate.getMinutes() : myDate.getMinutes(); //获取当前分钟
  214. var seconds = myDate.getSeconds() + 1 < 10 ? "0" + myDate.getSeconds() : myDate.getSeconds(); //获取当前秒
  215. var date = year + "-" + mon + "-" + dates + ' ' + hours + ':' + minutes + ':' + seconds;
  216. var Details = [];
  217. var obj_vendor = $("#gridList");
  218. var rowIds_vendor = obj_vendor.getDataIDs();
  219. var arrayData_vendor = new Array();
  220. if (rowIds_vendor.length > 0) {
  221. for (var i = 0; i < rowIds_vendor.length; i++) {
  222. var vendorRowData = obj_vendor.getRowData(rowIds_vendor[i]);
  223. if (vendorRowData.Quantity == '0' || vendorRowData.Quantity == 0) {
  224. $.modalAlertNew("WMS00089");
  225. return;
  226. }
  227. var Code = vendorRowData.InvCode;
  228. var Quantity = Number(vendorRowData.Quantity);
  229. var IssueNegQuantity = Number(vendorRowData.IssueNegQuantity);
  230. var tuinum = Number(vendorRowData.tuinum);
  231. //if (IssueNegQuantity - tuinum <= 0) {
  232. // $.modalAlert("料品:'" + Code + "',已发数'" + IssueNegQuantity + "',已全部退货!");
  233. // return;
  234. //}
  235. var obj = {
  236. Sequence: i + 1,
  237. DetailID:vendorRowData.TLZID,
  238. InvCode: vendorRowData.InvCode,
  239. Quantity: vendorRowData.Quantity,
  240. Amount: vendorRowData.Amount,
  241. SourceDetailID: vendorRowData.ZJID,
  242. ExtensionID: vendorRowData.ExtensionID,
  243. };
  244. Details.push(obj);
  245. }
  246. var ICSASNs = {
  247. ID:ID,
  248. WHCode: WHCode,
  249. User: RoleEnCode,
  250. MTIME: date,
  251. WorkPoint: WorkPoint,
  252. Type:'3',
  253. Detail: Details,
  254. }
  255. var ICSASN = [];
  256. ICSASN.push(ICSASNs);
  257. $.submitForm({
  258. url: "/WMS/WWMaterialsDeliveredRTM/UpdateICSMOApplyNeg?" + Math.random(),
  259. param: { ICSASN: JSON.stringify(ICSASN) },
  260. success: function () {
  261. $.currentWindow().$("#gridList").trigger("reloadGrid");
  262. }
  263. })
  264. }
  265. }
  266. </script>
  267. <form id="form1">
  268. <div class="topPanel" style="height:10px">
  269. <div class="btn-group">
  270. @*<a id="AddItemLot" style="margin-left:3px;" class="btn btn-primary" onclick="btnCreate()"><i class="fa fa-pencil-square-o"></i>添加明细</a>
  271. <a id="refresh" class="btn btn-primary" style="margin-left:3px;" onclick="reloadData()"><span class="glyphicon glyphicon-refresh"></span></a>*@
  272. </div>
  273. </div>
  274. <div style="margin-right: 20px;">
  275. <table class="form">
  276. <thead>主表信息</thead>
  277. <tr>
  278. <th class="formTitle MOPick">委外退料单号:</th>
  279. <td class="formValue MOPick">
  280. <input type="text" id="txtApplyNegCode" class="form-control" />
  281. </td>
  282. <th class="formTitle">仓库编码:</th>
  283. <td class="formValue">
  284. <select id="sel_WHCode" name="sel_WHCode" class="form-control select2" style="width: 230px" placeholder="请选择供应商编码..."></select>
  285. <input type="hidden" id="hidetext" />
  286. </td>
  287. </tr>
  288. <tr>
  289. <th class="formTitle">维护人:</th>
  290. <td class="formValue">
  291. <input id="txtMUSER" type="text" readonly="readonly" class="form-control" />
  292. </td>
  293. <th class="formTitle">维护时间:</th>
  294. <td class="formValue">
  295. <input id="txtMTIME" type="text" readonly="readonly" class="form-control" />
  296. </td>
  297. </tr>
  298. </table>
  299. </div>
  300. <div class="gridPanel" style="margin-left:10px">
  301. <span><strong>子表信息</strong></span>
  302. <table id="gridList"></table>
  303. <div style="text-align:center">
  304. <button id="AddRow" class="btn btn-primary" type="button" onclick="AddRowToLast()">添加</button>
  305. <button id="DeleteRow" type="button" class="btn btn-primary" onclick="DeleteRowToLast()">删除</button>
  306. </div>
  307. </div>
  308. </form>