ITP_POMNG04010.js 23 KB

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