UserCashLeaderRecord_Admin.js 25 KB

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