BatchSeeUserInfo_Admin.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. var ExcelData;
  2. var excel;
  3. layui.config({
  4. base: '/layuiadmin/' //静态资源所在路径
  5. }).extend({
  6. myexcel: 'layui/lay/modules/excel',
  7. index: 'lib/index' //主入口模块
  8. }).use(['index', 'table', 'excel', 'laydate'], function () {
  9. var $ = layui.$
  10. , form = layui.form
  11. , table = layui.table;
  12. //- 筛选条件-日期
  13. var laydate = layui.laydate;
  14. var layCreateDate = laydate.render({
  15. elem: '#CreateDate',
  16. type: 'date',
  17. range: true,
  18. trigger: 'click',
  19. change: function (value, date, endDate) {
  20. var op = true;
  21. if (date.year == endDate.year && endDate.month - date.month <= 2) {
  22. if (endDate.month - date.month == 2 && endDate.date > date.date) {
  23. op = false;
  24. layCreateDate.hint('日期范围请不要超过2个月');
  25. setTimeout(function () {
  26. $(".laydate-btns-confirm").addClass("laydate-disabled");
  27. }, 1);
  28. }
  29. } else {
  30. op = false;
  31. layCreateDate.hint('日期范围请不要超过2个月');
  32. setTimeout(function () {
  33. $(".laydate-btns-confirm").addClass("laydate-disabled");
  34. }, 1);
  35. }
  36. if (op) {
  37. $('#CreateDate').val(value);
  38. }
  39. }
  40. });
  41. //excel导入
  42. excel = layui.excel;
  43. $('#ExcelFile').change(function (e) {
  44. var files = e.target.files;
  45. excel.importExcel(files, {}, function (data) {
  46. ExcelData = data[0].sheet1;
  47. });
  48. });
  49. //列表数据
  50. table.render({
  51. elem: '#LAY-list-manage'
  52. , url: '/Admin/Users/BatchSeeUserInfoDo' //模拟接口
  53. , cols: [[
  54. { type: 'checkbox', fixed: 'left' }
  55. , { field: 'PosSn', width: 150, title: '机具Sn', sort: true }
  56. , { field: 'MerNo', width: 150, title: '商户编号', sort: true }
  57. , { field: 'PosFee', width: 150, title: '服务费', sort: true }
  58. , { field: 'BindingTime', width: 150, title: '绑定时间', sort: true }
  59. , { field: 'ActivationTime', width: 150, title: '激活时间', sort: true }
  60. , { field: 'MakerCode', width: 105, title: '创客编号', sort: true }
  61. , { field: 'RealName', width: 105, title: '创客姓名', sort: true }
  62. , { field: 'TopMakerCode', width: 160, title: '顶级创客编号', sort: true }
  63. , { field: 'TopRealName', width: 160, title: '顶级创客名称', sort: true }
  64. , { field: 'SecondMakerCode', width: 160, title: '次顶级创客编号', sort: true }
  65. , { field: 'SecondRealName', width: 160, title: '次顶级创客姓名', sort: true }
  66. , { field: 'ThirdMakerCode', width: 160, title: '次次顶级创客编号', sort: true }
  67. , { field: 'ThirdRealName', width: 160, title: '次次顶级创客姓名', sort: true }
  68. ]]
  69. , where: {
  70. }
  71. , page: true
  72. , limit: 30
  73. , height: 'full-' + String($('.layui-card-header').height() + 130)
  74. , text: '对不起,加载出现异常!'
  75. , done: function (res, curr, count) {
  76. $(".layui-none").text("无数据");
  77. }
  78. });
  79. //监听工具条
  80. table.on('tool(LAY-list-manage)', function (obj) {
  81. var data = obj.data;
  82. });
  83. //监听搜索
  84. form.on('submit(LAY-list-front-search)', function (data) {
  85. var field = data.field;
  86. //执行重载
  87. table.reload('LAY-list-manage', {
  88. where: field
  89. });
  90. });
  91. form.on('submit(LAY-list-front-searchall)', function (data) {
  92. table.reload('LAY-list-manage', {
  93. where: {
  94. UserId: UserId
  95. }
  96. });
  97. });
  98. //事件
  99. var active = {
  100. ImportData: function () {
  101. layer.open({
  102. type: 1,
  103. title: '导入',
  104. maxmin: false,
  105. area: ['460px', '180px'],
  106. content: $('#excelForm'),
  107. cancel: function () {
  108. }
  109. });
  110. }
  111. , ExportExcel: function () {
  112. var userdata = '';
  113. $(".layuiadmin-card-header-auto input").each(function (i) {
  114. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  115. });
  116. $(".layuiadmin-card-header-auto select").each(function (i) {
  117. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  118. });
  119. var index = layer.confirm('确定导出吗?', function (index) {
  120. var indexs = layer.load(1, {
  121. shade: [0.5, '#000']
  122. });
  123. $.ajax({
  124. type: "Post",
  125. url: "/Admin/Users/ExportBatchSeeUserInfoExcelDo?r=" + Math.random(1),
  126. data: userdata,
  127. dataType: "json",
  128. success: function (data) {
  129. layer.close(index); //关闭弹层
  130. if (data == "success") {
  131. layer.close(indexs); //关闭弹层
  132. layer.msg('成功', {
  133. time: 1000
  134. }, function () {
  135. window.location.reload();
  136. });
  137. } else {
  138. layer.close(indexs); //关闭弹层
  139. layer.msg(data);
  140. }
  141. }
  142. });
  143. });
  144. }
  145. };
  146. $('.layui-btn').on('click', function () {
  147. var type = $(this).data('type');
  148. active[type] ? active[type].call(this) : '';
  149. });
  150. });