equipallotList.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. // $(document).ready(function () {
  2. // if ($('#totalPage').val() > 0) {
  3. // $('.nullData').hide();
  4. // $('#page').parent().show();
  5. // } else {
  6. // $('.nullData').show();
  7. // $('#page').parent().hide();
  8. // }
  9. // })
  10. // 时间插件初始化
  11. layui.use('laydate', function () {
  12. var laydate = layui.laydate;
  13. //执行一个laydate实例
  14. laydate.render({
  15. elem: '#test10' //指定元素
  16. , type: 'date'
  17. , range: true
  18. , done: function (value, date) {
  19. var dateArray = value.split(' - ')
  20. $('#begin').val(dateArray[0])
  21. $('#end').val(dateArray[1])
  22. }
  23. });
  24. });
  25. var topicid = []; //imei数组
  26. //遍历当前是否已经有选中状态
  27. function isCheck(){
  28. $('.check').each(function () {
  29. if($(this).prop("checked") == true){
  30. topicid.push($(this).parents('tr').find('.itemId').html());
  31. }
  32. })
  33. }
  34. // 单个复选框
  35. function checkAllSelect() {
  36. var CheckCount = 0;
  37. $('.check').each(function () {
  38. if ($(this).prop("checked") == true) {
  39. $(this).parents('tr').addClass('selectedColor');
  40. CheckCount++;
  41. if (!contains(topicid, $(this).parents('tr').find('.itemId').html())) {
  42. topicid.push($(this).parents('tr').find('.itemId').html());
  43. }
  44. } else {
  45. $(this).parents('tr').removeClass('selectedColor');
  46. removeByValue(topicid, $(this).parents('tr').find('.itemId').html())
  47. }
  48. });
  49. if (CheckCount == $('.check').length) {
  50. $('#checkAll').prop("checked", true);
  51. } else {
  52. $('#checkAll').prop("checked", false);
  53. }
  54. }
  55. //全选
  56. function checkAllFun(obj) {
  57. if (obj.prop("checked") == true) {
  58. $('.check').each(function () {
  59. $(this).prop("checked", true);
  60. $(this).parents('tr').addClass('selectedColor');
  61. if (!contains(topicid, $(this).parents('tr').find('.itemId').html())) {
  62. topicid.push($(this).parents('tr').find('.itemId').html());
  63. }
  64. });
  65. } else {
  66. $('.check').each(function () {
  67. $(this).parents('tr').removeClass('selectedColor');
  68. $(this).prop("checked", false);
  69. });
  70. topicid = [];
  71. }
  72. }
  73. //移除数组元素
  74. function removeByValue(arr, val) {
  75. for (var i = 0; i < arr.length; i++) {
  76. if (arr[i] == val) {
  77. arr.splice(i, 1);
  78. break;
  79. }
  80. }
  81. }
  82. //判断数组中是否包含元素
  83. function contains(arr, obj) {
  84. var i = arr.length;
  85. while (i--) {
  86. if (arr[i] === obj) {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92. // 分页初始化
  93. layui.use('laypage', function () {
  94. var laypage = layui.laypage;
  95. var uname = $('#uname').val()
  96. laypage.render({
  97. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  98. // , count: 30
  99. , count: $('#totalPage').val()
  100. ,theme: '#428BCA'
  101. , layout: ['prev', 'page', 'next', 'skip']
  102. , jump: function (obj) {
  103. topicid = [];
  104. $.ajax({
  105. url: 'allot_equip_list?uname=' + uname + '&page=' + obj.curr,
  106. type: 'get',
  107. success: function (data) {
  108. $('#table tbody').html('');
  109. $('#table tbody').html(data);
  110. if ($('#totalPage').val() > 0) {
  111. $('.nullData').hide();
  112. $('#page').parent().show();
  113. } else {
  114. $('.nullData').show();
  115. $('#page').parent().hide();
  116. }
  117. if ($('.content').height() > 750) {
  118. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  119. } else {
  120. $('#iframe-main', parent.document).css('height', '750px')
  121. }
  122. isCheck();
  123. }
  124. })
  125. }
  126. });
  127. });
  128. //设备筛选:
  129. function sub_filter() {
  130. var uname = $('#uname').val();
  131. var type = $('#type').val();
  132. var f_id = $('#identity').val();
  133. var begin = $('#begin').val();
  134. var end = $('#end').val();
  135. $("#data_table tr:not(:first)").html("");
  136. $.ajax({
  137. url: 'allot_equip_list',
  138. type: 'post',
  139. data: {
  140. req: "filter",
  141. uname: uname,
  142. type: type,
  143. f_id: f_id,
  144. begin: begin,
  145. end: end,
  146. page:1
  147. },
  148. success: function (data) {
  149. $('#table tbody').html('');
  150. $('#table tbody').html(data);
  151. if ($('#total_nums').val() > 0) {
  152. $('.nullData').hide();
  153. $('#page').parent().show();
  154. } else {
  155. $('.nullData').show();
  156. $('#page').parent().hide();
  157. }
  158. var datas = {
  159. req: "filter",
  160. uname: uname,
  161. type: type,
  162. f_id: f_id,
  163. begin: begin,
  164. end: end
  165. }
  166. initSearchPage($('#total_nums').val(),'allot_equip_list', datas);
  167. if ($('.content').height() > 750) {
  168. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  169. } else {
  170. $('#iframe-main', parent.document).css('height', '750px')
  171. }
  172. }
  173. })
  174. }
  175. //设备搜索分页
  176. function initSearchPage(page, url, datas) {
  177. layui.use('laypage', function () {
  178. var laypage = layui.laypage;
  179. var uname = $('#uname').val()
  180. laypage.render({
  181. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  182. // , count: 30
  183. , count: page
  184. ,theme: '#428BCA'
  185. , layout: ['prev', 'page', 'next', 'skip']
  186. , jump: function (obj, first) {
  187. datas.page = obj.curr;
  188. topicid = [];
  189. if (!first) {
  190. $.ajax({
  191. url: url,
  192. type: 'post',
  193. data: datas,
  194. success: function (data) {
  195. $('#table tbody').html('');
  196. $('#table tbody').html(data);
  197. if ($('#total_nums').val() > 0) {
  198. $('.nullData').hide();
  199. $('#page').parent().show();
  200. } else {
  201. $('.nullData').show();
  202. $('#page').parent().hide();
  203. }
  204. if ($('.content').height() > 750) {
  205. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  206. } else {
  207. $('#iframe-main', parent.document).css('height', '750px')
  208. }
  209. }
  210. })
  211. }
  212. }
  213. });
  214. });
  215. }
  216. //取消当提交分配时,没有选中设备---即,全部取消分配当前用户下的设备;:
  217. //分配操作
  218. // function allotOperate(){
  219. // if(topicid.length > 0){
  220. // return true;
  221. // }else{
  222. // layui.use('layer', function () {
  223. // var layer = layui.layer;
  224. // layer.msg('请至少选择一项进行分配!');
  225. // })
  226. // return false;
  227. // }
  228. // }