ITP_COLLMNG03010.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. //화면변수
  8. const COLLMNG03010_GRID_ID = '#ITP_COLLMNG03010_jqGrid';
  9. const COLLMNG03010_GRID_LIST = '#ITP_COLLMNG03010_jqGrid_list';
  10. const COLLMNG03010_GRID_PAGER = '#ITP_COLLMNG03010_jqGridPager';
  11. const COLLMNG03010_GRID_EMPTY = '#ITP_COLLMNG03010_jqGridEmpty';
  12. //API URL
  13. let API_RTNMNG_INOUTMNG_SPPLY_PICK_GRID_LIST ='/api/rtnmng/inoutmng/spply-pick-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: 'BRAND_ID', name: 'brandId',
  25. label: ITP_MSG_LOCALE.label.brandId,
  26. width: '10', fixed: false, align: 'center',
  27. sortable: false, hidden: true
  28. },
  29. {
  30. index: 'BRAND_NM', name: 'brandNm',
  31. label: ITP_MSG_LOCALE.label.brandNm, // 브랜드명
  32. width: '10', fixed: false, align: 'center',
  33. sortable: false, hidden: false
  34. },
  35. {
  36. index: 'COL_PICK_UNQ_NO', name: 'colPickUnqNo',
  37. label: ITP_MSG_LOCALE.label.colPickUnqNo, // 수거서번호
  38. width: '10', fixed: false, align: 'center',
  39. sortable: false, hidden: false
  40. },
  41. {
  42. index: 'PICK_ST_NM', name: 'pickStNm',
  43. label: ITP_MSG_LOCALE.label.pickStNm, // 수거서상태
  44. width: '8', fixed: false, align: 'center',
  45. sortable: false, hidden: false
  46. },
  47. {
  48. index: 'COL_REQ_DT', name: 'colRegDt',
  49. label: ITP_MSG_LOCALE.label.colRegDt, // 수거일자
  50. width: '10', fixed: false, align: 'center',
  51. sortable: false, hidden: false
  52. },
  53. {
  54. index: 'COL_REQ_DT', name: 'colReqDt',
  55. label: ITP_MSG_LOCALE.label.colReqDt, // 수거요청일
  56. width: '10', fixed: false, align: 'center',
  57. sortable: false, hidden: false
  58. },
  59. {
  60. index: 'COL_SCH_DT', name: 'colSchDt',
  61. label: ITP_MSG_LOCALE.label.colSchDt, // 수거예정일
  62. width: '10', fixed: false, align: 'center',
  63. sortable: false, hidden: false
  64. },
  65. {
  66. index: 'ITEM_ID', name: 'itemId',
  67. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  68. width: '10', fixed: false, align: 'center',
  69. sortable: false, hidden: false
  70. },
  71. {
  72. index: 'ITEM_NM', name: 'itemNm',
  73. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  74. width: '8', fixed: false, align: 'center',
  75. sortable: false, hidden: false
  76. },
  77. {
  78. index: 'COL_REQ_QTY', name: 'colReqQty',
  79. label: ITP_MSG_LOCALE.label.colReqQty, // 수거수량
  80. width: '6', fixed: false, align: 'center',
  81. sortable: false, hidden: false
  82. },
  83. {
  84. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  85. label: ITP_MSG_LOCALE.label.rtnRsnDvsnNm, // 반품사유구분
  86. width: '9', fixed: false, align: 'center',
  87. sortable: false, hidden: false
  88. },
  89. {
  90. index: 'UNIT_AMT', name: 'unitAmt',
  91. label: ITP_MSG_LOCALE.label.unitAmt, // 단가
  92. width: '7', fixed: false, align: 'center',
  93. sortable: false, hidden: false
  94. },
  95. {
  96. index: 'COL_REQ_AMT', name: 'colReqAmt',
  97. label: ITP_MSG_LOCALE.label.colReqAmt, // 수거금액
  98. width: '9', fixed: false, align: 'center',
  99. sortable: false, hidden: false
  100. },
  101. {
  102. index: 'WHS_NM', name: 'whsNm',
  103. label: ITP_MSG_LOCALE.label.whsNm, // 납품장소
  104. width: '10', fixed: false, align: 'center',
  105. sortable: false, hidden: false
  106. },
  107. {
  108. index: 'PICK_MGR_NM', name: 'pickMgrNm',
  109. label: ITP_MSG_LOCALE.label.pickMgrNm, // 수거담당자
  110. width: '10', fixed: false, align: 'center',
  111. sortable: false, hidden: false
  112. },
  113. {
  114. index: 'PICK_MGR_TEL_NO', name: 'pickMgrTelNo',
  115. label: ITP_MSG_LOCALE.label.pickMgrTelNo, // 수거담당자연락처
  116. width: '10', fixed: false, align: 'center',
  117. sortable: false, hidden: false
  118. }
  119. ],
  120. view: [],
  121. detail: []
  122. };
  123. /*화면공통 Object*/
  124. let pageObj = {
  125. init: function() {
  126. this.ui.init();
  127. this.event.init();
  128. this.action();
  129. },
  130. ui: {
  131. init: function() {
  132. this.view();
  133. this.grid();
  134. this.ready();
  135. },
  136. view: function() {
  137. // 버튼 권한설정
  138. fn_proc_btn_auth('COLLMNG03010');
  139. // 공통코드 표시
  140. $('select').each(function() {
  141. if($(this).data('select-code')) {
  142. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  143. }
  144. });
  145. // 조회일자 지정
  146. var now = new Date();
  147. var defaultToDate = new Date(now);
  148. defaultToDate.setDate(now.getDate() + 7);
  149. $('#ITP_TAB_COLLMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  150. $('#ITP_FORM_COLLMNG03010_SEARCH_FROM_DT').datepicker('setDate', now);
  151. $('#ITP_FORM_COLLMNG03010_SEARCH_TO_DT').datepicker('setDate', defaultToDate);
  152. },
  153. grid: function() {
  154. itp_fn_jqgrid_resize(COLLMNG03010_GRID_ID, COLLMNG03010_GRID_LIST, 'lg');
  155. listObj.empty.init();
  156. itp_fn_fire_window_resize();
  157. },
  158. ready: function() {
  159. listObj.init();
  160. }
  161. },
  162. event: {
  163. init: function() {
  164. this.button();
  165. },
  166. button: function() {
  167. // 버튼 클릭 이벤트
  168. $('button').each(function() {
  169. var id = $(this).attr('id');
  170. $(this).on('click', function() {
  171. switch (id) {
  172. case 'ITP_BTN_COLLMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  173. case 'ITP_BTN_COLLMNG03010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  174. case 'ITP_BTN_COLLMNG03010_MODIFY' : modifyObj.button.modify(); break; // 수정 버튼
  175. case 'ITP_BTN_COLLMNG03010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  176. case 'ITP_BTN_COLLMNG03010_DELETE' : modifyObj.button.del(); break; // 발주 취소 버튼(예정)
  177. }
  178. });
  179. });
  180. }
  181. },
  182. switchScreen: function(mode) {
  183. $('.itp_det_head').find('button[id^="ITP_BTN_COLLMNG03010_"]').each(function(i) {
  184. $(this).hide();
  185. });
  186. $('#ITP_TAB_COLLMNG03010').find('div[id$="_CONTAINER"]').each(function(i) {
  187. $(this).hide();
  188. });
  189. if(mode == 'LIST') { // 목록
  190. fn_show_btn_auth_array(['#ITP_BTN_COLLMNG03010_SRH', '#ITP_BTN_COLLMNG03010_NEWREG']);
  191. $('#ITP_AJAX_COLLMNG03010_LIST_CONTAINER').show();
  192. $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  193. if(fn_make_user_info.get('spplyId').length != 0){
  194. $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  195. } else {
  196. $('#ITP_FORM_COLLMNG03010_SEARCH #ITP_FORM_COLLMNG03010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('userId'));
  197. }
  198. $('#ITP_BTN_COLLMNG03010_SRH').show();
  199. $('#ITP_BTN_COLLMNG03010_PRINT').show();
  200. $('#ITP_BTN_COLLMNG03010_SEARCH_WHS_ID').show();
  201. $('#ITP_BTN_COLLMNG03010_DELETE_WHS_ID').show();
  202. }
  203. },
  204. action: function() {
  205. var _this = this;
  206. $('#ITP_BTN_COLLMNG03010_PRINT').on('click', function() {
  207. _this.popup();
  208. });
  209. },
  210. popup: function() {
  211. var selectedIds = $(COLLMNG03010_GRID_ID).getGridParam('selarrrow');
  212. if(selectedIds.length > 1) { // 1이상 선택시
  213. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  214. return; //리턴
  215. }
  216. var selRowData ; //변수선언
  217. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  218. selRowData = $(COLLMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  219. }
  220. const key = {brandId: selRowData.brandId, colPickUnqNo: selRowData.colPickUnqNo}; // popup key 값 설정
  221. console.log(key);
  222. fn_call_popup('biz', 'BIZPOP_COL_STTMT_PRN', '#ITP_ASIDE', null, key, 'S');
  223. }
  224. };
  225. /*목록화면 Object*/
  226. let listObj = {
  227. init: function() {
  228. this.grid.init();
  229. this.action();
  230. },
  231. itp_COLLMNG03010_param: {},
  232. itp_COLLMNG03010_search: false,
  233. button: {
  234. search: function() {
  235. listObj.itp_COLLMNG03010_search = true;
  236. let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject();
  237. param.gridSize = $.jgrid.defaults.rowNum;
  238. param.gridPage = $.jgrid.defaults.page;
  239. console.log(1234);
  240. console.log(JSON.stringify(param));
  241. $(COLLMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  242. }
  243. },
  244. empty: {
  245. init: function() {
  246. var _this = this;
  247. this.push();
  248. $(COLLMNG03010_GRID_EMPTY).on('click', function() {
  249. _this.back();
  250. listObj.itp_COLLMNG03010_param.gridSize = $.jgrid.defaults.rowNum;
  251. $(COLLMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_COLLMNG03010_param)}).trigger('reloadGrid');
  252. });
  253. },
  254. push: function() {
  255. let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject();
  256. listObj.itp_COLLMNG03010_param = param;
  257. },
  258. back: function() {
  259. $('#ITP_FORM_COLLMNG03010_SERVICE_BRAND_TYPE').val(listObj.itp_COLLMNG03010_param.brandType);
  260. $('#ITP_FORM_COLLMNG03010_SERVICE_ST_CD').val(listObj.itp_COLLMNG03010_param.stCd);
  261. $('#ITP_FORM_COLLMNG03010_SEARCH_BRAND_NM').val(listObj.itp_COLLMNG03010_param.brandNm);
  262. }
  263. },
  264. grid: {
  265. init: function() {
  266. // 데이터 없을때
  267. listObj.empty.push();
  268. this.search();
  269. },
  270. colModel: gridColModel.list,
  271. search: function() {
  272. pageObj.switchScreen('LIST');
  273. this.unload();
  274. this.load();
  275. },
  276. load: function() {
  277. let param = $('#ITP_FORM_COLLMNG03010_SEARCH').serializeObject();
  278. param.gridSize = $.jgrid.defaults.rowNum;
  279. console.log(JSON.stringify(param));
  280. var option = {
  281. gridId: COLLMNG03010_GRID_ID,
  282. colModel: gridColModel.list,
  283. param: param,
  284. url: DOMAIN + API_RTNMNG_INOUTMNG_SPPLY_PICK_GRID_LIST,
  285. pager: COLLMNG03010_GRID_PAGER,
  286. multiselect: true,
  287. multiboxonly : false,
  288. rownumbers: false,/*
  289. onCellSelect: function(rowId, cellIdx, cellValue) {
  290. var cm = $(this).jqGrid('getGridParam', 'colModel');
  291. var colNm = cm[cellIdx].name;
  292. if (colNm === 'pchPodrUnqNo') {
  293. const pchPodrUnqNoVal = $(this).jqGrid('getCell', rowId, 'pchPodrUnqNo');
  294. const brandIdVal = $(this).jqGrid('getCell', rowId, 'brandId');
  295. const key = {pchPodrUnqNo: pchPodrUnqNoVal, brandId: brandIdVal};
  296. var param = $.param(key);
  297. modifyObj.init(param);
  298. }
  299. },*/
  300. loadComplete: function(data) {
  301. console.log(data);
  302. itp_fn_grid_load_complete(data, COLLMNG03010_GRID_ID, true, 'number', 'COLLMNG03010', listObj.itp_COLLMNG03010_search, listObj.empty, true, data.gridRecords, true);
  303. },
  304. onPaging: function(action) {
  305. itp_fn_grid_paging(COLLMNG03010_GRID_ID, action, param);
  306. }
  307. };
  308. itp_fn_grid_make_remote(option);
  309. },
  310. clearData: function() {
  311. $(COLLMNG03010_GRID_ID).jqGrid('clearGridData', true);
  312. $(COLLMNG03010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  313. $(COLLMNG03010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  314. $(COLLMNG03010_GRID_EMPTY).show();
  315. },
  316. unload: function() {
  317. $.jgrid.gridUnload(COLLMNG03010_GRID_ID);
  318. }
  319. },
  320. action: function() {
  321. var _this = this;
  322. // 출하창고 조회 버튼 클릭
  323. $('#ITP_BTN_COLLMNG03010_SEARCH_WHS_ID').on('click', function() {
  324. _this.popup();
  325. });
  326. // 출하창고 텍스트 삭제 버튼 클릭
  327. $('#ITP_BTN_COLLMNG03010_DELETE_WHS_ID').on('click', function() {
  328. $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_NM').val('');
  329. $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_ID').val('');
  330. });
  331. },
  332. popup: function() {
  333. var popFn = this.callback.create;
  334. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: ''};
  335. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  336. },
  337. callback: {
  338. create: function(rowDataPop) {
  339. console.log(rowDataPop);
  340. $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  341. $('#ITP_FORM_COLLMNG03010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  342. }
  343. }
  344. };