ITP_STOCKMNG01010.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /********************************************************
  2. --------------------------------------------------------
  3. - Object 목록 -
  4. --------------------------------------------------------
  5. * const gridColModel = {} : 화면 Grid Object *
  6. * let pageObj = {} : 화면공통 Object *
  7. * let listObj = {} : 목록화면 Object *
  8. * let viewObj = {} : 상세화면 Object *
  9. * let modifyObj = {} : 수정화면 Object *
  10. * let createObj = {} : 신규화면 Object *
  11. * let locInfoObj = {} : 로케이션정보 Object *
  12. *******************************************************/
  13. /*화면 변수*/
  14. const STOCKMNG01010_GRID_ID = '#ITP_STOCKMNG01010_jqGrid';
  15. const STOCKMNG01010_GRID_LIST = '#ITP_STOCKMNG01010_jqGrid_list';
  16. const STOCKMNG01010_GRID_PAGER = '#ITP_STOCKMNG01010_jqGridPager';
  17. const STOCKMNG01010_GRID_EMPTY = '#ITP_STOCKMNG01010_jqGridEmpty';
  18. let ITP_FORM_STOCKMNG01010_DETAIL_IS_DUPLICATE = false;
  19. let ITP_FORM_STOCKMNG01010_DETAIL_IS_WRITING = false;
  20. let STOCKMNG01010_DETAIL_GRID_LAST_ROW_ID;
  21. /*API URL*/
  22. let STOCK_MNG_DETAIL_GRID_LIST = '/api/stock/mng/detail-grid-list';
  23. let WHS_MNG_ADD_WHS = '/api/whs/mng/add-whs';
  24. let WHS_MNG_DETAIL_GRID_LIST = '/api/whs/mng/detail-grid-list';
  25. let WHS_MNG_LOCATION_GRID_LIST = '/api/whs/mng/location-grid-list';
  26. /*화면 Grid ColModel*/
  27. const gridColModel = {
  28. list: [
  29. {
  30. index: 'BRAND_ID', name: 'brandId',
  31. label: "브랜드ID",
  32. width: '0', fixed: false, align: 'center',
  33. sortable: false, hidden: true
  34. },
  35. {
  36. index: 'STORE_ID', name: 'storeId',
  37. label: "매장ID",
  38. width: '0', fixed: false, align: 'center',
  39. sortable: false, hidden: true
  40. },
  41. {
  42. index: 'BRAND_NM', name: 'brandNm',
  43. label: ITP_MSG_LOCALE.label.brandNm, //브랜드
  44. width: '13', fixed: false, align: 'center',
  45. sortable: false, hidden: false
  46. },
  47. {
  48. index: 'STORE_NM', name: 'storeNm',
  49. label: "매장명",
  50. width: '13', fixed: false, align: 'center',
  51. sortable: false, hidden: false
  52. },
  53. {
  54. index: 'WHS_ID', name: 'whsId',
  55. label: "창고번호",
  56. width: '8', fixed: false, align: 'center',
  57. sortable: false, hidden: false
  58. },
  59. {
  60. index: 'WHS_NM', name: 'whsNm',
  61. label: "창고명",
  62. width: '13', fixed: false, align: 'center',
  63. sortable: false, hidden: false
  64. },
  65. {
  66. index: 'WHS_ST_NM', name: 'whsStNm',
  67. label: ITP_MSG_LOCALE.label.status, //상태
  68. width: '6', fixed: false, align: 'center',
  69. sortable: false, hidden: false
  70. },
  71. {
  72. index: 'MGR_NM', name: 'mgrNm',
  73. label: "담당자명",
  74. width: '8', fixed: false, align: 'center',
  75. sortable: false, hidden: false
  76. },
  77. {
  78. index: 'MGR_TEL_NO', name: 'mgrTelNo',
  79. label: "연락처",
  80. width: '8', fixed: false, align: 'center',
  81. sortable: false, hidden: false
  82. }
  83. ]
  84. };
  85. require(['config'], function() {
  86. require([
  87. ], function($) {
  88. pageObj.init();
  89. });
  90. });
  91. /*화면공통 Object*/
  92. let pageObj = {
  93. init: function () {
  94. this.ui.init();
  95. this.event.init();
  96. },
  97. ui: {
  98. init: function () {
  99. this.view();
  100. this.grid();
  101. this.ready();
  102. },
  103. view: function() {
  104. // 버튼 권한설정
  105. fn_proc_btn_auth('STOCKMNG01010');
  106. // 브랜드ID 지정
  107. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_cd'));
  108. $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
  109. pageObj.fnWhsList(function() {
  110. pageObj.fnLocationList();
  111. }); // 창고리스트
  112. // 공통코드 표시
  113. // fn_make_select(CODE_LIST, 'WHS_DVSN', 'ITP_FORM_STOCKMNG01010_WHS_DVSN');
  114. // 조회일자 지정
  115. $('#ITP_TAB_STOCKMNG01010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  116. },
  117. grid: function() {
  118. itp_fn_jqgrid_resize(STOCKMNG01010_GRID_ID, STOCKMNG01010_GRID_LIST, 'lg');
  119. listObj.empty.init();
  120. itp_fn_fire_window_resize();
  121. },
  122. ready: function() {
  123. listObj.init();
  124. }
  125. },
  126. event: {
  127. init: function () {
  128. this.button();
  129. },
  130. button: function () {
  131. // 버튼 클릭 이벤트
  132. $('button').each(function() {
  133. var id = $(this).attr('id');
  134. $(this).on('click', function() {
  135. switch (id) {
  136. case 'ITP_BTN_STOCKMNG01010_SRH' : listObj.button.search(); break; // 조회 버튼
  137. case 'ITP_BTN_STOCKMNG01010_ADDROW' : locInfoObj.button.addRow(); break; // 재고처리 버튼
  138. case 'ITP_BTN_STOCKMNG01010_DELROW' : locInfoObj.button.delRow(); break; // 재고이력 버튼
  139. }
  140. });
  141. });
  142. $('body').on('click', function(e) {
  143. });
  144. }
  145. },
  146. switchScreen: function(mode) {
  147. if(mode == 'LIST') { // 목록
  148. fn_show_btn_auth('#ITP_BTN_STOCKMNG01010_SRH');
  149. $('#ITP_AJAX_STOCKMNG01010_LIST_CONTAINER').show();
  150. }
  151. },
  152. fnWhsList: function(fnCall) {
  153. const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
  154. const param = {sbrandId: brandIdVal, pagingYn: false};
  155. fn_ajax_call(WHS_MNG_DETAIL_GRID_LIST, JSON.stringify(param), function(result) {
  156. fn_make_select_whs(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID');
  157. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  158. }, 'POST');
  159. },
  160. fnLocationList: function(fnCall) {
  161. const brandIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val();
  162. const whsIdVal = $('#ITP_FORM_STOCKMNG01010_SEARCH_WHS_ID').val();
  163. const param = {brandId: brandIdVal, whsId: whsIdVal, pagingYn: false};
  164. fn_ajax_call(WHS_MNG_LOCATION_GRID_LIST, JSON.stringify(param), function(result) {
  165. fn_make_select_location(result.gridRows, 'ITP_FORM_STOCKMNG01010_SEARCH_LOCATION');
  166. if (fnCall !== undefined || typeof fnCall !== 'undefined') fnCall();
  167. }, 'POST');
  168. }
  169. };
  170. /*목록화면 Object*/
  171. let listObj = {
  172. init: function () {
  173. this.grid.init();
  174. },
  175. itp_STOCKMNG01010_search: false,
  176. button: {
  177. search: function() {
  178. listObj.itp_STOCKMNG01010_search = true;
  179. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  180. param.gridSize = $.jgrid.defaults.rowNum;
  181. param.gridPage = $.jgrid.defaults.page;
  182. $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  183. },
  184. create: function() {
  185. pageObj.switchScreen('ADD');
  186. itp_fn_form_clear_validate(null, '#ITP_FORM_STOCKMNG01010_DETAIL');
  187. // 로케이션 리스트 조회
  188. createObj.init();
  189. }
  190. },
  191. empty: {
  192. init: function() {
  193. var _this = this;
  194. this.push();
  195. $(STOCKMNG01010_GRID_EMPTY).on('click', function() {
  196. _this.back();
  197. _this.itp_STOCKMNG01010_param.gridSize = $.jgrid.defaults.rowNum;
  198. $(STOCKMNG01010_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_STOCKMNG01010_param)}).trigger('reloadGrid');
  199. });
  200. },
  201. itp_STOCKMNG01010_param: {},
  202. push: function() {
  203. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  204. listObj.itp_STOCKMNG01010_param = param;
  205. },
  206. back: function() {
  207. $('#ITP_FORM_STOCKMNG01010_DEVI_TP_CD').val(this.itp_STOCKMNG01010_param.deviTpCd);
  208. $('#ITP_FORM_STOCKMNG01010_ORDER_YN').val(this.itp_STOCKMNG01010_param.orderYn);
  209. $('#ITP_FORM_STOCKMNG01010_ADT_AUTH_CD').val(this.itp_STOCKMNG01010_param.adtAuthCd);
  210. $('#ITP_FORM_STOCKMNG01010_EMAIL_RCV_YN').val(this.itp_STOCKMNG01010_param.emailRcvYn);
  211. $('#ITP_FORM_STOCKMNG01010_MEMB_EXIT_DT').val(this.itp_STOCKMNG01010_param.membExitDt);
  212. $('#ITP_FORM_STOCKMNG01010_FROM_DT').val(this.itp_STOCKMNG01010_param.fromDt);
  213. $('#ITP_FORM_STOCKMNG01010_TO_DT').val(this.itp_STOCKMNG01010_param.toDt);
  214. $('#ITP_FORM_STOCKMNG01010_KEYWORD').val(this.itp_STOCKMNG01010_param.keyword);
  215. }
  216. },
  217. grid: {
  218. init: function () {
  219. // 데이터 없을때
  220. listObj.empty.push();
  221. this.search();
  222. },
  223. colModel: gridColModel.list,
  224. search: function() {
  225. pageObj.switchScreen('LIST');
  226. this.unload();
  227. this.load();
  228. },
  229. load: function() {
  230. var data = JSON.parse(sessionStorage.getItem('itp_manage_brand_cd'));
  231. $('#ITP_FORM_STOCKMNG01010_SEARCH_BRAND_ID').val(data.brandId);
  232. let param = $('#ITP_FORM_STOCKMNG01010_SEARCH').serializeObject();
  233. param.gridSize = $.jgrid.defaults.rowNum;
  234. var option = {
  235. gridId: STOCKMNG01010_GRID_ID,
  236. colModel: gridColModel.list,
  237. param: JSON.stringify(param),
  238. url: DOMAIN + STOCK_MNG_DETAIL_GRID_LIST,
  239. pager: STOCKMNG01010_GRID_PAGER,
  240. onCellSelect: function(rowId, cellIdx, cellValue) {
  241. var cm = $(this).jqGrid('getGridParam', 'colModel');
  242. var colNm = cm[cellIdx].name;
  243. if (colNm == 'whsNm') {
  244. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  245. const whsIdVal = $(this).jqGrid('getCell', rowId, 'whsId');
  246. const key = {brandId: brandIdVal, whsId: whsIdVal, viewCd: 'R'};
  247. var param = $.param(key);
  248. viewObj.init(param);
  249. }
  250. },
  251. loadComplete: function(data) {
  252. console.log(data);
  253. itp_fn_grid_load_complete(data, STOCKMNG01010_GRID_ID, true, 'number', 'STOCKMNG01010', listObj.itp_STOCKMNG01010_search, listObj.empty, true, data.gridRecords, true);
  254. var ids = $(STOCKMNG01010_GRID_ID).getDataIDs();
  255. $.each(ids, function(idx, rowId) {
  256. $(STOCKMNG01010_GRID_ID).jqGrid('setCell', rowId, 'whsNm', '', ITP_GRID_COL_STYLE.link);
  257. });
  258. },
  259. onPaging: function(action) {
  260. itp_fn_grid_paging(STOCKMNG01010_GRID_ID, action, param);
  261. }
  262. };
  263. itp_fn_grid_make_remote(option);
  264. },
  265. clearData : function() {
  266. $(STOCKMNG01010_GRID_ID).jqGrid('clearGridData', true);
  267. $(STOCKMNG01010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  268. $(STOCKMNG01010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  269. $(STOCKMNG01010_GRID_EMPTY).show();
  270. },
  271. unload : function() {
  272. $.jgrid.gridUnload(STOCKMNG01010_GRID_ID);
  273. }
  274. }
  275. };