ITP_POMNG04010.js 23 KB

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