CurStockInfoControlIndex.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. var refreshGirdData;
  2. var bootstrap = function ($, learun) {
  3. "use strict";
  4. var psuid = "";
  5. var page = {
  6. init: function () {
  7. page.initGird();
  8. page.bind();
  9. },
  10. bind: function () {
  11. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  12. // 调用后台查询
  13. // queryJson 查询条件
  14. queryJson["MatCode"] = $("#MatCode").val();
  15. queryJson["MatName"] = $("#MatName").val();
  16. queryJson["ContGrpBarCode"] = $("#ContGrpBarCode").val();
  17. queryJson["Grade"] = $("#Grade").val();
  18. queryJson["SKU"] = $("#SKU").val();
  19. queryJson["DocNo"] = $("#DocNo").val();
  20. queryJson["IsTorsChk"] = $("#IsTorsChk").lrselectGet();
  21. queryJson["IsBlack"] = $("#IsBlack").lrselectGet();
  22. page.search({ queryJson: JSON.stringify(queryJson) });
  23. }, 250);
  24. // 查询
  25. $('#btn_Search').on('click', function () {
  26. var keyword = $('#txt_Keyword').val();
  27. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val()}) });
  28. });
  29. // 刷新
  30. $('#lr_refresh').on('click', function () {
  31. location.reload();
  32. });
  33. $('#IsBlack').lrselect({
  34. url: top.$.rootUrl + '/SXManager/Enums/YesNoList',
  35. maxHeight: 60,
  36. allowSearch: false
  37. });
  38. $('#IsTorsChk').lrselect({
  39. url: top.$.rootUrl + '/SXManager/Enums/YesNoList',
  40. maxHeight: 60,
  41. allowSearch: false
  42. });
  43. // 导出数据
  44. $('#lr_exportnow').on('click', function () {
  45. var subsuid = "";
  46. if (psuid == "") {
  47. psuid = $('#gridtable').attr('id');
  48. }
  49. else if (psuid != "") {
  50. var t = $('#' + psuid).attr('id');
  51. if (t == undefined)
  52. psuid = $('#gridtable').attr('id');
  53. }
  54. var mainGridId = $('#gridtable').attr('id');
  55. learun.layerForm({
  56. id: "ExcelExportForm",
  57. title: '导出Excel数据',
  58. url: top.$.rootUrl + '/Utility/ExcelExportForm?mainGridId=' + mainGridId + '&gridId=' + psuid + '&filename=' + encodeURI(encodeURI("导出出入库报表")),
  59. width: 500,
  60. height: 380,
  61. callBack: function (id) {
  62. return top[id].acceptClick();
  63. },
  64. btn: ['导出Excel', '关闭']
  65. });
  66. });
  67. $('#lr_exportall').on('click', function () {
  68. //var where = $("#queryWhere").val();
  69. var query = $('#multiple_condition_query').lrGetFormData();
  70. query["EndTimeBegin"] = $("#EndTimeBegin").val();
  71. query["EndTimeEnd"] = $("#EndTimeEnd").val();
  72. query["GroupName"] = $("#GroupName").val();
  73. query["keyword"] = $('#txt_Keyword').val();
  74. var queryJson = JSON.stringify(query);
  75. learun.layerForm({
  76. id: "ExcelExportForm",
  77. title: '导出Excel数据',
  78. // url: top.$.rootUrl + '/Utility/ExcelExportForm?mainGridId=' + mainGridId + '&gridId=' + psuid + '&filename=' + encodeURI(encodeURI("库存")),
  79. url: top.$.rootUrl + '/Utility/ExcelExportColumn?gridId=' + $('#gridtable').attr('id') + '&subgridId=',
  80. width: 500,
  81. height: 380,
  82. callBack: function (id) {
  83. return top[id].acceptClick(function (data) {
  84. learun.download({
  85. method: "POST",
  86. url: '/SXManager/Statisticsreport/ExportInOutReportExcel',
  87. param: {
  88. fileName: "导出出入库报表",
  89. queryJson: queryJson,
  90. exportField: JSON.stringify(data)
  91. }
  92. });
  93. });
  94. },
  95. btn: ['导出Excel', '关闭']
  96. });
  97. });
  98. },
  99. // 初始化列表
  100. initGird: function () {
  101. $('#gridtable').jfGrid({
  102. url: top.$.rootUrl + '/SXManager/Statisticsreport/GetCurStockInfoControlList',
  103. headData: [
  104. { label: "SKU编码", name: "SKU", width: 100, align: "left" },
  105. { label: "物料描述", name: "MatName", width: 280, align: "left", },
  106. { label: "机器组", name: "WbGroupCode", width: 80, align: "left", },
  107. {
  108. label: "前天(R/L)", name: "BeforeYesterdayQty", width: 80, align: "left"
  109. , formatter: function (cellvalue) {
  110. return '<span class=\"label label-default\" >' + cellvalue[0] + '</span>/<span class=\"label label-default\" >' + cellvalue[1] + '</span>'
  111. }
  112. },
  113. {
  114. label: "昨天(R/L)", name: "YesterdayQty", width: 80, align: "left", formatter: function (cellvalue) {
  115. return '<span class=\"label label-default\" >' + cellvalue[0] + '</span>/<span class=\"label label-default\" >' + cellvalue[1] + '</span>'
  116. }
  117. },
  118. {
  119. label: "今天(R/L)", name: "TodayQty", width: 80, align: "left", formatter: function (cellvalue) {
  120. return '<span class=\"label label-default\" >' + cellvalue[0] + '</span>/<span class=\"label label-default\" >' + cellvalue[1] + '</span>'
  121. }
  122. },
  123. {
  124. label: "是否有黑盘", name: "HaveBlack", width: 230, align: "left", formatter: function (cellvalue) {
  125. return '<span class=\"label label-default\" >' + cellvalue[0] + '</span>/<span class=\"label label-default\" >' + cellvalue[1] + '</span>/<span class=\"label label-default\" >' + cellvalue[1] + '</span >';
  126. }
  127. },
  128. { label: "质量等级", name: "Grade", width: 80, align: "left", },
  129. ],
  130. rows: 200,
  131. mainId: 'SKU',
  132. footerrow: true,
  133. isPage: true,
  134. reloadSelected: true,
  135. autowWidth: true,
  136. sidx: 'SKU',
  137. sord: 'asc',
  138. onRenderComplete: function (data) {
  139. var datas = $('#gridtable').jfGridGet("rowdatas");
  140. for (var i = 0; i < datas.length; i++) {
  141. if (datas[i].BeforeYesterdayQty[0] != '0R' || datas[i].BeforeYesterdayQty[1] != '0L') {
  142. let result = datas[i].HaveBlack[0].match(/\(([^)]*)\)/);
  143. if (result) {
  144. let arr = result[1].split('/');
  145. if ((datas[i].BeforeYesterdayQty[0] != '0R' && arr[0] == '0R') || (datas[i].BeforeYesterdayQty[1] != '0L' && arr[1] == '0L')) {
  146. $('.jfgrid-data-cell[rowindex=' + i + ']').addClass("SelectBG");
  147. }
  148. }
  149. }
  150. if (datas[i].YesterdayQty[0] != '0R' || datas[i].YesterdayQty[1] != '0L') {
  151. let result = datas[i].HaveBlack[1].match(/\(([^)]*)\)/);
  152. if (result) {
  153. let arr = result[1].split('/');
  154. if ((datas[i].YesterdayQty[0] != '0R' && arr[0] == '0R') || (datas[i].YesterdayQty[1] != '0L' && arr[1] == '0L')) {
  155. $('.jfgrid-data-cell[rowindex=' + i + ']').addClass("SelectBG");
  156. }
  157. }
  158. }
  159. if (datas[i].TodayQty[0] != '0R' || datas[i].TodayQty[1] != '0L') {
  160. let result = datas[i].HaveBlack[2].match(/\(([^)]*)\)/);
  161. if (result) {
  162. let arr = result[1].split('/');
  163. if ((datas[i].TodayQty[0] != '0R' && arr[0] == '0R') || (datas[i].TodayQty[1] != '0L' && arr[1] == '0L')) {
  164. $('.jfgrid-data-cell[rowindex=' + i + ']').addClass("SelectBG");
  165. }
  166. }
  167. }
  168. }
  169. },
  170. });
  171. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val()}) });
  172. },
  173. search: function (param) {
  174. $('#gridtable').jfGridSet('reload', param);
  175. }
  176. };
  177. refreshGirdData = function () {
  178. $('#gridtable').jfGridSet('reload');
  179. };
  180. page.init();
  181. }