ITP_VSETTMNG02010.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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 VSETTMNG02010_GRID_ID = '#ITP_VSETTMNG02010_jqGrid';
  12. const VSETTMNG02010_GRID_LIST = '#ITP_VSETTMNG02010_jqGrid_list';
  13. const VSETTMNG02010_GRID_PAGER = '#ITP_VSETTMNG02010_jqGridPager';
  14. const VSETTMNG02010_GRID_EMPTY = '#ITP_VSETTMNG02010_jqGridEmpty';
  15. const VSETTMNG02010_DETAIL_GRID_ID = '#ITP_VSETTMNG02010_DETAIL_jqGrid';
  16. const VSETTMNG02010_DETAIL_GRID_LIST = '#ITP_VSETTMNG02010_DETAIL_jqGrid_list';
  17. const VSETTMNG02010_DETAIL_GRID_PAGER = '#ITP_VSETTMNG02010_DETAIL_jqGridPager';
  18. const VSETTMNG02010_DETAIL_GRID_EMPTY = '#ITP_VSETTMNG02010_DETAIL_jqGridEmpty';
  19. let ITP_FORM_VSETTMNG02010_DETAIL_IS_DUPLICATE = false;
  20. let ITP_FORM_VSETTMNG02010_DETAIL_IS_WRITING = false;
  21. let VSETTMNG02010_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: '14', fixed: false, align: 'left',
  41. sortable: false, hidden: false, classes: 'ui-ellipsis'
  42. },
  43. {
  44. index: 'STORE_NM', name: 'storeNm',
  45. label: "매장명",
  46. width: '10', fixed: false, align: 'center',
  47. sortable: false, hidden: true
  48. },
  49. {
  50. index: 'LOAN_DVSN_NM', name: 'loanDvsnNm',
  51. label: "정산타입",
  52. width: '8', fixed: false, align: 'center',
  53. sortable: false, hidden: true
  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: '14', 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: '8', fixed: false, align: 'center',
  77. sortable: false, hidden: false
  78. },
  79. {
  80. index: 'STTL_REQ_DT', name: 'sttlReqDt',
  81. label: "정산요청일",
  82. width: '9', fixed: false, align: 'center',
  83. sortable: false, editable: false, edittype: 'text'
  84. },
  85. {
  86. index: 'STTL_DT', name: 'sttlDt',
  87. label: "정산확정일",
  88. width: '9', fixed: false, align: 'center',
  89. sortable: false, editable: false, edittype: 'text'
  90. },
  91. {
  92. index: 'STTL_REQ_AMT', name: 'sttlReqAmt',
  93. label: "정산요청금액",
  94. width: '9', fixed: false, align: 'right',
  95. sortable: false, editable: false, edittype: 'text',
  96. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  97. },
  98. {
  99. index: 'STTL_REQ_AMT', name: 'sttlAmt',
  100. label: "정산확정금액",
  101. width: '9', fixed: false, align: 'right',
  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: '9', fixed: false, align: 'right',
  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: '14', fixed: false, align: 'center',
  116. sortable: false, editable: false, edittype: 'text', classes: 'ui-ellipsis'
  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. minwidth: 140,
  148. width: '12', fixed: false, align: 'center',
  149. sortable: false, editable: false, edittype: 'text'
  150. },
  151. {
  152. index: 'ITEM_NM', name: 'itemNm',
  153. label: "품목명",
  154. width: '12', fixed: false, align: 'center',
  155. sortable: false, editable: false, edittype: 'text', classes: 'ui-ellipsis'
  156. },
  157. {
  158. index: 'UNIT', name: 'unit',
  159. label: "단위",
  160. width: '7', fixed: false, align: 'center',
  161. sortable: false, editable: false, edittype: 'text'
  162. },
  163. {
  164. index: 'UNIT_AMT', name: 'unitAmt',
  165. label: "단가",
  166. width: '8', fixed: false, align: 'right',
  167. sortable: false, editable: false, edittype: 'text',
  168. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  169. },
  170. {
  171. index: 'PODR_QTY', name: 'podrQty',
  172. label: "발주수량",
  173. width: '7', fixed: false, align: 'right',
  174. sortable: false, editable: false, edittype: 'text',
  175. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  176. },
  177. {
  178. index: 'DLV_QTY', name: 'dlvQty',
  179. label: "납품수량",
  180. width: '7', fixed: false, align: 'right',
  181. sortable: false, editable: false, edittype: 'text',
  182. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  183. },
  184. {
  185. index: 'WHS_COL_QTY', name: 'whsColQty',
  186. label: "입고/수거수량",
  187. width: '8', fixed: false, align: 'right',
  188. minwidth: 80,
  189. sortable: false, editable: false, edittype: 'text',
  190. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  191. },
  192. {
  193. index: 'WHS_COL_DT', name: 'whsColDt',
  194. label: "입고/수거일자",
  195. width: '8', fixed: false, align: 'center',
  196. minwidth: 80,
  197. sortable: false, editable: false, edittype: 'text'
  198. },
  199. {
  200. index: 'WHS_COL_AMT', name: 'whsColAmt',
  201. label: "입고/수거금액",
  202. width: '8', fixed: false, align: 'right',
  203. sortable: false, editable: false, edittype: 'text',
  204. minwidth: 80,
  205. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  206. },
  207. {
  208. index: 'STTL_DVSN_NM', name: 'sttlDvsnNm',
  209. label: "정산구분",
  210. width: '7', fixed: false, align: 'center',
  211. sortable: false, editable: false, edittype: 'text'
  212. },
  213. {
  214. index: 'PODR_UNQ_NO', name: 'podrUnqNo',
  215. label: "발주번호",
  216. width: '10', fixed: false, align: 'center',
  217. minwidth: 160,
  218. sortable: false, editable: false, edittype: 'text'
  219. },
  220. {
  221. index: 'PODR_DTL_NO', name: 'podrDtlNo',
  222. label: "발주항번",
  223. width: '7', fixed: false, align: 'center',
  224. sortable: false, editable: false, edittype: 'text'
  225. }
  226. ]
  227. };
  228. require(['config'], function() {
  229. require([
  230. 'kakao.map.util'
  231. ], function($) {
  232. pageObj.init();
  233. });
  234. });
  235. /*화면공통 Object*/
  236. let pageObj = {
  237. init: function () {
  238. this.ui.init();
  239. this.event.init();
  240. },
  241. ui: {
  242. init: function () {
  243. this.view();
  244. this.grid();
  245. this.ready();
  246. },
  247. view: function() {
  248. // 버튼 권한설정
  249. fn_proc_btn_auth('VSETTMNG02010');
  250. // 공통코드 표시
  251. $('select').each(function() {
  252. if($(this).data('select-code')) {
  253. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  254. }
  255. });
  256. // 조회일자 지정
  257. var now = new Date();
  258. var fromDate = new Date(now);
  259. fromDate.setDate(now.getDate() - 30);
  260. var toDate = new Date(now);
  261. $('#ITP_TAB_VSETTMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  262. $('#ITP_FORM_VSETTMNG02010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  263. $('#ITP_FORM_VSETTMNG02010_SEARCH_TO_DT').datepicker('setDate', toDate);
  264. // 권한에 따라 매장값 설정
  265. $('#ITP_FORM_VSETTMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  266. $('#ITP_FORM_VSETTMNG02010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  267. LOGIN_AUTH_TYPE_CD = fn_make_user_info.get('authTpCd'); // 권한타입
  268. if(LOGIN_AUTH_TYPE_CD == '50') {
  269. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
  270. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_NM').val(fn_make_user_info.get('storeNm'));
  271. }
  272. },
  273. grid: function() {
  274. itp_fn_jqgrid_resize(VSETTMNG02010_GRID_ID, VSETTMNG02010_GRID_LIST, 'lg');
  275. listObj.empty.init();
  276. itp_fn_fire_window_resize();
  277. },
  278. ready: function() {
  279. listObj.init();
  280. }
  281. },
  282. event: {
  283. init: function () {
  284. this.button();
  285. this.change();
  286. },
  287. button: function () {
  288. // 버튼 클릭 이벤트
  289. $('button').each(function() {
  290. var id = $(this).attr('id');
  291. $(this).on('click', function() {
  292. switch (id) {
  293. case 'ITP_BTN_VSETTMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  294. case 'ITP_BTN_VSETTMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  295. case 'ITP_BTN_VSETTMNG02010_STTL_REQ' : modifyObj.button.endSttl(); break; // 정산확정 버튼
  296. case 'ITP_BTN_VSETTMNG02010_SEARCH_STORE_POP' : listObj.button.storePop(); break; // 매장검색 팝업
  297. case 'ITP_BTN_VSETTMNG02010_SEARCH_ERASE' : listObj.button.storeErase(); break; // 매장 지움
  298. case 'ITP_BTN_VSETTMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  299. }
  300. });
  301. });
  302. $('body').on('click', function(e) {
  303. var gridId = VSETTMNG02010_DETAIL_GRID_ID.replace('#', '');
  304. var rids = $(VSETTMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  305. var last_row_id = rids[rids.length - 1];
  306. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'VSETTMNG02010_DETAIL');
  307. });
  308. },
  309. change: function() {
  310. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_GUBUN').on('change', function() {
  311. var gubunVal = $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_GUBUN').val();
  312. if(gubunVal == '1') { // 매장
  313. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '매장명');
  314. $(VSETTMNG02010_GRID_ID).jqGrid('hideCol', ["spplyNm"]);
  315. $(VSETTMNG02010_GRID_ID).jqGrid('showCol', ["storeNm"]);
  316. // $(VSETTMNG02010_GRID_ID).setColProp('spplyNm', {hidden: true});
  317. // $(VSETTMNG02010_GRID_ID).setColProp('storeNm', {hidden: false});
  318. } else if(gubunVal == '2') { // 공급업체
  319. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_NM').attr('placeholder', '공급사명');
  320. $(VSETTMNG02010_GRID_ID).jqGrid('hideCol', ["storeNm"]);
  321. $(VSETTMNG02010_GRID_ID).jqGrid('showCol', ["spplyNm"]);
  322. // $(VSETTMNG02010_GRID_ID).setColProp('storeNm', {hidden: true});
  323. // $(VSETTMNG02010_GRID_ID).setColProp('spplyNm', {hidden: false});
  324. }
  325. listObj.button.search();
  326. // itp_fn_jqgrid_resize(VSETTMNG02010_GRID_ID, VSETTMNG02010_GRID_LIST, 'lg');
  327. });
  328. }
  329. },
  330. switchScreen: function(mode) {
  331. if(mode == 'LIST') { // 목록
  332. $('#ITP_BTN_VSETTMNG02010_MODIFY').hide();
  333. $('#ITP_BTN_VSETTMNG02010_CANCELLIST').hide();
  334. $('#ITP_BTN_VSETTMNG02010_DELETE').hide();
  335. $('#ITP_BTN_VSETTMNG02010_STTL_REQ').hide();
  336. if(LOGIN_AUTH_TYPE_CD == '50') { // 매장관리자
  337. $('#ITP_BTN_VSETTMNG02010_SEARCH_STORE_POP').hide();
  338. $('#ITP_BTN_VSETTMNG02010_SEARCH_ERASE').hide();
  339. } else {
  340. $('#ITP_BTN_VSETTMNG02010_SEARCH_STORE_POP').show();
  341. $('#ITP_BTN_VSETTMNG02010_SEARCH_ERASE').show();
  342. }
  343. fn_show_btn_auth('#ITP_BTN_VSETTMNG02010_SRH');
  344. fn_show_btn_auth('#ITP_BTN_VSETTMNG02010_NEWREG');
  345. $('#ITP_AJAX_VSETTMNG02010_LIST_CONTAINER').show();
  346. $('#ITP_AJAX_VSETTMNG02010_DETAIL_CONTAINER').hide();
  347. $('#ITP_BTN_VSETTMNG02010_EXCEL').show();
  348. } else if(mode == 'DETAIL') { // 보기
  349. $('#ITP_BTN_VSETTMNG02010_SRH').hide();
  350. $('#ITP_BTN_VSETTMNG02010_NEWREG').hide();
  351. $('#ITP_BTN_VSETTMNG02010_DELETE').hide();
  352. fn_show_btn_auth('#ITP_BTN_VSETTMNG02010_STTL_REQ');
  353. fn_show_btn_auth('#ITP_BTN_VSETTMNG02010_CANCELLIST');
  354. $('#ITP_AJAX_VSETTMNG02010_LIST_CONTAINER').hide();
  355. $('#ITP_AJAX_VSETTMNG02010_DETAIL_CONTAINER').show();
  356. }
  357. }
  358. };
  359. /*목록화면 Object*/
  360. let listObj = {
  361. init: function () {
  362. this.grid.init();
  363. },
  364. itp_VSETTMNG02010_search: false,
  365. button: {
  366. search: function() {
  367. listObj.itp_VSETTMNG02010_search = true;
  368. let param = $('#ITP_FORM_VSETTMNG02010_SEARCH').serializeObject();
  369. param.gridSize = $.jgrid.defaults.rowNum;
  370. param.gridPage = $.jgrid.defaults.page;
  371. $(VSETTMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  372. },
  373. storePop: function() {
  374. fn_call_popup('biz', 'BIZPOP_BRAND_STORE', '#ITP_ASIDE', function(result) {
  375. // alert(JSON.stringify(result));
  376. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_ID').val(result[0].storeId);
  377. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_NM').val(result[0].storeNm);
  378. listObj.button.search();
  379. }, null, 'S');
  380. },
  381. storeErase: function() {
  382. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_ID').val('');
  383. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_SPPLY_NM').val('');
  384. listObj.button.search();
  385. }
  386. },
  387. empty: {
  388. init: function() {
  389. var _this = this;
  390. this.push();
  391. $(VSETTMNG02010_GRID_EMPTY).on('click', function() {
  392. _this.back();
  393. _this.itp_VSETTMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
  394. $(VSETTMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_VSETTMNG02010_param)}).trigger('reloadGrid');
  395. });
  396. },
  397. itp_VSETTMNG02010_param: {},
  398. push: function() {
  399. let param = $('#ITP_FORM_VSETTMNG02010_SEARCH').serializeObject();
  400. listObj.itp_VSETTMNG02010_param = param;
  401. },
  402. back: function() {
  403. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_ID').val(listObj.itp_VSETTMNG02010_param.sstoreId);
  404. $('#ITP_FORM_VSETTMNG02010_SEARCH_STORE_NM').val(listObj.itp_VSETTMNG02010_param.sstoreNm);
  405. $('#ITP_FORM_VSETTMNG02010_SEARCH_FROM_DT').val(listObj.itp_VSETTMNG02010_param.fromDt);
  406. $('#ITP_FORM_VSETTMNG02010_SEARCH_TO_DT').val(listObj.itp_VSETTMNG02010_param.toDt);
  407. $('#ITP_FORM_VSETTMNG02010_SEARCH_ITEM_NM').val(listObj.itp_VSETTMNG02010_param.sitemNm);
  408. }
  409. },
  410. grid: {
  411. init: function () {
  412. // 데이터 없을때
  413. listObj.empty.push();
  414. this.search();
  415. },
  416. colModel: gridColModel.list,
  417. search: function() {
  418. pageObj.switchScreen('LIST');
  419. this.unload();
  420. this.load();
  421. },
  422. load: function() {
  423. let param = $('#ITP_FORM_VSETTMNG02010_SEARCH').serializeObject();
  424. param.gridSize = $.jgrid.defaults.rowNum;
  425. var option = {
  426. gridId: VSETTMNG02010_GRID_ID,
  427. colModel: gridColModel.list,
  428. param: param,
  429. url: DOMAIN + STTL_STATE_DETAIL_GRID_LIST,
  430. pager: VSETTMNG02010_GRID_PAGER,
  431. onCellSelect: function(rowId, cellIdx, cellValue) {
  432. var cm = $(this).jqGrid('getGridParam', 'colModel');
  433. var colNm = cm[cellIdx].name;
  434. if (colNm == 'sttlMgntUnqNo') {
  435. const sttlMgntUnqNoVal = $(this).jqGrid('getCell', rowId, 'sttlMgntUnqNo');
  436. const key = {sttlMgntUnqNo: sttlMgntUnqNoVal, viewCd: 'R'};
  437. var param = $.param(key);
  438. modifyObj.init(param);
  439. }
  440. },
  441. loadComplete: function(data) {
  442. console.log(data);
  443. itp_fn_grid_load_complete(data, VSETTMNG02010_GRID_ID, true, 'number', 'VSETTMNG02010', listObj.itp_VSETTMNG02010_search, listObj.empty, true, data.gridRecords, true);
  444. var ids = $(VSETTMNG02010_GRID_ID).getDataIDs();
  445. $.each(ids, function(idx, rowId) {
  446. $(VSETTMNG02010_GRID_ID).jqGrid('setCell', rowId, 'sttlMgntUnqNo', '', ITP_GRID_COL_STYLE.link);
  447. });
  448. },
  449. onPaging: function(action) {
  450. itp_fn_grid_paging(VSETTMNG02010_GRID_ID, action, param);
  451. }
  452. };
  453. itp_fn_grid_make_remote(option);
  454. },
  455. clearData : function() {
  456. $(VSETTMNG02010_GRID_ID).jqGrid('clearGridData', true);
  457. $(VSETTMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  458. $(VSETTMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  459. $(VSETTMNG02010_GRID_EMPTY).show();
  460. },
  461. unload : function() {
  462. $.jgrid.gridUnload(VSETTMNG02010_GRID_ID);
  463. }
  464. },
  465. excelDown: function() {
  466. var param = {
  467. 'url': STTL_STATE_DETAIL_GRID_LIST,
  468. 'param': $('#ITP_FORM_VSETTMNG02010_SEARCH').serializeObject(),
  469. 'gridColumns': $(VSETTMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  470. 'fileName': '공급사 정산현황.xlsx',
  471. 'sheetName': '공급사 정산리스트'
  472. };
  473. itp_fn_remote_to_excel(param);
  474. }
  475. };
  476. /*상세화면 Object*/
  477. let modifyObj = {
  478. init: function (param) {
  479. this.load(param);
  480. },
  481. button: {
  482. cancel: function() {
  483. listObj.grid.search();
  484. },
  485. endSttl: function() {
  486. // 정산확정
  487. const formId = '#ITP_FORM_VSETTMNG02010_DETAIL';
  488. let param = $(formId).serializeObject();
  489. var confirmFn= {
  490. callBack: function() {
  491. var searhFn = function() {
  492. listObj.grid.search();
  493. };
  494. fn_ajax_call(STTL_STATE_STTL_END, JSON.stringify(param), searhFn, 'POST');
  495. }
  496. };
  497. var sttlReqAmt = parseInt($('#ITP_FORM_VSETTMNG02010_DETAIL_STTL_REQ_AMT').val());
  498. var acctBal = parseInt($('#ITP_FORM_VSETTMNG02010_DETAIL_ACCT_BAL').val());
  499. if(acctBal > 0) {
  500. if(acctBal >= sttlReqAmt) {
  501. itp_fn_modal_confirm('계좌잔액에서 지급처리가 진행됩니다.\n정산 확정하시겠습니까?', confirmFn, null);
  502. } else {
  503. itp_fn_modal_confirm('일부금액이 계좌잔액에서 지급처리가 진행됩니다.\n정산 확정하시겠습니까?', confirmFn, null);
  504. }
  505. } else {
  506. itp_fn_modal_confirm('정산 확정하시겠습니까?', confirmFn, null);
  507. }
  508. }
  509. },
  510. load: function(param) {
  511. fn_ajax_call(STTL_REQ_INFO_STTL, param, this.callback, 'GET');
  512. },
  513. callback: function (result) {
  514. // console.log(result);
  515. pageObj.switchScreen('DETAIL');
  516. $('#ITP_FORM_VSETTMNG02010_DETAIL_BRAND_ID').val(result.brandId);
  517. $('#ITP_FORM_VSETTMNG02010_DETAIL_STORE_ID').val(result.storeId);
  518. $('#ITP_FORM_VSETTMNG02010_DETAIL_STTL_MGNT_UNQ_NO').val(result.sttlMgntUnqNo);
  519. $('#ITP_FORM_VSETTMNG02010_DETAIL_ACCT_BAL').val(result.acctBal); // 계좌잔액
  520. $('#ITP_FORM_VSETTMNG02010_DETAIL_STTL_REQ_AMT').val(result.sttlReqAmt); // 정산요청금액
  521. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnBrandNm').text(result.brandNm);
  522. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlMgntUnqNo').text(result.sttlMgntUnqNo);
  523. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnLoanDvsnNm').text(result.loanDvsnNm);
  524. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnAcctBal').text(itp_fn_number_comma(result.acctBal));
  525. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlRjctRsn').text(result.sttlRjctRsn == null ? '' : result.sttlRjctRsn);
  526. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlStNm').text(result.sttlStNm);
  527. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlReqDt').text(result.sttlReqDt); // 정산요청일자
  528. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlReqAmt').text(itp_fn_number_comma(result.sttlReqAmt));
  529. // $('#ITP_FORM_VSETTMNG02010_DETAIL_STTL_DT').val(result.sttlDt); // 정산일자
  530. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlDt').text(result.sttlDt == null ? '' : result.sttlDt); // 정산요청일자
  531. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSttlAmt').text(itp_fn_number_comma(result.sttlAmt));
  532. // $('#ITP_FORM_VSETTMNG02010_DETAIL .fnRcptYn').text(result.rcptYn == null ? '' : result.rcptYn);
  533. // $('#ITP_FORM_VSETTMNG02010_DETAIL .fnRcptDt').text(result.rcptDt == null ? '' : result.rcptDt);
  534. if(result.rcptYn == null) {
  535. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnRcptYnDate').text('');
  536. } else if(result.rcptYn == 'N') {
  537. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnRcptYnDate').text('N');
  538. } else if(result.rcptYn == 'Y') {
  539. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnRcptYnDate').text('Y (' + result.rcptDt + ')');
  540. }
  541. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnUnpaidAmt').text(itp_fn_number_comma(result.unpaidAmt));
  542. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSysRegDttm').text(result.sysRegDttm);
  543. $('#ITP_FORM_VSETTMNG02010_DETAIL .fnSysRegNm').text(result.sysRegNm);
  544. if(result.sttlStCd == 'ST10') { // 정산요청
  545. $('#ITP_BTN_VSETTMNG02010_STTL_REQ').show();
  546. } else {
  547. $('#ITP_BTN_VSETTMNG02010_STTL_REQ').hide();
  548. }
  549. // 리스트 조회
  550. modifyObj.grid.init();
  551. },
  552. grid: {
  553. init: function() {
  554. this.unload();
  555. this.load();
  556. },
  557. load : function() {
  558. let param = $('#ITP_FORM_VSETTMNG02010_DETAIL').serializeObject();
  559. param.gridSize = $.jgrid.defaults.rowNum;
  560. param.pagingYn = false; // 페이징안함
  561. var option = {
  562. gridId: VSETTMNG02010_DETAIL_GRID_ID,
  563. colModel: gridColModel.view,
  564. param: param,
  565. url: DOMAIN + STTL_REQ_STL_GRID_LIST,
  566. pager: VSETTMNG02010_DETAIL_GRID_PAGER,
  567. loadComplete: function(data) {
  568. itp_fn_grid_load_complete(data, VSETTMNG02010_DETAIL_GRID_ID, true, undefined, 'VSETTMNG02010_DETAIL');
  569. },
  570. onPaging: function(action) {
  571. var pagingFn = {
  572. callBack: function(args) {
  573. $(args).trigger('reloadGrid');
  574. }
  575. };
  576. if (itp_fn_check_grid_is_writing(VSETTMNG02010_DETAIL_GRID_ID)) {
  577. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, VSETTMNG02010_DETAIL_GRID_ID);
  578. return 'stop';
  579. } else {
  580. itp_fn_grid_paging(VSETTMNG02010_DETAIL_GRID_ID, action, param);
  581. }
  582. },
  583. onSortCol: function(index, columnIndex, sortOrder) {
  584. var sortingFn = {
  585. callBack: function(args) {
  586. $(args).trigger('reloadGrid');
  587. }
  588. };
  589. if (itp_fn_check_grid_is_writing(VSETTMNG02010_DETAIL_GRID_ID)) {
  590. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, sortingFn, VSETTMNG02010_DETAIL_GRID_ID);
  591. return 'stop';
  592. } else {
  593. itp_fn_grid_sorting(VSETTMNG02010_DETAIL_GRID_ID, index, sortOrder);
  594. }
  595. }
  596. };
  597. itp_fn_grid_make_remote(option);
  598. },
  599. clearData : function() {
  600. $(VSETTMNG02010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  601. $(VSETTMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  602. $(VSETTMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  603. $(VSETTMNG02010_DETAIL_GRID_EMPTY).show();
  604. },
  605. unload : function() {
  606. $.jgrid.gridUnload(VSETTMNG02010_DETAIL_GRID_ID);
  607. }
  608. }
  609. };