TradeDaySummary_Admin.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/TradeDaySummary/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("导入成功", { time: 2000 }, function () {
  11. window.location.reload();
  12. });
  13. } else {
  14. layer.msg(data);
  15. }
  16. }
  17. });
  18. }
  19. var excel;
  20. layui.config({
  21. base: '/layuiadmin/' //静态资源所在路径
  22. }).extend({
  23. myexcel: 'layui/lay/modules/excel',
  24. index: 'lib/index' //主入口模块
  25. }).use(['index', 'table', 'excel', 'laydate'], function () {
  26. var $ = layui.$
  27. , form = layui.form
  28. , table = layui.table;
  29. //- 筛选条件-日期
  30. var laydate = layui.laydate;
  31. var layCreateDate = laydate.render({
  32. elem: '#CreateDate',
  33. type: 'date',
  34. range: true,
  35. trigger: 'click',
  36. change: function (value, date, endDate) {
  37. var op = true;
  38. if (date.year == endDate.year && endDate.month - date.month <= 2) {
  39. if (endDate.month - date.month == 2 && endDate.date > date.date) {
  40. op = false;
  41. layCreateDate.hint('日期范围请不要超过2个月');
  42. setTimeout(function () {
  43. $(".laydate-btns-confirm").addClass("laydate-disabled");
  44. }, 1);
  45. }
  46. } else {
  47. op = false;
  48. layCreateDate.hint('日期范围请不要超过2个月');
  49. setTimeout(function () {
  50. $(".laydate-btns-confirm").addClass("laydate-disabled");
  51. }, 1);
  52. }
  53. if (op) {
  54. $('#CreateDate').val(value);
  55. }
  56. }
  57. });
  58. laydate.render({
  59. elem: '#TradeMonthSelect'
  60. , type: 'month'
  61. });
  62. //excel导入
  63. excel = layui.excel;
  64. $('#ExcelFile').change(function (e) {
  65. var files = e.target.files;
  66. excel.importExcel(files, { }, function (data) {
  67. ExcelData = data[0].sheet1;
  68. });
  69. });
  70. //监听单元格编辑
  71. table.on('edit(LAY-list-manage)', function(obj){
  72. var value = obj.value //得到修改后的值
  73. ,data = obj.data //得到所在行所有键值
  74. ,field = obj.field; //得到字段
  75. if(field == "Sort"){
  76. $.ajax({
  77. type: "POST",
  78. url: "/Admin/TradeDaySummary/Sort?r=" + Math.random(1),
  79. data: "Id=" + data.Id + "&Sort=" + value,
  80. dataType: "text",
  81. success: function (data) {
  82. }
  83. });
  84. }
  85. });
  86. //列表数据
  87. table.render({
  88. elem: '#LAY-list-manage'
  89. , url: '/Admin/TradeDaySummary/IndexData' //模拟接口
  90. , cols: [[
  91. { type: 'checkbox', fixed: 'left' }
  92. ,{field:'MakerCode', width: 200, title:'创客编号', sort: true}
  93. ,{field:'RealName', width: 200, title:'创客姓名', sort: true}
  94. // ,{field:'TopMakerCode', width: 200, title:'顶级创客编号', sort: true}
  95. // ,{field:'TopRealName', width: 200, title:'顶级创客姓名', sort: true}
  96. ,{field:'TradeDate', width: 200, title:'交易日', sort: true}
  97. ,{field:'TradeMonth', width: 200, title:'交易月', sort: true}
  98. ,{field:'NotHelpDirectTradeAmt', width: 320, title:'直营商户交易总额(稳定期)(元)', sort: true}
  99. ,{field:'NotHelpNonDirectTradeAmt', width: 320, title:'非直营商户交易总额(稳定期)(元)', sort: true}
  100. ,{field:'NotHelpDirectCreditTradeAmt', width: 320, title:'直营贷记卡交易总额(稳定期)(元)', sort: true}
  101. ,{field:'NotHelpNonDirectCreditTradeAmt', width: 320, title:'非直营贷记卡交易总额(稳定期)(元)', sort: true}
  102. ,{field:'NotHelpDirectQrCreditTradeAmt', width: 320, title:'直营云闪付贷记卡交易额(稳定期)(元)', sort: true}
  103. ,{field:'NotHelpNonDirectQrCreditTradeAmt', width: 320, title:'非直营云闪付贷记卡交易额(稳定期)(元)', sort: true}
  104. ,{field:'NotHelpDirectNonQrCreditTradeAmt', width: 320, title:'直营非云闪付贷记卡交易额(稳定期)(元)', sort: true}
  105. ,{field:'NotHelpNonDirectNonQrCreditTradeAmt', width: 320, title:'非直营非云闪付贷记卡交易额(稳定期)(元)', sort: true}
  106. ,{field:'NotHelpDirectDebitTradeAmt', width: 320, title:'直营商户借记卡交易总额(稳定期)(元)', sort: true}
  107. ,{field:'NotHelpDirectDebitCapTradeAmt', width: 320, title:'直营商户借记卡封顶交易总金额(稳定期)(元)', sort: true}
  108. ,{field:'NotHelpDirectDebitCapNum', width: 320, title:'直营商户借记卡封顶交易总数(稳定期)', sort: true}
  109. ,{field:'NotHelpNonDirectDebitTradeAmt', width: 320, title:'非直营商户借记卡交易总额(稳定期)(元)', sort: true}
  110. ,{field:'NotHelpNonDirectDebitCapTradeAmt', width: 320, title:'非直营商户借记卡封顶交易总金额(稳定期)(元)', sort: true}
  111. ,{field:'NotHelpNonDirectDebitCapNum', width: 320, title:'非直营商户借记卡封顶交易总数(稳定期)', sort: true}
  112. ,{field:'NotHelpDirectQrDebitTradeAmt', width: 320, title:'直营云闪付非封顶借记卡(稳定期)(元)', sort: true}
  113. ,{field:'NotHelpNonDirectQrDebitTradeAmt', width: 320, title:'非直营云闪付非封顶借记卡(稳定期)(元)', sort: true}
  114. ,{field:'NotHelpDirectNonQrDebitTradeAmt', width: 320, title:'直营非云闪付非封顶借记卡(稳定期)(元)', sort: true}
  115. ,{field:'NotHelpNonDirectNonQrDebitTradeAmt', width: 320, title:'非直营非云闪付非封顶借记卡(稳定期)(元)', sort: true}
  116. ,{field:'HelpDirectTradeAmt', width: 320, title:'直营商户交易总额(扶持期)(元)', sort: true}
  117. ,{field:'HelpNonDirectTradeAmt', width: 320, title:'非直营商户交易总额(扶持期)(元)', sort: true}
  118. ,{field:'HelpDirectCreditTradeAmt', width: 320, title:'直营贷记卡交易总额(扶持期)(元)', sort: true}
  119. ,{field:'HelpNonDirectCreditTradeAmt', width: 320, title:'非直营贷记卡交易总额(扶持期)(元)', sort: true}
  120. ,{field:'HelpDirectQrCreditTradeAmt', width: 320, title:'直营云闪付贷记卡交易额(扶持期)(元)', sort: true}
  121. ,{field:'HelpNonDirectQrCreditTradeAmt', width: 320, title:'非直营云闪付贷记卡交易额(扶持期)(元)', sort: true}
  122. ,{field:'HelpDirectNonQrCreditTradeAmt', width: 320, title:'直营非云闪付贷记卡交易额(扶持期)(元)', sort: true}
  123. ,{field:'HelpNonDirectNonQrCreditTradeAmt', width: 320, title:'非直营非云闪付贷记卡交易额(扶持期)(元)', sort: true}
  124. ,{field:'HelpDirectDebitTradeAmt', width: 320, title:'直营商户借记卡交易总额(扶持期)(元)', sort: true}
  125. ,{field:'HelpDirectDebitCapTradeAmt', width: 320, title:'直营商户借记卡封顶交易总金额(扶持期)(元)', sort: true}
  126. ,{field:'HelpDirectDebitCapNum', width: 320, title:'直营商户借记卡封顶交易总数(扶持期)', sort: true}
  127. ,{field:'HelpNonDirectDebitTradeAmt', width: 320, title:'非直营商户借记卡交易总额(扶持期)(元)', sort: true}
  128. ,{field:'HelpNonDirectDebitCapTradeAmt', width: 320, title:'非直营商户借记卡封顶交易总金额(扶持期)(元)', sort: true}
  129. ,{field:'HelpNonDirectDebitCapNum', width: 320, title:'非直营商户借记卡封顶交易总数(扶持期)', sort: true}
  130. ,{field:'HelpDirectQrDebitTradeAmt', width: 320, title:'直营云闪付非封顶借记卡(扶持期)(元)', sort: true}
  131. ,{field:'HelpNonDirectQrDebitTradeAmt', width: 320, title:'非直营云闪付非封顶借记卡(扶持期)(元)', sort: true}
  132. ,{field:'HelpDirectNonQrDebitTradeAmt', width: 320, title:'直营非云闪付非封顶借记卡(扶持期)(元)', sort: true}
  133. ,{field:'HelpNonDirectNonQrDebitTradeAmt', width: 320, title:'非直营非云闪付非封顶借记卡(扶持期)(元)', sort: true}
  134. ,{field:'ProfitDirectTradeAmt', width: 320, title:'直营商户交易总额(盈利期)(元)', sort: true}
  135. ,{field:'ProfitNonDirectTradeAmt', width: 320, title:'非直营商户交易总额(盈利期)(元)', sort: true}
  136. ,{field:'ProfitDirectCreditTradeAmt', width: 320, title:'直营贷记卡交易总额(盈利期)(元)', sort: true}
  137. ,{field:'ProfitNonDirectCreditTradeAmt', width: 320, title:'非直营贷记卡交易总额(盈利期)(元)', sort: true}
  138. ,{field:'ProfitDirectQrCreditTradeAmt', width: 320, title:'直营云闪付贷记卡交易额(盈利期)(元)', sort: true}
  139. ,{field:'ProfitNonDirectQrCreditTradeAmt', width: 320, title:'非直营云闪付贷记卡交易额(盈利期)(元)', sort: true}
  140. ,{field:'ProfitDirectNonQrCreditTradeAmt', width: 320, title:'直营非云闪付贷记卡交易额(盈利期)(元)', sort: true}
  141. ,{field:'ProfitNonDirectNonQrCreditTradeAmt', width: 320, title:'非直营非云闪付贷记卡交易额(盈利期)(元)', sort: true}
  142. ,{field:'ProfitDirectDebitTradeAmt', width: 320, title:'直营商户借记卡交易总额(盈利期)(元)', sort: true}
  143. ,{field:'ProfitDirectDebitCapTradeAmt', width: 320, title:'直营商户借记卡封顶交易总金额(盈利期)(元)', sort: true}
  144. ,{field:'ProfitDirectDebitCapNum', width: 320, title:'直营商户借记卡封顶交易总数(盈利期)', sort: true}
  145. ,{field:'ProfitNonDirectDebitTradeAmt', width: 320, title:'非直营商户借记卡交易总额(盈利期)(元)', sort: true}
  146. ,{field:'ProfitNonDirectDebitCapTradeAmt', width: 320, title:'非直营商户借记卡封顶交易总金额(盈利期)(元)', sort: true}
  147. ,{field:'ProfitNonDirectDebitCapNum', width: 320, title:'非直营商户借记卡封顶交易总数(盈利期)', sort: true}
  148. ,{field:'ProfitDirectQrDebitTradeAmt', width: 320, title:'直营云闪付非封顶借记卡(盈利期)(元)', sort: true}
  149. ,{field:'ProfitNonDirectQrDebitTradeAmt', width: 320, title:'非直营云闪付非封顶借记卡(盈利期)(元)', sort: true}
  150. ,{field:'ProfitDirectNonQrDebitTradeAmt', width: 320, title:'直营非云闪付非封顶借记卡(盈利期)(元)', sort: true}
  151. ,{field:'ProfitNonDirectNonQrDebitTradeAmt', width: 320, title:'非直营非云闪付非封顶借记卡(盈利期)(元)', sort: true}
  152. ]]
  153. , where: {
  154. BrandId: BrandId
  155. }
  156. , page: true
  157. , limit: 30
  158. , height: 'full-' + String($('.layui-card-header').height() + 130)
  159. , text: '对不起,加载出现异常!'
  160. , done: function (res, curr, count) {
  161. $("#tHelpDirectTradeAmt").text(res.other.tHelpDirectTradeAmt);
  162. $("#tNotHelpDirectTradeAmt").text(res.other.tNotHelpDirectTradeAmt);
  163. $("#tProfitDirectTradeAmt").text(res.other.tProfitDirectTradeAmt);
  164. $("#pHelpDirectTradeAmt").text(res.other.pHelpDirectTradeAmt);
  165. $("#pNotHelpDirectTradeAmt").text(res.other.pNotHelpDirectTradeAmt);
  166. $("#pProfitDirectTradeAmt").text(res.other.pProfitDirectTradeAmt);
  167. $(".layui-none").text("无数据");
  168. }
  169. });
  170. //监听工具条
  171. table.on('tool(LAY-list-manage)', function (obj) {
  172. var data = obj.data;
  173. if (obj.event === 'del') {
  174. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  175. $.ajax({
  176. type: "POST",
  177. url: "/Admin/TradeDaySummary/Delete?r=" + Math.random(1),
  178. data: "Id=" + data.Id,
  179. dataType: "text",
  180. success: function (data) {
  181. if (data == "success") {
  182. obj.del();
  183. layer.close(index);
  184. } else {
  185. parent.layer.msg(data);
  186. }
  187. }
  188. });
  189. });
  190. } else if (obj.event === 'edit') {
  191. var tr = $(obj.tr);
  192. var perContent = layer.open({
  193. type: 2
  194. , title: '交易日汇总-编辑'
  195. , content: 'Edit?Id=' + data.Id + ''
  196. , maxmin: true
  197. , area: ['500px', '450px']
  198. , btn: ['确定', '取消']
  199. , yes: function (index, layero) {
  200. var iframeWindow = window['layui-layer-iframe' + index]
  201. , submitID = 'LAY-list-front-submit'
  202. , submit = layero.find('iframe').contents().find('#' + submitID);
  203. setTimeout(function () {
  204. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  205. var errObj = $(this).find('.layui-form-danger');
  206. if (errObj.length > 0) {
  207. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  208. submit.click();
  209. }
  210. });
  211. }, 300);
  212. //监听提交
  213. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  214. var field = data.field; //获取提交的字段
  215. var userdata = "";
  216. for (var prop in field) {
  217. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  218. }
  219. //提交 Ajax 成功后,静态更新表格中的数据
  220. //$.ajax({});
  221. $.ajax({
  222. type: "POST",
  223. url: "/Admin/TradeDaySummary/Edit?r=" + Math.random(1),
  224. data: userdata,
  225. dataType: "text",
  226. success: function (data) {
  227. layer.close(index); //关闭弹层
  228. if (data == "success") {
  229. table.reload('LAY-list-manage'); //数据刷新
  230. } else {
  231. layer.msg(data);
  232. }
  233. }
  234. });
  235. });
  236. submit.trigger('click');
  237. }
  238. , success: function (layero, index) {
  239. }
  240. });
  241. layer.full(perContent);
  242. }
  243. });
  244. //监听搜索
  245. form.on('submit(LAY-list-front-search)', function (data) {
  246. var field = data.field;
  247. //执行重载
  248. table.reload('LAY-list-manage', {
  249. where: field,
  250. page: {
  251. curr: 1
  252. }
  253. });
  254. });
  255. form.on('submit(LAY-list-front-searchall)', function (data) {
  256. table.reload('LAY-list-manage', {
  257. where: null,
  258. page: {
  259. curr: 1
  260. }
  261. });
  262. });
  263. //事件
  264. var active = {
  265. batchdel: function () {
  266. var checkStatus = table.checkStatus('LAY-list-manage')
  267. , data = checkStatus.data; //得到选中的数据
  268. if (data.length < 1) {
  269. parent.layer.msg("请选择要删除的项");
  270. } else {
  271. var ids = "";
  272. $.each(data, function (index, value) {
  273. ids += data[index].Id + ",";
  274. });
  275. ids = ids.substring(0, ids.length - 1);
  276. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  277. $.ajax({
  278. type: "POST",
  279. url: "/Admin/TradeDaySummary/Delete?r=" + Math.random(1),
  280. data: "Id=" + ids,
  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. }
  293. }
  294. , add: function () {
  295. var perContent = layer.open({
  296. type: 2
  297. , title: '交易日汇总-添加'
  298. , content: 'Add'
  299. , maxmin: true
  300. , area: ['500px', '450px']
  301. , btn: ['确定', '取消']
  302. , yes: function (index, layero) {
  303. var iframeWindow = window['layui-layer-iframe' + index]
  304. , submitID = 'LAY-list-front-submit'
  305. , submit = layero.find('iframe').contents().find('#' + submitID);
  306. setTimeout(function () {
  307. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  308. var errObj = $(this).find('.layui-form-danger');
  309. if (errObj.length > 0) {
  310. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  311. submit.click();
  312. }
  313. });
  314. }, 300);
  315. //监听提交
  316. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  317. var field = data.field; //获取提交的字段
  318. var userdata = "";
  319. for (var prop in field) {
  320. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  321. }
  322. //提交 Ajax 成功后,静态更新表格中的数据
  323. //$.ajax({});
  324. $.ajax({
  325. type: "POST",
  326. url: "/Admin/TradeDaySummary/Add?r=" + Math.random(1),
  327. data: userdata,
  328. dataType: "text",
  329. success: function (data) {
  330. layer.close(index); //关闭弹层
  331. if (data == "success") {
  332. table.reload('LAY-list-manage'); //数据刷新
  333. } else {
  334. layer.msg(data);
  335. }
  336. }
  337. });
  338. });
  339. submit.trigger('click');
  340. }
  341. });
  342. layer.full(perContent);
  343. }
  344. , ImportData: function () {
  345. layer.open({
  346. type: 1,
  347. title: '导入',
  348. maxmin: false,
  349. area: ['460px', '180px'],
  350. content: $('#excelForm'),
  351. cancel: function () {
  352. }
  353. });
  354. }
  355. , ExportExcel: function () {
  356. var userdata = '';
  357. $(".layuiadmin-card-header-auto input").each(function (i) {
  358. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  359. });
  360. $(".layuiadmin-card-header-auto select").each(function (i) {
  361. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  362. });
  363. $.ajax({
  364. type: "GET",
  365. url: "/Admin/TradeDaySummary/ExportExcel?r=" + Math.random(1),
  366. data: userdata,
  367. dataType: "json",
  368. success: function (data) {
  369. data.Obj.unshift(data.Fields);
  370. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  371. }
  372. });
  373. }
  374. , Open: function () {
  375. var checkStatus = table.checkStatus('LAY-list-manage')
  376. , data = checkStatus.data; //得到选中的数据
  377. if(data.length < 1){
  378. parent.layer.msg("请选择要开启的项");
  379. }else{
  380. var ids = "";
  381. $.each(data, function (index, value) {
  382. ids += data[index].Id + ",";
  383. });
  384. ids = ids.substring(0, ids.length - 1);
  385. var index = layer.confirm('确定要开启吗?', function (index) {
  386. $.ajax({
  387. type: "POST",
  388. url: "/Admin/TradeDaySummary/Open?r=" + Math.random(1),
  389. data: "Id=" + ids,
  390. dataType: "text",
  391. success: function (data) {
  392. layer.close(index);
  393. if (data == "success") {
  394. table.reload('LAY-list-manage');
  395. } else {
  396. layer.msg(data);
  397. }
  398. }
  399. });
  400. });
  401. }
  402. }
  403. , Close: function () {
  404. var checkStatus = table.checkStatus('LAY-list-manage')
  405. , data = checkStatus.data; //得到选中的数据
  406. if(data.length < 1){
  407. parent.layer.msg("请选择要关闭的项");
  408. }else{
  409. var ids = "";
  410. $.each(data, function (index, value) {
  411. ids += data[index].Id + ",";
  412. });
  413. ids = ids.substring(0, ids.length - 1);
  414. var index = layer.confirm('确定要关闭吗?', function (index) {
  415. $.ajax({
  416. type: "POST",
  417. url: "/Admin/TradeDaySummary/Close?r=" + Math.random(1),
  418. data: "Id=" + ids,
  419. dataType: "text",
  420. success: function (data) {
  421. layer.close(index);
  422. if (data == "success") {
  423. table.reload('LAY-list-manage');
  424. } else {
  425. layer.msg(data);
  426. }
  427. }
  428. });
  429. });
  430. }
  431. }
  432. };
  433. $('.layui-btn').on('click', function () {
  434. var type = $(this).data('type');
  435. active[type] ? active[type].call(this) : '';
  436. });
  437. });