SanUsers_Admin.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. var ExcelData, ExcelKind;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/Users/Import?r=" + Math.random(1),
  6. data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
  7. dataType: "text",
  8. success: function (data) {
  9. if (data == "success") {
  10. layer.msg("导入成功", { time: 2000 }, function () {
  11. window.location.reload();
  12. });
  13. } else if (data.indexOf("warning") == 0) {
  14. var datalist = data.split('|');
  15. layer.alert(datalist[0], { time: 20000 }, function () {
  16. window.location.reload();
  17. });
  18. } else {
  19. layer.msg(data);
  20. }
  21. }
  22. });
  23. }
  24. layui.config({
  25. base: '/layuiadmin/' //静态资源所在路径
  26. }).extend({
  27. myexcel: 'layui/lay/modules/excel',
  28. index: 'lib/index' //主入口模块
  29. }).use(['index', 'table', 'excel', 'laydate'], function () {
  30. var $ = layui.$
  31. , form = layui.form
  32. , table = layui.table;
  33. //- 筛选条件-日期
  34. var laydate = layui.laydate;
  35. var layCreateDate = laydate.render({
  36. elem: '#CreateDate',
  37. type: 'date',
  38. range: true,
  39. trigger: 'click',
  40. change: function (value, date, endDate) {
  41. var op = true;
  42. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  43. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  44. op = false;
  45. layCreateDate.hint('日期范围请不要超过1个月');
  46. setTimeout(function () {
  47. $(".laydate-btns-confirm").addClass("laydate-disabled");
  48. }, 1);
  49. }
  50. } else {
  51. op = false;
  52. layCreateDate.hint('日期范围请不要超过1个月');
  53. setTimeout(function () {
  54. $(".laydate-btns-confirm").addClass("laydate-disabled");
  55. }, 1);
  56. }
  57. if (op) {
  58. $('#CreateDate').val(value);
  59. }
  60. }
  61. });
  62. //excel导入
  63. var excel = layui.excel;
  64. $('#ExcelFile').change(function (e) {
  65. var files = e.target.files;
  66. excel.importExcel(files, {}, function (data) {
  67. ExcelData = data[0].Sheet1;
  68. });
  69. });
  70. //监听单元格编辑
  71. table.on('edit(LAY-list-manage)', function (obj) {
  72. var value = obj.value //得到修改后的值
  73. , data = obj.data //得到所在行所有键值
  74. , field = obj.field; //得到字段
  75. if (field == "Sort") {
  76. $.ajax({
  77. type: "POST",
  78. url: "/Admin/Users/Sort?r=" + Math.random(1),
  79. data: "Id=" + data.Id + "&Sort=" + value,
  80. dataType: "text",
  81. success: function (data) {
  82. }
  83. });
  84. }
  85. });
  86. //列表数据
  87. table.render({
  88. elem: '#LAY-list-manage'
  89. , url: '/Admin/Users/SanIndexData' //模拟接口
  90. , cols: [[
  91. { type: 'checkbox', fixed: 'left' }
  92. , { field: 'Id', width: 100, title: 'ID', sort: true }
  93. , { field: 'MakerCode', width: 200, title: '创客编号', sort: true }
  94. , { field: 'RealName', width: 200, title: '创客姓名', sort: true }
  95. , { field: 'UserLevel', width: 200, title: '创客等级', sort: true }
  96. , { field: 'UserYsLevel', width: 200, title: '预设等级', sort: true }
  97. , { field: 'IsLeader', width: 200, title: '是否盟主', sort: true }
  98. , { field: 'IsOp', width: 200, title: '是否运营中心', sort: true }
  99. , { field: 'AgentAreas', width: 200, title: '展业地区', sort: true }
  100. , { field: 'SettleAmount', width: 200, title: '提现金额(元)', sort: true }
  101. , { field: 'FreezeAmount', width: 200, title: '冻结金额(元)', sort: true }
  102. , { field: 'CertId', width: 200, title: '身份证号', sort: true }
  103. , { field: 'Mobile', width: 200, title: '联系手机', sort: true }
  104. , { field: 'MerchantType', width: 200, title: '商户创客类型', sort: true }
  105. , { field: 'MerchantDate', width: 200, title: '成为商户创客时间', sort: true }
  106. , { field: 'ParentMakerCode', width: 200, title: '直属创客编号', sort: true }
  107. , { field: 'ParentRealName', width: 200, title: '直属创客名称', sort: true }
  108. , { field: 'AuthFlagName', width: 200, title: '实名状态', sort: true }
  109. , { field: 'RiskFlagName', width: 200, title: '风控状态', sort: true }
  110. , { field: 'CreateDate', width: 200, title: '注册时间', sort: true }
  111. ]]
  112. , where: {
  113. }
  114. , page: true
  115. , limit: 30
  116. , height: 'full-' + String($('.layui-card-header').height() + 130)
  117. , text: '对不起,加载出现异常!'
  118. , done: function (res, curr, count) {
  119. $(".layui-none").text("无数据");
  120. }
  121. });
  122. //监听工具条
  123. //监听搜索
  124. form.on('submit(LAY-list-front-search)', function (data) {
  125. var field = data.field;
  126. field.ShowFlag = 1;
  127. if (field.MakerCode == "" && field.CreateDateData == "" && field.IsLeader == "" && field.IsOp == "" && field.UserLevel == "" && field.UserYsLevel == "") {
  128. layer.alert('请输入查询条件');
  129. }
  130. else {
  131. //执行重载
  132. table.reload('LAY-list-manage', {
  133. where: field
  134. });
  135. }
  136. });
  137. form.on('submit(LAY-list-front-searchall)', function (data) {
  138. var field = data.field;
  139. field.ShowFlag = 1;
  140. field.MakerCode = "";
  141. field.CreateDateData = "";
  142. field.IsLeader = "";
  143. field.IsOp = "";
  144. field.UserLevel = "";
  145. field.UserYsLevel = "";
  146. table.reload('LAY-list-manage', {
  147. where: field,
  148. page: {
  149. curr: 1
  150. }
  151. });
  152. });
  153. // $('.layui-btn').on('click', function () {
  154. // var type = $(this).data('type');
  155. // active[type] ? active[type].call(this) : '';
  156. // });
  157. });