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.

487 lines
19 KiB

1 year ago
1 year ago
1 year ago
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  6. <link href="~/Content/js/dialog/dialog.css?v=20120420" rel="stylesheet" />
  7. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  8. <script src="~/Content/js/select2/select2.min.js"></script>
  9. <style>
  10. .selected-row {
  11. background-color: yellow;
  12. }
  13. </style>
  14. <style>
  15. .divbox {
  16. margin-left: 20px;
  17. margin-top: 10px;
  18. display: inline-block;
  19. float: left;
  20. }
  21. .divformValue {
  22. display: inline-block;
  23. float: left;
  24. }
  25. .divformTitle {
  26. display: inline-block;
  27. float: left;
  28. }
  29. /*.divformValue{
  30. display:inline-block;
  31. }*/
  32. </style>
  33. <script>
  34. var WorkPoint = '@NFine.Code.OperatorProvider.Provider.GetCurrent().Location'
  35. var User = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  36. var MODetailID = '';
  37. var TransSequence = '';
  38. var ZSequence = '';
  39. var Quantitys = '';
  40. var Amounts = '';
  41. var MODetailIDs = '';
  42. var count = 0;
  43. var selectedRowId = null;
  44. debugger;
  45. $(function () {
  46. gridList();
  47. gridList2(MODetailID);
  48. //gridList3();
  49. LotNoBinding();
  50. });
  51. function gridList() {
  52. document.getElementById("gridPanel").innerHTML = ' <span><strong>详细信息</strong></span> <table id="gridList"></table> ';//重置grid
  53. var queryJson = {
  54. Code: $("#txt_Code").val(),
  55. }
  56. $("#gridList").dataGrid({
  57. url: "/OMAY/OMAYMoOutbound/GetMosByCode" + "?" + Math.random(),
  58. postData: { queryJson: JSON.stringify(queryJson) },
  59. height:150,
  60. width: $(window).width() - 700,
  61. colModel: [
  62. { label: '选择', width: 100, align: 'left', formatter: BtnLookPick },
  63. { label: '主键', name: 'ID', hidden: true, key: true },
  64. { label: '工单号', name: 'MOCode', width: 100, align: 'left' },
  65. { label: '工单行号', name: 'Sequence', width: 100, align: 'left' },
  66. { label: '料品编码', name: 'InvCode', width: 100, align: 'left' },
  67. { label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  68. { label: '料品描述', name: 'InvDesc', width: 100, align: 'left' },
  69. { label: '规格型号', name: 'InvStd', width: 100, align: 'left' },
  70. { label: '数量', name: 'Quantity', width: 100, align: 'left' },
  71. { label: '单位', name: 'InvUnit', width: 100, align: 'left' },
  72. { label: '辅计量数量', name: 'Amount', width: 100, align: 'left' },
  73. { label: 'ERP工单行ID', name: 'MODetailID', width: 100, align: 'left' },
  74. { label: '部门', name: 'DepName', width: 100, align: 'left' },
  75. ],
  76. width: "100%",
  77. autowidth: true,
  78. gridComplete: function () {
  79. },
  80. pager: "#gridPager",
  81. sortname: 'MOCode',
  82. sortorder: "desc",
  83. viewrecords: true,
  84. multiselect: false,
  85. beforeSelectRow: function (rowid, e) {
  86. $("#gridList").jqGrid('resetSelection');
  87. selectedRowId = rowid;
  88. return (true);
  89. }
  90. });
  91. }
  92. function gridList2(MODetailID) {
  93. document.getElementById("gridPanel2").innerHTML = ' <span><strong>详细信息</strong></span> <table id="gridList2"></table> ';//重置grid
  94. $("#gridList2").jqGrid("clearGridData");
  95. $("#gridList3").jqGrid("clearGridData");
  96. var queryJson = {
  97. MODetailID: MODetailID,
  98. }
  99. $("#gridList2").dataGrid({
  100. url: "/OMAY/OMAYMoOutbound/GetMoPicksByCode" + "?" + Math.random(),
  101. postData: { queryJson: JSON.stringify(queryJson) },
  102. height:200,
  103. width: $(window).width() - 700,
  104. colModel: [
  105. { label: '选择', width: 100, align: 'left', formatter: BtnPick },
  106. { label: '主键', name: 'ID', hidden: true, key: true },
  107. { label: 'ERP工单行ID', name: 'MODetailID', width: 100, align: 'left' },
  108. { label: '子件行号', name: 'Sequence', width: 100, align: 'left' },
  109. { label: '料品编码', name: 'InvCode', width: 100, align: 'left' },
  110. { label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  111. { label: '料品描述', name: 'InvDesc', width: 100, align: 'left' },
  112. { label: '规格型号', name: 'InvStd', width: 100, align: 'left' },
  113. { label: '应发数量', name: 'Quantity', width: 100, align: 'left' },
  114. { label: '已发数量', name: 'IssueQuantity', width: 100, align: 'left' },
  115. { label: '辅计量', name: 'Amount', width: 100, align: 'left' },
  116. { label: '转换率', name: 'EATTRIBUTE1', width: 100, align: 'left' },
  117. ],
  118. width: "100%",
  119. autowidth: true,
  120. gridComplete: function () {
  121. },
  122. pager: "#gridPager",
  123. sortname: 'Sequence',
  124. sortorder: "asc",
  125. viewrecords: true,
  126. multiselect: false,
  127. beforeSelectRow: function (rowid, e) {
  128. $("#gridList").jqGrid('resetSelection');
  129. return (true);
  130. },
  131. });
  132. }
  133. function gridList3() {
  134. $("#gridList3").dataGrid({
  135. height:250,
  136. width: $(window).width() - 400,
  137. cellEdit: true,
  138. cellsubmit: "clientArray",
  139. colModel: [
  140. { label: "主键", name: "ID", hidden: true, key: true },
  141. {
  142. label: '删除', width: 100, align: 'left',
  143. formatter: btnDelete
  144. },
  145. { label: '料品编码', name: 'InvCode', width: 150, align: 'left' },
  146. { label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  147. { label: '规格型号', name: 'InvStd', width: 100, align: 'left' },
  148. { label: '条码', name: 'LotNo', width: 120, align: 'left' },
  149. { label: '单位', name: 'InvUnit', width: 80, align: 'left' },
  150. { label: '生产日期', name: 'ProductDate', width: 150, align: 'left' },
  151. { label: '数量', name: 'Quantity', width: 100, align: 'left' },
  152. { label: '本次发料数量', name: 'CurrentQuantity', width: 200, align: 'left', editable: true },
  153. { label: '辅计量', name: 'Amount', width: 100, align: 'left' },
  154. { label: '项目号', name: 'ProjectCode', width: 200, align: 'left', hidden: true },
  155. { label: '批次', name: 'BatchCode', width: 200, align: 'left', hidden: true },
  156. { label: '版本', name: 'Version', width: 200, align: 'left', hidden: true },
  157. { label: '厂牌', name: 'Brand', width: 200, align: 'left', hidden: true },
  158. { label: '自由项1', name: 'cFree1', width: 200, align: 'left', hidden: true },
  159. { label: '自由项2', name: 'cFree2', width: 200, align: 'left', hidden: true },
  160. { label: '自由项3', name: 'cFree3', width: 200, align: 'left', hidden: true },
  161. { label: '自由项4', name: 'cFree4', width: 200, align: 'left', hidden: true },
  162. { label: '自由项5', name: 'cFree5', width: 200, align: 'left', hidden: true },
  163. { label: '自由项6', name: 'cFree6', width: 200, align: 'left', hidden: true },
  164. { label: '自由项7', name: 'cFree7', width: 200, align: 'left', hidden: true },
  165. { label: '自由项8', name: 'cFree8', width: 200, align: 'left', hidden: true },
  166. { label: '自由项9', name: 'cFree9', width: 200, align: 'left', hidden: true },
  167. { label: '自由项10', name: 'cFree10', width: 200, align: 'left', hidden: true },
  168. ],
  169. width: "100%",
  170. autowidth: true,
  171. rownumbers: true,
  172. viewrecords: true,
  173. });
  174. }
  175. //查看子件信息
  176. function BtnLookPick(cellvalue, options, rowObject) {
  177. debugger;
  178. return cellvalue = "<a class=\"btn btn-info dropdown-text\" onclick=\"GridListClick('" + rowObject.ID + "','" + rowObject.MODetailID + "','" + rowObject.Sequence + "','" + rowObject.Quantity + "','" + rowObject.Amount + "')\">选择</a>";
  179. }
  180. function BtnPick(cellvalue, options, rowObject) {
  181. debugger;
  182. return cellvalue = "<a class=\"btn btn-info dropdown-text\" onclick=\"GridList2Click('" + rowObject.ID + "','" + rowObject.Sequence + "')\">选择</a>";
  183. }
  184. function GridListClick(ID, MODetailID, Sequence, Quantity, Amount) {
  185. debugger;
  186. $("#gridList").find("td").css("background-color", "");
  187. $("#" + ID).find("td").css("background-color", "yellow");
  188. TransSequence = Sequence;
  189. Quantitys = Quantity;
  190. Amounts = Amount;
  191. MODetailIDs = MODetailID;
  192. gridList2(MODetailID);
  193. }
  194. function GridList2Click(ID, Sequence) {
  195. $("#gridList2").find("td").css("background-color", "");
  196. $("#" + ID).find("td").css("background-color", "yellow");
  197. ZSequence = Sequence;
  198. $("#gridList3").jqGrid("clearGridData");
  199. gridList3();
  200. }
  201. function btnDelete(cellvalue, options, rowObject) {
  202. return cellvalue = "<a class=\"btn btn-primary dropdown-text\" onclick=\"Delete('" + rowObject.ID + "')\">删除</a>";
  203. }
  204. function Delete(ID) {
  205. $("#gridList3").delRowData(ID);
  206. }
  207. function SeachMO() {
  208. $.modalOpen({
  209. id: "SeachMO",
  210. title: "工单",
  211. url: "/OMAY/OMAYMoOutbound/SeachMoInfo" + "?" + Math.random(),
  212. width: "500px",
  213. height: "600px",
  214. callBack: function (iframeId) {
  215. var obj = top.frames[iframeId].submitForm();
  216. $("#txt_Code").val(obj.MOCode);
  217. $("#gridList").jqGrid("clearGridData");
  218. $("#gridList2").jqGrid("clearGridData");
  219. $("#gridList3").jqGrid("clearGridData");
  220. gridList();
  221. $(".unwritten").hide();
  222. top.frames[iframeId].Close();
  223. }
  224. });
  225. }
  226. function LotNoBinding() {
  227. //if (count!=0) {
  228. // if (ZSequence == '') {
  229. // $.modalAlert("请先选择工单子件!", "warning");
  230. // return;
  231. // }
  232. //}
  233. //count = count + 1;
  234. var Msg = '';
  235. $("#LotNo").keydown(function (e) {
  236. var curKey = e.which;rowIds
  237. debugger;
  238. if (curKey == 13) {
  239. var Code = $("#txt_Code").val();//工单号
  240. var LotNo = $("#LotNo").val();//条码号
  241. if (LotNo=='') {
  242. $.modalAlert("扫入的条码异常,请重新扫入!", "warning");
  243. return;
  244. }
  245. var gridList3 = $("#gridList3");
  246. var rowIds = gridList3.getDataIDs();
  247. if (rowIds.length > 0) {
  248. for (var i = 0; i < rowIds.length; i++) {
  249. var RowData = gridList3.getRowData(rowIds[i]);
  250. if (RowData.LotNo == LotNo) {
  251. $.modalAlert("条码" + LotNo + "重复扫入,请确认!", "warning");
  252. return;
  253. }
  254. }
  255. }
  256. var TransType = '生产发料-生产订单备料表';
  257. WorkPoint
  258. var keyValue = {
  259. TransCode: Code,
  260. TransSequence: TransSequence+'~'+ZSequence,
  261. Code: LotNo,
  262. TransType: TransType,
  263. WorkPoint: WorkPoint,
  264. User: User,
  265. }
  266. $.ajax({
  267. url: "/OMAY/OMAYMoOutbound/GetLotNotInfo" + "?" + Math.random(),
  268. data: { keyValue: JSON.stringify(keyValue) },
  269. dataType: "json",
  270. async: false,
  271. success: function (data) {
  272. debugger;
  273. if (data == "" || data == null) {
  274. $.modalAlertNew("WMS00022");
  275. return;
  276. }
  277. //Msg = data.msg;
  278. if (data.msg!="") {
  279. $.modalAlert(data.msg);
  280. return;
  281. }
  282. var cQuantity = data.dt[0].Quantity;
  283. if (data.dt[0].AmountEnable == true) {
  284. cQuantity = data.dt[0].Amount;
  285. }
  286. //最后一行新增数据
  287. var obj = {
  288. ID: data.dt[0].ID,
  289. LotNo: data.dt[0].LotNo,
  290. InvCode: data.dt[0].InvCode,
  291. InvName: data.dt[0].InvName,
  292. InvStd: data.dt[0].InvStd,
  293. InvUnit: data.dt[0].InvUnit,
  294. ProductDate: data.dt[0].ProductDate,
  295. Quantity: data.dt[0].Quantity,
  296. CurrentQuantity: cQuantity,
  297. Amount: data.dt[0].Amount,
  298. ProjectCode: data.dt[0].ProjectCode,
  299. BatchCode: data.dt[0].BatchCode,
  300. Version: data.dt[0].Version,
  301. Brand: data.dt[0].Brand,
  302. cFree1: data.dt[0].cFree1,
  303. cFree2: data.dt[0].cFree2,
  304. cFree3: data.dt[0].cFree3,
  305. cFree4: data.dt[0].cFree4,
  306. cFree5: data.dt[0].cFree5,
  307. cFree6: data.dt[0].cFree6,
  308. cFree7: data.dt[0].cFree7,
  309. cFree8: data.dt[0].cFree8,
  310. cFree9: data.dt[0].cFree9,
  311. cFree10: data.dt[0].cFree10
  312. };
  313. $("#gridList3").jqGrid('addRowData', obj.ID, obj, 'first');
  314. $(".unwritten").hide();
  315. }
  316. });
  317. }
  318. });
  319. };
  320. function submitForm() {
  321. debugger;
  322. var AllLotNoNum = 0;
  323. var Code = $("#txt_Code").val();//工单号
  324. var Details = [];
  325. var myDate = new Date();
  326. var year = myDate.getFullYear(); //获取当前年
  327. var mon = myDate.getMonth() + 1 < 10 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1; //获取当前月
  328. var dates = myDate.getDate() + 1 < 10 ? "0" + myDate.getDate() : myDate.getDate(); //获取当前日
  329. var hours = myDate.getHours() + 1 < 10 ? "0" + myDate.getHours() : myDate.getHours(); //获取当前小时
  330. var minutes = myDate.getMinutes() + 1 < 10 ? "0" + myDate.getMinutes() : myDate.getMinutes(); //获取当前分钟
  331. var seconds = myDate.getSeconds() + 1 < 10 ? "0" + myDate.getSeconds() : myDate.getSeconds(); //获取当前秒
  332. var date = year + "-" + mon + "-" + dates + ' ' + hours + ':' + minutes + ':' + seconds;
  333. var gridList3 = $("#gridList3");
  334. var rowIds = gridList3.getDataIDs();
  335. if (rowIds.length > 0) {
  336. for (var i = 0; i < rowIds.length; i++) {
  337. var RowData = gridList3.getRowData(rowIds[i]);
  338. if (RowData.CurrentQuantity == 0 || RowData.CurrentQuantity=='') {
  339. $.modalAlert("条码" + RowData.LotNo + "未输入本次发料数量,请确认!", "warning");
  340. return;
  341. }
  342. if (Number(RowData.CurrentQuantity) > Number(RowData.Quantity)) {
  343. $.modalAlert("条码" + RowData.LotNo + "所输入本次发料数量大于条码剩余数量,请确认!", "warning");
  344. return;
  345. }
  346. AllLotNoNum = AllLotNoNum + Number(RowData.CurrentQuantity);
  347. var obj = {
  348. LotNo: RowData.LotNo,
  349. CurrentQuantity: RowData.CurrentQuantity,
  350. };
  351. Details.push(obj);
  352. }
  353. var ICSASNs = {
  354. WorkPoint: WorkPoint,
  355. TransSequence: TransSequence + '~' + ZSequence,
  356. User: User,
  357. TransCode: Code,
  358. Amount: Amounts,
  359. Quantity: AllLotNoNum,
  360. TransType: "生产发料-生产订单备料表",
  361. MTime: date,
  362. Detail: Details,
  363. }
  364. var ICSASN = [];
  365. ICSASN.push(ICSASNs);
  366. $.modalConfirm("请确认是否出库!", function (r) {
  367. $.submitForm({
  368. url: "/OMAY/OMAYMoOutbound/OutboundShipments?" + Math.random(),
  369. param: { ICSASN: JSON.stringify(ICSASN) },
  370. success: function () {
  371. $("#gridList3").jqGrid("clearGridData");
  372. gridList2(MODetailIDs);
  373. // $.currentWindow().$("#gridList").trigger("reloadGrid");
  374. }
  375. })
  376. })
  377. } else {
  378. $.modalAlert("请扫入条码!", "warning");
  379. return;
  380. }
  381. };
  382. </script>
  383. <div class="topPanel" style="height:50px">
  384. <div class="toolbar">
  385. <div class="btn-group">
  386. <a id="NF-Submit" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="submitForm()"><i class="fa fa-pencil-square-o"></i>确定出库</a>
  387. </div>
  388. @*<script>$('.toolbar').authorizeButton()</script>*@
  389. </div>
  390. <div class="search">
  391. <table>
  392. <tr>
  393. <td>
  394. <label>工单号:</label>
  395. </td>
  396. <td>
  397. <div class="input-group">
  398. <input id="txt_Code" type="text" class="form-control" placeholder="工单号" style="width: 120px;">
  399. </div>
  400. </td>
  401. <td>
  402. <a id="Search" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="SeachMO()"><i class="fa fa-pencil-square-o"></i>查询</a>
  403. </td>
  404. <td style="width:20px"></td>
  405. <td>
  406. <label>条码:</label>
  407. </td>
  408. <td>
  409. <div class="input-group">
  410. <input id="LotNo" type="text" class="form-control" placeholder="条码" style="width: 500px;" οnkeydοwn="LotNoBinding()">
  411. </div>
  412. </td>
  413. </tr>
  414. <tr></tr>
  415. </table>
  416. </div>
  417. </div>
  418. <div class="gridPanel" id="gridPanel" style="width:99%;height:20%">
  419. <span><strong>工单信息</strong></span>
  420. <table id="gridList"></table>
  421. </div>
  422. <div class="gridPanel" id="gridPanel2" style="width:99%;height:28%">
  423. <span><strong>子件信息</strong></span>
  424. <table id="gridList2"></table>
  425. </div>
  426. <div class="gridPanel" id="gridPanel3" style="width:99%;height:28%">
  427. <span><strong>条码明细</strong></span>
  428. <table id="gridList3"></table>
  429. </div>