ProfitRewardRecord_Admin.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/ProfitRewardRecord/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. var excel;
  22. layui.config({
  23. base: '/layuiadmin/' //静态资源所在路径
  24. }).extend({
  25. myexcel: 'layui/lay/modules/excel',
  26. index: 'lib/index' //主入口模块
  27. }).use(['index', 'table', 'excel', 'laydate'], function () {
  28. var $ = layui.$,
  29. form = layui.form,
  30. table = layui.table;
  31. //- 筛选条件-日期
  32. var laydate = layui.laydate;
  33. var layCreateDate = laydate.render({
  34. elem: '#CreateDate',
  35. type: 'date',
  36. range: true,
  37. trigger: 'click',
  38. change: function (value, date, endDate) {
  39. var op = true;
  40. if (date.year == endDate.year && endDate.month - date.month <= 2) {
  41. if (endDate.month - date.month == 2 && endDate.date > date.date) {
  42. op = false;
  43. layCreateDate.hint('日期范围请不要超过2个月');
  44. setTimeout(function () {
  45. $(".laydate-btns-confirm").addClass("laydate-disabled");
  46. }, 1);
  47. }
  48. } else {
  49. op = false;
  50. layCreateDate.hint('日期范围请不要超过2个月');
  51. setTimeout(function () {
  52. $(".laydate-btns-confirm").addClass("laydate-disabled");
  53. }, 1);
  54. }
  55. if (op) {
  56. $('#CreateDate').val(value);
  57. }
  58. }
  59. });
  60. //excel导入
  61. excel = layui.excel;
  62. $('#ExcelFile').change(function (e) {
  63. var files = e.target.files;
  64. excel.importExcel(files, {}, function (data) {
  65. ExcelData = data[0].sheet1;
  66. });
  67. });
  68. //监听单元格编辑
  69. table.on('edit(LAY-list-manage)', function (obj) {
  70. var value = obj.value //得到修改后的值
  71. ,
  72. data = obj.data //得到所在行所有键值
  73. ,
  74. field = obj.field; //得到字段
  75. if (field == "Sort") {
  76. $.ajax({
  77. type: "POST",
  78. url: "/Admin/ProfitRewardRecord/Sort?r=" + Math.random(1),
  79. data: "Id=" + data.Id + "&Sort=" + value,
  80. dataType: "text",
  81. success: function (data) { }
  82. });
  83. }
  84. });
  85. //列表数据
  86. table.render({
  87. elem: '#LAY-list-manage',
  88. url: '/Admin/ProfitRewardRecord/IndexData' //模拟接口
  89. ,
  90. cols: [
  91. [{
  92. type: 'checkbox',
  93. fixed: 'left'
  94. }, {
  95. field: 'RecordNo',
  96. width: 200,
  97. title: '记录单号',
  98. sort: true
  99. }, {
  100. field: 'MakerCode',
  101. width: 200,
  102. title: '创客编号',
  103. sort: true
  104. }, {
  105. field: 'RealName',
  106. width: 200,
  107. title: '创客姓名',
  108. sort: true
  109. },
  110. // {
  111. // field: 'TopMakerCode',
  112. // width: 200,
  113. // title: '顶级创客编码',
  114. // sort: true
  115. // }, {
  116. // field: 'TopRealName',
  117. // width: 200,
  118. // title: '顶级创客名称',
  119. // sort: true
  120. // },
  121. {
  122. field: 'CreateDate',
  123. width: 200,
  124. title: '创建时间',
  125. sort: true
  126. }
  127. , {
  128. field: 'TradeMonth',
  129. width: 200,
  130. title: '交易所在月份',
  131. sort: true
  132. }, {
  133. field: 'ProfitType',
  134. width: 200,
  135. title: '分润类型',
  136. sort: true
  137. }, {
  138. field: 'TradeAmt',
  139. width: 200,
  140. title: '商户交易总额(元)',
  141. sort: true
  142. }, {
  143. field: 'OtherTradeAmt',
  144. width: 380,
  145. title: '其他产品交易额(元)',
  146. sort: true
  147. }, {
  148. field: 'CreditTradeAmt',
  149. width: 380,
  150. title: '贷记卡交易金额(元)',
  151. sort: true
  152. }, {
  153. field: 'MerDebitTradeAmt',
  154. width: 380,
  155. title: '商户借记卡交易金额(元)',
  156. sort: true
  157. }, {
  158. field: 'TradeProfit',
  159. width: 200,
  160. title: '交易分润(元)',
  161. sort: true
  162. }, {
  163. field: 'CreditProfitAmt',
  164. width: 380,
  165. title: '贷记卡分润金额',
  166. sort: true
  167. }, {
  168. field: 'DebitProfitAmt',
  169. width: 380,
  170. title: '借记卡交易分润金额',
  171. sort: true
  172. }, {
  173. field: 'CheckStatus',
  174. width: 200,
  175. title: '验证和同步账户状态',
  176. sort: true
  177. }]
  178. ],
  179. where: {
  180. BrandId: BrandId
  181. },
  182. page: true,
  183. limit: 30,
  184. height: 'full-' + String($('.layui-card-header').height() + 130),
  185. text: '对不起,加载出现异常!',
  186. done: function (res, curr, count) {
  187. $("#MerchantTradeAmount").text(res.other.MerchantTradeAmount);
  188. $("#CreditTradeAmount").text(res.other.CreditTradeAmount);
  189. $("#MerchantProfitAmount").text(res.other.MerchantProfitAmount);
  190. $("#CreditProfitAmount").text(res.other.CreditProfitAmount);
  191. $(".layui-none").text("无数据");
  192. }
  193. });
  194. //监听工具条
  195. table.on('tool(LAY-list-manage)', function (obj) {
  196. var data = obj.data;
  197. if (obj.event === 'del') {
  198. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  199. $.ajax({
  200. type: "POST",
  201. url: "/Admin/ProfitRewardRecord/Delete?r=" + Math.random(1),
  202. data: "Id=" + data.Id,
  203. dataType: "text",
  204. success: function (data) {
  205. if (data == "success") {
  206. obj.del();
  207. layer.close(index);
  208. } else {
  209. parent.layer.msg(data);
  210. }
  211. }
  212. });
  213. });
  214. } else if (obj.event === 'edit') {
  215. var tr = $(obj.tr);
  216. var perContent = layer.open({
  217. type: 2,
  218. title: '分润奖励记录-编辑',
  219. content: 'Edit?Id=' + data.Id + '',
  220. maxmin: true,
  221. area: ['500px', '450px'],
  222. btn: ['确定', '取消'],
  223. yes: function (index, layero) {
  224. var iframeWindow = window['layui-layer-iframe' + index],
  225. submitID = 'LAY-list-front-submit',
  226. submit = layero.find('iframe').contents().find('#' + submitID);
  227. setTimeout(function () {
  228. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  229. var errObj = $(this).find('.layui-form-danger');
  230. if (errObj.length > 0) {
  231. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  232. submit.click();
  233. }
  234. });
  235. }, 300);
  236. //监听提交
  237. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  238. var field = data.field; //获取提交的字段
  239. var userdata = "";
  240. for (var prop in field) {
  241. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  242. }
  243. //提交 Ajax 成功后,静态更新表格中的数据
  244. //$.ajax({});
  245. $.ajax({
  246. type: "POST",
  247. url: "/Admin/ProfitRewardRecord/Edit?r=" + Math.random(1),
  248. data: userdata,
  249. dataType: "text",
  250. success: function (data) {
  251. layer.close(index); //关闭弹层
  252. if (data == "success") {
  253. table.reload('LAY-list-manage'); //数据刷新
  254. } else {
  255. layer.msg(data);
  256. }
  257. }
  258. });
  259. });
  260. submit.trigger('click');
  261. },
  262. success: function (layero, index) {
  263. }
  264. });
  265. layer.full(perContent);
  266. }
  267. });
  268. //监听搜索
  269. form.on('submit(LAY-list-front-search)', function (data) {
  270. var field = data.field;
  271. //执行重载
  272. table.reload('LAY-list-manage', {
  273. where: field,
  274. page: {
  275. curr: 1
  276. }
  277. });
  278. });
  279. form.on('submit(LAY-list-front-searchall)', function (data) {
  280. table.reload('LAY-list-manage', {
  281. where: null,
  282. page: {
  283. curr: 1
  284. }
  285. });
  286. });
  287. //事件
  288. var active = {
  289. batchdel: function () {
  290. var checkStatus = table.checkStatus('LAY-list-manage'),
  291. data = checkStatus.data; //得到选中的数据
  292. if (data.length < 1) {
  293. parent.layer.msg("请选择要删除的项");
  294. } else {
  295. var ids = "";
  296. $.each(data, function (index, value) {
  297. ids += data[index].Id + ",";
  298. });
  299. ids = ids.substring(0, ids.length - 1);
  300. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  301. $.ajax({
  302. type: "POST",
  303. url: "/Admin/ProfitRewardRecord/Delete?r=" + Math.random(1),
  304. data: "Id=" + ids,
  305. dataType: "text",
  306. success: function (data) {
  307. layer.close(index);
  308. if (data == "success") {
  309. table.reload('LAY-list-manage');
  310. } else {
  311. layer.msg(data);
  312. }
  313. }
  314. });
  315. });
  316. }
  317. },
  318. add: function () {
  319. var perContent = layer.open({
  320. type: 2,
  321. title: '分润奖励记录-添加',
  322. content: 'Add',
  323. maxmin: true,
  324. area: ['500px', '450px'],
  325. btn: ['确定', '取消'],
  326. yes: function (index, layero) {
  327. var iframeWindow = window['layui-layer-iframe' + index],
  328. submitID = 'LAY-list-front-submit',
  329. submit = layero.find('iframe').contents().find('#' + submitID);
  330. setTimeout(function () {
  331. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  332. var errObj = $(this).find('.layui-form-danger');
  333. if (errObj.length > 0) {
  334. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  335. submit.click();
  336. }
  337. });
  338. }, 300);
  339. //监听提交
  340. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  341. var field = data.field; //获取提交的字段
  342. var userdata = "";
  343. for (var prop in field) {
  344. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  345. }
  346. //提交 Ajax 成功后,静态更新表格中的数据
  347. //$.ajax({});
  348. $.ajax({
  349. type: "POST",
  350. url: "/Admin/ProfitRewardRecord/Add?r=" + Math.random(1),
  351. data: userdata,
  352. dataType: "text",
  353. success: function (data) {
  354. layer.close(index); //关闭弹层
  355. if (data == "success") {
  356. table.reload('LAY-list-manage'); //数据刷新
  357. } else {
  358. layer.msg(data);
  359. }
  360. }
  361. });
  362. });
  363. submit.trigger('click');
  364. }
  365. });
  366. layer.full(perContent);
  367. },
  368. ImportData: function () {
  369. layer.open({
  370. type: 1,
  371. title: '导入',
  372. maxmin: false,
  373. area: ['460px', '180px'],
  374. content: $('#excelForm'),
  375. cancel: function () { }
  376. });
  377. },
  378. ExportExcel: function () {
  379. var userdata = '';
  380. $(".layuiadmin-card-header-auto input").each(function (i) {
  381. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  382. });
  383. $(".layuiadmin-card-header-auto select").each(function (i) {
  384. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  385. });
  386. $.ajax({
  387. type: "GET",
  388. url: "/Admin/ProfitRewardRecord/ExportExcel?r=" + Math.random(1),
  389. data: userdata,
  390. dataType: "json",
  391. success: function (data) {
  392. data.Obj.unshift(data.Fields);
  393. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  394. }
  395. });
  396. },
  397. Open: function () {
  398. var checkStatus = table.checkStatus('LAY-list-manage'),
  399. data = checkStatus.data; //得到选中的数据
  400. if (data.length < 1) {
  401. parent.layer.msg("请选择要开启的项");
  402. } else {
  403. var ids = "";
  404. $.each(data, function (index, value) {
  405. ids += data[index].Id + ",";
  406. });
  407. ids = ids.substring(0, ids.length - 1);
  408. var index = layer.confirm('确定要开启吗?', function (index) {
  409. $.ajax({
  410. type: "POST",
  411. url: "/Admin/ProfitRewardRecord/Open?r=" + Math.random(1),
  412. data: "Id=" + ids,
  413. dataType: "text",
  414. success: function (data) {
  415. layer.close(index);
  416. if (data == "success") {
  417. table.reload('LAY-list-manage');
  418. } else {
  419. layer.msg(data);
  420. }
  421. }
  422. });
  423. });
  424. }
  425. },
  426. Close: function () {
  427. var checkStatus = table.checkStatus('LAY-list-manage'),
  428. data = checkStatus.data; //得到选中的数据
  429. if (data.length < 1) {
  430. parent.layer.msg("请选择要关闭的项");
  431. } else {
  432. var ids = "";
  433. $.each(data, function (index, value) {
  434. ids += data[index].Id + ",";
  435. });
  436. ids = ids.substring(0, ids.length - 1);
  437. var index = layer.confirm('确定要关闭吗?', function (index) {
  438. $.ajax({
  439. type: "POST",
  440. url: "/Admin/ProfitRewardRecord/Close?r=" + Math.random(1),
  441. data: "Id=" + ids,
  442. dataType: "text",
  443. success: function (data) {
  444. layer.close(index);
  445. if (data == "success") {
  446. table.reload('LAY-list-manage');
  447. } else {
  448. layer.msg(data);
  449. }
  450. }
  451. });
  452. });
  453. }
  454. },
  455. SycnData: function () {
  456. var index = layer.confirm('确定要同步到APP展示吗?操作后无法撤回', function (index) {
  457. layer.close(index);
  458. var loadindex = layer.load(1, {
  459. shade: [0.5, '#000']
  460. });
  461. $.ajax({
  462. type: "POST",
  463. url: "/Admin/ProfitRewardRecord/SycnData?r=" + Math.random(1),
  464. data: "BrandId=" + BrandId,
  465. dataType: "text",
  466. success: function (data) {
  467. layer.close(loadindex);
  468. if (data == "success") {
  469. layer.msg('同步成功');
  470. } else {
  471. layer.msg(data);
  472. }
  473. }
  474. });
  475. });
  476. },
  477. SycnDataByCondi: function () {
  478. var MakerCode = $(".layuiadmin-card-header-auto input[name=MakerCode]").val();
  479. var index = layer.confirm('确定要同步到APP展示吗?操作后无法撤回', function (index) {
  480. layer.close(index);
  481. var loadindex = layer.load(1, {
  482. shade: [0.5, '#000']
  483. });
  484. $.ajax({
  485. type: "POST",
  486. url: "/Admin/ProfitRewardRecord/SycnDataByCondi?r=" + Math.random(1),
  487. data: "BrandId=" + BrandId + "&MakerCode=" + MakerCode,
  488. dataType: "text",
  489. success: function (data) {
  490. layer.close(loadindex);
  491. if (data == "success") {
  492. layer.msg('同步成功');
  493. } else {
  494. layer.msg(data);
  495. }
  496. }
  497. });
  498. });
  499. },
  500. SycnCash: function () {
  501. var index = layer.confirm('确定要同步到余额吗?操作后无法撤回', function (index) {
  502. layer.close(index);
  503. var loadindex = layer.load(1, {
  504. shade: [0.5, '#000']
  505. });
  506. $.ajax({
  507. type: "POST",
  508. url: "/Admin/ProfitRewardRecord/SycnData?r=" + Math.random(1),
  509. data: "BrandId=" + BrandId + "&OpType=1",
  510. dataType: "text",
  511. success: function (data) {
  512. layer.close(loadindex);
  513. if (data == "success") {
  514. layer.msg('同步成功');
  515. } else {
  516. layer.msg(data);
  517. }
  518. }
  519. });
  520. });
  521. },
  522. SycnCashByCondi: function () {
  523. var MakerCode = $(".layuiadmin-card-header-auto input[name=MakerCode]").val();
  524. var index = layer.confirm('确定要同步到余额吗?操作后无法撤回', function (index) {
  525. layer.close(index);
  526. var loadindex = layer.load(1, {
  527. shade: [0.5, '#000']
  528. });
  529. $.ajax({
  530. type: "POST",
  531. url: "/Admin/ProfitRewardRecord/SycnDataByCondi?r=" + Math.random(1),
  532. data: "BrandId=" + BrandId + "&MakerCode=" + MakerCode + "&OpType=1",
  533. dataType: "text",
  534. success: function (data) {
  535. layer.close(loadindex);
  536. if (data == "success") {
  537. layer.msg('同步成功');
  538. } else {
  539. layer.msg(data);
  540. }
  541. }
  542. });
  543. });
  544. }
  545. };
  546. $('.layui-btn').on('click', function () {
  547. var type = $(this).data('type');
  548. active[type] ? active[type].call(this) : '';
  549. });
  550. });