ITP_SETTMNG03010.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /********************************************************
  2. --------------------------------------------------------
  3. - Object 목록 -
  4. --------------------------------------------------------
  5. * const gridColModel = {} : 화면 Grid Object *
  6. * let pageObj = {} : 화면공통 Object *
  7. * let listObj = {} : 목록화면 Object *
  8. * let modifyObj = {} : 상세화면 Object *
  9. *******************************************************/
  10. /*화면 변수*/
  11. const SETTMNG03010_GRID_ID = '#ITP_SETTMNG03010_jqGrid';
  12. const SETTMNG03010_GRID_LIST = '#ITP_SETTMNG03010_jqGrid_list';
  13. const SETTMNG03010_GRID_PAGER = '#ITP_SETTMNG03010_jqGridPager';
  14. const SETTMNG03010_GRID_EMPTY = '#ITP_SETTMNG03010_jqGridEmpty';
  15. const SETTMNG03010_DETAIL_GRID_ID = '#ITP_SETTMNG03010_DETAIL_jqGrid';
  16. const SETTMNG03010_DETAIL_GRID_LIST = '#ITP_SETTMNG03010_DETAIL_jqGrid_list';
  17. const SETTMNG03010_DETAIL_GRID_PAGER = '#ITP_SETTMNG03010_DETAIL_jqGridPager';
  18. const SETTMNG03010_DETAIL_GRID_EMPTY = '#ITP_SETTMNG03010_DETAIL_jqGridEmpty';
  19. let ITP_FORM_SETTMNG03010_DETAIL_IS_DUPLICATE = false;
  20. let ITP_FORM_SETTMNG03010_DETAIL_IS_WRITING = false;
  21. let SETTMNG03010_DETAIL_GRID_LAST_ROW_ID;
  22. /*API URL*/
  23. let STTL_STATE_DETAIL_GRID_LIST = '/api/sttl/state/detail-grid-list';
  24. let STTL_STATE_STTL_END = '/api/sttl/state/sttl-end';
  25. let STTL_REQ_INFO_STTL = '/api/sttl/req/info-sttl';
  26. let STTL_REQ_STL_GRID_LIST = '/api/sttl/req/stl-grid-list';
  27. let LOGIN_AUTH_TYPE_CD;
  28. /*화면 Grid ColModel*/
  29. const gridColModel = {
  30. list: [
  31. {
  32. index: 'VIEW_CD', name: 'viewCd',
  33. label: ITP_MSG_LOCALE.label.viewCd,
  34. width: '10', fixed: false, align: 'center',
  35. sortable: false, hidden: true
  36. },
  37. {
  38. index: 'BRAND_NM', name: 'brandNm',
  39. label: "브랜드",
  40. width: '10', fixed: false, align: 'center',
  41. sortable: false, hidden: true
  42. },
  43. {
  44. index: 'STORE_NM', name: 'storeNm',
  45. label: "매장명",
  46. width: '10', fixed: false, align: 'center',
  47. sortable: false, hidden: false
  48. },
  49. {
  50. index: 'LOAN_DVSN_NM', name: 'loanDvsnNm',
  51. label: "정산타입",
  52. width: '8', fixed: false, align: 'center',
  53. sortable: false, hidden: false
  54. },
  55. {
  56. index: 'SPPLY_NM', name: 'spplyNm',
  57. label: "공급사명",
  58. width: '10', fixed: false, align: 'center',
  59. sortable: false, hidden: true
  60. },
  61. {
  62. index: 'STTL_MGNT_UNQ_NO', name: 'sttlMgntUnqNo',
  63. label: "정산번호",
  64. width: '10', fixed: false, align: 'center',
  65. sortable: false, hidden: false
  66. },
  67. {
  68. index: 'STTL_ST_CD', name: 'sttlStCd',
  69. label: "정산상태코드",
  70. width: '8', fixed: false, align: 'center',
  71. sortable: false, hidden: true
  72. },
  73. {
  74. index: 'STTL_ST_NM', name: 'sttlStNm',
  75. label: "정산상태",
  76. width: '10', fixed: false, align: 'center',
  77. sortable: false, hidden: false
  78. },
  79. {
  80. index: 'STTL_REQ_DT', name: 'sttlReqDt',
  81. label: "정산요청일",
  82. width: '10', fixed: false, align: 'center',
  83. sortable: false, editable: false, edittype: 'text'
  84. },
  85. {
  86. index: 'STTL_REQ_AMT', name: 'sttlReqAmt',
  87. label: "정산요청금액",
  88. width: '10', fixed: false, align: 'center',
  89. sortable: false, editable: false, edittype: 'text',
  90. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  91. },
  92. {
  93. index: 'STTL_DT', name: 'sttlDt',
  94. label: "정산확정일",
  95. width: '10', fixed: false, align: 'center',
  96. sortable: false, editable: false, edittype: 'text'
  97. },
  98. {
  99. index: 'STTL_REQ_AMT', name: 'sttlAmt',
  100. label: "정산확정금액",
  101. width: '10', fixed: false, align: 'center',
  102. sortable: false, editable: false, edittype: 'text',
  103. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  104. },
  105. {
  106. index: 'UNPAID_AMT', name: 'unpaidAmt',
  107. label: "미납금액",
  108. width: '10', fixed: false, align: 'center',
  109. sortable: false, editable: false, edittype: 'text',
  110. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  111. },
  112. {
  113. index: 'STTL_REG_MGR_NM', name: 'sttlRegMgrNm',
  114. label: "등록자",
  115. width: '10', fixed: false, align: 'center',
  116. sortable: false, editable: false, edittype: 'text'
  117. }
  118. ],
  119. view: [
  120. {
  121. index: 'VIEW_CD', name: 'viewCd',
  122. label: ITP_MSG_LOCALE.label.viewCd,
  123. width: '10', fixed: false, align: 'center',
  124. sortable: false, hidden: true
  125. },
  126. {
  127. index: 'STTL_MGNT_DTL_NO', name: 'sttlMgntDtlNo',
  128. label: '정산관리상세번호',
  129. width: '10', fixed: false, align: 'center',
  130. sortable: false, hidden: true
  131. },
  132. {
  133. index: 'BRAND_NM', name: 'brandNm',
  134. label: "브랜드",
  135. width: '10', fixed: false, align: 'center',
  136. sortable: false, hidden: true
  137. },
  138. {
  139. index: 'STORE_NM', name: 'storeNm',
  140. label: "매장명",
  141. width: '10', fixed: false, align: 'center',
  142. sortable: false, hidden: true
  143. },
  144. {
  145. index: 'ITEM_ID', name: 'itemId',
  146. label: "품목코드",
  147. width: '10', fixed: false, align: 'center',
  148. sortable: false, editable: false, edittype: 'text'
  149. },
  150. {
  151. index: 'ITEM_NM', name: 'itemNm',
  152. label: "품목명",
  153. width: '10', fixed: false, align: 'center',
  154. sortable: false, editable: false, edittype: 'text'
  155. },
  156. {
  157. index: 'UNIT', name: 'unit',
  158. label: "단위",
  159. width: '8', fixed: false, align: 'center',
  160. sortable: false, editable: false, edittype: 'text'
  161. },
  162. {
  163. index: 'UNIT_AMT', name: 'unitAmt',
  164. label: "단가",
  165. width: '8', fixed: false, align: 'center',
  166. sortable: false, editable: false, edittype: 'text',
  167. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  168. },
  169. {
  170. index: 'PODR_QTY', name: 'podrQty',
  171. label: "발주수량",
  172. width: '8', fixed: false, align: 'center',
  173. sortable: false, editable: false, edittype: 'text',
  174. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  175. },
  176. {
  177. index: 'DLV_QTY', name: 'dlvQty',
  178. label: "납품수량",
  179. width: '8', fixed: false, align: 'center',
  180. sortable: false, editable: false, edittype: 'text',
  181. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  182. },
  183. {
  184. index: 'WHS_COL_QTY', name: 'whsColQty',
  185. label: "입고/수거수량",
  186. width: '8', fixed: false, align: 'center',
  187. sortable: false, editable: false, edittype: 'text',
  188. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  189. },
  190. {
  191. index: 'WHS_COL_DT', name: 'whsColDt',
  192. label: "입고/수거일자",
  193. width: '8', fixed: false, align: 'center',
  194. sortable: false, editable: false, edittype: 'text'
  195. },
  196. {
  197. index: 'WHS_COL_AMT', name: 'whsColAmt',
  198. label: "입고/수거금액",
  199. width: '8', fixed: false, align: 'center',
  200. sortable: false, editable: false, edittype: 'text',
  201. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  202. },
  203. {
  204. index: 'STTL_DVSN_NM', name: 'sttlDvsnNm',
  205. label: "정산구분",
  206. width: '8', fixed: false, align: 'center',
  207. sortable: false, editable: false, edittype: 'text'
  208. },
  209. {
  210. index: 'PODR_UNQ_NO', name: 'podrUnqNo',
  211. label: "발주번호",
  212. width: '8', fixed: false, align: 'center',
  213. sortable: false, editable: false, edittype: 'text'
  214. },
  215. {
  216. index: 'PODR_DTL_NO', name: 'podrDtlNo',
  217. label: "발주항번",
  218. width: '8', fixed: false, align: 'center',
  219. sortable: false, editable: false, edittype: 'text'
  220. }
  221. ]
  222. };
  223. require(['config'], function() {
  224. require([
  225. 'kakao.map.util'
  226. ], function($) {
  227. pageObj.init();
  228. });
  229. });
  230. /*화면공통 Object*/
  231. let pageObj = {
  232. init: function () {
  233. this.ui.init();
  234. this.event.init();
  235. },
  236. ui: {
  237. init: function () {
  238. this.view();
  239. this.grid();
  240. this.ready();
  241. },
  242. view: function() {
  243. // 버튼 권한설정
  244. fn_proc_btn_auth('SETTMNG03010');
  245. // 공통코드 표시
  246. $('select').each(function() {
  247. if($(this).data('select-code')) {
  248. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  249. }
  250. });
  251. // 조회일자 지정
  252. var now = new Date();
  253. $('#ITP_TAB_SETTMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  254. $('#ITP_FORM_SETTMNG03010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  255. $('#ITP_FORM_SETTMNG03010_SEARCH_TO_DT').datepicker('setDate', new Date());
  256. // 권한에 따라 매장값 설정
  257. $('#ITP_FORM_SETTMNG03010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  258. LOGIN_AUTH_TYPE_CD = fn_make_user_info.get('authTpCd'); // 권한타입
  259. if(LOGIN_AUTH_TYPE_CD == '50') {
  260. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
  261. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_NM').val(fn_make_user_info.get('storeNm'));
  262. }
  263. },
  264. grid: function() {
  265. itp_fn_jqgrid_resize(SETTMNG03010_GRID_ID, SETTMNG03010_GRID_LIST, 'lg');
  266. listObj.empty.init();
  267. itp_fn_fire_window_resize();
  268. },
  269. ready: function() {
  270. listObj.init();
  271. }
  272. },
  273. event: {
  274. init: function () {
  275. this.button();
  276. this.change();
  277. },
  278. button: function () {
  279. // 버튼 클릭 이벤트
  280. $('button').each(function() {
  281. var id = $(this).attr('id');
  282. $(this).on('click', function() {
  283. switch (id) {
  284. case 'ITP_BTN_SETTMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  285. case 'ITP_BTN_SETTMNG03010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  286. case 'ITP_BTN_SETTMNG03010_STTL_END' : modifyObj.button.endSttl(); break; // 정산확정 버튼
  287. case 'ITP_BTN_SETTMNG03010_SEARCH_STORE_POP' : listObj.button.storePop(); break; // 매장검색 팝업
  288. case 'ITP_BTN_SETTMNG03010_SEARCH_ERASE' : listObj.button.storeErase(); break; // 매장 지움
  289. }
  290. });
  291. });
  292. $('body').on('click', function(e) {
  293. var gridId = SETTMNG03010_DETAIL_GRID_ID.replace('#', '');
  294. var rids = $(SETTMNG03010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  295. var last_row_id = rids[rids.length - 1];
  296. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'SETTMNG03010_DETAIL');
  297. });
  298. },
  299. change: function() {
  300. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_GUBUN').on('change', function() {
  301. var gubunVal = $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_GUBUN').val();
  302. if(gubunVal == '1') { // 매장
  303. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '매장명');
  304. $(SETTMNG03010_GRID_ID).jqGrid('hideCol', ["spplyNm"]);
  305. $(SETTMNG03010_GRID_ID).jqGrid('showCol', ["storeNm"]);
  306. // $(SETTMNG03010_GRID_ID).setColProp('spplyNm', {hidden: true});
  307. // $(SETTMNG03010_GRID_ID).setColProp('storeNm', {hidden: false});
  308. } else if(gubunVal == '2') { // 공급업체
  309. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '공급사명');
  310. $(SETTMNG03010_GRID_ID).jqGrid('hideCol', ["storeNm"]);
  311. $(SETTMNG03010_GRID_ID).jqGrid('showCol', ["spplyNm"]);
  312. // $(SETTMNG03010_GRID_ID).setColProp('storeNm', {hidden: true});
  313. // $(SETTMNG03010_GRID_ID).setColProp('spplyNm', {hidden: false});
  314. }
  315. listObj.button.search();
  316. // itp_fn_jqgrid_resize(SETTMNG03010_GRID_ID, SETTMNG03010_GRID_LIST, 'lg');
  317. });
  318. }
  319. },
  320. switchScreen: function(mode) {
  321. if(mode == 'LIST') { // 목록
  322. $('#ITP_BTN_SETTMNG03010_MODIFY').hide();
  323. $('#ITP_BTN_SETTMNG03010_CANCELLIST').hide();
  324. $('#ITP_BTN_SETTMNG03010_DELETE').hide();
  325. $('#ITP_BTN_SETTMNG03010_STTL_END').hide();
  326. if(LOGIN_AUTH_TYPE_CD == '50') { // 매장관리자
  327. $('#ITP_BTN_SETTMNG03010_SEARCH_STORE_POP').hide();
  328. $('#ITP_BTN_SETTMNG03010_SEARCH_ERASE').hide();
  329. } else {
  330. $('#ITP_BTN_SETTMNG03010_SEARCH_STORE_POP').show();
  331. $('#ITP_BTN_SETTMNG03010_SEARCH_ERASE').show();
  332. }
  333. fn_show_btn_auth('#ITP_BTN_SETTMNG03010_SRH');
  334. fn_show_btn_auth('#ITP_BTN_SETTMNG03010_NEWREG');
  335. $('#ITP_AJAX_SETTMNG03010_LIST_CONTAINER').show();
  336. $('#ITP_AJAX_SETTMNG03010_DETAIL_CONTAINER').hide();
  337. } else if(mode == 'DETAIL') { // 보기
  338. $('#ITP_BTN_SETTMNG03010_SRH').hide();
  339. $('#ITP_BTN_SETTMNG03010_NEWREG').hide();
  340. $('#ITP_BTN_SETTMNG03010_DELETE').hide();
  341. fn_show_btn_auth('#ITP_BTN_SETTMNG03010_STTL_END');
  342. fn_show_btn_auth('#ITP_BTN_SETTMNG03010_CANCELLIST');
  343. $('#ITP_AJAX_SETTMNG03010_LIST_CONTAINER').hide();
  344. $('#ITP_AJAX_SETTMNG03010_DETAIL_CONTAINER').show();
  345. }
  346. }
  347. };
  348. /*목록화면 Object*/
  349. let listObj = {
  350. init: function () {
  351. this.grid.init();
  352. },
  353. itp_SETTMNG03010_search: false,
  354. button: {
  355. search: function() {
  356. listObj.itp_SETTMNG03010_search = true;
  357. let param = $('#ITP_FORM_SETTMNG03010_SEARCH').serializeObject();
  358. param.gridSize = $.jgrid.defaults.rowNum;
  359. param.gridPage = $.jgrid.defaults.page;
  360. $(SETTMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  361. },
  362. storePop: function() {
  363. fn_call_popup('biz', 'BIZPOP_BRAND_STORE', '#ITP_ASIDE', function(result) {
  364. // alert(JSON.stringify(result));
  365. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_ID').val(result[0].storeId);
  366. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_NM').val(result[0].storeNm);
  367. listObj.button.search();
  368. }, null, 'S');
  369. },
  370. storeErase: function() {
  371. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_ID').val('');
  372. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_SPPLY_NM').val('');
  373. listObj.button.search();
  374. }
  375. },
  376. empty: {
  377. init: function() {
  378. var _this = this;
  379. this.push();
  380. $(SETTMNG03010_GRID_EMPTY).on('click', function() {
  381. _this.back();
  382. _this.itp_SETTMNG03010_param.gridSize = $.jgrid.defaults.rowNum;
  383. $(SETTMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_SETTMNG03010_param)}).trigger('reloadGrid');
  384. });
  385. },
  386. itp_SETTMNG03010_param: {},
  387. push: function() {
  388. let param = $('#ITP_FORM_SETTMNG03010_SEARCH').serializeObject();
  389. listObj.itp_SETTMNG03010_param = param;
  390. },
  391. back: function() {
  392. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_ID').val(listObj.itp_SETTMNG03010_param.sstoreId);
  393. $('#ITP_FORM_SETTMNG03010_SEARCH_STORE_NM').val(listObj.itp_SETTMNG03010_param.sstoreNm);
  394. $('#ITP_FORM_SETTMNG03010_SEARCH_FROM_DT').val(listObj.itp_SETTMNG03010_param.fromDt);
  395. $('#ITP_FORM_SETTMNG03010_SEARCH_TO_DT').val(listObj.itp_SETTMNG03010_param.toDt);
  396. $('#ITP_FORM_SETTMNG03010_SEARCH_ITEM_NM').val(listObj.itp_SETTMNG03010_param.sitemNm);
  397. }
  398. },
  399. grid: {
  400. init: function () {
  401. // 데이터 없을때
  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_SETTMNG03010_SEARCH').serializeObject();
  413. param.gridSize = $.jgrid.defaults.rowNum;
  414. var option = {
  415. gridId: SETTMNG03010_GRID_ID,
  416. colModel: gridColModel.list,
  417. param: param,
  418. url: DOMAIN + STTL_STATE_DETAIL_GRID_LIST,
  419. pager: SETTMNG03010_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. modifyObj.init(param);
  428. }
  429. },
  430. loadComplete: function(data) {
  431. console.log(data);
  432. itp_fn_grid_load_complete(data, SETTMNG03010_GRID_ID, true, 'number', 'SETTMNG03010', listObj.itp_SETTMNG03010_search, listObj.empty, true, data.gridRecords, true);
  433. var ids = $(SETTMNG03010_GRID_ID).getDataIDs();
  434. $.each(ids, function(idx, rowId) {
  435. $(SETTMNG03010_GRID_ID).jqGrid('setCell', rowId, 'sttlMgntUnqNo', '', ITP_GRID_COL_STYLE.link);
  436. });
  437. },
  438. onPaging: function(action) {
  439. itp_fn_grid_paging(SETTMNG03010_GRID_ID, action, param);
  440. }
  441. };
  442. itp_fn_grid_make_remote(option);
  443. },
  444. clearData : function() {
  445. $(SETTMNG03010_GRID_ID).jqGrid('clearGridData', true);
  446. $(SETTMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  447. $(SETTMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  448. $(SETTMNG03010_GRID_EMPTY).show();
  449. },
  450. unload : function() {
  451. $.jgrid.gridUnload(SETTMNG03010_GRID_ID);
  452. }
  453. }
  454. };
  455. /*상세화면 Object*/
  456. let modifyObj = {
  457. init: function (param) {
  458. this.load(param);
  459. },
  460. button: {
  461. cancel: function() {
  462. listObj.grid.search();
  463. },
  464. endSttl: function() {
  465. // 정산확정
  466. const formId = '#ITP_FORM_SETTMNG03010_DETAIL';
  467. let param = $(formId).serializeObject();
  468. var confirmFn= {
  469. callBack: function() {
  470. var searhFn = function() {
  471. listObj.grid.search();
  472. };
  473. fn_ajax_call(STTL_STATE_STTL_END, JSON.stringify(param), searhFn, 'POST');
  474. }
  475. };
  476. var sttlReqAmt = parseInt($('#ITP_FORM_SETTMNG03010_DETAIL_STTL_REQ_AMT').val());
  477. var acctBal = parseInt($('#ITP_FORM_SETTMNG03010_DETAIL_ACCT_BAL').val());
  478. if(acctBal > 0) {
  479. if(acctBal >= sttlReqAmt) {
  480. itp_fn_modal_confirm('계좌잔액에서 지급처리가 진행됩니다.\n정산 확정하시겠습니까?', confirmFn, null);
  481. } else {
  482. itp_fn_modal_confirm('일부금액이 계좌잔액에서 지급처리가 진행됩니다.\n정산 확정하시겠습니까?', confirmFn, null);
  483. }
  484. } else {
  485. itp_fn_modal_confirm('정산 확정하시겠습니까?', confirmFn, null);
  486. }
  487. }
  488. },
  489. load: function(param) {
  490. fn_ajax_call(STTL_REQ_INFO_STTL, param, this.callback, 'GET');
  491. },
  492. callback: function (result) {
  493. // console.log(result);
  494. pageObj.switchScreen('DETAIL');
  495. $('#ITP_FORM_SETTMNG03010_DETAIL_BRAND_ID').val(result.brandId);
  496. $('#ITP_FORM_SETTMNG03010_DETAIL_STORE_ID').val(result.storeId);
  497. $('#ITP_FORM_SETTMNG03010_DETAIL_STTL_MGNT_UNQ_NO').val(result.sttlMgntUnqNo);
  498. $('#ITP_FORM_SETTMNG03010_DETAIL_ACCT_BAL').val(result.acctBal); // 계좌잔액
  499. $('#ITP_FORM_SETTMNG03010_DETAIL_STTL_REQ_AMT').val(result.sttlReqAmt); // 정산요청금액
  500. $('#ITP_FORM_SETTMNG03010_DETAIL .fnBrandNm').text(result.brandNm);
  501. $('#ITP_FORM_SETTMNG03010_DETAIL .fnStoreNm').text(result.storeNm);
  502. $('#ITP_FORM_SETTMNG03010_DETAIL .fnLoanDvsnNm').text(result.loanDvsnNm);
  503. $('#ITP_FORM_SETTMNG03010_DETAIL .fnAcctBal').text(itp_fn_number_comma(result.acctBal));
  504. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlRjctRsn').text(result.sttlRjctRsn == null ? '' : result.sttlRjctRsn);
  505. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlStNm').text(result.sttlStNm);
  506. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlReqDt').text(result.sttlReqDt); // 정산요청일자
  507. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlReqAmt').text(itp_fn_number_comma(result.sttlReqAmt));
  508. // $('#ITP_FORM_SETTMNG03010_DETAIL_STTL_DT').val(result.sttlDt); // 정산일자
  509. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlDt').text(result.sttlDt == null ? '' : result.sttlDt); // 정산요청일자
  510. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSttlAmt').text(itp_fn_number_comma(result.sttlAmt));
  511. // $('#ITP_FORM_SETTMNG03010_DETAIL .fnRcptYn').text(result.rcptYn == null ? '' : result.rcptYn);
  512. // $('#ITP_FORM_SETTMNG03010_DETAIL .fnRcptDt').text(result.rcptDt == null ? '' : result.rcptDt);
  513. if(result.rcptYn == null) {
  514. $('#ITP_FORM_SETTMNG03010_DETAIL .fnRcptYnDate').text('');
  515. } else if(result.rcptYn == 'N') {
  516. $('#ITP_FORM_SETTMNG03010_DETAIL .fnRcptYnDate').text('N');
  517. } else if(result.rcptYn == 'Y') {
  518. $('#ITP_FORM_SETTMNG03010_DETAIL .fnRcptYnDate').text('Y (' + result.rcptDt + ')');
  519. }
  520. $('#ITP_FORM_SETTMNG03010_DETAIL .fnUnpaidAmt').text(itp_fn_number_comma(result.unpaidAmt));
  521. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSysRegDttm').text(result.sysRegDttm);
  522. $('#ITP_FORM_SETTMNG03010_DETAIL .fnSysRegNm').text(result.sysRegNm);
  523. if(result.sttlStCd == 'ST10') { // 정산요청
  524. $('#ITP_BTN_SETTMNG03010_STTL_END').show();
  525. } else {
  526. $('#ITP_BTN_SETTMNG03010_STTL_END').hide();
  527. }
  528. // 리스트 조회
  529. modifyObj.grid.init();
  530. },
  531. grid: {
  532. init: function() {
  533. this.unload();
  534. this.load();
  535. },
  536. load : function() {
  537. let param = $('#ITP_FORM_SETTMNG03010_DETAIL').serializeObject();
  538. param.gridSize = $.jgrid.defaults.rowNum;
  539. param.pagingYn = false; // 페이징안함
  540. var option = {
  541. gridId: SETTMNG03010_DETAIL_GRID_ID,
  542. colModel: gridColModel.view,
  543. param: param,
  544. url: DOMAIN + STTL_REQ_STL_GRID_LIST,
  545. pager: SETTMNG03010_DETAIL_GRID_PAGER,
  546. loadComplete: function(data) {
  547. itp_fn_grid_load_complete(data, SETTMNG03010_DETAIL_GRID_ID, true, undefined, 'SETTMNG03010_DETAIL');
  548. },
  549. onPaging: function(action) {
  550. var pagingFn = {
  551. callBack: function(args) {
  552. $(args).trigger('reloadGrid');
  553. }
  554. };
  555. if (itp_fn_check_grid_is_writing(SETTMNG03010_DETAIL_GRID_ID)) {
  556. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, SETTMNG03010_DETAIL_GRID_ID);
  557. return 'stop';
  558. } else {
  559. itp_fn_grid_paging(SETTMNG03010_DETAIL_GRID_ID, action, param);
  560. }
  561. },
  562. onSortCol: function(index, columnIndex, sortOrder) {
  563. var sortingFn = {
  564. callBack: function(args) {
  565. $(args).trigger('reloadGrid');
  566. }
  567. };
  568. if (itp_fn_check_grid_is_writing(SETTMNG03010_DETAIL_GRID_ID)) {
  569. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, SETTMNG03010_DETAIL_GRID_ID);
  570. return 'stop';
  571. } else {
  572. itp_fn_grid_sorting(SETTMNG03010_DETAIL_GRID_ID, index, sortOrder);
  573. }
  574. }
  575. };
  576. itp_fn_grid_make_remote(option);
  577. },
  578. clearData : function() {
  579. $(SETTMNG03010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  580. $(SETTMNG03010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  581. $(SETTMNG03010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  582. $(SETTMNG03010_DETAIL_GRID_EMPTY).show();
  583. },
  584. unload : function() {
  585. $.jgrid.gridUnload(SETTMNG03010_DETAIL_GRID_ID);
  586. }
  587. }
  588. };