ITP_STOCKMNG01010.js 11 KB

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