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.

514 lines
24 KiB

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