ITP_RTNMNG04010.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. //화면변수
  8. const RTNMNG04010_GRID_ID = '#ITP_RTNMNG04010_jqGrid';
  9. const RTNMNG04010_GRID_LIST = '#ITP_RTNMNG04010_jqGrid_list';
  10. const RTNMNG04010_GRID_PAGER = '#ITP_RTNMNG04010_jqGridPager';
  11. const RTNMNG04010_GRID_EMPTY = '#ITP_RTNMNG04010_jqGridEmpty';
  12. const RTNMNG04010_DETAIL_GRID_ID = '#ITP_RTNMNG04010_DETAIL_jqGrid';
  13. const RTNMNG04010_DETAIL_GRID_LIST = '#ITP_RTNMNG04010_DETAIL_jqGrid_list';
  14. const RTNMNG04010_DETAIL_GRID_PAGER = '#ITP_RTNMNG04010_DETAIL_jqGridPager';
  15. const RTNMNG04010_DETAIL_GRID_EMPTY = '#ITP_RTNMNG04010_DETAIL_jqGridEmpty';
  16. let ITP_PODR_DTL_ST_CD = fn_make_common_cd_list(CODE_LIST, 'PODR_DTL_ST_CD', true, '구매발주상세상태코드');
  17. //API URL
  18. let API_RTNMNG_RTN_DETAIL_GRID_LIST = '/api/rtnmng/rtn/detail-grid-list';
  19. let API_RTNMNG_RTN_INFO_RTNODR = '/api/rtnmng/rtn/info-rtnOdr';
  20. let API_RTNMNG_RTN_CANCEL_RTNPO = '/api/rtnmng/rtn/cancel-rtnPo';
  21. //화면 grid ColModel
  22. const gridColModel = {
  23. list:[
  24. {
  25. index: 'VIEW_CD', name: 'viewCd',
  26. label: ITP_MSG_LOCALE.label.viewCd,
  27. width: '10', fixed: false, align: 'center',
  28. sortable: false, hidden: true
  29. },
  30. {
  31. index: 'BRAND_NM', name: 'brandNm',
  32. label: ITP_MSG_LOCALE.label.brandNm, // 브랜드명
  33. width: '9', fixed: false, align: 'left',
  34. sortable: false, hidden: false, classes: 'ui-ellipsis'
  35. },
  36. {
  37. index: 'RTN_PODR_UNQ_NO', name: 'rtnPodrUnqNo',
  38. label: '반품발주번호',
  39. width: '10', fixed: false, align: 'center',
  40. sortable: false, hidden: false
  41. },
  42. {
  43. index: 'RTN_ODR_ST_NM', name: 'rtnOdrStNm',
  44. label: '발주상태',
  45. width: '7', fixed: false, align: 'center',
  46. sortable: false, hidden: false
  47. },
  48. {
  49. index: 'RTN_ODR_REG_DT', name: 'rtnOdrRegDt',
  50. label: '반품발주일자',
  51. width: '8', fixed: false, align: 'center',
  52. sortable: false, hidden: false
  53. },
  54. {
  55. index: 'RTN_WHS_NM', name: 'rtnWhsNm',
  56. label: '수거처',
  57. width: '9', fixed: false, align: 'left',
  58. sortable: false, hidden: false, classes: 'ui-ellipsis'
  59. },
  60. {
  61. index: 'SPPLY_NM', name: 'spplyNm',
  62. label: ITP_MSG_LOCALE.label.spplyNm, // 공급업체명
  63. width: '10', fixed: false, align: 'left',
  64. sortable: false, hidden: false, classes: 'ui-ellipsis'
  65. },
  66. {
  67. index: 'RTN_DODR_TOTAL_AMT', name: 'rtnDodrTotalAmt',
  68. label: '총 반품발주금액',
  69. width: '8', fixed: false, align: 'right',
  70. sortable: false, hidden: false,
  71. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  72. },
  73. {
  74. index: 'rtn_Dodr_Item_Qty', name: 'rtnDodrItemQty',
  75. label: '반품발주품목수',
  76. width: '8', fixed: false, align: 'right',
  77. sortable: false, hidden: false,
  78. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  79. },
  80. {
  81. index: 'COL_REQ_DT', name: 'colReqDt',
  82. label: '수거요청일',
  83. width: '8', fixed: false, align: 'center',
  84. sortable: false, hidden: false
  85. },
  86. {
  87. index: 'col_Dvsn_Nm', name: 'colDvsnNm',
  88. label: '수거구분',
  89. width: '7', fixed: false, align: 'center',
  90. sortable: false, hidden: false
  91. }
  92. ],
  93. view: [],
  94. detail: [
  95. {
  96. index: 'VIEW_CD', name: 'viewCd',
  97. label: ITP_MSG_LOCALE.label.viewCd,
  98. width: '10', fixed: false, align: 'center',
  99. sortable: false, hidden: true
  100. },
  101. {
  102. index: 'RTN_PODR_DTL_NO', name: 'rtnPodrDtlNo',
  103. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, // 발주항번
  104. width: '4', fixed: false, align: 'center',
  105. sortable: false, hidden: false
  106. },
  107. {
  108. index: 'ITEM_ID', name: 'itemId',
  109. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  110. width: '8', fixed: false, align: 'center',
  111. sortable: false, hidden: false
  112. },
  113. {
  114. index: 'ITEM_NM', name: 'itemNm',
  115. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  116. width: '10', fixed: false, align: 'left',
  117. sortable: false, hidden: false, classes: 'ui-ellipsis'
  118. },
  119. {
  120. index: 'RODR_DTL_ST_NM', name: 'rodrDtlStNm',
  121. label: '발주상세상태',
  122. width: '5', fixed: false, align: 'center',
  123. sortable: false, hidden: false
  124. },
  125. {
  126. index: 'UNIT_AMT', name: 'unitAmt',
  127. label: ITP_MSG_LOCALE.label.unitAmt, // 단가
  128. width: '5', fixed: false, align: 'right',
  129. sortable: false, hidden: false,
  130. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  131. },
  132. {
  133. index: 'UNIT', name: 'unit',
  134. label: ITP_MSG_LOCALE.label.unit, // 기본단위
  135. width: '4', fixed: false, align: 'center',
  136. sortable: false, hidden: false
  137. },
  138. {
  139. index: 'RTN_REQ_QTY', name: 'rtnReqQty',
  140. label: '반품요청수량',
  141. width: '5', fixed: false, align: 'right',
  142. sortable: false, hidden: false,
  143. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  144. },
  145. {
  146. index: 'RTN_ODR_QTY', name: 'rtnOdrQty',
  147. label: '반품발주수량',
  148. width: '5', fixed: false, align: 'right',
  149. sortable: false, hidden: false,
  150. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  151. },
  152. {
  153. index: 'RTN_ODR_AMT', name: 'rtnOdrAmt',
  154. label: ITP_MSG_LOCALE.label.podrAmt, // 발주금액
  155. width: '6', fixed: false, align: 'right',
  156. sortable: false, hidden: false,
  157. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  158. }
  159. ]
  160. };
  161. /*화면공통 Object*/
  162. let pageObj = {
  163. init: function() {
  164. this.ui.init();
  165. this.event.init();
  166. },
  167. ui: {
  168. init: function() {
  169. this.view();
  170. this.grid();
  171. this.ready();
  172. },
  173. view: function() {
  174. // 버튼 권한설정
  175. fn_proc_btn_auth('RTNMNG04010');
  176. // 공통코드 표시
  177. $('select').each(function() {
  178. if($(this).data('select-code')) {
  179. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  180. }
  181. });
  182. // 조회일자 지정
  183. var now = new Date();
  184. var fromDate = new Date(now);
  185. fromDate.setDate(now.getDate() - 7);
  186. var toDate = new Date(now);
  187. $('#ITP_TAB_RTNMNG04010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  188. $('#ITP_FORM_RTNMNG04010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  189. $('#ITP_FORM_RTNMNG04010_SEARCH_TO_DT').datepicker('setDate', toDate);
  190. },
  191. grid: function() {
  192. itp_fn_jqgrid_resize(RTNMNG04010_GRID_ID, RTNMNG04010_GRID_LIST, 'lg');
  193. listObj.empty.init();
  194. },
  195. ready: function() {
  196. listObj.init();
  197. }
  198. },
  199. event: {
  200. init: function() {
  201. this.button();
  202. },
  203. button: function() {
  204. // 버튼 클릭 이벤트
  205. $('button').each(function() {
  206. var id = $(this).attr('id');
  207. $(this).on('click', function() {
  208. switch (id) {
  209. case 'ITP_BTN_RTNMNG04010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  210. case 'ITP_BTN_RTNMNG04010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  211. case 'ITP_BTN_RTNMNG04010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  212. case 'ITP_BTN_RTNMNG04010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  213. case 'ITP_BTN_RTNMNG04010_RTNCANCEL' : modifyObj.button.del(); break; // 발주 취소 버튼(예정)
  214. case 'ITP_BTN_RTNMNG04010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  215. }
  216. });
  217. });
  218. }
  219. },
  220. switchScreen: function(mode) {
  221. $('.itp_det_head').find('button[id^="ITP_BTN_RTNMNG04010_"]').each(function(i) {
  222. $(this).hide();
  223. });
  224. $('#ITP_TAB_RTNMNG04010').find('div[id$="_CONTAINER"]').each(function(i) {
  225. $(this).hide();
  226. });
  227. if(mode == 'LIST') { // 목록
  228. itp_fn_fire_window_resize();
  229. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG04010_SRH', '#ITP_BTN_RTNMNG04010_NEWREG']);
  230. $('#ITP_AJAX_RTNMNG04010_LIST_CONTAINER').show();
  231. $('#ITP_FORM_RTNMNG04010_SEARCH #ITP_FORM_RTNMNG04010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  232. $('#ITP_BTN_RTNMNG04010_SEARCH_SPPLY_ID').show();
  233. $('#ITP_BTN_RTNMNG04010_DELETE_SPPLY_ID').show();
  234. $('#ITP_BTN_RTNMNG04010_SEARCH_WHS_ID').show();
  235. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SWHS_NM').show();
  236. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SRTN_WHS_NM').show();
  237. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SSPPLY_NM').show();
  238. $('#ITP_BTN_RTNMNG04010_EXCEL').show();
  239. } else if(mode == 'MODIFY') { // 수정
  240. $('#ITP_AJAX_RTNMNG04010_DETAIL_CONTAINER').show();
  241. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG04010_CANCELLIST', '#ITP_BTN_RTNMNG04010_RTNCANCEL']);
  242. $('#ITP_BTN_RTNMNG04010_CANCELLIST').show();
  243. $('#ITP_BTN_RTNMNG04010_DELETE').show();
  244. $('#ITP_FORM_RTNMNG04010_DETAIL_BRAND_ID').attr('readonly', true);
  245. $('#ITP_FORM_RTNMNG04010_DETAIL_BRAND_NM').attr('readonly', true);
  246. $('#ITP_FORM_RTNMNG04010_DETAIL_BSNS_REG_NO').attr('readonly', true);
  247. $('#ITP_FORM_RTNMNG04010_DETAIL_CORP_REG_NO').attr('readonly', true);
  248. $('#ITP_FORM_RTNMNG04010_DETAIL_SEARCH_AFFL_SHOP').hide();
  249. $('#ITP_FORM_RTNMNG04010_DETAIL_DELETE_AFFL_SHOP').hide();
  250. $('#ITP_FORM_RTNMNG04010_DETAIL .itp_form_info').show();
  251. $('#ITP_FORM_RTNMNG04010_DETAIL .itp_form_change').hide();
  252. $('#ITP_FORM_RTNMNG04010_DETAIL #ITP_FORM_RTNMNG04010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  253. }
  254. }
  255. };
  256. /*목록화면 Object*/
  257. let listObj = {
  258. init: function() {
  259. this.grid.init();
  260. this.action();
  261. },
  262. itp_RTNMNG04010_param: {},
  263. itp_RTNMNG04010_search: false,
  264. button: {
  265. search: function() {
  266. listObj.itp_RTNMNG04010_search = true;
  267. let param = $('#ITP_FORM_RTNMNG04010_SEARCH').serializeObject();
  268. param.gridSize = $.jgrid.defaults.rowNum;
  269. param.gridPage = $.jgrid.defaults.page;
  270. param.sidx = '0';
  271. $(RTNMNG04010_GRID_ID).data('grid-param',param);
  272. $(RTNMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  273. }
  274. },
  275. empty: {
  276. init: function() {
  277. var _this = this;
  278. this.push();
  279. $(RTNMNG04010_GRID_EMPTY).on('click', function() {
  280. _this.back();
  281. listObj.itp_RTNMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  282. $(RTNMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_RTNMNG04010_param)}).trigger('reloadGrid');
  283. });
  284. },
  285. push: function() {
  286. let param = $('#ITP_FORM_RTNMNG04010_SEARCH').serializeObject();
  287. listObj.itp_RTNMNG04010_param = param;
  288. param.sidx = '0';
  289. },
  290. back: function() {
  291. $('#ITP_FORM_RTNMNG04010_SERVICE_BRAND_TYPE').val(listObj.itp_RTNMNG04010_param.brandType);
  292. $('#ITP_FORM_RTNMNG04010_SERVICE_ST_CD').val(listObj.itp_RTNMNG04010_param.stCd);
  293. $('#ITP_FORM_RTNMNG04010_SEARCH_BRAND_NM').val(listObj.itp_RTNMNG04010_param.brandNm);
  294. }
  295. },
  296. grid: {
  297. init: function() {
  298. // 데이터 없을때
  299. listObj.empty.push();
  300. this.search();
  301. },
  302. colModel: gridColModel.list,
  303. search: function() {
  304. pageObj.switchScreen('LIST');
  305. this.unload();
  306. this.load();
  307. },
  308. load: function() {
  309. let param = $('#ITP_FORM_RTNMNG04010_SEARCH').serializeObject();
  310. param.gridSize = $.jgrid.defaults.rowNum;
  311. param.sidx = '0';
  312. var option = {
  313. gridId: RTNMNG04010_GRID_ID,
  314. colModel: gridColModel.list,
  315. param: param,
  316. url: DOMAIN + API_RTNMNG_RTN_DETAIL_GRID_LIST,
  317. pager: RTNMNG04010_GRID_PAGER,
  318. onCellSelect: function(rowId, cellIdx, cellValue) {
  319. var cm = $(this).jqGrid('getGridParam', 'colModel');
  320. var colNm = cm[cellIdx].name;
  321. if (colNm === 'rtnPodrUnqNo') {
  322. const rtnPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'rtnPodrUnqNo');
  323. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  324. const key = {rtnPodrUnqNo: rtnPodrUnqNoVal, brandId: brandIdVal};
  325. var param = $.param(key);
  326. modifyObj.init(param);
  327. }
  328. },
  329. loadComplete: function(data) {
  330. itp_fn_grid_load_complete(data, RTNMNG04010_GRID_ID, true, 'number', 'RTNMNG04010', listObj.itp_RTNMNG04010_search, listObj.empty, true, data.gridRecords, true);
  331. var ids = $(RTNMNG04010_GRID_ID).getDataIDs();
  332. $.each(ids, function(idx, rowId) {
  333. $(RTNMNG04010_GRID_ID).jqGrid('setCell', rowId, 'rtnPodrUnqNo', '', ITP_GRID_COL_STYLE.link);
  334. });
  335. },
  336. onPaging: function(action) {
  337. itp_fn_grid_paging(RTNMNG04010_GRID_ID, action, param);
  338. }
  339. };
  340. itp_fn_grid_make_remote(option);
  341. },
  342. clearData: function() {
  343. $(RTNMNG04010_GRID_ID).jqGrid('clearGridData', true);
  344. $(RTNMNG04010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  345. $(RTNMNG04010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  346. $(RTNMNG04010_GRID_EMPTY).show();
  347. },
  348. unload: function() {
  349. $.jgrid.gridUnload(RTNMNG04010_GRID_ID);
  350. }
  351. },
  352. action: function() {
  353. var _this = this;
  354. // 매장/창고 조회 버튼 클릭
  355. $('#ITP_BTN_RTNMNG04010_SEARCH_POP_SWHS_NM').on('click', function() {
  356. _this.popup('whs');
  357. });
  358. // 매장/창고 텍스트 삭제 버튼 클릭
  359. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SWHS_NM').on('click', function() {
  360. $('#ITP_FORM_RTNMNG04010_SEARCH_SWHS_NM').val('');
  361. $('#ITP_FORM_RTNMNG04010_SEARCH_SWHS_ID').val('');
  362. });
  363. // 매장/창고 조회 버튼 클릭
  364. $('#ITP_BTN_RTNMNG04010_SEARCH_POP_SRTN_WHS_NM').on('click', function() {
  365. _this.popup('rwhs');
  366. });
  367. // 매장/창고 텍스트 삭제 버튼 클릭
  368. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SRTN_WHS_NM').on('click', function() {
  369. $('#ITP_FORM_RTNMNG04010_SEARCH_SRTN_WHS_NM').val('');
  370. $('#ITP_FORM_RTNMNG04010_SEARCH_SRTN_WHS_ID').val('');
  371. });
  372. // 공급업체 조회 버튼 클릭
  373. $('#ITP_BTN_RTNMNG04010_SEARCH_POP_SSPPLY_NM').on('click', function() {
  374. _this.popup('spply');
  375. });
  376. // 공급업체 텍스트 삭제 버튼 클릭
  377. $('#ITP_BTN_RTNMNG04010_SEARCH_DEL_SSPPLY_NM').on('click', function() {
  378. $('#ITP_FORM_RTNMNG04010_SEARCH_SSPPLY_NM').val('');
  379. $('#ITP_FORM_RTNMNG04010_SEARCH_SSPPLY_ID').val('');
  380. });
  381. },
  382. popup: function(keyword) {
  383. if(keyword === 'spply'){
  384. var popFn = this.callback.spply;
  385. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  386. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  387. } else if(keyword === 'whs'){
  388. var popFn = this.callback.whs;
  389. const key1 = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  390. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key1, 'S');
  391. } else if(keyword === 'rwhs'){
  392. var popFn = this.callback.rwhs;
  393. const key1 = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  394. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key1, 'S');
  395. }
  396. },
  397. callback: {
  398. whs: function(rowDataPop) {
  399. $('#ITP_FORM_RTNMNG04010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  400. $('#ITP_FORM_RTNMNG04010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  401. },
  402. rwhs: function(rowDataPop) {
  403. $('#ITP_FORM_RTNMNG04010_SEARCH_SRTN_WHS_NM').val(rowDataPop.whsNm);
  404. $('#ITP_FORM_RTNMNG04010_SEARCH_SRTN_WHS_ID').val(rowDataPop.whsId);
  405. },
  406. spply: function(rowDataPop) {
  407. $('#ITP_FORM_RTNMNG04010_SEARCH_SSPPLY_NM').val(rowDataPop.spplyNm);
  408. $('#ITP_FORM_RTNMNG04010_SEARCH_SSPPLY_ID').val(rowDataPop.spplyId);
  409. }
  410. },
  411. excelDown: function() {
  412. var param = {
  413. 'url': API_RTNMNG_RTN_DETAIL_GRID_LIST,
  414. 'param': $('#ITP_FORM_RTNMNG04010_SEARCH').serializeObject(),
  415. 'gridColumns': $(RTNMNG04010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  416. 'fileName': '반품발주현황.xlsx',
  417. 'sheetName': '반품발주현황리스트'
  418. };
  419. itp_fn_remote_to_excel(param);
  420. }
  421. };
  422. /*수정화면 Object*/
  423. let modifyObj = {
  424. init: function(param) {
  425. this.load(param);
  426. },
  427. itp_RTNMNG04010_param: {},
  428. itp_RTNMNG04010_search: false,
  429. button: {
  430. cancel: function() {
  431. listObj.grid.search();
  432. },
  433. del: function() {
  434. var modalFn = {
  435. callBack: () => {
  436. var param = {brandId: $('#ITP_FORM_RTNMNG04010_DETAIL_BRAND_ID').val(), rtnPodrUnqNo: $('#ITP_FORM_RTNMNG04010_DETAIL_RTN_PODR_UNQ_NO').val()};
  437. var searhFn = function () {
  438. listObj.grid.search();
  439. }
  440. fn_ajax_call(API_RTNMNG_RTN_CANCEL_RTNPO, JSON.stringify(param), searhFn, 'POST');
  441. }
  442. };
  443. itp_fn_modal_confirm('반품발주를 취소 하시겠습니까?', modalFn);
  444. }
  445. },
  446. empty: {
  447. init: function() {
  448. var _this = this;
  449. this.push();
  450. $(RTNMNG04010_VIEW_GRID_EMPTY).on('click', function() {
  451. _this.back();
  452. viewObj.itp_RTNMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  453. $(RTNMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(viewObj.itp_RTNMNG04010_param)}).trigger('reloadGrid');
  454. });
  455. },
  456. push: function() {
  457. let param = $('#ITP_FORM_RTNMNG04010_DETAIL').serializeObject();
  458. viewObj.itp_RTNMNG04010_param = param;
  459. },
  460. back: function() {
  461. $('#ITP_FORM_RTNMNG04010_SERVICE_BRAND_TYPE').val(viewObj.itp_RTNMNG04010_param.brandType);
  462. $('#ITP_FORM_RTNMNG04010_SERVICE_ST_CD').val(viewObj.itp_RTNMNG04010_param.stCd);
  463. $('#ITP_FORM_RTNMNG04010_SEARCH_BRAND_NM').val(viewObj.itp_RTNMNG04010_param.brandNm);
  464. }
  465. },
  466. load: function(param) {
  467. fn_ajax_call(API_RTNMNG_RTN_INFO_RTNODR, param, this.callback, 'GET');
  468. },
  469. callback: function(result) {
  470. // 그리드 전화번호 '-' 함수
  471. let telNo = '';
  472. if(result.rtnMgrTelNo != '') {
  473. function convertTel(value){
  474. answer = (value.startsWith('0')) ? value.replace(/[^0-9]/g, "")
  475. .replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3")
  476. .replace("--", "-") : '';
  477. return answer;
  478. }
  479. telNo = convertTel(result.rtnMgrTelNo);
  480. }
  481. pageObj.switchScreen('MODIFY');
  482. $('#ITP_FORM_RTNMNG04010_DETAIL #ITP_FORM_RTNMNG04010_DETAIL_BRAND_ID').val(result.brandId);
  483. $('#ITP_FORM_RTNMNG04010_DETAIL #ITP_FORM_RTNMNG04010_DETAIL_RTN_PODR_UNQ_NO').val(result.rtnPodrUnqNo);
  484. $('#ITP_FORM_RTNMNG04010_DETAIL #ITP_FORM_RTNMNG04010_DETAIL_RTN_ODR_ST_CD').val(result.rtnOdrStCd);
  485. $('#ITP_FORM_RTNMNG04010_DETAIL .fnBrandNm').text(result.brandNm);
  486. $('#ITP_FORM_RTNMNG04010_DETAIL .fnRtnPodrUnqNo').text(result.rtnPodrUnqNo + ' / ' + result.rtnOdrStNm);
  487. $('#ITP_FORM_RTNMNG04010_DETAIL .fnColPlace').text(result.rtnWhsNm + ' - ' + result.rtnLocationNm);
  488. $('#ITP_FORM_RTNMNG04010_DETAIL .fnWhsNm').text(result.whsNm + ' - ' + result.locationNm);
  489. $('#ITP_FORM_RTNMNG04010_DETAIL .fnSpplyNm').text(result.spplyNm);
  490. $('#ITP_FORM_RTNMNG04010_DETAIL .fnRtnOdrRegDt').text(result.rtnOdrRegDt);
  491. $('#ITP_FORM_RTNMNG04010_DETAIL .fnPodrMgrNm').text(result.rtnMgrNm);
  492. $('#ITP_FORM_RTNMNG04010_DETAIL .fnPodrMgrTelNo').text(telNo);
  493. $('#ITP_FORM_RTNMNG04010_DETAIL .fnColDvsnNm').text(result.colDvsnNm);
  494. $('#ITP_FORM_RTNMNG04010_DETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(result.rtnDodrTotalAmt));
  495. if('RO20' == result.rtnOdrStCd) { // 반품발주요청
  496. $('#ITP_BTN_RTNMNG04010_RTNCANCEL').show();
  497. } else {
  498. $('#ITP_BTN_RTNMNG04010_RTNCANCEL').hide();
  499. }
  500. modifyObj.grid.init('MODIFY', result.rtnOdrDtlList)
  501. },
  502. grid: {
  503. init: function(mode, gridData) {
  504. this.mode = mode;
  505. this.gridId = (mode === 'VIEW') ? RTNMNG04010_VIEW_GRID_ID : RTNMNG04010_DETAIL_GRID_ID;
  506. this.gridList = (mode === 'VIEW') ? RTNMNG04010_VIEW_GRID_LIST : RTNMNG04010_DETAIL_GRID_LIST;
  507. this.gridEmpty = (mode === 'VIEW') ? RTNMNG04010_VIEW_GRID_EMPTY : RTNMNG04010_DETAIL_GRID_EMPTY;
  508. this.unload();
  509. this.load(mode, gridData);
  510. },
  511. mode: '',
  512. colModel: gridColModel.view,
  513. load: function(mode, gridData) {
  514. var _this = this;
  515. var option = {
  516. gridId: _this.gridId,
  517. colModel: gridColModel.detail,
  518. data: gridData,
  519. // multiselect: true,
  520. onSelectRow: function(index, status) {
  521. if(index) {
  522. var row = $(RTNMNG04010_DETAIL_GRID_ID).jqGrid('getRowData', index);
  523. if(row.podrDtlStCd == 'POD2') {
  524. $("#jqg_ITP_RTNMNG04010_DETAIL_jqGrid_" + index).prop("checked", false);
  525. }
  526. }
  527. },
  528. onSelectAll: function(rowIds, status) {
  529. for(let i = 0; i < rowIds.length; i++){
  530. let podrDtlStCd = $(RTNMNG04010_DETAIL_GRID_ID).getCell(rowIds[i], 'podrDtlStCd');
  531. if(podrDtlStCd == 'POD2') {
  532. $("#jqg_ITP_RTNMNG04010_DETAIL_jqGrid_" + rowIds[i]).prop("checked", false);
  533. } else {
  534. $("#jqg_ITP_RTNMNG04010_DETAIL_jqGrid_" + rowIds[i]).prop("checked", status);
  535. }
  536. }
  537. },
  538. loadComplete: function(data) {
  539. let datas = data.rows;
  540. for(let i = 0; i < datas.length; i++) {
  541. let podrDtlStCd = datas[i].podrDtlStCd;
  542. if(podrDtlStCd == 'POD2') {
  543. $('#jqg_ITP_RTNMNG04010_DETAIL_jqGrid_' + (i + 1)).attr('disabled', true);
  544. }
  545. }
  546. itp_fn_grid_load_complete(data, RTNMNG04010_DETAIL_GRID_ID, true, 'number', 'RTNMNG04010', modifyObj.itp_RTNMNG04010_search, modifyObj.empty, true, data.gridRecords, true);
  547. }
  548. };
  549. itp_fn_grid_make_local(option);
  550. },
  551. unload: function() {
  552. $.jgrid.gridUnload(this.gridId);
  553. }
  554. },
  555. isValid: function(formId) {
  556. var isValid = false;
  557. $(formId).find('input, select, checkbox, textarea').each(function(k) {
  558. if($(this).data('check-required')) {
  559. var arry = $(this).data('check-required').split(',');
  560. isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined);
  561. if(!isValid) return false;
  562. }
  563. });
  564. return isValid;
  565. },
  566. };