ITP_RTNMNG02010.js 29 KB

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