UserAccount_Admin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/UserAccount/Import?r=" + Math.random(1),
  6. data: "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 {
  16. layer.msg(data);
  17. }
  18. }
  19. });
  20. }
  21. var excel;
  22. layui.config({
  23. base: '/layuiadmin/' //静态资源所在路径
  24. }).extend({
  25. myexcel: 'layui/lay/modules/excel',
  26. index: 'lib/index' //主入口模块
  27. }).use(['index', 'table', 'excel', 'laydate'], function () {
  28. var $ = layui.$,
  29. form = layui.form,
  30. table = layui.table;
  31. //- 筛选条件-日期
  32. var laydate = layui.laydate;
  33. var layCreateDate = laydate.render({
  34. elem: '#CreateDate',
  35. type: 'date',
  36. range: true,
  37. trigger: 'click',
  38. change: function (value, date, endDate) {
  39. var op = true;
  40. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  41. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  42. op = false;
  43. layCreateDate.hint('日期范围请不要超过1个月');
  44. setTimeout(function () {
  45. $(".laydate-btns-confirm").addClass("laydate-disabled");
  46. }, 1);
  47. }
  48. } else {
  49. op = false;
  50. layCreateDate.hint('日期范围请不要超过1个月');
  51. setTimeout(function () {
  52. $(".laydate-btns-confirm").addClass("laydate-disabled");
  53. }, 1);
  54. }
  55. if (op) {
  56. $('#CreateDate').val(value);
  57. }
  58. }
  59. });
  60. //excel导入
  61. excel = layui.excel;
  62. $('#ExcelFile').change(function (e) {
  63. var files = e.target.files;
  64. excel.importExcel(files, {}, function (data) {
  65. ExcelData = data[0].sheet1;
  66. });
  67. });
  68. //监听单元格编辑
  69. table.on('edit(LAY-list-manage)', function (obj) {
  70. var value = obj.value //得到修改后的值
  71. ,
  72. data = obj.data //得到所在行所有键值
  73. ,
  74. field = obj.field; //得到字段
  75. if (field == "Sort") {
  76. $.ajax({
  77. type: "POST",
  78. url: "/Admin/UserAccount/Sort?r=" + Math.random(1),
  79. data: "Id=" + data.Id + "&Sort=" + value,
  80. dataType: "text",
  81. success: function (data) {}
  82. });
  83. }
  84. });
  85. //列表数据
  86. table.render({
  87. elem: '#LAY-list-manage',
  88. url: '/Admin/UserAccount/IndexData' //模拟接口
  89. ,
  90. cols: [
  91. [{
  92. type: 'checkbox',
  93. fixed: 'left'
  94. },
  95. { field: 'MakerCode', width: 110, title: '创客编号' ,sort: true},
  96. { field: 'RealName', width: 110, title: '创客姓名' ,sort: true},
  97. // { field: 'TopMakerCode', width: 200, title: '顶级创客编号' ,sort: true},
  98. // { field: 'TopRealName', width: 200, title: '顶级创客姓名' ,sort: true},
  99. { field: 'TotalAmount', width: 120, title: '账户总金额' ,sort: true},
  100. { field: 'FreezeAmount', width: 110, title: '冻结金额' ,sort: true},
  101. { field: 'BalanceAmount', width: 110, title: '余额' ,sort: true},
  102. { field: 'TempAmount', width: 110, title: '支付宝临时额度' ,sort: true},
  103. { field: 'TempAmountForBalance', width: 110, title: '余额临时额度' ,sort: true},
  104. { field: 'ThisMonthPreAmount', width: 110, title: '本月预发额度' ,sort: true},
  105. { field: 'ValidPreAmount', width: 110, title: '可用预发额度' ,sort: true},
  106. { field: 'AccountStatusName', width: 110, title: '账户状态' ,sort: true},
  107. { field: 'SeoDescription', width: 100, title: '备注' ,sort: true},
  108. { field: 'LeaderReserve', width: 100, title: '盟主储蓄金' ,sort: true},
  109. { field: 'LeaderBalanceAmount', width: 100, title: '盟主可提现余额' ,sort: true},
  110. // { field: 'CreateDate', width: 200, title: '创建时间' ,sort: true},
  111. { field: 'UpdateDate', width: 160, title: '冻结/解冻时间' ,sort: true},
  112. { field: 'UpdateMan', width: 160, title: '操作信息' ,sort: true},
  113. {
  114. title: '操作',
  115. width: 400,
  116. align: 'center',
  117. fixed: 'right',
  118. toolbar: '#table-list-tools'
  119. }
  120. ]
  121. ],
  122. where: {
  123. UserId: UserId
  124. },
  125. page: true,
  126. limit: 30,
  127. height: 'full-' + String($('.layui-card-header').height() + 130),
  128. text: '对不起,加载出现异常!',
  129. done: function (res, curr, count) {
  130. $("#TotalAmount").text(res.other.TotalAmount);
  131. $("#FreezeAmount").text(res.other.FreezeAmount);
  132. $("#BalanceAmount").text(res.other.BalanceAmount);
  133. $(".layui-none").text("无数据");
  134. }
  135. });
  136. //监听工具条
  137. table.on('tool(LAY-list-manage)', function (obj) {
  138. var data = obj.data;
  139. if (obj.event === 'del') {
  140. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  141. $.ajax({
  142. type: "POST",
  143. url: "/Admin/UserAccount/Delete?r=" + Math.random(1),
  144. data: "Id=" + data.Id,
  145. dataType: "text",
  146. success: function (data) {
  147. if (data == "success") {
  148. obj.del();
  149. layer.close(index);
  150. } else {
  151. parent.layer.msg(data);
  152. }
  153. }
  154. });
  155. });
  156. } else if (obj.event === 'edit') {
  157. var tr = $(obj.tr);
  158. var perContent = layer.open({
  159. type: 2,
  160. title: '创客账户-编辑',
  161. content: 'Edit?Id=' + data.Id + '',
  162. maxmin: true,
  163. area: ['500px', '450px'],
  164. btn: ['确定', '取消'],
  165. yes: function (index, layero) {
  166. var iframeWindow = window['layui-layer-iframe' + index],
  167. submitID = 'LAY-list-front-submit',
  168. submit = layero.find('iframe').contents().find('#' + submitID);
  169. setTimeout(function () {
  170. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  171. var errObj = $(this).find('.layui-form-danger');
  172. if (errObj.length > 0) {
  173. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  174. submit.click();
  175. }
  176. });
  177. }, 300);
  178. //监听提交
  179. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  180. var field = data.field; //获取提交的字段
  181. var userdata = "";
  182. for (var prop in field) {
  183. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  184. }
  185. //提交 Ajax 成功后,静态更新表格中的数据
  186. //$.ajax({});
  187. $.ajax({
  188. type: "POST",
  189. url: "/Admin/UserAccount/Edit?r=" + Math.random(1),
  190. data: userdata,
  191. dataType: "text",
  192. success: function (data) {
  193. layer.close(index); //关闭弹层
  194. if (data == "success") {
  195. table.reload('LAY-list-manage'); //数据刷新
  196. } else {
  197. layer.msg(data);
  198. }
  199. }
  200. });
  201. });
  202. submit.trigger('click');
  203. },
  204. success: function (layero, index) {
  205. }
  206. });
  207. layer.full(perContent);
  208. } else if (obj.event === 'closeRemark') {
  209. var tr = $(obj.tr);
  210. var perContent = layer.open({
  211. type: 2,
  212. title: '创客账户冻结备注',
  213. content: 'CloseRemark?Id=' + data.Id + '',
  214. maxmin: true,
  215. area: ['510px', '300px'],
  216. btn: ['确定', '取消'],
  217. yes: function (index, layero) {
  218. var iframeWindow = window['layui-layer-iframe' + index],
  219. submitID = 'LAY-list-front-submit',
  220. submit = layero.find('iframe').contents().find('#' + submitID);
  221. setTimeout(function () {
  222. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  223. var errObj = $(this).find('.layui-form-danger');
  224. if (errObj.length > 0) {
  225. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  226. submit.click();
  227. }
  228. });
  229. }, 300);
  230. //监听提交
  231. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  232. var field = data.field; //获取提交的字段
  233. var userdata = "";
  234. for (var prop in field) {
  235. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  236. }
  237. //提交 Ajax 成功后,静态更新表格中的数据
  238. //$.ajax({});
  239. $.ajax({
  240. type: "POST",
  241. url: "/Admin/UserAccount/CloseRemark?r=" + Math.random(1),
  242. data: userdata,
  243. dataType: "text",
  244. success: function (data) {
  245. layer.close(index); //关闭弹层
  246. if (data == "success") {
  247. table.reload('LAY-list-manage'); //数据刷新
  248. } else {
  249. layer.msg(data);
  250. }
  251. }
  252. });
  253. });
  254. submit.trigger('click');
  255. },
  256. success: function (layero, index) {
  257. }
  258. });
  259. } else if (obj.event === 'Open') {
  260. var index = layer.confirm('是否确定解冻' + data.RealName + '的账户,恢复他提现?', function (index) {
  261. $.ajax({
  262. type: "POST",
  263. url: "/Admin/UserAccount/Open?r=" + Math.random(1),
  264. data: "Id=" + data.Id,
  265. dataType: "text",
  266. success: function (data) {
  267. layer.close(index); //关闭弹层
  268. if (data == "success") {
  269. layer.msg("已解冻", { time: 1500 }, function () {
  270. table.reload('LAY-list-manage'); //数据刷新
  271. });
  272. } else {
  273. parent.layer.msg(data);
  274. }
  275. }
  276. });
  277. });
  278. } else if (obj.event === 'Close') {
  279. var index = layer.confirm('是否确定冻结' + data.RealName + '的账户,禁止他提现?', function (index)
  280. {
  281. $.ajax({
  282. type: "POST",
  283. url: "/Admin/UserAccount/Close?r=" + Math.random(1),
  284. data: "Id=" + data.Id,
  285. dataType: "text",
  286. success: function (data) {
  287. layer.close(index); //关闭弹层
  288. if (data == "success") {
  289. layer.msg("已冻结", { time: 1500 }, function () {
  290. table.reload('LAY-list-manage'); //数据刷新
  291. });
  292. } else {
  293. parent.layer.msg(data);
  294. }
  295. }
  296. });
  297. });
  298. }
  299. });
  300. //监听搜索
  301. form.on('submit(LAY-list-front-search)', function (data) {
  302. var field = data.field;
  303. field.ShowFlag = 1;
  304. if (field.MakerCode == "" && field.RealName == "" && field.CreateDateData == "" && field.TopUserId == "" && field.AccountStatusSelect == "") {
  305. layer.alert('请输入查询条件');
  306. }
  307. else {
  308. //执行重载
  309. table.reload('LAY-list-manage', {
  310. where: field,
  311. page: {
  312. curr: 1
  313. }
  314. });
  315. }
  316. });
  317. form.on('submit(LAY-list-front-searchall)', function (data) {
  318. table.reload('LAY-list-manage', {
  319. where: null,
  320. page: {
  321. curr: 1
  322. }
  323. });
  324. });
  325. //事件
  326. var active = {
  327. batchdel: function () {
  328. var checkStatus = table.checkStatus('LAY-list-manage'),
  329. data = checkStatus.data; //得到选中的数据
  330. if (data.length < 1) {
  331. parent.layer.msg("请选择要删除的项");
  332. } else {
  333. var ids = "";
  334. $.each(data, function (index, value) {
  335. ids += data[index].Id + ",";
  336. });
  337. ids = ids.substring(0, ids.length - 1);
  338. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  339. $.ajax({
  340. type: "POST",
  341. url: "/Admin/UserAccount/Delete?r=" + Math.random(1),
  342. data: "Id=" + ids,
  343. dataType: "text",
  344. success: function (data) {
  345. layer.close(index);
  346. if (data == "success") {
  347. table.reload('LAY-list-manage');
  348. } else {
  349. layer.msg(data);
  350. }
  351. }
  352. });
  353. });
  354. }
  355. },
  356. add: function () {
  357. var perContent = layer.open({
  358. type: 2,
  359. title: '创客账户-添加',
  360. content: 'Add',
  361. maxmin: true,
  362. area: ['500px', '450px'],
  363. btn: ['确定', '取消'],
  364. yes: function (index, layero) {
  365. var iframeWindow = window['layui-layer-iframe' + index],
  366. submitID = 'LAY-list-front-submit',
  367. submit = layero.find('iframe').contents().find('#' + submitID);
  368. setTimeout(function () {
  369. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  370. var errObj = $(this).find('.layui-form-danger');
  371. if (errObj.length > 0) {
  372. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  373. submit.click();
  374. }
  375. });
  376. }, 300);
  377. //监听提交
  378. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  379. var field = data.field; //获取提交的字段
  380. var userdata = "";
  381. for (var prop in field) {
  382. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  383. }
  384. //提交 Ajax 成功后,静态更新表格中的数据
  385. //$.ajax({});
  386. $.ajax({
  387. type: "POST",
  388. url: "/Admin/UserAccount/Add?r=" + Math.random(1),
  389. data: userdata,
  390. dataType: "text",
  391. success: function (data) {
  392. layer.close(index); //关闭弹层
  393. if (data == "success") {
  394. table.reload('LAY-list-manage'); //数据刷新
  395. } else {
  396. layer.msg(data);
  397. }
  398. }
  399. });
  400. });
  401. submit.trigger('click');
  402. }
  403. });
  404. layer.full(perContent);
  405. },
  406. ImportData: function () {
  407. layer.open({
  408. type: 1,
  409. title: '导入',
  410. maxmin: false,
  411. area: ['460px', '180px'],
  412. content: $('#excelForm'),
  413. cancel: function () {}
  414. });
  415. },
  416. ExportExcel: function () {
  417. var userdata = $('#QueryForm').serialize();
  418. $.ajax({
  419. type: "POST",
  420. url: "/Admin/UserAccount/ExportExcel?r=" + Math.random(1),
  421. data: userdata,
  422. dataType: "json",
  423. success: function (data) {
  424. data.Obj.unshift(data.Fields);
  425. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  426. }
  427. });
  428. },
  429. Open: function () {
  430. var checkStatus = table.checkStatus('LAY-list-manage'),
  431. data = checkStatus.data; //得到选中的数据
  432. if (data.length < 1) {
  433. parent.layer.msg("请选择要开启的项");
  434. } else {
  435. var ids = "";
  436. $.each(data, function (index, value) {
  437. ids += data[index].Id + ",";
  438. });
  439. ids = ids.substring(0, ids.length - 1);
  440. var index = layer.confirm('确定要开启吗?', function (index) {
  441. $.ajax({
  442. type: "POST",
  443. url: "/Admin/UserAccount/Open?r=" + Math.random(1),
  444. data: "Id=" + ids,
  445. dataType: "text",
  446. success: function (data) {
  447. layer.close(index);
  448. if (data == "success") {
  449. table.reload('LAY-list-manage');
  450. } else {
  451. layer.msg(data);
  452. }
  453. }
  454. });
  455. });
  456. }
  457. },
  458. Close: function () {
  459. var checkStatus = table.checkStatus('LAY-list-manage'),
  460. data = checkStatus.data; //得到选中的数据
  461. if (data.length < 1) {
  462. parent.layer.msg("请选择要关闭的项");
  463. } else {
  464. var ids = "";
  465. $.each(data, function (index, value) {
  466. ids += data[index].Id + ",";
  467. });
  468. ids = ids.substring(0, ids.length - 1);
  469. var index = layer.confirm('确定要关闭吗?', function (index) {
  470. $.ajax({
  471. type: "POST",
  472. url: "/Admin/UserAccount/Close?r=" + Math.random(1),
  473. data: "Id=" + ids,
  474. dataType: "text",
  475. success: function (data) {
  476. layer.close(index);
  477. if (data == "success") {
  478. table.reload('LAY-list-manage');
  479. } else {
  480. layer.msg(data);
  481. }
  482. }
  483. });
  484. });
  485. }
  486. }
  487. };
  488. $('.layui-btn').on('click', function () {
  489. var type = $(this).data('type');
  490. active[type] ? active[type].call(this) : '';
  491. });
  492. });