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.

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