ITP_RTNMNG03010.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  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: '14', 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: 110,
  101. width: '9', fixed: false, align: 'left',
  102. sortable: false, hidden: false, classes: 'ui-ellipsis'
  103. },
  104. {
  105. index: 'RTN_QTY', name: 'rtnQty',
  106. label: '반품수량',
  107. width: '9', 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: '6', fixed: false, align: 'center',
  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: '8', fixed: false, align: 'center',
  129. sortable: false, hidden: false
  130. },
  131. {
  132. index: 'COL_REQ_DT', name: 'colReqDt',
  133. label: '수거요청일',
  134. width: '8', fixed: false, align: 'center',
  135. sortable: false, hidden: false
  136. },
  137. {
  138. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  139. label: '반품사유',
  140. minwidth: 120,
  141. width: '7', fixed: false, align: 'left',
  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. var fromDate = new Date(now);
  412. fromDate.setDate(now.getDate() - 7);
  413. var toDate = new Date(now);
  414. toDate.setDate(now.getDate() + 5);
  415. $('#ITP_TAB_RTNMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  416. $('#ITP_FORM_RTNMNG03010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  417. $('#ITP_FORM_RTNMNG03010_SEARCH_TO_DT').datepicker('setDate', toDate);
  418. },
  419. grid: function() {
  420. itp_fn_jqgrid_resize(RTNMNG03010_GRID_ID, RTNMNG03010_GRID_LIST, 'lg');
  421. },
  422. ready: function() {
  423. listObj.init();
  424. }
  425. },
  426. action: function () {
  427. var _this = this;
  428. // 검색 반품장소
  429. $('#ITP_FORM_RTNMNG03010_SSEARCH_SWHS_NM').on('click', function() {
  430. _this.popup('SW');
  431. });
  432. // 검색 반품장소 텍스트 삭제 버튼 클릭
  433. $('#ITP_FORM_RTNMNG03010_SDELETE_SWHS_NM').on('click', function() {
  434. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_NM').val('');
  435. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_ID').val('');
  436. });
  437. // 상세 출하창고
  438. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').on('click', function() {
  439. _this.popup('SHW');
  440. });
  441. // 검색 납품장소 텍스트 삭제 버튼 클릭
  442. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').on('click', function() {
  443. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val('');
  444. $('#ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val('');
  445. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val('');
  446. });
  447. // 검색 공급사
  448. $('#ITP_FORM_RTNMNG03010_SSEARCH_SSPPLY_NM').on('click', function() {
  449. _this.popup('SS');
  450. });
  451. // 검색 텍스트 삭제 버튼 클릭
  452. $('#ITP_FORM_RTNMNG03010_SDELETE_SSPPLY_NM').on('click', function() {
  453. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_NM').val('');
  454. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_ID').val('');
  455. });
  456. // 검색 공급사
  457. $('#ITP_BTN_RTNMNG03010_NDETAIL_SPPLY_NM').on('click', function() {
  458. _this.popup('NS');
  459. });
  460. // 검색 텍스트 삭제 버튼 클릭
  461. $('#ITP_BTN_RTNMNG03010_SDELETE_SPPLY_NM').on('click', function() {
  462. var spplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  463. var records = $(RTNMNG03010_NDETAIL_GRID_ID).getGridParam('reccount')
  464. if (spplyId != '' && records != 0 ) {
  465. // 공급업체 삭제시 품목까지 삭제 처리되어집니다. 삭제 하시겠습니까?
  466. var delSpply = {
  467. callBack: function(args) {
  468. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val('');
  469. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val('');
  470. // 품목그리드삭제 처리
  471. pageObj.grid.clearData('NPC');
  472. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnDodrTotalAmt').text('');
  473. }
  474. };
  475. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.delAllItem, delSpply, null);
  476. } else {
  477. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val('');
  478. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val('')
  479. }
  480. });
  481. // 수거장소
  482. $('#ITP_BTN_RTNMNG03010_NDETAIL_SRH').on('click', function() {
  483. _this.popup('NHW');
  484. });
  485. // 수거장소 삭제 버튼 클릭
  486. $('#ITP_BTN_RTNMNG03010_NDETAIL_MODIFY').on('click', function() {
  487. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_NM').val('');
  488. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_ID').val('');
  489. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_LOCATION').val('');
  490. });
  491. },
  492. popup: function (arg) {
  493. var popFn ;
  494. // 팝업
  495. if (arg == "SW") {
  496. popFn = this.callback.searWhs;
  497. } else if (arg == "SS") {
  498. popFn = this.callback.searSpply;
  499. } else if (arg == "SHW") {
  500. popFn = this.callback.searchRtnWhs;
  501. } else if (arg == "NS") {
  502. popFn = this.callback.searNSpply;
  503. } else if (arg == "NHW") {
  504. popFn = this.callback.searNWhs;
  505. } else if (arg == "REJ") {
  506. popFn = this.callback.poRej;
  507. }
  508. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  509. if (arg == "SW" ) {
  510. const keya = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  511. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keya, 'S');
  512. } else if (arg == "SS" || arg == "NS" ) {
  513. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  514. } else if (arg == "SHW" || arg == "NHW") {
  515. const keyb = {brandId:fn_make_user_info.get('brandId'),storeId:"", whsDvsn:"W01"};
  516. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keyb, 'S');
  517. } else if (arg == "REJ" ) {
  518. /* 선택ROW가져오기 */
  519. const rowKey = $(RTNMNG03010_GRID_ID).getGridParam('selrow');
  520. if (!rowKey) {
  521. return;
  522. }
  523. var selectedIds = $(RTNMNG03010_GRID_ID).getGridParam('selarrrow');
  524. if(selectedIds.length > 1) { // 1개만 선택
  525. itp_fn_modal_alert("반품요청 반려대상에 대해 하나만 선택해주세요.") ;
  526. return;
  527. }
  528. var selRowData ;
  529. for (var i=selectedIds.length-1; i>=0; i--) {
  530. selRowData = $(RTNMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]);
  531. }
  532. const key1 = {rtnReqUnqNo:selRowData.rtnReqUnqNo, storeId:selRowData.storeId};
  533. fn_call_popup('biz', 'BIZPOP_RTN_PO_REJECT', '#ITP_ASIDE', popFn, key1, 'S');
  534. }
  535. },
  536. callback: {
  537. searWhs: function(rowDataPop) {
  538. if(rowDataPop) {
  539. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  540. $('#ITP_FORM_RTNMNG03010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  541. }
  542. },
  543. searSpply: function(rowDataPop) {
  544. if(rowDataPop) {
  545. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_NM').val(rowDataPop.spplyNm);
  546. $('#ITP_FORM_RTNMNG03010_SEARCH_SSPPLY_ID').val(rowDataPop.spplyId);
  547. }
  548. },
  549. searNSpply: function(rowDataPop) {
  550. if(rowDataPop) {
  551. var pspplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  552. console.log("1111");
  553. console.log(pspplyId);
  554. if (pspplyId == "") {
  555. console.log(rowDataPop);
  556. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val(rowDataPop.spplyNm);
  557. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val(rowDataPop.spplyId);
  558. // console.log(rowDataPop.spplyId);
  559. } else {
  560. var records = $(RTNMNG03010_NDETAIL_GRID_ID).getGridParam('reccount')
  561. if (records != 0) {
  562. if (pspplyId != rowDataPop.spplyId ) {
  563. itp_fn_modal_alert( "추가한 품목의 공급사와 서로 틀립니다 !");
  564. return ;
  565. }
  566. }
  567. }
  568. }
  569. },
  570. searchRtnWhs: function(rowDataPop) {
  571. if(rowDataPop) {
  572. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val(rowDataPop.whsNm + " - " + rowDataPop.locationNm);
  573. $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  574. $('#ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val(rowDataPop.location);
  575. }
  576. },
  577. searNWhs: function(rowDataPop) {
  578. if(rowDataPop) {
  579. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_NM').val(rowDataPop.whsNm + " - " + rowDataPop.locationNm);
  580. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_ID').val(rowDataPop.whsId);
  581. $('#ITP_FORM_RTNMNG03010_NDETAIL_RTN_LOCATION').val(rowDataPop.location);
  582. }
  583. },
  584. poRej: function(rowDataPop) {
  585. if(rowDataPop) {
  586. if (rowDataPop.retVal == "Y") {
  587. modifyObj.button.rejectSave(rowDataPop);
  588. }
  589. }
  590. }
  591. },
  592. event: {
  593. init: function () {
  594. this.button();
  595. },
  596. button: function () {
  597. // 버튼 클릭 이벤트
  598. $('button').each(function() {
  599. var id = $(this).attr('id');
  600. $(this).on('click', function() {
  601. switch (id) {
  602. case 'ITP_BTN_RTNMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  603. case 'ITP_BTN_RTNMNG03010_NEWCREATE' : listObj.button.chkpo(); break; // 반품발주생성 버튼
  604. case 'ITP_BTN_RTNMNG03010_POCREATE' : listObj.button.newpocreate(); break; // 반품신규생성 버튼
  605. case 'ITP_BTN_RTNMNG03010_POREJECT' : listObj.button.reject(); break; // 반려
  606. case 'ITP_BTN_RTNMNG03010_RTNPO' : modifyObj.button.save(); break; // 발주
  607. case 'ITP_BTN_RTNMNG03010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  608. case 'ITP_BTN_RTNMNG03010_NDETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 품목추가
  609. case 'ITP_BTN_RTNMNG03010_NDETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 품목삭제
  610. case 'ITP_BTN_RTNMNG03010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  611. }
  612. });
  613. });
  614. $('body').on('click', function(e) {
  615. var gridId = ((SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).replace('#', '');
  616. var rids = $( (SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  617. var last_row_id = rids[rids.length - 1];
  618. itp_fn_grid_reset_selection(e, last_row_id, gridId, (SCREEN_MODE === 'NPC') ? 'RTNMNG03010_NDETAIL' : 'RTNMNG03010_DETAIL');
  619. pageObj.grid.recal();
  620. });
  621. }
  622. },
  623. switchScreen: function(mode) {
  624. $('.itp_det_head').find('button[id^="ITP_BTN_RTNMNG03010_"]').each(function(i) {
  625. $(this).hide();
  626. });
  627. $('#ITP_TAB_RTNMNG03010').find('div[id$="_CONTAINER"]').each(function(i) {
  628. $(this).hide();
  629. });
  630. if(mode == 'LIST') { // 목록
  631. itp_fn_fire_window_resize();
  632. $('#ITP_AJAX_RTNMNG03010_LIST_CONTAINER').show();
  633. $('#ITP_FORM_RTNMNG03010_SDELETE_SSPPLY_NM').show();
  634. $('#ITP_FORM_RTNMNG03010_SDELETE_SWHS_NM').show();
  635. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_SRH', '#ITP_BTN_RTNMNG03010_NEWCREATE','#ITP_BTN_RTNMNG03010_POCREATE', '#ITP_BTN_RTNMNG03010_POREJECT']);
  636. // $('#ITP_FORM_RTNMNG03010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  637. // $('#ITP_FORM_RTNMNG03010_DETAIL_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  638. $('#ITP_BTN_RTNMNG03010_EXCEL').show();
  639. SCREEN_MODE = 'LIST' ;
  640. } else if(mode == 'NPC') { // 신규발주등록
  641. $('#ITP_AJAX_RTNMNG03010_NDETAIL_CONTAINER').show();
  642. $('#ITP_BTN_RTNMNG03010_SDELETE_SPPLY_NM').show();
  643. $('#ITP_BTN_RTNMNG03010_NDETAIL_MODIFY').show();
  644. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_RTNPO', '#ITP_BTN_RTNMNG03010_CANCELLIST', '#ITP_BTN_RTNMNG03010_NDETAIL_ADDROW','#ITP_BTN_RTNMNG03010_NDETAIL_DELROW']);
  645. $('#ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  646. SCREEN_MODE = 'NPC' ;
  647. pageObj.grid.init('NPC');
  648. } else if(mode == 'POC') { // 구매요청 발주
  649. $('#ITP_AJAX_RTNMNG03010_DETAIL_CONTAINER').show();
  650. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').show();
  651. fn_show_btn_auth_array(['#ITP_BTN_RTNMNG03010_RTNPO', '#ITP_BTN_RTNMNG03010_CANCELLIST']);
  652. $('#ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  653. $('#ITP_FORM_RTNMNG03010_DETAIL_STORE_ID').val(fn_make_user_info.get('storeId'));
  654. SCREEN_MODE = 'POC' ;
  655. }
  656. },
  657. grid: {
  658. init: function(mode, gridRows) {
  659. this.gridId = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID;
  660. this.gridList = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST;
  661. this.gridEmpty = (mode === 'NPC') ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY;
  662. this.gridRows = gridRows;
  663. this.unload();
  664. this.load(mode, gridRows);
  665. },
  666. gridId: '',
  667. button: {
  668. addRow: function() {
  669. // 팝업
  670. var popFn = function(rowDataPop) {
  671. // 기존등록 데이터
  672. var exists = '';
  673. const rowData = $(RTNMNG03010_NDETAIL_GRID_ID).getRowData();
  674. $.each(rowData, function(key, value) {
  675. if (value.viewCd != "D") {
  676. exists = exists + value.brandUnitUnqNo + ';';
  677. }
  678. });
  679. var diffchk = "N";
  680. var spplyId = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val();
  681. var spplyNm = $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val();
  682. // 넘어오는 데이타가 서로 상이한 공급업체인지 파악
  683. var chkSpplyId = "";
  684. var chkSpplyNm = "";
  685. $.each(rowDataPop, function(key, value) {
  686. if (chkSpplyId != "" ) {
  687. if (value.spplyId != chkSpplyId ) {
  688. itp_fn_modal_alert("서로다른 공급사 품목을 발주 진행 할 수 없습니다.");
  689. diffchk = "Y" ;
  690. return false ;
  691. }
  692. } else {
  693. chkSpplyId = value.spplyId;
  694. chkSpplyNm = value.spplyNm;
  695. }
  696. });
  697. if (diffchk == "Y") return;
  698. if (spplyId == "" ) {
  699. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val(chkSpplyId);
  700. $('#ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_NM').val(chkSpplyNm);
  701. } else {
  702. if (spplyId != chkSpplyId ) {
  703. itp_fn_modal_alert("납품 공급사와 품목 공급사 정보가 서로 다릅니다.");
  704. diffchk = "Y" ;
  705. }
  706. }
  707. if (diffchk == "Y") return;
  708. $.each(rowDataPop, function(key, value) {
  709. // 공급업체가 상이사면 오류 알럿 출력
  710. if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
  711. value['viewCd'] = "C";
  712. $(RTNMNG03010_NDETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
  713. }
  714. });
  715. $(RTNMNG03010_NDETAIL_GRID_EMPTY).hide();
  716. };
  717. const key = {brandId:fn_make_user_info.get('brandId')};
  718. console.log("key==",key);
  719. fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S'); // ==>dwkim 추후 작업 진행 파라메타 설명필요
  720. },
  721. delRow: function() {
  722. itp_fn_grid_del_row(RTNMNG03010_NDETAIL_GRID_ID);
  723. pageObj.grid.recal();
  724. }
  725. },
  726. gridList: '',
  727. gridEmpty: '',
  728. gridRows: '',
  729. load: function(mode, gridRows) {
  730. var _this = this;
  731. var option = {
  732. gridId: _this.gridId,
  733. colModel: (mode === 'NPC') ? gridColModel.ndetail : gridColModel.detail,
  734. data: gridRows,
  735. multiselect: (mode === 'NPC'),
  736. loadComplete: function(data) {
  737. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  738. data.records === 0 ? _this.clearData(mode) : $(_this.mode === 'NPC' ? _this.clearData(mode) : RTNMNG03010_DETAIL_GRID_EMPTY).hide();
  739. },
  740. onCellSelect: function(rowid, cellIdx, cellValue) {
  741. RTNMNG03010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, RTNMNG03010_GRID_LAST_ROW_ID, _this.gridId, ['pchReqDtlNo']);
  742. }
  743. };
  744. itp_fn_grid_make_local(option);
  745. },
  746. recal: function() {
  747. if (SCREEN_MODE == 'NPC' || SCREEN_MODE === 'POC') {
  748. var ids = $((SCREEN_MODE === 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).getDataIDs();
  749. $.each(ids, function(idx, rowId) {
  750. var viewCd = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'viewCd');
  751. var unitAmt = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  752. var rtnQty = jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'rtnQty');
  753. if(viewCd != 'D' && unitAmt != null && unitAmt != '' && rtnQty != null && rtnQty != '') {
  754. jQuery(SCREEN_MODE === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{rtnAmt: parseInt(unitAmt)*parseInt(rtnQty)});
  755. }
  756. });
  757. const rowData = $((SCREEN_MODE == 'NPC') ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).getRowData();
  758. var rtnAmt = 0 ;
  759. $.each(rowData, function(key, value) {
  760. if (value.rtnAmt != null && value.rtnAmt != "" && value.viewCd != "D") {
  761. rtnAmt = rtnAmt + parseInt(value.rtnAmt) ;
  762. }
  763. });
  764. if (SCREEN_MODE == 'NPC') {
  765. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(rtnAmt));
  766. } else {
  767. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(rtnAmt));
  768. }
  769. }
  770. },
  771. clearData : function(mode) {
  772. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_ID : RTNMNG03010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  773. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_LIST : RTNMNG03010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  774. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  775. $(mode === 'NPC' ? RTNMNG03010_NDETAIL_GRID_EMPTY : RTNMNG03010_DETAIL_GRID_EMPTY).show();
  776. },
  777. unload : function() {
  778. $.jgrid.gridUnload(this.gridId);
  779. }
  780. }
  781. };
  782. /*목록화면 Object*/
  783. let listObj = {
  784. init: function () {
  785. this.grid.init();
  786. },
  787. itp_RTNMNG03010_search: false,
  788. button: {
  789. search: function() {
  790. listObj.itp_RTNMNG03010_search = true;
  791. let param = $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject();
  792. param.gridSize = $.jgrid.defaults.rowNum;
  793. param.gridPage = $.jgrid.defaults.page;
  794. $(RTNMNG03010_GRID_ID).data('grid-param',param);
  795. $(RTNMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  796. },
  797. pocreate: function(param) {
  798. //pageObj.switchScreen('POC');
  799. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_DETAIL');
  800. modifyObj.init(param);
  801. },
  802. newpocreate: function() {
  803. pageObj.switchScreen('NPC');
  804. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_NDETAIL');
  805. createObj.init();
  806. },
  807. reject: function() {
  808. //팝업 오픈
  809. pageObj.popup('REJ');
  810. },
  811. chkpo: function() {
  812. let gridUpdateData = [];
  813. const rowKey = $(RTNMNG03010_GRID_ID).getGridParam('selrow');
  814. if (!rowKey) {
  815. itp_fn_modal_alert( "반품요청 품목을 선택하세요.");
  816. return;
  817. }
  818. var selectedIds = $(RTNMNG03010_GRID_ID).getGridParam('selarrrow');
  819. for (var i=selectedIds.length-1; i>=0; i--) {
  820. gridUpdateData.push($(RTNMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]));
  821. }
  822. let param = {};
  823. param.brandId=fn_make_user_info.get('brandId');
  824. param.gridUpdateData = gridUpdateData;
  825. var chkFn = function(result) {
  826. if (result.code == "Y") {
  827. //발수 생성화면으로 전화
  828. listObj.button.pocreate(param);
  829. }
  830. };
  831. fn_ajax_call(API_DETAIL_POPASS_CHK, JSON.stringify(param), chkFn, 'POST');
  832. },
  833. },
  834. empty: {
  835. init: function() {
  836. },
  837. itp_RTNMNG03010_param: {},
  838. push: function() {
  839. },
  840. back: function() {
  841. }
  842. },
  843. grid: {
  844. init: function () {
  845. // 데이터 없을때
  846. itp_fn_jqgrid_resize(RTNMNG03010_GRID_ID, RTNMNG03010_GRID_LIST, 'lg');
  847. itp_fn_fire_window_resize();
  848. this.search();
  849. },
  850. colModel: gridColModel.list,
  851. search: function() {
  852. pageObj.switchScreen('LIST');
  853. this.unload();
  854. this.load();
  855. },
  856. load: function() {
  857. let param = $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject();
  858. param.gridSize = $.jgrid.defaults.rowNum;
  859. var option = {
  860. multiselect: true,
  861. autowidth: true,
  862. gridId: RTNMNG03010_GRID_ID,
  863. colModel: gridColModel.list,
  864. param: param,
  865. url: DOMAIN + API_DETAIL_GRID_LIST,
  866. rownumbers: false,
  867. pager: RTNMNG03010_GRID_PAGER,
  868. loadComplete: function(data) {
  869. itp_fn_grid_load_complete(data, RTNMNG03010_GRID_ID, true, 'number', 'RTNMNG03010', listObj.itp_RTNMNG03010_search, listObj.empty, true, data.gridRecords, true);
  870. var ids = $(RTNMNG03010_GRID_ID).getDataIDs();
  871. $.each(ids, function(idx, rowId) {
  872. $(RTNMNG03010_GRID_ID).jqGrid('setCell', rowId, 'storeId', '', ITP_GRID_COL_STYLE.link);
  873. });
  874. },
  875. onPaging: function(action) {
  876. itp_fn_grid_paging(RTNMNG03010_GRID_ID, action, param);
  877. }
  878. };
  879. itp_fn_grid_make_remote(option);
  880. },
  881. button: {
  882. },
  883. unload : function() {
  884. $.jgrid.gridUnload(RTNMNG03010_GRID_ID);
  885. },
  886. clearData : function() {
  887. $(RTNMNG03010_GRID_ID).jqGrid('clearGridData', true);
  888. $(RTNMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  889. $(RTNMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  890. $(RTNMNG03010_GRID_EMPTY).show();
  891. }
  892. },
  893. excelDown: function() {
  894. var param = {
  895. 'url': API_DETAIL_GRID_LIST,
  896. 'param': $('#ITP_FORM_RTNMNG03010_SEARCH').serializeObject(),
  897. 'gridColumns': $(RTNMNG03010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  898. 'fileName': '반품발주대상정보.xlsx',
  899. 'sheetName': '반품발주대상리스트'
  900. };
  901. itp_fn_remote_to_excel(param);
  902. }
  903. };
  904. /*수정화면 Object*/
  905. let modifyObj = {
  906. init: function (param) {
  907. this.load(param);
  908. },
  909. button: {
  910. modify: function (param) {
  911. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_DETAIL');
  912. const selectVal = $('#ITP_FORM_RTNMNG03010_VIEW_STORE_ID').val();
  913. const key = {brandId:fn_make_user_info.get('brandId'), storeId: selectVal, viewCd: 'R'};
  914. var param = $.param(key);
  915. modifyObj.load(param);
  916. },
  917. cancel: function() {
  918. document.getElementById('ITP_FORM_RTNMNG03010_DETAIL').reset();
  919. document.getElementById('ITP_FORM_RTNMNG03010_NDETAIL').reset();
  920. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val('');
  921. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val('');
  922. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_SPPLY_ID').val('');
  923. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_WHS_ID').val('');
  924. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_LOCATION').val('');
  925. listObj.grid.search();
  926. },
  927. rejectSave: function(param) {
  928. var modalFn = {
  929. callBack: () => {
  930. var searhFn = function () {
  931. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  932. pageObj.grid.clearData();
  933. modifyObj.button.cancel();
  934. }
  935. fn_ajax_call(API_DETAIL_REJECT, param, searhFn, 'GET');
  936. }
  937. };
  938. itp_fn_modal_confirm('반품요청 반려 하시겠습니까?', modalFn);
  939. },
  940. save: function() {
  941. $('body').trigger('click');
  942. const formId = (SCREEN_MODE == 'NPC' ? '#ITP_FORM_RTNMNG03010_NDETAIL' : '#ITP_FORM_RTNMNG03010_DETAIL');
  943. itp_fn_form_clear_validate(null, formId);
  944. if (itp_fn_form_event.isValid(formId)) {
  945. if (SCREEN_MODE == 'NPC') {
  946. const rowData1 = $(RTNMNG03010_NDETAIL_GRID_ID).getRowData();
  947. var dataCnt = 0;
  948. $.each(rowData1, function(key, value) {
  949. if (value.viewCd != 'D') {
  950. dataCnt = dataCnt + 1;
  951. }
  952. });
  953. if (dataCnt == 0) {
  954. itp_fn_modal_alert( "발주 생성할 품목내역이 없습니다.");
  955. return ;
  956. }
  957. }
  958. var jobCd = "";
  959. if (SCREEN_MODE == 'NPC') {
  960. jobCd = $('#ITP_FORM_RTNMNG03010_NDETAIL_JOB_CD').val()
  961. } else {
  962. jobCd = $('#ITP_FORM_RTNMNG03010_DETAIL_JOB_CD').val()
  963. }
  964. var chkQtyYn = true;
  965. var chkQtyYn2 = true;
  966. const rowData2 = (SCREEN_MODE == 'NPC' ? $(RTNMNG03010_NDETAIL_GRID_ID).getRowData() : $(RTNMNG03010_DETAIL_GRID_ID).getRowData());
  967. $.each(rowData2, function(key, value) {
  968. if (value.rtnQty == '' || parseInt(value.rtnQty) < 1 ) {
  969. chkQtyYn = false;
  970. }
  971. if (jobCd == 'R' && parseInt(value.rtnQty) > parseInt(value.rtnReqQty) ) {
  972. chkQtyYn2 = false;
  973. }
  974. });
  975. if (chkQtyYn == false) {
  976. itp_fn_modal_alert("반품발주수량을 입력해주세요!");
  977. return;
  978. }
  979. if (chkQtyYn2 == false) {
  980. itp_fn_modal_alert("반품발주수량이 반품요청수량보다 클수 없습니다!");
  981. return;
  982. }
  983. //수거요처일
  984. var now = new Date();
  985. var today = now.getFullYear() +
  986. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  987. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  988. var colReqDt = '' ;
  989. if (SCREEN_MODE == 'NPC') {
  990. colReqDt = $('#ITP_FORM_RTNMNG03010_NDETAIL_COL_REQ_DT').val()
  991. } else {
  992. colReqDt = $('#ITP_FORM_RTNMNG03010_DETAIL_COL_REQ_DT').val()
  993. }
  994. if (today > colReqDt) {
  995. alert("수거요청일은 오늘 이후이어야 합니다.");
  996. return;
  997. }
  998. // 수거구분 값 가져오기
  999. var colDvsn = $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').val();
  1000. if (colDvsn == 'C001') {
  1001. var whsId = $('#ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val();
  1002. var location = $('ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val();
  1003. if (whsId == '' || location == '') {
  1004. itp_fn_modal_alert("반품입고창고를 선택해주세요!");
  1005. return;
  1006. }
  1007. }
  1008. var modalFn = {
  1009. callBack: () => {
  1010. if (SCREEN_MODE == 'NPC') {
  1011. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_NDETAIL');
  1012. } else {
  1013. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
  1014. }
  1015. let gridInsertData = [];
  1016. const rowData = (SCREEN_MODE == 'NPC' ? $(RTNMNG03010_NDETAIL_GRID_ID).getRowData() : $(RTNMNG03010_DETAIL_GRID_ID).getRowData());
  1017. $.each(rowData, function(key, value) {
  1018. gridInsertData.push(value);
  1019. });
  1020. if (SCREEN_MODE == 'POC') {
  1021. $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').attr("disabled", false);
  1022. }
  1023. let param = $(formId).serializeObject();
  1024. if (SCREEN_MODE == 'POC') {
  1025. $('#ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').attr("disabled", true);
  1026. }
  1027. param.gridInsertData = gridInsertData;
  1028. console.log( JSON.stringify(param));
  1029. var searhFn = function () {
  1030. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  1031. pageObj.grid.clearData();
  1032. modifyObj.button.cancel();
  1033. }
  1034. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  1035. }
  1036. };
  1037. itp_fn_modal_confirm('반품발주를 진행 하시겠습니까?', modalFn);
  1038. }
  1039. }
  1040. },
  1041. load: function(param) {
  1042. fn_ajax_call(API_DETAIL_PO_INIT_INFO, JSON.stringify(param), this.callback, 'POST');
  1043. },
  1044. callback: function (result) {
  1045. pageObj.switchScreen('POC');
  1046. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_VIEW_CD').val('C');
  1047. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_BRAND_ID').val(result.brandId);
  1048. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_STORE_ID').val(result.storeId);
  1049. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_REQ_DVSN').val(result.rtnReqDvsn);
  1050. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_SPPLY_ID').val(result.spplyId);
  1051. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_COL_REQ_DT').val(result.colReqDt);
  1052. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId);
  1053. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_LOCATION').val(result.rtnLocation);
  1054. //$('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_RTN_WHS_NM').val(result.rtnWhsNm);
  1055. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_COL_DVSN').val(result.colDvsn);
  1056. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_WHS_ID').val(result.whsId);
  1057. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_LOCATION').val(result.location);
  1058. $('#ITP_FORM_RTNMNG03010_DETAIL #ITP_FORM_RTNMNG03010_DETAIL_WHS_NM').val(result.whsNm);
  1059. $('#ITP_FORM_RTNMNG03010_DETAIL .fnBrandNm').text(result.brandNm);
  1060. $('#ITP_FORM_RTNMNG03010_DETAIL .fnSpplyNm').text(result.spplyNm);
  1061. $('#ITP_FORM_RTNMNG03010_DETAIL .fnPodrMgrNm').text(result.rtnMgrNm);
  1062. $('#ITP_FORM_RTNMNG03010_DETAIL .fnPodrMgrMblNo').text(result.rtnMgrTelNo);
  1063. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnDodrTotalAmt').text(itp_fn_number_comma(result.rtnDodrTotalAmt));
  1064. // TODO 수거장소
  1065. $('#ITP_FORM_RTNMNG03010_DETAIL .fnRtnWhsNme').text(result.rtnWhsNm);
  1066. if (result.colDvsn == 'C001') { //본사수거
  1067. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').attr("disabled", false);
  1068. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').attr("disabled", false);
  1069. } else {
  1070. $('#ITP_BTN_RTNMNG03010_DETAIL_SRH').attr("disabled", true);
  1071. $('#ITP_BTN_RTNMNG03010_DETAIL_MODIFY').attr("disabled", true);
  1072. }
  1073. // 품목 리스트 조회
  1074. pageObj.grid.init('POC', result.itemList);
  1075. },
  1076. whsPassQty: function(param) {
  1077. },
  1078. passQtyCallback: function (result) {
  1079. }
  1080. };
  1081. /*신규화면 Object*/
  1082. let createObj = {
  1083. init: function () {
  1084. $('#ITP_FORM_RTNMNG03010_NDETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  1085. itp_fn_form_clear_validate(null, '#ITP_FORM_RTNMNG03010_NDETAIL');
  1086. const key = {brandId:fn_make_user_info.get('brandId'), viewCd: 'R'};
  1087. var param = $.param(key);
  1088. createObj.load(param);
  1089. },
  1090. button: {
  1091. cancel: function() {
  1092. document.getElementById('ITP_FORM_RTNMNG03010_DETAIL').reset();
  1093. listObj.grid.search();
  1094. },
  1095. save: function() {
  1096. const formId = '#ITP_FORM_RTNMNG03010_DETAIL';
  1097. itp_fn_form_clear_validate(null, formId);
  1098. if (itp_fn_form_event.isValid(formId)) {
  1099. var modalFn = {
  1100. callBack: (args) => {
  1101. itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
  1102. let param = $(formId).serializeObject();
  1103. var searhFn = function () {
  1104. ITP_FORM_RTNMNG03010_DETAIL_IS_WRITING = false;
  1105. listObj.grid.search();
  1106. }
  1107. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  1108. }
  1109. };
  1110. itp_fn_modal_confirm('저장 하시겠습니까?', modalFn);
  1111. }
  1112. }
  1113. },
  1114. load: function(param) {
  1115. fn_ajax_call(API_DETAIL_NEW_INIT_INFO, param, this.callback, 'GET');
  1116. },
  1117. callback: function (result) {
  1118. //pageObj.switchScreen('NPC');
  1119. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_DETAIL_VIEW_CD').val('C');
  1120. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_BRAND_ID').val(result.brandId);
  1121. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_REQ_DVSN').val(result.rtnReqDvsn);
  1122. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_RTN_MGR_ID').val(result.rtnMgrId);
  1123. $('#ITP_FORM_RTNMNG03010_NDETAIL #ITP_FORM_RTNMNG03010_NDETAIL_COL_DVSN').val(result.colDvsn);
  1124. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnBrandNm').text(result.brandNm);
  1125. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrNm').text(result.rtnMgrNm);
  1126. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrTelNo').text(result.rtnMgrTelNo);
  1127. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnColDvsnNm').text(result.colDvsnNm);
  1128. $('#ITP_FORM_RTNMNG03010_NDETAIL .fnRtnMgrTelNo').text(result.rtnMgrTelNo);
  1129. var now = new Date();
  1130. $('#ITP_TAB_RTNMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  1131. $('#ITP_FORM_RTNMNG03010_NDETAIL_COL_REQ_DT').datepicker('setDate', new Date(now.setDate(now.getDate()+5)));
  1132. // 품목 리스트 조회
  1133. // pageObj.grid.init('DETAIL', result.itemList);
  1134. }
  1135. };