BatchSeeUserInfo_Admin.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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: 'BrandName', width: 150, title: '机具类型', sort: true }
  56. , { field: 'BindingTime', width: 150, title: '绑定时间', sort: true }
  57. , { field: 'ActivationTime', width: 150, title: '激活时间', sort: true }
  58. , { field: 'MerchantName', width: 150, title: '商户姓名', sort: true }
  59. , { field: 'PosSn', width: 150, title: '机具Sn', sort: true }
  60. , { field: 'MerNo', width: 150, title: '商户编号', sort: true }
  61. , { field: 'userInfo', width: 150, title: '创客信息', sort: true }
  62. // , { field: 'MakerCode', width: 105, title: '创客编号', sort: true }
  63. // , { field: 'RealName', width: 105, title: '创客姓名', sort: true }
  64. , { field: 'Mobile', width: 150, title: '创客手机号', sort: true }
  65. , { field: 'Balance', width: 150, title: '创客账户余额', sort: true }
  66. , { field: 'PosFee', width: 150, title: '服务费', sort: true }
  67. , { field: 'TopMakerCode', width: 160, title: '顶级创客编号', sort: true }
  68. , { field: 'TopRealName', width: 160, title: '顶级创客名称', sort: true }
  69. , { field: 'SecondMakerCode', width: 160, title: '次顶级创客编号', sort: true }
  70. , { field: 'SecondRealName', width: 160, title: '次顶级创客姓名', sort: true }
  71. , { field: 'ThirdMakerCode', width: 160, title: '次次顶级创客编号', sort: true }
  72. , { field: 'ThirdRealName', width: 160, title: '次次顶级创客姓名', sort: true }
  73. ]]
  74. , where: {
  75. }
  76. , page: true
  77. , limit: 30
  78. , height: 'full-' + String($('.layui-card-header').height() + 130)
  79. , text: '对不起,加载出现异常!'
  80. , done: function (res, curr, count) {
  81. $(".layui-none").text("无数据");
  82. }
  83. });
  84. //监听工具条
  85. table.on('tool(LAY-list-manage)', function (obj) {
  86. var data = obj.data;
  87. });
  88. //监听搜索
  89. form.on('submit(LAY-list-front-search)', function (data) {
  90. var field = data.field;
  91. //执行重载
  92. table.reload('LAY-list-manage', {
  93. where: field
  94. });
  95. });
  96. form.on('submit(LAY-list-front-searchall)', function (data) {
  97. table.reload('LAY-list-manage', {
  98. where: {
  99. UserId: UserId
  100. }
  101. });
  102. });
  103. //事件
  104. var active = {
  105. batchdel: function () {
  106. var checkStatus = table.checkStatus('LAY-list-manage')
  107. , data = checkStatus.data; //得到选中的数据
  108. if (data.length < 1) {
  109. parent.layer.msg("请选择要删除的项");
  110. } else {
  111. var ids = "";
  112. $.each(data, function (index, value) {
  113. ids += data[index].Id + ",";
  114. });
  115. ids = ids.substring(0, ids.length - 1);
  116. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  117. $.ajax({
  118. type: "POST",
  119. // url: "/Admin/LeaderReserveRecord/Delete?r=" + Math.random(1),
  120. data: "Id=" + ids,
  121. dataType: "text",
  122. success: function (data) {
  123. layer.close(index);
  124. if (data == "success") {
  125. table.reload('LAY-list-manage');
  126. } else {
  127. layer.msg(data);
  128. }
  129. }
  130. });
  131. });
  132. }
  133. }
  134. , add: function () {
  135. var perContent = layer.open({
  136. type: 2
  137. , title: '盟主管理-添加'
  138. , content: 'Add'
  139. , maxmin: true
  140. , area: ['500px', '450px']
  141. , btn: ['确定', '取消']
  142. , yes: function (index, layero) {
  143. var iframeWindow = window['layui-layer-iframe' + index]
  144. , submitID = 'LAY-list-front-submit'
  145. , submit = layero.find('iframe').contents().find('#' + submitID);
  146. setTimeout(function () {
  147. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  148. var errObj = $(this).find('.layui-form-danger');
  149. if (errObj.length > 0) {
  150. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  151. submit.click();
  152. }
  153. });
  154. }, 300);
  155. //监听提交
  156. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  157. var field = data.field; //获取提交的字段
  158. var userdata = "";
  159. for (var prop in field) {
  160. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  161. }
  162. //提交 Ajax 成功后,静态更新表格中的数据
  163. //$.ajax({});
  164. $.ajax({
  165. type: "POST",
  166. // url: "/Admin/LeaderReserveRecord/Add?r=" + Math.random(1),
  167. data: userdata,
  168. dataType: "text",
  169. success: function (data) {
  170. layer.close(index); //关闭弹层
  171. if (data == "success") {
  172. table.reload('LAY-list-manage'); //数据刷新
  173. } else {
  174. layer.msg(data);
  175. }
  176. }
  177. });
  178. });
  179. submit.trigger('click');
  180. }
  181. });
  182. layer.full(perContent);
  183. }
  184. , ImportData: function () {
  185. ExcelKind = 1;
  186. layer.open({
  187. type: 1,
  188. title: '导入',
  189. maxmin: false,
  190. area: ['460px', '280px'],
  191. content: $('#excelForm'),
  192. cancel: function () {
  193. }
  194. });
  195. $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
  196. }
  197. , ExportExcel: function () {
  198. var userdata = '';
  199. $(".layuiadmin-card-header-auto input").each(function (i) {
  200. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  201. });
  202. $(".layuiadmin-card-header-auto select").each(function (i) {
  203. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  204. });
  205. var index = layer.confirm('确定导出吗?', function (index) {
  206. var indexs = layer.load(1, {
  207. shade: [0.5, '#000']
  208. });
  209. $.ajax({
  210. type: "Post",
  211. url: "/Admin/Users/ExportBatchSeeUserInfoExcelDo?r=" + Math.random(1),
  212. data: userdata,
  213. dataType: "text",
  214. success: function (data) {
  215. layer.close(index); //关闭弹层
  216. if (data == "success") {
  217. layer.close(indexs); //关闭弹层
  218. layer.msg('导出成功,请到我的下载中点击下载文件', {
  219. time: 1000
  220. }, function () {
  221. window.location.reload();
  222. });
  223. } else {
  224. layer.close(indexs); //关闭弹层
  225. layer.msg(data);
  226. }
  227. }
  228. });
  229. });
  230. }
  231. };
  232. $('.layui-btn').on('click', function () {
  233. var type = $(this).data('type');
  234. active[type] ? active[type].call(this) : '';
  235. });
  236. });