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.

572 lines
28 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. 
  2. @{
  3. ViewBag.Title = "MoProducePlan";
  4. Layout = "~/Views/Shared/_Form.cshtml";
  5. }
  6. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  7. <script>
  8. $(function () {
  9. var service = {
  10. isCanEditDate: false,
  11. Init: function () {
  12. var that = this;
  13. $("#txt_ItemCode").val('');
  14. $("#txt_ItemName").val('');
  15. $("#txt_SSName").val('');
  16. that.initControl();
  17. that.loadGrid();
  18. that.loadEvent();
  19. that.loadViewGrid();
  20. },
  21. initControl: function () {
  22. let that = this;
  23. let orgName = '';
  24. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  25. $.ajax({
  26. url: "/OMAY/Aps/GetOrgAName" + "?" + Math.random(),
  27. type: "Get",
  28. dataType: "json",
  29. async: false,
  30. success: function (data) {
  31. //
  32. console.log(data);
  33. if (data.state == "success") {
  34. orgName = data.message;
  35. }
  36. }
  37. });
  38. if (userName.indexOf('L') > -1 || userName.indexOf('C') > -1) {
  39. $("#txt_SSName").val(userName.substr(0, 2));
  40. $("#txt_SSName").attr("disabled", "disabled");
  41. $("#NF-UpdateMoPlan").attr("disabled", "disabled");
  42. }
  43. else {
  44. $("#NF-PrintLabel").attr("disabled", "disabled");
  45. }
  46. if (orgName == "生产主管") {
  47. //生产主管
  48. that.isCanEditDate = true;
  49. //$("#txt_SSName2").css("display", "block");
  50. //$("#lbl_SSName2").css("display", "block");
  51. }
  52. else if (orgName == "生产人员") {
  53. //生产人员
  54. that.isCanEditDate = false;
  55. $("#txt_SSName2").css("display", "none");
  56. $("#lbl_SSName2").css("display", "none");
  57. }
  58. else {
  59. that.isCanEditDate = false;
  60. $("#txt_SSName2").css("display", "none");
  61. $("#lbl_SSName2").css("display", "none");
  62. }
  63. if (!that.isCanEditDate) {
  64. var obj_Item1 = $("#gridList");
  65. var rowIds_Item1 = obj_Item1.getDataIDs();
  66. for (var i = 0; i < rowIds_Item1.length; i++) {
  67. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell');
  68. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell');
  69. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell');
  70. }
  71. }
  72. },
  73. addArriveDateCellAttr(rowId, val, rawObject, cm, rdata) {
  74. //if (rdata.ApsOrderDate != "" && rdata.ApsOrderDate != null) {
  75. // if (rdata.Free5 == "" || rdata.Free5 == null) {
  76. // //var nowDate = GetNowDate();
  77. // //var pass = new Date(rdata.PreArriveDate).getDate() - new Date(rdata.ArriveDate).getDate();
  78. // var pass = daysBetween(rdata.PreArriveDate, rdata.ArriveDate);
  79. // if (pass <= 3 && pass >= 0) {
  80. // //return "style='background-color:darkgray'";
  81. // return "style='background-color:yellow'";
  82. // }
  83. // else if (pass > 3) {
  84. // return "style='background-color:darkgray'";
  85. // }
  86. // else {
  87. // return "style='background-color:red'";
  88. // }
  89. // }
  90. //}
  91. //else {
  92. // return "style='background-color:null'";
  93. //}
  94. },
  95. loadGrid: function () {
  96. var that = this;
  97. var queryJson = {
  98. ItemCode: $("#txt_ItemCode").val(),
  99. ItemName: $("#txt_ItemName").val(),
  100. SSName: $("#txt_SSName").val(),
  101. SSName2: $("#txt_SSName2").val(),
  102. MoCode: $("#txt_MoCode").val(),
  103. }
  104. var $gridList = $("#gridList");
  105. $gridList.dataGrid({
  106. url: "/OMAY/Aps/GetGridJsonChengPing" + "?" + Math.random(),
  107. postData: { queryJson: JSON.stringify(queryJson) },
  108. mtype: "POST",
  109. height: 400,
  110. width: $(window).width() - 300,
  111. cellEdit: true,
  112. cellsubmit: "clientArray",
  113. colModel: [
  114. { label: "主键", name: "ID", hidden: true, key: true },
  115. { label: '预订单号', name: 'PreOrderNo', width: 100, align: 'left' },
  116. { label: '业务员', name: 'BusinessName', width: 100, align: 'left' },
  117. { label: '工单', name: 'MOCode', width: 100, align: 'left' },
  118. { label: '工单行', name: 'MoSeq', width: 100, align: 'left' },
  119. { label: '工单类型', name: 'MoTypeValue', hidden: true, width: 100, align: 'left' },
  120. { label: '部门', name: 'DepName', width: 100, align: 'left' },
  121. { label: '生产日期', name: 'CreateDateTime', width: 150, align: 'left' },
  122. { label: '包装要求', name: 'PackageAsk', width: 100, align: 'left' },
  123. { label: '特殊要求', name: 'SpecialAsk', width: 100, align: 'left' },
  124. { label: '用途', name: 'Useage', width: 100, align: 'left' },
  125. { label: '存货编码', name: 'ItemCode', width: 100, align: 'left' },
  126. { label: '存货名称', name: 'ItemName', width: 100, align: 'left' },
  127. { label: '存货代码', name: 'ItemAddCode', width: 100, align: 'left' },
  128. { label: '单位', name: 'ItemUnit', width: 100, align: 'left' },
  129. { label: '同步状态', name: 'APSStatus', width: 100, align: 'left' },
  130. { label: '数量', name: 'Amount', width: 100, align: 'left' },
  131. {
  132. label: '计划开始时间', name: 'PlanStartDate', width: 150, align: 'left',
  133. editable: true,
  134. editoptions: {
  135. dataInit: function (el) {
  136. console.log(that.isCanEditDate);
  137. if (!that.isCanEditDate)
  138. return;
  139. $(el).click(function () {
  140. WdatePicker({
  141. dateFmt: "yyyy-MM-dd"//时间显示格式
  142. });
  143. })
  144. }
  145. },
  146. },
  147. {
  148. label: '计划结束时间', name: 'PlanEndDate', width: 150, align: 'left',
  149. editable: true,
  150. editoptions: {
  151. dataInit: function (el) {
  152. $(el).click(function () {
  153. WdatePicker({
  154. dateFmt: "yyyy-MM-dd"//时间显示格式
  155. });
  156. })
  157. }
  158. },
  159. },
  160. {
  161. label: '排序时间', name: 'ApsOrderDate', align: 'left', width: 150,
  162. editable: true,
  163. editoptions: {
  164. dataInit: function (el) {
  165. $(el).click(function () {
  166. WdatePicker({
  167. dateFmt: "yyyy-MM-dd HH:mm:ss"//时间显示格式
  168. });
  169. })
  170. }
  171. },
  172. },
  173. ],
  174. shrinkToFit: true,//宽度自适应
  175. width: "100%",
  176. autowidth: true,
  177. gridComplete: function () {
  178. if (!that.isCanEditDate) {
  179. var obj_Item1 = $("#gridList");
  180. var rowIds_Item1 = obj_Item1.getDataIDs();
  181. for (var i = 0; i < rowIds_Item1.length; i++) {
  182. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanStartDate", '', 'not-editable-cell');
  183. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "PlanEndDate", '', 'not-editable-cell');
  184. $("#gridList").jqGrid('setCell', rowIds_Item1[i], "ApsOrderDate", '', 'not-editable-cell');
  185. }
  186. }
  187. },
  188. pager: "#gridPager",
  189. sortname: 'ApsOrderDate,PlanStartDate',
  190. sortorder: "asc",
  191. viewrecords: true,
  192. multiselect: true,
  193. subGrid: true, // (1)开启子表格支持
  194. subGridRowExpanded: function (subgrid_id, rowid) { // (2)子表格容器的id和需要展开子表格的行id,将传入此事件函数
  195. // console.log(subgrid_id, rowid);
  196. //
  197. $("#gridList").jqGrid("setSelection", rowid, false);
  198. that.bindSubGrid3(subgrid_id, rowid);
  199. }
  200. });
  201. },
  202. loadViewGrid: function () {
  203. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  204. if (objList.length == 0) {
  205. objList = ['-1'];
  206. }
  207. var $gridList = $("#gridList2");
  208. $gridList.dataGrid({
  209. url: "/OMAY/Aps/GetApsPlanSelectSubItemList" + "?" + Math.random(),
  210. postData: { ids: objList.join() },
  211. mtype: "POST",
  212. height: 280,
  213. width: $(window).width() - 300,
  214. colModel: [
  215. { label: "主键", name: "ID", hidden: true, key: true },
  216. { label: '子件料号', name: 'SubItemCode', width: 150, align: 'left' },
  217. { label: '子件名称', name: 'SubItemName', width: 150, align: 'left' },
  218. { label: '子件规格', name: 'SubItemStd', width: 150, align: 'left' },
  219. { label: '主数量', name: 'Quantity', width: 100, align: 'left' },
  220. { label: '主单位', name: 'InvUnit', width: 100, align: 'left' },
  221. { label: '辅计量', name: 'Amount', width: 100, align: 'left' },
  222. { label: '辅单位', name: 'AmountUnit', width: 100, align: 'left' },
  223. ],
  224. shrinkToFit: true,//宽度自适应
  225. width: "100%",
  226. autowidth: true,
  227. gridComplete: function () {
  228. },
  229. pager: "#gridPager2",
  230. sortname: 'MOCode,MoSeq',
  231. sortorder: "asc",
  232. viewrecords: true,
  233. multiselect: false
  234. });
  235. },
  236. bindSubGrid3: function (subgrid_id, rowid) {
  237. //
  238. $("#gridList").jqGrid("setSelection", rowid, false);
  239. var subgrid_table_id;
  240. subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
  241. var subgrid_pager_id;
  242. subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
  243. $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
  244. var MOCode = $("#gridList").jqGrid('getRowData', rowid).MOCode;
  245. var MoSeq = $("#gridList").jqGrid('getRowData', rowid).MoSeq;
  246. // (6)创建jqGrid对象
  247. $("#" + subgrid_table_id).dataGrid({
  248. cellEdit: true,
  249. mtype: "GET",
  250. url: "/OMAY/Aps/GetApsPlanSubGridJsonList?moCode=" + MOCode + "&moSeq=" + MoSeq + "&" + Math.random(), // (7)子表格数据对应的url,注意传入的contact.id参数
  251. colModel: [
  252. { label: "主键", name: "ID", hidden: true, key: true },
  253. { label: '子件行号', name: 'SubSeq', width: 150, align: 'left' },
  254. { label: '子件料号', name: 'SubItemCode', width: 150, align: 'left' },
  255. { label: '子件名称', name: 'SubItemName', width: 150, align: 'left' },
  256. { label: '子件规格', name: 'SubItemDtd', width: 150, align: 'left' },
  257. { label: '比例', name: 'Rate', width: 100, align: 'left' },
  258. { label: '主数量', name: 'Quantity', width: 100, align: 'left' },
  259. { label: '主单位', name: 'InvUnit', width: 100, align: 'left' },
  260. { label: '辅计量', name: 'Amount', width: 100, align: 'left' },
  261. { label: '辅单位', name: 'AmountUnit', width: 100, align: 'left' },
  262. ],
  263. //colModel: ColModelSub,
  264. shrinkToFit: true,//宽度自适应
  265. multiselect: true,
  266. prmNames: { search: "search" },
  267. viewrecords: true,
  268. height: "100%",
  269. //rowNum: 20,
  270. //pager: subgrid_pager_id,
  271. });
  272. },
  273. query: function () {
  274. console.log("点击查询");
  275. let queryJson = {
  276. ItemCode: $("#txt_ItemCode").val(),
  277. ItemName: $("#txt_ItemName").val(),
  278. SSName: $("#txt_SSName").val(),
  279. SSName2: $("#txt_SSName2").val(),
  280. MoCode: $("#txt_MoCode").val(),
  281. };
  282. // that.loadGrid(queryJson);
  283. $("#gridList").jqGrid('setGridParam', {
  284. postData: { queryJson: JSON.stringify(queryJson) },
  285. }).trigger('reloadGrid');
  286. },
  287. loadEvent: function () {
  288. var that = this;
  289. $("#btn_search").click(function () {
  290. that.query();
  291. });
  292. $("#NF-InstructionBill").click(function () {
  293. // console.log("编辑指令单");
  294. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  295. // console.log(objList);
  296. if (objList.length == 0) {
  297. $.modalMsg("请选择一条数据", "warning");
  298. return;
  299. }
  300. var idstr = objList.join();
  301. // return;
  302. $.modalOpen({
  303. id: "Form",
  304. title: "指令单",
  305. url: "/OMAY/Aps/EditInstructionBill?ids=" + idstr + "",
  306. width: "600px",
  307. height: "400px",
  308. callBack: function (iframeId) {
  309. top.frames[iframeId].submitForm();
  310. }
  311. });
  312. });
  313. $("#NF-ViewSubItem").click(function () {
  314. console.log("点击预览");
  315. //let queryJson = {
  316. // ItemCode: $("#txt_ItemCode").val(),
  317. // ItemName: $("#txt_ItemName").val(),
  318. // SSName: $("#txt_SSName").val(),
  319. //};
  320. // that.loadGrid(queryJson);
  321. var objList = $("#gridList").jqGrid('getGridParam', 'selarrrow');
  322. // console.log(objList);
  323. if (objList.length == 0) {
  324. $.modalMsg("请选择一条数据", "warning");
  325. return;
  326. }
  327. console.log(objList);
  328. $("#gridList2").jqGrid('setGridParam', {
  329. postData: { ids: objList.join() },
  330. }).trigger('reloadGrid');
  331. });
  332. $("#NF-PrintLabel").click(function () {
  333. console.log("打印条码");
  334. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  335. if (ids.length != 1) {
  336. $.modalMsg("请选择一条数据", "warning");
  337. return;
  338. }
  339. var POCode = "";
  340. var PORow = "";
  341. for (var i in ids) {
  342. MODetailID = $("#gridList").jqGrid('getRowData', ids[i]).MODetailID;
  343. MOCode = $("#gridList").jqGrid('getRowData', ids[i]).MOCode;
  344. Sequence = $("#gridList").jqGrid('getRowData', ids[i]).MoSeq;
  345. InvCode = $("#gridList").jqGrid('getRowData', ids[i]).ItemCode;
  346. MoTypeValue = $("#gridList").jqGrid('getRowData', ids[i]).MoTypeValue;
  347. }
  348. $.modalOpen({
  349. id: "FormAddItemLot",
  350. title: "成品条码产生",
  351. url: "/OMAY/ICSMoCreateLot/From?MOCode=" + encodeURI(encodeURI(MOCode)) + "&Sequence=" + Sequence + "&InvCode=" + InvCode + "&Type=" + 3 + "&MODetailID=" + MODetailID + "&MoTypeValue=" + MoTypeValue + "&" + Math.random(),
  352. width: "550px",
  353. height: "1000px",
  354. callBack: function (iframeId) {
  355. top.frames[iframeId].submitForm();
  356. }
  357. });
  358. });
  359. $("#NF-UpdateMoPlan").click(function () {
  360. // console.log('@NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode');
  361. // return;
  362. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  363. if (ids.length != 1) {
  364. $.modalMsg("请选择一条数据", "warning");
  365. return;
  366. }
  367. let obj = {
  368. isCanUpdateStatus:false,
  369. ids: ids[0],
  370. line: $("#gridList").jqGrid('getRowData', ids[0]).DepName,
  371. planStartDate: $("#gridList").jqGrid('getRowData', ids[0]).PlanStartDate,
  372. planEndDate: $("#gridList").jqGrid('getRowData', ids[0]).PlanEndDate,
  373. orderDate: $("#gridList").jqGrid('getRowData', ids[0]).ApsOrderDate,
  374. };
  375. //if (!obj.orderDate) {
  376. // $.modalMsg("排序时间格式错误", "warning");
  377. // return;
  378. //}
  379. //if (!obj.planStartDate) {
  380. // $.modalMsg("计划开始时间必填", "warning");
  381. // return;
  382. //}
  383. //if (!obj.planEndDate) {
  384. // $.modalMsg("计划结束时间必填", "warning");
  385. // return;
  386. //}
  387. if (new Date(obj.planStartDate) > new Date(obj.planEndDate)) {
  388. $.modalMsg("计划开始时间不能大于结束时间", "warning");
  389. return;
  390. }
  391. //if (!obj.orderDate) {
  392. // obj.orderDate = new Date().toLocaleDateString();
  393. //}
  394. $.ajax({
  395. url: "/OMAY/Aps/UpdateMoPlan" + "?" + Math.random(),
  396. type: "POST",
  397. dataType: "json",
  398. async: false,
  399. data: {
  400. keyValue: JSON.stringify(obj)
  401. },
  402. success: function (data) {
  403. //
  404. console.log(data);
  405. if (data.state == "success") {
  406. $.modalMsg("修改成功", "success");
  407. that.query();
  408. }
  409. else
  410. $.modalMsg(data.message, "warning");
  411. }
  412. });
  413. });
  414. $("#txt_SSName").change(function (event,handle) {
  415. //console.log( $("#txt_SSName").val());
  416. // console.log(val);
  417. // console.log("值改变了");
  418. let val = $("#txt_SSName").val();
  419. if (!val) {
  420. $("#NF-PrintLabel").attr("disabled", "disabled");
  421. }
  422. else {
  423. $("#NF-PrintLabel").removeAttr("disabled");
  424. }
  425. });
  426. }
  427. }
  428. service.Init();
  429. })
  430. </script>
  431. <iframe id="ifrm" src="" width="0" height="0"></iframe>
  432. <script>
  433. </script>
  434. <div class="topPanel" style="height:100px;">
  435. <div class="toolbar">
  436. <div class="btn-group">
  437. <a id="NF-InstructionBill" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>指令单</a>
  438. <a id="NF-ViewSubItem" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>预览子料</a>
  439. <a id="NF-PrintLabel" authorize="no" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>生成条码</a>
  440. <a id="NF-UpdateMoPlan" authorize="yes" style="margin-left:3px;" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i>修改</a>
  441. @*<a id="NF-ExportAll" authorize="yes" class="btn btn-default" onclick="btn_ExportAll()"><i class="fa fa-download"></i>导出</a>*@
  442. <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
  443. </div>
  444. <div class="btn-group" style="display:block;padding-left:2px;">
  445. <a class="btn btn-primary" id="downPrintControl" href="~/PrintActivex.exe" style="display:none">点击下载打印组件</a>
  446. </div>
  447. @*<script>$('.toolbar').authorizeButton()</script>*@
  448. </div>
  449. <div class="search">
  450. <table>
  451. <tr>
  452. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_MoCode">&nbsp;&nbsp;&nbsp;&nbsp;生产工单</label>:</td>
  453. <td class="HideItems">
  454. <div class="input-group HideItems">
  455. <input id="txt_MoCode" type="text" class="form-control HideItems" style="width: 100px;">
  456. </div>
  457. </td>
  458. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ItemCode">&nbsp;&nbsp;&nbsp;&nbsp;存货编码</label>:</td>
  459. <td class="HideItems">
  460. <div class="input-group HideItems">
  461. <input id="txt_ItemCode" type="text" class="form-control HideItems" style="width: 100px;">
  462. </div>
  463. </td>
  464. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_ItemName">&nbsp;&nbsp;&nbsp;&nbsp;存货名称</label>:</td>
  465. <td class="HideItems">
  466. <div class="input-group HideItems">
  467. <input id="txt_ItemName" type="text" class="form-control HideItems" style="width: 100px;">
  468. </div>
  469. </td>
  470. <td class="HideItems" style="text-align:right;"><label class="lglabel HideItems" for="txt_SSName">&nbsp;&nbsp;&nbsp;&nbsp;已下发产线</label>:</td>
  471. <td class="HideItems">
  472. <div class="input-group HideItems">
  473. @*<input id="txt_SSName" type="text" class="form-control HideItems" style="width: 100px;">*@
  474. <select id="txt_SSName" name="ssName" class="form-control select2 required" style="width: 200px;">
  475. <option value=""></option>
  476. <option value="L1">L1</option>
  477. <option value="L2">L2</option>
  478. <option value="L3">L3</option>
  479. <option value="L4">L4</option>
  480. <option value="L5">L5</option>
  481. <option value="L6">L6</option>
  482. <option value="L7">L7</option>
  483. <option value="C1">C1</option>
  484. <option value="C2">C2</option>
  485. </select>
  486. </div>
  487. </td>
  488. <td class="HideItems" style="text-align:right;"><label id="lbl_SSName2" class="lglabel HideItems" for="txt_SSName">未下发产线</label>:</td>
  489. <td class="HideItems">
  490. <div class="input-group HideItems">
  491. @*<input id="txt_SSName" type="text" class="form-control HideItems" style="width: 100px;">*@
  492. <select id="txt_SSName2" name="ssName2" class="form-control select2 required" style="width: 200px;">
  493. <option value=""></option>
  494. <option value="L1">L1</option>
  495. <option value="L2">L2</option>
  496. <option value="L3">L3</option>
  497. <option value="L4">L4</option>
  498. <option value="L5">L5</option>
  499. <option value="L6">L6</option>
  500. <option value="L7">L7</option>
  501. <option value="C1">C1</option>
  502. <option value="C2">C2</option>
  503. </select>
  504. </div>
  505. </td>
  506. </tr>
  507. <tr>
  508. <td>
  509. <span class="input-group-btn">
  510. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  511. </span>
  512. </td>
  513. </tr>
  514. </table>
  515. </div>
  516. </div>
  517. <div class="gridPanel">
  518. <table id="gridList"></table>
  519. <div id="gridPager"></div>
  520. </div>
  521. <div class="gridPane2">
  522. <table id="gridList2"></table>
  523. <div id="gridPager2"></div>
  524. </div>