ITP_SETTMNG02010.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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, classes: 'ui-ellipsis'
  55. },
  56. {
  57. index: 'STTL_MGNT_UNQ_NO', name: 'sttlMgntUnqNo',
  58. label: "정산번호",
  59. minwidth: 180,
  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', classes: 'ui-ellipsis'
  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. minwidth: 300,
  144. width: '10', fixed: false, align: 'center',
  145. sortable: false, editable: false, edittype: 'text'
  146. },
  147. {
  148. index: 'ITEM_NM', name: 'itemNm',
  149. label: "품목명",
  150. width: '10', fixed: false, align: 'left',
  151. sortable: false, editable: false, edittype: 'text', classes: 'ui-ellipsis'
  152. },
  153. {
  154. index: 'UNIT', name: 'unit',
  155. label: "단위",
  156. width: '8', fixed: false, align: 'center',
  157. sortable: false, editable: false, edittype: 'text'
  158. },
  159. {
  160. index: 'UNIT_AMT', name: 'unitAmt',
  161. label: "단가",
  162. width: '8', fixed: false, align: 'right',
  163. sortable: false, editable: false, edittype: 'text',
  164. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  165. },
  166. {
  167. index: 'PODR_QTY', name: 'podrQty',
  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: 'DLV_QTY', name: 'dlvQty',
  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: 'WHS_COL_QTY', name: 'whsColQty',
  182. label: "입고/수거수량",
  183. minwidth: 100,
  184. width: '8', fixed: false, align: 'right',
  185. sortable: false, editable: false, edittype: 'text',
  186. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  187. },
  188. {
  189. index: 'WHS_COL_DT', name: 'whsColDt',
  190. label: "입고/수거일자",
  191. minwidth: 100,
  192. width: '8', fixed: false, align: 'center',
  193. sortable: false, editable: false, edittype: 'text'
  194. },
  195. {
  196. index: 'WHS_COL_AMT', name: 'whsColAmt',
  197. label: "입고/수거금액",
  198. minwidth: 100,
  199. width: '8', fixed: false, align: 'right',
  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('SETTMNG02010');
  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. var fromDate = new Date(now);
  254. fromDate.setDate(now.getDate() - 30);
  255. var toDate = new Date(now);
  256. $('#ITP_TAB_SETTMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  257. $('#ITP_FORM_SETTMNG02010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  258. $('#ITP_FORM_SETTMNG02010_SEARCH_TO_DT').datepicker('setDate', toDate);
  259. // 권한에 따라 매장값 설정
  260. $('#ITP_FORM_SETTMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  261. LOGIN_AUTH_TYPE_CD = fn_make_user_info.get('authTpCd'); // 권한타입
  262. if(LOGIN_AUTH_TYPE_CD == '60') {
  263. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
  264. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_NM').val(fn_make_user_info.get('storeNm'));
  265. }
  266. },
  267. grid: function() {
  268. itp_fn_jqgrid_resize(SETTMNG02010_GRID_ID, SETTMNG02010_GRID_LIST, 'lg');
  269. listObj.empty.init();
  270. itp_fn_fire_window_resize();
  271. },
  272. ready: function() {
  273. listObj.init();
  274. }
  275. },
  276. event: {
  277. init: function () {
  278. this.button();
  279. this.change();
  280. },
  281. button: function () {
  282. // 버튼 클릭 이벤트
  283. $('button').each(function() {
  284. var id = $(this).attr('id');
  285. $(this).on('click', function() {
  286. switch (id) {
  287. case 'ITP_BTN_SETTMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  288. case 'ITP_BTN_SETTMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  289. case 'ITP_BTN_SETTMNG02010_CONFIRM' : modifyObj.button.confirmSttl(); break; // 정산확정 버튼
  290. case 'ITP_BTN_SETTMNG02010_REJECT' : modifyObj.button.rejectSttl(); break; // 정산반려 버튼
  291. case 'ITP_BTN_SETTMNG02010_SEARCH_SPPLY_POP' : listObj.button.spplyPop(); break; //
  292. case 'ITP_BTN_SETTMNG02010_SEARCH_ERASE' : listObj.button.spplyErase(); break; //
  293. case 'ITP_BTN_SETTMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  294. }
  295. });
  296. });
  297. $('body').on('click', function(e) {
  298. var gridId = SETTMNG02010_DETAIL_GRID_ID.replace('#', '');
  299. var rids = $(SETTMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  300. var last_row_id = rids[rids.length - 1];
  301. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'SETTMNG02010_DETAIL');
  302. });
  303. },
  304. change: function() {
  305. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_GUBUN').on('change', function() {
  306. var gubunVal = $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_GUBUN').val();
  307. if(gubunVal == '1') { // 매장
  308. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '매장명');
  309. $(SETTMNG02010_GRID_ID).jqGrid('hideCol', ["spplyNm"]);
  310. $(SETTMNG02010_GRID_ID).jqGrid('showCol', ["storeNm"]);
  311. // $(SETTMNG02010_GRID_ID).setColProp('spplyNm', {hidden: true});
  312. // $(SETTMNG02010_GRID_ID).setColProp('storeNm', {hidden: false});
  313. } else if(gubunVal == '2') { // 공급업체
  314. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '공급사명');
  315. $(SETTMNG02010_GRID_ID).jqGrid('hideCol', ["storeNm"]);
  316. $(SETTMNG02010_GRID_ID).jqGrid('showCol', ["spplyNm"]);
  317. // $(SETTMNG02010_GRID_ID).setColProp('storeNm', {hidden: true});
  318. // $(SETTMNG02010_GRID_ID).setColProp('spplyNm', {hidden: false});
  319. }
  320. listObj.button.search();
  321. // itp_fn_jqgrid_resize(SETTMNG02010_GRID_ID, SETTMNG02010_GRID_LIST, 'lg');
  322. });
  323. }
  324. },
  325. switchScreen: function(mode) {
  326. if(mode == 'LIST') { // 목록
  327. $('#ITP_BTN_SETTMNG02010_MODIFY').hide();
  328. $('#ITP_BTN_SETTMNG02010_CANCELLIST').hide();
  329. $('#ITP_BTN_SETTMNG02010_DELETE').hide();
  330. $('#ITP_BTN_SETTMNG02010_REQUEST').hide();
  331. $('#ITP_BTN_SETTMNG02010_CONFIRM').hide();
  332. $('#ITP_BTN_SETTMNG02010_REJECT').hide();
  333. if(LOGIN_AUTH_TYPE_CD == '60') { // 공급사
  334. $('#ITP_BTN_SETTMNG02010_SEARCH_SPPLY_POP').hide();
  335. $('#ITP_BTN_SETTMNG02010_SEARCH_ERASE').hide();
  336. } else {
  337. $('#ITP_BTN_SETTMNG02010_SEARCH_SPPLY_POP').show();
  338. $('#ITP_BTN_SETTMNG02010_SEARCH_ERASE').show();
  339. }
  340. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_SRH');
  341. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_NEWREG');
  342. $('#ITP_AJAX_SETTMNG02010_LIST_CONTAINER').show();
  343. $('#ITP_AJAX_SETTMNG02010_DETAIL_CONTAINER').hide();
  344. $('#ITP_BTN_SETTMNG02010_EXCEL').show();
  345. } else if(mode == 'DETAIL') { // 보기
  346. $('#ITP_BTN_SETTMNG02010_SRH').hide();
  347. $('#ITP_BTN_SETTMNG02010_NEWREG').hide();
  348. $('#ITP_BTN_SETTMNG02010_DELETE').hide();
  349. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_REQUEST');
  350. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_CANCELLIST');
  351. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_CONFIRM');
  352. fn_show_btn_auth('#ITP_BTN_SETTMNG02010_REJECT');
  353. $('#ITP_AJAX_SETTMNG02010_LIST_CONTAINER').hide();
  354. $('#ITP_AJAX_SETTMNG02010_DETAIL_CONTAINER').show();
  355. }
  356. }
  357. };
  358. /*목록화면 Object*/
  359. let listObj = {
  360. init: function () {
  361. this.grid.init();
  362. },
  363. itp_SETTMNG02010_search: false,
  364. button: {
  365. search: function() {
  366. listObj.itp_SETTMNG02010_search = true;
  367. let param = $('#ITP_FORM_SETTMNG02010_SEARCH').serializeObject();
  368. param.gridSize = $.jgrid.defaults.rowNum;
  369. param.gridPage = $.jgrid.defaults.page;
  370. $(SETTMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  371. },
  372. spplyPop: function() {
  373. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', function(result) {
  374. // alert(JSON.stringify(result));
  375. $('#ITP_FORM_SETTMNG02010_SEARCH_SPPLY_ID').val(result.spplyId);
  376. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_NM').val(result.spplyNm);
  377. listObj.button.search();
  378. }, null, 'S');
  379. },
  380. spplyErase: function() {
  381. $('#ITP_FORM_SETTMNG02010_SEARCH_SPPLY_ID').val('');
  382. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_SPPLY_NM').val('');
  383. listObj.button.search();
  384. }
  385. },
  386. empty: {
  387. init: function() {
  388. var _this = this;
  389. this.push();
  390. $(SETTMNG02010_GRID_EMPTY).on('click', function() {
  391. _this.back();
  392. _this.itp_SETTMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
  393. $(SETTMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_SETTMNG02010_param)}).trigger('reloadGrid');
  394. });
  395. },
  396. itp_SETTMNG02010_param: {},
  397. push: function() {
  398. let param = $('#ITP_FORM_SETTMNG02010_SEARCH').serializeObject();
  399. listObj.itp_SETTMNG02010_param = param;
  400. },
  401. back: function() {
  402. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_ID').val(listObj.itp_SETTMNG02010_param.sstoreId);
  403. $('#ITP_FORM_SETTMNG02010_SEARCH_STORE_NM').val(listObj.itp_SETTMNG02010_param.sstoreNm);
  404. $('#ITP_FORM_SETTMNG02010_SEARCH_FROM_DT').val(listObj.itp_SETTMNG02010_param.fromDt);
  405. $('#ITP_FORM_SETTMNG02010_SEARCH_TO_DT').val(listObj.itp_SETTMNG02010_param.toDt);
  406. $('#ITP_FORM_SETTMNG02010_SEARCH_ITEM_NM').val(listObj.itp_SETTMNG02010_param.sitemNm);
  407. }
  408. },
  409. grid: {
  410. init: function () {
  411. // 데이터 없을때
  412. listObj.empty.push();
  413. this.search();
  414. },
  415. colModel: gridColModel.list,
  416. search: function() {
  417. pageObj.switchScreen('LIST');
  418. this.unload();
  419. this.load();
  420. },
  421. load: function() {
  422. let param = $('#ITP_FORM_SETTMNG02010_SEARCH').serializeObject();
  423. param.gridSize = $.jgrid.defaults.rowNum;
  424. var option = {
  425. gridId: SETTMNG02010_GRID_ID,
  426. colModel: gridColModel.list,
  427. param: param,
  428. url: DOMAIN + STTL_STATE_DETAIL_GRID_LIST,
  429. pager: SETTMNG02010_GRID_PAGER,
  430. onCellSelect: function(rowId, cellIdx, cellValue) {
  431. var cm = $(this).jqGrid('getGridParam', 'colModel');
  432. var colNm = cm[cellIdx].name;
  433. if (colNm == 'sttlMgntUnqNo') {
  434. const sttlMgntUnqNoVal = $(this).jqGrid('getCell', rowId, 'sttlMgntUnqNo');
  435. const key = {sttlMgntUnqNo: sttlMgntUnqNoVal, viewCd: 'R'};
  436. var param = $.param(key);
  437. modifyObj.init(param);
  438. }
  439. },
  440. loadComplete: function(data) {
  441. console.log(data);
  442. itp_fn_grid_load_complete(data, SETTMNG02010_GRID_ID, true, 'number', 'SETTMNG02010', listObj.itp_SETTMNG02010_search, listObj.empty, true, data.gridRecords, true);
  443. var ids = $(SETTMNG02010_GRID_ID).getDataIDs();
  444. $.each(ids, function(idx, rowId) {
  445. $(SETTMNG02010_GRID_ID).jqGrid('setCell', rowId, 'sttlMgntUnqNo', '', ITP_GRID_COL_STYLE.link);
  446. });
  447. },
  448. onPaging: function(action) {
  449. itp_fn_grid_paging(SETTMNG02010_GRID_ID, action, param);
  450. }
  451. };
  452. itp_fn_grid_make_remote(option);
  453. },
  454. clearData : function() {
  455. $(SETTMNG02010_GRID_ID).jqGrid('clearGridData', true);
  456. $(SETTMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  457. $(SETTMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  458. $(SETTMNG02010_GRID_EMPTY).show();
  459. },
  460. unload : function() {
  461. $.jgrid.gridUnload(SETTMNG02010_GRID_ID);
  462. }
  463. },
  464. excelDown: function() {
  465. var param = {
  466. 'url': STTL_STATE_DETAIL_GRID_LIST,
  467. 'param': $('#ITP_FORM_SETTMNG02010_SEARCH').serializeObject(),
  468. 'gridColumns': $(SETTMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  469. 'fileName': '정산검수현황.xlsx',
  470. 'sheetName': '정산검수리스트'
  471. };
  472. itp_fn_remote_to_excel(param);
  473. }
  474. };
  475. /*상세화면 Object*/
  476. let modifyObj = {
  477. init: function (param) {
  478. this.load(param);
  479. this.grid.init();
  480. },
  481. button: {
  482. cancel: function() {
  483. listObj.grid.search();
  484. },
  485. confirmSttl: function() {
  486. // 정산확정
  487. const formId = '#ITP_FORM_SETTMNG02010_DETAIL';
  488. let param = $(formId).serializeObject();
  489. // console.log(JSON.stringify(param));
  490. var confirmFn= {
  491. callBack: function() {
  492. //
  493. var searhFn = function() {
  494. listObj.grid.search();
  495. };
  496. fn_ajax_call(STTL_INSPECT_STATE_STTL_CONFIRM, JSON.stringify(param), searhFn, 'POST');
  497. }
  498. };
  499. itp_fn_modal_confirm('정산 확정하시겠습니까?', confirmFn, null);
  500. },
  501. rejectSttl: function() {
  502. // 정산반려
  503. fn_call_popup('biz', 'BIZPOP_STTL_REJECT_REASON', '#ITP_ASIDE', function(result) {
  504. // API 호출
  505. let param = {};
  506. param.sttlMgntUnqNo = $('#ITP_FORM_SETTMNG02010_DETAIL_STTL_MGNT_UNQ_NO').val();
  507. param.sttlRjctRsn = result;
  508. fn_ajax_call(STTL_INSPECT_STATE_STTL_REJECT, JSON.stringify(param), function() {
  509. listObj.grid.search();
  510. }, 'POST');
  511. }, null, 'S');
  512. }
  513. },
  514. load: function(param) {
  515. fn_ajax_call(STTL_REQ_INFO_STTL, param, this.callback, 'GET');
  516. },
  517. callback: function (result) {
  518. // console.log(result);
  519. pageObj.switchScreen('DETAIL');
  520. $('#ITP_FORM_SETTMNG02010_DETAIL_BRAND_ID').val(result.brandId);
  521. $('#ITP_FORM_SETTMNG02010_DETAIL_STORE_ID').val(result.storeId);
  522. $('#ITP_FORM_SETTMNG02010_DETAIL_STTL_MGNT_UNQ_NO').val(result.sttlMgntUnqNo);
  523. $('#ITP_FORM_SETTMNG02010_DETAIL .fnBrandNm').text(result.brandNm);
  524. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSupplyNm').text(result.spplyNm);
  525. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlRjctRsn').text(result.sttlRjctRsn == null ? '' : result.sttlRjctRsn);
  526. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlStNm').text(result.sttlStNm);
  527. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlReqDt').text(result.sttlReqDt); // 정산일자
  528. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlReqAmt').text(itp_fn_number_comma(result.sttlReqAmt));
  529. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlDt').text(result.sttlDt == null ? '' : result.sttlDt); // 정산일자
  530. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSttlAmt').text(itp_fn_number_comma(result.sttlAmt));
  531. $('#ITP_FORM_SETTMNG02010_DETAIL .fnAcctBal').text(itp_fn_number_comma(result.acctBal));
  532. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSysRegDttm').text(result.sysRegDttm);
  533. $('#ITP_FORM_SETTMNG02010_DETAIL .fnSysRegNm').text(result.sysRegNm);
  534. // 정산요청 상태
  535. if(result.sttlStCd == 'ST10') {
  536. $('#ITP_BTN_SETTMNG02010_CONFIRM').show();
  537. $('#ITP_BTN_SETTMNG02010_REJECT').show();
  538. } else {
  539. $('#ITP_BTN_SETTMNG02010_CONFIRM').hide();
  540. $('#ITP_BTN_SETTMNG02010_REJECT').hide();
  541. }
  542. // 리스트 조회
  543. modifyObj.grid.init();
  544. },
  545. grid: {
  546. init: function() {
  547. this.unload();
  548. this.load();
  549. },
  550. colModel: gridColModel.view,
  551. load : function() {
  552. let param = $('#ITP_FORM_SETTMNG02010_DETAIL').serializeObject();
  553. param.gridSize = $.jgrid.defaults.rowNum;
  554. //param.pagingYn = false; // 페이징안함
  555. var option = {
  556. gridId: SETTMNG02010_DETAIL_GRID_ID,
  557. colModel: gridColModel.view,
  558. param: param,
  559. url: DOMAIN + STTL_REQ_STL_GRID_LIST,
  560. pager: SETTMNG02010_DETAIL_GRID_PAGER,
  561. loadComplete: function(data) {
  562. itp_fn_grid_load_complete(data, SETTMNG02010_DETAIL_GRID_ID, true, undefined, 'SETTMNG02010_DETAIL');
  563. },
  564. onPaging: function(action) {
  565. var pagingFn = {
  566. callBack: function(args) {
  567. $(args).trigger('reloadGrid');
  568. }
  569. };
  570. if (itp_fn_check_grid_is_writing(SETTMNG02010_DETAIL_GRID_ID)) {
  571. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, SETTMNG02010_DETAIL_GRID_ID);
  572. return 'stop';
  573. } else {
  574. itp_fn_grid_paging(SETTMNG02010_DETAIL_GRID_ID, action, param);
  575. }
  576. },
  577. onSortCol: function(index, columnIndex, sortOrder) {
  578. var sortingFn = {
  579. callBack: function(args) {
  580. $(args).trigger('reloadGrid');
  581. }
  582. };
  583. if (itp_fn_check_grid_is_writing(SETTMNG02010_DETAIL_GRID_ID)) {
  584. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, SETTMNG02010_DETAIL_GRID_ID);
  585. return 'stop';
  586. } else {
  587. itp_fn_grid_sorting(SETTMNG02010_DETAIL_GRID_ID, index, sortOrder);
  588. }
  589. }
  590. };
  591. itp_fn_grid_make_remote(option);
  592. },
  593. clearData : function() {
  594. $(SETTMNG02010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  595. $(SETTMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  596. $(SETTMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  597. $(SETTMNG02010_DETAIL_GRID_EMPTY).show();
  598. },
  599. unload : function() {
  600. $.jgrid.gridUnload(SETTMNG02010_DETAIL_GRID_ID);
  601. }
  602. }
  603. };