ITP_POMNG04010.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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: 'left',
  34. sortable: false, hidden: false, classes: 'ui-ellipsis'
  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: '7', 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: '8', fixed: false, align: 'center',
  52. sortable: false, hidden: false
  53. },
  54. {
  55. index: 'WHS_NM', name: 'whsNm',
  56. label: ITP_MSG_LOCALE.label.locationNm, // 입고처
  57. width: '10', fixed: false, align: 'center',
  58. sortable: false, hidden: false, classes: 'ui-ellipsis'
  59. },
  60. {
  61. index: 'SPPLY_NM', name: 'spplyNm',
  62. label: ITP_MSG_LOCALE.label.spplyNm, // 공급업체명
  63. width: '10', fixed: false, align: 'left',
  64. sortable: false, hidden: false, classes: 'ui-ellipsis'
  65. },
  66. {
  67. index: 'PODR_TOTAL_AMT', name: 'podrTotalAmt',
  68. label: ITP_MSG_LOCALE.label.podrTotalAmt, // 총 발주금액
  69. width: '8', fixed: false, align: 'right',
  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: 'right',
  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: 'left',
  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: 'ITEM_ID', name: 'itemId',
  96. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  97. width: '8', fixed: false, align: 'center',
  98. sortable: false, hidden: false
  99. },
  100. {
  101. index: 'ITEM_NM', name: 'itemNm',
  102. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  103. width: '6', fixed: false, align: 'left',
  104. sortable: false, hidden: false
  105. },
  106. {
  107. index: 'UNIT_AMT', name: 'unitAmt',
  108. label: ITP_MSG_LOCALE.label.unitAmt, // 단가
  109. width: '3', fixed: false, align: 'right',
  110. sortable: false, hidden: false,
  111. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  112. },
  113. {
  114. index: 'UNIT', name: 'unit',
  115. label: ITP_MSG_LOCALE.label.unit, // 기본단위
  116. width: '5', fixed: false, align: 'center',
  117. sortable: false, hidden: false
  118. },
  119. {
  120. index: 'PODR_QTY', name: 'podrQty',
  121. label: ITP_MSG_LOCALE.label.podrQty, // 발주수량
  122. width: '5', fixed: false, align: 'right',
  123. sortable: false, hidden: false
  124. },
  125. {
  126. index: 'PODR_AMT', name: 'podrAmt',
  127. label: ITP_MSG_LOCALE.label.podrAmt, // 발주금액
  128. width: '5', fixed: false, align: 'right',
  129. sortable: false, hidden: false,
  130. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  131. },
  132. {
  133. index: 'WHS_PASS_QTY', name: 'whsPassQty',
  134. label: ITP_MSG_LOCALE.label.whsPassQty, // 출고가능수량
  135. width: '5', fixed: false, align: 'right',
  136. sortable: false, hidden: false
  137. },
  138. {
  139. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  140. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, // 발주항번
  141. width: '3', fixed: false, align: 'right',
  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 defaultToDate1 = new Date(now);
  177. var defaultToDate2 = new Date(now);
  178. defaultToDate1.setDate(now.getDate() - 30);
  179. defaultToDate2.setDate(now.getDate() + 30);
  180. $('#ITP_TAB_POMNG04010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  181. $('#ITP_FORM_POMNG04010_SEARCH_FROM_DT').datepicker('setDate', defaultToDate1);
  182. $('#ITP_FORM_POMNG04010_SEARCH_TO_DT').datepicker('setDate', defaultToDate2);
  183. },
  184. grid: function() {
  185. itp_fn_jqgrid_resize(POMNG04010_GRID_ID, POMNG04010_GRID_LIST, 'lg');
  186. //listObj.empty.init();
  187. //itp_fn_fire_window_resize();
  188. },
  189. ready: function() {
  190. listObj.init();
  191. }
  192. },
  193. event: {
  194. init: function() {
  195. this.button();
  196. },
  197. button: function() {
  198. // 버튼 클릭 이벤트
  199. $('button').each(function() {
  200. var id = $(this).attr('id');
  201. $(this).on('click', function() {
  202. switch (id) {
  203. case 'ITP_BTN_POMNG04010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  204. case 'ITP_BTN_POMNG04010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  205. case 'ITP_BTN_POMNG04010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  206. case 'ITP_BTN_POMNG04010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  207. case 'ITP_BTN_POMNG04010_DELETE' : modifyObj.button.del(); break; // 발주 취소 버튼(예정)
  208. case 'ITP_BTN_POMNG04010_EXCEL' : listObj.excelDown(); break; // 엑셀
  209. }
  210. });
  211. });
  212. }
  213. },
  214. switchScreen: function(mode) {
  215. $('.itp_det_head').find('button[id^="ITP_BTN_POMNG04010_"]').each(function(i) {
  216. $(this).hide();
  217. });
  218. $('#ITP_TAB_POMNG04010').find('div[id$="_CONTAINER"]').each(function(i) {
  219. $(this).hide();
  220. });
  221. if(mode == 'LIST') { // 목록
  222. itp_fn_fire_window_resize();
  223. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_SRH', '#ITP_BTN_POMNG04010_NEWREG']);
  224. $('#ITP_AJAX_POMNG04010_LIST_CONTAINER').show();
  225. $('#ITP_FORM_POMNG04010_SEARCH #ITP_FORM_POMNG04010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  226. $('#ITP_BTN_POMNG04010_SEARCH_SPPLY_ID').show();
  227. $('#ITP_BTN_POMNG04010_DELETE_SPPLY_ID').show();
  228. $('#ITP_BTN_POMNG04010_SEARCH_WHS_ID').show();
  229. $('#ITP_BTN_POMNG04010_DELETE_WHS_ID').show();
  230. $('#ITP_BTN_POMNG04010_EXCEL').show();
  231. } /*else if(mode == 'ADD') { // 등록
  232. $('#ITP_AJAX_POMNG04010_DETAIL_CONTAINER').show();
  233. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_CANCELLIST', '#ITP_BTN_POMNG04010_SAVE']);
  234. $('#ITP_FORM_POMNG04010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
  235. $(this).attr('id') === 'ITP_FORM_POMNG04010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
  236. if(elem.type === 'select') {
  237. $(this).val('').prop('selected', true);
  238. }
  239. });
  240. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_FILE_NO').val('');
  241. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_ID').removeAttr('readonly');
  242. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_NM').removeAttr('readonly');
  243. $('#ITP_FORM_POMNG04010_DETAIL_BSNS_REG_NO').removeAttr('readonly');
  244. $('#ITP_FORM_POMNG04010_DETAIL_CORP_REG_NO').removeAttr('readonly');
  245. // $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').removeAttr('disabled');
  246. // $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').removeAttr('disabled');
  247. $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').show();
  248. $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').show();
  249. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_info').hide();
  250. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_change').show();
  251. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_AFFL_SHOP_ID').val(fn_make_user_info.get('afflShopId'));
  252. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  253. $('.fnBrandId').text('(자동부여)');
  254. } */else if(mode == 'MODIFY') { // 수정
  255. $('#ITP_AJAX_POMNG04010_DETAIL_CONTAINER').show();
  256. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_CANCELLIST', '#ITP_BTN_POMNG04010_SAVE']);
  257. $('#ITP_BTN_POMNG04010_CANCELLIST').show();
  258. $('#ITP_BTN_POMNG04010_DELETE').show();
  259. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_ID').attr('readonly', true);
  260. $('#ITP_FORM_POMNG04010_DETAIL_BRAND_NM').attr('readonly', true);
  261. $('#ITP_FORM_POMNG04010_DETAIL_BSNS_REG_NO').attr('readonly', true);
  262. $('#ITP_FORM_POMNG04010_DETAIL_CORP_REG_NO').attr('readonly', true);
  263. // $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').attr('disabled', true);
  264. // $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').attr('disabled', true);
  265. $('#ITP_FORM_POMNG04010_DETAIL_SEARCH_AFFL_SHOP').hide();
  266. $('#ITP_FORM_POMNG04010_DETAIL_DELETE_AFFL_SHOP').hide();
  267. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_info').show();
  268. $('#ITP_FORM_POMNG04010_DETAIL .itp_form_change').hide();
  269. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRAND_ID').val(fn_make_user_info.get('brandId'));
  270. } /*else if(mode == 'VIEW') { // 보기
  271. $('#ITP_AJAX_POMNG04010_VIEW_CONTAINER').show();
  272. fn_show_btn_auth_array(['#ITP_BTN_POMNG04010_MODIFY', '#ITP_BTN_POMNG04010_CANCELLIST']);
  273. }*/
  274. }
  275. };
  276. /*목록화면 Object*/
  277. let listObj = {
  278. init: function() {
  279. this.grid.init();
  280. this.action();
  281. },
  282. itp_POMNG04010_param: {},
  283. itp_POMNG04010_search: false,
  284. button: {
  285. search: function() {
  286. listObj.itp_POMNG04010_search = true;
  287. let param = $('#ITP_FORM_POMNG04010_SEARCH').serializeObject();
  288. param.gridSize = $.jgrid.defaults.rowNum;
  289. param.gridPage = $.jgrid.defaults.page;
  290. param.sidx = '0';
  291. console.log(JSON.stringify(param));
  292. $(POMNG04010_GRID_ID).data('grid-param',param);
  293. $(POMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  294. }
  295. },
  296. empty: {
  297. init: function() {
  298. },
  299. push: function() {
  300. },
  301. back: function() {
  302. }
  303. },
  304. grid: {
  305. init: function() {
  306. // 데이터 없을때
  307. //listObj.empty.push();
  308. this.search();
  309. },
  310. colModel: gridColModel.list,
  311. search: function() {
  312. pageObj.switchScreen('LIST');
  313. this.unload();
  314. this.load();
  315. },
  316. load: function() {
  317. let param = $('#ITP_FORM_POMNG04010_SEARCH').serializeObject();
  318. param.gridSize = $.jgrid.defaults.rowNum;
  319. param.sidx = '0';
  320. console.log(JSON.stringify(param));
  321. var option = {
  322. gridId: POMNG04010_GRID_ID,
  323. colModel: gridColModel.list,
  324. param: param,
  325. url: DOMAIN + API_POMNG_PO_DETAIL_GRID_LIST,
  326. pager: POMNG04010_GRID_PAGER,
  327. onCellSelect: function(rowId, cellIdx, cellValue) {
  328. var cm = $(this).jqGrid('getGridParam', 'colModel');
  329. var colNm = cm[cellIdx].name;
  330. if (colNm === 'pchPodrUnqNo') {
  331. const pchPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'pchPodrUnqNo');
  332. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  333. const key = {pchPodrUnqNo: pchPodrUnqNoVal, brandId: brandIdVal};
  334. var param = $.param(key);
  335. modifyObj.init(param);
  336. }
  337. },
  338. loadComplete: function(data) {
  339. console.log(data);
  340. itp_fn_grid_load_complete(data, POMNG04010_GRID_ID, true, 'number', 'POMNG04010', listObj.itp_POMNG04010_search, listObj.empty, true, data.gridRecords, true);
  341. var ids = $(POMNG04010_GRID_ID).getDataIDs();
  342. $.each(ids, function(idx, rowId) {
  343. $(POMNG04010_GRID_ID).jqGrid('setCell', rowId, 'pchPodrUnqNo', '', ITP_GRID_COL_STYLE.link);
  344. });
  345. },
  346. onPaging: function(action) {
  347. itp_fn_grid_paging(POMNG04010_GRID_ID, action, param);
  348. }
  349. };
  350. itp_fn_grid_make_remote(option);
  351. },
  352. clearData: function() {
  353. $(POMNG04010_GRID_ID).jqGrid('clearGridData', true);
  354. $(POMNG04010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  355. $(POMNG04010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  356. $(POMNG04010_GRID_EMPTY).show();
  357. },
  358. unload: function() {
  359. $.jgrid.gridUnload(POMNG04010_GRID_ID);
  360. }
  361. },
  362. action: function() {
  363. var _this = this;
  364. // 공급업체 조회 버튼 클릭
  365. $('#ITP_BTN_POMNG04010_SEARCH_SPPLY_ID').on('click', function() {
  366. _this.popup('spply');
  367. });
  368. // 공급업체 텍스트 삭제 버튼 클릭
  369. $('#ITP_BTN_POMNG04010_DELETE_SPPLY_ID').on('click', function() {
  370. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_NM').val('');
  371. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_ID').val('');
  372. });
  373. // 매장/창고 조회 버튼 클릭
  374. $('#ITP_BTN_POMNG04010_SEARCH_WHS_ID').on('click', function() {
  375. _this.popup('whs');
  376. });
  377. // 매장/창고 텍스트 삭제 버튼 클릭
  378. $('#ITP_BTN_POMNG04010_DELETE_WHS_ID').on('click', function() {
  379. $('#ITP_FORM_POMNG04010_DETAIL_WHS_NM').val('');
  380. $('#ITP_FORM_POMNG04010_DETAIL_WHS_ID').val('');
  381. });
  382. },
  383. popup: function(keyword) {
  384. var popFn = this.callback.create;
  385. if(keyword === 'spply'){
  386. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  387. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  388. } else if(keyword === 'whs'){
  389. const key1 = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  390. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key1, 'S');
  391. }
  392. },
  393. callback: {
  394. create: function(rowDataPop) {
  395. console.log(rowDataPop);
  396. if(rowDataPop.hasOwnProperty('whsId') == false) {
  397. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_NM').val(rowDataPop.spplyNm);
  398. $('#ITP_FORM_POMNG04010_DETAIL_SPPLY_ID').val(rowDataPop.spplyId);
  399. } else {
  400. $('#ITP_FORM_POMNG04010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  401. $('#ITP_FORM_POMNG04010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  402. }
  403. }
  404. },
  405. excelDown: function() {
  406. var param = {
  407. 'url': API_POMNG_PO_DETAIL_GRID_LIST,
  408. 'param': $('#ITP_FORM_POMNG04010_SEARCH').serializeObject(),
  409. 'gridColumns': $(POMNG04010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  410. 'fileName': '구매발주현황.xlsx',
  411. 'sheetName': '구매발주현황리스트'
  412. };
  413. itp_fn_remote_to_excel(param);
  414. }
  415. };
  416. /*수정화면 Object*/
  417. let modifyObj = {
  418. init: function(param) {
  419. this.load(param);
  420. },
  421. itp_POMNG04010_param: {},
  422. itp_POMNG04010_search: false,
  423. button: {
  424. cancel: function() {
  425. listObj.grid.search();
  426. },
  427. del: function() {
  428. const formId = '#ITP_FORM_POMNG04010_DETAIL';
  429. itp_fn_form_clear_validate(null, formId);
  430. itp_fn_grid_save_rows(POMNG04010_DETAIL_GRID_ID);
  431. let gridUpdateData = [];
  432. for(var i=0; i<$(POMNG04010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
  433. $(POMNG04010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
  434. }
  435. const selection = $(POMNG04010_DETAIL_GRID_ID).getGridParam('selarrrow');
  436. if (selection.length == 0 ) {
  437. alert("취소 대상 품목이 없습니다.");
  438. return ;
  439. }
  440. let param = $(formId).serializeObject();
  441. let newData = [];
  442. for(let i = 0; i < selection.length; i++){
  443. let before = $(POMNG04010_DETAIL_GRID_ID).getRowData(selection[i]);
  444. before.pchPodrUnqNo = param.pchPodrUnqNo;
  445. newData.push(before);
  446. }
  447. param.gridUpdateData = newData;
  448. var modalFn = {
  449. callBack: () => {
  450. var searhFn = function() {
  451. ITP_FORM_POMNG02010_DETAIL_IS_WRITING = false;
  452. listObj.grid.search();
  453. };
  454. fn_ajax_call(API_POMNG_PO_CANCEL_PCHPO, JSON.stringify(param), searhFn, 'POST');
  455. }
  456. };
  457. itp_fn_modal_confirm('발주 취소 하시겠습니까?', modalFn);
  458. }
  459. },
  460. empty: {
  461. init: function() {
  462. var _this = this;
  463. this.push();
  464. $(POMNG04010_VIEW_GRID_EMPTY).on('click', function() {
  465. _this.back();
  466. viewObj.itp_POMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  467. $(POMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(viewObj.itp_POMNG04010_param)}).trigger('reloadGrid');
  468. });
  469. },
  470. push: function() {
  471. let param = $('#ITP_FORM_POMNG04010_DETAIL').serializeObject();
  472. viewObj.itp_POMNG04010_param = param;
  473. },
  474. back: function() {
  475. $('#ITP_FORM_POMNG04010_SERVICE_BRAND_TYPE').val(viewObj.itp_POMNG04010_param.brandType);
  476. $('#ITP_FORM_POMNG04010_SERVICE_ST_CD').val(viewObj.itp_POMNG04010_param.stCd);
  477. $('#ITP_FORM_POMNG04010_SEARCH_BRAND_NM').val(viewObj.itp_POMNG04010_param.brandNm);
  478. }
  479. },
  480. load: function(param) {
  481. fn_ajax_call(API_POMNG_PO_INFO_PCHODR, param, this.callback, 'GET');
  482. },
  483. callback: function(result) {
  484. console.log(result);
  485. // 그리드 전화번호 '-' 함수
  486. function convertTel(value){
  487. answer = (value.startsWith('0')) ? value.replace(/[^0-9]/g, "")
  488. .replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3")
  489. .replace("--", "-") : '';
  490. return answer;
  491. }
  492. let telNo = convertTel(result.podrMgrTelNo);
  493. console.log(result);
  494. pageObj.switchScreen('MODIFY');
  495. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_AFFL_SHOP_ID').val(result.afflShopId);
  496. $('#ITP_FORM_POMNG04010_DETAIL .fnBrandNm').text(result.brandNm);
  497. $('#ITP_FORM_POMNG04010_DETAIL .fnPchPodrUnqNo').text(result.pchPodrUnqNo);
  498. $('#ITP_FORM_POMNG04010_DETAIL .fnSpplyNm').text(result.spplyId);
  499. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrDt').text(result.podrDt);
  500. $('#ITP_FORM_POMNG04010_DETAIL .fnPchOdrStCd').text(result.pchOdrStNm);
  501. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrTotalAmt').text(result.podrTotalAmt.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','));
  502. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrMgrNm').text(result.podrMgrNm);
  503. $('#ITP_FORM_POMNG04010_DETAIL .fnPodrMgrNo').text(telNo);
  504. $('#ITP_FORM_POMNG04010_DETAIL .fnDlvDvsn').text(result.dlvDvsnNm);
  505. $('#ITP_FORM_POMNG04010_DETAIL .fnDlvReqDt').text(result.dlvReqDt);
  506. $('#ITP_FORM_POMNG04010_DETAIL .fnShmtWhsNm').text(result.shmtWhsNm);
  507. $('#ITP_FORM_POMNG04010_DETAIL .fnWhsNm').text(result.whsNm);
  508. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_BRANDID').val(result.brandId);
  509. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_DLV_DVSN').val(result.dlvDvsn);
  510. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_PCH_PODR_UNQ_NO').val(result.pchPodrUnqNo);
  511. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_STORE_ID').val(result.storeId);
  512. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_SHM_LOCATION').val(result.shmtLocation);
  513. $('#ITP_FORM_POMNG04010_DETAIL #ITP_FORM_POMNG04010_DETAIL_SHM_WHS_ID').val(result.shmtWhsId);
  514. modifyObj.grid.init('MODIFY', result.pchOdrDtlList)
  515. },
  516. grid: {
  517. init: function(mode, gridData) {
  518. this.mode = mode;
  519. this.gridId = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_ID : POMNG04010_DETAIL_GRID_ID;
  520. this.gridList = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_LIST : POMNG04010_DETAIL_GRID_LIST;
  521. this.gridEmpty = (mode === 'VIEW') ? POMNG04010_VIEW_GRID_EMPTY : POMNG04010_DETAIL_GRID_EMPTY;
  522. this.unload();
  523. this.load(mode, gridData);
  524. },
  525. mode: '',
  526. colModel: gridColModel.view,
  527. load: function(mode, gridData) {
  528. var _this = this;
  529. var option = {
  530. gridId: _this.gridId,
  531. colModel: gridColModel.detail,
  532. data: gridData,
  533. multiselect: true,
  534. onSelectRow: function(index, status) {
  535. if(index) {
  536. var row = $(POMNG04010_DETAIL_GRID_ID).jqGrid('getRowData', index);
  537. if(row.podrDtlStCd == 'POD2') {
  538. $("#jqg_ITP_POMNG04010_DETAIL_jqGrid_" + index).prop("checked", false);
  539. }
  540. }
  541. },
  542. onSelectAll: function(rowIds, status) {
  543. for(let i = 0; i < rowIds.length; i++){
  544. let podrDtlStCd = $(POMNG04010_DETAIL_GRID_ID).getCell(rowIds[i], 'podrDtlStCd');
  545. if(podrDtlStCd == 'POD2') {
  546. $("#jqg_ITP_POMNG04010_DETAIL_jqGrid_" + rowIds[i]).prop("checked", false);
  547. } else {
  548. $("#jqg_ITP_POMNG04010_DETAIL_jqGrid_" + rowIds[i]).prop("checked", status);
  549. }
  550. }
  551. },
  552. loadComplete: function(data) {
  553. console.log(data);
  554. let datas = data.rows;
  555. for(let i = 0; i < datas.length; i++) {
  556. let podrDtlStCd = datas[i].podrDtlStCd;
  557. if(podrDtlStCd == 'POD2') {
  558. $('#jqg_ITP_POMNG04010_DETAIL_jqGrid_' + (i + 1)).attr('disabled', true);
  559. }
  560. }
  561. itp_fn_grid_load_complete(data, POMNG04010_DETAIL_GRID_ID, true, 'number', 'POMNG04010', modifyObj.itp_POMNG04010_search, modifyObj.empty, true, data.gridRecords, true);
  562. }
  563. };
  564. itp_fn_grid_make_local(option);
  565. },
  566. unload: function() {
  567. $.jgrid.gridUnload(this.gridId);
  568. }
  569. },
  570. isValid: function(formId) {
  571. var isValid = false;
  572. $(formId).find('input, select, checkbox, textarea').each(function(k) {
  573. if($(this).data('check-required')) {
  574. var arry = $(this).data('check-required').split(',');
  575. isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined);
  576. if(!isValid) return false;
  577. }
  578. });
  579. return isValid;
  580. },
  581. };