UserCashRecord_Admin.js 27 KB

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