UsersCancle_Admin.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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/CancleUsersData' //模拟接口
  90. , cols: [[
  91. { type: 'checkbox', fixed: 'left' }
  92. , { field: 'Id', width: 100, title: 'ID', sort: true }
  93. , { field: 'MakerCode', width: 200, title: '创客编号', sort: true, templet: '#MakerCodeTpl' }
  94. , { field: 'RealName', width: 200, title: '创客姓名', sort: true }
  95. , { field: 'UserLevel', width: 200, title: '创客等级', sort: true }
  96. , { field: 'AgentAreas', width: 200, title: '展业地区', sort: true }
  97. , { field: 'SettleAmount', width: 200, title: '提现金额(元)', sort: true }
  98. , { field: 'FreezeAmount', width: 200, title: '冻结金额(元)', sort: true }
  99. , { field: 'CertId', width: 200, title: '身份证号', sort: true }
  100. , { field: 'Mobile', width: 200, title: '联系手机', sort: true }
  101. , { field: 'MerchantType', width: 200, title: '商户创客类型', sort: true }
  102. , { field: 'MerchantDate', width: 200, title: '成为商户创客时间', sort: true }
  103. , { field: 'ParentMakerCode', width: 200, title: '直属创客编号', sort: true }
  104. , { field: 'ParentRealName', width: 200, title: '直属创客名称', sort: true }
  105. , { field: 'TopMakerCode', width: 200, title: '顶级创客编号', sort: true }
  106. , { field: 'TopRealName', width: 200, title: '顶级创客名称', sort: true }
  107. , { field: 'AuthFlagName', width: 200, title: '实名状态', sort: true }
  108. , { field: 'RiskFlagName', width: 200, title: '风控状态', sort: true }
  109. , { field: 'CreateDate', width: 200, title: '注册时间', sort: true }
  110. , { field: 'LogOutDate', width: 200, title: '注销时间', sort: true }
  111. , { title: '操作', width: 200, align: 'left', toolbar: '#table-list-tools' }
  112. ]]
  113. , where: {
  114. }
  115. , page: true
  116. , limit: 30
  117. , height: 'full-' + String($('.layui-card-header').height() + 130)
  118. , text: '对不起,加载出现异常!'
  119. , done: function (res, curr, count) {
  120. $(".layui-none").text("无数据");
  121. }
  122. });
  123. //监听工具条
  124. table.on('tool(LAY-list-manage)', function (obj) {
  125. var data = obj.data;
  126. if (obj.event === 'SetLogoutDate') {
  127. var index = layer.confirm('是否确定提前31天' + data.MakerCode + ',' + data.RealName + '的注销时间?', function (index) {
  128. $.ajax({
  129. type: "POST",
  130. url: "/Admin/Users/SetLogoutDate?r=" + Math.random(1),
  131. data: "Id=" + data.Id,
  132. dataType: "text",
  133. success: function (data) {
  134. layer.close(index); //关闭弹层
  135. if (data == 'success') {
  136. parent.layer.msg('设置成功');
  137. table.reload('LAY-list-manage'); //数据刷新
  138. } else {
  139. parent.layer.msg(data);
  140. }
  141. }
  142. });
  143. });
  144. }
  145. });
  146. //监听搜索
  147. form.on('submit(LAY-list-front-search)', function (data) {
  148. var field = data.field;
  149. //执行重载
  150. table.reload('LAY-list-manage', {
  151. where: field,
  152. page: {
  153. curr: 1
  154. }
  155. });
  156. });
  157. form.on('submit(LAY-list-front-searchall)', function (data) {
  158. table.reload('LAY-list-manage', {
  159. where: null,
  160. page: {
  161. curr: 1
  162. }
  163. });
  164. });
  165. //事件
  166. var active = {
  167. batchdel: function () {
  168. var checkStatus = table.checkStatus('LAY-list-manage')
  169. , data = checkStatus.data; //得到选中的数据
  170. if (data.length < 1) {
  171. parent.layer.msg("请选择要注销的项");
  172. } else {
  173. var ids = "";
  174. $.each(data, function (index, value) {
  175. ids += data[index].Id + ",";
  176. });
  177. ids = ids.substring(0, ids.length - 1);
  178. var index = layer.confirm('确定要注销吗?注销后不能恢复!', function (index) {
  179. $.ajax({
  180. type: "POST",
  181. url: "/Admin/Users/Delete?r=" + Math.random(1),
  182. data: "Id=" + ids,
  183. dataType: "text",
  184. success: function (data) {
  185. layer.close(index);
  186. if (data == "success") {
  187. table.reload('LAY-list-manage');
  188. } else {
  189. layer.msg(data);
  190. }
  191. }
  192. });
  193. });
  194. }
  195. }
  196. , add: function () {
  197. var perContent = layer.open({
  198. type: 2
  199. , title: '创客-添加'
  200. , content: 'Add'
  201. , maxmin: true
  202. , area: ['500px', '550px']
  203. , btn: ['确定', '取消']
  204. , yes: function (index, layero) {
  205. var iframeWindow = window['layui-layer-iframe' + index]
  206. , submitID = 'LAY-list-front-submit'
  207. , submit = layero.find('iframe').contents().find('#' + submitID);
  208. setTimeout(function () {
  209. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  210. var errObj = $(this).find('.layui-form-danger');
  211. if (errObj.length > 0) {
  212. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  213. submit.click();
  214. }
  215. });
  216. }, 300);
  217. //监听提交
  218. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  219. var field = data.field; //获取提交的字段
  220. var userdata = "";
  221. for (var prop in field) {
  222. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  223. }
  224. //提交 Ajax 成功后,静态更新表格中的数据
  225. //$.ajax({});
  226. $.ajax({
  227. type: "POST",
  228. url: "/Admin/Users/Add?r=" + Math.random(1),
  229. data: userdata,
  230. dataType: "text",
  231. success: function (data) {
  232. if (data == "success") {
  233. layer.close(index); //关闭弹层
  234. layer.msg('新增成功', { time: 1500 }, function () {
  235. table.reload('LAY-list-manage'); //数据刷新
  236. });
  237. } else {
  238. layer.msg(data);
  239. }
  240. }
  241. });
  242. });
  243. submit.trigger('click');
  244. }
  245. });
  246. }
  247. , Open: function () {
  248. var checkStatus = table.checkStatus('LAY-list-manage')
  249. , data = checkStatus.data; //得到选中的数据
  250. if (data.length < 1) {
  251. parent.layer.msg("请选择要开启的项");
  252. } else {
  253. var ids = "";
  254. $.each(data, function (index, value) {
  255. ids += data[index].Id + ",";
  256. });
  257. ids = ids.substring(0, ids.length - 1);
  258. var index = layer.confirm('确定要开启吗?', function (index) {
  259. $.ajax({
  260. type: "POST",
  261. url: "/Admin/Users/Open?r=" + Math.random(1),
  262. data: "Id=" + ids,
  263. dataType: "text",
  264. success: function (data) {
  265. layer.close(index);
  266. if (data == "success") {
  267. table.reload('LAY-list-manage');
  268. } else {
  269. layer.msg(data);
  270. }
  271. }
  272. });
  273. });
  274. }
  275. }
  276. , Close: function () {
  277. var checkStatus = table.checkStatus('LAY-list-manage')
  278. , data = checkStatus.data; //得到选中的数据
  279. if (data.length < 1) {
  280. parent.layer.msg("请选择要关闭的项");
  281. } else {
  282. var ids = "";
  283. $.each(data, function (index, value) {
  284. ids += data[index].Id + ",";
  285. });
  286. ids = ids.substring(0, ids.length - 1);
  287. var index = layer.confirm('确定要关闭吗?', function (index) {
  288. $.ajax({
  289. type: "POST",
  290. url: "/Admin/Users/Close?r=" + Math.random(1),
  291. data: "Id=" + ids,
  292. dataType: "text",
  293. success: function (data) {
  294. layer.close(index);
  295. if (data == "success") {
  296. table.reload('LAY-list-manage');
  297. } else {
  298. layer.msg(data);
  299. }
  300. }
  301. });
  302. });
  303. }
  304. }
  305. };
  306. $('.layui-btn').on('click', function () {
  307. var type = $(this).data('type');
  308. active[type] ? active[type].call(this) : '';
  309. });
  310. });