ITP_POMNG02010.js 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. /********************************************************
  8. --------------------------------------------------------
  9. - Object 목록 -
  10. --------------------------------------------------------
  11. * const gridColModel = {} : 화면 Grid Object *
  12. * let pageObj = {} : 화면공통 Object *
  13. * let listObj = {} : 목록화면 Object *
  14. * let viewObj = {} : 상세화면 Object *
  15. * let modifyObj = {} : 수정화면 Object *
  16. * let createObj = {} : 신규화면 Object *
  17. * let sfflyObj = {} : 공급업체담당자 Object *
  18. *******************************************************/
  19. /*화면 변수*/
  20. const POMNG02010_GRID_ID = '#ITP_POMNG02010_jqGrid';
  21. const POMNG02010_GRID_LIST = '#ITP_POMNG02010_jqGrid_list';
  22. const POMNG02010_GRID_PAGER = '#ITP_POMNG02010_jqGridPager';
  23. const POMNG02010_GRID_EMPTY = '#ITP_POMNG02010_jqGridEmpty';
  24. const POMNG02010_VIEW_GRID_ID = '#ITP_POMNG02010_VIEW_jqGrid';
  25. const POMNG02010_VIEW_GRID_LIST = '#ITP_POMNG02010_VIEW_jqGrid_list';
  26. const POMNG02010_VIEW_GRID_PAGER = '#ITP_POMNG02010_VIEW_jqGridPager';
  27. const POMNG02010_VIEW_GRID_EMPTY = '#ITP_POMNG02010_VIEW_jqGridEmpty';
  28. const POMNG02010_DETAIL_GRID_ID = '#ITP_POMNG02010_DETAIL_jqGrid';
  29. const POMNG02010_DETAIL_GRID_LIST = '#ITP_POMNG02010_DETAIL_jqGrid_list';
  30. const POMNG02010_DETAIL_GRID_PAGER = '#ITP_POMNG02010_DETAIL_jqGridPager';
  31. const POMNG02010_DETAIL_GRID_EMPTY = '#ITP_POMNG02010_DETAIL_jqGridEmpty';
  32. //let ITP_FORM_POMNG02010_DETAIL_IS_DUPLICATE = false;
  33. let ITP_FORM_POMNG02010_DETAIL_IS_WRITING = false;
  34. let POMNG02010_GRID_LAST_ROW_ID;
  35. let SCREEN_MODE;
  36. //let ITP_COMMON_ASSGN_TASK = fn_make_common_cd_list(CODE_LIST, 'ASSGN_TASK', true, '담당업무');
  37. /*API URL*/
  38. let API_DETAIL_GRID_LIST = '/api/pomng/detail-grid-list'; // 목록
  39. let API_DETAIL_INFO = '/api/pomng/info-pchReq'; // 상세
  40. let API_DETAIL_SAVE = '/api/pomng/save-pchReq'; // 저장
  41. //let API_INTI_PW = '/api/spply/inti-spplyPw'; // 패스워드 초기화
  42. //let API_POP_GRID_LIST = '/api/spply/pop-grid-list'; // 공급사 팝업 그리드 리스트
  43. /*화면 Grid ColModel*/
  44. const gridColModel = {
  45. list: [
  46. {
  47. index: 'BRAND_ID', name: 'brandId',
  48. label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
  49. width: '10', fixed: false, align: 'center',
  50. sortable: false, hidden: true
  51. },
  52. {
  53. index: 'BRAND_NM', name: 'brandNm',
  54. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  55. width: '13', fixed: false, align: 'left',
  56. minwidth: 120,
  57. sortable: false, hidden: false, classes: 'ui-ellipsis'
  58. },
  59. {
  60. index: 'STORE_ID', name: 'storeId',
  61. label: ITP_MSG_LOCALE.label.storeId, //매장아이디
  62. width: '13', fixed: false, align: 'center',
  63. sortable: false, hidden: true
  64. },
  65. {
  66. index: 'REQ_TYPE_NM', name: 'reqTypeNm',
  67. label: ITP_MSG_LOCALE.label.reqTypeNm, //요청구분
  68. width: '7', fixed: false, align: 'center',
  69. sortable: false, hidden: false
  70. },
  71. {
  72. index: 'PCH_REQ_UNQ_NO', name: 'pchReqUnqNo',
  73. label: ITP_MSG_LOCALE.label.pchReqUnqNo, //구매요청번호
  74. width: '10', fixed: false, align: 'center',
  75. minwidth: 120,
  76. sortable: false, hidden: false
  77. },
  78. {
  79. index: 'PCH_REQ_NM', name: 'pchReqNm',
  80. label: ITP_MSG_LOCALE.label.pchReqNm, //구매요청명
  81. width: '13', fixed: false, align: 'left',
  82. minwidth: 180,
  83. sortable: false, hidden: false, classes: 'ui-ellipsis'
  84. },
  85. {
  86. index: 'PCH_REQ_ST_CD', name: 'pchReqStCd',
  87. label: ITP_MSG_LOCALE.label.pchReqStCd, //구매요청상태
  88. width: '15', fixed: false, align: 'center',
  89. sortable: false, hidden: true
  90. },
  91. {
  92. index: 'PCH_REQ_ST_NM', name: 'pchReqStNm',
  93. label: ITP_MSG_LOCALE.label.pchReqStNm, //구매요청상태명
  94. width: '9', fixed: false, align: 'center',
  95. sortable: false, hidden: false
  96. },
  97. {
  98. index: 'PCH_REQ_DT', name: 'pchReqDt',
  99. label: ITP_MSG_LOCALE.label.pchReqDt, //구매요청일
  100. width: '10', fixed: false, align: 'center',
  101. minwidth: 100,
  102. sortable: false, hidden: false
  103. },
  104. {
  105. index: 'PCH_REQ_ITEM_QTY', name: 'pchReqItemQty',
  106. label: ITP_MSG_LOCALE.label.pchReqItemQty, //요청품목수
  107. width: '12', fixed: false, align: 'right',
  108. sortable: false, hidden: false,
  109. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  110. },
  111. {
  112. index: 'PCH_REQ_TOTAL_AMT', name: 'pchReqTotalAmt',
  113. label: ITP_MSG_LOCALE.label.pchReqTotalAmt, //요청금액
  114. width: '12', fixed: false, align: 'right',
  115. sortable: false, hidden: false,
  116. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  117. },
  118. {
  119. index: 'PCH_REQ_RJCT_DT', name: 'pchReqRjctDt',
  120. label: ITP_MSG_LOCALE.label.pchReqRjctDt, //반려일자
  121. width: '11', fixed: false, align: 'center',
  122. sortable: false, hidden: false
  123. },
  124. {
  125. index: 'PCH_REQ_RJCT_NM', name: 'pchReqRjctNm',
  126. label: ITP_MSG_LOCALE.label.pchReqRjctNm, //반려자
  127. width: '10', fixed: false, align: 'center',
  128. sortable: false, hidden: false
  129. },
  130. {
  131. index: 'PCH_REQ_MGR_NM', name: 'pchReqMgrNm',
  132. label: ITP_MSG_LOCALE.label.pchReqMgrNm, //구매요청자명
  133. width: '11', fixed: false, align: 'center',
  134. sortable: false, hidden: false
  135. },
  136. {
  137. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  138. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  139. width: '10', fixed: false, align: 'center',
  140. minwidth: 100,
  141. sortable: false, hidden: false
  142. },
  143. {
  144. index: 'WHS_LOCATION_NM', name: 'whsLocationNm',
  145. label: ITP_MSG_LOCALE.label.whsLocationNm, //납품창고
  146. width: '10', fixed: false, align: 'left',
  147. minwidth: 180,
  148. sortable: false, hidden: false, classes: 'ui-ellipsis'
  149. }
  150. ],
  151. detail: [
  152. {
  153. index: 'VIEW_CD', name: 'viewCd',
  154. label: ITP_MSG_LOCALE.label.viewCd,
  155. width: '10', fixed: false, align: 'center',
  156. sortable: false, hidden: true
  157. },
  158. {
  159. index: 'PCH_REQ_UNQ_NO', name: 'pchReqUnqNo',
  160. label: ITP_MSG_LOCALE.label.pchReqUnqNo
  161. , //구매요청번호
  162. width: '10', fixed: false, align: 'center',
  163. sortable: false, hidden: true
  164. },
  165. {
  166. index: 'PCH_REQ_Dtl_NO', name: 'pchReqDtlNo',
  167. label: ITP_MSG_LOCALE.label.pchReqDtlNo
  168. , //구매요청상세번호
  169. width: '10', fixed: false, align: 'center',
  170. sortable: false, hidden: true
  171. },
  172. {
  173. index: 'ITEM_ID', name: 'itemId',
  174. label: ITP_MSG_LOCALE.label.itemId,
  175. width: '20', fixed: false, align: 'center',
  176. sortable: false, editable: false, edittype: 'text',
  177. editrules: { required: true }
  178. },
  179. {
  180. index: 'ITEM_NM', name: 'itemNm',
  181. label: ITP_MSG_LOCALE.label.itemNm,
  182. width: '30', fixed: false, align: 'left',
  183. sortable: true, editable: false, edittype: 'text',
  184. editrules: { required: true }
  185. },
  186. {
  187. index: 'UNIT', name: 'unit',
  188. label: ITP_MSG_LOCALE.label.unit,
  189. width: '10', fixed: false, align: 'center',
  190. sortable: false, editable: false, edittype: 'text'
  191. },
  192. {
  193. index: 'UNIT_AMT', name: 'unitAmt',
  194. label: ITP_MSG_LOCALE.label.unitAmt,
  195. width: '10', fixed: false, align: 'right',
  196. sortable: false, editable: false, edittype: 'text', hidden: false,
  197. formatter:'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  198. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');"}
  199. },
  200. {
  201. index: 'PCH_REQ_QTY', name: 'pchReqQty',
  202. label: ITP_MSG_LOCALE.label.pchReqQty, //단가
  203. width: '10', fixed: false, align: 'right',
  204. classes: 'input_color',
  205. sortable: true, editable: true, edittype: 'text',
  206. editrules: {required: true, number:true},
  207. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  208. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');"}
  209. },
  210. {
  211. index: 'PCH_REQ_AMT', name: 'pchReqAmt',
  212. label: ITP_MSG_LOCALE.label.pchReqAmt,
  213. width: '10', fixed: false, align: 'right',
  214. sortable: false, editable: false, edittype: 'text', hidden: false,
  215. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  216. },
  217. {
  218. index: 'PCH_REQ_DTL_ST_NM', name: 'pchReqDtlStNm',
  219. label: ITP_MSG_LOCALE.label.pchReqDtlStNm,
  220. width: '10', fixed: false, align: 'center',
  221. sortable: false, editable: false, edittype: 'text', hidden: false
  222. },
  223. {
  224. index: 'PCH_REQ_DTL_ST_CD', name: 'pchReqDtlStCd',
  225. label: ITP_MSG_LOCALE.label.pchReqDtlStNm,
  226. width: '10', fixed: false, align: 'right',
  227. sortable: false, editable: false, edittype: 'text', hidden: true
  228. },
  229. {
  230. index: 'BRAND_UNIT_UNQ_NO', name: 'brandUnitUnqNo',
  231. label: ITP_MSG_LOCALE.label.brandUnitUnqNo,
  232. width: '10', fixed: false, align: 'center',
  233. sortable: false, editable: false, edittype: 'text', hidden: true
  234. },
  235. {
  236. index: 'STORE_UNIT_UNQ_NO', name: 'storeUnitUnqNo',
  237. label: ITP_MSG_LOCALE.label.storeUnitUnqNo,
  238. width: '10', fixed: false, align: 'center',
  239. sortable: false, editable: false, edittype: 'text', hidden: true
  240. },
  241. {
  242. index: 'UNIT_GUBUN', name: 'unitGubun',
  243. label: ITP_MSG_LOCALE.label.unitGubun,
  244. width: '10', fixed: false, align: 'center',
  245. sortable: false, editable: false, edittype: 'text', hidden: true
  246. }
  247. ]
  248. };
  249. /*화면공통 Object*/
  250. let pageObj = {
  251. init: function () {
  252. this.ui.init();
  253. this.event.init();
  254. this.action();
  255. },
  256. itp_POMNG02010_param: {},
  257. itp_POMNG02010_search: false,
  258. ui: {
  259. init: function () {
  260. this.view();
  261. //this.form();
  262. this.grid();
  263. this.ready();
  264. },
  265. view: function() {
  266. // 버튼 권한설정
  267. fn_proc_btn_auth('POMNG02010');
  268. // 공통코드 표시
  269. $('select').each(function() {
  270. if($(this).data('select-code')) {
  271. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  272. }
  273. });
  274. var now = new Date();
  275. $('#ITP_TAB_POMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  276. $('#ITP_FORM_POMNG02010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setDate(now.getDate()-30)));
  277. $('#ITP_FORM_POMNG02010_SEARCH_TO_DT').datepicker('setDate', new Date(now.setDate(now.getDate()+30)));
  278. },
  279. /*
  280. form: function() {
  281. itp_fn_form_event.onKeyup('#ITP_FORM_POMNG02010_DETAIL');
  282. },
  283. */
  284. grid: function() {
  285. itp_fn_jqgrid_resize(POMNG02010_GRID_ID, POMNG02010_GRID_LIST, 'lg');
  286. },
  287. ready: function() {
  288. listObj.init();
  289. }
  290. },
  291. action: function () {
  292. var _this = this;
  293. // 납품장소 조회 버튼 클릭
  294. $('#ITP_FORM_POMNG02010_SSEARCH_SWHS_NM').on('click', function() {
  295. console.log("=================================");
  296. _this.popup('S');
  297. });
  298. // 납품장소 텍스트 삭제 버튼 클릭
  299. $('#ITP_FORM_POMNG02010_SDELETE_SWHS_NM').on('click', function() {
  300. console.log("=================================");
  301. $('#ITP_FORM_POMNG02010_SEARCH_SWHS_NM').val('');
  302. $('#ITP_FORM_POMNG02010_SEARCH_SWHS_ID').val('');
  303. });
  304. // 수정 화면에서의 납품장소 조회 버튼 클릭
  305. $('#ITP_FORM_POMNG02010_SEARCH_WHS_NM').on('click', function() {
  306. console.log("=================================");
  307. _this.popup('U');
  308. });
  309. // 납품장소 텍스트 삭제 버튼 클릭
  310. $('#ITP_FORM_POMNG02010_DELETE_WHS_NM').on('click', function() {
  311. console.log("=================================");
  312. $('#ITP_FORM_POMNG02010_DETAIL_WHS_NM').val('');
  313. $('#ITP_FORM_POMNG02010_DETAIL_WHS_ID').val('');
  314. $('#ITP_FORM_POMNG02010_DETAIL_LOCATION_NM').val('');
  315. $('#ITP_FORM_POMNG02010_DETAIL_LOCATION').val('');
  316. });
  317. },
  318. popup: function (arg) {
  319. var popFn ;
  320. // 팝업
  321. var whsDvsn = "";
  322. if (arg == "S") {
  323. popFn = this.callback.create;
  324. if (fn_make_user_info.get('storeId') == '' ) {
  325. whsDvsn = "";
  326. } else {
  327. whsDvsn = "W02";
  328. }
  329. } else {
  330. popFn = this.callback.modify;
  331. if (fn_make_user_info.get('storeId') == '' ) {
  332. whsDvsn = "W01";
  333. } else {
  334. whsDvsn = "W02";
  335. }
  336. }
  337. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn: whsDvsn};
  338. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  339. },
  340. callback: {
  341. create: function(rowDataPop) {
  342. console.log(rowDataPop);
  343. if(rowDataPop) {
  344. $('#ITP_FORM_POMNG02010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  345. $('#ITP_FORM_POMNG02010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  346. }
  347. },
  348. modify: function(rowDataPop) {
  349. console.log(rowDataPop);
  350. if(rowDataPop) {
  351. $('#ITP_FORM_POMNG02010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  352. $('#ITP_FORM_POMNG02010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  353. $('#ITP_FORM_POMNG02010_DETAIL_LOCATION_NM').val(rowDataPop.locationNm);
  354. $('#ITP_FORM_POMNG02010_DETAIL_LOCATION').val(rowDataPop.location);
  355. }
  356. }
  357. },
  358. event: {
  359. init: function () {
  360. this.button();
  361. },
  362. button: function () {
  363. // 버튼 클릭 이벤트
  364. $('button').each(function() {
  365. var id = $(this).attr('id');
  366. $(this).on('click', function() {
  367. switch (id) {
  368. case 'ITP_BTN_POMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  369. //case 'ITP_BTN_POMNG02010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  370. case 'ITP_BTN_POMNG02010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  371. case 'ITP_BTN_POMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  372. case 'ITP_BTN_POMNG02010_REQ' : modifyObj.button.save("PR20"); break; // 구매요청
  373. case 'ITP_BTN_POMNG02010_SAVE' : modifyObj.button.save("PR00"); break; // 임시저장
  374. case 'ITP_BTN_POMNG02010_DETAIL_ADDROW' : pageObj.grid.button.addRow(); break; // 품목추가
  375. case 'ITP_BTN_POMNG02010_DETAIL_DELROW' : pageObj.grid.button.delRow(); break; // 품목삭제
  376. case 'ITP_BTN_POMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드 버튼
  377. }
  378. });
  379. });
  380. $('body').on('click', function(e) {
  381. var gridId = POMNG02010_DETAIL_GRID_ID.replace('#', '');
  382. var rids = $(POMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  383. var last_row_id = rids[rids.length - 1];
  384. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'POMNG02010_DETAIL');
  385. pageObj.grid.recal();
  386. });
  387. }
  388. },
  389. switchScreen: function(mode) {
  390. $('.itp_det_head').find('button[id^="ITP_BTN_POMNG02010_"]').each(function(i) {
  391. $(this).hide();
  392. });
  393. $('#ITP_TAB_POMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  394. $(this).hide();
  395. });
  396. if(mode == 'LIST') { // 목록
  397. itp_fn_fire_window_resize();
  398. fn_show_btn_auth_array(['#ITP_BTN_POMNG02010_SRH', '#ITP_BTN_POMNG02010_NEWREG']);
  399. $('#ITP_AJAX_POMNG02010_LIST_CONTAINER').show();
  400. $('#ITP_FORM_POMNG02010_DETAIL_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  401. $('#ITP_FORM_POMNG02010_DETAIL_SSTORE_ID').val(fn_make_user_info.get('storeId'));
  402. $('#ITP_BTN_POMNG02010_EXCEL').show();
  403. SCREEN_MODE = 'LIST' ;
  404. } else if(mode == 'ADD') { // 등록
  405. fn_show_btn_auth_array(['#ITP_BTN_POMNG02010_CANCELLIST', '#ITP_BTN_POMNG02010_SAVE']);
  406. $('#ITP_AJAX_POMNG02010_DETAIL_CONTAINER').show();
  407. $('#ITP_FORM_POMNG02010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  408. $(this).attr('id') === 'ITP_FORM_POMNG02010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  409. if(elem.type === 'select') {
  410. $(this).val('').prop('selected', true);
  411. }
  412. });
  413. SCREEN_MODE = 'DETAIL' ;
  414. } else if(mode == 'MODIFY') { // 수정
  415. fn_show_btn_auth_array(['#ITP_BTN_POMNG02010_CANCELLIST', '#ITP_BTN_POMNG02010_SAVE', '#ITP_BTN_POMNG02010_REQ']);
  416. $('#ITP_AJAX_POMNG02010_DETAIL_CONTAINER').show();
  417. $('#ITP_FORM_POMNG02010_DETAIL .itp_form_info').show();
  418. $('#ITP_FORM_POMNG02010_DETAIL .itp_form_change').hide();
  419. SCREEN_MODE = 'DETAIL' ;
  420. } else if(mode == 'VIEW') { // 보기
  421. fn_show_btn_auth_array(['#ITP_BTN_POMNG02010_MODIFY', '#ITP_BTN_POMNG02010_CANCELLIST']);
  422. $('#ITP_AJAX_POMNG02010_VIEW_CONTAINER').show();
  423. SCREEN_MODE = 'VIEW' ;
  424. }
  425. },
  426. grid: {
  427. init: function(mode, gridRows) {
  428. console.log(mode);
  429. this.gridId = (mode === 'VIEW') ? POMNG02010_VIEW_GRID_ID : POMNG02010_DETAIL_GRID_ID;
  430. this.gridList = (mode === 'VIEW') ? POMNG02010_VIEW_GRID_LIST : POMNG02010_DETAIL_GRID_LIST;
  431. this.gridEmpty = (mode === 'VIEW') ? POMNG02010_VIEW_GRID_EMPTY : POMNG02010_DETAIL_GRID_EMPTY;
  432. this.gridRows = gridRows;
  433. this.unload();
  434. this.load(mode, gridRows);
  435. },
  436. gridId: '',
  437. gridList: '',
  438. gridEmpty: '',
  439. gridRows: '',
  440. button: {
  441. addRow: function() {
  442. // 팝업
  443. var popFn = function(rowDataPop) {
  444. console.log(rowDataPop);
  445. // 기존등록 데이터
  446. var exists = '';
  447. const rowData = $(POMNG02010_DETAIL_GRID_ID).getRowData();
  448. $.each(rowData, function(key, value) {
  449. if (value.viewCd != "D") {
  450. exists = exists + value.brandUnitUnqNo + ';';
  451. }
  452. });
  453. $.each(rowDataPop, function(key, value) {
  454. if (exists.indexOf(value.brandUnitUnqNo) < 0 && value.podrPssblDvsn == 'PO01') {
  455. value['viewCd'] = "C";
  456. $(POMNG02010_DETAIL_GRID_ID).jqGrid('addRowData', value.brandUnitUnqNo, value, 'last');
  457. }
  458. });
  459. $(POMNG02010_DETAIL_GRID_EMPTY).hide();
  460. };
  461. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  462. fn_call_popup('biz', 'BIZPOP_ITEM', '#ITP_ASIDE', popFn, key, 'S'); // ==>dwkim 추후 작업 진행 파라메타 설명필요
  463. },
  464. delRow: function() {
  465. itp_fn_grid_del_row(POMNG02010_DETAIL_GRID_ID);
  466. pageObj.grid.recal();
  467. }
  468. },
  469. load: function(mode, gridRows) {
  470. var _this = this;
  471. var option = {
  472. gridId: _this.gridId,
  473. colModel: gridColModel.detail,
  474. data: gridRows,
  475. //cellEdit: (mode !== 'VIEW'),
  476. loadComplete: function(data) {
  477. //console.log(data);
  478. //$(_this.gridList).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  479. //(Array.isArray(data.rows) && data.rows.length === 0) ? $(_this.gridEmpty).show() : $(_this.gridEmpty).hide();
  480. $(_this.mode === 'VIEW' ? POMNG02010_VIEW_GRID_LIST : POMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
  481. data.records === 0 ? _this.clearData() : $(_this.mode === 'VIEW' ? POMNG02010_VIEW_GRID_EMPTY : POMNG02010_DETAIL_GRID_EMPTY).hide();
  482. },
  483. onCellSelect: function(rowid, cellIdx, cellValue) {
  484. if(mode !== 'VIEW') {
  485. POMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, POMNG02010_GRID_LAST_ROW_ID, POMNG02010_DETAIL_GRID_ID, ['pchReqUnqNo']);
  486. }
  487. }
  488. };
  489. itp_fn_grid_make_local(option);
  490. },
  491. recal: function() {
  492. console.log("recal call");
  493. if (SCREEN_MODE === 'DETAIL') {
  494. var ids = $(POMNG02010_DETAIL_GRID_ID).getDataIDs();
  495. $.each(ids, function(idx, rowId) {
  496. console.log("recal start");
  497. var viewCd = jQuery(POMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'viewCd');
  498. var unitAmt = jQuery(POMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  499. var pchReqQty = jQuery(POMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'pchReqQty');
  500. if(viewCd != 'D' && unitAmt != null && unitAmt != '' && pchReqQty != null && pchReqQty != '') {
  501. jQuery(POMNG02010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{pchReqAmt: parseInt(unitAmt)*parseInt(pchReqQty)});
  502. }
  503. });
  504. const rowData = $(POMNG02010_DETAIL_GRID_ID).getRowData();
  505. var pchReqAmt = 0 ;
  506. $.each(rowData, function(key, value) {
  507. // console.log(JSON.stringify(rowData));
  508. if (value.pchReqAmt != null && value.pchReqAmt != "" && value.viewCd != "D") {
  509. pchReqAmt = pchReqAmt + parseInt(value.pchReqAmt) ;
  510. }
  511. });
  512. $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqTotalAmt').text(itp_fn_number_comma(pchReqAmt));
  513. }
  514. },
  515. clearData : function() {
  516. $(this.gridId).jqGrid('clearGridData', true);
  517. $(this.mode === 'VIEW' ? POMNG02010_VIEW_GRID_LIST : POMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  518. $(this.mode === 'VIEW' ? POMNG02010_VIEW_GRID_EMPTY : POMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  519. $(this.mode === 'VIEW' ? POMNG02010_VIEW_GRID_EMPTY : POMNG02010_DETAIL_GRID_EMPTY).show();
  520. },
  521. unload : function() {
  522. $.jgrid.gridUnload(this.gridId);
  523. }
  524. }
  525. };
  526. /*목록화면 Object*/
  527. let listObj = {
  528. init: function () {
  529. this.grid.init();
  530. },
  531. itp_POMNG02010_search: false,
  532. button: {
  533. search: function() {
  534. listObj.itp_POMNG02010_search = true;
  535. let param = $('#ITP_FORM_POMNG02010_SEARCH').serializeObject();
  536. param.gridSize = $.jgrid.defaults.rowNum;
  537. param.gridPage = $.jgrid.defaults.page;
  538. console.log(param);
  539. $(POMNG02010_GRID_ID).data('grid-param',param);
  540. $(POMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  541. },
  542. create: function() {
  543. if(!fn_make_user_info.isEmpty()) {
  544. //createObj.init();
  545. }
  546. }
  547. },
  548. empty: {
  549. init: function() {
  550. },
  551. itp_POMNG02010_param: {},
  552. push: function() {
  553. },
  554. back: function() {
  555. }
  556. },
  557. grid: {
  558. init: function () {
  559. // 데이터 없을때
  560. //itp_fn_jqgrid_resize(POMNG02010_GRID_ID, POMNG02010_GRID_LIST, 'lg');
  561. //itp_fn_fire_window_resize();
  562. //this.reload();
  563. this.search();
  564. },
  565. colModel: gridColModel.list,
  566. search: function() {
  567. pageObj.switchScreen('LIST');
  568. this.unload();
  569. this.load();
  570. },
  571. load: function() {
  572. let param = $('#ITP_FORM_POMNG02010_SEARCH').serializeObject();
  573. param.gridSize = $.jgrid.defaults.rowNum;
  574. param.sbrandId = fn_make_user_info.get('brandId');
  575. param.sstoreId = fn_make_user_info.get('storeId');
  576. var option = {
  577. gridId: POMNG02010_GRID_ID,
  578. colModel: gridColModel.list,
  579. //autowidth: true,
  580. //shrinkToFit:false,
  581. param: param,
  582. url: DOMAIN + API_DETAIL_GRID_LIST,
  583. pager: POMNG02010_GRID_PAGER,
  584. rownumbers: false,
  585. onCellSelect: function(rowId, cellIdx, cellValue) {
  586. var cm = $(this).jqGrid('getGridParam', 'colModel');
  587. var colNm = cm[cellIdx].name;
  588. if (colNm == 'pchReqUnqNo') {
  589. const selectVal = $(this).jqGrid('getCell', rowId, 'pchReqUnqNo');
  590. const key = {brandId:fn_make_user_info.get('brandId'), pchReqUnqNo: selectVal, viewCd: 'R'};
  591. var param = $.param(key);
  592. viewObj.init(param);
  593. }
  594. },
  595. loadComplete: function(data) {
  596. console.log(data);
  597. itp_fn_grid_load_complete(data, POMNG02010_GRID_ID, true, 'number', 'POMNG02010', listObj.itp_POMNG02010_search, listObj.empty, true, data.gridRecords, true);
  598. var ids = $(POMNG02010_GRID_ID).getDataIDs();
  599. $.each(ids, function(idx, rowId) {
  600. $(POMNG02010_GRID_ID).jqGrid('setCell', rowId, 'pchReqUnqNo', '', ITP_GRID_COL_STYLE.link);
  601. });
  602. },
  603. onPaging: function(action) {
  604. /*
  605. var pagingFn = {
  606. callBack: function(args) {
  607. $(args).trigger('reloadGrid');
  608. }
  609. };
  610. if (itp_fn_check_grid_is_writing(POMNG02010_DETAIL_GRID_ID)) {
  611. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.cancelData, pagingFn, POMNG02010_DETAIL_GRID_ID);
  612. return 'stop';
  613. } else {
  614. itp_fn_grid_paging(POMNG02010_DETAIL_GRID_ID, action, param);
  615. }
  616. */
  617. itp_fn_grid_paging(POMNG02010_GRID_ID, action, param);
  618. }
  619. };
  620. itp_fn_grid_make_remote(option);
  621. },
  622. /*
  623. reload : function() {
  624. var _this = this;
  625. $(POMNG02010_GRID_EMPTY).off('click').on('click', function() {
  626. pageObj.itp_OPER03010_param.gridSize = $.jgrid.defaults.rowNum;
  627. $(POMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(pageObj.itp_POMNG02010_param)}).trigger('reloadGrid');
  628. });
  629. },
  630. */
  631. clearData : function() {
  632. $(POMNG02010_GRID_ID).jqGrid('clearGridData', true);
  633. $(POMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  634. $(POMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  635. $(POMNG02010_GRID_EMPTY).show();
  636. },
  637. unload : function() {
  638. $.jgrid.gridUnload(POMNG02010_GRID_ID);
  639. }
  640. },
  641. excelDown: function() {
  642. var param = {
  643. 'url': API_DETAIL_GRID_LIST,
  644. 'param': $('#ITP_FORM_POMNG02010_SEARCH').serializeObject(),
  645. 'gridColumns': $(POMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  646. 'fileName': '구매요청현황.xlsx',
  647. 'sheetName': '구매요청리스트'
  648. };
  649. itp_fn_remote_to_excel(param);
  650. }
  651. };
  652. /*상세화면 Object*/
  653. let viewObj = {
  654. init: function (param) {
  655. this.load(param);
  656. },
  657. load: function(param) {
  658. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  659. },
  660. callback: function (result) {
  661. console.log(result);
  662. pageObj.switchScreen('VIEW');
  663. $('#ITP_FORM_POMNG02010_VIEW #ITP_FORM_POMNG02010_VIEW_PCH_REQ_UNQ_NO').val(result.pchReqUnqNo);
  664. $('#ITP_FORM_POMNG02010_VIEW #ITP_FORM_POMNG02010_VIEW_PCH_REQ_MGR_ID').val(result.pchReqMgrId);
  665. $('#ITP_FORM_POMNG02010_VIEW #ITP_FORM_POMNG02010_VIEW_PCH_REQ_ST_CD').val(result.pchReqStCd);
  666. $('#ITP_FORM_POMNG02010_VIEW .fnBrandNm').text(result.brandNm);
  667. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqUnqNo').text(result.pchReqUnqNo);
  668. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqNm').text(result.pchReqNm);
  669. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqStNm').text(result.pchReqStNm);
  670. $('#ITP_FORM_POMNG02010_VIEW .pchReqMgrNm').text(result.pchReqMgrNm);
  671. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqTotalAmt').text(itp_fn_number_comma(result.pchReqTotalAmt));
  672. $('#ITP_FORM_POMNG02010_VIEW .fnDlvReqDt').text(result.dlvReqDt);
  673. $('#ITP_FORM_POMNG02010_VIEW .fnWhsNm').text(result.whsNm + " - " + result.locationNm);
  674. $('#ITP_FORM_POMNG02010_VIEW .fnLoanDvsnNm').text(result.loanDvsnNm);
  675. $('#ITP_FORM_POMNG02010_VIEW .fnOrdUseAmt').text(itp_fn_number_comma(result.ordUseAmt));
  676. $('#ITP_FORM_POMNG02010_VIEW .fnNote').text(result.note);
  677. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqRjctDt').text(result.pchReqRjctDt);
  678. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqRjctNm').text(result.pchReqRjctNm);
  679. $('#ITP_FORM_POMNG02010_VIEW .fnPchReqRjctRsn').text(result.pchReqRjctRsn);
  680. // 품목 리스트 조회
  681. pageObj.grid.init('VIEW', result.pchReqDtlList);
  682. }
  683. };
  684. /*수정화면 Object*/
  685. let modifyObj = {
  686. init: function (param) {
  687. pageObj.grid.init('DETAIL', []);
  688. //this.load(param);
  689. },
  690. button: {
  691. modify: function (param) {
  692. itp_fn_form_clear_validate(null, '#ITP_FORM_POMNG02010_DETAIL');
  693. const selectVal = $('#ITP_FORM_POMNG02010_VIEW_PCH_REQ_UNQ_NO').val();
  694. const writeVal = $('#ITP_FORM_POMNG02010_VIEW_PCH_REQ_MGR_ID').val();
  695. const stCd = $('#ITP_FORM_POMNG02010_VIEW_PCH_REQ_ST_CD').val();
  696. var userId = fn_make_user_info.get('userId');
  697. console.log(writeVal);
  698. console.log(userId);
  699. console.log(writeVal == userId);
  700. console.log(stCd);
  701. if (writeVal != userId) {
  702. alert(ITP_MSG_LOCALE.message.ajax.diffWrite);
  703. return;
  704. }
  705. if (stCd != "PR00") {
  706. alert(ITP_MSG_LOCALE.message.ajax.notWrite);
  707. return;
  708. }
  709. const key = {brandId:fn_make_user_info.get('brandId'), pchReqUnqNo: selectVal, viewCd: 'R'};
  710. var param = $.param(key);
  711. //modifyObj.init(param);
  712. modifyObj.load(param);
  713. },
  714. save: function(arg) {
  715. $('body').trigger('click');
  716. const formId = '#ITP_FORM_POMNG02010_DETAIL';
  717. itp_fn_form_clear_validate(null, formId);
  718. itp_fn_grid_save_rows(POMNG02010_DETAIL_GRID_ID);
  719. $('#ITP_FORM_POMNG02010_DETAIL_PCH_REQ_ST_CD').val(arg);
  720. //정산 타입이 무정산이면 스킵
  721. var loanDvsn = $('#ITP_FORM_POMNG02010_DETAIL_LOAN_DVSN').val();
  722. var dlvReqDt = $('#ITP_FORM_POMNG02010_DETAIL_DLV_REQ_DT').val();
  723. var itemcnt = $(POMNG02010_DETAIL_GRID_ID).getGridParam('reccount');
  724. var dlvReqAmt = $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqTotalAmt').text();
  725. var reqMsg = "";
  726. var apprArg = {};
  727. //정산 타입이 무정산이면 스킵
  728. var apprTypeCd = "Y" // Y 정상결재, NP 선불, NA 후불
  729. var now = new Date();
  730. var today = now.getFullYear() +
  731. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  732. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  733. var dlvReqDt = $('#ITP_FORM_POMNG02010_DETAIL_DLV_REQ_DT').val();
  734. if (today > dlvReqDt) {
  735. alert("납품요청일은 오늘 이후이어야 합니다.");
  736. return;
  737. }
  738. //console.log(loanDvsn);
  739. var pchActAtm = itp_fn_currency_unfmatter($('#ITP_FORM_POMNG02010_DETAIL .fnPchActAmt').text(),"","");
  740. var pchReqAtm = itp_fn_currency_unfmatter($('#ITP_FORM_POMNG02010_DETAIL .fnPchReqTotalAmt').text(),"","");
  741. if (loanDvsn != null && loanDvsn != "") {
  742. if (loanDvsn != 'LD03' && arg == 'PR20' ) {
  743. var mallId = $('#ITP_FORM_POMNG02010_DETAIL_MALL_ID').val();
  744. if (parseInt(pchActAtm) < parseInt(pchReqAtm)) {
  745. dlvReqAmt = itp_fn_number_comma(String(parseInt(pchReqAtm) - parseInt(pchActAtm)));
  746. if (mallId == '') {
  747. if (loanDvsn == 'LD01') {
  748. apprTypeCd = 'NPN';
  749. } else {
  750. apprTypeCd = 'NAN';
  751. }
  752. } else {
  753. if (loanDvsn == 'LD01') {
  754. apprTypeCd = 'NP';
  755. } else {
  756. apprTypeCd = 'NA';
  757. }
  758. }
  759. } else {
  760. dlvReqAmt = 0 ;
  761. }
  762. } else if (loanDvsn == 'LD03' && arg == 'PR20' ) {
  763. dlvReqAmt = 0 ;
  764. }
  765. }
  766. if (itp_fn_form_event.isValid(formId)) {
  767. const rowData1 = $(POMNG02010_DETAIL_GRID_ID).getRowData();
  768. var dataCnt = 0;
  769. var chkQtyYn = "N";
  770. $.each(rowData1, function(key, value) {
  771. if (value.viewCd != 'D') {
  772. dataCnt = dataCnt + 1;
  773. if (value.pchReqQty == '' || value.pchReqQty < 1 ) {
  774. alert("요청수량을 입력해주세요!");
  775. chkQtyYn = "Y";
  776. return false;
  777. }
  778. }
  779. });
  780. if (dataCnt == 0) {
  781. alert( "요청할 품목내역이 없습니다.");
  782. return ;
  783. }
  784. if (chkQtyYn == "Y") return;
  785. if (arg == 'PR20') {
  786. apprArg.dlvReqDt = dlvReqDt;
  787. apprArg.itemcnt = itemcnt;
  788. apprArg.pchReqAtm = itp_fn_number_comma(pchReqAtm);
  789. apprArg.pchPssblAtm = itp_fn_number_comma(pchActAtm);
  790. apprArg.dlvReqAmt = dlvReqAmt;
  791. if (apprTypeCd == "Y") { // 여신 구분, 여신금액
  792. var prIngFn = {
  793. callBack: function(args) {
  794. modifyObj.button.saveLastReq(arg);
  795. }
  796. };
  797. itp_fn_modal_confirm_req1(apprArg, prIngFn, arg);
  798. } else // 금액 부족시
  799. modifyObj.button.saveApprReq(apprArg,apprTypeCd, arg);
  800. } else {
  801. modifyObj.button.saveReq(arg);
  802. }
  803. }
  804. },
  805. saveReq: function(arg) {
  806. const formId = '#ITP_FORM_POMNG02010_DETAIL';
  807. var saveFn = {
  808. callBack: function(args) {
  809. $(formId).val(arg);
  810. let gridInsertData = [];
  811. let gridUpdateData = [];
  812. let gridDeleteData = [];
  813. const rowData = $(POMNG02010_DETAIL_GRID_ID).getRowData();
  814. $.each(rowData, function(key, value) {
  815. if (value.viewCd !== 'R') {
  816. if (value.viewCd === 'C') {
  817. gridInsertData.push(value);
  818. } else if (value.viewCd === 'U') {
  819. gridUpdateData.push(value);
  820. } else if (value.viewCd === 'D') {
  821. gridDeleteData.push(value);
  822. }
  823. }
  824. });
  825. let param = $(formId).serializeObject();
  826. param.gridInsertData = gridInsertData;
  827. param.gridUpdateData = gridUpdateData;
  828. param.gridDeleteData = gridDeleteData;
  829. console.log(JSON.stringify(param));
  830. var searhFn = function() {
  831. ITP_FORM_POMNG02010_DETAIL_IS_WRITING = false;
  832. modifyObj.button.clear();
  833. };
  834. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  835. }
  836. };
  837. itp_fn_modal_confirm(ITP_MSG_LOCALE.message.ajax.tmpSave, saveFn, null);
  838. },
  839. saveApprReq: function(param, apprTypeCd, arg) {
  840. var apprFn = {
  841. callBack: function(args) {
  842. // 결재금액이 부족하여 결재란으로 이동처리
  843. var popFn = function(rowDataPop) {
  844. // 결재 성공시 승인처리함
  845. console.log(rowDataPop);
  846. modifyObj.button.saveLastReq(arg);
  847. };
  848. // 결제 팝업 : LD01(선불(충전)), LD02(후불(신용))
  849. // 결제타입코드 : 10(선불(충전)), 20(후불(결제)), 30(후불(선결제))
  850. // 구매요청 번호 전달 -
  851. //var loanDvsn = $('#ITP_FORM_LOANMNG02010_SEARCH_STORE_LOAN_DVSN').val();
  852. var pchActAtm = itp_fn_currency_unfmatter($('#ITP_FORM_POMNG02010_DETAIL .fnPchActAmt').text(),"","");
  853. var pchReqAtm = itp_fn_currency_unfmatter($('#ITP_FORM_POMNG02010_DETAIL .fnPchReqTotalAmt').text(),"","");
  854. var args = {'payTpCd': '40',
  855. 'brandId': fn_make_user_info.get('brandId'),
  856. 'storeId': fn_make_user_info.get('storeId'),
  857. 'prchReqUnqNo': $('ITP_FORM_POMNG02010_DETAIL_PCH_REQ_UNQ_NO').val(),
  858. 'goodsAmt': pchReqAtm-pchActAtm};
  859. fn_call_popup('biz', 'BIZPOP_PO_PAYMENT', '#ITP_ASIDE', popFn, args, 'S');
  860. }
  861. };
  862. var apprNFn = {
  863. callBack: function(args) {
  864. // 임시저장 처리한다.
  865. arg = 'PR00';
  866. $('#ITP_FORM_POMNG02010_DETAIL_PCH_REQ_ST_CD').val(arg);
  867. modifyObj.button.saveLastReq(arg);
  868. }
  869. };
  870. if (apprTypeCd == 'NP') { // 선불
  871. itp_fn_modal_confirm_req2(param, apprFn, arg);
  872. } else if (apprTypeCd == 'NA') { //후불
  873. itp_fn_modal_confirm_req3(param, apprFn, arg);
  874. } else if (apprTypeCd == 'NPN') { //선불 pg없음 임시저장으로
  875. itp_fn_modal_confirm_req4(param, apprNFn, arg);
  876. } else if (apprTypeCd == 'NAN') { //후불 pg없음 임시저장으로
  877. itp_fn_modal_confirm_req5(param, apprNFn, arg);
  878. }
  879. },
  880. saveLastReq: function(arg) {
  881. const formId = '#ITP_FORM_POMNG02010_DETAIL';
  882. $(formId).val(arg);
  883. let gridInsertData = [];
  884. let gridUpdateData = [];
  885. let gridDeleteData = [];
  886. const rowData = $(POMNG02010_DETAIL_GRID_ID).getRowData();
  887. $.each(rowData, function(key, value) {
  888. if (value.viewCd !== 'R') {
  889. if (value.viewCd === 'C') {
  890. gridInsertData.push(value);
  891. } else if (value.viewCd === 'U') {
  892. gridUpdateData.push(value);
  893. } else if (value.viewCd === 'D') {
  894. gridDeleteData.push(value);
  895. }
  896. }
  897. });
  898. //if (chkQtyYn == "Y") return;
  899. let param = $(formId).serializeObject();
  900. param.gridInsertData = gridInsertData;
  901. param.gridUpdateData = gridUpdateData;
  902. param.gridDeleteData = gridDeleteData;
  903. console.log(JSON.stringify(param));
  904. var searhFn = function() {
  905. ITP_FORM_POMNG02010_DETAIL_IS_WRITING = false;
  906. modifyObj.button.clear();
  907. };
  908. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  909. },
  910. clear: function () {
  911. document.getElementById('ITP_FORM_POMNG02010_DETAIL').reset();
  912. listObj.grid.search();
  913. },
  914. cancel: function () {
  915. listObj.grid.search();
  916. }
  917. },
  918. load: function(param) {
  919. console.log("=================================");
  920. console.log(param);
  921. console.log("=================================");
  922. fn_ajax_call(API_DETAIL_INFO, param, this.callback, 'GET');
  923. },
  924. callback: function (result) {
  925. console.log(result);
  926. pageObj.switchScreen('MODIFY');
  927. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_VIEW_CD').val('U');
  928. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_PCH_REQ_UNQ_NO').val(result.pchReqUnqNo);
  929. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_BRAND_ID').val(result.brandId);
  930. $('#ITP_FORM_POMNG02010_DETAIL .fnBrandNm').text(result.brandNm);
  931. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_STORE_ID').val(result.storeId);
  932. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_LOAN_DVSN').val(result.loanDvsn);
  933. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_LOAN_MGNT_UNQ_NO').val(result.loanMgntUnqNo);
  934. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_PCH_REQ_DVSN').val(result.pchReqDvsn);
  935. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_PCH_REQ_ST_CD').val(result.pchReqStCd);
  936. $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqUnqNo').text(result.pchReqUnqNo);
  937. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_PCH_REQ_NM').val(result.pchReqNm);
  938. $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqDept').text(result.pchReqDePt);
  939. $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqMgrNm').text(result.pchReqMgrNm);
  940. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_PCH_REQ_MGR_ID').val(result.pchReqMgrId);
  941. $('#ITP_FORM_POMNG02010_DETAIL .fnPchReqTotalAmt').text(itp_fn_number_comma(result.pchReqTotalAmt));
  942. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_DLV_REQ_DT').val(result.dlvReqDt);
  943. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_WHS_ID').val(result.whsId);
  944. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_WHS_NM').val(result.whsNm);
  945. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_LOCATION').val(result.location);
  946. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_LOCATION_NM').val(result.locationNm);
  947. $('#ITP_FORM_POMNG02010_DETAIL .fnLoanDvsnNm').text(result.loanDvsnNm);
  948. $('#ITP_FORM_POMNG02010_DETAIL .fnPchActAmt').text(itp_fn_number_comma(result.ordUseAmt));
  949. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_NOTE').val(result.note);
  950. $('#ITP_FORM_POMNG02010_DETAIL #ITP_FORM_POMNG02010_DETAIL_MALL_ID').val(result.mallId);
  951. // 품목 리스트 조회
  952. pageObj.grid.init('DETAIL', result.pchReqDtlList);
  953. // modifyObj.grid.load(result.spplyMgrList);
  954. },
  955. };