ITP_RTNMNG03010.js 43 KB

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