Index.js 11 KB

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