Index.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. var refreshGirdData;
  2. var OneInTimebegin = '';
  3. var OneInTimeend = '';
  4. var ProductTimebegin = '';
  5. var ProductTimeend = '';
  6. var logbegin = '';
  7. var logend = '';
  8. var postData;
  9. var bootstrap = function ($, learun) {
  10. var psuid = "";
  11. "use strict";
  12. var page = {
  13. init: function () {
  14. page.initGird();
  15. page.bind();
  16. },
  17. bind: function () {
  18. $('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  19. // 调用后台查询
  20. // queryJson 查询条件
  21. var oneintime = $('#lr_search_date_OneInTime').html();
  22. if (oneintime == '') {
  23. OneInTimebegin = '';
  24. OneInTimeend = '';
  25. }
  26. var producttime = $('#lr_search_date_ProductTime').html();
  27. if (producttime == '') {
  28. ProductTimebegin = '';
  29. ProductTimeend = '';
  30. }
  31. console.log(queryJson);
  32. queryJson["MatCode"] = $("#MatCode").val();
  33. queryJson["MatName"] = $("#MatName").val();
  34. queryJson["BoilerNo"] = $("#BoilerNo").val();
  35. queryJson["RFIDBarCode"] = $("#RFIDBarCode").val();
  36. queryJson["InvBarCode"] = $("#InvBarCode").val();
  37. queryJson["Tunnel"] = $("#Tunnel").val();
  38. queryJson["Code"] = $("#Code").val();
  39. queryJson["PutRow"] = $("#PutRow").val();
  40. queryJson["PutCol"] = $("#PutCol").val();
  41. queryJson["PutLayer"] = $("#PutLayer").val();
  42. queryJson["OneInTimeBegin"] = $("#OneInTimeBegin").val();
  43. queryJson["OneInTimeEnd"] = $("#OneInTimeEnd").val();
  44. queryJson["ProductTimeBegin"] = $("#ProductTimeBegin").val();
  45. queryJson["ProductTimeEnd"] = $("#ProductTimeEnd").val();
  46. //queryJson["OneInTimeBegin"] = OneInTimebegin;
  47. //queryJson["OneInTimeEnd"] = OneInTimeend;
  48. //queryJson["ProductTimeBegin"] = ProductTimebegin;
  49. //queryJson["ProductTimeEnd"] = ProductTimeend;
  50. queryJson["Grade"] = $("#Grade").val();
  51. queryJson["ExecStateCode"] = $("#ExecStateCode").lrselectGet();
  52. queryJson["InvStateCode"] = $("#InvStateCode").lrselectGet();
  53. queryJson["IsSurplus"] = $("#IsSurplus").lrselectGet();
  54. queryJson["IsRework"] = $("#IsRework").lrselectGet();
  55. queryJson["IsFast"] = $("#IsFast").lrselectGet();
  56. queryJson["IsFail"] = $("#IsFail").lrselectGet();
  57. queryJson["IsBack"] = $("#IsBack").lrselectGet();
  58. queryJson["ExecStateCode"] = $("#ExecStateCode").lrselectGet();
  59. page.search({ queryJson: JSON.stringify(queryJson) });
  60. }, 250);
  61. // 查询
  62. $('#btn_Search').on('click', function () {
  63. var keyword = $('#txt_Keyword').val();
  64. page.search({ queryJson: JSON.stringify({ keyword: keyword }) });
  65. });
  66. // 刷新
  67. $('#lr_refresh').on('click', function () {
  68. location.reload();
  69. });
  70. // 导出数据
  71. $('#lr_exportnow').on('click', function () {
  72. var subsuid = "";
  73. if (psuid == "") {
  74. psuid = $('#gridtable').attr('id');
  75. }
  76. else if (psuid != "") {
  77. var t = $('#' + psuid).attr('id');
  78. if (t == undefined)
  79. psuid = $('#gridtable').attr('id');
  80. }
  81. var mainGridId = $('#gridtable').attr('id');
  82. learun.layerForm({
  83. id: "ExcelExportForm",
  84. title: '导出Excel数据',
  85. url: top.$.rootUrl + '/Utility/ExcelExportForm?mainGridId=' + mainGridId + '&gridId=' + psuid + '&filename=' + encodeURI(encodeURI("库存")),
  86. width: 500,
  87. height: 380,
  88. callBack: function (id) {
  89. return top[id].acceptClick();
  90. },
  91. btn: ['导出Excel', '关闭']
  92. });
  93. });
  94. ////导出全部数据
  95. //$('#lr_exportall').on('click', function () {
  96. // var query = $('#multiple_condition_query').lrGetFormData();
  97. // query["Btime"] = logbegin;
  98. // query["Etime"] = logend;
  99. // query["keyword"] = $('#txt_Keyword').val();
  100. // var queryJson = JSON.stringify(query);
  101. // if ($('#jfgrid_head_' + psuid).length == 0) {
  102. // learun.alert.warning('请任意展开一行子表');
  103. // return false;
  104. // }
  105. // learun.layerForm({
  106. // id: "ExcelExportColumn",
  107. // title: '导出Excel数据',
  108. // url: top.$.rootUrl + '/Utility/ExcelExportColumn?gridId=' + $('#gridtable').attr('id') + '&subgridId=' + psuid,
  109. // width: 600,
  110. // height: 480,
  111. // callBack: function (id) {
  112. // return top[id].acceptClick(function (data) {
  113. // learun.download({
  114. // method: "POST",
  115. // url: top.$.rootUrl + '/TaskManager/EquipmentTask_Dis/ExportExcel',
  116. // param: {
  117. // fileName: encodeURI("WCS历史任务"),
  118. // queryJson: queryJson,
  119. // exportField: JSON.stringify(data)
  120. // }
  121. // });
  122. // });
  123. // },
  124. // btn: ['导出Excel', '关闭']
  125. // });
  126. //});
  127. //导出
  128. $('#lr_exportall').on('click', function () {
  129. //var where = $("#queryWhere").val();
  130. var query = $('#multiple_condition_query').lrGetFormData();
  131. query["MatCode"] = $("#MatCode").val();
  132. query["MatName"] = $("#MatName").val();
  133. query["BoilerNo"] = $("#BoilerNo").val();
  134. query["RFIDBarCode"] = $("#RFIDBarCode").val();
  135. query["InvBarCode"] = $("#InvBarCode").val();
  136. query["Tunnel"] = $("#Tunnel").val();
  137. query["Code"] = $("#Code").val();
  138. query["PutRow"] = $("#PutRow").val();
  139. query["PutCol"] = $("#PutCol").val();
  140. query["PutLayer"] = $("#PutLayer").val();
  141. query["OneInTimeBegin"] = OneInTimebegin;
  142. query["OneInTimeEnd"] = OneInTimeend;
  143. query["ProductTimeBegin"] = ProductTimebegin;
  144. query["ProductTimeEnd"] = ProductTimeend;
  145. query["Grade"] = $("#Grade").val();
  146. query["ContGrpType"] = $("#ContGrpType").lrselectGet();
  147. query["InvStateCode"] = $("#InvStateCode").lrselectGet();
  148. query["IsSurplus"] = $("#IsSurplus").lrselectGet();
  149. query["IsRework"] = $("#IsRework").lrselectGet();
  150. query["IsFast"] = $("#IsFast").lrselectGet();
  151. query["IsFail"] = $("#IsFail").lrselectGet();
  152. query["IsBack"] = $("#IsBack").lrselectGet();
  153. query["ExecStateCode"] = $("#ExecStateCode").lrselectGet();
  154. query["keyword"] = $('#txt_Keyword').val();
  155. var queryJson = JSON.stringify(query);
  156. learun.layerForm({
  157. id: "ExcelExportForm",
  158. title: '导出Excel数据',
  159. // url: top.$.rootUrl + '/Utility/ExcelExportForm?mainGridId=' + mainGridId + '&gridId=' + psuid + '&filename=' + encodeURI(encodeURI("库存")),
  160. url: top.$.rootUrl + '/Utility/ExcelExportColumn?gridId=' + $('#gridtable').attr('id') + '&subgridId=',
  161. width: 500,
  162. height: 380,
  163. callBack: function (id) {
  164. return top[id].acceptClick(function (data) {
  165. learun.download({
  166. method: "POST",
  167. url: '/PTManager/Inventorys/ExportExcel',
  168. param: {
  169. fileName: "导出库存报表",
  170. queryJson: queryJson,
  171. exportField: JSON.stringify(data)
  172. }
  173. });
  174. });
  175. },
  176. btn: ['导出Excel', '关闭']
  177. });
  178. });
  179. // 解锁
  180. $('#lr_UnLock').on('click', function () {
  181. postData = $('#gridtable').jfGridGet("rowdata");
  182. if (postData.length == 0) {
  183. learun.alert.error('未选择行!');
  184. return false;
  185. }
  186. learun.layerConfirm('是否确认解锁!', function (res) {
  187. if (res) {
  188. learun.postForm(top.$.rootUrl + '/PTManager/Inventorys/UnLock', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  189. refreshGirdData();
  190. });
  191. }
  192. });
  193. });
  194. // 锁定
  195. $('#lr_Lock').on('click', function () {
  196. postData = $('#gridtable').jfGridGet("rowdata");
  197. if (postData.length == 0) {
  198. learun.alert.error('未选择行!');
  199. return false;
  200. }
  201. learun.layerConfirm('是否确认锁定!', function (res) {
  202. if (res) {
  203. learun.postForm(top.$.rootUrl + '/PTManager/Inventorys/Lock', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  204. refreshGirdData();
  205. });
  206. }
  207. });
  208. });
  209. $('#OneInTime').lrdatetime({
  210. dfdata: [
  211. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  212. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  213. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  214. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  215. ],
  216. // 月
  217. mShow: false,
  218. premShow: false,
  219. // 季度
  220. jShow: false,
  221. prejShow: false,
  222. // 年
  223. ysShow: false,
  224. yxShow: false,
  225. preyShow: false,
  226. yShow: false,
  227. // 默认
  228. dfvalue: 'all',
  229. selectfn: function (begin, end) {
  230. OneInTimebegin = begin;
  231. OneInTimeend = end;
  232. }
  233. });
  234. $('#ProductTime').lrdatetime({
  235. dfdata: [
  236. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  237. { name: '近7天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'd', -6) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  238. { name: '近1个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -1) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  239. { name: '近3个月', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00', 'm', -3) }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  240. ],
  241. // 月
  242. mShow: false,
  243. premShow: false,
  244. // 季度
  245. jShow: false,
  246. prejShow: false,
  247. // 年
  248. ysShow: false,
  249. yxShow: false,
  250. preyShow: false,
  251. yShow: false,
  252. // 默认
  253. dfvalue: 'all',
  254. selectfn: function (begin, end) {
  255. ProductTimebegin = begin;
  256. ProductTimeend = end;
  257. }
  258. });
  259. $('#ExecStateCode').lrselect({
  260. url: top.$.rootUrl + '/PTManager/Enums/InvLockStateList',
  261. maxHeight: 180,
  262. allowSearch: false
  263. });
  264. $('#InvStateCode').lrselect({
  265. url: top.$.rootUrl + '/PTManager/Enums/GetInvStateList',
  266. maxHeight: 180,
  267. allowSearch: false
  268. });
  269. $('#IsSurplus').lrselect({
  270. url: top.$.rootUrl + '/PTManager/Enums/YesNoList',
  271. maxHeight: 60,
  272. allowSearch: false
  273. });
  274. $('#IsRework').lrselect({
  275. url: top.$.rootUrl + '/PTManager/Enums/YesNoList',
  276. maxHeight: 60,
  277. allowSearch: false
  278. });
  279. $('#IsFast').lrselect({
  280. url: top.$.rootUrl + '/PTManager/Enums/YesNoList',
  281. maxHeight: 60,
  282. allowSearch: false
  283. });
  284. $('#IsFail').lrselect({
  285. url: top.$.rootUrl + '/PTManager/Enums/YesNoList',
  286. maxHeight: 60,
  287. allowSearch: false
  288. });
  289. $('#IsBack').lrselect({
  290. url: top.$.rootUrl + '/PTManager/Enums/YesNoList',
  291. maxHeight: 60,
  292. allowSearch: false
  293. });
  294. },
  295. // 初始化列表
  296. initGird: function () {
  297. $('#gridtable').jfGrid({
  298. url: top.$.rootUrl + '/PTManager/Inventorys/GetPageList',
  299. headData: [
  300. { label: "容器条码", name: "ContGrpBarCode", width: 120, align: "left" },
  301. { label: "材料号", name: "InvBarCode", width: 110, align: "left" },
  302. { label: "库存状态", name: "InvStateName", width: 80, align: "left", sortname: "InvStateCode" },
  303. { label: "冻结/放行状态", name: "ExecStateName", width: 80, align: "left", sortname: "ExecStateCode" },
  304. { label: "巷道", name: "Tunnel", width: 50, align: "left" },
  305. { label: "货位号", name: "Code", width: 100, align: "left" },
  306. {
  307. label: "货位状态", name: "CellState", width: 80, align: "left"
  308. , formatter: function (cellvalue) {
  309. if (cellvalue == 0) {
  310. return '<span class=\"label label-success\" >启用</span>';
  311. } else {
  312. return '<span class=\"label label-default\" >禁用</span>';
  313. }
  314. }
  315. },
  316. { label: "行", name: "PutRow", width: 40, align: "left" },
  317. { label: "列", name: "PutCol", width: 40, align: "left" },
  318. { label: "层", name: "PutLayer", width: 40, align: "left" },
  319. { label: "首次入库时间", name: "OneInTime", width: 130, align: "left" },
  320. learun.jfFormatter.col_Date("生产时间", "ProductTime"),
  321. { label: "物料编码", name: "MatCode", width: 110, align: "left" },
  322. { label: "物料名称", name: "MatName", width: 80, align: "left" },
  323. { label: "牌号", name: "BrandNo", width: 80, align: "left" },
  324. { label: "炉号", name: "BoilerNo", width: 80, align: "left" },
  325. { label: "包号", name: "PackNo", width: 80, align: "left" },
  326. { label: "碳当量", name: "CaQty", width: 80, align: "left" },
  327. { label: "总重量", name: "TolWQty", width: 80, align: "left" },
  328. { label: "净重", name: "NetWQty", width: 80, align: "left" },
  329. { label: "皮重", name: "TareWQty", width: 80, align: "left" },
  330. { label: "长度", name: "LengthQty", width: 80, align: "left" },
  331. { label: "RFID编号", name: "RFIDBarCode", width: 80, align: "left" },
  332. {
  333. label: "是否余料", name: "IsSurplus", width: 80, align: "left"
  334. , formatter: function (cellvalue) {
  335. if (cellvalue == true) {
  336. return '<span class=\"label label-success\" >是</span>';
  337. } else {
  338. return '<span class=\"label label-default\" >否</span>';
  339. }
  340. }
  341. },
  342. {
  343. label: "是否退料", name: "IsBack", width: 80, align: "left"
  344. , formatter: function (cellvalue) {
  345. if (cellvalue == true) {
  346. return '<span class=\"label label-success\" >是</span>';
  347. } else {
  348. return '<span class=\"label label-default\" >否</span>';
  349. }
  350. }
  351. },
  352. {
  353. label: "返工标记", name: "IsRework", width: 80, align: "left", formatter: function (cellvalue) {
  354. if (cellvalue == true) {
  355. return '<span class=\"label label-success\" >是</span>';
  356. } else {
  357. return '<span class=\"label label-default\" >否</span>';
  358. }
  359. }
  360. },
  361. {
  362. label: "快投标记", name: "IsFast", width: 80, align: "left", formatter: function (cellvalue) {
  363. if (cellvalue == true) {
  364. return '<span class=\"label label-success\" >是</span>';
  365. } else {
  366. return '<span class=\"label label-default\" >否</span>';
  367. }
  368. }
  369. },
  370. {
  371. label: "是否异常", name: "IsFail", width: 80, align: "left", formatter: function (cellvalue) {
  372. if (cellvalue == true) {
  373. return '<span class=\"label label-success\" >是</span>';
  374. } else {
  375. return '<span class=\"label label-default\" >否</span>';
  376. }
  377. }
  378. },
  379. {
  380. label: "是否锁定", name: "ExecStateCode", width: 80, align: "left"
  381. , formatter: function (cellvalue) {
  382. if (cellvalue == "InvState_Normal") {
  383. return '<span class=\"label label-default\" >否</span>';
  384. } else {
  385. return '<span class=\"label label-success\" >是</span>';
  386. }
  387. }
  388. },
  389. { label: "异常原因", name: "FailReason", width: 80, align: "left" },
  390. { label: "等级", name: "Grade", width: 80, align: "left" },
  391. { label: "退料原因", name: "BackReason", width: 80, align: "left" },
  392. { label: "工序订单号", name: "ProcessDocsCode", width: 120, align: "left" },
  393. { label: "生产机台号", name: "ProductMachCode", width: 80, align: "left" },
  394. { label: "产线编号", name: "ProductLineNo", width: 80, align: "left" },
  395. { label: "入库单号", name: "InDocsNo", width: 120, align: "left" },
  396. { label: "入库单行号", name: "InDocsRowNo", width: 120, align: "left" },
  397. { label: "创建时间", name: "AddTime", width: 130, align: "left" },
  398. { label: "更新时间", name: "EditTime", width: 130, align: "left" },
  399. ],
  400. mainId: 'Id',
  401. isPage: true,
  402. reloadSelected: true,
  403. autowWidth: true,
  404. sidx: 'AddTime',
  405. sord: 'DESC',
  406. isMultiselect: true,
  407. });
  408. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  409. },
  410. search: function (param) {
  411. $('#gridtable').jfGridSet('reload', param);
  412. }
  413. };
  414. refreshGirdData = function () {
  415. $('#gridtable').jfGridSet('reload');
  416. };
  417. page.init();
  418. }