Index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. var refreshGirdData;
  2. var logbegin = '';
  3. var logend = '';
  4. var StartTimeBegin = '';
  5. var StartTimeend = '';
  6. var EndTimeBegin = '';
  7. var EndTimeend = '';
  8. var selectedRow;
  9. var refreshGirdData; // 更新数据
  10. var bootstrap = function ($, learun) {
  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 starttime = $('#lr_search_date_StartTime').html();
  22. //if (starttime == '') {
  23. // StartTimeBegin = '';
  24. // StartTimeend = '';
  25. //}
  26. //var endtime = $('#lr_search_date_EndTime').html();
  27. //if (endtime == '') {
  28. // EndTimeBegin = '';
  29. // EndTimeend = '';
  30. //}
  31. queryJson["AddTimeFrom"] = logbegin;
  32. queryJson["AddTimeTo"] = logend;
  33. queryJson["MatType"] = $("#MatType").val();
  34. queryJson["Code"] = $("#Code").val();
  35. queryJson["Name"] = $("#Name").val();
  36. queryJson["StateNum"] = $("#Status").lrselectGet();
  37. queryJson["WarehouseId"] = $("#WarehouseId").lrselectGet();
  38. queryJson["Tunnel"] = $("#Tunnel").val();
  39. queryJson["Layer"] = $("#Layer").val();
  40. queryJson["SCRel"] = $("#SCRel").val();
  41. queryJson["Row"] = $("#Row").val();
  42. queryJson["Col"] = $("#Col").val();
  43. queryJson["GroupID"] = $("#GroupID").val();
  44. queryJson["Size"] = $("#Size").val();
  45. queryJson["ContGrpBarCode"] = $("#ContGrpBarCode").val();
  46. if ($("#IsStop").is(":checked")) {
  47. queryJson["IsStop"] = '1';
  48. } else {
  49. queryJson["IsStop"] = '0';
  50. }
  51. page.search({ queryJson: JSON.stringify(queryJson) });
  52. }, 250);
  53. // 查询
  54. $('#btn_Search').on('click', function () {
  55. var keyword = $('#txt_Keyword').val();
  56. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  57. });
  58. // 刷新
  59. $('#lr_refresh').on('click', function () {
  60. location.reload();
  61. });
  62. $('.datetime').each(function () {
  63. $(this).lrdatetime({
  64. dfdata: [
  65. { name: '今天', begin: function () { return learun.getDate('yyyy-MM-dd 00:00:00') }, end: function () { return learun.getDate('yyyy-MM-dd 23:59:59') } },
  66. { 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') } },
  67. { 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') } },
  68. { 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') } },
  69. ],
  70. // 月
  71. mShow: false,
  72. premShow: false,
  73. // 季度
  74. jShow: false,
  75. prejShow: false,
  76. // 年
  77. ysShow: false,
  78. yxShow: false,
  79. preyShow: false,
  80. yShow: false,
  81. // 默认
  82. dfvalue: 'all',
  83. selectfn: function (begin, end) {
  84. let id = $(this).attr('id');
  85. if (id == 'datesearch') {
  86. logbegin = begin;
  87. logend = end;
  88. }
  89. else if (id == 'StartTime') {
  90. StartTimeBegin = begin;
  91. StartTimeend = end;
  92. }
  93. else if (id == 'EndTime') {
  94. EndTimeBegin = begin;
  95. EndTimeend = end;
  96. }
  97. }
  98. });
  99. });
  100. $('#Type').lrselect({
  101. url: top.$.rootUrl + '/KLHCManager/Enums/GetTaskTypeList',
  102. maxHeight: 180,
  103. allowSearch: false
  104. });
  105. $('#Status').lrselect({
  106. url: top.$.rootUrl + '/KLHCManager/Enums/GetLocationStateList',
  107. maxHeight: 180,
  108. allowSearch: false
  109. });
  110. $('#WarehouseId').lrselect({
  111. url: top.$.rootUrl + '/KLHCManager/BaseWarehouse/GetSelectWarehouseNameList',
  112. maxHeight: 180,
  113. allowSearch: false
  114. });
  115. // 启用
  116. $('#lr_enable').on('click', function () {
  117. var postData = $('#gridtable').jfGridGet("rowdata");
  118. if (postData.length == 0) {
  119. learun.alert.error('未选择行!');
  120. return false;
  121. }
  122. learun.layerConfirm('是否确认启用该货位!', function (res) {
  123. if (res) {
  124. learun.postForm(top.$.rootUrl + '/KLHCManager/BaseWareCell/EnableWareCells', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  125. refreshGirdData();
  126. });
  127. }
  128. });
  129. });
  130. // 禁用
  131. $('#lr_disable').on('click', function () {
  132. var postData = $('#gridtable').jfGridGet("rowdata");
  133. if (postData.length == 0) {
  134. learun.alert.error('未选择行!');
  135. return false;
  136. }
  137. learun.layerConfirm('是否确认禁用该货位!', function (res) {
  138. if (res) {
  139. learun.postForm(top.$.rootUrl + '/KLHCManager/BaseWareCell/DisableWareCells', { ids: JSON.stringify(postData.map((item) => item.Id)) }, function () {
  140. refreshGirdData();
  141. });
  142. }
  143. });
  144. });
  145. // 新增
  146. $('#lr_add').on('click', function () {
  147. var keyValue = {};
  148. selectedRow = {};
  149. learun.layerForm({
  150. id: 'form',
  151. title: '添加货位',
  152. url: top.$.rootUrl + '/KLHCManager/BaseWareCell/Form',
  153. height: 500,
  154. width: 800,
  155. callBack: function (id) {
  156. return top[id].acceptClick(refreshGirdData);
  157. }
  158. });
  159. });
  160. // 编辑
  161. $('#lr_edit').on('click', function () {
  162. var keyValue = $('#gridtable').jfGridValue('Code');
  163. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  164. if (editSelRows.length == 0) {
  165. learun.alert.error('未选择行!');
  166. return false;
  167. }
  168. if (editSelRows.length > 1) {
  169. learun.alert.error('选择了多行!');
  170. return false;
  171. }
  172. selectedRow = editSelRows[0];
  173. if (learun.checkrow(keyValue)) {
  174. learun.layerForm({
  175. id: 'form',
  176. title: '编辑货位信息',
  177. url: top.$.rootUrl + '/KLHCManager/BaseWareCell/Form?keyValue=' + keyValue,
  178. height: 500,
  179. width: 800,
  180. callBack: function (id) {
  181. return top[id].acceptClick(refreshGirdData);
  182. }
  183. });
  184. }
  185. });
  186. $('#lr_size').on('click', function () {
  187. var keyValue = $('#gridtable').jfGridValue('Code');
  188. selectedRow = $('#gridtable').jfGridGet("rowdata");
  189. if (selectedRow.length == 0) {
  190. learun.alert.error('未选择行!');
  191. return false;
  192. }
  193. if (learun.checkrow(keyValue)) {
  194. learun.layerForm({
  195. id: 'form',
  196. title: '编辑货位值',
  197. url: top.$.rootUrl + '/KLHCManager/BaseWareCell/SizeForm?keyValue=' + keyValue,
  198. height: 300,
  199. width: 400,
  200. callBack: function (id) {
  201. return top[id].acceptClick(refreshGirdData);
  202. }
  203. });
  204. }
  205. });
  206. // 删除
  207. $('#lr_delete').on('click', function () {
  208. var keyValue = $('#gridtable').jfGridValue('Code');
  209. if (learun.checkrow(keyValue)) {
  210. learun.layerConfirm('是否确认删除该项!', function (res) {
  211. if (res) {
  212. learun.deleteForm(top.$.rootUrl + '/KLHCManager/BaseWareCell/Delete', { keyValue: keyValue }, function () {
  213. refreshGirdData();
  214. });
  215. }
  216. });
  217. }
  218. });
  219. },
  220. // 初始化列表
  221. initGird: function () {
  222. $('#gridtable').jfGrid({
  223. url: top.$.rootUrl + '/KLHCManager/BaseWareCell/GetPageList',
  224. headData: [
  225. { label: "仓库", name: "WarehouseName", width: 120, align: "left" },
  226. { label: "货物类型", name: "MatType", width: 50, align: "left" },
  227. { label: "货位号", name: "Code", width: 120, align: "left" },
  228. { label: "货位名称", name: "Name", width: 150, align: "left" },
  229. { label: "货位状态", name: "StatusName", width: 90, align: "left", sortname: "StateNum" },
  230. { label: "货位类型", name: "TypeName", width: 70, align: "left", sortname: "TypeNum" },
  231. {
  232. label: "是否停用", name: "IsStop", width: 70, align: "left", formatter: function (cellvalue) {
  233. if (cellvalue == 0) {
  234. return '<span class=\"label label-success\" >正常</span>';
  235. } else if (cellvalue == 1) {
  236. return '<span class=\"label label-default\" >停用</span>';
  237. } else {
  238. return '<span class=\"label label-default\" >未知</span>';
  239. }
  240. }
  241. },
  242. { label: "组ID", name: "GroupID", width: 160, align: "left" },
  243. { label: "货位值", name: "Size", width: 50, align: "left" },
  244. { label: "RFID条码", name: "ContGrpBarCode", width: 130, align: "left" },
  245. { label: "行", name: "Row", width: 50, align: "left" },
  246. { label: "列", name: "Col", width: 50, align: "left" },
  247. { label: "层", name: "Layer", width: 50, align: "left" },
  248. { label: "深度", name: "Depth", width: 50, align: "left" },
  249. { label: "设备", name: "SCRel", width: 60, align: "left" },
  250. { label: '出库跺型', name: 'XYNO', width: 100, align: 'left' },
  251. { label: "创建时间", name: "AddTime", width: 130, align: "left" },
  252. { label: "创建用户", name: "AddWho", width: 90, align: "left" },
  253. { label: "更新用户", name: "EditWho", width: 90, align: "left" },
  254. { label: "更新时间", name: "EditTime", width: 130, align: "left" },
  255. ],
  256. mainId: 'Id',
  257. isPage: true,
  258. reloadSelected: true,
  259. sidx: 'AddTime',
  260. isMultiselect: true,
  261. sord: 'DESC',
  262. });
  263. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  264. },
  265. search: function (param) {
  266. $('#gridtable').jfGridSet('reload', param);
  267. }
  268. };
  269. refreshGirdData = function () {
  270. $('#gridtable').jfGridSet('reload');
  271. };
  272. page.init();
  273. }