ITP_SETTMNG02010.js 21 KB

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