Index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 + '/PTManager/Enums/GetTaskTypeList',
  98. // maxHeight: 180,
  99. // allowSearch: false
  100. //});
  101. $('#Status').lrselect({
  102. url: top.$.rootUrl + '/PTManager/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 + '/PTManager/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 + '/PTManager/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 + '/PTManager/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. //selectedRow = $('#gridtable').jfGridGet('rowdata');
  155. let editSelRows = $('#gridtable').jfGridGet("rowdata");
  156. if (editSelRows.length == 0) {
  157. learun.alert.error('未选择行!');
  158. return false;
  159. }
  160. if (editSelRows.length > 1) {
  161. learun.alert.error('选择了多行!');
  162. return false;
  163. }
  164. selectedRow = editSelRows[0];
  165. if (learun.checkrow(keyValue)) {
  166. learun.layerForm({
  167. id: 'form',
  168. title: '编辑货位信息',
  169. url: top.$.rootUrl + '/PTManager/BaseWareCell/Form?keyValue=' + keyValue,
  170. height: 500,
  171. width: 800,
  172. callBack: function (id) {
  173. return top[id].acceptClick(refreshGirdData);
  174. }
  175. });
  176. }
  177. });
  178. // 删除
  179. $('#lr_delete').on('click', function () {
  180. var keyValue = $('#gridtable').jfGridValue('Code');
  181. if (learun.checkrow(keyValue)) {
  182. learun.layerConfirm('是否确认删除该项!', function (res) {
  183. if (res) {
  184. learun.deleteForm(top.$.rootUrl + '/PTManager/BaseWareCell/Delete', { keyValue: keyValue }, function () {
  185. refreshGirdData();
  186. });
  187. }
  188. });
  189. }
  190. });
  191. },
  192. // 初始化列表
  193. initGird: function () {
  194. $('#gridtable').jfGrid({
  195. url: top.$.rootUrl + '/PTManager/BaseWareCell/GetPageList',
  196. headData: [
  197. { label: "货位号", name: "Code", width: 120, align: "left" },
  198. { label: "货位名称", name: "Name", width: 150, align: "left" },
  199. { label: "货位状态", name: "StatusName", width: 90, align: "left", sortname: "StateNum" },
  200. { label: "货位类型", name: "TypeName", width: 70, align: "left", sortname: "TypeNum" },
  201. {
  202. label: "是否停用", name: "IsStop", width: 70, align: "left", formatter: function (cellvalue) {
  203. if (cellvalue == 0) {
  204. return '<span class=\"label label-success\" >正常</span>';
  205. } else if (cellvalue == 1) {
  206. return '<span class=\"label label-default\" >停用</span>';
  207. } else {
  208. return '<span class=\"label label-default\" >未知</span>';
  209. }
  210. }
  211. },
  212. { label: "巷道", name: "Tunnel", width: 50, align: "left" },
  213. { label: "RFID条码", name: "ContGrpBarCode", width: 130, align: "left" },
  214. { label: "行", name: "Row", width: 50, align: "left" },
  215. { label: "列", name: "Col", width: 50, align: "left" },
  216. { label: "层", name: "Layer", width: 50, align: "left" },
  217. { label: "深度", name: "Depth", width: 50, align: "left" },
  218. { label: "设备", name: "SCRel", width: 60, align: "left" },
  219. { label: "创建时间", name: "AddTime", width: 130, align: "left" },
  220. { label: "创建用户", name: "AddWho", width: 90, align: "left" },
  221. { label: "更新用户", name: "EditWho", width: 90, align: "left" },
  222. { label: "更新时间", name: "EditTime", width: 130, align: "left" },
  223. ],
  224. mainId: 'Id',
  225. isPage: true,
  226. reloadSelected: true,
  227. sidx: 'AddTime',
  228. isMultiselect: true,
  229. sord: 'DESC',
  230. });
  231. page.search({ queryJson: JSON.stringify({ keyword: $('#txt_Keyword').val() }) });
  232. },
  233. search: function (param) {
  234. $('#gridtable').jfGridSet('reload', param);
  235. }
  236. };
  237. refreshGirdData = function () {
  238. $('#gridtable').jfGridSet('reload');
  239. };
  240. page.init();
  241. }