ITP_POMNG07010.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. //화면변수
  8. const POMNG07010_GRID_ID = '#ITP_POMNG07010_jqGrid';
  9. const POMNG07010_GRID_LIST = '#ITP_POMNG07010_jqGrid_list';
  10. const POMNG07010_GRID_PAGER = '#ITP_POMNG07010_jqGridPager';
  11. const POMNG07010_GRID_EMPTY = '#ITP_POMNG07010_jqGridEmpty';
  12. //API URL
  13. let API_POMNG_INOUTMNG_WAREHOUSE_GRID_LIST = '/api/pomng/inoutmng/warehouse-grid-list';
  14. //화면 grid ColModel
  15. const gridColModel = {
  16. list:[
  17. {
  18. index: 'VIEW_CD', name: 'viewCd',
  19. label: ITP_MSG_LOCALE.label.viewCd,
  20. width: '10', fixed: false, align: 'center',
  21. sortable: false, hidden: true
  22. },
  23. {
  24. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  25. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, // 발주번호
  26. width: '10', fixed: false, align: 'center',
  27. minwidth: 140,
  28. sortable: false, hidden: false
  29. },
  30. {
  31. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  32. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, // 발주항번
  33. width: '5', fixed: false, align: 'center',
  34. minwidth: 80,
  35. sortable: false, hidden: false
  36. },
  37. {
  38. index: 'DLV_STTMT_UNQ_NO', name: 'dlvSttmtUnqNo',
  39. label: ITP_MSG_LOCALE.label.dlvSttmtUnqNo, // 납품번호
  40. width: '10', fixed: false, align: 'center',
  41. minwidth: 140,
  42. sortable: false, hidden: false
  43. },
  44. {
  45. index: 'DLV_STTMT_DTL_NO', name: 'dlvSttmtDtlNo',
  46. label: ITP_MSG_LOCALE.label.dlvSttmtDtlNo, // 납품항번
  47. width: '5', fixed: false, align: 'center',
  48. minwidth: 80,
  49. sortable: false, hidden: false
  50. },
  51. {
  52. index: 'PODR_QTY', name: 'podrQty',
  53. label: ITP_MSG_LOCALE.label.podrQty, // 발주수량
  54. width: '13', fixed: false, align: 'right',
  55. minwidth: 80,
  56. sortable: false, hidden: false,
  57. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  58. },
  59. {
  60. index: 'DLV_QTY', name: 'dlvQty',
  61. label: ITP_MSG_LOCALE.label.dlvQty, // 납품수량
  62. width: '13', fixed: false, align: 'right',
  63. minwidth: 80,
  64. sortable: false, hidden: false,
  65. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  66. },
  67. {
  68. index: 'WHS_QTY', name: 'whsQty',
  69. label: ITP_MSG_LOCALE.label.whsQty, // 입고수량
  70. width: '13', fixed: false, align: 'right',
  71. minwidth: 80,
  72. sortable: false, hidden: false,
  73. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  74. },
  75. {
  76. index: 'DIV_REQ_DT', name: 'dlvReqDt',
  77. label: ITP_MSG_LOCALE.label.dlvReqDt, // 납품요청일
  78. width: '8', fixed: false, align: 'center',
  79. minwidth: 100,
  80. sortable: false, hidden: false
  81. },
  82. {
  83. index: 'DLV_SCH_DT', name: 'dlvSchDt',
  84. label: ITP_MSG_LOCALE.label.dlvSchDt, // 납품예정일
  85. width: '8', fixed: false, align: 'center',
  86. minwidth: 100,
  87. sortable: false, hidden: false
  88. },
  89. {
  90. index: 'DLV_CMPLT_DT', name: 'dlvCmpltDt',
  91. label: ITP_MSG_LOCALE.label.dlvCmpltDt, // 납품일자
  92. width: '8', fixed: false, align: 'center',
  93. minwidth: 100,
  94. sortable: false, hidden: false
  95. },
  96. {
  97. index: 'WHS_CNFM_NM', name: 'whsCnfmNm',
  98. label: ITP_MSG_LOCALE.label.whsCnfmNm, // 입고확인자
  99. width: '8', fixed: false, align: 'center',
  100. minwidth: 100,
  101. sortable: false, hidden: false
  102. },
  103. {
  104. index: 'DLV_MGR_NM', name: 'dlvMgrNm',
  105. label: ITP_MSG_LOCALE.label.dlvMgrNm, // 납품자명
  106. width: '8', fixed: false, align: 'center',
  107. sortable: false, hidden: false
  108. },
  109. {
  110. index: 'DLV_MGR_TEL_NO', name: 'dlvMgrTelNo',
  111. label: ITP_MSG_LOCALE.label.dlvMgrTelNo, // 납품자전화번호
  112. width: '8', fixed: false, align: 'center',
  113. minwidth: 140,
  114. sortable: false, hidden: false
  115. },
  116. {
  117. index: 'ITEM_ID', name: 'itemId',
  118. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  119. width: '8', fixed: false, align: 'left',
  120. minwidth: 140,
  121. sortable: false, hidden: false
  122. },
  123. {
  124. index: 'ITEM_NM', name: 'itemNm',
  125. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  126. width: '8', fixed: false, align: 'left',
  127. minwidth: 100,
  128. sortable: false, hidden: false, classes: 'ui-ellipsis'
  129. },
  130. {
  131. index: 'UNIT', name: 'unit',
  132. label: ITP_MSG_LOCALE.label.unit, // 기본단위
  133. width: '5', fixed: false, align: 'center',
  134. minwidth: 80,
  135. sortable: false, hidden: false
  136. },
  137. {
  138. index: 'WHS_AMT', name: 'whsAmt',
  139. label: ITP_MSG_LOCALE.label.whsAmt, // 입고금액
  140. width: '13', fixed: false, align: 'right',
  141. sortable: false, hidden: false,
  142. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  143. }
  144. ],
  145. view: [],
  146. detail: []
  147. };
  148. /*화면공통 Object*/
  149. let pageObj = {
  150. init: function() {
  151. this.ui.init();
  152. this.event.init();
  153. },
  154. ui: {
  155. init: function() {
  156. this.view();
  157. this.grid();
  158. this.ready();
  159. },
  160. view: function() {
  161. // 버튼 권한설정
  162. fn_proc_btn_auth('POMNG07010');
  163. // 공통코드 표시
  164. $('select').each(function() {
  165. if($(this).data('select-code')) {
  166. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  167. }
  168. });
  169. // 조회일자 지정
  170. var now = new Date();
  171. var fromDate = new Date(now);
  172. fromDate.setDate(now.getDate() - 7);
  173. var toDate = new Date(now);
  174. $('#ITP_TAB_POMNG07010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  175. $('#ITP_FORM_POMNG07010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  176. $('#ITP_FORM_POMNG07010_SEARCH_TO_DT').datepicker('setDate', toDate);
  177. $('#ITP_BTN_POMNG07010_EXCEL').show();
  178. if (fn_make_user_info.get('storeId') != '') {
  179. $('.brandSearchCond').hide();
  180. }
  181. },
  182. grid: function() {
  183. itp_fn_jqgrid_resize(POMNG07010_GRID_ID, POMNG07010_GRID_LIST, 'lg');
  184. listObj.empty.init();
  185. },
  186. ready: function() {
  187. listObj.init();
  188. }
  189. },
  190. event: {
  191. init: function() {
  192. this.button();
  193. },
  194. button: function() {
  195. // 버튼 클릭 이벤트
  196. $('button').each(function() {
  197. var id = $(this).attr('id');
  198. $(this).on('click', function() {
  199. switch (id) {
  200. case 'ITP_BTN_POMNG07010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  201. case 'ITP_BTN_POMNG07010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  202. case 'ITP_BTN_POMNG07010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  203. case 'ITP_BTN_POMNG07010_CANCELLIST' : viewObj.button.cancel(); break; // 취소/목록 버튼
  204. case 'ITP_BTN_POMNG07010_DELETE' : break; // 삭제 버튼
  205. case 'ITP_BTN_POMNG07010_EXCEL' : listObj.excelDown(); break; // excel 버튼
  206. }
  207. });
  208. });
  209. }
  210. },
  211. switchScreen: function(mode) {
  212. $('.itp_det_head').find('button[id^="ITP_BTN_POMNG07010_"]').each(function(i) {
  213. $(this).hide();
  214. });
  215. $('#ITP_TAB_POMNG07010').find('div[id$="_CONTAINER"]').each(function(i) {
  216. $(this).hide();
  217. });
  218. if(mode == 'LIST') { // 목록
  219. itp_fn_fire_window_resize();
  220. fn_show_btn_auth_array(['#ITP_BTN_POMNG07010_SRH', '#ITP_BTN_POMNG07010_NEWREG']);
  221. $('#ITP_AJAX_POMNG07010_LIST_CONTAINER').show();
  222. $('#ITP_FORM_POMNG07010_SEARCH #ITP_FORM_POMNG07010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  223. $('#ITP_FORM_POMNG07010_SEARCH #ITP_FORM_POMNG07010_SEARCH_STORE_ID').val(fn_make_user_info.get('storeId'));
  224. $('#ITP_BTN_POMNG07010_SEARCH_SPPLY_ID').show();
  225. $('#ITP_BTN_POMNG07010_DELETE_SPPLY_ID').show();
  226. $('#ITP_BTN_POMNG07010_SEARCH_WHS_ID').show();
  227. $('#ITP_BTN_POMNG07010_DELETE_WHS_ID').show();
  228. }
  229. }
  230. }
  231. /*목록화면 Object*/
  232. let listObj = {
  233. init: function() {
  234. this.grid.init();
  235. this.action();
  236. },
  237. itp_POMNG07010_param: {},
  238. itp_POMNG07010_search: false,
  239. button: {
  240. search: function() {
  241. listObj.itp_POMNG07010_search = true;
  242. let param = $('#ITP_FORM_POMNG07010_SEARCH').serializeObject();
  243. param.gridSize = $.jgrid.defaults.rowNum;
  244. param.gridPage = $.jgrid.defaults.page;
  245. //console.log(JSON.stringify(param));
  246. $(POMNG07010_GRID_ID).data('grid-param',param);
  247. $(POMNG07010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  248. }
  249. },
  250. empty: {
  251. init: function() {
  252. var _this = this;
  253. this.push();
  254. $(POMNG07010_GRID_EMPTY).on('click', function() {
  255. _this.back();
  256. listObj.itp_POMNG07010_param.gridSize = $.jgrid.defaults.rowNum;
  257. $(POMNG07010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_POMNG07010_param)}).trigger('reloadGrid');
  258. });
  259. },
  260. push: function() {
  261. let param = $('#ITP_FORM_POMNG07010_SEARCH').serializeObject();
  262. listObj.itp_POMNG07010_param = param;
  263. },
  264. back: function() {
  265. $('#ITP_FORM_POMNG07010_SERVICE_BRAND_TYPE').val(listObj.itp_POMNG07010_param.brandType);
  266. $('#ITP_FORM_POMNG07010_SERVICE_ST_CD').val(listObj.itp_POMNG07010_param.stCd);
  267. $('#ITP_FORM_POMNG07010_SEARCH_BRAND_NM').val(listObj.itp_POMNG07010_param.brandNm);
  268. }
  269. },
  270. grid: {
  271. init: function() {
  272. // 데이터 없을때
  273. listObj.empty.push();
  274. this.search();
  275. },
  276. colModel: gridColModel.list,
  277. search: function() {
  278. pageObj.switchScreen('LIST');
  279. this.unload();
  280. this.load();
  281. },
  282. load: function() {
  283. let param = $('#ITP_FORM_POMNG07010_SEARCH').serializeObject();
  284. param.gridSize = $.jgrid.defaults.rowNum;
  285. console.log(JSON.stringify(param));
  286. var option = {
  287. gridId: POMNG07010_GRID_ID,
  288. colModel: gridColModel.list,
  289. param: param,
  290. url: DOMAIN + API_POMNG_INOUTMNG_WAREHOUSE_GRID_LIST,
  291. pager: POMNG07010_GRID_PAGER,
  292. rownumbers: false,
  293. /*onCellSelect: function(rowId, cellIdx, cellValue) {
  294. var cm = $(this).jqGrid('getGridParam', 'colModel');
  295. var colNm = cm[cellIdx].name;
  296. if (colNm === 'pchPodrUnqNo') {
  297. const pchPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'pchPodrUnqNo');
  298. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  299. const spplyIdVal = LOGIN_USER_INFO.spplyId;
  300. const key = {pchPodrUnqNo: pchPodrUnqNoVal, brandId: brandIdVal, spplyId: spplyIdVal};
  301. var param = $.param(key);
  302. viewObj.init(param);
  303. }
  304. },*/
  305. loadComplete: function(data) {
  306. console.log(data);
  307. itp_fn_grid_load_complete(data, POMNG07010_GRID_ID, true, 'number', 'POMNG07010', listObj.itp_POMNG07010_search, listObj.empty, true, data.gridRecords, true);
  308. var ids = $(POMNG07010_GRID_ID).getDataIDs();
  309. $.each(ids, function(idx, rowId) {
  310. $(POMNG07010_GRID_ID).jqGrid('setCell', rowId, '', '', ITP_GRID_COL_STYLE.link);
  311. });
  312. },
  313. onPaging: function(action) {
  314. itp_fn_grid_paging(POMNG07010_GRID_ID, action, param);
  315. }
  316. };
  317. itp_fn_grid_make_remote(option);
  318. },
  319. clearData: function() {
  320. $(POMNG07010_GRID_ID).jqGrid('clearGridData', true);
  321. $(POMNG07010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  322. $(POMNG07010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  323. $(POMNG07010_GRID_EMPTY).show();
  324. },
  325. unload: function() {
  326. $.jgrid.gridUnload(POMNG07010_GRID_ID);
  327. }
  328. },
  329. action: function() {
  330. var _this = this;
  331. // 공급업체 조회 버튼 클릭
  332. $('#ITP_BTN_POMNG07010_SEARCH_SPPLY_ID').on('click', function() {
  333. _this.popup('spply');
  334. });
  335. // 공급업체 텍스트 삭제 버튼 클릭
  336. $('#ITP_BTN_POMNG07010_DELETE_SPPLY_ID').on('click', function() {
  337. $('#ITP_FORM_POMNG07010_DETAIL_SPPLY_NM').val('');
  338. $('#ITP_FORM_POMNG07010_DETAIL_SPPLY_ID').val('');
  339. });
  340. // 매장/창고 조회 버튼 클릭
  341. $('#ITP_BTN_POMNG07010_SEARCH_WHS_ID').on('click', function() {
  342. _this.popup('whs');
  343. });
  344. // 매장/창고 텍스트 삭제 버튼 클릭
  345. $('#ITP_BTN_POMNG07010_DELETE_WHS_ID').on('click', function() {
  346. $('#ITP_FORM_POMNG07010_DETAIL_WHS_NM').val('');
  347. $('#ITP_FORM_POMNG07010_DETAIL_WHS_ID').val('');
  348. });
  349. },
  350. popup: function(keyword) {
  351. var popFn = this.callback.create;
  352. if(keyword === 'spply'){
  353. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  354. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  355. } else if(keyword === 'whs'){
  356. var whsdvsn = "W01";
  357. if (fn_make_user_info.get('storeId') != '') {
  358. whsdvsn = "W02";
  359. }
  360. const key1 = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:whsdvsn};
  361. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key1, 'S');
  362. }
  363. },
  364. callback: {
  365. create: function(rowDataPop) {
  366. console.log(rowDataPop);
  367. console.log(Array.isArray(rowDataPop));
  368. if(rowDataPop.hasOwnProperty('whsId') == false) {
  369. console.log(rowDataPop.spplyId);
  370. $('#ITP_FORM_POMNG07010_DETAIL_SPPLY_NM').val(rowDataPop.spplyNm);
  371. $('#ITP_FORM_POMNG07010_DETAIL_SPPLY_ID').val(rowDataPop.spplyId);
  372. //console.log(rowDataPop[0].storeId);
  373. //$('#ITP_FORM_POMNG07010_DETAIL_STORE_NM').val(rowDataPop[0].storeNm);
  374. //$('#ITP_FORM_POMNG07010_DETAIL_STORE_ID').val(rowDataPop[0].storeId);
  375. } else {
  376. console.log(rowDataPop);
  377. console.log(rowDataPop.whsId);
  378. $('#ITP_FORM_POMNG07010_DETAIL_WHS_NM').val(rowDataPop.whsNm);
  379. $('#ITP_FORM_POMNG07010_DETAIL_WHS_ID').val(rowDataPop.whsId);
  380. }
  381. }
  382. },
  383. excelDown: function() {
  384. var param = {
  385. 'url': API_POMNG_INOUTMNG_WAREHOUSE_GRID_LIST,
  386. 'param': $('#ITP_FORM_POMNG07010_SEARCH').serializeObject(),
  387. 'gridColumns': $(POMNG07010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  388. 'fileName': '입고현황정보.xlsx',
  389. 'sheetName': '입고현황리스트'
  390. };
  391. itp_fn_remote_to_excel(param);
  392. }
  393. }