UserCashRecord_Admin.js 27 KB

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