UserAccount_Admin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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: 'CreateDate', width: 200, title: '创建时间' ,sort: true},
  109. { field: 'UpdateDate', width: 160, title: '冻结/解冻时间' ,sort: true},
  110. { field: 'UpdateMan', width: 160, title: '操作信息' ,sort: true},
  111. {
  112. title: '操作',
  113. width: 400,
  114. align: 'center',
  115. fixed: 'right',
  116. toolbar: '#table-list-tools'
  117. }
  118. ]
  119. ],
  120. where: {
  121. UserId: UserId
  122. },
  123. page: true,
  124. limit: 30,
  125. height: 'full-' + String($('.layui-card-header').height() + 130),
  126. text: '对不起,加载出现异常!',
  127. done: function (res, curr, count) {
  128. $("#TotalAmount").text(res.other.TotalAmount);
  129. $("#FreezeAmount").text(res.other.FreezeAmount);
  130. $("#BalanceAmount").text(res.other.BalanceAmount);
  131. $(".layui-none").text("无数据");
  132. }
  133. });
  134. //监听工具条
  135. table.on('tool(LAY-list-manage)', function (obj) {
  136. var data = obj.data;
  137. if (obj.event === 'del') {
  138. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  139. $.ajax({
  140. type: "POST",
  141. url: "/Admin/UserAccount/Delete?r=" + Math.random(1),
  142. data: "Id=" + data.Id,
  143. dataType: "text",
  144. success: function (data) {
  145. if (data == "success") {
  146. obj.del();
  147. layer.close(index);
  148. } else {
  149. parent.layer.msg(data);
  150. }
  151. }
  152. });
  153. });
  154. } else if (obj.event === 'edit') {
  155. var tr = $(obj.tr);
  156. var perContent = layer.open({
  157. type: 2,
  158. title: '创客账户-编辑',
  159. content: 'Edit?Id=' + data.Id + '',
  160. maxmin: true,
  161. area: ['500px', '450px'],
  162. btn: ['确定', '取消'],
  163. yes: function (index, layero) {
  164. var iframeWindow = window['layui-layer-iframe' + index],
  165. submitID = 'LAY-list-front-submit',
  166. submit = layero.find('iframe').contents().find('#' + submitID);
  167. setTimeout(function () {
  168. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  169. var errObj = $(this).find('.layui-form-danger');
  170. if (errObj.length > 0) {
  171. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  172. submit.click();
  173. }
  174. });
  175. }, 300);
  176. //监听提交
  177. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  178. var field = data.field; //获取提交的字段
  179. var userdata = "";
  180. for (var prop in field) {
  181. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  182. }
  183. //提交 Ajax 成功后,静态更新表格中的数据
  184. //$.ajax({});
  185. $.ajax({
  186. type: "POST",
  187. url: "/Admin/UserAccount/Edit?r=" + Math.random(1),
  188. data: userdata,
  189. dataType: "text",
  190. success: function (data) {
  191. layer.close(index); //关闭弹层
  192. if (data == "success") {
  193. table.reload('LAY-list-manage'); //数据刷新
  194. } else {
  195. layer.msg(data);
  196. }
  197. }
  198. });
  199. });
  200. submit.trigger('click');
  201. },
  202. success: function (layero, index) {
  203. }
  204. });
  205. layer.full(perContent);
  206. } else if (obj.event === 'closeRemark') {
  207. var tr = $(obj.tr);
  208. var perContent = layer.open({
  209. type: 2,
  210. title: '创客账户冻结备注',
  211. content: 'CloseRemark?Id=' + data.Id + '',
  212. maxmin: true,
  213. area: ['510px', '300px'],
  214. btn: ['确定', '取消'],
  215. yes: function (index, layero) {
  216. var iframeWindow = window['layui-layer-iframe' + index],
  217. submitID = 'LAY-list-front-submit',
  218. submit = layero.find('iframe').contents().find('#' + submitID);
  219. setTimeout(function () {
  220. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  221. var errObj = $(this).find('.layui-form-danger');
  222. if (errObj.length > 0) {
  223. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  224. submit.click();
  225. }
  226. });
  227. }, 300);
  228. //监听提交
  229. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  230. var field = data.field; //获取提交的字段
  231. var userdata = "";
  232. for (var prop in field) {
  233. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  234. }
  235. //提交 Ajax 成功后,静态更新表格中的数据
  236. //$.ajax({});
  237. $.ajax({
  238. type: "POST",
  239. url: "/Admin/UserAccount/CloseRemark?r=" + Math.random(1),
  240. data: userdata,
  241. dataType: "text",
  242. success: function (data) {
  243. layer.close(index); //关闭弹层
  244. if (data == "success") {
  245. table.reload('LAY-list-manage'); //数据刷新
  246. } else {
  247. layer.msg(data);
  248. }
  249. }
  250. });
  251. });
  252. submit.trigger('click');
  253. },
  254. success: function (layero, index) {
  255. }
  256. });
  257. } else if (obj.event === 'Open') {
  258. var index = layer.confirm('是否确定解冻' + data.RealName + '的账户,恢复他提现?', function (index) {
  259. $.ajax({
  260. type: "POST",
  261. url: "/Admin/UserAccount/Open?r=" + Math.random(1),
  262. data: "Id=" + data.Id,
  263. dataType: "text",
  264. success: function (data) {
  265. layer.close(index); //关闭弹层
  266. if (data == "success") {
  267. layer.msg("已解冻", { time: 1500 }, function () {
  268. table.reload('LAY-list-manage'); //数据刷新
  269. });
  270. } else {
  271. parent.layer.msg(data);
  272. }
  273. }
  274. });
  275. });
  276. } else if (obj.event === 'Close') {
  277. var index = layer.confirm('是否确定冻结' + data.RealName + '的账户,禁止他提现?', function (index)
  278. {
  279. $.ajax({
  280. type: "POST",
  281. url: "/Admin/UserAccount/Close?r=" + Math.random(1),
  282. data: "Id=" + data.Id,
  283. dataType: "text",
  284. success: function (data) {
  285. layer.close(index); //关闭弹层
  286. if (data == "success") {
  287. layer.msg("已冻结", { time: 1500 }, function () {
  288. table.reload('LAY-list-manage'); //数据刷新
  289. });
  290. } else {
  291. parent.layer.msg(data);
  292. }
  293. }
  294. });
  295. });
  296. }
  297. });
  298. //监听搜索
  299. form.on('submit(LAY-list-front-search)', function (data) {
  300. var field = data.field;
  301. field.ShowFlag = 1;
  302. if (field.MakerCode == "" && field.RealName == "" && field.CreateDateData == "" && field.TopUserId == "" && field.AccountStatusSelect == "") {
  303. layer.alert('请输入查询条件');
  304. }
  305. else {
  306. //执行重载
  307. table.reload('LAY-list-manage', {
  308. where: field,
  309. page: {
  310. curr: 1
  311. }
  312. });
  313. }
  314. });
  315. form.on('submit(LAY-list-front-searchall)', function (data) {
  316. table.reload('LAY-list-manage', {
  317. where: null,
  318. page: {
  319. curr: 1
  320. }
  321. });
  322. });
  323. //事件
  324. var active = {
  325. batchdel: function () {
  326. var checkStatus = table.checkStatus('LAY-list-manage'),
  327. data = checkStatus.data; //得到选中的数据
  328. if (data.length < 1) {
  329. parent.layer.msg("请选择要删除的项");
  330. } else {
  331. var ids = "";
  332. $.each(data, function (index, value) {
  333. ids += data[index].Id + ",";
  334. });
  335. ids = ids.substring(0, ids.length - 1);
  336. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  337. $.ajax({
  338. type: "POST",
  339. url: "/Admin/UserAccount/Delete?r=" + Math.random(1),
  340. data: "Id=" + ids,
  341. dataType: "text",
  342. success: function (data) {
  343. layer.close(index);
  344. if (data == "success") {
  345. table.reload('LAY-list-manage');
  346. } else {
  347. layer.msg(data);
  348. }
  349. }
  350. });
  351. });
  352. }
  353. },
  354. add: function () {
  355. var perContent = layer.open({
  356. type: 2,
  357. title: '创客账户-添加',
  358. content: 'Add',
  359. maxmin: true,
  360. area: ['500px', '450px'],
  361. btn: ['确定', '取消'],
  362. yes: function (index, layero) {
  363. var iframeWindow = window['layui-layer-iframe' + index],
  364. submitID = 'LAY-list-front-submit',
  365. submit = layero.find('iframe').contents().find('#' + submitID);
  366. setTimeout(function () {
  367. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  368. var errObj = $(this).find('.layui-form-danger');
  369. if (errObj.length > 0) {
  370. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  371. submit.click();
  372. }
  373. });
  374. }, 300);
  375. //监听提交
  376. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  377. var field = data.field; //获取提交的字段
  378. var userdata = "";
  379. for (var prop in field) {
  380. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  381. }
  382. //提交 Ajax 成功后,静态更新表格中的数据
  383. //$.ajax({});
  384. $.ajax({
  385. type: "POST",
  386. url: "/Admin/UserAccount/Add?r=" + Math.random(1),
  387. data: userdata,
  388. dataType: "text",
  389. success: function (data) {
  390. layer.close(index); //关闭弹层
  391. if (data == "success") {
  392. table.reload('LAY-list-manage'); //数据刷新
  393. } else {
  394. layer.msg(data);
  395. }
  396. }
  397. });
  398. });
  399. submit.trigger('click');
  400. }
  401. });
  402. layer.full(perContent);
  403. },
  404. ImportData: function () {
  405. layer.open({
  406. type: 1,
  407. title: '导入',
  408. maxmin: false,
  409. area: ['460px', '180px'],
  410. content: $('#excelForm'),
  411. cancel: function () {}
  412. });
  413. },
  414. ExportExcel: function () {
  415. var userdata = $('#QueryForm').serialize();
  416. $.ajax({
  417. type: "POST",
  418. url: "/Admin/UserAccount/ExportExcel?r=" + Math.random(1),
  419. data: userdata,
  420. dataType: "json",
  421. success: function (data) {
  422. data.Obj.unshift(data.Fields);
  423. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  424. }
  425. });
  426. },
  427. Open: function () {
  428. var checkStatus = table.checkStatus('LAY-list-manage'),
  429. data = checkStatus.data; //得到选中的数据
  430. if (data.length < 1) {
  431. parent.layer.msg("请选择要开启的项");
  432. } else {
  433. var ids = "";
  434. $.each(data, function (index, value) {
  435. ids += data[index].Id + ",";
  436. });
  437. ids = ids.substring(0, ids.length - 1);
  438. var index = layer.confirm('确定要开启吗?', function (index) {
  439. $.ajax({
  440. type: "POST",
  441. url: "/Admin/UserAccount/Open?r=" + Math.random(1),
  442. data: "Id=" + ids,
  443. dataType: "text",
  444. success: function (data) {
  445. layer.close(index);
  446. if (data == "success") {
  447. table.reload('LAY-list-manage');
  448. } else {
  449. layer.msg(data);
  450. }
  451. }
  452. });
  453. });
  454. }
  455. },
  456. Close: function () {
  457. var checkStatus = table.checkStatus('LAY-list-manage'),
  458. data = checkStatus.data; //得到选中的数据
  459. if (data.length < 1) {
  460. parent.layer.msg("请选择要关闭的项");
  461. } else {
  462. var ids = "";
  463. $.each(data, function (index, value) {
  464. ids += data[index].Id + ",";
  465. });
  466. ids = ids.substring(0, ids.length - 1);
  467. var index = layer.confirm('确定要关闭吗?', function (index) {
  468. $.ajax({
  469. type: "POST",
  470. url: "/Admin/UserAccount/Close?r=" + Math.random(1),
  471. data: "Id=" + ids,
  472. dataType: "text",
  473. success: function (data) {
  474. layer.close(index);
  475. if (data == "success") {
  476. table.reload('LAY-list-manage');
  477. } else {
  478. layer.msg(data);
  479. }
  480. }
  481. });
  482. });
  483. }
  484. }
  485. };
  486. $('.layui-btn').on('click', function () {
  487. var type = $(this).data('type');
  488. active[type] ? active[type].call(this) : '';
  489. });
  490. });