AuthUsers_Admin.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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("导入成功", {
  11. time: 2000
  12. }, function () {
  13. window.location.reload();
  14. });
  15. } else if (data.indexOf("warning") == 0) {
  16. var datalist = data.split('|');
  17. layer.alert(datalist[0], {
  18. time: 20000
  19. }, function () {
  20. window.location.reload();
  21. });
  22. } else {
  23. layer.msg(data);
  24. }
  25. }
  26. });
  27. }
  28. layui.config({
  29. base: '/layuiadmin/' //静态资源所在路径
  30. }).extend({
  31. myexcel: 'layui/lay/modules/excel',
  32. index: 'lib/index' //主入口模块
  33. }).use(['index', 'table', 'excel', 'laydate'], function () {
  34. var $ = layui.$,
  35. form = layui.form,
  36. table = layui.table;
  37. //- 筛选条件-日期
  38. var laydate = layui.laydate;
  39. var layCreateDate = laydate.render({
  40. elem: '#CreateDate',
  41. type: 'date',
  42. range: true,
  43. trigger: 'click',
  44. change: function (value, date, endDate) {
  45. var op = true;
  46. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  47. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  48. op = false;
  49. layCreateDate.hint('日期范围请不要超过1个月');
  50. setTimeout(function () {
  51. $(".laydate-btns-confirm").addClass("laydate-disabled");
  52. }, 1);
  53. }
  54. } else {
  55. op = false;
  56. layCreateDate.hint('日期范围请不要超过1个月');
  57. setTimeout(function () {
  58. $(".laydate-btns-confirm").addClass("laydate-disabled");
  59. }, 1);
  60. }
  61. if (op) {
  62. $('#CreateDate').val(value);
  63. }
  64. }
  65. });
  66. //excel导入
  67. var excel = layui.excel;
  68. $('#ExcelFile').change(function (e) {
  69. var files = e.target.files;
  70. excel.importExcel(files, {}, function (data) {
  71. ExcelData = data[0].Sheet1;
  72. });
  73. });
  74. //监听单元格编辑
  75. table.on('edit(LAY-list-manage)', function (obj) {
  76. var value = obj.value //得到修改后的值
  77. ,
  78. data = obj.data //得到所在行所有键值
  79. ,
  80. field = obj.field; //得到字段
  81. if (field == "Sort") {
  82. $.ajax({
  83. type: "POST",
  84. url: "/Admin/Users/Sort?r=" + Math.random(1),
  85. data: "Id=" + data.Id + "&Sort=" + value,
  86. dataType: "text",
  87. success: function (data) {}
  88. });
  89. }
  90. });
  91. //列表数据
  92. table.render({
  93. elem: '#LAY-list-manage',
  94. url: '/Admin/Users/AuthIndexData' //模拟接口
  95. ,
  96. cols: [
  97. [{
  98. type: 'checkbox',
  99. fixed: 'left'
  100. }, {
  101. field: 'Id',
  102. width: 100,
  103. title: 'ID',
  104. sort: true
  105. }, {
  106. field: 'MakerCode',
  107. width: 200,
  108. title: '创客编号',
  109. sort: true
  110. }, {
  111. field: 'RealName',
  112. width: 200,
  113. title: '创客姓名',
  114. sort: true
  115. }, {
  116. field: 'CertId',
  117. width: 200,
  118. title: '身份证号',
  119. sort: true
  120. }, {
  121. field: 'SettleBankCardNo',
  122. width: 200,
  123. title: '银行卡号',
  124. sort: true
  125. }, {
  126. field: 'SettleBankCardName',
  127. width: 200,
  128. title: '银行名称',
  129. sort: true
  130. }, {
  131. field: 'Mobile',
  132. width: 200,
  133. title: '联系手机',
  134. sort: true
  135. }
  136. , {
  137. title: '操作',
  138. width: 1800,
  139. align: 'left',
  140. toolbar: '#table-list-tools'
  141. }
  142. ]
  143. ],
  144. where: {},
  145. page: true,
  146. limit: 30,
  147. height: 'full-' + String($('.layui-card-header').height() + 130),
  148. text: '对不起,加载出现异常!',
  149. done: function (res, curr, count) {
  150. $(".layui-none").text("无数据");
  151. }
  152. });
  153. //监听工具条
  154. table.on('tool(LAY-list-manage)', function (obj) {
  155. var data = obj.data;
  156. if (obj.event === 'Auth') {
  157. var index = layer.confirm('确定要认证吗?', function (index) {
  158. $.ajax({
  159. type: "POST",
  160. url: "/Admin/Users/Auth?r=" + Math.random(1),
  161. data: "Id=" + data.Id,
  162. dataType: "text",
  163. success: function (data) {
  164. if (data == "success") {
  165. layer.close(index);
  166. layer.msg("认证成功");
  167. } else {
  168. parent.layer.msg(data);
  169. }
  170. }
  171. });
  172. });
  173. }
  174. });
  175. //监听搜索
  176. form.on('submit(LAY-list-front-search)', function (data) {
  177. var field = data.field;
  178. //执行重载
  179. table.reload('LAY-list-manage', {
  180. where: field,
  181. page: {
  182. curr: 1
  183. }
  184. });
  185. });
  186. form.on('submit(LAY-list-front-searchall)', function (data) {
  187. table.reload('LAY-list-manage', {
  188. where: null,
  189. page: {
  190. curr: 1
  191. }
  192. });
  193. });
  194. //事件
  195. var active = {
  196. BatchAuth: function () {
  197. var checkStatus = table.checkStatus('LAY-list-manage'),
  198. data = checkStatus.data; //得到选中的数据
  199. if (data.length < 1) {
  200. parent.layer.msg("请选择要认证的项");
  201. } else {
  202. var ids = "";
  203. $.each(data, function (index, value) {
  204. ids += data[index].Id + ",";
  205. });
  206. ids = ids.substring(0, ids.length - 1);
  207. var index = layer.confirm('确定要认证吗?', function (index) {
  208. $.ajax({
  209. type: "POST",
  210. url: "/Admin/Users/Auth?r=" + Math.random(1),
  211. data: "Id=" + ids,
  212. dataType: "text",
  213. success: function (data) {
  214. layer.close(index);
  215. if (data == "success") {
  216. layer.msg("认证成功");
  217. table.reload('LAY-list-manage');
  218. } else {
  219. layer.msg(data);
  220. }
  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. });