UserCashRecord_Admin.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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: 'BusinessFlag',
  167. width: 100,
  168. title: '是否对公',
  169. sort: true
  170. }, {
  171. field: 'StatusName',
  172. width: 200,
  173. title: '订单状态',
  174. templet: '#StatusTpl',
  175. sort: true
  176. }, {
  177. field: 'ReturnCode',
  178. width: 200,
  179. title: '提现服务返回编码',
  180. sort: true
  181. }, {
  182. field: 'ReturnMsg',
  183. width: 200,
  184. title: '提现服务返回信息',
  185. sort: true
  186. }, {
  187. field: 'CreateDate',
  188. width: 200,
  189. title: '创建时间',
  190. sort: true
  191. }, {
  192. field: 'SeoTitle',
  193. width: 200,
  194. title: '发放时间',
  195. sort: true
  196. }, { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  197. ]
  198. ],
  199. where: {
  200. },
  201. page: true,
  202. limit: 30,
  203. height: 'full-' + String($('.layui-card-header').height() + 130),
  204. text: '对不起,加载出现异常!',
  205. done: function (res, curr, count) {
  206. $("#SuccessAmount").text(res.other.SuccessAmount);
  207. $("#FailAmount").text(res.other.FailAmount);
  208. $("#WaitAmount").text(res.other.WaitAmount);
  209. $(".layui-none").text("无数据");
  210. layer.close(loadindex);
  211. }
  212. });
  213. //监听工具条
  214. table.on('tool(LAY-list-manage)', function (obj) {
  215. var data = obj.data;
  216. if (obj.event === 'del') {
  217. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  218. $.ajax({
  219. type: "POST",
  220. url: "/Admin/UserCashRecordOperate/Delete?r=" + Math.random(1),
  221. data: "Id=" + data.Id,
  222. dataType: "text",
  223. success: function (data) {
  224. if (data == "success") {
  225. obj.del();
  226. layer.close(index);
  227. } else {
  228. parent.layer.msg(data);
  229. }
  230. }
  231. });
  232. });
  233. } else if (obj.event === 'cancel') {
  234. var index = layer.confirm('确定要解除吗?操作后不能恢复!', function (index) {
  235. $.ajax({
  236. type: "POST",
  237. url: "/Admin/UserCashRecordOperate/Cancel?r=" + Math.random(1),
  238. data: "Id=" + data.Id,
  239. dataType: "text",
  240. success: function (data) {
  241. layer.close(index);
  242. if (data == "success") {
  243. parent.layer.msg('已解除');
  244. table.reload('LAY-list-manage'); //数据刷新
  245. } else {
  246. parent.layer.msg(data);
  247. }
  248. }
  249. });
  250. });
  251. } else if (obj.event === 'edit') {
  252. var tr = $(obj.tr);
  253. var perContent = layer.open({
  254. type: 2,
  255. title: '提现记录-编辑',
  256. content: 'Edit?Id=' + data.Id + '',
  257. maxmin: true,
  258. area: ['500px', '450px'],
  259. btn: ['确定', '取消'],
  260. yes: function (index, layero) {
  261. var iframeWindow = window['layui-layer-iframe' + index],
  262. submitID = 'LAY-list-front-submit',
  263. submit = layero.find('iframe').contents().find('#' + submitID);
  264. setTimeout(function () {
  265. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  266. var errObj = $(this).find('.layui-form-danger');
  267. if (errObj.length > 0) {
  268. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  269. submit.click();
  270. }
  271. });
  272. }, 300);
  273. //监听提交
  274. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  275. var field = data.field; //获取提交的字段
  276. var userdata = "";
  277. for (var prop in field) {
  278. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  279. }
  280. //提交 Ajax 成功后,静态更新表格中的数据
  281. //$.ajax({});
  282. $.ajax({
  283. type: "POST",
  284. url: "/Admin/UserCashRecordOperate/Edit?r=" + Math.random(1),
  285. data: userdata,
  286. dataType: "text",
  287. success: function (data) {
  288. layer.close(index); //关闭弹层
  289. if (data == "success") {
  290. table.reload('LAY-list-manage'); //数据刷新
  291. } else {
  292. layer.msg(data);
  293. }
  294. }
  295. });
  296. });
  297. submit.trigger('click');
  298. },
  299. success: function (layero, index) {
  300. }
  301. });
  302. layer.full(perContent);
  303. } else if (obj.event === 'reduce') {
  304. var tr = $(obj.tr);
  305. var perContent = layer.open({
  306. type: 2,
  307. title: '拒绝处理',
  308. content: 'Reduce?Id=' + data.Id + '',
  309. maxmin: true,
  310. area: ['500px', '450px'],
  311. btn: ['确定', '取消'],
  312. yes: function (index, layero) {
  313. loadindex = layer.load(1, {
  314. shade: [0.5, '#000']
  315. });
  316. var iframeWindow = window['layui-layer-iframe' + index],
  317. submitID = 'LAY-list-front-submit',
  318. submit = layero.find('iframe').contents().find('#' + submitID);
  319. setTimeout(function () {
  320. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  321. var errObj = $(this).find('.layui-form-danger');
  322. if (errObj.length > 0) {
  323. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  324. submit.click();
  325. }
  326. });
  327. }, 300);
  328. //监听提交
  329. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  330. var field = data.field; //获取提交的字段
  331. var userdata = "";
  332. for (var prop in field) {
  333. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  334. }
  335. //提交 Ajax 成功后,静态更新表格中的数据
  336. //$.ajax({});
  337. $.ajax({
  338. type: "POST",
  339. url: "/Admin/UserCashRecordOperate/ReduceDo?r=" + Math.random(1),
  340. data: userdata,
  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. submit.trigger('click');
  353. },
  354. success: function (layero, index) {
  355. }
  356. });
  357. }
  358. });
  359. //监听搜索
  360. form.on('submit(LAY-list-front-search)', function (data) {
  361. var field = data.field;
  362. //执行重载
  363. table.reload('LAY-list-manage', {
  364. where: field,
  365. page: {
  366. curr: 1
  367. }
  368. });
  369. });
  370. form.on('submit(LAY-list-front-searchall)', function (data) {
  371. table.reload('LAY-list-manage', {
  372. where: null,
  373. page: {
  374. curr: 1
  375. }
  376. });
  377. });
  378. //事件
  379. var active = {
  380. batchdel: function () {
  381. var checkStatus = table.checkStatus('LAY-list-manage'),
  382. data = checkStatus.data; //得到选中的数据
  383. if (data.length < 1) {
  384. parent.layer.msg("请选择要删除的项");
  385. } else {
  386. var ids = "";
  387. $.each(data, function (index, value) {
  388. ids += data[index].Id + ",";
  389. });
  390. ids = ids.substring(0, ids.length - 1);
  391. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  392. $.ajax({
  393. type: "POST",
  394. url: "/Admin/UserCashRecordOperate/Delete?r=" + Math.random(1),
  395. data: "Id=" + ids,
  396. dataType: "text",
  397. success: function (data) {
  398. layer.close(index);
  399. if (data == "success") {
  400. table.reload('LAY-list-manage');
  401. } else {
  402. layer.msg(data);
  403. }
  404. }
  405. });
  406. });
  407. }
  408. },
  409. add: function () {
  410. var perContent = layer.open({
  411. type: 2,
  412. title: '提现记录-添加',
  413. content: 'Add',
  414. maxmin: true,
  415. area: ['500px', '450px'],
  416. btn: ['确定', '取消'],
  417. yes: function (index, layero) {
  418. var iframeWindow = window['layui-layer-iframe' + index],
  419. submitID = 'LAY-list-front-submit',
  420. submit = layero.find('iframe').contents().find('#' + submitID);
  421. setTimeout(function () {
  422. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  423. var errObj = $(this).find('.layui-form-danger');
  424. if (errObj.length > 0) {
  425. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  426. submit.click();
  427. }
  428. });
  429. }, 300);
  430. //监听提交
  431. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  432. var field = data.field; //获取提交的字段
  433. var userdata = "";
  434. for (var prop in field) {
  435. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  436. }
  437. //提交 Ajax 成功后,静态更新表格中的数据
  438. //$.ajax({});
  439. $.ajax({
  440. type: "POST",
  441. url: "/Admin/UserCashRecordOperate/Add?r=" + Math.random(1),
  442. data: userdata,
  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. submit.trigger('click');
  455. }
  456. });
  457. layer.full(perContent);
  458. },
  459. ImportData: function () {
  460. var perContent = layer.open({
  461. type: 2
  462. , title: '提现结果导入'
  463. , content: 'Import'
  464. , maxmin: true
  465. , area: ['650px', '350px']
  466. , btn: ['确定', '取消']
  467. , yes: function (index, layero) {
  468. var iframeWindow = window['layui-layer-iframe' + index]
  469. , submitID = 'LAY-list-front-submit'
  470. , submit = layero.find('iframe').contents().find('#' + submitID);
  471. //监听提交
  472. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  473. var field = data.field; //获取提交的字段
  474. var userdata = "";
  475. for (var prop in field) {
  476. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  477. }
  478. //提交 Ajax 成功后,静态更新表格中的数据
  479. //$.ajax({});
  480. var loadindex = layer.load(1, {
  481. shade: [0.5, '#000']
  482. });
  483. $.ajax({
  484. type: "POST",
  485. url: "/Admin/UserCashRecordOperate/ImportPost?r=" + Math.random(1),
  486. data: userdata,
  487. dataType: "text",
  488. success: function (data) {
  489. if (data.indexOf("success") == 0) {
  490. var datalist = data.split('|');
  491. var key = datalist[1];
  492. CheckImport(table, key, loadindex, index);
  493. } else {
  494. layer.msg(data);
  495. }
  496. }
  497. });
  498. });
  499. submit.trigger('click');
  500. }
  501. });
  502. },
  503. ExportExcel: function () {
  504. var userdata = '';
  505. $(".layuiadmin-card-header-auto input").each(function (i) {
  506. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  507. });
  508. $(".layuiadmin-card-header-auto select").each(function (i) {
  509. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  510. });
  511. $.ajax({
  512. type: "GET",
  513. url: "/Admin/UserCashRecordOperate/ExportExcel?r=" + Math.random(1),
  514. data: userdata,
  515. dataType: "json",
  516. success: function (data) {
  517. data.Obj.unshift(data.Fields);
  518. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  519. }
  520. });
  521. },
  522. BatchSetting: function () {
  523. var checkStatus = table.checkStatus('LAY-list-manage'),
  524. data = checkStatus.data; //得到选中的数据
  525. if (data.length < 1) {
  526. parent.layer.msg("请选择要设置的项");
  527. } else {
  528. var ids = "";
  529. $.each(data, function (index, value) {
  530. ids += data[index].Id + ",";
  531. });
  532. ids = ids.substring(0, ids.length - 1);
  533. var index = layer.confirm('确定要设为成功状态吗?', function (index) {
  534. loadindex = layer.load(1, {
  535. shade: [0.5, '#000']
  536. });
  537. $.ajax({
  538. type: "POST",
  539. url: "/Admin/UserCashRecordOperate/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/UserCashRecordOperate/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/UserCashRecordOperate/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/UserCashRecordOperate/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. });