ITP_POMNG04010.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. //화면변수
  8. const POMNG04010_GRID_ID = '#ITP_POMNG04010_jqGrid';
  9. const POMNG04010_GRID_LIST = '#ITP_POMNG04010_jqGrid_list';
  10. const POMNG04010_GRID_PAGER = '#ITP_POMNG04010_jqGridPager';
  11. const POMNG04010_GRID_EMPTY = '#ITP_POMNG04010_jqGridEmpty';
  12. const POMNG04010_DETAIL_GRID_ID = '#ITP_POMNG04010_DETAIL_jqGrid';
  13. const POMNG04010_DETAIL_GRID_LIST = '#ITP_POMNG04010_DETAIL_jqGrid_list';
  14. const POMNG04010_DETAIL_GRID_PAGER = '#ITP_POMNG04010_DETAIL_jqGridPager';
  15. const POMNG04010_DETAIL_GRID_EMPTY = '#ITP_POMNG04010_DETAIL_jqGridEmpty';
  16. let ITP_PODR_DTL_ST_CD = fn_make_common_cd_list(CODE_LIST, 'PODR_DTL_ST_CD', true, '구매발주상세상태코드');
  17. //API URL
  18. let API_POMNG_PO_DETAIL_GRID_LIST = '/api/pomng/po/detail-grid-list';
  19. let API_POMNG_PO_INFO_PCHODR = '/api/pomng/po/info-pchOdr';
  20. let API_POMNG_PO_CANCEL_PCHPO = '/api/pomng/po/cancel-pchPo';
  21. //화면 grid ColModel
  22. const gridColModel = {
  23. list:[
  24. {
  25. index: 'VIEW_CD', name: 'viewCd',
  26. label: ITP_MSG_LOCALE.label.viewCd,
  27. width: '10', fixed: false, align: 'center',
  28. sortable: false, hidden: true
  29. },
  30. {
  31. index: 'BRAND_NM', name: 'brandNm',
  32. label: ITP_MSG_LOCALE.label.brandNm, // 브랜드명
  33. width: '10', fixed: false, align: 'center',
  34. sortable: false, hidden: false
  35. },
  36. {
  37. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  38. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, // 발주번호
  39. width: '10', fixed: false, align: 'center',
  40. sortable: false, hidden: false
  41. },
  42. {
  43. index: 'PCH_ODR_ST_NM', name: 'pchOdrStNm',
  44. label: ITP_MSG_LOCALE.label.pchOdrStNm, // 발주상태명
  45. width: '10', fixed: false, align: 'center',
  46. sortable: false, hidden: false
  47. },
  48. {
  49. index: 'PODR_DT', name: 'podrDt',
  50. label: ITP_MSG_LOCALE.label.podrDt, // 발주일자
  51. width: '10', fixed: false, align: 'center',
  52. sortable: false, hidden: false
  53. },
  54. {
  55. index: 'LOCATION_NM', name: 'locationNm',
  56. label: ITP_MSG_LOCALE.label.locationNm, // 입고처
  57. width: '10', fixed: false, align: 'center',
  58. sortable: false, hidden: false
  59. },
  60. {
  61. index: 'SPPLY_NM', name: 'spplyNm',
  62. label: ITP_MSG_LOCALE.label.spplyNm, // 공급업체명
  63. width: '10', fixed: false, align: 'center',
  64. sortable: false, hidden: false
  65. },
  66. {
  67. index: 'PODR_TOTAL_AMT', name: 'podrTotalAmt',
  68. label: ITP_MSG_LOCALE.label.podrTotalAmt, // 총 발주금액
  69. width: '8', fixed: false, align: 'center',
  70. sortable: false, hidden: false,
  71. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  72. },
  73. {
  74. index: 'PODR_ITEM_QTY', name: 'podrItemQty',
  75. label: ITP_MSG_LOCALE.label.podrItemQty, // 발주품목수
  76. width: '7', fixed: false, align: 'center',
  77. sortable: false, hidden: false
  78. },
  79. {
  80. index: 'PODR_MGR_NM', name: 'podrMgrNm',
  81. label: ITP_MSG_LOCALE.label.podrMgrNm, // 발주담당자
  82. width: '10', fixed: false, align: 'center',
  83. sortable: false, hidden: false
  84. }
  85. ],
  86. view: [],
  87. detail: [
  88. {
  89. index: 'VIEW_CD', name: 'viewCd',
  90. label: ITP_MSG_LOCALE.label.viewCd,
  91. width: '10', fixed: false, align: 'center',
  92. sortable: false, hidden: true
  93. },
  94. {
  95. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  96. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, // 발주항번
  97. width: '5', fixed: false, align: 'center',
  98. sortable: false, hidden: false
  99. },
  100. {
  101. index: 'ITEM_ID', name: 'itemId',
  102. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  103. width: '5', fixed: false, align: 'center',
  104. sortable: false, hidden: false
  105. },
  106. {
  107. index: 'ITEM_NM', name: 'itemNm',
  108. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  109. width: '5', fixed: false, align: 'center',
  110. sortable: false, hidden: false
  111. },
  112. {
  113. index: 'UNIT_AMT', name: 'unitAmt',
  114. label: ITP_MSG_LOCALE.label.unitAmt, // 단가
  115. width: '5', fixed: false, align: 'center',
  116. sortable: false, hidden: false,
  117. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  118. },
  119. {
  120. index: 'UNIT', name: 'unit',
  121. label: ITP_MSG_LOCALE.label.unit, // 기본단위
  122. width: '5', fixed: false, align: 'center',
  123. sortable: false, hidden: false
  124. },
  125. {
  126. index: 'PODR_QTY', name: 'podrQty',
  127. label: ITP_MSG_LOCALE.label.podrQty, // 발주수량
  128. width: '5', fixed: false, align: 'center',
  129. sortable: false, hidden: false
  130. },
  131. {
  132. index: 'PODR_AMT', name: 'podrAmt',
  133. label: ITP_MSG_LOCALE.label.podrAmt, // 발주금액
  134. width: '5', fixed: false, align: 'center',
  135. sortable: false, hidden: false,
  136. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  137. },
  138. {
  139. index: 'WHS_PASS_QTY', name: 'whsPassQty',
  140. label: ITP_MSG_LOCALE.label.whsPassQty, // 출고가능수량
  141. width: '5', fixed: false, align: 'center',
  142. sortable: false, hidden: false
  143. },
  144. {
  145. index: 'PODR_DTL_ST_CD', name: 'podrDtlStCd',
  146. label: ITP_MSG_LOCALE.label.podrDtlStCd, // 구매발주상세상태코드
  147. width: '5', fixed: false, align: 'center',
  148. sortable: false, hidden: false, formatter: 'select', edittype: 'select',
  149. editoptions: {value: ITP_PODR_DTL_ST_CD},
  150. }
  151. ]
  152. };
  153. /*화면공통 Object*/
  154. let pageObj = {
  155. init: function() {
  156. this.ui.init();
  157. this.event.init();
  158. },
  159. ui: {
  160. init: function() {
  161. this.view();
  162. this.grid();
  163. this.ready();
  164. },
  165. view: function() {
  166. // 버튼 권한설정
  167. fn_proc_btn_auth('POMNG04010');
  168. // 공통코드 표시
  169. $('select').each(function() {
  170. if($(this).data('select-code')) {
  171. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  172. }
  173. });
  174. // 조회일자 지정
  175. var now = new Date();
  176. var defaultToDate = new Date(now);
  177. defaultToDate.setDate(now.getDate() + 5);
  178. $('#ITP_TAB_POMNG04010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  179. $('#ITP_FORM_POMNG04010_SEARCH_FROM_DT').datepicker('setDate', '2020.10.01');
  180. $('#ITP_FORM_POMNG04010_SEARCH_TO_DT').datepicker('setDate', '2024.10.01');
  181. },
  182. grid: function() {
  183. itp_fn_jqgrid_resize(POMNG04010_GRID_ID, POMNG04010_GRID_LIST, 'lg');
  184. listObj.empty.init();
  185. itp_fn_fire_window_resize();
  186. },
  187. ready: function() {
  188. listObj.init();
  189. }
  190. },
  191. event: {
  192. init: function() {
  193. this.button();
  194. },
  195. button: function() {
  196. // 버튼 클릭 이벤트
  197. $('button').each(function() {
  198. var id = $(this).attr('id');
  199. $(this).on('click', function() {
  200. switch (id) {
  201. case 'ITP_BTN_POMNG04010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  202. case 'ITP_BTN_POMNG04010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  203. case 'ITP_BTN_POMNG04010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  204. case 'ITP_BTN_POMNG04010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  205. case 'ITP_BTN_POMNG04010_DELETE' : modifyObj.button.del(); break; // 발주 취소 버튼(예정)
  206. }
  207. });
  208. });
  209. }
  210. },
  211. switchScreen: function(mode) {
  212. $('.itp_det_head').find('button[id^="ITP_BTN_POMNG04010_"]').each(function(i) {
  213. $(this).hide();
  214. });
  215. $('#ITP_TAB_POMNG04010').find('div[id$="_CONTAINER"]').each(function(i) {
  216. $(this).hide();
  217. });
  218. if(mode == 'LIST') { // 목록
  219. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_SRH', '#ITP_BTN_POMNG04010_NEWREG']);
  220. $('#ITP_AJAX_POMNG04010_LIST_CONTAINER').show();
  221. $('#ITP_FORM_POMNG04010_SEARCH #ITP_FORM_POMNG04010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  222. $('#ITP_BTN_POMNG04010_SEARCH_SPPLY_ID').show();
  223. $('#ITP_BTN_POMNG04010_DELETE_SPPLY_ID').show();
  224. $('#ITP_BTN_POMNG04010_SEARCH_WHS_ID').show();
  225. $('#ITP_BTN_POMNG04010_DELETE_WHS_ID').show();
  226. } else if(mode == 'ADD') { // 등록
  227. $('#ITP_AJAX_POMNG04010_DETAIL_CONTAINER').show();
  228. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_CANCELLIST', '#ITP_BTN_POMNG04010_SAVE']);
  229. $('#ITP_FORM_POMNG04010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  230. $(this).attr('id') === 'ITP_FORM_POMNG04010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  231. if(elem.type === 'select') {
  232. $(this).val('').prop('selected', true);
  233. }
  234. });
  235. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_FILE_NO').val('');
  236. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_ID').removeAttr('readonly');
  237. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_NM').removeAttr('readonly');
  238. $('#ITP_FORM_POMNG04010_DETAIL_BSNS_REG_NO').removeAttr('readonly');
  239. $('#ITP_FORM_POMNG04010_DETAIL_CORP_REG_NO').removeAttr('readonly');
  240. // $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').removeAttr('disabled');
  241. // $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').removeAttr('disabled');
  242. $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').show();
  243. $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').show();
  244. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_info').hide();
  245. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_change').show();
  246. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_AFFL_SHOP_ID').val(fn_make_user_info.get('afflShopId'));
  247. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  248. $('.fnBrandId').text('(자동부여)');
  249. } else if(mode == 'MODIFY') { // 수정
  250. $('#ITP_AJAX_POMNG04010_DETAIL_CONTAINER').show();
  251. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_CANCELLIST', '#ITP_BTN_POMNG04010_SAVE']);
  252. $('#ITP_BTN_POMNG04010_CANCELLIST').show();
  253. $('#ITP_BTN_POMNG04010_DELETE').show();
  254. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_ID').attr('readonly', true);
  255. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_NM').attr('readonly', true);
  256. $('#ITP_FORM_POMNG04010_DETAIL_BSNS_REG_NO').attr('readonly', true);
  257. $('#ITP_FORM_POMNG04010_DETAIL_CORP_REG_NO').attr('readonly', true);
  258. // $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').attr('disabled', true);
  259. // $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').attr('disabled', true);
  260. $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').hide();
  261. $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').hide();
  262. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_info').show();
  263. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_change').hide();
  264. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  265. } else if(mode == 'VIEW') { // 보기
  266. $('#ITP_AJAX_POMNG04010_VIEW_CONTAINER').show();
  267. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_MODIFY', '#ITP_BTN_POMNG04010_CANCELLIST']);
  268. }
  269. }
  270. };
  271. /*목록화면 Object*/
  272. let listObj = {
  273. init: function() {
  274. this.grid.init();
  275. this.action();
  276. },
  277. itp_POMNG04010_param: {},
  278. itp_POMNG04010_search: false,
  279. button: {
  280. search: function() {
  281. listObj.itp_POMNG04010_search = true;
  282. let param = $('#ITP_FORM_POMNG04010_SEARCH').serializeObject();
  283. param.gridSize = $.jgrid.defaults.rowNum;
  284. param.gridPage = $.jgrid.defaults.page;
  285. param.sidx = '0';
  286. console.log(JSON.stringify(param));
  287. $(POMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  288. }
  289. },
  290. empty: {
  291. init: function() {
  292. var _this = this;
  293. this.push();
  294. $(POMNG04010_GRID_EMPTY).on('click', function() {
  295. _this.back();
  296. listObj.itp_POMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  297. $(POMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_POMNG04010_param)}).trigger('reloadGrid');
  298. });
  299. },
  300. push: function() {
  301. let param = $('#ITP_FORM_POMNG04010_SEARCH').serializeObject();
  302. listObj.itp_POMNG04010_param = param;
  303. param.sidx = '0';
  304. },
  305. back: function() {
  306. $('#ITP_FORM_POMNG04010_SERVICE_BRAND_TYPE').val(listObj.itp_POMNG04010_param.brandType);
  307. $('#ITP_FORM_POMNG04010_SERVICE_ST_CD').val(listObj.itp_POMNG04010_param.stCd);
  308. $('#ITP_FORM_POMNG04010_SEARCH_BRAND_NM').val(listObj.itp_POMNG04010_param.brandNm);
  309. }
  310. },
  311. grid: {
  312. init: function() {
  313. // 데이터 없을때
  314. listObj.empty.push();
  315. this.search();
  316. },
  317. colModel: gridColModel.list,
  318. search: function() {
  319. pageObj.switchScreen('LIST');
  320. this.unload();
  321. this.load();
  322. },
  323. load: function() {
  324. let param = $('#ITP_FORM_POMNG04010_SEARCH').serializeObject();
  325. param.gridSize = $.jgrid.defaults.rowNum;
  326. param.sidx = '0';
  327. console.log(JSON.stringify(param));
  328. var option = {
  329. gridId: POMNG04010_GRID_ID,
  330. colModel: gridColModel.list,
  331. param: param,
  332. url: DOMAIN + API_POMNG_PO_DETAIL_GRID_LIST,
  333. pager: POMNG04010_GRID_PAGER,
  334. onCellSelect: function(rowId, cellIdx, cellValue) {
  335. var cm = $(this).jqGrid('getGridParam', 'colModel');
  336. var colNm = cm[cellIdx].name;
  337. if (colNm === 'pchPodrUnqNo') {
  338. const pchPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'pchPodrUnqNo');
  339. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  340. const key = {pchPodrUnqNo: pchPodrUnqNoVal, brandId: brandIdVal};
  341. var param = $.param(key);
  342. modifyObj.init(param);
  343. }
  344. },
  345. loadComplete: function(data) {
  346. console.log(data);
  347. itp_fn_grid_load_complete(data, POMNG04010_GRID_ID, true, 'number', 'POMNG04010', listObj.itp_POMNG04010_search, listObj.empty, true, data.gridRecords, true);
  348. var ids = $(POMNG04010_GRID_ID).getDataIDs();
  349. $.each(ids, function(idx, rowId) {
  350. $(POMNG04010_GRID_ID).jqGrid('setCell', rowId, 'pchPodrUnqNo', '', ITP_GRID_COL_STYLE.link);
  351. });
  352. },
  353. onPaging: function(action) {
  354. itp_fn_grid_paging(POMNG04010_GRID_ID, action, param);
  355. }
  356. };
  357. itp_fn_grid_make_remote(option);
  358. },
  359. clearData: function() {
  360. $(POMNG04010_GRID_ID).jqGrid('clearGridData', true);
  361. $(POMNG04010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  362. $(POMNG04010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  363. $(POMNG04010_GRID_EMPTY).show();
  364. },
  365. unload: function() {
  366. $.jgrid.gridUnload(POMNG04010_GRID_ID);
  367. }
  368. },
  369. action: function() {
  370. var _this = this;
  371. // 공급업체 조회 버튼 클릭
  372. $('#ITP_BTN_POMNG04010_SEARCH_SPPLY_ID').on('click', function() {
  373. _this.popup('spply');
  374. });
  375. // 공급업체 텍스트 삭제 버튼 클릭
  376. $('#ITP_BTN_POMNG04010_DELETE_SPPLY_ID').on('click', function() {
  377. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_NM').val('');
  378. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_ID').val('');
  379. });
  380. // 매장/창고 조회 버튼 클릭
  381. $('#ITP_BTN_POMNG04010_SEARCH_WHS_ID').on('click', function() {
  382. _this.popup('whs');
  383. });
  384. // 매장/창고 텍스트 삭제 버튼 클릭
  385. $('#ITP_BTN_POMNG04010_DELETE_WHS_ID').on('click', function() {
  386. $('#ITP_FORM_POMNG04010_DETAIL_WHS_NM').val('');
  387. $('#ITP_FORM_POMNG04010_DETAIL_WHS_ID').val('');
  388. });
  389. },
  390. popup: function(keyword) {
  391. var popFn = this.callback.create;
  392. // const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  393. if(keyword === 'spply'){
  394. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, /*key*/null, 'S');
  395. } else if(keyword === 'whs'){
  396. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, /*key*/null, 'S');
  397. }
  398. },
  399. callback: {
  400. create: function(rowDataPop) {
  401. console.log(rowDataPop);
  402. if(rowDataPop.hasOwnProperty('whsId') == false) {
  403. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_NM').val(rowDataPop.spplyNm);
  404. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_ID').val(rowDataPop.spplyId);
  405. } else {
  406. $('#ITP_FORM_POMNG04010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  407. $('#ITP_FORM_POMNG04010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  408. }
  409. }
  410. }
  411. };
  412. /*수정화면 Object*/
  413. let modifyObj = {
  414. init: function(param) {
  415. this.load(param);
  416. },
  417. itp_POMNG04010_param: {},
  418. itp_POMNG04010_search: false,
  419. button: {
  420. cancel: function() {
  421. listObj.grid.search();
  422. },
  423. del: function() {
  424. console.log('here');
  425. const formId = '#ITP_FORM_POMNG04010_DETAIL';
  426. itp_fn_form_clear_validate(null, formId);
  427. itp_fn_grid_save_rows(POMNG04010_DETAIL_GRID_ID);
  428. let gridUpdateData = [];
  429. for(var i=0; i<$(POMNG04010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
  430. $(POMNG04010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
  431. }
  432. const selection = $(POMNG04010_DETAIL_GRID_ID).getGridParam('selarrrow');
  433. console.log(selection);
  434. const rowData = $(POMNG04010_DETAIL_GRID_ID).getRowData();
  435. let newData = [];
  436. for(let i = 0; i < selection.length; i++){
  437. let before = $(POMNG04010_DETAIL_GRID_ID).getRowData(selection[i]);
  438. //before.podrDtlStCd = 'POD2';
  439. //console.log(before)
  440. newData.push(before);
  441. }
  442. console.log(newData);
  443. let param = $(formId).serializeObject();
  444. param.gridUpdateData = newData;
  445. console.log(JSON.stringify(param));
  446. var searhFn = function() {
  447. ITP_FORM_POMNG02010_DETAIL_IS_WRITING = false;
  448. listObj.grid.search();
  449. };
  450. fn_ajax_call(API_POMNG_PO_CANCEL_PCHPO, JSON.stringify(param), searhFn, 'POST');
  451. }
  452. },
  453. empty: {
  454. init: function() {
  455. var _this = this;
  456. this.push();
  457. $(POMNG04010_VIEW_GRID_EMPTY).on('click', function() {
  458. _this.back();
  459. viewObj.itp_POMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  460. $(POMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(viewObj.itp_POMNG04010_param)}).trigger('reloadGrid');
  461. });
  462. },
  463. push: function() {
  464. let param = $('#ITP_FORM_POMNG04010_DETAIL').serializeObject();
  465. viewObj.itp_POMNG04010_param = param;
  466. },
  467. back: function() {
  468. $('#ITP_FORM_POMNG04010_SERVICE_BRAND_TYPE').val(viewObj.itp_POMNG04010_param.brandType);
  469. $('#ITP_FORM_POMNG04010_SERVICE_ST_CD').val(viewObj.itp_POMNG04010_param.stCd);
  470. $('#ITP_FORM_POMNG04010_SEARCH_BRAND_NM').val(viewObj.itp_POMNG04010_param.brandNm);
  471. }
  472. },
  473. load: function(param) {
  474. fn_ajax_call(API_POMNG_PO_INFO_PCHODR, param, this.callback, 'GET');
  475. },
  476. callback: function(result) {
  477. console.log(result);
  478. // 그리드 전화번호 '-' 함수
  479. function convertTel(value){
  480. answer = (value.startsWith('0')) ? value.replace(/[^0-9]/g, "")
  481. .replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3")
  482. .replace("--", "-") : '';
  483. return answer;
  484. }
  485. let telNo = convertTel(result.podrMgrTelNo);
  486. pageObj.switchScreen('MODIFY');
  487. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_AFFL_SHOP_ID').val(result.afflShopId);
  488. $('#ITP_FORM_POMNG04010_DETAIL .fnBrandNm').text(result.brandNm);
  489. $('#ITP_FORM_POMNG04010_DETAIL .fnPchPodrUnqNo').text(result.pchPodrUnqNo);
  490. $('#ITP_FORM_POMNG04010_DETAIL .fnSpplyNm').text(result.spplyId);
  491. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrDt').text(result.podrDt);
  492. $('#ITP_FORM_POMNG04010_DETAIL .fnPchOdrStCd').text(result.pchOdrStNm);
  493. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrTotalAmt').text(result.podrTotalAmt.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','));
  494. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrMgrNm').text(result.podrMgrNm);
  495. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrMgrNo').text(telNo);
  496. $('#ITP_FORM_POMNG04010_DETAIL .fnDlvDvsn').text(result.dlvDvsnNm);
  497. $('#ITP_FORM_POMNG04010_DETAIL .fnDlvReqDt').text(result.dlvReqDt);
  498. $('#ITP_FORM_POMNG04010_DETAIL .fnShmtWhsNm').text(result.shmtWhsDvsnNm);
  499. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRANDID').val(result.brandId);
  500. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_DLV_DVSN').val(result.dlvDvsnNm);
  501. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_PCH_PODR_UNQ_NO').val(result.pchPodrUnqNo);
  502. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_STORE_ID').val(result.storeId);
  503. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_SHM_LOCATION').val(result.shmtLocation);
  504. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_SHM_WHS_ID').val(result.shmtWhsId);
  505. modifyObj.grid.init('MODIFY', result.pchOdrDtlList)
  506. },
  507. grid: {
  508. init: function(mode, gridData) {
  509. this.mode = mode;
  510. this.gridId = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_ID : POMNG04010_DETAIL_GRID_ID;
  511. this.gridList = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_LIST : POMNG04010_DETAIL_GRID_LIST;
  512. this.gridEmpty = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_EMPTY : POMNG04010_DETAIL_GRID_EMPTY;
  513. this.unload();
  514. this.load(mode, gridData);
  515. },
  516. mode: '',
  517. colModel: gridColModel.view,
  518. load: function(mode, gridData) {
  519. var _this = this;
  520. var option = {
  521. gridId: _this.gridId,
  522. colModel: gridColModel.detail,
  523. data: gridData,
  524. multiselect: true,
  525. loadComplete: function(data) {
  526. console.log(data);
  527. itp_fn_grid_load_complete(data, POMNG04010_DETAIL_GRID_ID, true, 'number', 'POMNG04010', modifyObj.itp_POMNG04010_search, modifyObj.empty, true, data.gridRecords, true);
  528. var idArry = $(POMNG04010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  529. for(var i = 0; i < idArry.length; i++){
  530. var ret = $(POMNG04010_DETAIL_GRID_ID).getRowData(idArry[i]);
  531. console.log(1111111);
  532. console.log(ret);
  533. if(ret.podrDtlStCd == 'POD4'){
  534. $("#jqg_list_"+idArry[i]).attr("disabled", true);
  535. }
  536. }
  537. },
  538. onSelectAll: function(aRowids, status) {
  539. if(status){
  540. var cbs = $("tr.jqgrow > td > input.cbox:disabled", $(POMNG04010_DETAIL_GRID_ID)[0]);
  541. cbs.removeAttr("checked");
  542. $(POMNG04010_DETAIL_GRID_ID)[0].p.selarrrow = $("#grid_id").find("tr.jqgrow:has(td > input.cbox:checked)").map(function() { return this.id; }).get();
  543. }
  544. }
  545. };
  546. itp_fn_grid_make_local(option);
  547. },
  548. unload: function() {
  549. $.jgrid.gridUnload(this.gridId);
  550. }
  551. },
  552. isValid: function(formId) {
  553. var isValid = false;
  554. $(formId).find('input, select, checkbox, textarea').each(function(k) {
  555. if($(this).data('check-required')) {
  556. var arry = $(this).data('check-required').split(',');
  557. isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined);
  558. if(!isValid) return false;
  559. }
  560. });
  561. return isValid;
  562. },
  563. };