ITP_RTNMNG02010.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. /********************************************************
  8. --------------------------------------------------------
  9. - Object 목록 -
  10. --------------------------------------------------------
  11. * const gridColModel = {} : 화면 Grid Object *
  12. * let pageObj = {} : 화면공통 Object *
  13. * let listObj = {} : 목록화면 Object *
  14. * let viewObj = {} : 상세화면 Object *
  15. * let modifyObj = {} : 수정화면 Object *
  16. * let createObj = {} : 신규화면 Object *
  17. * let sfflyObj = {} : 공급업체담당자 Object *
  18. *******************************************************/
  19. //[grid]
  20. /*화면 변수*/
  21. const RTNMNG02010_GRID_ID = '#ITP_RTNMNG02010_jqGrid';
  22. const RTNMNG02010_GRID_LIST = '#ITP_RTNMNG02010_jqGrid_list';
  23. const RTNMNG02010_GRID_PAGER = '#ITP_RTNMNG02010_jqGridPager';
  24. const RTNMNG02010_GRID_EMPTY = '#ITP_RTNMNG02010_jqGridEmpty';
  25. const RTNMNG02010_VIEW_GRID_ID = '#ITP_RTNMNG02010_VIEW_jqGrid';
  26. const RTNMNG02010_VIEW_GRID_LIST = '#ITP_RTNMNG02010_VIEW_jqGrid_list';
  27. const RTNMNG02010_VIEW_GRID_PAGER = '#ITP_RTNMNG02010_VIEW_jqGridPager';
  28. const RTNMNG02010_VIEW_GRID_EMPTY = '#ITP_RTNMNG02010_VIEW_jqGridEmpty';
  29. const RTNMNG02010_DETAIL_GRID_ID = '#ITP_RTNMNG02010_DETAIL_jqGrid';
  30. const RTNMNG02010_DETAIL_GRID_LIST = '#ITP_RTNMNG02010_DETAIL_jqGrid_list';
  31. const RTNMNG02010_DETAIL_GRID_PAGER = '#ITP_RTNMNG02010_DETAIL_jqGridPager';
  32. const RTNMNG02010_DETAIL_GRID_EMPTY = '#ITP_RTNMNG02010_DETAIL_jqGridEmpty';
  33. //let ITP_FORM_RTNMNG02010_DETAIL_IS_DUPLICATE = false;
  34. let ITP_FORM_RTNMNG02010_DETAIL_IS_WRITING = false;
  35. let RTNMNG02010_GRID_LAST_ROW_ID;
  36. let SCREEN_MODE;
  37. /* 공통코드 리스트 */
  38. let ITP_COMMON_CD_RTN_DVSN = fn_make_common_cd_list(CODE_LIST, 'RTN_DVSN', false);
  39. let ITP_COMMON_CD_RTN_RSN_DVSN = fn_make_common_cd_list(CODE_LIST, 'RTN_RSN_DVSN', false);
  40. /*API URL*/
  41. let API_DETAIL_GRID_LIST = '/api/rtnmng/detail-grid-list'; // 목록
  42. let API_DETAIL_INFO = '/api/rtnmng/info-rtnReq'; // 상세
  43. let API_DETAIL_SAVE = '/api/rtnmng/save-rtnReq'; // 저장
  44. /*화면 Grid ColModel*/
  45. const gridColModel = {
  46. list: [
  47. {
  48. index: 'BRAND_ID', name: 'brandId',
  49. label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
  50. width: '10', fixed: false, align: 'center',
  51. sortable: false, hidden: true
  52. },
  53. {
  54. index: 'STORE_ID', name: 'storeId',
  55. label: ITP_MSG_LOCALE.label.storeId, //매장아이디
  56. width: '13', fixed: false, align: 'center',
  57. sortable: false, hidden: true
  58. },
  59. {
  60. index: 'RTN_REQ_UNQ_NO', name: 'rtnReqUnqNo',
  61. label: '반품요청번호',
  62. width: '10', fixed: false, align: 'center',
  63. minwidth: 190,
  64. sortable: false, hidden: false
  65. },
  66. {
  67. index: 'RTN_REQ_ST_CD', name: 'rtnReqStCd',
  68. label: '상태',
  69. width: '0', fixed: false, align: 'left',
  70. sortable: false, hidden: true
  71. },
  72. {
  73. index: 'RTN_REQ_ST_NM', name: 'rtnReqStNm',
  74. label: '상태',
  75. width: '6', fixed: false, align: 'center',
  76. sortable: false, hidden: false
  77. },
  78. {
  79. index: 'rtn_Whs_Nm', name: 'rtnWhsNm',
  80. label: '반품장소',
  81. width: '10', fixed: false, align: 'left',
  82. minwidth: 220,
  83. sortable: false, hidden: false, classes: 'ui-ellipsis'
  84. },
  85. {
  86. index: 'RTN_REQ_DT', name: 'rtnReqDt',
  87. label: '반품요청일',
  88. width: '9', fixed: false, align: 'center',
  89. sortable: false, hidden: false
  90. },
  91. {
  92. index: 'RTN_REQ_AMT', name: 'rtnReqAmt',
  93. label: '반품요청금액',
  94. width: '9', fixed: false, align: 'right',
  95. sortable: false, hidden: false,
  96. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  97. },
  98. {
  99. index: 'RTN_REQ_ITEM_QTY', name: 'rtnReqItemQty',
  100. label: '요청품목수',
  101. width: '9', fixed: false, align: 'right',
  102. sortable: false, hidden: false,
  103. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  104. },
  105. {
  106. index: 'COL_REQ_DT', name: 'colReqDt',
  107. label: '수거요청일자',
  108. width: '9', fixed: false, align: 'center',
  109. sortable: false, hidden: false
  110. },
  111. {
  112. index: 'RTN_REQ_MGR_NM', name: 'rtnReqMgrNm',
  113. label: '반품요청자',
  114. width: '9', fixed: false, align: 'center',
  115. sortable: false, hidden: false
  116. },
  117. {
  118. index: 'RTN_RJCT_DT', name: 'rtnRjctDt',
  119. label: '반려일자',
  120. width: '9', fixed: false, align: 'center',
  121. sortable: false, hidden: false
  122. },
  123. {
  124. index: 'RTN_RJCT_NM', name: 'rtnRjctNm',
  125. label: '반려담당자',
  126. width: '9', fixed: false, align: 'center',
  127. sortable: false, hidden: false
  128. },
  129. {
  130. index: 'BRAND_NM', name: 'brandNm',
  131. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  132. width: '10', fixed: false, align: 'left',
  133. minwidth: 190,
  134. sortable: false, hidden: false, classes: 'ui-ellipsis'
  135. }
  136. ],
  137. detail: [
  138. {
  139. index: 'VIEW_CD', name: 'viewCd',
  140. label: ITP_MSG_LOCALE.label.viewCd,
  141. width: '10', fixed: false, align: 'center',
  142. sortable: false, hidden: true
  143. },
  144. {
  145. index: 'RTN_REQ_UNQ_NO', name: 'rtnReqUnqNo',
  146. label: '반품요청고유번호',
  147. width: '10', fixed: false, align: 'center',
  148. sortable: false, hidden: true
  149. },
  150. {
  151. index: 'RTN_REQ_DTL_NO', name: 'rtnReqDtlNo',
  152. label: '반품요청상세번호',
  153. width: '10', fixed: false, align: 'center',
  154. sortable: false, hidden: true
  155. },
  156. {
  157. index: 'ITEM_ID', name: 'itemId',
  158. label: ITP_MSG_LOCALE.label.itemId,
  159. width: '15', fixed: false, align: 'center',
  160. sortable: false, editable: false, edittype: 'text',
  161. editrules: { required: true }
  162. },
  163. {
  164. index: 'ITEM_NM', name: 'itemNm',
  165. label: ITP_MSG_LOCALE.label.itemNm,
  166. width: '15', fixed: false, align: 'left',
  167. sortable: true, editable: false, edittype: 'text',
  168. editrules: { required: true }, classes: 'ui-ellipsis'
  169. },
  170. {
  171. index: 'UNIT', name: 'unit',
  172. label: ITP_MSG_LOCALE.label.unit,
  173. width: '7', fixed: false, align: 'center',
  174. sortable: false, editable: false, edittype: 'text'
  175. },
  176. {
  177. index: 'UNIT_AMT', name: 'unitAmt',
  178. label: ITP_MSG_LOCALE.label.unitAmt,
  179. width: '11', fixed: false, align: 'right',
  180. sortable: false, editable: false, edittype: 'text', hidden: false,
  181. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  182. },
  183. {
  184. index: 'RTN_QTY', name: 'rtnQty',
  185. label: '반품수량',
  186. width: '11', fixed: false, align: 'right',
  187. sortable: true, editable: true, edittype: 'text',
  188. classes: 'input_color',
  189. editrules: {required: true, number:true},
  190. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  191. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');", maxlength: 10}
  192. },
  193. {
  194. index: 'RTN_AMT', name: 'rtnAmt',
  195. label: '반품예상금액',
  196. width: '11', fixed: false, align: 'right',
  197. sortable: false, editable: false, edittype: 'text', hidden: false,
  198. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  199. },
  200. {
  201. index: 'RTN_REQ_DTL_STNM', name: 'rtnReqDtlStNm',
  202. label: '반품상세상태',
  203. width: '9', fixed: false, align: 'center',
  204. sortable: false, editable: false, edittype: 'text', hidden: false
  205. },
  206. {
  207. index: 'rtnReqDtlStCd', name: 'rtnReqDtlStCd',
  208. label: '반품상세상태코드',
  209. width: '10', fixed: false, align: 'right',
  210. sortable: false, editable: false, edittype: 'text', hidden: true
  211. },
  212. {
  213. index: 'RTN_DVSN', name: 'rtnDvsn',
  214. label: '반품구분',
  215. width: '9', fixed: false, align: 'center',
  216. classes: 'input_color',
  217. sortable: false, editable: true, formatter: 'select', edittype: 'select',
  218. editoptions: {value: ITP_COMMON_CD_RTN_DVSN},
  219. editrules: {required: true}
  220. },
  221. {
  222. index: 'RTN_RSN_DVSN', name: 'rtnRsnDvsn',
  223. label: '사유구분',
  224. classes: 'input_color',
  225. width: '9', fixed: false, align: 'center',
  226. sortable: false, editable: true, formatter: 'select', edittype: 'select',
  227. editoptions: {value: ITP_COMMON_CD_RTN_RSN_DVSN},
  228. editrules: {required: true}
  229. },
  230. {
  231. index: 'RTN_RSN', name: 'rtnRsn',
  232. label: '반품사유',
  233. classes: 'input_color',
  234. width: '15', fixed: false, align: 'left',
  235. sortable: false, editable: true, edittype: 'text', editoptions: {maxlength: 200}, classes: 'ui-ellipsis'
  236. },
  237. {
  238. index: 'BRAND_UNIT_UNQ_NO', name: 'brandUnitUnqNo',
  239. label: ITP_MSG_LOCALE.label.brandUnitUnqNo,
  240. width: '10', fixed: false, align: 'center',
  241. sortable: false, editable: false, edittype: 'text', hidden: true
  242. },
  243. {
  244. index: 'STORE_UNIT_UNQ_NO', name: 'storeUnitUnqNo',
  245. label: ITP_MSG_LOCALE.label.storeUnitUnqNo,
  246. width: '10', fixed: false, align: 'center',
  247. sortable: false, editable: false, edittype: 'text', hidden: true
  248. },
  249. {
  250. index: 'UNIT_GUBUN', name: 'unitGubun',
  251. label: ITP_MSG_LOCALE.label.unitGubun,
  252. width: '10', fixed: false, align: 'center',
  253. sortable: false, editable: false, edittype: 'text', hidden: true
  254. }
  255. ]
  256. };
  257. /*화면공통 Object*/
  258. let pageObj = {
  259. init: function () {
  260. this.ui.init();
  261. this.event.init();
  262. this.action();
  263. },
  264. itp_RTNMNG02010_param: {},
  265. itp_RTNMNG02010_search: false,
  266. ui: {
  267. init: function () {
  268. this.view();
  269. this.grid();
  270. this.ready();
  271. },
  272. view: function() {
  273. // 버튼 권한설정
  274. fn_proc_btn_auth('RTNMNG02010');
  275. // 공통코드 표시
  276. $('select').each(function() {
  277. if($(this).data('select-code')) {
  278. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  279. }
  280. });
  281. // 브랜드/매장
  282. $('#ITP_FORM_RTNMNG02010_SEARCH_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  283. $('#ITP_FORM_RTNMNG02010_SEARCH_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  284. // 조회일자 지정
  285. var now = new Date();
  286. var fromDate = new Date(now);
  287. fromDate.setDate(now.getDate() - 7);
  288. var toDate = new Date(now);
  289. $('#ITP_TAB_RTNMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  290. $('#ITP_FORM_RTNMNG02010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  291. $('#ITP_FORM_RTNMNG02010_SEARCH_TO_DT').datepicker('setDate', toDate);
  292. },
  293. grid: function() {
  294. itp_fn_jqgrid_resize(RTNMNG02010_GRID_ID, RTNMNG02010_GRID_LIST, 'lg');
  295. },
  296. ready: function() {
  297. listObj.init();
  298. }
  299. },
  300. action: function () {
  301. var _this = this;
  302. // 납품장소 조회 버튼 클릭
  303. $('#ITP_FORM_RTNMNG02010_SSEARCH_SWHS_NM').on('click', function() {
  304. _this.popup('S');
  305. });
  306. // 납품장소 텍스트 삭제 버튼 클릭
  307. $('#ITP_FORM_RTNMNG02010_SDELETE_SWHS_NM').on('click', function() {
  308. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_NM').val('');
  309. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_ID').val('');
  310. });
  311. // 수정 화면에서의 납품장소 조회 버튼 클릭
  312. $('#ITP_FORM_RTNMNG02010_SEARCH_WHS_NM').on('click', function() {
  313. _this.popup('U');
  314. });
  315. // 납품장소 텍스트 삭제 버튼 클릭
  316. $('#ITP_FORM_RTNMNG02010_DELETE_WHS_NM').on('click', function() {
  317. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_NM').val('');
  318. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_ID').val('');
  319. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION_NM').val('');
  320. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION').val('');
  321. });
  322. },
  323. popup: function (arg) {
  324. var popFn ;
  325. // 팝업
  326. if (arg == "S") {
  327. popFn = this.callback.create;
  328. } else {
  329. popFn = this.callback.modify;
  330. }
  331. var whsDvsn = "";
  332. if (fn_make_user_info.get('storeId') == '' ) {
  333. whsDvsn = "W01";
  334. } else {
  335. whsDvsn = "W02";
  336. }
  337. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn: whsDvsn};
  338. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  339. },
  340. callback: {
  341. create: function(rowDataPop) {
  342. if(rowDataPop) {
  343. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  344. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  345. }
  346. },
  347. modify: function(rowDataPop) {
  348. if(rowDataPop) {
  349. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  350. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  351. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION_NM').val(rowDataPop.locationNm);
  352. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION').val(rowDataPop.location);
  353. }
  354. }
  355. },
  356. event: {
  357. init: function () {
  358. this.button();
  359. },
  360. button: function () {
  361. // 버튼 클릭 이벤트
  362. $('button').each(function() {
  363. var id = $(this).attr('id');
  364. $(this).on('click', function() {
  365. switch (id) {
  366. case 'ITP_BTN_RTNMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  367. //case 'ITP_BTN_RTNMNG02010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  368. case 'ITP_BTN_RTNMNG02010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  369. case 'ITP_BTN_RTNMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  370. case 'ITP_BTN_RTNMNG02010_REQ' : modifyObj.button.save("RR20"); break; // 구매요청
  371. case 'ITP_BTN_RTNMNG02010_SAVE' : modifyObj.button.save("RR00"); break; // 임시저장
  372. case 'ITP_BTN_RTNMNG02010_DETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 품목추가
  373. case 'ITP_BTN_RTNMNG02010_DETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 품목삭제
  374. case 'ITP_BTN_RTNMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  375. }
  376. });
  377. });
  378. $('body').on('click', function(e) {
  379. var gridId = RTNMNG02010_DETAIL_GRID_ID.replace('#', '');
  380. var rids = $(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  381. var last_row_id = rids[rids.length - 1];
  382. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'RTNMNG02010_DETAIL');
  383. pageObj.grid.recal();
  384. });
  385. }
  386. },
  387. switchScreen: function(mode) {
  388. $('.itp_det_head').find('button[id^="ITP_BTN_RTNMNG02010_"]').each(function(i) {
  389. $(this).hide();
  390. });
  391. $('#ITP_TAB_RTNMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  392. $(this).hide();
  393. });
  394. if(mode == 'LIST') { // 목록
  395. itp_fn_fire_window_resize();
  396. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_SRH']);
  397. $('#ITP_AJAX_RTNMNG02010_LIST_CONTAINER').show();
  398. $('#ITP_FORM_RTNMNG02010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  399. $('#ITP_FORM_RTNMNG02010_DETAIL_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  400. $('#ITP_BTN_RTNMNG02010_EXCEL').show();
  401. SCREEN_MODE = 'LIST' ;
  402. } else if(mode == 'ADD') { // 등록
  403. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_CANCELLIST', '#ITP_BTN_RTNMNG02010_SAVE']);
  404. $('#ITP_AJAX_RTNMNG02010_DETAIL_CONTAINER').show();
  405. $('#ITP_FORM_RTNMNG02010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  406. $(this).attr('id') === 'ITP_FORM_RTNMNG02010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  407. if(elem.type === 'select') {
  408. $(this).val('').prop('selected', true);
  409. }
  410. });
  411. SCREEN_MODE = 'DETAIL' ;
  412. } else if(mode == 'MODIFY') { // 수정
  413. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_CANCELLIST', '#ITP_BTN_RTNMNG02010_SAVE', '#ITP_BTN_RTNMNG02010_REQ']);
  414. $('#ITP_AJAX_RTNMNG02010_DETAIL_CONTAINER').show();
  415. $('#ITP_FORM_RTNMNG02010_DETAIL .itp_form_info').show();
  416. $('#ITP_FORM_RTNMNG02010_DETAIL .itp_form_change').hide();
  417. SCREEN_MODE = 'DETAIL' ;
  418. } else if(mode == 'VIEW') { // 보기
  419. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_MODIFY', '#ITP_BTN_RTNMNG02010_CANCELLIST']);
  420. $('#ITP_AJAX_RTNMNG02010_VIEW_CONTAINER').show();
  421. SCREEN_MODE = 'VIEW' ;
  422. }
  423. },
  424. grid: {
  425. init: function(mode, gridRows) {
  426. this.gridId = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_ID : RTNMNG02010_DETAIL_GRID_ID;
  427. this.gridList = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST;
  428. this.gridEmpty = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY;
  429. this.gridRows = gridRows;
  430. this.unload();
  431. this.load(mode, gridRows);
  432. },
  433. gridId: '',
  434. gridList: '',
  435. gridEmpty: '',
  436. gridRows: '',
  437. button: {
  438. addRow: function() {
  439. // 팝업
  440. var popFn = function(rowDataPop) {
  441. // 기존등록 데이터
  442. var exists = '';
  443. const rowData = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  444. $.each(rowData, function(key, value) {
  445. if (value.viewCd != "D") {
  446. exists = exists + value.brandUnitUnqNo + ';';
  447. }
  448. });
  449. $.each(rowDataPop, function(key, value) {
  450. if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
  451. value['viewCd'] = "C";
  452. $(RTNMNG02010_DETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
  453. }
  454. });
  455. $(RTNMNG02010_DETAIL_GRID_EMPTY).hide();
  456. };
  457. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  458. fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S'); // ==>dwkim 추후 작업 진행 파라메타 설명필요
  459. },
  460. delRow: function() {
  461. itp_fn_grid_del_row(RTNMNG02010_DETAIL_GRID_ID);
  462. pageObj.grid.recal();
  463. }
  464. },
  465. load: function(mode, gridRows) {
  466. var _this = this;
  467. var option = {
  468. gridId: _this.gridId,
  469. colModel: gridColModel.detail,
  470. data: gridRows,
  471. multiselect: true,
  472. loadComplete: function(data) {
  473. $(_this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  474. data.records === 0 ? _this.clearData() : $(_this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).hide();
  475. },
  476. onCellSelect: function(rowid, cellIdx, cellValue) {
  477. if(mode !== 'VIEW') {
  478. RTNMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, RTNMNG02010_GRID_LAST_ROW_ID, RTNMNG02010_DETAIL_GRID_ID, ['rtnReqUnqNo']);
  479. }
  480. }
  481. };
  482. itp_fn_grid_make_local(option);
  483. },
  484. recal: function() {
  485. if (SCREEN_MODE === 'DETAIL') {
  486. var ids = $(RTNMNG02010_DETAIL_GRID_ID).getDataIDs();
  487. $.each(ids, function(idx, rowId) {
  488. var viewCd = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'viewCd');
  489. var unitAmt = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  490. var rtnQty = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'rtnQty');
  491. if(viewCd != 'D' && unitAmt != null && unitAmt != '' && rtnQty != null && rtnQty != '') {
  492. jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{rtnAmt: parseInt(unitAmt)*parseInt(rtnQty)});
  493. }
  494. });
  495. }
  496. },
  497. clearData : function() {
  498. $(this.gridId).jqGrid('clearGridData', true);
  499. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  500. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  501. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).show();
  502. },
  503. unload : function() {
  504. $.jgrid.gridUnload(this.gridId);
  505. }
  506. }
  507. };
  508. /*목록화면 Object*/
  509. let listObj = {
  510. init: function () {
  511. this.grid.init();
  512. },
  513. itp_RTNMNG02010_search: false,
  514. button: {
  515. search: function() {
  516. listObj.itp_RTNMNG02010_search = true;
  517. let param = $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject();
  518. param.gridSize = $.jgrid.defaults.rowNum;
  519. param.gridPage = $.jgrid.defaults.page;
  520. $(RTNMNG02010_GRID_ID).data('grid-param',param);
  521. $(RTNMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  522. },
  523. create: function() {
  524. if(!fn_make_user_info.isEmpty()) {
  525. //createObj.init();
  526. }
  527. }
  528. },
  529. empty: {
  530. init: function() {
  531. },
  532. itp_RTNMNG02010_param: {},
  533. push: function() {
  534. },
  535. back: function() {
  536. }
  537. },
  538. grid: {
  539. init: function () {
  540. // 데이터 없을때
  541. itp_fn_jqgrid_resize(RTNMNG02010_GRID_ID, RTNMNG02010_GRID_LIST, 'lg');
  542. itp_fn_fire_window_resize();
  543. //this.reload();
  544. this.search();
  545. },
  546. colModel: gridColModel.list,
  547. search: function() {
  548. pageObj.switchScreen('LIST');
  549. this.unload();
  550. this.load();
  551. },
  552. load: function() {
  553. let param = $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject();
  554. param.gridSize = $.jgrid.defaults.rowNum;
  555. param.sbrandId = fn_make_user_info.get('brandId');
  556. param.sstoreId = fn_make_user_info.get('storeId');
  557. var option = {
  558. gridId: RTNMNG02010_GRID_ID,
  559. colModel: gridColModel.list,
  560. //autowidth: true,
  561. //shrinkToFit:false,
  562. param: param,
  563. url: DOMAIN + API_DETAIL_GRID_LIST,
  564. pager: RTNMNG02010_GRID_PAGER,
  565. onCellSelect: function(rowId, cellIdx, cellValue) {
  566. var cm = $(this).jqGrid('getGridParam', 'colModel');
  567. var colNm = cm[cellIdx].name;
  568. if (colNm == 'rtnReqUnqNo') {
  569. const selectVal = $(this).jqGrid('getCell', rowId, 'rtnReqUnqNo');
  570. const key = {brandId:fn_make_user_info.get('brandId'), rtnReqUnqNo: selectVal, viewCd: 'R'};
  571. var param = $.param(key);
  572. viewObj.init(param);
  573. }
  574. },
  575. loadComplete: function(data) {
  576. itp_fn_grid_load_complete(data, RTNMNG02010_GRID_ID, true, 'number', 'RTNMNG02010', listObj.itp_RTNMNG02010_search, listObj.empty, true, data.gridRecords, true);
  577. var ids = $(RTNMNG02010_GRID_ID).getDataIDs();
  578. let rtnReqAmtSum = 0;
  579. for (var i = 0; i < ids.length; i++) {
  580. var rowData = $(RTNMNG02010_GRID_ID).jqGrid('getRowData', ids[i]);
  581. rtnReqAmtSum = rtnReqAmtSum + Number(rowData.rtnReqAmt);
  582. }
  583. $('#ITP_RTNMNG02010_REQ_TOTAL_AMT_SUM').val(itp_fn_number_comma(rtnReqAmtSum));
  584. $.each(ids, function(idx, rowId) {
  585. $(RTNMNG02010_GRID_ID).jqGrid('setCell', rowId, 'rtnReqUnqNo', '', ITP_GRID_COL_STYLE.link);
  586. });
  587. },
  588. onPaging: function(action) {
  589. itp_fn_grid_paging(RTNMNG02010_GRID_ID, action, param);
  590. }
  591. };
  592. itp_fn_grid_make_remote(option);
  593. },
  594. clearData : function() {
  595. $(RTNMNG02010_GRID_ID).jqGrid('clearGridData', true);
  596. $(RTNMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  597. $(RTNMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  598. $(RTNMNG02010_GRID_EMPTY).show();
  599. },
  600. unload : function() {
  601. $.jgrid.gridUnload(RTNMNG02010_GRID_ID);
  602. }
  603. },
  604. excelDown: function() {
  605. var param = {
  606. 'url': API_DETAIL_GRID_LIST,
  607. 'param': $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject(),
  608. 'gridColumns': $(RTNMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  609. 'fileName': '반품요청현황.xlsx',
  610. 'sheetName': '반품요청리스트'
  611. };
  612. itp_fn_remote_to_excel(param);
  613. }
  614. };
  615. /*상세화면 Object*/
  616. let viewObj = {
  617. init: function (param) {
  618. this.load(param);
  619. },
  620. load: function(param) {
  621. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  622. },
  623. callback: function (result) {
  624. pageObj.switchScreen('VIEW');
  625. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_BRAND_ID').val(result.brandId);
  626. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_UNQ_NO').val(result.rtnReqUnqNo);
  627. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_ST_CD').val(result.rtnReqStCd);
  628. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_MGR_ID').val(result.rtnReqMgrId);
  629. $('#ITP_FORM_RTNMNG02010_VIEW .fnBrandNm').text(result.brandNm);
  630. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnReqUnqNo').text(result.rtnReqUnqNo + ' / ' + result.rtnReqStNm);
  631. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnWhsNm').text(result.rtnWhsNm);
  632. $('#ITP_FORM_RTNMNG02010_VIEW .fnColReqDt').text(result.colReqDt);
  633. $('#ITP_FORM_RTNMNG02010_VIEW .fnNote').text(result.note);
  634. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctDt').text(result.rtnRjctDt);
  635. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctNm').text(result.rtnRjctNm);
  636. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctRsn').text(result.rtnRjctRsn);
  637. // $('#ITP_FORM_RTNMNG02010_VIEW .fnPchReqTotalAmt').text(itp_fn_number_comma(result.pchReqTotalAmt));
  638. // 품목 리스트 조회
  639. pageObj.grid.init('VIEW', result.rtnReqDtlList);
  640. }
  641. };
  642. /*수정화면 Object*/
  643. let modifyObj = {
  644. init: function (param) {
  645. pageObj.grid.init('DETAIL', []);
  646. //this.load(param);
  647. },
  648. button: {
  649. modify: function (param) {
  650. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG02010_DETAIL');
  651. const selectVal = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_UNQ_NO').val();
  652. const writeVal = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_MGR_ID').val();
  653. const stCd = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_ST_CD').val();
  654. var userId = fn_make_user_info.get('userId');
  655. if (writeVal != userId) {
  656. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.diffWrite);
  657. return;
  658. }
  659. if (stCd != "RR00") {
  660. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.notWrite);
  661. return;
  662. }
  663. const key = {brandId:fn_make_user_info.get('brandId'), rtnReqUnqNo: selectVal, viewCd: 'R'};
  664. var param = $.param(key);
  665. modifyObj.load(param);
  666. },
  667. save: function(arg) {
  668. $('body').trigger('click');
  669. const formId = '#ITP_FORM_RTNMNG02010_DETAIL';
  670. itp_fn_form_clear_validate(null, formId);
  671. itp_fn_grid_save_rows(RTNMNG02010_DETAIL_GRID_ID);
  672. $('#ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_ST_CD').val(arg);
  673. if (itp_fn_form_event.isValid(formId)) {
  674. const rowData1 = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  675. var dataCnt = 0;
  676. $.each(rowData1, function(key, value) {
  677. if (value.viewCd != 'D') {
  678. dataCnt = dataCnt + 1;
  679. }
  680. });
  681. if (dataCnt == 0) {
  682. itp_fn_modal_alert( "요청할 품목내역이 없습니다.");
  683. return ;
  684. }
  685. var now = new Date();
  686. var today = now.getFullYear() +
  687. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  688. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  689. var colReqDt = $('#ITP_FORM_RTNMNG02010_DETAIL_COL_REQ_DT').val();
  690. if (today > colReqDt) {
  691. alert("수거요청일은 오늘 이후이어야 합니다.");
  692. return;
  693. }
  694. var rtnQtyCheck = true;
  695. var rtnDvsnCheck = true;
  696. var rtnRsnDvsnCheck = true;
  697. var rtnRsnCheck = true;
  698. $.each(rowData1, function(key, value) {
  699. if(value.rtnQty == '') {
  700. rtnQtyCheck = false;
  701. }
  702. if(value.rtnDvsn == '') {
  703. rtnDvsnCheck = false;
  704. }
  705. if(value.rtnRsnDvsn == '') {
  706. rtnRsnDvsnCheck = false;
  707. }
  708. if(value.rtnRsn == '') {
  709. rtnRsnCheck = false;
  710. }
  711. });
  712. if(rtnQtyCheck == false) {
  713. itp_fn_modal_alert( "반품수량을 입력하세요.");
  714. return;
  715. }
  716. if(rtnDvsnCheck == false) {
  717. itp_fn_modal_alert( "반품구분을 입력하세요.");
  718. return;
  719. }
  720. if(rtnRsnDvsnCheck == false) {
  721. itp_fn_modal_alert( "사유구분을 입력하세요.");
  722. return;
  723. }
  724. if(rtnRsnCheck == false) {
  725. itp_fn_modal_alert( "반품사유를 입력하세요.");
  726. return;
  727. }
  728. var saveReq = {
  729. callBack: function(args) {
  730. $(formId).val(arg);
  731. let gridInsertData = [];
  732. let gridUpdateData = [];
  733. let gridDeleteData = [];
  734. const rowData = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  735. $.each(rowData, function(key, value) {
  736. if (value.viewCd != 'R') {
  737. if (value.viewCd == 'C') {
  738. gridInsertData.push(value);
  739. } else if (value.viewCd == 'U') {
  740. gridUpdateData.push(value);
  741. } else if (value.viewCd == 'D') {
  742. gridDeleteData.push(value);
  743. }
  744. }
  745. });
  746. let param = $(formId).serializeObject();
  747. param.gridInsertData = gridInsertData;
  748. param.gridUpdateData = gridUpdateData;
  749. param.gridDeleteData = gridDeleteData;
  750. var searhFn = function() {
  751. ITP_FORM_RTNMNG02010_DETAIL_IS_WRITING = false;
  752. modifyObj.button.clear();
  753. //listObj.grid.search();
  754. };
  755. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  756. }
  757. };
  758. if (arg == 'RR20') {
  759. itp_fn_modal_confirm('반품 요청하시겠습니까?', saveReq, null);
  760. } else {
  761. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.tmpSave, saveReq, null);
  762. }
  763. }
  764. },
  765. clear: function () {
  766. document.getElementById('ITP_FORM_RTNMNG02010_DETAIL').reset();
  767. listObj.grid.search();
  768. },
  769. cancel: function () {
  770. listObj.grid.search();
  771. }
  772. },
  773. load: function(param) {
  774. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  775. },
  776. callback: function (result) {
  777. pageObj.switchScreen('MODIFY');
  778. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_VIEW_CD').val('U');
  779. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_BRAND_ID').val(result.brandId);
  780. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_STORE_ID').val(result.storeId);
  781. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_UNQ_NO').val(result.rtnReqUnqNo);
  782. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_ST_CD').val(result.rtnReqStCd);
  783. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_MGR_ID').val(result.rtnReqMgrId);
  784. $('#ITP_FORM_RTNMNG02010_DETAIL .fnBrandNm').text(result.brandNm);
  785. $('#ITP_FORM_RTNMNG02010_DETAIL .fnRtnReqUnqNo').text(result.rtnReqUnqNo + ' / ' + result.rtnReqStNm);
  786. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId);
  787. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_WHS_NM').val(result.rtnWhsNm);
  788. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_LOCATION').val(result.rtnLocation);
  789. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_LOCATION_NM').val(result.rtnLocationNm);
  790. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_COL_REQ_DT').val(result.colReqDt);
  791. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_NOTE').val(result.note);
  792. // 품목 리스트 조회
  793. pageObj.grid.init('DETAIL', result.rtnReqDtlList);
  794. },
  795. };