ITP_LOANMNG01010.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /********************************************************
  2. --------------------------------------------------------
  3. - Object 목록 -
  4. --------------------------------------------------------
  5. * const gridColModel = {} : 화면 Grid Object *
  6. * let pageObj = {} : 화면공통 Object *
  7. * let listObj = {} : 목록화면 Object *
  8. * let viewObj = {} : 상세화면 Object *
  9. * let modifyObj = {} : 수정화면 Object *
  10. * let locInfoObj = {} : 로케이션정보 Object *
  11. *******************************************************/
  12. /*화면 변수*/
  13. const LOANMNG01010_GRID_ID = '#ITP_LOANMNG01010_jqGrid';
  14. const LOANMNG01010_GRID_LIST = '#ITP_LOANMNG01010_jqGrid_list';
  15. const LOANMNG01010_GRID_PAGER = '#ITP_LOANMNG01010_jqGridPager';
  16. const LOANMNG01010_GRID_EMPTY = '#ITP_LOANMNG01010_jqGridEmpty';
  17. const LOANMNG01010_VIEW_GRID_ID = '#ITP_LOANMNG01010_VIEW_jqGrid';
  18. const LOANMNG01010_VIEW_GRID_LIST = '#ITP_LOANMNG01010_VIEW_jqGrid_list';
  19. const LOANMNG01010_VIEW_GRID_PAGER = '#ITP_LOANMNG01010_VIEW_jqGridPager';
  20. const LOANMNG01010_VIEW_GRID_EMPTY = '#ITP_LOANMNG01010_VIEW_jqGridEmpty';
  21. let ITP_FORM_LOANMNG01010_DETAIL_IS_DUPLICATE = false;
  22. let ITP_FORM_LOANMNG01010_DETAIL_IS_WRITING = false;
  23. let LOANMNG01010_DETAIL_GRID_LAST_ROW_ID;
  24. /*API URL*/
  25. let LOAN_STATE_DETAIL_GRID_LIST = '/api/loan/state/detail-grid-list';
  26. let LOAN_STATE_INFO_LOAN_MNG = '/api/loan/state/info-loan-mng';
  27. let LOAN_STATE_HIST_GRID_LIST = '/api/loan/state/hist-grid-list';
  28. /*화면 Grid ColModel*/
  29. const gridColModel = {
  30. list: [
  31. {
  32. index: 'BRAND_ID', name: 'brandId',
  33. label: "브랜드ID",
  34. width: '0', fixed: false, align: 'center',
  35. sortable: false, hidden: true
  36. },
  37. {
  38. index: 'STORE_ID', name: 'storeId',
  39. label: "매장ID",
  40. width: '0', fixed: false, align: 'center',
  41. sortable: false, hidden: true
  42. },
  43. {
  44. index: 'BRAND_NM', name: 'brandNm',
  45. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  46. width: '13', fixed: false, align: 'center',
  47. sortable: false, hidden: true
  48. },
  49. {
  50. index: 'STORE_NM', name: 'storeNm',
  51. label: "매장명",
  52. width: '13', fixed: false, align: 'center',
  53. sortable: false, hidden: false
  54. },
  55. {
  56. index: 'LOAN_MGNT_UNQ_NO', name: 'loanMgntUnqNo',
  57. label: "여신관리번호",
  58. width: '10', fixed: false, align: 'center',
  59. sortable: false, hidden: false
  60. },
  61. {
  62. index: 'LOAN_DVSN_NM', name: 'loanDvsnNm',
  63. label: "정산타입",
  64. width: '10', fixed: false, align: 'center',
  65. sortable: false, hidden: false
  66. },
  67. {
  68. index: 'LIMIT_AMT', name: 'limitAmt',
  69. label: "한도금액",
  70. width: '10', fixed: false, align: 'center',
  71. sortable: false, hidden: false,
  72. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  73. },
  74. {
  75. index: 'POSB_LIMIT_AMT', name: 'posbLimitAmt',
  76. label: "가용한도금액",
  77. width: '10', fixed: false, align: 'center',
  78. sortable: false, hidden: false,
  79. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  80. },
  81. {
  82. index: 'TMP_RCV_ACCT_TOTAL', name: 'tmpRcvAcctTotal',
  83. label: '가수금액',
  84. width: '10', fixed: false, align: 'center',
  85. sortable: false, hidden: false,
  86. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  87. },
  88. {
  89. index: 'USE_AMT_TOTAL', name: 'useAmtTotal',
  90. label: '사용금액',
  91. width: '10', fixed: false, align: 'center',
  92. sortable: false, hidden: false,
  93. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  94. },
  95. {
  96. index: 'USE_YN_NM', name: 'useYnNm',
  97. label: "사용여부",
  98. width: '8', fixed: false, align: 'center',
  99. sortable: false, hidden: false
  100. },
  101. {
  102. index: 'SYS_CHG_NM', name: 'sysChgNm',
  103. label: "최종수정자",
  104. width: '10', fixed: false, align: 'center',
  105. sortable: false, hidden: false
  106. }
  107. ],
  108. view: [
  109. {
  110. index: 'VIEW_CD', name: 'viewCd',
  111. label: ITP_MSG_LOCALE.label.viewCd,
  112. width: '10', fixed: false, align: 'center',
  113. sortable: false, hidden: true
  114. },
  115. {
  116. index: 'LOAN_REG_DT', name: 'loanRegDt',
  117. label: "발생일자",
  118. width: '10', fixed: false, align: 'center',
  119. sortable: false, editable: false, edittype: 'text'
  120. },
  121. {
  122. index: 'DPST_PAY_DVSN_NM', name: 'dpstPayDvsnNm',
  123. label: "입지구분",
  124. width: '10', fixed: false, align: 'center',
  125. sortable: false, editable: false, edittype: 'text'
  126. },
  127. {
  128. index: 'MEDIA_DVSN_NM', name: 'mediaDvsnNm',
  129. label: "매체구분",
  130. width: '10', fixed: false, align: 'center',
  131. sortable: false, editable: false, edittype: 'text'
  132. },
  133. {
  134. index: 'DPST_AMT', name: 'dpstAmt',
  135. label: "입금",
  136. width: '10', fixed: false, align: 'center',
  137. sortable: false, editable: false, edittype: 'text',
  138. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  139. },
  140. {
  141. index: 'PAYM_AMT', name: 'paymAmt',
  142. label: "지급",
  143. width: '10', fixed: false, align: 'center',
  144. sortable: false, editable: false, edittype: 'text',
  145. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  146. },
  147. {
  148. index: 'TRSC_AF_BAL', name: 'trscAfBal',
  149. label: "잔액",
  150. width: '10', fixed: false, align: 'center',
  151. sortable: false, editable: false, edittype: 'text',
  152. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  153. },
  154. {
  155. index: 'USER', name: 'user',
  156. label: "사용자",
  157. width: '10', fixed: false, align: 'center',
  158. sortable: false, editable: false, edittype: 'text'
  159. },
  160. {
  161. index: 'NO', name: 'no',
  162. label: "관련번호",
  163. width: '10', fixed: false, align: 'center',
  164. sortable: false, editable: false, edittype: 'text'
  165. }
  166. ]
  167. };
  168. require(['config'], function() {
  169. require([
  170. ], function($) {
  171. pageObj.init();
  172. });
  173. });
  174. /*화면공통 Object*/
  175. let pageObj = {
  176. init: function () {
  177. this.ui.init();
  178. this.event.init();
  179. },
  180. ui: {
  181. init: function () {
  182. this.view();
  183. this.grid();
  184. this.ready();
  185. },
  186. view: function() {
  187. // 버튼 권한설정
  188. fn_proc_btn_auth('LOANMNG01010');
  189. // 공통코드 표시
  190. $('select').each(function() {
  191. if($(this).data('select-code')) {
  192. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  193. }
  194. });
  195. // 조회일자 지정
  196. var now = new Date();
  197. $('#ITP_TAB_LOANMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  198. $('#ITP_FORM_LOANMNG01010_SEARCH_FROM').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  199. $('#ITP_FORM_LOANMNG01010_SEARCH_TO').datepicker('setDate', new Date());
  200. },
  201. grid: function() {
  202. itp_fn_jqgrid_resize(LOANMNG01010_GRID_ID, LOANMNG01010_GRID_LIST, 'lg');
  203. listObj.empty.init();
  204. itp_fn_fire_window_resize();
  205. },
  206. ready: function() {
  207. listObj.init();
  208. }
  209. },
  210. event: {
  211. init: function () {
  212. this.button();
  213. },
  214. button: function () {
  215. // 버튼 클릭 이벤트
  216. $('button').each(function() {
  217. var id = $(this).attr('id');
  218. $(this).on('click', function() {
  219. switch (id) {
  220. case 'ITP_BTN_LOANMNG01010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  221. case 'ITP_BTN_LOANMNG01010_CANCELLIST' : viewObj.button.cancel(); break; // 취소/목록 버튼
  222. case 'ITP_BTN_LOANMNG01010_VIEW_SEARCH_SRH' : viewObj.button.history(); break; // 이력조회
  223. case 'ITP_BTN_LOANMNG01010_SEARCH_SRH' : listObj.button.popupStore(); break; // 매장선택 팝업
  224. case 'ITP_BTN_LOANMNG01010_SEARCH_MODIFY' : listObj.button.eraseStore(); break; // 매장선택 삭제
  225. }
  226. });
  227. });
  228. $('body').on('click', function(e) {
  229. });
  230. }
  231. },
  232. switchScreen: function(mode) {
  233. if(mode == 'LIST') { // 목록
  234. $('#ITP_BTN_LOANMNG01010_MODIFY').hide();
  235. $('#ITP_BTN_LOANMNG01010_CANCELLIST').hide();
  236. $('#ITP_BTN_LOANMNG01010_DELETE').hide();
  237. $('#ITP_BTN_LOANMNG01010_SAVE').hide();
  238. fn_show_btn_auth('#ITP_BTN_LOANMNG01010_SRH');
  239. fn_show_btn_auth('#ITP_BTN_LOANMNG01010_NEWREG');
  240. $('#ITP_AJAX_LOANMNG01010_LIST_CONTAINER').show();
  241. $('#ITP_AJAX_LOANMNG01010_DETAIL_CONTAINER').hide();
  242. $('#ITP_AJAX_LOANMNG01010_VIEW_CONTAINER').hide();
  243. } else if(mode == 'VIEW') { // 보기
  244. $('#ITP_BTN_LOANMNG01010_SRH').hide();
  245. $('#ITP_BTN_LOANMNG01010_NEWREG').hide();
  246. $('#ITP_BTN_LOANMNG01010_DELETE').hide();
  247. $('#ITP_BTN_LOANMNG01010_SAVE').hide();
  248. fn_show_btn_auth('#ITP_BTN_LOANMNG01010_MODIFY');
  249. fn_show_btn_auth('#ITP_BTN_LOANMNG01010_CANCELLIST');
  250. $('#ITP_AJAX_LOANMNG01010_LIST_CONTAINER').hide();
  251. $('#ITP_AJAX_LOANMNG01010_DETAIL_CONTAINER').hide();
  252. $('#ITP_AJAX_LOANMNG01010_VIEW_CONTAINER').show();
  253. }
  254. }
  255. };
  256. /*목록화면 Object*/
  257. let listObj = {
  258. init: function () {
  259. this.grid.init();
  260. },
  261. itp_LOANMNG01010_search: false,
  262. button: {
  263. search: function() {
  264. listObj.itp_LOANMNG01010_search = true;
  265. let param = $('#ITP_FORM_LOANMNG01010_SEARCH').serializeObject();
  266. param.gridSize = $.jgrid.defaults.rowNum;
  267. param.gridPage = $.jgrid.defaults.page;
  268. $(LOANMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  269. },
  270. popupStore: function() { // 매장선택 팝업
  271. },
  272. eraseStore: function() { // 매장선택 삭제
  273. $('#ITP_FORM_LOANMNG01010_SEARCH_STORE_ID').val('');
  274. $('#ITP_FORM_LOANMNG01010_SEARCH_STORE_NM').val('');
  275. }
  276. },
  277. empty: {
  278. init: function() {
  279. var _this = this;
  280. this.push();
  281. $(LOANMNG01010_GRID_EMPTY).on('click', function() {
  282. _this.back();
  283. _this.itp_LOANMNG01010_param.gridSize = $.jgrid.defaults.rowNum;
  284. $(LOANMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_LOANMNG01010_param)}).trigger('reloadGrid');
  285. });
  286. },
  287. itp_LOANMNG01010_param: {},
  288. push: function() {
  289. let param = $('#ITP_FORM_LOANMNG01010_SEARCH').serializeObject();
  290. listObj.itp_LOANMNG01010_param = param;
  291. },
  292. back: function() {
  293. $('#ITP_FORM_LOANMNG01010_WHS_DVSN').val(listObj.itp_LOANMNG01010_param.swhsDvsn);
  294. $('#ITP_FORM_LOANMNG01010_WHS_ST_CD').val(listObj.itp_LOANMNG01010_param.swhsStCd);
  295. $('#ITP_FORM_LOANMNG01010_SEARCH_WHS_NM').val(listObj.itp_LOANMNG01010_param.swhsNm);
  296. }
  297. },
  298. grid: {
  299. init: function () {
  300. // 데이터 없을때
  301. listObj.empty.push();
  302. this.search();
  303. },
  304. colModel: gridColModel.list,
  305. search: function() {
  306. pageObj.switchScreen('LIST');
  307. this.unload();
  308. this.load();
  309. },
  310. load: function() {
  311. $('#ITP_FORM_LOANMNG01010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  312. let param = $('#ITP_FORM_LOANMNG01010_SEARCH').serializeObject();
  313. param.gridSize = $.jgrid.defaults.rowNum;
  314. var option = {
  315. gridId: LOANMNG01010_GRID_ID,
  316. colModel: gridColModel.list,
  317. param: JSON.stringify(param),
  318. url: DOMAIN + LOAN_STATE_DETAIL_GRID_LIST,
  319. pager: LOANMNG01010_GRID_PAGER,
  320. onCellSelect: function(rowId, cellIdx, cellValue) {
  321. var cm = $(this).jqGrid('getGridParam', 'colModel');
  322. var colNm = cm[cellIdx].name;
  323. if (colNm == 'loanDvsnNm') {
  324. const loanMgntUnqNoVal = $(this).jqGrid('getCell', rowId, 'loanMgntUnqNo');
  325. const key = {loanMgntUnqNo: loanMgntUnqNoVal, viewCd: 'R'};
  326. var param = $.param(key);
  327. viewObj.init(param);
  328. }
  329. },
  330. loadComplete: function(data) {
  331. // console.log(data);
  332. itp_fn_grid_load_complete(data, LOANMNG01010_GRID_ID, true, 'number', 'LOANMNG01010', listObj.itp_LOANMNG01010_search, listObj.empty, true, data.gridRecords, true);
  333. var ids = $(LOANMNG01010_GRID_ID).getDataIDs();
  334. $.each(ids, function(idx, rowId) {
  335. $(LOANMNG01010_GRID_ID).jqGrid('setCell', rowId, 'loanDvsnNm', '', ITP_GRID_COL_STYLE.link);
  336. });
  337. },
  338. onPaging: function(action) {
  339. itp_fn_grid_paging(LOANMNG01010_GRID_ID, action, param);
  340. }
  341. };
  342. itp_fn_grid_make_remote(option);
  343. },
  344. clearData : function() {
  345. $(LOANMNG01010_GRID_ID).jqGrid('clearGridData', true);
  346. $(LOANMNG01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  347. $(LOANMNG01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  348. $(LOANMNG01010_GRID_EMPTY).show();
  349. },
  350. unload : function() {
  351. $.jgrid.gridUnload(LOANMNG01010_GRID_ID);
  352. }
  353. }
  354. };
  355. /*상세화면 Object*/
  356. let viewObj = {
  357. init: function (param) {
  358. this.load(param);
  359. },
  360. button: {
  361. cancel: function() {
  362. listObj.grid.search();
  363. },
  364. history: function() {
  365. let param = $('#ITP_FORM_LOANMNG01010_VIEW_SEARCH').serializeObject();
  366. param.gridSize = $.jgrid.defaults.rowNum;
  367. param.gridPage = $.jgrid.defaults.page;
  368. $(LOANMNG01010_VIEW_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  369. },
  370. },
  371. load: function(param) {
  372. fn_ajax_call(LOAN_STATE_INFO_LOAN_MNG, param, this.callback, 'GET');
  373. },
  374. callback: function (result) {
  375. // console.log(result);
  376. pageObj.switchScreen('VIEW');
  377. $('#ITP_FORM_LOANMNG01010_VIEW_BRAND_ID').val(result.brandId);
  378. $('#ITP_FORM_LOANMNG01010_VIEW_STORE_ID').val(result.storeId);
  379. $('#ITP_FORM_LOANMNG01010_VIEW_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
  380. $('#ITP_FORM_LOANMNG01010_VIEW_SEARCH_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
  381. $('#ITP_FORM_LOANMNG01010_VIEW .fnBrandNm').text(result.brandNm);
  382. $('#ITP_FORM_LOANMNG01010_VIEW .fnStoreNm').text(result.storeNm);
  383. $('#ITP_FORM_LOANMNG01010_VIEW .fnLoanDvsn').text(result.loanDvsnNm);
  384. var limitAmt;
  385. if(result.loanDvsn == 'LD01') { // 선불(충전)
  386. limitAmt = result.chrgeLimitAmt;
  387. } else if(result.loanDvsn == 'LD02') { // 후불(신용)
  388. limitAmt = result.credtLimitAmt;
  389. }
  390. $('#ITP_FORM_LOANMNG01010_VIEW .fnCredtLimitAmt').text(itp_fn_number_comma(limitAmt));
  391. $('#ITP_FORM_LOANMNG01010_VIEW .fnContDt').text(''); // TODO 계약기간
  392. $('#ITP_FORM_LOANMNG01010_VIEW .fnUseYn').text(result.useYnNm);
  393. $('#ITP_FORM_LOANMNG01010_VIEW .fnPosbLimitAmt').text(itp_fn_number_comma(limitAmt - result.useAmtTotal)); // TODO 가용한도금액
  394. $('#ITP_FORM_LOANMNG01010_VIEW .fnTmpRcvAcctTotal').text(itp_fn_number_comma(result.tmpRcvAcctTotal));
  395. $('#ITP_FORM_LOANMNG01010_VIEW .fnUseAmtTotal').text(itp_fn_number_comma(result.useAmtTotal));
  396. $('#ITP_FORM_LOANMNG01010_VIEW .fnLastModify').text(result.sysChgNm + ' / ' + result.sysChgDttm);
  397. // 여신이력 리스트 조회
  398. viewObj.grid.init();
  399. },
  400. grid: {
  401. init: function() {
  402. this.unload();
  403. this.load();
  404. },
  405. load : function() {
  406. let param = $('#ITP_FORM_LOANMNG01010_VIEW_SEARCH').serializeObject();
  407. param.gridSize = $.jgrid.defaults.rowNum;
  408. param.pagingYn = false; // 페이징안함
  409. var option = {
  410. gridId: LOANMNG01010_VIEW_GRID_ID,
  411. colModel: gridColModel.view,
  412. param: JSON.stringify(param),
  413. url: DOMAIN + LOAN_STATE_HIST_GRID_LIST,
  414. pager: LOANMNG01010_VIEW_GRID_PAGER,
  415. loadComplete: function(data) {
  416. itp_fn_grid_load_complete(data, LOANMNG01010_VIEW_GRID_ID, true, undefined, 'LOANMNG01010_VIEW');
  417. },
  418. onPaging: function(action) {
  419. var pagingFn = {
  420. callBack: function(args) {
  421. $(args).trigger('reloadGrid');
  422. }
  423. };
  424. if (itp_fn_check_grid_is_writing(LOANMNG01010_VIEW_GRID_ID)) {
  425. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, LOANMNG01010_VIEW_GRID_ID);
  426. return 'stop';
  427. } else {
  428. itp_fn_grid_paging(LOANMNG01010_VIEW_GRID_ID, action, param);
  429. }
  430. },
  431. onSortCol: function(index, columnIndex, sortOrder) {
  432. var sortingFn = {
  433. callBack: function(args) {
  434. $(args).trigger('reloadGrid');
  435. }
  436. };
  437. if (itp_fn_check_grid_is_writing(LOANMNG01010_VIEW_GRID_ID)) {
  438. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, LOANMNG01010_VIEW_GRID_ID);
  439. return 'stop';
  440. } else {
  441. itp_fn_grid_sorting(LOANMNG01010_VIEW_GRID_ID, index, sortOrder);
  442. }
  443. }
  444. };
  445. itp_fn_grid_make_remote(option);
  446. },
  447. clearData : function() {
  448. $(LOANMNG01010_VIEW_GRID_ID).jqGrid('clearGridData', true);
  449. $(LOANMNG01010_VIEW_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  450. $(LOANMNG01010_VIEW_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  451. $(LOANMNG01010_VIEW_GRID_EMPTY).show();
  452. },
  453. unload : function() {
  454. $.jgrid.gridUnload(LOANMNG01010_VIEW_GRID_ID);
  455. }
  456. }
  457. };