UserCashRecords_Admin.js 26 KB

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