UserCashRecord_Admin.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/UserCashRecord/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. function CheckImport(table, key, loadindex, index) {
  22. $.ajax({
  23. url: "/Admin/UserCashRecord/CheckImport?r=" + Math.random(1),
  24. data: "key=" + key,
  25. dataType: "text",
  26. success: function (data) {
  27. if (data.indexOf('success') == 0) {
  28. layer.msg("成功操作" + data.split('|')[1] + "笔提现申请", { time: 2000 }, function () {
  29. layer.close(index); //关闭弹层
  30. layer.close(loadindex);
  31. table.reload('LAY-list-manage'); //数据刷新
  32. });
  33. } else {
  34. layer.msg(data, { time: 1000 }, function () {
  35. CheckImport(table, key, loadindex, index);
  36. });
  37. }
  38. }
  39. });
  40. }
  41. var excel;
  42. layui.config({
  43. base: '/layuiadmin/' //静态资源所在路径
  44. }).extend({
  45. myexcel: 'layui/lay/modules/excel',
  46. index: 'lib/index' //主入口模块
  47. }).use(['index', 'table', 'excel', 'laydate'], function () {
  48. var $ = layui.$,
  49. form = layui.form,
  50. table = layui.table;
  51. //- 筛选条件-日期
  52. var laydate = layui.laydate;
  53. var layCreateDate = laydate.render({
  54. elem: '#CreateDate',
  55. type: 'date',
  56. range: true,
  57. trigger: 'click',
  58. change: function (value, date, endDate) {
  59. var op = true;
  60. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  61. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  62. op = false;
  63. layCreateDate.hint('日期范围请不要超过1个月');
  64. setTimeout(function () {
  65. $(".laydate-btns-confirm").addClass("laydate-disabled");
  66. }, 1);
  67. }
  68. } else {
  69. op = false;
  70. layCreateDate.hint('日期范围请不要超过1个月');
  71. setTimeout(function () {
  72. $(".laydate-btns-confirm").addClass("laydate-disabled");
  73. }, 1);
  74. }
  75. if (op) {
  76. $('#CreateDate').val(value);
  77. }
  78. }
  79. });
  80. //excel导入
  81. excel = layui.excel;
  82. $('#ExcelFile').change(function (e) {
  83. var files = e.target.files;
  84. excel.importExcel(files, {}, function (data) {
  85. ExcelData = data[0].sheet1;
  86. });
  87. });
  88. //监听单元格编辑
  89. table.on('edit(LAY-list-manage)', function (obj) {
  90. var value = obj.value //得到修改后的值
  91. ,
  92. data = obj.data //得到所在行所有键值
  93. ,
  94. field = obj.field; //得到字段
  95. if (field == "Sort") {
  96. $.ajax({
  97. type: "POST",
  98. url: "/Admin/UserCashRecord/Sort?r=" + Math.random(1),
  99. data: "Id=" + data.Id + "&Sort=" + value,
  100. dataType: "text",
  101. success: function (data) {}
  102. });
  103. }
  104. });
  105. //列表数据
  106. table.render({
  107. elem: '#LAY-list-manage',
  108. url: '/Admin/UserCashRecord/IndexData' //模拟接口
  109. ,
  110. cols: [
  111. [{
  112. type: 'checkbox',
  113. fixed: 'left'
  114. }, {
  115. field: 'CashOrderNo',
  116. width: 200,
  117. title: '提现单号',
  118. sort: true
  119. }, {
  120. field: 'MakerCode',
  121. width: 200,
  122. title: '创客编码',
  123. sort: true
  124. }, {
  125. field: 'RealName',
  126. width: 200,
  127. title: '创客名称',
  128. sort: true
  129. }, {
  130. field: 'IdCardNo',
  131. width: 200,
  132. title: '身份证号',
  133. sort: true
  134. }, {
  135. field: 'SettleBankCardNo',
  136. width: 200,
  137. title: '提现卡号',
  138. sort: true
  139. }, {
  140. field: 'SettleBankName',
  141. width: 200,
  142. title: '银行名称',
  143. sort: true
  144. }, {
  145. field: 'TradeType',
  146. width: 200,
  147. title: '交易类型',
  148. sort: true
  149. }, {
  150. field: 'TradeAmount',
  151. width: 200,
  152. title: '提现金额(元)',
  153. sort: true
  154. }, {
  155. field: 'ActualTradeAmount',
  156. width: 200,
  157. title: '发佣金额(元)',
  158. sort: true
  159. }, {
  160. field: 'ManageFee',
  161. width: 200,
  162. title: '交易扣税(元)',
  163. sort: true
  164. }, {
  165. field: 'TradeFee',
  166. width: 200,
  167. title: '交易手续费(元)',
  168. sort: true
  169. }, {
  170. field: 'StatusName',
  171. width: 200,
  172. title: '订单状态',
  173. templet: '#StatusTpl',
  174. sort: true
  175. }, {
  176. field: 'LockName',
  177. width: 200,
  178. title: '提现标记',
  179. sort: true
  180. }, {
  181. field: 'ReturnCode',
  182. width: 200,
  183. title: '提现服务返回编码',
  184. sort: true
  185. }, {
  186. field: 'ReturnMsg',
  187. width: 200,
  188. title: '提现服务返回信息',
  189. sort: true
  190. }, {
  191. field: 'SeoTitle',
  192. width: 200,
  193. title: '备注/代付返回信息',
  194. sort: true
  195. }, {
  196. field: 'CreateDate',
  197. width: 200,
  198. title: '创建时间',
  199. sort: true
  200. }, { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  201. ]
  202. ],
  203. where: {
  204. },
  205. page: true,
  206. limit: 30,
  207. height: 'full-' + String($('.layui-card-header').height() + 130),
  208. text: '对不起,加载出现异常!',
  209. done: function (res, curr, count) {
  210. $("#SuccessAmount").text(res.other.SuccessAmount);
  211. $("#FailAmount").text(res.other.FailAmount);
  212. $("#WaitAmount").text(res.other.WaitAmount);
  213. $("#WaitTaxAmount").text(res.other.WaitTaxAmount);
  214. $("#SuccessTaxAmount").text(res.other.SuccessTaxAmount);
  215. $("#FailTaxAmount").text(res.other.FailTaxAmount);
  216. $(".layui-none").text("无数据");
  217. }
  218. });
  219. //监听工具条
  220. table.on('tool(LAY-list-manage)', function (obj) {
  221. var data = obj.data;
  222. if (obj.event === 'del') {
  223. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  224. $.ajax({
  225. type: "POST",
  226. url: "/Admin/UserCashRecord/Delete?r=" + Math.random(1),
  227. data: "Id=" + data.Id,
  228. dataType: "text",
  229. success: function (data) {
  230. if (data == "success") {
  231. obj.del();
  232. layer.close(index);
  233. } else {
  234. parent.layer.msg(data);
  235. }
  236. }
  237. });
  238. });
  239. } else if (obj.event === 'cancel') {
  240. var index = layer.confirm('确定要解除吗?操作后不能恢复!', function (index) {
  241. $.ajax({
  242. type: "POST",
  243. url: "/Admin/UserCashRecord/Cancel?r=" + Math.random(1),
  244. data: "Id=" + data.Id,
  245. dataType: "text",
  246. success: function (data) {
  247. layer.close(index);
  248. if (data == "success") {
  249. parent.layer.msg('已解除');
  250. table.reload('LAY-list-manage'); //数据刷新
  251. } else {
  252. parent.layer.msg(data);
  253. }
  254. }
  255. });
  256. });
  257. } else if (obj.event === 'edit') {
  258. var tr = $(obj.tr);
  259. var perContent = layer.open({
  260. type: 2,
  261. title: '提现记录-编辑',
  262. content: 'Edit?Id=' + data.Id + '',
  263. maxmin: true,
  264. area: ['500px', '450px'],
  265. btn: ['确定', '取消'],
  266. yes: function (index, layero) {
  267. var iframeWindow = window['layui-layer-iframe' + index],
  268. submitID = 'LAY-list-front-submit',
  269. submit = layero.find('iframe').contents().find('#' + submitID);
  270. setTimeout(function () {
  271. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  272. var errObj = $(this).find('.layui-form-danger');
  273. if (errObj.length > 0) {
  274. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  275. submit.click();
  276. }
  277. });
  278. }, 300);
  279. //监听提交
  280. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  281. var field = data.field; //获取提交的字段
  282. var userdata = "";
  283. for (var prop in field) {
  284. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  285. }
  286. //提交 Ajax 成功后,静态更新表格中的数据
  287. //$.ajax({});
  288. $.ajax({
  289. type: "POST",
  290. url: "/Admin/UserCashRecord/Edit?r=" + Math.random(1),
  291. data: userdata,
  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. submit.trigger('click');
  304. },
  305. success: function (layero, index) {
  306. }
  307. });
  308. layer.full(perContent);
  309. } else if (obj.event === 'reduce') {
  310. var tr = $(obj.tr);
  311. var perContent = layer.open({
  312. type: 2,
  313. title: '拒绝处理',
  314. content: 'Reduce?Id=' + data.Id + '',
  315. maxmin: true,
  316. area: ['500px', '450px'],
  317. btn: ['确定', '取消'],
  318. yes: function (index, layero) {
  319. var iframeWindow = window['layui-layer-iframe' + index],
  320. submitID = 'LAY-list-front-submit',
  321. submit = layero.find('iframe').contents().find('#' + submitID);
  322. setTimeout(function () {
  323. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  324. var errObj = $(this).find('.layui-form-danger');
  325. if (errObj.length > 0) {
  326. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  327. submit.click();
  328. }
  329. });
  330. }, 300);
  331. //监听提交
  332. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  333. var field = data.field; //获取提交的字段
  334. var userdata = "";
  335. for (var prop in field) {
  336. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  337. }
  338. //提交 Ajax 成功后,静态更新表格中的数据
  339. //$.ajax({});
  340. $.ajax({
  341. type: "POST",
  342. url: "/Admin/UserCashRecord/ReduceDo?r=" + Math.random(1),
  343. data: userdata,
  344. dataType: "text",
  345. success: function (data) {
  346. layer.close(index); //关闭弹层
  347. if (data == "success") {
  348. table.reload('LAY-list-manage'); //数据刷新
  349. } else {
  350. layer.msg(data);
  351. }
  352. }
  353. });
  354. });
  355. submit.trigger('click');
  356. },
  357. success: function (layero, index) {
  358. }
  359. });
  360. }
  361. });
  362. //监听搜索
  363. form.on('submit(LAY-list-front-search)', function (data) {
  364. var field = data.field;
  365. //执行重载
  366. table.reload('LAY-list-manage', {
  367. where: field,
  368. page: {
  369. curr: 1
  370. }
  371. });
  372. });
  373. form.on('submit(LAY-list-front-searchall)', function (data) {
  374. table.reload('LAY-list-manage', {
  375. where: null,
  376. page: {
  377. curr: 1
  378. }
  379. });
  380. });
  381. //事件
  382. var active = {
  383. batchdel: function () {
  384. var checkStatus = table.checkStatus('LAY-list-manage'),
  385. data = checkStatus.data; //得到选中的数据
  386. if (data.length < 1) {
  387. parent.layer.msg("请选择要删除的项");
  388. } else {
  389. var ids = "";
  390. $.each(data, function (index, value) {
  391. ids += data[index].Id + ",";
  392. });
  393. ids = ids.substring(0, ids.length - 1);
  394. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  395. $.ajax({
  396. type: "POST",
  397. url: "/Admin/UserCashRecord/Delete?r=" + Math.random(1),
  398. data: "Id=" + ids,
  399. dataType: "text",
  400. success: function (data) {
  401. layer.close(index);
  402. if (data == "success") {
  403. table.reload('LAY-list-manage');
  404. } else {
  405. layer.msg(data);
  406. }
  407. }
  408. });
  409. });
  410. }
  411. },
  412. add: function () {
  413. var perContent = layer.open({
  414. type: 2,
  415. title: '提现记录-添加',
  416. content: 'Add',
  417. maxmin: true,
  418. area: ['500px', '450px'],
  419. btn: ['确定', '取消'],
  420. yes: function (index, layero) {
  421. var iframeWindow = window['layui-layer-iframe' + index],
  422. submitID = 'LAY-list-front-submit',
  423. submit = layero.find('iframe').contents().find('#' + submitID);
  424. setTimeout(function () {
  425. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  426. var errObj = $(this).find('.layui-form-danger');
  427. if (errObj.length > 0) {
  428. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  429. submit.click();
  430. }
  431. });
  432. }, 300);
  433. //监听提交
  434. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  435. var field = data.field; //获取提交的字段
  436. var userdata = "";
  437. for (var prop in field) {
  438. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  439. }
  440. //提交 Ajax 成功后,静态更新表格中的数据
  441. //$.ajax({});
  442. $.ajax({
  443. type: "POST",
  444. url: "/Admin/UserCashRecord/Add?r=" + Math.random(1),
  445. data: userdata,
  446. dataType: "text",
  447. success: function (data) {
  448. layer.close(index); //关闭弹层
  449. if (data == "success") {
  450. table.reload('LAY-list-manage'); //数据刷新
  451. } else {
  452. layer.msg(data);
  453. }
  454. }
  455. });
  456. });
  457. submit.trigger('click');
  458. }
  459. });
  460. layer.full(perContent);
  461. },
  462. ImportData: function () {
  463. var perContent = layer.open({
  464. type: 2
  465. , title: '提现结果导入'
  466. , content: 'Import'
  467. , maxmin: true
  468. , area: ['650px', '350px']
  469. , btn: ['确定', '取消']
  470. , yes: function (index, layero) {
  471. var iframeWindow = window['layui-layer-iframe' + index]
  472. , submitID = 'LAY-list-front-submit'
  473. , submit = layero.find('iframe').contents().find('#' + submitID);
  474. //监听提交
  475. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  476. var field = data.field; //获取提交的字段
  477. var userdata = "";
  478. for (var prop in field) {
  479. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  480. }
  481. //提交 Ajax 成功后,静态更新表格中的数据
  482. //$.ajax({});
  483. var loadindex = layer.load(1, {
  484. shade: [0.5, '#000']
  485. });
  486. $.ajax({
  487. type: "POST",
  488. url: "/Admin/UserCashRecord/ImportPost?r=" + Math.random(1),
  489. data: userdata,
  490. dataType: "text",
  491. success: function (data) {
  492. if (data.indexOf("success") == 0) {
  493. var datalist = data.split('|');
  494. var key = datalist[1];
  495. CheckImport(table, key, loadindex, index);
  496. } else {
  497. layer.msg(data);
  498. }
  499. }
  500. });
  501. });
  502. submit.trigger('click');
  503. }
  504. });
  505. },
  506. ExportExcel: function () {
  507. var userdata = '';
  508. $(".layuiadmin-card-header-auto input").each(function (i) {
  509. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  510. });
  511. $(".layuiadmin-card-header-auto select").each(function (i) {
  512. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  513. });
  514. $.ajax({
  515. type: "GET",
  516. url: "/Admin/UserCashRecord/ExportExcel?r=" + Math.random(1),
  517. data: userdata,
  518. dataType: "json",
  519. success: function (data) {
  520. data.Obj.unshift(data.Fields);
  521. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  522. }
  523. });
  524. },
  525. BatchSetting: function () {
  526. var checkStatus = table.checkStatus('LAY-list-manage'),
  527. data = checkStatus.data; //得到选中的数据
  528. if (data.length < 1) {
  529. parent.layer.msg("请选择要设置的项");
  530. } else {
  531. var ids = "";
  532. $.each(data, function (index, value) {
  533. ids += data[index].Id + ",";
  534. });
  535. ids = ids.substring(0, ids.length - 1);
  536. var index = layer.confirm('确定要设为成功状态吗?', function (index) {
  537. $.ajax({
  538. type: "POST",
  539. url: "/Admin/UserCashRecord/BatchSetting?r=" + Math.random(1),
  540. data: "Id=" + ids,
  541. dataType: "text",
  542. success: function (data) {
  543. layer.close(index);
  544. if (data == "success") {
  545. table.reload('LAY-list-manage');
  546. } else {
  547. layer.msg(data);
  548. }
  549. }
  550. });
  551. });
  552. }
  553. },
  554. Open: function () {
  555. var checkStatus = table.checkStatus('LAY-list-manage'),
  556. data = checkStatus.data; //得到选中的数据
  557. if (data.length < 1) {
  558. parent.layer.msg("请选择要开启的项");
  559. } else {
  560. var ids = "";
  561. $.each(data, function (index, value) {
  562. ids += data[index].Id + ",";
  563. });
  564. ids = ids.substring(0, ids.length - 1);
  565. var index = layer.confirm('确定要开启吗?', function (index) {
  566. $.ajax({
  567. type: "POST",
  568. url: "/Admin/UserCashRecord/Open?r=" + Math.random(1),
  569. data: "Id=" + ids,
  570. dataType: "text",
  571. success: function (data) {
  572. layer.close(index);
  573. if (data == "success") {
  574. table.reload('LAY-list-manage');
  575. } else {
  576. layer.msg(data);
  577. }
  578. }
  579. });
  580. });
  581. }
  582. },
  583. Close: function () {
  584. var checkStatus = table.checkStatus('LAY-list-manage'),
  585. data = checkStatus.data; //得到选中的数据
  586. if (data.length < 1) {
  587. parent.layer.msg("请选择要关闭的项");
  588. } else {
  589. var ids = "";
  590. $.each(data, function (index, value) {
  591. ids += data[index].Id + ",";
  592. });
  593. ids = ids.substring(0, ids.length - 1);
  594. var index = layer.confirm('确定要关闭吗?', function (index) {
  595. $.ajax({
  596. type: "POST",
  597. url: "/Admin/UserCashRecord/Close?r=" + Math.random(1),
  598. data: "Id=" + ids,
  599. dataType: "text",
  600. success: function (data) {
  601. layer.close(index);
  602. if (data == "success") {
  603. table.reload('LAY-list-manage');
  604. } else {
  605. layer.msg(data);
  606. }
  607. }
  608. });
  609. });
  610. }
  611. },
  612. Cash: function () {
  613. var checkStatus = table.checkStatus('LAY-list-manage'),
  614. data = checkStatus.data; //得到选中的数据
  615. if (data.length < 1) {
  616. parent.layer.msg("请选择要提交代付的项");
  617. } else {
  618. var ids = "";
  619. $.each(data, function (index, value) {
  620. ids += data[index].Id + ",";
  621. });
  622. ids = ids.substring(0, ids.length - 1);
  623. var index = layer.confirm('确定要提交到代付平台申请出款吗?', function (index) {
  624. $.ajax({
  625. type: "POST",
  626. url: "/Admin/UserCashRecord/Cash?r=" + Math.random(1),
  627. data: "Id=" + ids,
  628. dataType: "text",
  629. success: function (data) {
  630. layer.close(index);
  631. if (data == "success") {
  632. layer.msg('提交成功,请等待代付平台处理');
  633. table.reload('LAY-list-manage');
  634. } else {
  635. layer.msg(data);
  636. }
  637. }
  638. });
  639. });
  640. }
  641. },
  642. };
  643. $('.layui-btn').on('click', function () {
  644. var type = $(this).data('type');
  645. active[type] ? active[type].call(this) : '';
  646. });
  647. });