BatchSeeUserInfo_Admin.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. batchdel: function () {
  101. var checkStatus = table.checkStatus('LAY-list-manage')
  102. , data = checkStatus.data; //得到选中的数据
  103. if (data.length < 1) {
  104. parent.layer.msg("请选择要删除的项");
  105. } else {
  106. var ids = "";
  107. $.each(data, function (index, value) {
  108. ids += data[index].Id + ",";
  109. });
  110. ids = ids.substring(0, ids.length - 1);
  111. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  112. $.ajax({
  113. type: "POST",
  114. // url: "/Admin/LeaderReserveRecord/Delete?r=" + Math.random(1),
  115. data: "Id=" + ids,
  116. dataType: "text",
  117. success: function (data) {
  118. layer.close(index);
  119. if (data == "success") {
  120. table.reload('LAY-list-manage');
  121. } else {
  122. layer.msg(data);
  123. }
  124. }
  125. });
  126. });
  127. }
  128. }
  129. , add: function () {
  130. var perContent = layer.open({
  131. type: 2
  132. , title: '盟主管理-添加'
  133. , content: 'Add'
  134. , maxmin: true
  135. , area: ['500px', '450px']
  136. , btn: ['确定', '取消']
  137. , yes: function (index, layero) {
  138. var iframeWindow = window['layui-layer-iframe' + index]
  139. , submitID = 'LAY-list-front-submit'
  140. , submit = layero.find('iframe').contents().find('#' + submitID);
  141. setTimeout(function () {
  142. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  143. var errObj = $(this).find('.layui-form-danger');
  144. if (errObj.length > 0) {
  145. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  146. submit.click();
  147. }
  148. });
  149. }, 300);
  150. //监听提交
  151. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  152. var field = data.field; //获取提交的字段
  153. var userdata = "";
  154. for (var prop in field) {
  155. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  156. }
  157. //提交 Ajax 成功后,静态更新表格中的数据
  158. //$.ajax({});
  159. $.ajax({
  160. type: "POST",
  161. // url: "/Admin/LeaderReserveRecord/Add?r=" + Math.random(1),
  162. data: userdata,
  163. dataType: "text",
  164. success: function (data) {
  165. layer.close(index); //关闭弹层
  166. if (data == "success") {
  167. table.reload('LAY-list-manage'); //数据刷新
  168. } else {
  169. layer.msg(data);
  170. }
  171. }
  172. });
  173. });
  174. submit.trigger('click');
  175. }
  176. });
  177. layer.full(perContent);
  178. }
  179. , ImportData: function () {
  180. ExcelKind = 1;
  181. layer.open({
  182. type: 1,
  183. title: '导入',
  184. maxmin: false,
  185. area: ['460px', '280px'],
  186. content: $('#excelForm'),
  187. cancel: function () {
  188. }
  189. });
  190. $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
  191. }
  192. , ExportExcel: function () {
  193. var userdata = '';
  194. $(".layuiadmin-card-header-auto input").each(function (i) {
  195. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  196. });
  197. $(".layuiadmin-card-header-auto select").each(function (i) {
  198. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  199. });
  200. var index = layer.confirm('确定导出吗?', function (index) {
  201. var indexs = layer.load(1, {
  202. shade: [0.5, '#000']
  203. });
  204. $.ajax({
  205. type: "Post",
  206. url: "/Admin/Users/ExportBatchSeeUserInfoExcelDo?r=" + Math.random(1),
  207. data: userdata,
  208. dataType: "text",
  209. success: function (data) {
  210. layer.close(index); //关闭弹层
  211. if (data == "success") {
  212. layer.close(indexs); //关闭弹层
  213. layer.msg('导出成功,请到我的下载中点击下载文件', {
  214. time: 1000
  215. }, function () {
  216. window.location.reload();
  217. });
  218. } else {
  219. layer.close(indexs); //关闭弹层
  220. layer.msg(data);
  221. }
  222. }
  223. });
  224. });
  225. }
  226. };
  227. $('.layui-btn').on('click', function () {
  228. var type = $(this).data('type');
  229. active[type] ? active[type].call(this) : '';
  230. });
  231. });