ITP_RTNMNG04010.js 25 KB

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