ITP_MLOANMNG01011.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. mobPageObj.init();
  5. });
  6. });
  7. /*API URL*/
  8. const API_MOBILE_INFO = '/api/loan/state/info-loan-store'; // 상세
  9. const API_MOBILE_HISTORY = '/api/loan/state/hist-grid-list'; // 이력
  10. let mobPageObj = {
  11. init: function () {
  12. this.ui.init();
  13. this.event.init();
  14. this.ready();
  15. },
  16. ui: {
  17. init: function () {
  18. this.view();
  19. },
  20. view: function() {
  21. // 공통코드 표시
  22. $('select').each(function() {
  23. if($(this).data('select-code')) {
  24. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  25. }
  26. });
  27. // 조회일자 지정
  28. $('#ITP_MOBILE_MLOANMNG01011 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
  29. $('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH_FROM_DT').datepicker('setDate', itp_fn_date_add('M', -1));
  30. $('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH_TO_DT').datepicker('setDate', itp_fn_date_add('M', 0));
  31. $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
  32. $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
  33. }
  34. },
  35. event: {
  36. init: function() {
  37. this.button();
  38. },
  39. button: function() {
  40. $('button[id^="ITP_BTN_MLOANMNG01011_VIEW"]').on('click', function() {
  41. var id = $(this).attr('id');
  42. switch (id) {
  43. case 'ITP_BTN_MLOANMNG01011_VIEW_SEARCH' : mobContentObj.view.history.search(); break;
  44. }
  45. return false;
  46. });
  47. }
  48. },
  49. ready: function() {
  50. mobContentObj.view.init();
  51. }
  52. };
  53. let mobContentObj = {
  54. view: {
  55. init: function() {
  56. this.load();
  57. },
  58. load: function(item) {
  59. var _this = this;
  60. var callbackFn = function(result) {
  61. console.log(result);
  62. _this.view(result);
  63. };
  64. fn_ajax_call(API_MOBILE_INFO, null, callbackFn, 'GET');
  65. },
  66. view: function(result) {
  67. var id = '#ITP_AJAX_MLOANMNG01011_VIEW_CONTAINER';
  68. $(id).find('.fnStoreNm').text(result.storeNm);
  69. $(id).find('.fnLoanDvsnNm').text(result.loanDvsnNm);
  70. var limitAmt;
  71. if(result.loanDvsn == 'LD01') { // 선불(충전)
  72. limitAmt = result.chrgeLimitAmt;
  73. } else if(result.loanDvsn == 'LD02') { // 후불(신용)
  74. limitAmt = result.credtLimitAmt;
  75. }
  76. $(id).find('.fnLimitAmt').text(CommonObj.currency.add(limitAmt));
  77. $(id).find('.fnUseYnNm').text(result.useYnNm);
  78. $(id).find('.fnPosbLimitAmt').text(CommonObj.currency.add(limitAmt - result.useAmtTotal));
  79. $(id).find('.fnTmpRcvAcctTotal').text(CommonObj.currency.add(result.tmpRcvAcctTotal));
  80. $(id).find('.fnUseAmtTotal').text(CommonObj.currency.add(result.useAmtTotal));
  81. $(id).find('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
  82. this.history.init();
  83. },
  84. history: {
  85. rows: [],
  86. init: function() {
  87. // 조회일자 지정
  88. $('#ITP_MOBILE_MLOANMNG01011 .itp_input.date').datepicker(ITP_DATE_LANGUAGE);
  89. $('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH_FROM_DT').datepicker('setDate', itp_fn_date_add('M', -1));
  90. $('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH_TO_DT').datepicker('setDate', itp_fn_date_add('M', 0));
  91. this.search();
  92. this.action();
  93. },
  94. action: function() {
  95. var _this = this;
  96. $('#ITP_LIST_MLOANMNG01011_VIEW_ITEM_AREA').on('scroll', function () {
  97. if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
  98. if(_this.totPage > _this.listPage) {
  99. _this.load();
  100. }
  101. }
  102. });
  103. },
  104. search: function() {
  105. this.listPage = 0;
  106. this.totPage = 0;
  107. this.rows.length = 0;
  108. $('#ITP_LIST_MLOANMNG01011_VIEW_ITEM_ROWS').empty();
  109. this.load();
  110. },
  111. load: function() {
  112. var _this = this;
  113. this.isSearch = true;
  114. var callbackFn = function(result) {
  115. console.log(result);
  116. _this.isSearch = false;
  117. _this.totPage = result.gridTotal;
  118. $.each(result.gridRows, function (i, item) {
  119. $('#ITP_LIST_MLOANMNG01011_VIEW_ITEM_AREA .panel-group').append($('#ITP_LIST_MLOANMNG01011_VIEW_ITEM_ROWCOPY').html());
  120. var $li = $('#ITP_LIST_MLOANMNG01011_VIEW_ITEM_AREA .panel-group > .item-row:last');
  121. $li.find('.fnLoanRegDt').text(item.loanRegDt + ' ' + item.loanRegTm);
  122. $li.find('.fnDpstPayDvsnNm').text(item.dpstPayDvsnNm);
  123. $li.find('.fnTrscAmt').text(CommonObj.currency.add(item.trscAmt));
  124. $li.find('.fnTrscAfBal').text(CommonObj.currency.add(item.trscAfBal));
  125. _this.rows.push(item);
  126. });
  127. };
  128. var errFn = function() { _this.isSearch = false;};
  129. const param = $('#ITP_FORM_MLOANMNG01011_VIEW_SEARCH').serializeObject();
  130. param.gridPage = ++this.listPage;
  131. param.gridSize = this.listSize;
  132. console.log(JSON.stringify(param));
  133. fn_ajax_call(API_MOBILE_HISTORY, JSON.stringify(param), callbackFn, 'POST', errFn);
  134. }
  135. }
  136. }
  137. };