ITP_RTNMNG02010.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  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_FORM_RTNMNG02010_SEARCH_FROM_DT').val(itp_fn_get_before_month() );
  290. $('#ITP_FORM_RTNMNG02010_SEARCH_TO_DT').val(itp_fn_get_today_ko() );
  291. $('#ITP_TAB_RTNMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  292. $('#ITP_FORM_RTNMNG02010_SEARCH_FROM_DT').datepicker();
  293. $('#ITP_FORM_RTNMNG02010_SEARCH_TO_DT').datepicker();
  294. },
  295. grid: function() {
  296. },
  297. ready: function() {
  298. listObj.init();
  299. }
  300. },
  301. action: function () {
  302. var _this = this;
  303. // 납품장소 조회 버튼 클릭
  304. $('#ITP_FORM_RTNMNG02010_SSEARCH_SWHS_NM').on('click', function() {
  305. _this.popup('S');
  306. });
  307. // 납품장소 텍스트 삭제 버튼 클릭
  308. $('#ITP_FORM_RTNMNG02010_SDELETE_SWHS_NM').on('click', function() {
  309. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_NM').val('');
  310. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_ID').val('');
  311. });
  312. // 수정 화면에서의 납품장소 조회 버튼 클릭
  313. $('#ITP_FORM_RTNMNG02010_SEARCH_WHS_NM').on('click', function() {
  314. _this.popup('U');
  315. });
  316. // 납품장소 텍스트 삭제 버튼 클릭
  317. $('#ITP_FORM_RTNMNG02010_DELETE_WHS_NM').on('click', function() {
  318. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_NM').val('');
  319. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_ID').val('');
  320. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION_NM').val('');
  321. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION').val('');
  322. });
  323. },
  324. popup: function (arg) {
  325. var popFn ;
  326. // 팝업
  327. if (arg == "S") {
  328. popFn = this.callback.create;
  329. } else {
  330. popFn = this.callback.modify;
  331. }
  332. var whsDvsn = "";
  333. if (fn_make_user_info.get('storeId') == '' ) {
  334. whsDvsn = "W01";
  335. } else {
  336. whsDvsn = "W02";
  337. }
  338. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn: whsDvsn};
  339. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  340. },
  341. callback: {
  342. create: function(rowDataPop) {
  343. if(rowDataPop) {
  344. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  345. $('#ITP_FORM_RTNMNG02010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  346. }
  347. },
  348. modify: function(rowDataPop) {
  349. if(rowDataPop) {
  350. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  351. $('#ITP_FORM_RTNMNG02010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  352. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION_NM').val(rowDataPop.locationNm);
  353. $('#ITP_FORM_RTNMNG02010_DETAIL_LOCATION').val(rowDataPop.location);
  354. }
  355. }
  356. },
  357. event: {
  358. init: function () {
  359. this.button();
  360. },
  361. button: function () {
  362. // 버튼 클릭 이벤트
  363. $('button').each(function() {
  364. var id = $(this).attr('id');
  365. $(this).on('click', function() {
  366. switch (id) {
  367. case 'ITP_BTN_RTNMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  368. //case 'ITP_BTN_RTNMNG02010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  369. case 'ITP_BTN_RTNMNG02010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  370. case 'ITP_BTN_RTNMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  371. case 'ITP_BTN_RTNMNG02010_REQ' : modifyObj.button.save("RR20"); break; // 구매요청
  372. case 'ITP_BTN_RTNMNG02010_SAVE' : modifyObj.button.save("RR00"); break; // 임시저장
  373. case 'ITP_BTN_RTNMNG02010_DETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 품목추가
  374. case 'ITP_BTN_RTNMNG02010_DETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 품목삭제
  375. case 'ITP_BTN_RTNMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  376. }
  377. });
  378. });
  379. $('body').on('click', function(e) {
  380. var gridId = RTNMNG02010_DETAIL_GRID_ID.replace('#', '');
  381. var rids = $(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  382. var last_row_id = rids[rids.length - 1];
  383. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'RTNMNG02010_DETAIL');
  384. pageObj.grid.recal();
  385. });
  386. }
  387. },
  388. switchScreen: function(mode) {
  389. $('.itp_det_head').find('button[id^="ITP_BTN_RTNMNG02010_"]').each(function(i) {
  390. $(this).hide();
  391. });
  392. $('#ITP_TAB_RTNMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  393. $(this).hide();
  394. });
  395. if(mode == 'LIST') { // 목록
  396. itp_fn_fire_window_resize();
  397. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_SRH']);
  398. $('#ITP_AJAX_RTNMNG02010_LIST_CONTAINER').show();
  399. $('#ITP_FORM_RTNMNG02010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  400. $('#ITP_FORM_RTNMNG02010_DETAIL_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  401. $('#ITP_BTN_RTNMNG02010_EXCEL').show();
  402. SCREEN_MODE = 'LIST' ;
  403. } else if(mode == 'ADD') { // 등록
  404. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_CANCELLIST', '#ITP_BTN_RTNMNG02010_SAVE']);
  405. $('#ITP_AJAX_RTNMNG02010_DETAIL_CONTAINER').show();
  406. $('#ITP_FORM_RTNMNG02010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  407. $(this).attr('id') === 'ITP_FORM_RTNMNG02010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  408. if(elem.type === 'select') {
  409. $(this).val('').prop('selected', true);
  410. }
  411. });
  412. SCREEN_MODE = 'DETAIL' ;
  413. } else if(mode == 'MODIFY') { // 수정
  414. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_CANCELLIST', '#ITP_BTN_RTNMNG02010_SAVE', '#ITP_BTN_RTNMNG02010_REQ']);
  415. $('#ITP_AJAX_RTNMNG02010_DETAIL_CONTAINER').show();
  416. $('#ITP_FORM_RTNMNG02010_DETAIL .itp_form_info').show();
  417. $('#ITP_FORM_RTNMNG02010_DETAIL .itp_form_change').hide();
  418. SCREEN_MODE = 'DETAIL' ;
  419. } else if(mode == 'VIEW') { // 보기
  420. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG02010_MODIFY', '#ITP_BTN_RTNMNG02010_CANCELLIST']);
  421. $('#ITP_AJAX_RTNMNG02010_VIEW_CONTAINER').show();
  422. SCREEN_MODE = 'VIEW' ;
  423. }
  424. },
  425. grid: {
  426. init: function(mode, gridRows) {
  427. this.gridId = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_ID : RTNMNG02010_DETAIL_GRID_ID;
  428. this.gridList = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST;
  429. this.gridEmpty = (mode === 'VIEW') ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY;
  430. itp_fn_jqgrid_resize(this.gridId, this.gridList, 'lg');
  431. this.gridRows = gridRows;
  432. this.unload();
  433. this.load(mode, gridRows);
  434. },
  435. gridId: '',
  436. gridList: '',
  437. gridEmpty: '',
  438. gridRows: '',
  439. button: {
  440. addRow: function() {
  441. // 팝업
  442. var popFn = function(rowDataPop) {
  443. // 기존등록 데이터
  444. var exists = '';
  445. const rowData = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  446. $.each(rowData, function(key, value) {
  447. if (value.viewCd != "D") {
  448. exists = exists + value.brandUnitUnqNo + ';';
  449. }
  450. });
  451. $.each(rowDataPop, function(key, value) {
  452. if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
  453. value['viewCd'] = "C";
  454. $(RTNMNG02010_DETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
  455. }
  456. });
  457. $(RTNMNG02010_DETAIL_GRID_EMPTY).hide();
  458. };
  459. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  460. fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S'); // ==>dwkim 추후 작업 진행 파라메타 설명필요
  461. },
  462. delRow: function() {
  463. itp_fn_grid_del_row(RTNMNG02010_DETAIL_GRID_ID);
  464. pageObj.grid.recal();
  465. }
  466. },
  467. load: function(mode, gridRows) {
  468. var _this = this;
  469. var option = {
  470. gridId: _this.gridId,
  471. colModel: gridColModel.detail,
  472. data: gridRows,
  473. multiselect: true,
  474. loadComplete: function(data) {
  475. $(_this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  476. data.records === 0 ? _this.clearData() : $(_this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).hide();
  477. },
  478. onCellSelect: function(rowid, cellIdx, cellValue) {
  479. if(mode !== 'VIEW') {
  480. RTNMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, RTNMNG02010_GRID_LAST_ROW_ID, RTNMNG02010_DETAIL_GRID_ID, ['rtnReqUnqNo']);
  481. }
  482. }
  483. };
  484. itp_fn_grid_make_local(option);
  485. },
  486. recal: function() {
  487. if (SCREEN_MODE === 'DETAIL') {
  488. var ids = $(RTNMNG02010_DETAIL_GRID_ID).getDataIDs();
  489. $.each(ids, function(idx, rowId) {
  490. var viewCd = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'viewCd');
  491. var unitAmt = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  492. var rtnQty = jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'rtnQty');
  493. if(viewCd != 'D' && unitAmt != null && unitAmt != '' && rtnQty != null && rtnQty != '') {
  494. jQuery(RTNMNG02010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{rtnAmt: parseInt(unitAmt)*parseInt(rtnQty)});
  495. }
  496. });
  497. }
  498. },
  499. clearData : function() {
  500. $(this.gridId).jqGrid('clearGridData', true);
  501. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_LIST : RTNMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  502. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  503. $(this.mode === 'VIEW' ? RTNMNG02010_VIEW_GRID_EMPTY : RTNMNG02010_DETAIL_GRID_EMPTY).show();
  504. },
  505. unload : function() {
  506. $.jgrid.gridUnload(this.gridId);
  507. }
  508. }
  509. };
  510. /*목록화면 Object*/
  511. let listObj = {
  512. init: function () {
  513. this.grid.init();
  514. },
  515. itp_RTNMNG02010_search: false,
  516. button: {
  517. search: function() {
  518. listObj.itp_RTNMNG02010_search = true;
  519. let param = $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject();
  520. param.gridSize = $.jgrid.defaults.rowNum;
  521. param.gridPage = $.jgrid.defaults.page;
  522. $(RTNMNG02010_GRID_ID).data('grid-param',param);
  523. $(RTNMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  524. },
  525. create: function() {
  526. if(!fn_make_user_info.isEmpty()) {
  527. //createObj.init();
  528. }
  529. }
  530. },
  531. empty: {
  532. init: function() {
  533. },
  534. itp_RTNMNG02010_param: {},
  535. push: function() {
  536. },
  537. back: function() {
  538. }
  539. },
  540. grid: {
  541. init: function () {
  542. // 데이터 없을때
  543. itp_fn_jqgrid_resize(RTNMNG02010_GRID_ID, RTNMNG02010_GRID_LIST, 'lg');
  544. itp_fn_fire_window_resize();
  545. //this.reload();
  546. this.search();
  547. },
  548. colModel: gridColModel.list,
  549. search: function() {
  550. pageObj.switchScreen('LIST');
  551. this.unload();
  552. this.load();
  553. },
  554. load: function() {
  555. let param = $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject();
  556. param.gridSize = $.jgrid.defaults.rowNum;
  557. param.sbrandId = fn_make_user_info.get('brandId');
  558. param.sstoreId = fn_make_user_info.get('storeId');
  559. var option = {
  560. gridId: RTNMNG02010_GRID_ID,
  561. colModel: gridColModel.list,
  562. //autowidth: true,
  563. //shrinkToFit:false,
  564. param: param,
  565. url: DOMAIN + API_DETAIL_GRID_LIST,
  566. pager: RTNMNG02010_GRID_PAGER,
  567. onCellSelect: function(rowId, cellIdx, cellValue) {
  568. var cm = $(this).jqGrid('getGridParam', 'colModel');
  569. var colNm = cm[cellIdx].name;
  570. if (colNm == 'rtnReqUnqNo') {
  571. const selectVal = $(this).jqGrid('getCell', rowId, 'rtnReqUnqNo');
  572. const key = {brandId:fn_make_user_info.get('brandId'), rtnReqUnqNo: selectVal, viewCd: 'R'};
  573. var param = $.param(key);
  574. viewObj.init(param);
  575. }
  576. },
  577. loadComplete: function(data) {
  578. itp_fn_grid_load_complete(data, RTNMNG02010_GRID_ID, true, 'number', 'RTNMNG02010', listObj.itp_RTNMNG02010_search, listObj.empty, true, data.gridRecords, true);
  579. var ids = $(RTNMNG02010_GRID_ID).getDataIDs();
  580. let rtnReqAmtSum = 0;
  581. for (var i = 0; i < ids.length; i++) {
  582. var rowData = $(RTNMNG02010_GRID_ID).jqGrid('getRowData', ids[i]);
  583. rtnReqAmtSum = rtnReqAmtSum + Number(rowData.rtnReqAmt);
  584. }
  585. $('#ITP_RTNMNG02010_REQ_TOTAL_AMT_SUM').val(itp_fn_number_comma(rtnReqAmtSum));
  586. $.each(ids, function(idx, rowId) {
  587. $(RTNMNG02010_GRID_ID).jqGrid('setCell', rowId, 'rtnReqUnqNo', '', ITP_GRID_COL_STYLE.link);
  588. });
  589. const self=this;
  590. if(self.sortUse) return;
  591. self.sortUse=true;
  592. $(RTNMNG02010_GRID_LIST).find('.ui-jqgrid-labels .ui-th-div').css('cursor','default');
  593. $(RTNMNG02010_GRID_LIST).find('.ui-jqgrid-labels .ui-th-div').eq(3).css('cursor','pointer');
  594. $(RTNMNG02010_GRID_LIST).find('.ui-jqgrid-labels>th').on('click', function() {
  595. const idx=$(this).index();
  596. console.log("xxxx grid header click xxxxxxx index=="+idx, param );
  597. if(idx==3 || idx==2 ) {
  598. var field='',sort=self['sort'+idx];
  599. if(sort ) {
  600. sort=sort=='asc'?'desc':'asc';
  601. } else {
  602. // 등록일 내림차순, 제목 오름차순
  603. sort=idx==3? 'asc':idx==2? 'desc': 'asc';
  604. }
  605. const icon=sort=='asc'? '.glyphicon-triangle-bottom': '.glyphicon-triangle-top';
  606. self['sort'+idx]=sort;
  607. if(idx==3) {
  608. field='rtnReqUnqNo';
  609. } else if(idx==2) {
  610. field='brandNm';
  611. }
  612. param.page=1;
  613. param.sidx=field;
  614. param.sord=sort;
  615. $(RTNMNG02010_GRID_ID).jqGrid('setGridParam',{
  616. postData:JSON.stringify(param)
  617. }).trigger('reloadGrid');
  618. $(this).find('.s-ico').show();
  619. $(this).find('.ui-grid-ico-sort').hide();
  620. $(this).find(icon).show();
  621. }
  622. });
  623. },
  624. onPaging: function(action) {
  625. itp_fn_grid_paging(RTNMNG02010_GRID_ID, action, param);
  626. }
  627. };
  628. itp_fn_grid_make_remote(option);
  629. },
  630. clearData : function() {
  631. $(RTNMNG02010_GRID_ID).jqGrid('clearGridData', true);
  632. $(RTNMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  633. $(RTNMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  634. $(RTNMNG02010_GRID_EMPTY).show();
  635. },
  636. unload : function() {
  637. $.jgrid.gridUnload(RTNMNG02010_GRID_ID);
  638. }
  639. },
  640. excelDown: function() {
  641. var param = {
  642. 'url': API_DETAIL_GRID_LIST,
  643. 'param': $('#ITP_FORM_RTNMNG02010_SEARCH').serializeObject(),
  644. 'gridColumns': $(RTNMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  645. 'fileName': '반품요청현황.xlsx',
  646. 'sheetName': '반품요청리스트'
  647. };
  648. itp_fn_remote_to_excel(param);
  649. }
  650. };
  651. /*상세화면 Object*/
  652. let viewObj = {
  653. init: function (param) {
  654. this.load(param);
  655. },
  656. load: function(param) {
  657. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  658. },
  659. callback: function (result) {
  660. pageObj.switchScreen('VIEW');
  661. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_BRAND_ID').val(result.brandId);
  662. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_UNQ_NO').val(result.rtnReqUnqNo);
  663. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_ST_CD').val(result.rtnReqStCd);
  664. $('#ITP_FORM_RTNMNG02010_VIEW #ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_MGR_ID').val(result.rtnReqMgrId);
  665. $('#ITP_FORM_RTNMNG02010_VIEW .fnBrandNm').text(result.brandNm);
  666. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnReqUnqNo').text(result.rtnReqUnqNo + ' / ' + result.rtnReqStNm);
  667. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnWhsNm').text(result.rtnWhsNm);
  668. $('#ITP_FORM_RTNMNG02010_VIEW .fnColReqDt').text(result.colReqDt);
  669. $('#ITP_FORM_RTNMNG02010_VIEW .fnNote').text(result.note);
  670. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctDt').text(result.rtnRjctDt);
  671. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctNm').text(result.rtnRjctNm);
  672. $('#ITP_FORM_RTNMNG02010_VIEW .fnRtnRjctRsn').text(result.rtnRjctRsn);
  673. // $('#ITP_FORM_RTNMNG02010_VIEW .fnPchReqTotalAmt').text(itp_fn_number_comma(result.pchReqTotalAmt));
  674. // 품목 리스트 조회
  675. pageObj.grid.init('VIEW', result.rtnReqDtlList);
  676. }
  677. };
  678. /*수정화면 Object*/
  679. let modifyObj = {
  680. init: function (param) {
  681. pageObj.grid.init('DETAIL', []);
  682. //this.load(param);
  683. },
  684. button: {
  685. modify: function (param) {
  686. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG02010_DETAIL');
  687. const selectVal = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_UNQ_NO').val();
  688. const writeVal = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_MGR_ID').val();
  689. const stCd = $('#ITP_FORM_RTNMNG02010_VIEW_RTN_REQ_ST_CD').val();
  690. var userId = fn_make_user_info.get('userId');
  691. if (writeVal != userId) {
  692. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.diffWrite);
  693. return;
  694. }
  695. if (stCd != "RR00") {
  696. itp_fn_modal_alert(ITP_MSG_LOCALE.message.ajax.notWrite);
  697. return;
  698. }
  699. const key = {brandId:fn_make_user_info.get('brandId'), rtnReqUnqNo: selectVal, viewCd: 'R'};
  700. var param = $.param(key);
  701. modifyObj.load(param);
  702. },
  703. save: function(arg) {
  704. $('body').trigger('click');
  705. const formId = '#ITP_FORM_RTNMNG02010_DETAIL';
  706. itp_fn_form_clear_validate(null, formId);
  707. itp_fn_grid_save_rows(RTNMNG02010_DETAIL_GRID_ID);
  708. $('#ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_ST_CD').val(arg);
  709. if (itp_fn_form_event.isValid(formId)) {
  710. const rowData1 = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  711. var dataCnt = 0;
  712. $.each(rowData1, function(key, value) {
  713. if (value.viewCd != 'D') {
  714. dataCnt = dataCnt + 1;
  715. }
  716. });
  717. if (dataCnt == 0) {
  718. itp_fn_modal_alert( "요청할 품목내역이 없습니다.");
  719. return ;
  720. }
  721. var now = new Date();
  722. var today = now.getFullYear() +
  723. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  724. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  725. var colReqDt = $('#ITP_FORM_RTNMNG02010_DETAIL_COL_REQ_DT').val();
  726. if (today > colReqDt) {
  727. alert("수거요청일은 오늘 이후이어야 합니다.");
  728. return;
  729. }
  730. var rtnQtyCheck = true;
  731. var rtnDvsnCheck = true;
  732. var rtnRsnDvsnCheck = true;
  733. var rtnRsnCheck = true;
  734. $.each(rowData1, function(key, value) {
  735. if(value.rtnQty == '') {
  736. rtnQtyCheck = false;
  737. }
  738. if(value.rtnDvsn == '') {
  739. rtnDvsnCheck = false;
  740. }
  741. if(value.rtnRsnDvsn == '') {
  742. rtnRsnDvsnCheck = false;
  743. }
  744. if(value.rtnRsn == '') {
  745. rtnRsnCheck = false;
  746. }
  747. });
  748. if(rtnQtyCheck == false) {
  749. itp_fn_modal_alert( "반품수량을 입력하세요.");
  750. return;
  751. }
  752. if(rtnDvsnCheck == false) {
  753. itp_fn_modal_alert( "반품구분을 입력하세요.");
  754. return;
  755. }
  756. if(rtnRsnDvsnCheck == false) {
  757. itp_fn_modal_alert( "사유구분을 입력하세요.");
  758. return;
  759. }
  760. if(rtnRsnCheck == false) {
  761. itp_fn_modal_alert( "반품사유를 입력하세요.");
  762. return;
  763. }
  764. var saveReq = {
  765. callBack: function(args) {
  766. $(formId).val(arg);
  767. let gridInsertData = [];
  768. let gridUpdateData = [];
  769. let gridDeleteData = [];
  770. const rowData = $(RTNMNG02010_DETAIL_GRID_ID).getRowData();
  771. $.each(rowData, function(key, value) {
  772. if (value.viewCd != 'R') {
  773. if (value.viewCd == 'C') {
  774. gridInsertData.push(value);
  775. } else if (value.viewCd == 'U') {
  776. gridUpdateData.push(value);
  777. } else if (value.viewCd == 'D') {
  778. gridDeleteData.push(value);
  779. }
  780. }
  781. });
  782. let param = $(formId).serializeObject();
  783. param.gridInsertData = gridInsertData;
  784. param.gridUpdateData = gridUpdateData;
  785. param.gridDeleteData = gridDeleteData;
  786. var searhFn = function() {
  787. ITP_FORM_RTNMNG02010_DETAIL_IS_WRITING = false;
  788. modifyObj.button.clear();
  789. //listObj.grid.search();
  790. };
  791. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  792. }
  793. };
  794. if (arg == 'RR20') {
  795. itp_fn_modal_confirm('반품 요청하시겠습니까?', saveReq, null);
  796. } else {
  797. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.tmpSave, saveReq, null);
  798. }
  799. }
  800. },
  801. clear: function () {
  802. document.getElementById('ITP_FORM_RTNMNG02010_DETAIL').reset();
  803. listObj.grid.search();
  804. },
  805. cancel: function () {
  806. listObj.grid.search();
  807. }
  808. },
  809. load: function(param) {
  810. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  811. },
  812. callback: function (result) {
  813. pageObj.switchScreen('MODIFY');
  814. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_VIEW_CD').val('U');
  815. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_BRAND_ID').val(result.brandId);
  816. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_STORE_ID').val(result.storeId);
  817. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_UNQ_NO').val(result.rtnReqUnqNo);
  818. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_ST_CD').val(result.rtnReqStCd);
  819. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_REQ_MGR_ID').val(result.rtnReqMgrId);
  820. $('#ITP_FORM_RTNMNG02010_DETAIL .fnBrandNm').text(result.brandNm);
  821. $('#ITP_FORM_RTNMNG02010_DETAIL .fnRtnReqUnqNo').text(result.rtnReqUnqNo + ' / ' + result.rtnReqStNm);
  822. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId);
  823. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_WHS_NM').val(result.rtnWhsNm);
  824. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_LOCATION').val(result.rtnLocation);
  825. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_RTN_LOCATION_NM').val(result.rtnLocationNm);
  826. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_COL_REQ_DT').val(result.colReqDt);
  827. $('#ITP_FORM_RTNMNG02010_DETAIL #ITP_FORM_RTNMNG02010_DETAIL_NOTE').val(result.note);
  828. // 품목 리스트 조회
  829. pageObj.grid.init('DETAIL', result.rtnReqDtlList);
  830. },
  831. };