ITP_STOCKMNG01010.js 8.4 KB

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