UserCashHelpRecord_Admin.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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/HelpProfitIndexData' //模拟接口
  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: 'StatusName',
  161. width: 200,
  162. title: '订单状态',
  163. templet: '#StatusTpl',
  164. sort: true
  165. }, {
  166. field: 'LockName',
  167. width: 200,
  168. title: '提现标记',
  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: 'SeoTitle',
  182. width: 200,
  183. title: '备注/代付返回信息',
  184. sort: true
  185. }, {
  186. field: 'CreateDate',
  187. width: 200,
  188. title: '创建时间',
  189. sort: true
  190. }, { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  191. ]
  192. ],
  193. where: {
  194. },
  195. page: true,
  196. limit: 30,
  197. height: 'full-' + String($('.layui-card-header').height() + 130),
  198. text: '对不起,加载出现异常!',
  199. done: function (res, curr, count) {
  200. $("#SuccessAmount").text(res.other.SuccessAmount);
  201. $("#FailAmount").text(res.other.FailAmount);
  202. $("#WaitAmount").text(res.other.WaitAmount);
  203. $(".layui-none").text("无数据");
  204. }
  205. });
  206. //监听工具条
  207. table.on('tool(LAY-list-manage)', function (obj) {
  208. var data = obj.data;
  209. if (obj.event === 'del') {
  210. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  211. $.ajax({
  212. type: "POST",
  213. url: "/Admin/UserCashRecord/Delete?r=" + Math.random(1),
  214. data: "Id=" + data.Id,
  215. dataType: "text",
  216. success: function (data) {
  217. if (data == "success") {
  218. obj.del();
  219. layer.close(index);
  220. } else {
  221. parent.layer.msg(data);
  222. }
  223. }
  224. });
  225. });
  226. } else if (obj.event === 'cancel') {
  227. var index = layer.confirm('确定要解除吗?操作后不能恢复!', function (index) {
  228. $.ajax({
  229. type: "POST",
  230. url: "/Admin/UserCashRecord/Cancel?r=" + Math.random(1),
  231. data: "Id=" + data.Id,
  232. dataType: "text",
  233. success: function (data) {
  234. layer.close(index);
  235. if (data == "success") {
  236. parent.layer.msg('已解除');
  237. table.reload('LAY-list-manage'); //数据刷新
  238. } else {
  239. parent.layer.msg(data);
  240. }
  241. }
  242. });
  243. });
  244. } else if (obj.event === 'edit') {
  245. var tr = $(obj.tr);
  246. var perContent = layer.open({
  247. type: 2,
  248. title: '提现记录-编辑',
  249. content: 'Edit?Id=' + data.Id + '',
  250. maxmin: true,
  251. area: ['500px', '450px'],
  252. btn: ['确定', '取消'],
  253. yes: function (index, layero) {
  254. var iframeWindow = window['layui-layer-iframe' + index],
  255. submitID = 'LAY-list-front-submit',
  256. submit = layero.find('iframe').contents().find('#' + submitID);
  257. setTimeout(function () {
  258. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  259. var errObj = $(this).find('.layui-form-danger');
  260. if (errObj.length > 0) {
  261. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  262. submit.click();
  263. }
  264. });
  265. }, 300);
  266. //监听提交
  267. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  268. var field = data.field; //获取提交的字段
  269. var userdata = "";
  270. for (var prop in field) {
  271. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  272. }
  273. //提交 Ajax 成功后,静态更新表格中的数据
  274. //$.ajax({});
  275. $.ajax({
  276. type: "POST",
  277. url: "/Admin/UserCashRecord/Edit?r=" + Math.random(1),
  278. data: userdata,
  279. dataType: "text",
  280. success: function (data) {
  281. layer.close(index); //关闭弹层
  282. if (data == "success") {
  283. table.reload('LAY-list-manage'); //数据刷新
  284. } else {
  285. layer.msg(data);
  286. }
  287. }
  288. });
  289. });
  290. submit.trigger('click');
  291. },
  292. success: function (layero, index) {
  293. }
  294. });
  295. layer.full(perContent);
  296. } else if (obj.event === 'reduce') {
  297. var tr = $(obj.tr);
  298. var perContent = layer.open({
  299. type: 2,
  300. title: '拒绝处理',
  301. content: 'Reduce?Id=' + data.Id + '',
  302. maxmin: true,
  303. area: ['500px', '450px'],
  304. btn: ['确定', '取消'],
  305. yes: function (index, layero) {
  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/UserCashRecord/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/UserCashRecord/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/UserCashRecord/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/UserCashRecord/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/UserCashRecord/HelpProfitExportExcel?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. Open: 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. $.ajax({
  525. type: "POST",
  526. url: "/Admin/UserCashRecord/Open?r=" + Math.random(1),
  527. data: "Id=" + ids,
  528. dataType: "text",
  529. success: function (data) {
  530. layer.close(index);
  531. if (data == "success") {
  532. table.reload('LAY-list-manage');
  533. } else {
  534. layer.msg(data);
  535. }
  536. }
  537. });
  538. });
  539. }
  540. },
  541. Close: function () {
  542. var checkStatus = table.checkStatus('LAY-list-manage'),
  543. data = checkStatus.data; //得到选中的数据
  544. if (data.length < 1) {
  545. parent.layer.msg("请选择要关闭的项");
  546. } else {
  547. var ids = "";
  548. $.each(data, function (index, value) {
  549. ids += data[index].Id + ",";
  550. });
  551. ids = ids.substring(0, ids.length - 1);
  552. var index = layer.confirm('确定要关闭吗?', function (index) {
  553. $.ajax({
  554. type: "POST",
  555. url: "/Admin/UserCashRecord/Close?r=" + Math.random(1),
  556. data: "Id=" + ids,
  557. dataType: "text",
  558. success: function (data) {
  559. layer.close(index);
  560. if (data == "success") {
  561. table.reload('LAY-list-manage');
  562. } else {
  563. layer.msg(data);
  564. }
  565. }
  566. });
  567. });
  568. }
  569. },
  570. Cash: function () {
  571. var checkStatus = table.checkStatus('LAY-list-manage'),
  572. data = checkStatus.data; //得到选中的数据
  573. if (data.length < 1) {
  574. parent.layer.msg("请选择要提交代付的项");
  575. } else {
  576. var ids = "";
  577. $.each(data, function (index, value) {
  578. ids += data[index].Id + ",";
  579. });
  580. ids = ids.substring(0, ids.length - 1);
  581. var index = layer.confirm('确定要提交到代付平台申请出款吗?', function (index) {
  582. $.ajax({
  583. type: "POST",
  584. url: "/Admin/UserCashRecord/Cash?r=" + Math.random(1),
  585. data: "Id=" + ids,
  586. dataType: "text",
  587. success: function (data) {
  588. layer.close(index);
  589. if (data == "success") {
  590. layer.msg('提交成功,请等待代付平台处理');
  591. table.reload('LAY-list-manage');
  592. } else {
  593. layer.msg(data);
  594. }
  595. }
  596. });
  597. });
  598. }
  599. },
  600. };
  601. $('.layui-btn').on('click', function () {
  602. var type = $(this).data('type');
  603. active[type] ? active[type].call(this) : '';
  604. });
  605. });