UserCashRecord_Admin.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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: 'SeoKeyword',
  192. width: 200,
  193. title: '备注',
  194. sort: true
  195. }, {
  196. field: 'Remark',
  197. width: 200,
  198. title: '代付返回信息',
  199. sort: true
  200. }, {
  201. field: 'CreateDate',
  202. width: 200,
  203. title: '创建时间',
  204. sort: true
  205. }, { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  206. ]
  207. ],
  208. where: {
  209. },
  210. page: true,
  211. limit: 30,
  212. height: 'full-' + String($('.layui-card-header').height() + 130),
  213. text: '对不起,加载出现异常!',
  214. done: function (res, curr, count) {
  215. $("#SuccessAmount").text(res.other.SuccessAmount);
  216. $("#FailAmount").text(res.other.FailAmount);
  217. $("#WaitAmount").text(res.other.WaitAmount);
  218. $("#WaitTaxAmount").text(res.other.WaitTaxAmount);
  219. $("#SuccessTaxAmount").text(res.other.SuccessTaxAmount);
  220. $("#FailTaxAmount").text(res.other.FailTaxAmount);
  221. $(".layui-none").text("无数据");
  222. }
  223. });
  224. //监听工具条
  225. table.on('tool(LAY-list-manage)', function (obj) {
  226. var data = obj.data;
  227. if (obj.event === 'del') {
  228. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  229. $.ajax({
  230. type: "POST",
  231. url: "/Admin/UserCashRecord/Delete?r=" + Math.random(1),
  232. data: "Id=" + data.Id,
  233. dataType: "text",
  234. success: function (data) {
  235. if (data == "success") {
  236. obj.del();
  237. layer.close(index);
  238. } else {
  239. parent.layer.msg(data);
  240. }
  241. }
  242. });
  243. });
  244. } else if (obj.event === 'cancel') {
  245. var index = layer.confirm('确定要解除吗?操作后不能恢复!', function (index) {
  246. $.ajax({
  247. type: "POST",
  248. url: "/Admin/UserCashRecord/Cancel?r=" + Math.random(1),
  249. data: "Id=" + data.Id,
  250. dataType: "text",
  251. success: function (data) {
  252. layer.close(index);
  253. if (data == "success") {
  254. parent.layer.msg('已解除');
  255. table.reload('LAY-list-manage'); //数据刷新
  256. } else {
  257. parent.layer.msg(data);
  258. }
  259. }
  260. });
  261. });
  262. } else if (obj.event === 'refund') {
  263. var index = layer.confirm('确定要退汇吗?操作后不能恢复!', function (index) {
  264. $.ajax({
  265. type: "POST",
  266. url: "/Admin/UserCashRecord/Refund?r=" + Math.random(1),
  267. data: "Id=" + data.Id,
  268. dataType: "text",
  269. success: function (data) {
  270. layer.close(index);
  271. if (data == "success") {
  272. parent.layer.msg('已退汇');
  273. table.reload('LAY-list-manage'); //数据刷新
  274. } else {
  275. parent.layer.msg(data);
  276. }
  277. }
  278. });
  279. });
  280. } else if (obj.event === 'edit') {
  281. var tr = $(obj.tr);
  282. var perContent = layer.open({
  283. type: 2,
  284. title: '提现记录-编辑',
  285. content: 'Edit?Id=' + data.Id + '',
  286. maxmin: true,
  287. area: ['500px', '450px'],
  288. btn: ['确定', '取消'],
  289. yes: function (index, layero) {
  290. var iframeWindow = window['layui-layer-iframe' + index],
  291. submitID = 'LAY-list-front-submit',
  292. submit = layero.find('iframe').contents().find('#' + submitID);
  293. setTimeout(function () {
  294. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  295. var errObj = $(this).find('.layui-form-danger');
  296. if (errObj.length > 0) {
  297. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  298. submit.click();
  299. }
  300. });
  301. }, 300);
  302. //监听提交
  303. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  304. var field = data.field; //获取提交的字段
  305. var userdata = "";
  306. for (var prop in field) {
  307. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  308. }
  309. //提交 Ajax 成功后,静态更新表格中的数据
  310. //$.ajax({});
  311. $.ajax({
  312. type: "POST",
  313. url: "/Admin/UserCashRecord/Edit?r=" + Math.random(1),
  314. data: userdata,
  315. dataType: "text",
  316. success: function (data) {
  317. layer.close(index); //关闭弹层
  318. if (data == "success") {
  319. table.reload('LAY-list-manage'); //数据刷新
  320. } else {
  321. layer.msg(data);
  322. }
  323. }
  324. });
  325. });
  326. submit.trigger('click');
  327. },
  328. success: function (layero, index) {
  329. }
  330. });
  331. layer.full(perContent);
  332. } else if (obj.event === 'reduce') {
  333. var tr = $(obj.tr);
  334. var perContent = layer.open({
  335. type: 2,
  336. title: '拒绝处理',
  337. content: 'Reduce?Id=' + data.Id + '',
  338. maxmin: true,
  339. area: ['500px', '450px'],
  340. btn: ['确定', '取消'],
  341. yes: function (index, layero) {
  342. var iframeWindow = window['layui-layer-iframe' + index],
  343. submitID = 'LAY-list-front-submit',
  344. submit = layero.find('iframe').contents().find('#' + submitID);
  345. setTimeout(function () {
  346. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  347. var errObj = $(this).find('.layui-form-danger');
  348. if (errObj.length > 0) {
  349. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  350. submit.click();
  351. }
  352. });
  353. }, 300);
  354. //监听提交
  355. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  356. var field = data.field; //获取提交的字段
  357. var userdata = "";
  358. for (var prop in field) {
  359. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  360. }
  361. //提交 Ajax 成功后,静态更新表格中的数据
  362. //$.ajax({});
  363. $.ajax({
  364. type: "POST",
  365. url: "/Admin/UserCashRecord/ReduceDo?r=" + Math.random(1),
  366. data: userdata,
  367. dataType: "text",
  368. success: function (data) {
  369. layer.close(index); //关闭弹层
  370. if (data == "success") {
  371. table.reload('LAY-list-manage'); //数据刷新
  372. } else {
  373. layer.msg(data);
  374. }
  375. }
  376. });
  377. });
  378. submit.trigger('click');
  379. },
  380. success: function (layero, index) {
  381. }
  382. });
  383. }
  384. });
  385. //监听搜索
  386. form.on('submit(LAY-list-front-search)', function (data) {
  387. var field = data.field;
  388. //执行重载
  389. table.reload('LAY-list-manage', {
  390. where: field,
  391. page: {
  392. curr: 1
  393. }
  394. });
  395. });
  396. form.on('submit(LAY-list-front-searchall)', function (data) {
  397. table.reload('LAY-list-manage', {
  398. where: null,
  399. page: {
  400. curr: 1
  401. }
  402. });
  403. });
  404. //事件
  405. var active = {
  406. batchdel: function () {
  407. var checkStatus = table.checkStatus('LAY-list-manage'),
  408. data = checkStatus.data; //得到选中的数据
  409. if (data.length < 1) {
  410. parent.layer.msg("请选择要删除的项");
  411. } else {
  412. var ids = "";
  413. $.each(data, function (index, value) {
  414. ids += data[index].Id + ",";
  415. });
  416. ids = ids.substring(0, ids.length - 1);
  417. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  418. $.ajax({
  419. type: "POST",
  420. url: "/Admin/UserCashRecord/Delete?r=" + Math.random(1),
  421. data: "Id=" + ids,
  422. dataType: "text",
  423. success: function (data) {
  424. layer.close(index);
  425. if (data == "success") {
  426. table.reload('LAY-list-manage');
  427. } else {
  428. layer.msg(data);
  429. }
  430. }
  431. });
  432. });
  433. }
  434. },
  435. add: function () {
  436. var perContent = layer.open({
  437. type: 2,
  438. title: '提现记录-添加',
  439. content: 'Add',
  440. maxmin: true,
  441. area: ['500px', '450px'],
  442. btn: ['确定', '取消'],
  443. yes: function (index, layero) {
  444. var iframeWindow = window['layui-layer-iframe' + index],
  445. submitID = 'LAY-list-front-submit',
  446. submit = layero.find('iframe').contents().find('#' + submitID);
  447. setTimeout(function () {
  448. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  449. var errObj = $(this).find('.layui-form-danger');
  450. if (errObj.length > 0) {
  451. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  452. submit.click();
  453. }
  454. });
  455. }, 300);
  456. //监听提交
  457. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  458. var field = data.field; //获取提交的字段
  459. var userdata = "";
  460. for (var prop in field) {
  461. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  462. }
  463. //提交 Ajax 成功后,静态更新表格中的数据
  464. //$.ajax({});
  465. $.ajax({
  466. type: "POST",
  467. url: "/Admin/UserCashRecord/Add?r=" + Math.random(1),
  468. data: userdata,
  469. dataType: "text",
  470. success: function (data) {
  471. layer.close(index); //关闭弹层
  472. if (data == "success") {
  473. table.reload('LAY-list-manage'); //数据刷新
  474. } else {
  475. layer.msg(data);
  476. }
  477. }
  478. });
  479. });
  480. submit.trigger('click');
  481. }
  482. });
  483. layer.full(perContent);
  484. },
  485. ImportData: function () {
  486. var perContent = layer.open({
  487. type: 2
  488. , title: '提现结果导入'
  489. , content: 'Import'
  490. , maxmin: true
  491. , area: ['650px', '350px']
  492. , btn: ['确定', '取消']
  493. , yes: function (index, layero) {
  494. var iframeWindow = window['layui-layer-iframe' + index]
  495. , submitID = 'LAY-list-front-submit'
  496. , submit = layero.find('iframe').contents().find('#' + submitID);
  497. //监听提交
  498. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  499. var field = data.field; //获取提交的字段
  500. var userdata = "";
  501. for (var prop in field) {
  502. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  503. }
  504. //提交 Ajax 成功后,静态更新表格中的数据
  505. //$.ajax({});
  506. var loadindex = layer.load(1, {
  507. shade: [0.5, '#000']
  508. });
  509. $.ajax({
  510. type: "POST",
  511. url: "/Admin/UserCashRecord/ImportPost?r=" + Math.random(1),
  512. data: userdata,
  513. dataType: "text",
  514. success: function (data) {
  515. if (data.indexOf("success") == 0) {
  516. var datalist = data.split('|');
  517. var key = datalist[1];
  518. CheckImport(table, key, loadindex, index);
  519. } else {
  520. layer.msg(data);
  521. }
  522. }
  523. });
  524. });
  525. submit.trigger('click');
  526. }
  527. });
  528. },
  529. ExportExcel: function () {
  530. var userdata = '';
  531. $(".layuiadmin-card-header-auto input").each(function (i) {
  532. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  533. });
  534. $(".layuiadmin-card-header-auto select").each(function (i) {
  535. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  536. });
  537. $.ajax({
  538. type: "GET",
  539. url: "/Admin/UserCashRecord/ExportExcel?r=" + Math.random(1),
  540. data: userdata,
  541. dataType: "json",
  542. success: function (data) {
  543. data.Obj.unshift(data.Fields);
  544. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  545. }
  546. });
  547. },
  548. BatchSetting: function () {
  549. var checkStatus = table.checkStatus('LAY-list-manage'),
  550. data = checkStatus.data; //得到选中的数据
  551. if (data.length < 1) {
  552. parent.layer.msg("请选择要设置的项");
  553. } else {
  554. var ids = "";
  555. $.each(data, function (index, value) {
  556. ids += data[index].Id + ",";
  557. });
  558. ids = ids.substring(0, ids.length - 1);
  559. var index = layer.confirm('确定要设为成功状态吗?', function (index) {
  560. $.ajax({
  561. type: "POST",
  562. url: "/Admin/UserCashRecord/BatchSetting?r=" + Math.random(1),
  563. data: "Id=" + ids,
  564. dataType: "text",
  565. success: function (data) {
  566. layer.close(index);
  567. if (data == "success") {
  568. table.reload('LAY-list-manage');
  569. } else {
  570. layer.msg(data);
  571. }
  572. }
  573. });
  574. });
  575. }
  576. },
  577. Open: function () {
  578. var checkStatus = table.checkStatus('LAY-list-manage'),
  579. data = checkStatus.data; //得到选中的数据
  580. if (data.length < 1) {
  581. parent.layer.msg("请选择要开启的项");
  582. } else {
  583. var ids = "";
  584. $.each(data, function (index, value) {
  585. ids += data[index].Id + ",";
  586. });
  587. ids = ids.substring(0, ids.length - 1);
  588. var index = layer.confirm('确定要开启吗?', function (index) {
  589. $.ajax({
  590. type: "POST",
  591. url: "/Admin/UserCashRecord/Open?r=" + Math.random(1),
  592. data: "Id=" + ids,
  593. dataType: "text",
  594. success: function (data) {
  595. layer.close(index);
  596. if (data == "success") {
  597. table.reload('LAY-list-manage');
  598. } else {
  599. layer.msg(data);
  600. }
  601. }
  602. });
  603. });
  604. }
  605. },
  606. Close: function () {
  607. var checkStatus = table.checkStatus('LAY-list-manage'),
  608. data = checkStatus.data; //得到选中的数据
  609. if (data.length < 1) {
  610. parent.layer.msg("请选择要关闭的项");
  611. } else {
  612. var ids = "";
  613. $.each(data, function (index, value) {
  614. ids += data[index].Id + ",";
  615. });
  616. ids = ids.substring(0, ids.length - 1);
  617. var index = layer.confirm('确定要关闭吗?', function (index) {
  618. $.ajax({
  619. type: "POST",
  620. url: "/Admin/UserCashRecord/Close?r=" + Math.random(1),
  621. data: "Id=" + ids,
  622. dataType: "text",
  623. success: function (data) {
  624. layer.close(index);
  625. if (data == "success") {
  626. table.reload('LAY-list-manage');
  627. } else {
  628. layer.msg(data);
  629. }
  630. }
  631. });
  632. });
  633. }
  634. },
  635. Cash: function () {
  636. var checkStatus = table.checkStatus('LAY-list-manage'),
  637. data = checkStatus.data; //得到选中的数据
  638. if (data.length < 1) {
  639. parent.layer.msg("请选择要提交代付的项");
  640. } else {
  641. var ids = "";
  642. $.each(data, function (index, value) {
  643. ids += data[index].Id + ",";
  644. });
  645. ids = ids.substring(0, ids.length - 1);
  646. var index = layer.confirm('确定要提交到代付平台申请出款吗?', function (index) {
  647. $.ajax({
  648. type: "POST",
  649. url: "/Admin/UserCashRecord/Cash?r=" + Math.random(1),
  650. data: "Id=" + ids,
  651. dataType: "text",
  652. success: function (data) {
  653. layer.close(index);
  654. if (data == "success") {
  655. layer.msg('提交成功,请等待代付平台处理');
  656. table.reload('LAY-list-manage');
  657. } else {
  658. layer.msg(data);
  659. }
  660. }
  661. });
  662. });
  663. }
  664. },
  665. };
  666. $('.layui-btn').on('click', function () {
  667. var type = $(this).data('type');
  668. active[type] ? active[type].call(this) : '';
  669. });
  670. });