ITP_STOCKMNG01010.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. /********************************************************
  2. --------------------------------------------------------
  3. - Object 목록 -
  4. --------------------------------------------------------
  5. * const gridColModel = {} : 화면 Grid Object *
  6. * let pageObj = {} : 화면공통 Object *
  7. * let listObj = {} : 목록화면 Object *
  8. *******************************************************/
  9. /*화면 변수*/
  10. const STOCKMNG01010_GRID_ID = '#ITP_STOCKMNG01010_jqGrid';
  11. const STOCKMNG01010_GRID_LIST = '#ITP_STOCKMNG01010_jqGrid_list';
  12. const STOCKMNG01010_GRID_PAGER = '#ITP_STOCKMNG01010_jqGridPager';
  13. const STOCKMNG01010_GRID_EMPTY = '#ITP_STOCKMNG01010_jqGridEmpty';
  14. let ITP_FORM_STOCKMNG01010_DETAIL_IS_DUPLICATE = false;
  15. let ITP_FORM_STOCKMNG01010_DETAIL_IS_WRITING = false;
  16. let STOCKMNG01010_DETAIL_GRID_LAST_ROW_ID;
  17. /*API URL*/
  18. let STOCK_MNG_DETAIL_GRID_LIST = '/api/stock/mng/detail-grid-list';
  19. let WHS_MNG_DETAIL_GRID_LIST = '/api/whs/mng/detail-grid-list';
  20. let WHS_MNG_LOCATION_GRID_LIST = '/api/whs/mng/location-grid-list';
  21. /*화면 Grid ColModel*/
  22. const gridColModel = {
  23. list: [
  24. {
  25. index: 'BRAND_ID', name: 'brandId',
  26. label: "브랜드ID",
  27. width: '0', fixed: false, align: 'center',
  28. sortable: false, hidden: true
  29. },
  30. {
  31. index: 'LOCATION', name: 'location',
  32. label: "로케이션",
  33. width: '0', fixed: false, align: 'center',
  34. sortable: false, hidden: true
  35. },
  36. {
  37. index: 'BRAND_NM', name: 'brandNm',
  38. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  39. width: '10', fixed: false, align: 'center',
  40. sortable: false, hidden: false
  41. },
  42. {
  43. index: 'STORE_NM', name: 'storeNm',
  44. label: "매장명",
  45. width: '10', fixed: false, align: 'center',
  46. sortable: false, hidden: false
  47. },
  48. {
  49. index: 'WHS_ID', name: 'whsId',
  50. label: "창고번호",
  51. width: '8', fixed: false, align: 'center',
  52. sortable: false, hidden: false
  53. },
  54. {
  55. index: 'WHS_NM', name: 'whsNm',
  56. label: "창고명",
  57. width: '13', fixed: false, align: 'center',
  58. sortable: false, hidden: false
  59. },
  60. {
  61. index: 'LOCATION_NM', name: 'locationNm',
  62. label: "Location명",
  63. width: '10', fixed: false, align: 'center',
  64. sortable: false, hidden: false
  65. },
  66. {
  67. index: 'ITEM_ID', name: 'itemId',
  68. label: "품목번호",
  69. width: '11', fixed: false, align: 'center',
  70. sortable: false, hidden: false
  71. },
  72. {
  73. index: 'ITEM_NM', name: 'itemNm',
  74. label: "품목명",
  75. width: '10', fixed: false, align: 'center',
  76. sortable: false, hidden: false
  77. },
  78. {
  79. index: 'UNIT', name: 'unit',
  80. label: "단위",
  81. width: '7', fixed: false, align: 'center',
  82. sortable: false, hidden: false
  83. },
  84. {
  85. index: 'STCK_QTY', name: 'stckQty',
  86. label: "현재고수량",
  87. width: '8', fixed: false, align: 'center',
  88. sortable: false, hidden: false
  89. },
  90. {
  91. index: 'PRP_STCK_QTY', name: 'prpStckQty',
  92. label: "적정재고수량",
  93. width: '8', fixed: false, align: 'center',
  94. sortable: false, hidden: false
  95. },
  96. {
  97. index: 'SFT_STCK_RT', name: 'sftStckRt',
  98. label: "안전재고비율(%)",
  99. width: '10', fixed: false, align: 'center',
  100. sortable: false, hidden: false
  101. },
  102. {
  103. index: 'CUR_STCK_RT', name: 'curStckRt',
  104. label: "현재고비율(%)",
  105. width: '10', fixed: false, align: 'center',
  106. sortable: false, hidden: false
  107. }
  108. ]
  109. };
  110. require(['config'], function() {
  111. require([
  112. ], function($) {
  113. pageObj.init();
  114. });
  115. });
  116. /*화면공통 Object*/
  117. let pageObj = {
  118. init: function () {
  119. this.ui.init();
  120. this.event.init();
  121. },
  122. ui: {
  123. init: function () {
  124. this.view();
  125. this.grid();
  126. this.ready();
  127. },
  128. view: function() {
  129. // 버튼 권한설정
  130. fn_proc_btn_auth('STOCKMNG01010');
  131. // 브랜드ID 지정
  132. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
  133. $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
  134. pageObj.fnWhsList(function() {
  135. pageObj.fnLocationList();
  136. }); // 창고리스트
  137. // 공통코드 표시
  138. // fn_make_select(CODE_LIST, 'WHS_DVSN', 'ITP_FORM_STOCKMNG01010_WHS_DVSN');
  139. // 조회일자 지정
  140. $('#ITP_TAB_STOCKMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  141. },
  142. grid: function() {
  143. itp_fn_jqgrid_resize(STOCKMNG01010_GRID_ID, STOCKMNG01010_GRID_LIST, 'lg');
  144. listObj.empty.init();
  145. itp_fn_fire_window_resize();
  146. },
  147. ready: function() {
  148. listObj.init();
  149. }
  150. },
  151. event: {
  152. init: function () {
  153. this.button();
  154. this.change();
  155. },
  156. button: function () {
  157. // 버튼 클릭 이벤트
  158. $('button').each(function() {
  159. var id = $(this).attr('id');
  160. $(this).on('click', function() {
  161. switch (id) {
  162. case 'ITP_BTN_STOCKMNG01010_SRH' : listObj.button.search(); break; // 조회 버튼
  163. case 'ITP_BTN_STOCKMNG01010_ADDROW' : listObj.button.clickStockProc(); break; // 재고처리 버튼
  164. case 'ITP_BTN_STOCKMNG01010_DELROW' : listObj.button.clickStockHist(); break; // 재고이력 버튼
  165. }
  166. });
  167. });
  168. $('body').on('click', function(e) {
  169. });
  170. },
  171. change: function () {
  172. // 창고 변경
  173. $('#ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID').on('change', function() {
  174. pageObj.fnLocationList(function() {
  175. listObj.button.search(); // 조회
  176. }); // 로케이션 리스트
  177. });
  178. $('#ITP_FORM_STOCKMNG01010_SEARCH_LOCATION').on('change', function() {
  179. listObj.button.search(); // 조회
  180. });
  181. }
  182. },
  183. switchScreen: function(mode) {
  184. if(mode == 'LIST') { // 목록
  185. fn_show_btn_auth('#ITP_BTN_STOCKMNG01010_SRH');
  186. $('#ITP_AJAX_STOCKMNG01010_LIST_CONTAINER').show();
  187. }
  188. },
  189. fnWhsList: function(fnCall) {
  190. const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
  191. const param = {sbrandId: brandIdVal, pagingYn: false};
  192. fn_ajax_call(WHS_MNG_DETAIL_GRID_LIST, JSON.stringify(param), function(result) {
  193. fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID');
  194. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  195. }, 'POST');
  196. },
  197. fnLocationList: function(fnCall) {
  198. const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
  199. const whsIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID').val();
  200. const param = {brandId: brandIdVal, whsId: whsIdVal, pagingYn: false};
  201. fn_ajax_call(WHS_MNG_LOCATION_GRID_LIST, JSON.stringify(param), function(result) {
  202. fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_LOCATION');
  203. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  204. }, 'POST');
  205. }
  206. };
  207. /*목록화면 Object*/
  208. let listObj = {
  209. init: function () {
  210. this.grid.init();
  211. },
  212. itp_STOCKMNG01010_search: false,
  213. button: {
  214. search: function() {
  215. listObj.itp_STOCKMNG01010_search = true;
  216. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  217. param.gridSize = $.jgrid.defaults.rowNum;
  218. param.gridPage = $.jgrid.defaults.page;
  219. $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  220. },
  221. clickStockProc: function() {
  222. // 그리드에서 최소1개는 선택해야 함
  223. const rowKey = $(STOCKMNG01010_GRID_ID).getGridParam('selrow');
  224. if (!rowKey) {
  225. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData);
  226. return;
  227. }
  228. var selectedIds = $(STOCKMNG01010_GRID_ID).getGridParam('selarrrow');
  229. if (selectedIds.length > 1) {
  230. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noSingleData);
  231. return;
  232. }
  233. var brandId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).brandId;
  234. var whsId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).whsId;
  235. var location = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).location;
  236. var itemId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).itemId;
  237. var args = {'brandId': brandId, 'whsId': whsId, 'location': location, 'itemId': itemId};
  238. fn_call_popup('biz', 'BIZPOP_PO_STOCK_PROC', '#ITP_ASIDE', function() {
  239. listObj.button.search(); // 조회
  240. }, args, 'S');
  241. },
  242. clickStockHist: function() {
  243. // 그리드에서 최소1개는 선택해야 함
  244. const rowKey = $(STOCKMNG01010_GRID_ID).getGridParam('selrow');
  245. if (!rowKey) {
  246. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData);
  247. return;
  248. }
  249. var selectedIds = $(STOCKMNG01010_GRID_ID).getGridParam('selarrrow');
  250. if (selectedIds.length > 1) {
  251. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noSingleData);
  252. return;
  253. }
  254. var brandId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).brandId;
  255. var whsId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).whsId;
  256. var location = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).location;
  257. var itemId = $(STOCKMNG01010_GRID_ID).jqGrid('getRowData', selectedIds[0]).itemId;
  258. var args = {'brandId': brandId, 'whsId': whsId, 'location': location, 'itemId': itemId};
  259. fn_call_popup('biz', 'BIZPOP_PO_STOCK_HIST', '#ITP_ASIDE', null, args, 'S');
  260. }
  261. },
  262. empty: {
  263. init: function() {
  264. var _this = this;
  265. this.push();
  266. $(STOCKMNG01010_GRID_EMPTY).on('click', function() {
  267. _this.back();
  268. _this.itp_STOCKMNG01010_param.gridSize = $.jgrid.defaults.rowNum;
  269. $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STOCKMNG01010_param)}).trigger('reloadGrid');
  270. });
  271. },
  272. itp_STOCKMNG01010_param: {},
  273. push: function() {
  274. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  275. listObj.itp_STOCKMNG01010_param = param;
  276. },
  277. back: function() {
  278. $('#ITP_FORM_STOCKMNG01010_DEVI_TP_CD').val(this.itp_STOCKMNG01010_param.deviTpCd);
  279. $('#ITP_FORM_STOCKMNG01010_ORDER_YN').val(this.itp_STOCKMNG01010_param.orderYn);
  280. $('#ITP_FORM_STOCKMNG01010_ADT_AUTH_CD').val(this.itp_STOCKMNG01010_param.adtAuthCd);
  281. $('#ITP_FORM_STOCKMNG01010_EMAIL_RCV_YN').val(this.itp_STOCKMNG01010_param.emailRcvYn);
  282. $('#ITP_FORM_STOCKMNG01010_MEMB_EXIT_DT').val(this.itp_STOCKMNG01010_param.membExitDt);
  283. $('#ITP_FORM_STOCKMNG01010_FROM_DT').val(this.itp_STOCKMNG01010_param.fromDt);
  284. $('#ITP_FORM_STOCKMNG01010_TO_DT').val(this.itp_STOCKMNG01010_param.toDt);
  285. $('#ITP_FORM_STOCKMNG01010_KEYWORD').val(this.itp_STOCKMNG01010_param.keyword);
  286. }
  287. },
  288. grid: {
  289. init: function () {
  290. // 데이터 없을때
  291. listObj.empty.push();
  292. this.search();
  293. },
  294. colModel: gridColModel.list,
  295. search: function() {
  296. pageObj.switchScreen('LIST');
  297. this.unload();
  298. this.load();
  299. },
  300. load: function() {
  301. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_info'));
  302. $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
  303. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  304. param.gridSize = $.jgrid.defaults.rowNum;
  305. var option = {
  306. gridId: STOCKMNG01010_GRID_ID,
  307. colModel: gridColModel.list,
  308. param: JSON.stringify(param),
  309. url: DOMAIN + STOCK_MNG_DETAIL_GRID_LIST,
  310. pager: STOCKMNG01010_GRID_PAGER,
  311. multiselect: true,
  312. onCellSelect: function(rowId, cellIdx, cellValue) {
  313. var cm = $(this).jqGrid('getGridParam', 'colModel');
  314. var colNm = cm[cellIdx].name;
  315. if (colNm == 'whsNm') {
  316. }
  317. },
  318. loadComplete: function(data) {
  319. console.log(data);
  320. itp_fn_grid_load_complete(data, STOCKMNG01010_GRID_ID, true, 'number', 'STOCKMNG01010', listObj.itp_STOCKMNG01010_search, listObj.empty, true, data.gridRecords, true);
  321. var ids = $(STOCKMNG01010_GRID_ID).getDataIDs();
  322. $.each(ids, function(idx, rowId) {
  323. // $(STOCKMNG01010_GRID_ID).jqGrid('setCell', rowId, 'whsNm', '', ITP_GRID_COL_STYLE.link);
  324. });
  325. },
  326. onPaging: function(action) {
  327. itp_fn_grid_paging(STOCKMNG01010_GRID_ID, action, param);
  328. }
  329. };
  330. itp_fn_grid_make_remote(option);
  331. },
  332. clearData : function() {
  333. $(STOCKMNG01010_GRID_ID).jqGrid('clearGridData', true);
  334. $(STOCKMNG01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  335. $(STOCKMNG01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  336. $(STOCKMNG01010_GRID_EMPTY).show();
  337. },
  338. unload : function() {
  339. $.jgrid.gridUnload(STOCKMNG01010_GRID_ID);
  340. }
  341. }
  342. };