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.

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