ITP_LOANMNG03010.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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 createObj = {} : 신규화면 Object *
  11. *******************************************************/
  12. //[grid]
  13. /*화면 변수*/
  14. const LOANMNG03010_GRID_ID = '#ITP_LOANMNG03010_jqGrid';
  15. const LOANMNG03010_GRID_LIST = '#ITP_LOANMNG03010_jqGrid_list';
  16. const LOANMNG03010_GRID_PAGER = '#ITP_LOANMNG03010_jqGridPager';
  17. const LOANMNG03010_GRID_EMPTY = '#ITP_LOANMNG03010_jqGridEmpty';
  18. const LOANMNG03010_VIEW_GRID_ID = '#ITP_LOANMNG03010_VIEW_jqGrid';
  19. const LOANMNG03010_VIEW_GRID_LIST = '#ITP_LOANMNG03010_VIEW_jqGrid_list';
  20. const LOANMNG03010_VIEW_GRID_PAGER = '#ITP_LOANMNG03010_VIEW_jqGridPager';
  21. const LOANMNG03010_VIEW_GRID_EMPTY = '#ITP_LOANMNG03010_VIEW_jqGridEmpty';
  22. const LOANMNG03010_DETAIL_GRID_ID = '#ITP_LOANMNG03010_DETAIL_jqGrid';
  23. const LOANMNG03010_DETAIL_GRID_LIST = '#ITP_LOANMNG03010_DETAIL_jqGrid_list';
  24. const LOANMNG03010_DETAIL_GRID_PAGER = '#ITP_LOANMNG03010_DETAIL_jqGridPager';
  25. const LOANMNG03010_DETAIL_GRID_EMPTY = '#ITP_LOANMNG03010_DETAIL_jqGridEmpty';
  26. let ITP_FORM_LOANMNG03010_DETAIL_IS_DUPLICATE = false;
  27. let ITP_FORM_LOANMNG03010_DETAIL_IS_WRITING = false;
  28. let LOANMNG03010_DETAIL_GRID_LAST_ROW_ID;
  29. /*API URL*/
  30. let UNPAID_MNG_DETAIL_GRID_LIST = '/api/unpaid/mng/detail-grid-list';
  31. let UNPAID_MNG_STL_GRID_LIST = '/api/unpaid/mng/stl-grid-list';
  32. let UNPAID_MNG_INFO_UNPAID = '/api/unpaid/mng/info-unpaid';
  33. let WHS_MNG_ADD_WHS = '/api/whs/mng/add-whs';
  34. let WHS_MNG_MIDIFY_WHS = '/api/whs/mng/modify-whs';
  35. let WHS_MNG_REMOVE_WHS = '/api/whs/mng/remove-whs';
  36. let LOGIN_AUTH_TYPE_CD;
  37. /*화면 Grid ColModel*/
  38. const gridColModel = {
  39. list: [
  40. {
  41. index: 'BRAND_ID', name: 'brandId',
  42. label: "브랜드ID",
  43. width: '0', fixed: false, align: 'center',
  44. sortable: false, hidden: true
  45. },
  46. {
  47. index: 'STORE_ID', name: 'storeId',
  48. label: "매장ID",
  49. width: '0', fixed: false, align: 'center',
  50. sortable: false, hidden: true
  51. },
  52. {
  53. index: 'BRAND_NM', name: 'brandNm',
  54. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  55. width: '13', fixed: false, align: 'center',
  56. sortable: false, hidden: true
  57. },
  58. {
  59. index: 'STORE_NM', name: 'storeNm',
  60. label: "매장명",
  61. width: '13', fixed: false, align: 'left',
  62. sortable: false, hidden: false, classes: 'ui-ellipsis'
  63. },
  64. {
  65. index: 'LOAN_DVSN_NM', name: 'loanDvsnNm',
  66. label: "정산타입",
  67. width: '8', fixed: false, align: 'center',
  68. sortable: false, hidden: false
  69. },
  70. {
  71. index: 'STTL_MGNT_UNQ_NO', name: 'sttlMgntUnqNo',
  72. label: "정산번호",
  73. width: '14', fixed: false, align: 'center',
  74. sortable: false, hidden: false
  75. },
  76. {
  77. index: 'STTL_ST_NM', name: 'sttlStNm',
  78. label: "상태",
  79. width: '6', fixed: false, align: 'center',
  80. sortable: false, hidden: false
  81. },
  82. {
  83. index: 'STTL_REQ_DT', name: 'sttlReqDt',
  84. label: "정산요청일",
  85. width: '8', fixed: false, align: 'center',
  86. sortable: false, hidden: false
  87. },
  88. {
  89. index: 'STTL_REQ_AMT', name: 'sttlReqAmt',
  90. label: '정산요청금액',
  91. width: '10', fixed: false, align: 'right',
  92. sortable: false, hidden: false,
  93. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  94. },
  95. {
  96. index: 'STTL_DT', name: 'sttlDt',
  97. label: "정산확정일",
  98. width: '10', fixed: false, align: 'center',
  99. sortable: false, hidden: false
  100. },
  101. {
  102. index: 'UNPAId_AMT', name: 'unpaidAmt',
  103. label: '미납금액',
  104. width: '10', fixed: false, align: 'right',
  105. sortable: false, hidden: false,
  106. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  107. },
  108. {
  109. index: 'USE_AMT_TOTAL', name: 'useAmtTotal',
  110. label: '사용가능한도',
  111. width: '10', fixed: false, align: 'right',
  112. sortable: false, hidden: false,
  113. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  114. },
  115. {
  116. index: 'SEARCH_SUM', name: 'searchSum',
  117. label: ITP_MSG_LOCALE.label.brandNm, //합계
  118. width: '13', fixed: false, align: 'left',
  119. minwidth: 200,
  120. sortable: false, hidden: true, classes: 'ui-ellipsis'
  121. }
  122. ],
  123. view: [
  124. {
  125. index: 'VIEW_CD', name: 'viewCd',
  126. label: ITP_MSG_LOCALE.label.viewCd,
  127. width: '10', fixed: false, align: 'center',
  128. sortable: false, hidden: true
  129. },
  130. {
  131. index: 'STTL_MGNT_DTL_NO', name: 'sttlMgntDtlNo',
  132. label: '정산관리상세번호',
  133. width: '10', fixed: false, align: 'center',
  134. sortable: false, hidden: true
  135. },
  136. {
  137. index: 'BRAND_NM', name: 'brandNm',
  138. label: "브랜드",
  139. width: '10', fixed: false, align: 'center',
  140. sortable: false, hidden: true
  141. },
  142. {
  143. index: 'STORE_NM', name: 'storeNm',
  144. label: "매장명",
  145. width: '10', fixed: false, align: 'center',
  146. sortable: false, hidden: true
  147. },
  148. {
  149. index: 'ITEM_ID', name: 'itemId',
  150. label: "품목코드",
  151. width: '10', fixed: false, align: 'center',
  152. sortable: false, editable: false, edittype: 'text'
  153. },
  154. {
  155. index: 'ITEM_NM', name: 'itemNm',
  156. label: "품목명",
  157. width: '10', fixed: false, align: 'left',
  158. sortable: false, editable: false, edittype: 'text', classes: 'ui-ellipsis'
  159. },
  160. {
  161. index: 'UNIT', name: 'unit',
  162. label: "단위",
  163. width: '8', fixed: false, align: 'center',
  164. sortable: false, editable: false, edittype: 'text'
  165. },
  166. {
  167. index: 'UNIT_AMT', name: 'unitAmt',
  168. label: "단가",
  169. width: '8', fixed: false, align: 'right',
  170. sortable: false, editable: false, edittype: 'text',
  171. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  172. },
  173. {
  174. index: 'PODR_QTY', name: 'podrQty',
  175. label: "발주수량",
  176. width: '8', fixed: false, align: 'right',
  177. sortable: false, editable: false, edittype: 'text',
  178. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  179. },
  180. {
  181. index: 'DLV_QTY', name: 'dlvQty',
  182. label: "납품수량",
  183. width: '8', fixed: false, align: 'right',
  184. sortable: false, editable: false, edittype: 'text',
  185. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  186. },
  187. {
  188. index: 'WHS_COL_QTY', name: 'whsColQty',
  189. label: "입고/수거수량",
  190. width: '8', fixed: false, align: 'right',
  191. sortable: false, editable: false, edittype: 'text',
  192. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  193. },
  194. {
  195. index: 'WHS_COL_DT', name: 'whsColDt',
  196. label: "입고/수거일자",
  197. width: '8', fixed: false, align: 'center',
  198. sortable: false, editable: false, edittype: 'text'
  199. },
  200. {
  201. index: 'WHS_COL_AMT', name: 'whsColAmt',
  202. label: "입고/수거금액",
  203. width: '8', fixed: false, align: 'right',
  204. sortable: false, editable: false, edittype: 'text',
  205. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  206. },
  207. {
  208. index: 'STTL_DVSN_NM', name: 'sttlDvsnNm',
  209. label: "정산구분",
  210. width: '8', fixed: false, align: 'center',
  211. sortable: false, editable: false, edittype: 'text'
  212. },
  213. {
  214. index: 'PODR_UNQ_NO', name: 'podrUnqNo',
  215. label: "발주번호",
  216. width: '8', fixed: false, align: 'center',
  217. sortable: false, editable: false, edittype: 'text'
  218. },
  219. {
  220. index: 'PODR_DTL_NO', name: 'podrDtlNo',
  221. label: "발주항번",
  222. width: '8', fixed: false, align: 'center',
  223. sortable: false, editable: false, edittype: 'text'
  224. }
  225. ]
  226. };
  227. require(['config'], function() {
  228. require([
  229. 'kakao.map.util'
  230. ], function($) {
  231. pageObj.init();
  232. });
  233. });
  234. /*화면공통 Object*/
  235. let pageObj = {
  236. init: function () {
  237. this.ui.init();
  238. this.event.init();
  239. },
  240. ui: {
  241. init: function () {
  242. this.view();
  243. this.grid();
  244. this.ready();
  245. },
  246. view: function() {
  247. // 버튼 권한설정
  248. fn_proc_btn_auth('LOANMNG03010');
  249. // 공통코드 표시
  250. $('select').each(function() {
  251. if($(this).data('select-code')) {
  252. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  253. }
  254. });
  255. // 조회일자 지정
  256. var now = new Date();
  257. var fromDate = new Date(now);
  258. fromDate.setDate(now.getDate() - 7);
  259. var toDate = new Date(now);
  260. $('#ITP_FORM_LOANMNG03010_SEARCH_FROM_DT').val(itp_fn_get_before_month() );
  261. $('#ITP_FORM_LOANMNG03010_SEARCH_TO_DT').val(itp_fn_get_today_ko() );
  262. $('#ITP_TAB_LOANMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  263. $('#ITP_FORM_LOANMNG03010_SEARCH_FROM_DT').datepicker();
  264. $('#ITP_FORM_LOANMNG03010_SEARCH_TO_DT').datepicker();
  265. // 권한에 따라 매장값 설정
  266. $('#ITP_FORM_LOANMNG03010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  267. LOGIN_AUTH_TYPE_CD = fn_make_user_info.get('authTpCd'); // 권한타입
  268. if(LOGIN_AUTH_TYPE_CD == '50') {
  269. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
  270. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_NM').val(fn_make_user_info.get('storeNm'));
  271. }
  272. },
  273. grid: function() {
  274. listObj.empty.init();
  275. },
  276. ready: function() {
  277. listObj.init();
  278. }
  279. },
  280. event: {
  281. init: function () {
  282. this.button();
  283. },
  284. button: function () {
  285. // 버튼 클릭 이벤트
  286. $('button').each(function() {
  287. var id = $(this).attr('id');
  288. $(this).on('click', function() {
  289. switch (id) {
  290. case 'ITP_BTN_LOANMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  291. case 'ITP_BTN_LOANMNG03010_CANCELLIST' : viewObj.button.cancel(); break; // 취소/목록 버튼
  292. case 'ITP_BTN_LOANMNG03010_PAYMENT' : viewObj.button.payment(); break; // 결제 버튼
  293. case 'ITP_BTN_LOANMNG03010_DEPOSIT' : viewObj.button.deposit(); break; // 입금 버튼
  294. case 'ITP_BTN_LOANMNG03010_STORE_SEARCH' : listObj.button.storePop(); break; // 매장검색 팝업
  295. case 'ITP_BTN_LOANMNG03010_STORE_ERASE' : listObj.button.storeErase(); break; // 매장 지움
  296. case 'ITP_BTN_LOANMNG03010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  297. }
  298. });
  299. });
  300. $('body').on('click', function(e) {
  301. var gridId = LOANMNG03010_DETAIL_GRID_ID.replace('#', '');
  302. var rids = $(LOANMNG03010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  303. var last_row_id = rids[rids.length - 1];
  304. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'LOANMNG03010_DETAIL');
  305. });
  306. }
  307. },
  308. switchScreen: function(mode) {
  309. if(mode == 'LIST') { // 목록
  310. $('#ITP_BTN_LOANMNG03010_MODIFY').hide();
  311. $('#ITP_BTN_LOANMNG03010_CANCELLIST').hide();
  312. $('#ITP_BTN_LOANMNG03010_DELETE').hide();
  313. $('#ITP_BTN_LOANMNG03010_PAYMENT').hide();
  314. $('#ITP_BTN_LOANMNG03010_DEPOSIT').hide();
  315. if(LOGIN_AUTH_TYPE_CD == '50') { // 매장관리자
  316. $('#ITP_BTN_LOANMNG03010_STORE_SEARCH').hide();
  317. $('#ITP_BTN_LOANMNG03010_STORE_ERASE').hide();
  318. } else {
  319. $('#ITP_BTN_LOANMNG03010_STORE_SEARCH').show();
  320. $('#ITP_BTN_LOANMNG03010_STORE_ERASE').show();
  321. }
  322. fn_show_btn_auth('#ITP_BTN_LOANMNG03010_SRH');
  323. fn_show_btn_auth('#ITP_BTN_LOANMNG03010_NEWREG');
  324. $('#ITP_AJAX_LOANMNG03010_LIST_CONTAINER').show();
  325. $('#ITP_AJAX_LOANMNG03010_DETAIL_CONTAINER').hide();
  326. $('#ITP_AJAX_LOANMNG03010_VIEW_CONTAINER').hide();
  327. $('#ITP_BTN_LOANMNG03010_EXCEL').show();
  328. } else if(mode == 'VIEW') { // 보기
  329. $('#ITP_BTN_LOANMNG03010_SRH').hide();
  330. $('#ITP_BTN_LOANMNG03010_NEWREG').hide();
  331. $('#ITP_BTN_LOANMNG03010_DELETE').hide();
  332. fn_show_btn_auth('#ITP_BTN_LOANMNG03010_PAYMENT');
  333. fn_show_btn_auth('#ITP_BTN_LOANMNG03010_DEPOSIT');
  334. fn_show_btn_auth('#ITP_BTN_LOANMNG03010_CANCELLIST');
  335. $('#ITP_AJAX_LOANMNG03010_LIST_CONTAINER').hide();
  336. $('#ITP_AJAX_LOANMNG03010_DETAIL_CONTAINER').hide();
  337. $('#ITP_AJAX_LOANMNG03010_VIEW_CONTAINER').show();
  338. }
  339. }
  340. };
  341. /*목록화면 Object*/
  342. let listObj = {
  343. init: function () {
  344. this.grid.init();
  345. },
  346. itp_LOANMNG03010_search: false,
  347. button: {
  348. search: function() {
  349. listObj.itp_LOANMNG03010_search = true;
  350. let param = $('#ITP_FORM_LOANMNG03010_SEARCH').serializeObject();
  351. param.gridSize = $.jgrid.defaults.rowNum;
  352. param.gridPage = $.jgrid.defaults.page;
  353. $(LOANMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  354. },
  355. create: function() {
  356. pageObj.switchScreen('ADD');
  357. itp_fn_form_clear_validate(null, '#ITP_FORM_LOANMNG03010_DETAIL');
  358. // 로케이션 리스트 조회
  359. createObj.init();
  360. },
  361. storePop: function() {
  362. const key = {loanDvsn:"LD02"};
  363. fn_call_popup('biz', 'BIZPOP_BRAND_STORE', '#ITP_ASIDE',function(result) {
  364. // alert(JSON.stringify(result));
  365. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_ID').val(result[0].storeId);
  366. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_NM').val(result[0].storeNm);
  367. listObj.button.search();
  368. }, key, 'S');
  369. },
  370. storeErase: function() {
  371. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_ID').val('');
  372. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_NM').val('');
  373. listObj.button.search();
  374. }
  375. },
  376. empty: {
  377. init: function() {
  378. var _this = this;
  379. this.push();
  380. $(LOANMNG03010_GRID_EMPTY).on('click', function() {
  381. _this.back();
  382. _this.itp_LOANMNG03010_param.gridSize = $.jgrid.defaults.rowNum;
  383. $(LOANMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_LOANMNG03010_param)}).trigger('reloadGrid');
  384. });
  385. },
  386. itp_LOANMNG03010_param: {},
  387. push: function() {
  388. let param = $('#ITP_FORM_LOANMNG03010_SEARCH').serializeObject();
  389. listObj.itp_LOANMNG03010_param = param;
  390. },
  391. back: function() {
  392. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_ID').val(listObj.itp_LOANMNG03010_param.sstoreId);
  393. $('#ITP_FORM_LOANMNG03010_SEARCH_STORE_NM').val(listObj.itp_LOANMNG03010_param.sstoreNm);
  394. $('#ITP_FORM_LOANMNG03010_SEARCH_FROM_DT').val(listObj.itp_LOANMNG03010_param.fromDt);
  395. $('#ITP_FORM_LOANMNG03010_SEARCH_TO_DT').val(listObj.itp_LOANMNG03010_param.toDt);
  396. }
  397. },
  398. grid: {
  399. init: function () {
  400. // 데이터 없을때
  401. itp_fn_jqgrid_resize(LOANMNG03010_GRID_ID, LOANMNG03010_GRID_LIST, 'lg');
  402. listObj.empty.push();
  403. this.search();
  404. },
  405. colModel: gridColModel.list,
  406. search: function() {
  407. pageObj.switchScreen('LIST');
  408. this.unload();
  409. this.load();
  410. },
  411. load: function() {
  412. let param = $('#ITP_FORM_LOANMNG03010_SEARCH').serializeObject();
  413. param.gridSize = $.jgrid.defaults.rowNum;
  414. var option = {
  415. gridId: LOANMNG03010_GRID_ID,
  416. colModel: gridColModel.list,
  417. param: param,
  418. url: DOMAIN + UNPAID_MNG_DETAIL_GRID_LIST,
  419. pager: LOANMNG03010_GRID_PAGER,
  420. onCellSelect: function(rowId, cellIdx, cellValue) {
  421. var cm = $(this).jqGrid('getGridParam', 'colModel');
  422. var colNm = cm[cellIdx].name;
  423. if (colNm == 'sttlMgntUnqNo') {
  424. const sttlMgntUnqNoVal = $(this).jqGrid('getCell', rowId, 'sttlMgntUnqNo');
  425. const key = {sttlMgntUnqNo: sttlMgntUnqNoVal, viewCd: 'R'};
  426. var param = $.param(key);
  427. viewObj.init(param);
  428. }
  429. },
  430. loadComplete: function(data) {
  431. itp_fn_grid_load_complete(data, LOANMNG03010_GRID_ID, true, 'number', 'LOANMNG03010', listObj.itp_LOANMNG03010_search, listObj.empty, true, data.gridRecords, true);
  432. var ids = $(LOANMNG03010_GRID_ID).getDataIDs();
  433. let searchAmtSum = 0;
  434. if (ids.length > 0) {
  435. var rowData = $(LOANMNG03010_GRID_ID).jqGrid('getRowData', ids[0]);
  436. searchAmtSum = rowData.searchSum;
  437. }
  438. $('#ITP_LOANMNG03010_UNPAId_TOT_SUM').val(itp_fn_number_comma(searchAmtSum));
  439. $.each(ids, function(idx, rowId) {
  440. $(LOANMNG03010_GRID_ID).jqGrid('setCell', rowId, 'sttlMgntUnqNo', '', ITP_GRID_COL_STYLE.link);
  441. });
  442. const self=this;
  443. if(self.sortUse) return;
  444. self.sortUse=true;
  445. self['sort4']='desc';
  446. const th=$(LOANMNG03010_GRID_LIST).find('.ui-jqgrid-labels .ui-th-div').eq(4);
  447. th.find('.s-ico').show();
  448. th.find('.ui-grid-ico-sort').hide();
  449. th.find('.glyphicon-triangle-top').show();//asc 는 bottom 으로
  450. //$(LOANMNG03010_GRID_LIST).find('.ui-jqgrid-labels .ui-th-div').css('cursor','default');
  451. $(LOANMNG03010_GRID_LIST).find('th').eq(4).css({cursor:'pointer',background:'#FFEBCD'});
  452. $(LOANMNG03010_GRID_LIST).find('th').eq(5).css({cursor:'pointer',background:'#FFEBCD'});
  453. $(LOANMNG03010_GRID_LIST).find('th').eq(6).css({cursor:'pointer',background:'#FFEBCD'});
  454. $(LOANMNG03010_GRID_LIST).find('th').eq(8).css({cursor:'pointer',background:'#FFEBCD'});
  455. $(LOANMNG03010_GRID_LIST).find('.ui-jqgrid-labels>th').on('click', function() {
  456. const idx=$(this).index();
  457. console.log("xxxx grid header click xxxxxxx index=="+idx, param );
  458. if(idx==4 || idx==5 || idx==6 || idx==8) {
  459. var field='',sort=self['sort'+idx];
  460. if(sort ) {
  461. sort=sort=='asc'?'desc':'asc';
  462. } else {
  463. // 등록일 내림차순, 제목 오름차순
  464. sort=idx==4? 'desc':idx==5? 'asc': 'desc';
  465. }
  466. const icon=sort=='asc'? '.glyphicon-triangle-bottom': '.glyphicon-triangle-top';
  467. self['sort'+idx]=sort;
  468. if(idx==4) {
  469. field='storeNm';
  470. } else if(idx==5) {
  471. field='loanDvsnNm';
  472. } else if(idx==6) {
  473. field='sttlMgntUnqNo';
  474. } else if(idx==8) {
  475. field='sttlReqDt';
  476. }
  477. param.page=1;
  478. param.sidx=field;
  479. param.sord=sort;
  480. $(LOANMNG03010_GRID_ID).jqGrid('setGridParam',{
  481. postData:JSON.stringify(param)
  482. }).trigger('reloadGrid');
  483. $(this).find('.s-ico').show();
  484. $(this).find('.ui-grid-ico-sort').hide();
  485. $(this).find(icon).show();
  486. }
  487. });
  488. },
  489. onPaging: function(action) {
  490. itp_fn_grid_paging(LOANMNG03010_GRID_ID, action, param);
  491. }
  492. };
  493. itp_fn_grid_make_remote(option);
  494. },
  495. clearData : function() {
  496. $(LOANMNG03010_GRID_ID).jqGrid('clearGridData', true);
  497. $(LOANMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  498. $(LOANMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  499. $(LOANMNG03010_GRID_EMPTY).show();
  500. },
  501. unload : function() {
  502. $.jgrid.gridUnload(LOANMNG03010_GRID_ID);
  503. }
  504. },
  505. excelDown: function() {
  506. var param = {
  507. 'url': UNPAID_MNG_DETAIL_GRID_LIST,
  508. 'param': $('#ITP_FORM_LOANMNG03010_SEARCH').serializeObject(),
  509. 'gridColumns': $(LOANMNG03010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  510. 'fileName': '미납금현황.xlsx',
  511. 'sheetName': '미납금리스트'
  512. };
  513. itp_fn_remote_to_excel(param);
  514. }
  515. };
  516. /*상세화면 Object*/
  517. let viewObj = {
  518. init: function (param) {
  519. this.load(param);
  520. },
  521. button: {
  522. cancel: function() {
  523. listObj.grid.search();
  524. },
  525. payment: function() {
  526. // 결제 팝업 결과
  527. var popFn = function(rowDataPop) {
  528. listObj.grid.search();
  529. };
  530. // 결제 팝업
  531. // 결제타입코드 : 10(선불(충전)), 20(후불(결제)), 30(후불(선결제))
  532. var acctVal = $('#ITP_FORM_LOANMNG03010_VIEW_ACCT_BAL').val();
  533. var unpaidAmt = $('#ITP_FORM_LOANMNG03010_VIEW_UNPAID_AMT').val();
  534. var goodsAmt = parseInt(unpaidAmt) - parseInt(acctVal);
  535. var args = {'payTpCd': '20',
  536. 'brandId': $('#ITP_FORM_LOANMNG03010_VIEW_BRAND_ID').val(),
  537. 'storeId': $('#ITP_FORM_LOANMNG03010_VIEW_STORE_ID').val(),
  538. 'sttlMgntUnqNoList': $('#ITP_FORM_LOANMNG03010_VIEW_STTL_MGNT_UNQ_NO').val(),
  539. 'goodsAmt': goodsAmt };
  540. fn_call_popup('biz', 'BIZPOP_PO_PAYMENT', '#ITP_ASIDE', popFn, args, 'S');
  541. },
  542. deposit: function() {
  543. // 입금관리 화면 활성화
  544. // $('#LOANMNG02010_PAGE_NO').trigger('click');
  545. if($('#ITP_FORM_LOANMNG03010_VIEW_DSPT_MGNT_NO').val() != '' && $('#ITP_FORM_LOANMNG03010_VIEW_DPST_ST_CD').val() == 'DP01') {
  546. itp_fn_modal_alert_ajax('입금 요청중인 데이터 입니다.<br>입금관리에서 데이터를 확인하세요.');
  547. return;
  548. }
  549. var acctVal = $('#ITP_FORM_LOANMNG03010_VIEW_ACCT_BAL').val();
  550. var unpaidAmt = $('#ITP_FORM_LOANMNG03010_VIEW_UNPAID_AMT').val();
  551. var goodsAmt = parseInt(unpaidAmt) - parseInt(acctVal);
  552. var args = {'payTpCd': '20',
  553. 'brandId': $('#ITP_FORM_LOANMNG03010_VIEW_BRAND_ID').val(),
  554. 'brandNm': $('#ITP_FORM_LOANMNG03010_VIEW .fnBrandNm').text(),
  555. 'storeId': $('#ITP_FORM_LOANMNG03010_VIEW_STORE_ID').val(),
  556. 'storeNm': $('#ITP_FORM_LOANMNG03010_VIEW .fnStoreNm').text(),
  557. 'sttlMgntUnqNo': $('#ITP_FORM_LOANMNG03010_VIEW_STTL_MGNT_UNQ_NO').val(),
  558. 'goodsAmt': goodsAmt };
  559. fn_call_popup('biz', 'BIZPOP_DSPT_INFO_REG', '#ITP_ASIDE', function(result) {
  560. // console.log('>>>>> 팝업결과 : ' + JSON.stringify(result));
  561. listObj.grid.search();
  562. }, args, 'S');
  563. }
  564. },
  565. load: function(param) {
  566. fn_ajax_call(UNPAID_MNG_INFO_UNPAID, param, this.callback, 'GET');
  567. },
  568. callback: function (result) {
  569. // console.log(result);
  570. pageObj.switchScreen('VIEW');
  571. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_BRAND_ID').val(result.brandId);
  572. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_STORE_ID').val(result.storeId);
  573. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_STTL_MGNT_UNQ_NO').val(result.sttlMgntUnqNo);
  574. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_RCPT_YN').val(result.rcptYn);
  575. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_UNPAID_AMT').val(result.unpaidAmt); // 미납금액
  576. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_ACCT_BAL').val(result.acctBal); // 계좌잔액
  577. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_DSPT_MGNT_NO').val(result.dsptMgntNo);
  578. $('#ITP_FORM_LOANMNG03010_VIEW #ITP_FORM_LOANMNG03010_VIEW_DPST_ST_CD').val(result.dpstStCd);
  579. $('#ITP_FORM_LOANMNG03010_VIEW .fnBrandNm').text(result.brandNm);
  580. $('#ITP_FORM_LOANMNG03010_VIEW .fnStoreNm').text(result.storeNm);
  581. $('#ITP_FORM_LOANMNG03010_VIEW .fnSttlReqDt').text(result.sttlReqDt);
  582. $('#ITP_FORM_LOANMNG03010_VIEW .fnSttlDt').text(result.sttlDt == null ? '' : result.sttlDt);
  583. $('#ITP_FORM_LOANMNG03010_VIEW .fnSttlStNm').text(result.sttlStNm);
  584. // $('#ITP_FORM_LOANMNG03010_VIEW .fnSysRegDttm').text(result.sysRegDttm);
  585. $('#ITP_FORM_LOANMNG03010_VIEW .fnSysRegNm').text(result.sysRegNm + ' (' + result.sysRegDttm + ')');
  586. $('#ITP_FORM_LOANMNG03010_VIEW .fnSttlReqAmt').text(itp_fn_number_comma(result.sttlReqAmt));
  587. $('#ITP_FORM_LOANMNG03010_VIEW .fnUseAmtTotal').text(itp_fn_number_comma(result.useAmtTotal));
  588. $('#ITP_FORM_LOANMNG03010_VIEW .fnAcctBal').text(itp_fn_number_comma(result.acctBal));
  589. $('#ITP_FORM_LOANMNG03010_VIEW .fnUnpaidAmt').text(itp_fn_number_comma(result.unpaidAmt));
  590. if(result.rcptYn == 'Y') { // 수납여부
  591. $('#ITP_BTN_LOANMNG03010_PAYMENT').hide();
  592. $('#ITP_BTN_LOANMNG03010_DEPOSIT').hide();
  593. } else {
  594. // 카드결제가능여부에 따라 처리
  595. if( result.mallId == null || result.mallId == '' ) {
  596. $('#ITP_BTN_LOANMNG03010_PAYMENT').hide();
  597. } else {
  598. $('#ITP_BTN_LOANMNG03010_PAYMENT').show();
  599. }
  600. }
  601. // 리스트 조회
  602. viewObj.grid.init();
  603. },
  604. grid: {
  605. init: function() {
  606. itp_fn_jqgrid_resize(LOANMNG03010_VIEW_GRID_ID, LOANMNG03010_VIEW_GRID_LIST, 'lg');
  607. this.unload();
  608. this.load();
  609. },
  610. load : function() {
  611. let param = $('#ITP_FORM_LOANMNG03010_VIEW').serializeObject();
  612. param.gridSize = $.jgrid.defaults.rowNum;
  613. param.pagingYn = false; // 페이징안함
  614. var option = {
  615. gridId: LOANMNG03010_VIEW_GRID_ID,
  616. colModel: gridColModel.view,
  617. param: param,
  618. url: DOMAIN + UNPAID_MNG_STL_GRID_LIST,
  619. pager: LOANMNG03010_VIEW_GRID_PAGER,
  620. loadComplete: function(data) {
  621. itp_fn_grid_load_complete(data, LOANMNG03010_VIEW_GRID_ID, true, undefined, 'LOANMNG03010_VIEW');
  622. },
  623. onPaging: function(action) {
  624. var pagingFn = {
  625. callBack: function(args) {
  626. $(args).trigger('reloadGrid');
  627. }
  628. };
  629. if (itp_fn_check_grid_is_writing(LOANMNG03010_VIEW_GRID_ID)) {
  630. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, LOANMNG03010_VIEW_GRID_ID);
  631. return 'stop';
  632. } else {
  633. itp_fn_grid_paging(LOANMNG03010_VIEW_GRID_ID, action, param);
  634. }
  635. },
  636. onSortCol: function(index, columnIndex, sortOrder) {
  637. var sortingFn = {
  638. callBack: function(args) {
  639. $(args).trigger('reloadGrid');
  640. }
  641. };
  642. if (itp_fn_check_grid_is_writing(LOANMNG03010_VIEW_GRID_ID)) {
  643. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, LOANMNG03010_VIEW_GRID_ID);
  644. return 'stop';
  645. } else {
  646. itp_fn_grid_sorting(LOANMNG03010_VIEW_GRID_ID, index, sortOrder);
  647. }
  648. }
  649. };
  650. itp_fn_grid_make_remote(option);
  651. },
  652. clearData : function() {
  653. $(LOANMNG03010_VIEW_GRID_ID).jqGrid('clearGridData', true);
  654. $(LOANMNG03010_VIEW_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  655. $(LOANMNG03010_VIEW_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  656. $(LOANMNG03010_VIEW_GRID_EMPTY).show();
  657. },
  658. unload : function() {
  659. $.jgrid.gridUnload(LOANMNG03010_VIEW_GRID_ID);
  660. }
  661. }
  662. };