ITP_RTNMNG03010.js 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. require(['config'], function() {
  2. require([
  3. 'kakao.map.util'
  4. ], function($) {
  5. pageObj.init();
  6. });
  7. });
  8. /********************************************************
  9. --------------------------------------------------------
  10. - Object 목록 -
  11. --------------------------------------------------------
  12. * const gridColModel = {} : 화면 Grid Object *
  13. * let pageObj = {} : 화면공통 Object *
  14. * let listObj = {} : 목록화면 Object *
  15. * let viewObj = {} : 상세화면 Object *
  16. * let modifyObj = {} : 수정화면 Object *
  17. * let createObj = {} : 신규화면 Object *
  18. *******************************************************/
  19. /*화면 변수*/
  20. const RTNMNG03010_GRID_ID = '#ITP_RTNMNG03010_jqGrid';
  21. const RTNMNG03010_GRID_LIST = '#ITP_RTNMNG03010_jqGrid_list';
  22. const RTNMNG03010_GRID_PAGER = '#ITP_RTNMNG03010_jqGridPager';
  23. const RTNMNG03010_GRID_EMPTY = '#ITP_RTNMNG03010_jqGridEmpty';
  24. const RTNMNG03010_DETAIL_GRID_ID = '#ITP_RTNMNG03010_DETAIL_jqGrid';
  25. const RTNMNG03010_DETAIL_GRID_LIST = '#ITP_RTNMNG03010_DETAIL_jqGrid_list';
  26. const RTNMNG03010_DETAIL_GRID_PAGER = '#ITP_RTNMNG03010_DETAIL_jqGridPager';
  27. const RTNMNG03010_DETAIL_GRID_EMPTY = '#ITP_RTNMNG03010_DETAIL_jqGridEmpty';
  28. const RTNMNG03010_NDETAIL_GRID_ID = '#ITP_RTNMNG03010_NDETAIL_jqGrid';
  29. const RTNMNG03010_NDETAIL_GRID_LIST = '#ITP_RTNMNG03010_NDETAIL_jqGrid_list';
  30. const RTNMNG03010_NDETAIL_GRID_PAGER = '#ITP_RTNMNG03010_NDETAIL_jqGridPager';
  31. const RTNMNG03010_NDETAIL_GRID_EMPTY = '#ITP_RTNMNG03010_NDETAIL_jqGridEmpty';
  32. let ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  33. let RTNMNG03010_GRID_LAST_ROW_ID;
  34. let SCREEN_MODE ;
  35. /* 공통코드 리스트 */
  36. let ITP_COMMON_CD_RTN_DVSN = fn_make_common_cd_list(CODE_LIST, 'RTN_DVSN', false);
  37. let ITP_COMMON_CD_RTN_RSN_DVSN = fn_make_common_cd_list(CODE_LIST, 'RTN_RSN_DVSN', false);
  38. /*API URL*/
  39. let API_DETAIL_GRID_LIST = '/api/rtnmng/target-grid-list'; // 목록
  40. let API_DETAIL_REJECT = '/api/rtnmng/reject-rtnReq'; // 반품요청 선택한건 반려 처리
  41. let API_DETAIL_POPASS_CHK = '/api/rtnmng/rtn/chk-rtnOrd'; // 목록에서 선택한 요청건에 대해 발주가능여부 체크 함
  42. let API_DETAIL_PO_INIT_INFO = '/api/rtnmng/rtn/init-rtnOrd'; // 요청발주생성 오픈시 호출하여 데이타 세팅함 (/api/rtnmng/rtn/init-rtnOrd)
  43. let API_DETAIL_NEW_INIT_INFO = '/api/rtnmng/rtn/init-new-rtnOrd'; // 신규발주생성 오픈시 호출하여 데이타 세팅함
  44. let API_DETAIL_SAVE = '/api/rtnmng/rtn/save-rtnPo'; // 저장(/api/rtnmng/rtn/save-rtnPo)
  45. let API_DETAIL_PASSQTY = '/api/stock/mng/whs-passqty-list'; // 창고선택후 해당 창고의 출고가능수량을 가져옴
  46. /*화면 Grid ColModel*/
  47. const gridColModel = {
  48. list: [
  49. {
  50. index: 'RTN_REQ_UNQ_NO', name: 'rtnReqUnqNo',
  51. label: '반품요청고유번호',
  52. width: '13', fixed: false, align: 'center',
  53. sortable: false, hidden: true
  54. },
  55. {
  56. index: 'RTN_REQ_DTL_NO', name: 'rtnReqDtlNo',
  57. label: '반품요청상세번호',
  58. width: '13', fixed: false, align: 'center',
  59. sortable: false, hidden: true
  60. },
  61. {
  62. index: 'BRAND_ID', name: 'brandId',
  63. label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
  64. width: '10', fixed: false, align: 'center',
  65. sortable: false, hidden: true
  66. },
  67. {
  68. index: 'STORE_ID', name: 'storeId',
  69. label: ITP_MSG_LOCALE.label.storeId, //매장아이디
  70. width: '13', fixed: false, align: 'center',
  71. sortable: false, hidden: true
  72. },
  73. {
  74. index: 'BRAND_NM', name: 'brandNm',
  75. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  76. width: '10', fixed: false, align: 'left',
  77. sortable: false, hidden: false, classes: 'ui-ellipsis'
  78. },
  79. {
  80. index: 'RTN_WHS_NM', name: 'rtnWhsNm',
  81. label: '반품장소',
  82. width: '10', fixed: false, align: 'left',
  83. sortable: false, hidden: false, classes: 'ui-ellipsis'
  84. },
  85. {
  86. index: 'SPPLY_NM', name: 'spplyNm',
  87. label: '공급사명',
  88. width: '10', fixed: false, align: 'left',
  89. sortable: false, hidden: false, classes: 'ui-ellipsis'
  90. },
  91. {
  92. index: 'ITEM_ID', name: 'itemId',
  93. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  94. width: '12', fixed: false, align: 'center',
  95. sortable: false, hidden: false
  96. },
  97. {
  98. index: 'ITEM_NM', name: 'itemNm',
  99. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  100. minwidth: 100,
  101. width: '7', fixed: false, align: 'left',
  102. sortable: false, hidden: false, classes: 'ui-ellipsis'
  103. },
  104. {
  105. index: 'RTN_QTY', name: 'rtnQty',
  106. label: '반품수량',
  107. width: '8', fixed: false, align: 'right',
  108. sortable: false, hidden: false,
  109. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  110. },
  111. {
  112. index: 'RTN_DVSN_NM', name: 'rtnDvsnNm',
  113. label: '반품구분',
  114. width: '8', fixed: false, align: 'left',
  115. sortable: false, hidden: false
  116. },
  117. {
  118. index: 'RTN_AMT', name: 'rtnAmt',
  119. label: '반품금액',
  120. width: '10', fixed: false, align: 'right',
  121. sortable: false, hidden: true,
  122. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  123. classes: 'ui-ellipsis'
  124. },
  125. {
  126. index: 'RTN_REQ_DT', name: 'rtnReqDt',
  127. label: '반품요청일',
  128. width: '9', fixed: false, align: 'center',
  129. sortable: false, hidden: false
  130. },
  131. {
  132. index: 'COL_REQ_DT', name: 'colReqDt',
  133. label: '수거요청일',
  134. width: '9', fixed: false, align: 'center',
  135. sortable: false, hidden: false
  136. },
  137. {
  138. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  139. label: '반품사유',
  140. minwidth: 130,
  141. width: '7', fixed: false, align: 'center',
  142. sortable: false, hidden: false
  143. }
  144. ],
  145. detail: [
  146. {
  147. index: 'VIEW_CD', name: 'viewCd',
  148. label: ITP_MSG_LOCALE.label.viewCd,
  149. width: '10', fixed: false, align: 'center',
  150. sortable: false, hidden: true
  151. },
  152. {
  153. index: 'RTN_REQ_UNQ_NO', name: 'rtnReqUnqNo',
  154. label: '반품요청번호',
  155. width: '9', fixed: false, align: 'center',
  156. sortable: false, hidden: false, edittype: 'text',
  157. editable: false
  158. },
  159. {
  160. index: 'RTN_REQ_DTL_NO', name: 'rtnReqDtlNo',
  161. label: '반품요청항번',
  162. width: '8', fixed: false, align: 'center',
  163. sortable: true, editable: false, edittype: 'text',
  164. hidden: false
  165. },
  166. {
  167. index: 'ITEM_ID', name: 'itemId',
  168. label: ITP_MSG_LOCALE.label.itemId, // 품목아이디
  169. width: '10', fixed: false, align: 'center',
  170. sortable: false, editable: false, edittype: 'text',
  171. hidden: false
  172. },
  173. {
  174. index: 'ITEM_NM', name: 'itemNm',
  175. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  176. width: '6', fixed: false, align: 'left',
  177. sortable: false, editable: false, edittype: 'text',
  178. hidden: false
  179. },
  180. {
  181. index: 'UNIT_AMT', name: 'unitAmt',
  182. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  183. width: '5', fixed: false, align: 'right',
  184. sortable: false, editable: false, edittype: 'text',
  185. hidden: false,
  186. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  187. },
  188. {
  189. index: 'UNIT', name: 'unit',
  190. label: ITP_MSG_LOCALE.label.unit, //단위
  191. width: '5', fixed: false, align: 'center',
  192. sortable: false, editable: false, edittype: 'text',
  193. hidden: false
  194. },
  195. {
  196. index: 'RTN_REQ_QTY', name: 'rtnReqQty',
  197. label: '반품요청수량',
  198. width: '8', fixed: false, align: 'right',
  199. sortable: false, editable: false, edittype: 'text',
  200. hidden: false,
  201. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  202. },
  203. {
  204. index: 'RTN_QTY', name: 'rtnQty',
  205. label: '반품발주수량', classes: 'input_color',
  206. width: '8', fixed: false, align: 'right',
  207. sortable: false, editable: true, edittype: 'text',
  208. editrules: {required: true}, hidden: false,
  209. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');", maxlength: 10},
  210. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  211. },
  212. {
  213. index: 'RTN_AMT', name: 'rtnAmt',
  214. label: '발주금액',
  215. width: '6', fixed: false, align: 'right',
  216. sortable: false, editable: false, edittype: 'text',
  217. hidden: false,
  218. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  219. },
  220. {
  221. index: 'RTN_DVSN_NM', name: 'rtnDvsnNm',
  222. label: '반품구분',
  223. width: '6', fixed: false, align: 'left',
  224. sortable: false, editable: false, edittype: 'text',
  225. hidden: false
  226. },
  227. {
  228. index: 'RTN_DVSN', name: 'rtnDvsn',
  229. label: '반품구분',
  230. width: '6', fixed: false, align: 'center',
  231. sortable: false, editable: false, edittype: 'text',
  232. hidden: true
  233. },
  234. {
  235. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  236. label: '사유구분',
  237. width: '7', fixed: false, align: 'left',
  238. sortable: false, editable: false, edittype: 'text',
  239. hidden: false
  240. },
  241. {
  242. index: 'RTN_RSN_DVSN', name: 'rtnRsnDvsn',
  243. label: '사유구분',
  244. width: '7', fixed: false, align: 'left',
  245. sortable: false, editable: false, edittype: 'text',
  246. hidden: true
  247. },
  248. {
  249. index: 'RTN_RSN', name: 'rtnRsn',
  250. label: '사유',
  251. width: '11', fixed: false, align: 'center',
  252. sortable: false, editable: false, edittype: 'text',
  253. hidden: false
  254. },
  255. {
  256. index: 'BRAND_UNIT_UNQ_NO', name: 'brandUnitUnqNo',
  257. label: ITP_MSG_LOCALE.label.brandUnitUnqNo, //브랜드단가고유번호
  258. width: '10', fixed: false, align: 'center',
  259. sortable: false, editable: false, edittype: 'text',
  260. hidden: true
  261. },
  262. {
  263. index: 'STORE_UNIT_UNQ_NO', name: 'storeUnitUnqNo',
  264. label: ITP_MSG_LOCALE.label.storeUnitUnqNo, //매장단가고유번호
  265. width: '10', fixed: false, align: 'left',
  266. sortable: false, editable: false, edittype: 'text',
  267. hidden: true
  268. }
  269. ],
  270. ndetail: [
  271. {
  272. index: 'VIEW_CD', name: 'viewCd',
  273. label: ITP_MSG_LOCALE.label.viewCd,
  274. width: '10', fixed: false, align: 'center',
  275. sortable: false, hidden: true
  276. },
  277. {
  278. index: 'RTN_REQ_UNQ_NO', name: 'rtnReqUnqNo',
  279. label: '반품요청번호',
  280. width: '10', fixed: false, align: 'center',
  281. sortable: false, hidden: true, edittype: 'text',
  282. editable: false
  283. },
  284. {
  285. index: 'RTN_REQ_DTL_NO', name: 'rtnReqDtlNo',
  286. label: '반품요청항번',
  287. width: '10', fixed: false, align: 'center',
  288. sortable: true, editable: false, edittype: 'text',
  289. hidden: true
  290. },
  291. {
  292. index: 'ITEM_ID', name: 'itemId',
  293. label: ITP_MSG_LOCALE.label.itemId, // 품목아이디
  294. width: '14', fixed: false, align: 'center',
  295. sortable: false, editable: false, edittype: 'text',
  296. hidden: false
  297. },
  298. {
  299. index: 'ITEM_NM', name: 'itemNm',
  300. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  301. width: '10', fixed: false, align: 'left',
  302. sortable: false, editable: false, edittype: 'text',
  303. hidden: false
  304. },
  305. {
  306. index: 'UNIT_AMT', name: 'unitAmt',
  307. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  308. width: '8', fixed: false, align: 'right',
  309. sortable: false, editable: false, edittype: 'text',
  310. hidden: false,
  311. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  312. },
  313. {
  314. index: 'UNIT', name: 'unit',
  315. label: ITP_MSG_LOCALE.label.unit, //단위
  316. width: '12', fixed: false, align: 'center',
  317. sortable: false, editable: false, edittype: 'text',
  318. hidden: false
  319. },
  320. {
  321. index: 'RTN_REQ_QTY', name: 'rtnReqQty',
  322. label: '반품요청수량',
  323. width: '10', fixed: false, align: 'right',
  324. sortable: false, editable: false, edittype: 'text',
  325. hidden: true,
  326. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  327. },
  328. {
  329. index: 'RTN_QTY', name: 'rtnQty',
  330. label: '반품발주수량', classes: 'input_color',
  331. width: '10', fixed: false, align: 'right',
  332. sortable: false, editable: true, edittype: 'text',
  333. editrules: {required: true}, hidden: false,
  334. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');", maxlength: 10},
  335. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  336. },
  337. {
  338. index: 'RTN_AMT', name: 'rtnAmt',
  339. label: '발주금액',
  340. width: '10', fixed: false, align: 'right',
  341. sortable: false, editable: false, edittype: 'text',
  342. hidden: false,
  343. formatter:'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  344. },
  345. {
  346. index: 'RTN_DVSN', name: 'rtnDvsn',
  347. label: '반품구분', classes: 'input_color',
  348. width: '10', fixed: false, align: 'center',
  349. sortable: false, editable: true, formatter: 'select', edittype: 'select',
  350. editoptions: {value: ITP_COMMON_CD_RTN_DVSN},
  351. editrules: {required: true}
  352. },
  353. {
  354. index: 'RTN_RSN_DVSN', name: 'rtnRsnDvsn',
  355. label: '사유구분', classes: 'input_color',
  356. width: '10', fixed: false, align: 'center',
  357. sortable: false, editable: true, formatter: 'select', edittype: 'select',
  358. editoptions: {value: ITP_COMMON_CD_RTN_RSN_DVSN},
  359. editrules: {required: true}
  360. },
  361. {
  362. index: 'RTN_RSN', name: 'rtnRsn',
  363. label: '반품사유', classes: 'input_color',
  364. width: '15', fixed: false, align: 'left',
  365. sortable: false, editable: true, edittype: 'text',
  366. editoptions: {maxlength: 200}
  367. },
  368. {
  369. index: 'BRAND_UNIT_UNQ_NO', name: 'brandUnitUnqNo',
  370. label: ITP_MSG_LOCALE.label.brandUnitUnqNo, //브랜드단가고유번호
  371. width: '10', fixed: false, align: 'center',
  372. sortable: false, editable: false, edittype: 'text',
  373. hidden: true
  374. },
  375. {
  376. index: 'STORE_UNIT_UNQ_NO', name: 'storeUnitUnqNo',
  377. label: ITP_MSG_LOCALE.label.storeUnitUnqNo, //매장단가고유번호
  378. width: '10', fixed: false, align: 'center',
  379. sortable: false, editable: false, edittype: 'text',
  380. hidden: true
  381. }
  382. ]
  383. };
  384. /*화면공통 Object*/
  385. let pageObj = {
  386. init: function () {
  387. this.ui.init();
  388. this.event.init();
  389. this.action();
  390. },
  391. ui: {
  392. init: function () {
  393. this.view();
  394. this.grid();
  395. this.ready();
  396. },
  397. view: function() {
  398. // 버튼 권한설정
  399. fn_proc_btn_auth('RTNMNG03010');
  400. // 공통코드 표시
  401. $('select').each(function() {
  402. if($(this).data('select-code')) {
  403. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  404. }
  405. });
  406. // 브랜드/매장
  407. $('#ITP_FORM_RTNMNG03010_SEARCH_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  408. $('#ITP_FORM_RTNMNG03010_SEARCH_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  409. // 조회일자 지정
  410. var now = new Date();
  411. $('#ITP_TAB_RTNMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  412. $('#ITP_FORM_RTNMNG03010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  413. $('#ITP_FORM_RTNMNG03010_SEARCH_TO_DT').datepicker('setDate', new Date());
  414. },
  415. grid: function() {
  416. itp_fn_jqgrid_resize(RTNMNG03010_GRID_ID, RTNMNG03010_GRID_LIST, 'lg');
  417. },
  418. ready: function() {
  419. listObj.init();
  420. }
  421. },
  422. action: function () {
  423. var _this = this;
  424. // 검색 반품장소
  425. $('#ITP_FORM_RTNMNG03010_SSEARCH_SWHS_NM').on('click', function() {
  426. _this.popup('SW');
  427. });
  428. // 검색 반품장소 텍스트 삭제 버튼 클릭
  429. $('#ITP_FORM_RTNMNG03010_SDELETE_SWHS_NM').on('click', function() {
  430. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_NM').val('');
  431. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_ID').val('');
  432. });
  433. // 상세 출하창고
  434. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').on('click', function() {
  435. _this.popup('SHW');
  436. });
  437. // 검색 납품장소 텍스트 삭제 버튼 클릭
  438. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').on('click', function() {
  439. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val('');
  440. $('#ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val('');
  441. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val('');
  442. });
  443. // 검색 공급사
  444. $('#ITP_FORM_RTNMNG03010_SSEARCH_SSPPLY_NM').on('click', function() {
  445. _this.popup('SS');
  446. });
  447. // 검색 텍스트 삭제 버튼 클릭
  448. $('#ITP_FORM_RTNMNG03010_SDELETE_SSPPLY_NM').on('click', function() {
  449. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_NM').val('');
  450. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_ID').val('');
  451. });
  452. // 검색 공급사
  453. $('#ITP_BTN_RTNMNG03010_NDETAIL_SPPLY_NM').on('click', function() {
  454. _this.popup('NS');
  455. });
  456. // 검색 텍스트 삭제 버튼 클릭
  457. $('#ITP_BTN_RTNMNG03010_SDELETE_SPPLY_NM').on('click', function() {
  458. var spplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  459. var records = $(RTNMNG03010_NDETAIL_GRID_ID).getGridParam('reccount')
  460. if (spplyId != '' && records != 0 ) {
  461. // 공급업체 삭제시 품목까지 삭제 처리되어집니다. 삭제 하시겠습니까?
  462. var delSpply = {
  463. callBack: function(args) {
  464. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val('');
  465. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val('');
  466. // 품목그리드삭제 처리
  467. pageObj.grid.clearData('NPC');
  468. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnDodrTotalAmt').text('');
  469. }
  470. };
  471. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.delAllItem, delSpply, null);
  472. } else {
  473. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val('');
  474. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val('')
  475. }
  476. });
  477. // 수거장소
  478. $('#ITP_BTN_RTNMNG03010_NDETAIL_SRH').on('click', function() {
  479. _this.popup('NHW');
  480. });
  481. // 수거장소 삭제 버튼 클릭
  482. $('#ITP_BTN_RTNMNG03010_NDETAIL_MODIFY').on('click', function() {
  483. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_NM').val('');
  484. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_ID').val('');
  485. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_LOCATION').val('');
  486. });
  487. },
  488. popup: function (arg) {
  489. var popFn ;
  490. // 팝업
  491. if (arg == "SW") {
  492. popFn = this.callback.searWhs;
  493. } else if (arg == "SS") {
  494. popFn = this.callback.searSpply;
  495. } else if (arg == "SHW") {
  496. popFn = this.callback.searchRtnWhs;
  497. } else if (arg == "NS") {
  498. popFn = this.callback.searNSpply;
  499. } else if (arg == "NHW") {
  500. popFn = this.callback.searNWhs;
  501. } else if (arg == "REJ") {
  502. popFn = this.callback.poRej;
  503. }
  504. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  505. if (arg == "SW" ) {
  506. const keya = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  507. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keya, 'S');
  508. } else if (arg == "SS" || arg == "NS" ) {
  509. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  510. } else if (arg == "SHW" || arg == "NHW") {
  511. const keyb = {brandId:fn_make_user_info.get('brandId'),storeId:"", whsDvsn:"W01"};
  512. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keyb, 'S');
  513. } else if (arg == "REJ" ) {
  514. /* 선택ROW가져오기 */
  515. const rowKey = $(RTNMNG03010_GRID_ID).getGridParam('selrow');
  516. if (!rowKey) {
  517. return;
  518. }
  519. var selectedIds = $(RTNMNG03010_GRID_ID).getGridParam('selarrrow');
  520. if(selectedIds.length > 1) { // 1개만 선택
  521. itp_fn_modal_alert("반품요청 반려대상에 대해 하나만 선택해주세요.") ;
  522. return;
  523. }
  524. var selRowData ;
  525. for (var i=selectedIds.length-1; i>=0; i--) {
  526. selRowData = $(RTNMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]);
  527. }
  528. const key1 = {rtnReqUnqNo:selRowData.rtnReqUnqNo, storeId:selRowData.storeId};
  529. fn_call_popup('biz', 'BIZPOP_RTN_PO_REJECT', '#ITP_ASIDE', popFn, key1, 'S');
  530. }
  531. },
  532. callback: {
  533. searWhs: function(rowDataPop) {
  534. if(rowDataPop) {
  535. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  536. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  537. }
  538. },
  539. searSpply: function(rowDataPop) {
  540. if(rowDataPop) {
  541. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_NM').val(rowDataPop.spplyNm);
  542. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_ID').val(rowDataPop.spplyId);
  543. }
  544. },
  545. searNSpply: function(rowDataPop) {
  546. if(rowDataPop) {
  547. var pspplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  548. if (pspplyId == "") {
  549. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val(rowDataPop.spplyNm);
  550. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val(rowDataPop.spplyId);
  551. } else {
  552. var records = $(RTNMNG03010_NDETAIL_GRID_ID).getGridParam('reccount')
  553. if (records != 0) {
  554. if (pspplyId != rowDataPop.spplyId ) {
  555. itp_fn_modal_alert( "추가한 품목의 공급사와 서로 틀립니다 !");
  556. return ;
  557. }
  558. }
  559. }
  560. }
  561. },
  562. searchRtnWhs: function(rowDataPop) {
  563. if(rowDataPop) {
  564. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val(rowDataPop.whsNm + " - " + rowDataPop.locationNm);
  565. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  566. $('#ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val(rowDataPop.location);
  567. }
  568. },
  569. searNWhs: function(rowDataPop) {
  570. if(rowDataPop) {
  571. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_NM').val(rowDataPop.whsNm + " - " + rowDataPop.locationNm);
  572. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_ID').val(rowDataPop.whsId);
  573. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_LOCATION').val(rowDataPop.location);
  574. }
  575. },
  576. poRej: function(rowDataPop) {
  577. if(rowDataPop) {
  578. if (rowDataPop.retVal == "Y") {
  579. modifyObj.button.rejectSave(rowDataPop);
  580. }
  581. }
  582. }
  583. },
  584. event: {
  585. init: function () {
  586. this.button();
  587. },
  588. button: function () {
  589. // 버튼 클릭 이벤트
  590. $('button').each(function() {
  591. var id = $(this).attr('id');
  592. $(this).on('click', function() {
  593. switch (id) {
  594. case 'ITP_BTN_RTNMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  595. case 'ITP_BTN_RTNMNG03010_NEWCREATE' : listObj.button.chkpo(); break; // 반품발주생성 버튼
  596. case 'ITP_BTN_RTNMNG03010_POCREATE' : listObj.button.newpocreate(); break; // 반품신규생성 버튼
  597. case 'ITP_BTN_RTNMNG03010_POREJECT' : listObj.button.reject(); break; // 반려
  598. case 'ITP_BTN_RTNMNG03010_RTNPO' : modifyObj.button.save(); break; // 발주
  599. case 'ITP_BTN_RTNMNG03010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  600. case 'ITP_BTN_RTNMNG03010_NDETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 품목추가
  601. case 'ITP_BTN_RTNMNG03010_NDETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 품목삭제
  602. case 'ITP_BTN_RTNMNG03010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  603. }
  604. });
  605. });
  606. $('body').on('click', function(e) {
  607. var gridId = ((SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).replace('#', '');
  608. var rids = $( (SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  609. var last_row_id = rids[rids.length - 1];
  610. itp_fn_grid_reset_selection(e, last_row_id, gridId, (SCREEN_MODE === 'NPC') ? 'RTNMNG03010_NDETAIL' : 'RTNMNG03010_DETAIL');
  611. pageObj.grid.recal();
  612. });
  613. }
  614. },
  615. switchScreen: function(mode) {
  616. $('.itp_det_head').find('button[id^="ITP_BTN_RTNMNG03010_"]').each(function(i) {
  617. $(this).hide();
  618. });
  619. $('#ITP_TAB_RTNMNG03010').find('div[id$="_CONTAINER"]').each(function(i) {
  620. $(this).hide();
  621. });
  622. if(mode == 'LIST') { // 목록
  623. itp_fn_fire_window_resize();
  624. $('#ITP_AJAX_RTNMNG03010_LIST_CONTAINER').show();
  625. $('#ITP_FORM_RTNMNG03010_SDELETE_SSPPLY_NM').show();
  626. $('#ITP_FORM_RTNMNG03010_SDELETE_SWHS_NM').show();
  627. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_SRH', '#ITP_BTN_RTNMNG03010_NEWCREATE','#ITP_BTN_RTNMNG03010_POCREATE', '#ITP_BTN_RTNMNG03010_POREJECT']);
  628. // $('#ITP_FORM_RTNMNG03010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  629. // $('#ITP_FORM_RTNMNG03010_DETAIL_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  630. $('#ITP_BTN_RTNMNG03010_EXCEL').show();
  631. SCREEN_MODE = 'LIST' ;
  632. } else if(mode == 'NPC') { // 신규발주등록
  633. $('#ITP_AJAX_RTNMNG03010_NDETAIL_CONTAINER').show();
  634. $('#ITP_BTN_RTNMNG03010_SDELETE_SPPLY_NM').show();
  635. $('#ITP_BTN_RTNMNG03010_NDETAIL_MODIFY').show();
  636. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_RTNPO', '#ITP_BTN_RTNMNG03010_CANCELLIST', '#ITP_BTN_RTNMNG03010_NDETAIL_ADDROW','#ITP_BTN_RTNMNG03010_NDETAIL_DELROW']);
  637. $('#ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  638. SCREEN_MODE = 'NPC' ;
  639. pageObj.grid.init('NPC');
  640. } else if(mode == 'POC') { // 구매요청 발주
  641. $('#ITP_AJAX_RTNMNG03010_DETAIL_CONTAINER').show();
  642. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').show();
  643. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_RTNPO', '#ITP_BTN_RTNMNG03010_CANCELLIST']);
  644. $('#ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  645. $('#ITP_FORM_RTNMNG03010_DETAIL_STORE_ID').val(fn_make_user_info.get('storeId'));
  646. SCREEN_MODE = 'POC' ;
  647. }
  648. },
  649. grid: {
  650. init: function(mode, gridRows) {
  651. this.gridId = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID;
  652. this.gridList = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST;
  653. this.gridEmpty = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY;
  654. this.gridRows = gridRows;
  655. this.unload();
  656. this.load(mode, gridRows);
  657. },
  658. gridId: '',
  659. button: {
  660. addRow: function() {
  661. // 팝업
  662. var popFn = function(rowDataPop) {
  663. // 기존등록 데이터
  664. var exists = '';
  665. const rowData = $(RTNMNG03010_NDETAIL_GRID_ID).getRowData();
  666. $.each(rowData, function(key, value) {
  667. if (value.viewCd != "D") {
  668. exists = exists + value.brandUnitUnqNo + ';';
  669. }
  670. });
  671. var diffchk = "N";
  672. var spplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  673. var spplyNm = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val();
  674. // 넘어오는 데이타가 서로 상이한 공급업체인지 파악
  675. var chkSpplyId = "";
  676. var chkSpplyNm = "";
  677. $.each(rowDataPop, function(key, value) {
  678. if (chkSpplyId != "" ) {
  679. if (value.spplyId != chkSpplyId ) {
  680. itp_fn_modal_alert("서로다른 공급사 품목을 발주 진행 할 수 없습니다.");
  681. diffchk = "Y" ;
  682. return false ;
  683. }
  684. } else {
  685. chkSpplyId = value.spplyId;
  686. chkSpplyNm = value.spplyNm;
  687. }
  688. });
  689. if (diffchk == "Y") return;
  690. if (spplyId == "" ) {
  691. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val(chkSpplyId);
  692. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val(chkSpplyNm);
  693. } else {
  694. if (spplyId != chkSpplyId ) {
  695. itp_fn_modal_alert("납품 공급사와 품목 공급사 정보가 서로 다릅니다.");
  696. diffchk = "Y" ;
  697. }
  698. }
  699. if (diffchk == "Y") return;
  700. $.each(rowDataPop, function(key, value) {
  701. // 공급업체가 상이사면 오류 알럿 출력
  702. if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
  703. value['viewCd'] = "C";
  704. $(RTNMNG03010_NDETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
  705. }
  706. });
  707. $(RTNMNG03010_NDETAIL_GRID_EMPTY).hide();
  708. };
  709. const key = {brandId:fn_make_user_info.get('brandId')};
  710. console.log("key==",key);
  711. fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S'); // ==>dwkim 추후 작업 진행 파라메타 설명필요
  712. },
  713. delRow: function() {
  714. itp_fn_grid_del_row(RTNMNG03010_NDETAIL_GRID_ID);
  715. pageObj.grid.recal();
  716. }
  717. },
  718. gridList: '',
  719. gridEmpty: '',
  720. gridRows: '',
  721. load: function(mode, gridRows) {
  722. var _this = this;
  723. var option = {
  724. gridId: _this.gridId,
  725. colModel: (mode === 'NPC') ? gridColModel.ndetail : gridColModel.detail,
  726. data: gridRows,
  727. multiselect: (mode === 'NPC'),
  728. loadComplete: function(data) {
  729. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  730. data.records === 0 ? _this.clearData(mode) : $(_this.mode === 'NPC' ? _this.clearData(mode) : RTNMNG03010_DETAIL_GRID_EMPTY).hide();
  731. },
  732. onCellSelect: function(rowid, cellIdx, cellValue) {
  733. RTNMNG03010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, RTNMNG03010_GRID_LAST_ROW_ID, _this.gridId, ['pchReqDtlNo']);
  734. }
  735. };
  736. itp_fn_grid_make_local(option);
  737. },
  738. recal: function() {
  739. if (SCREEN_MODE == 'NPC' || SCREEN_MODE === 'POC') {
  740. var ids = $((SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).getDataIDs();
  741. $.each(ids, function(idx, rowId) {
  742. var viewCd = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'viewCd');
  743. var unitAmt = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  744. var rtnQty = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'rtnQty');
  745. if(viewCd != 'D' && unitAmt != null && unitAmt != '' && rtnQty != null && rtnQty != '') {
  746. jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{rtnAmt: parseInt(unitAmt)*parseInt(rtnQty)});
  747. }
  748. });
  749. const rowData = $((SCREEN_MODE == 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).getRowData();
  750. var rtnAmt = 0 ;
  751. $.each(rowData, function(key, value) {
  752. if (value.rtnAmt != null && value.rtnAmt != "" && value.viewCd != "D") {
  753. rtnAmt = rtnAmt + parseInt(value.rtnAmt) ;
  754. }
  755. });
  756. if (SCREEN_MODE == 'NPC') {
  757. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(rtnAmt));
  758. } else {
  759. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(rtnAmt));
  760. }
  761. }
  762. },
  763. clearData : function(mode) {
  764. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  765. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  766. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  767. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY).show();
  768. },
  769. unload : function() {
  770. $.jgrid.gridUnload(this.gridId);
  771. }
  772. }
  773. };
  774. /*목록화면 Object*/
  775. let listObj = {
  776. init: function () {
  777. this.grid.init();
  778. },
  779. itp_RTNMNG03010_search: false,
  780. button: {
  781. search: function() {
  782. listObj.itp_RTNMNG03010_search = true;
  783. let param = $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject();
  784. param.gridSize = $.jgrid.defaults.rowNum;
  785. param.gridPage = $.jgrid.defaults.page;
  786. $(RTNMNG03010_GRID_ID).data('grid-param',param);
  787. $(RTNMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  788. },
  789. pocreate: function(param) {
  790. //pageObj.switchScreen('POC');
  791. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_DETAIL');
  792. modifyObj.init(param);
  793. },
  794. newpocreate: function() {
  795. pageObj.switchScreen('NPC');
  796. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_NDETAIL');
  797. createObj.init();
  798. },
  799. reject: function() {
  800. //팝업 오픈
  801. pageObj.popup('REJ');
  802. },
  803. chkpo: function() {
  804. let gridUpdateData = [];
  805. const rowKey = $(RTNMNG03010_GRID_ID).getGridParam('selrow');
  806. if (!rowKey) {
  807. itp_fn_modal_alert( "반품요청 품목을 선택하세요.");
  808. return;
  809. }
  810. var selectedIds = $(RTNMNG03010_GRID_ID).getGridParam('selarrrow');
  811. for (var i=selectedIds.length-1; i>=0; i--) {
  812. gridUpdateData.push($(RTNMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]));
  813. }
  814. let param = {};
  815. param.brandId=fn_make_user_info.get('brandId');
  816. param.gridUpdateData = gridUpdateData;
  817. var chkFn = function(result) {
  818. if (result.code == "Y") {
  819. //발수 생성화면으로 전화
  820. listObj.button.pocreate(param);
  821. }
  822. };
  823. fn_ajax_call(API_DETAIL_POPASS_CHK, JSON.stringify(param), chkFn, 'POST');
  824. },
  825. },
  826. empty: {
  827. init: function() {
  828. },
  829. itp_RTNMNG03010_param: {},
  830. push: function() {
  831. },
  832. back: function() {
  833. }
  834. },
  835. grid: {
  836. init: function () {
  837. // 데이터 없을때
  838. itp_fn_jqgrid_resize(RTNMNG03010_GRID_ID, RTNMNG03010_GRID_LIST, 'lg');
  839. itp_fn_fire_window_resize();
  840. this.search();
  841. },
  842. colModel: gridColModel.list,
  843. search: function() {
  844. pageObj.switchScreen('LIST');
  845. this.unload();
  846. this.load();
  847. },
  848. load: function() {
  849. let param = $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject();
  850. param.gridSize = $.jgrid.defaults.rowNum;
  851. var option = {
  852. multiselect: true,
  853. autowidth: true,
  854. gridId: RTNMNG03010_GRID_ID,
  855. colModel: gridColModel.list,
  856. param: param,
  857. url: DOMAIN + API_DETAIL_GRID_LIST,
  858. rownumbers: false,
  859. pager: RTNMNG03010_GRID_PAGER,
  860. loadComplete: function(data) {
  861. itp_fn_grid_load_complete(data, RTNMNG03010_GRID_ID, true, 'number', 'RTNMNG03010', listObj.itp_RTNMNG03010_search, listObj.empty, true, data.gridRecords, true);
  862. var ids = $(RTNMNG03010_GRID_ID).getDataIDs();
  863. $.each(ids, function(idx, rowId) {
  864. $(RTNMNG03010_GRID_ID).jqGrid('setCell', rowId, 'storeId', '', ITP_GRID_COL_STYLE.link);
  865. });
  866. },
  867. onPaging: function(action) {
  868. itp_fn_grid_paging(RTNMNG03010_GRID_ID, action, param);
  869. }
  870. };
  871. itp_fn_grid_make_remote(option);
  872. },
  873. button: {
  874. },
  875. unload : function() {
  876. $.jgrid.gridUnload(RTNMNG03010_GRID_ID);
  877. },
  878. clearData : function() {
  879. $(RTNMNG03010_GRID_ID).jqGrid('clearGridData', true);
  880. $(RTNMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  881. $(RTNMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  882. $(RTNMNG03010_GRID_EMPTY).show();
  883. }
  884. },
  885. excelDown: function() {
  886. var param = {
  887. 'url': API_DETAIL_GRID_LIST,
  888. 'param': $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject(),
  889. 'gridColumns': $(RTNMNG03010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  890. 'fileName': '반품발주대상정보.xlsx',
  891. 'sheetName': '반품발주대상리스트'
  892. };
  893. itp_fn_remote_to_excel(param);
  894. }
  895. };
  896. /*수정화면 Object*/
  897. let modifyObj = {
  898. init: function (param) {
  899. this.load(param);
  900. },
  901. button: {
  902. modify: function (param) {
  903. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_DETAIL');
  904. const selectVal = $('#ITP_FORM_RTNMNG03010_VIEW_STORE_ID').val();
  905. const key = {brandId:fn_make_user_info.get('brandId'), storeId: selectVal, viewCd: 'R'};
  906. var param = $.param(key);
  907. modifyObj.load(param);
  908. },
  909. cancel: function() {
  910. document.getElementById('ITP_FORM_RTNMNG03010_DETAIL').reset();
  911. document.getElementById('ITP_FORM_RTNMNG03010_NDETAIL').reset();
  912. listObj.grid.search();
  913. },
  914. rejectSave: function(param) {
  915. var modalFn = {
  916. callBack: () => {
  917. var searhFn = function () {
  918. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  919. pageObj.grid.clearData();
  920. modifyObj.button.cancel();
  921. }
  922. fn_ajax_call(API_DETAIL_REJECT, param, searhFn, 'GET');
  923. }
  924. };
  925. itp_fn_modal_confirm('반품요청 반려 하시겠습니까?', modalFn);
  926. },
  927. save: function() {
  928. $('body').trigger('click');
  929. const formId = (SCREEN_MODE == 'NPC' ? '#ITP_FORM_RTNMNG03010_NDETAIL' : '#ITP_FORM_RTNMNG03010_DETAIL');
  930. itp_fn_form_clear_validate(null, formId);
  931. if (itp_fn_form_event.isValid(formId)) {
  932. if (SCREEN_MODE == 'NPC') {
  933. const rowData1 = $(RTNMNG03010_NDETAIL_GRID_ID).getRowData();
  934. var dataCnt = 0;
  935. $.each(rowData1, function(key, value) {
  936. if (value.viewCd != 'D') {
  937. dataCnt = dataCnt + 1;
  938. }
  939. });
  940. if (dataCnt == 0) {
  941. itp_fn_modal_alert( "발주 생성할 품목내역이 없습니다.");
  942. return ;
  943. }
  944. }
  945. var jobCd = "";
  946. if (SCREEN_MODE == 'NPC') {
  947. jobCd = $('#ITP_FORM_RTNMNG03010_NDETAIL_JOB_CD').val()
  948. } else {
  949. jobCd = $('#ITP_FORM_RTNMNG03010_DETAIL_JOB_CD').val()
  950. }
  951. var chkQtyYn = true;
  952. var chkQtyYn2 = true;
  953. const rowData2 = (SCREEN_MODE == 'NPC' ? $(RTNMNG03010_NDETAIL_GRID_ID).getRowData() : $(RTNMNG03010_DETAIL_GRID_ID).getRowData());
  954. $.each(rowData2, function(key, value) {
  955. if (value.rtnQty == '' || parseInt(value.rtnQty) < 1 ) {
  956. chkQtyYn = false;
  957. }
  958. if (jobCd == 'R' && parseInt(value.rtnQty) > parseInt(value.rtnReqQty) ) {
  959. chkQtyYn2 = false;
  960. }
  961. });
  962. if (chkQtyYn == false) {
  963. itp_fn_modal_alert("반품발주수량을 입력해주세요!");
  964. return;
  965. }
  966. if (chkQtyYn2 == false) {
  967. itp_fn_modal_alert("반품발주수량이 반품요청수량보다 클수 없습니다!");
  968. return;
  969. }
  970. //수거요처일
  971. var now = new Date();
  972. var today = now.getFullYear() +
  973. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  974. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  975. var colReqDt = '' ;
  976. if (SCREEN_MODE == 'NPC') {
  977. colReqDt = $('#ITP_FORM_RTNMNG03010_NDETAIL_COL_REQ_DT').val()
  978. } else {
  979. colReqDt = $('#ITP_FORM_RTNMNG03010_DETAIL_COL_REQ_DT').val()
  980. }
  981. if (today > colReqDt) {
  982. alert("수거요청일은 오늘 이후이어야 합니다.");
  983. return;
  984. }
  985. // 수거구분 값 가져오기
  986. var colDvsn = $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').val();
  987. if (colDvsn == 'C001') {
  988. var whsId = $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val();
  989. var location = $('ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val();
  990. if (whsId == '' || location == '') {
  991. itp_fn_modal_alert("반품입고창고를 선택해주세요!");
  992. return;
  993. }
  994. }
  995. var modalFn = {
  996. callBack: () => {
  997. if (SCREEN_MODE == 'NPC') {
  998. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_NDETAIL');
  999. } else {
  1000. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
  1001. }
  1002. let gridInsertData = [];
  1003. const rowData = (SCREEN_MODE == 'NPC' ? $(RTNMNG03010_NDETAIL_GRID_ID).getRowData() : $(RTNMNG03010_DETAIL_GRID_ID).getRowData());
  1004. $.each(rowData, function(key, value) {
  1005. gridInsertData.push(value);
  1006. });
  1007. if (SCREEN_MODE == 'POC') {
  1008. $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').attr("disabled", false);
  1009. }
  1010. let param = $(formId).serializeObject();
  1011. if (SCREEN_MODE == 'POC') {
  1012. $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').attr("disabled", true);
  1013. }
  1014. param.gridInsertData = gridInsertData;
  1015. console.log( JSON.stringify(param));
  1016. var searhFn = function () {
  1017. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  1018. pageObj.grid.clearData();
  1019. modifyObj.button.cancel();
  1020. }
  1021. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  1022. }
  1023. };
  1024. itp_fn_modal_confirm('반품발주를 진행 하시겠습니까?', modalFn);
  1025. }
  1026. }
  1027. },
  1028. load: function(param) {
  1029. fn_ajax_call(API_DETAIL_PO_INIT_INFO, JSON.stringify(param), this.callback, 'POST');
  1030. },
  1031. callback: function (result) {
  1032. pageObj.switchScreen('POC');
  1033. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_VIEW_CD').val('C');
  1034. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(result.brandId);
  1035. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_STORE_ID').val(result.storeId);
  1036. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_REQ_DVSN').val(result.rtnReqDvsn);
  1037. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_SPPLY_ID').val(result.spplyId);
  1038. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_COL_REQ_DT').val(result.colReqDt);
  1039. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId);
  1040. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_LOCATION').val(result.rtnLocation);
  1041. //$('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_WHS_NM').val(result.rtnWhsNm);
  1042. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').val(result.colDvsn);
  1043. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val(result.whsId);
  1044. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val(result.location);
  1045. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val(result.whsNm);
  1046. $('#ITP_FORM_RTNMNG03010_DETAIL .fnBrandNm').text(result.brandNm);
  1047. $('#ITP_FORM_RTNMNG03010_DETAIL .fnSpplyNm').text(result.spplyNm);
  1048. $('#ITP_FORM_RTNMNG03010_DETAIL .fnPodrMgrNm').text(result.rtnMgrNm);
  1049. $('#ITP_FORM_RTNMNG03010_DETAIL .fnPodrMgrMblNo').text(result.rtnMgrTelNo);
  1050. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(result.rtnDodrTotalAmt));
  1051. // TODO 수거장소
  1052. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnWhsNme').text(result.rtnWhsNm);
  1053. if (result.colDvsn == 'C001') { //본사수거
  1054. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').attr("disabled", false);
  1055. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').attr("disabled", false);
  1056. } else {
  1057. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').attr("disabled", true);
  1058. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').attr("disabled", true);
  1059. }
  1060. // 품목 리스트 조회
  1061. pageObj.grid.init('POC', result.itemList);
  1062. },
  1063. whsPassQty: function(param) {
  1064. },
  1065. passQtyCallback: function (result) {
  1066. }
  1067. };
  1068. /*신규화면 Object*/
  1069. let createObj = {
  1070. init: function () {
  1071. $('#ITP_FORM_RTNMNG03010_NDETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  1072. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_NDETAIL');
  1073. const key = {brandId:fn_make_user_info.get('brandId'), viewCd: 'R'};
  1074. var param = $.param(key);
  1075. createObj.load(param);
  1076. },
  1077. button: {
  1078. cancel: function() {
  1079. document.getElementById('ITP_FORM_RTNMNG03010_DETAIL').reset();
  1080. listObj.grid.search();
  1081. },
  1082. save: function() {
  1083. const formId = '#ITP_FORM_RTNMNG03010_DETAIL';
  1084. itp_fn_form_clear_validate(null, formId);
  1085. if (itp_fn_form_event.isValid(formId)) {
  1086. var modalFn = {
  1087. callBack: (args) => {
  1088. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
  1089. let param = $(formId).serializeObject();
  1090. var searhFn = function () {
  1091. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  1092. listObj.grid.search();
  1093. }
  1094. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  1095. }
  1096. };
  1097. itp_fn_modal_confirm('저장 하시겠습니까?', modalFn);
  1098. }
  1099. }
  1100. },
  1101. load: function(param) {
  1102. fn_ajax_call(API_DETAIL_NEW_INIT_INFO, param, this.callback, 'GET');
  1103. },
  1104. callback: function (result) {
  1105. //pageObj.switchScreen('NPC');
  1106. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_DETAIL_VIEW_CD').val('C');
  1107. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_BRAND_ID').val(result.brandId);
  1108. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_REQ_DVSN').val(result.rtnReqDvsn);
  1109. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_MGR_ID').val(result.rtnMgrId);
  1110. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_COL_DVSN').val(result.colDvsn);
  1111. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnBrandNm').text(result.brandNm);
  1112. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrNm').text(result.rtnMgrNm);
  1113. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrTelNo').text(result.rtnMgrTelNo);
  1114. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnColDvsnNm').text(result.colDvsnNm);
  1115. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrTelNo').text(result.rtnMgrTelNo);
  1116. var now = new Date();
  1117. $('#ITP_TAB_RTNMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  1118. $('#ITP_FORM_RTNMNG03010_NDETAIL_COL_REQ_DT').datepicker('setDate', new Date(now.setDate(now.getDate()+5)));
  1119. // 품목 리스트 조회
  1120. // pageObj.grid.init('DETAIL', result.itemList);
  1121. }
  1122. };