UsersCancle_Admin.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. ]]
  111. , where: {
  112. }
  113. , page: true
  114. , limit: 30
  115. , height: 'full-' + String($('.layui-card-header').height() + 130)
  116. , text: '对不起,加载出现异常!'
  117. , done: function (res, curr, count) {
  118. $(".layui-none").text("无数据");
  119. }
  120. });
  121. //监听工具条
  122. table.on('tool(LAY-list-manage)', function (obj) {
  123. var data = obj.data;
  124. });
  125. //监听搜索
  126. form.on('submit(LAY-list-front-search)', function (data) {
  127. var field = data.field;
  128. //执行重载
  129. table.reload('LAY-list-manage', {
  130. where: field,
  131. page: {
  132. curr: 1
  133. }
  134. });
  135. });
  136. form.on('submit(LAY-list-front-searchall)', function (data) {
  137. table.reload('LAY-list-manage', {
  138. where: null,
  139. page: {
  140. curr: 1
  141. }
  142. });
  143. });
  144. //事件
  145. var active = {
  146. batchdel: function () {
  147. var checkStatus = table.checkStatus('LAY-list-manage')
  148. , data = checkStatus.data; //得到选中的数据
  149. if (data.length < 1) {
  150. parent.layer.msg("请选择要注销的项");
  151. } else {
  152. var ids = "";
  153. $.each(data, function (index, value) {
  154. ids += data[index].Id + ",";
  155. });
  156. ids = ids.substring(0, ids.length - 1);
  157. var index = layer.confirm('确定要注销吗?注销后不能恢复!', function (index) {
  158. $.ajax({
  159. type: "POST",
  160. url: "/Admin/Users/Delete?r=" + Math.random(1),
  161. data: "Id=" + ids,
  162. dataType: "text",
  163. success: function (data) {
  164. layer.close(index);
  165. if (data == "success") {
  166. table.reload('LAY-list-manage');
  167. } else {
  168. layer.msg(data);
  169. }
  170. }
  171. });
  172. });
  173. }
  174. }
  175. , add: function () {
  176. var perContent = layer.open({
  177. type: 2
  178. , title: '创客-添加'
  179. , content: 'Add'
  180. , maxmin: true
  181. , area: ['500px', '550px']
  182. , btn: ['确定', '取消']
  183. , yes: function (index, layero) {
  184. var iframeWindow = window['layui-layer-iframe' + index]
  185. , submitID = 'LAY-list-front-submit'
  186. , submit = layero.find('iframe').contents().find('#' + submitID);
  187. setTimeout(function () {
  188. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  189. var errObj = $(this).find('.layui-form-danger');
  190. if (errObj.length > 0) {
  191. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  192. submit.click();
  193. }
  194. });
  195. }, 300);
  196. //监听提交
  197. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  198. var field = data.field; //获取提交的字段
  199. var userdata = "";
  200. for (var prop in field) {
  201. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  202. }
  203. //提交 Ajax 成功后,静态更新表格中的数据
  204. //$.ajax({});
  205. $.ajax({
  206. type: "POST",
  207. url: "/Admin/Users/Add?r=" + Math.random(1),
  208. data: userdata,
  209. dataType: "text",
  210. success: function (data) {
  211. if (data == "success") {
  212. layer.close(index); //关闭弹层
  213. layer.msg('新增成功', { time: 1500 }, function () {
  214. table.reload('LAY-list-manage'); //数据刷新
  215. });
  216. } else {
  217. layer.msg(data);
  218. }
  219. }
  220. });
  221. });
  222. submit.trigger('click');
  223. }
  224. });
  225. }
  226. , Open: function () {
  227. var checkStatus = table.checkStatus('LAY-list-manage')
  228. , data = checkStatus.data; //得到选中的数据
  229. if (data.length < 1) {
  230. parent.layer.msg("请选择要开启的项");
  231. } else {
  232. var ids = "";
  233. $.each(data, function (index, value) {
  234. ids += data[index].Id + ",";
  235. });
  236. ids = ids.substring(0, ids.length - 1);
  237. var index = layer.confirm('确定要开启吗?', function (index) {
  238. $.ajax({
  239. type: "POST",
  240. url: "/Admin/Users/Open?r=" + Math.random(1),
  241. data: "Id=" + ids,
  242. dataType: "text",
  243. success: function (data) {
  244. layer.close(index);
  245. if (data == "success") {
  246. table.reload('LAY-list-manage');
  247. } else {
  248. layer.msg(data);
  249. }
  250. }
  251. });
  252. });
  253. }
  254. }
  255. , Close: function () {
  256. var checkStatus = table.checkStatus('LAY-list-manage')
  257. , data = checkStatus.data; //得到选中的数据
  258. if (data.length < 1) {
  259. parent.layer.msg("请选择要关闭的项");
  260. } else {
  261. var ids = "";
  262. $.each(data, function (index, value) {
  263. ids += data[index].Id + ",";
  264. });
  265. ids = ids.substring(0, ids.length - 1);
  266. var index = layer.confirm('确定要关闭吗?', function (index) {
  267. $.ajax({
  268. type: "POST",
  269. url: "/Admin/Users/Close?r=" + Math.random(1),
  270. data: "Id=" + ids,
  271. dataType: "text",
  272. success: function (data) {
  273. layer.close(index);
  274. if (data == "success") {
  275. table.reload('LAY-list-manage');
  276. } else {
  277. layer.msg(data);
  278. }
  279. }
  280. });
  281. });
  282. }
  283. }
  284. };
  285. $('.layui-btn').on('click', function () {
  286. var type = $(this).data('type');
  287. active[type] ? active[type].call(this) : '';
  288. });
  289. });