ITP_INOUTMNG04010.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. //화면변수
  8. const INOUTMNG04010_GRID_ID = '#ITP_INOUTMNG04010_jqGrid';
  9. const INOUTMNG04010_GRID_LIST = '#ITP_INOUTMNG04010_jqGrid_list';
  10. const INOUTMNG04010_GRID_PAGER = '#ITP_INOUTMNG04010_jqGridPager';
  11. const INOUTMNG04010_GRID_EMPTY = '#ITP_INOUTMNG04010_jqGridEmpty';
  12. let ITP_COL_CMD_DTL_ST_CD = fn_make_common_cd_list(CODE_LIST, 'COL_CMD_DTL_ST_CD', true, '수거상태코드');
  13. //API URL
  14. let API_RTNMNG_INOUTMNG_OUTSEARCH_GRID_LIST = '/api/rtnmng/inoutmng/colsearch-grid-list';
  15. //let API_RTNMNG_INOUTMNG_INFO_INV = '/api/rtnmng/inoutmng/info-pick';
  16. //화면 grid ColModel
  17. const gridColModel = {
  18. list:[
  19. {
  20. index: 'VIEW_CD', name: 'viewCd',
  21. label: ITP_MSG_LOCALE.label.viewCd,
  22. width: '10', fixed: false, align: 'center',
  23. sortable: false, hidden: true
  24. },
  25. {
  26. index: 'BRAND_NM', name: 'brandId',
  27. label: ITP_MSG_LOCALE.label.brandId, // 브랜드아이디
  28. width: '10', fixed: false, align: 'center',
  29. sortable: false, hidden: true
  30. },
  31. {
  32. index: 'BRAND_NM', name: 'brandNm',
  33. label: ITP_MSG_LOCALE.label.brandNm, // 브랜드명
  34. width: '10', fixed: false, align: 'center',
  35. minwidth: 100,
  36. sortable: false, hidden: false, classes: 'ui-ellipsis'
  37. },
  38. {
  39. index: 'SHMT_REQ_UNQ_NO', name: 'colCmdUnqNo',
  40. label: ITP_MSG_LOCALE.label.colCmdUnqNo, // 수거지시번호
  41. width: '10', fixed: false, align: 'center',
  42. minwidth: 140,
  43. sortable: false, hidden: false
  44. },
  45. {
  46. index: 'PCH_PODR_UNQ_NO', name: 'colCmdDtlNo',
  47. label: ITP_MSG_LOCALE.label.colCmdDtlNo, // 수거지시항번
  48. width: '10', fixed: false, align: 'center',
  49. minwidth: 100,
  50. sortable: false, hidden: false
  51. },
  52. {
  53. index: 'PCH_PODR_DTL_NO', name: 'rtnPodrUnqNo',
  54. label: ITP_MSG_LOCALE.label.rtnPodrUnqNo, // 반품발주번호
  55. width: '9', fixed: false, align: 'center',
  56. minwidth: 140,
  57. sortable: false, hidden: false
  58. },
  59. {
  60. index: 'PCH_PODR_DTL_NO', name: 'rtnPodrDtlNo',
  61. label: ITP_MSG_LOCALE.label.rtnPodrDtlNo, // 반품발주항번
  62. width: '9', fixed: false, align: 'center',
  63. minwidth: 100,
  64. sortable: false, hidden: false
  65. },
  66. {
  67. index: 'SHMT_REQ_ST_CD', name: 'colCmdDtlStCd',
  68. label: ITP_MSG_LOCALE.label.colCmdDtlStCd, // 수거지시상태
  69. width: '8', fixed: false, align: 'center',
  70. sortable: false, hidden: false, formatter: 'select', edittype: 'select',
  71. editoptions: {value: ITP_COL_CMD_DTL_ST_CD}
  72. },
  73. {
  74. index: 'ITEM_ID', name: 'itemId',
  75. label: ITP_MSG_LOCALE.label.itemId, // 품목번호
  76. width: '10', fixed: false, align: 'center',
  77. minwidth: 140,
  78. sortable: false, hidden: false
  79. },
  80. {
  81. index: 'ITEM_NM', name: 'itemNm',
  82. label: ITP_MSG_LOCALE.label.itemNm, // 품목명
  83. width: '10', fixed: false, align: 'left',
  84. minwidth: 120,
  85. sortable: false, hidden: false, classes: 'ui-ellipsis'
  86. },
  87. {
  88. index: 'WHS_NM', name: 'rtnWhsNm',
  89. label: ITP_MSG_LOCALE.label.rtnWhsNm, // 반품장소
  90. width: '10', fixed: false, align: 'left',
  91. minwidth: 200,
  92. sortable: false, hidden: false, classes: 'ui-ellipsis'
  93. },
  94. {
  95. index: 'SHMT_QTY', name: 'rtnQty',
  96. label: ITP_MSG_LOCALE.label.rtnQty, // 반품발주수량
  97. width: '14', fixed: false, align: 'right',
  98. sortable: false, hidden: false,
  99. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  100. },
  101. {
  102. index: 'WHS_QTY', name: 'colQty',
  103. label: ITP_MSG_LOCALE.label.colQty, // 수거수량
  104. width: '14', fixed: false, align: 'right',
  105. sortable: false, hidden: false,
  106. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  107. },
  108. {
  109. index: 'SHMT_AMT', name: 'colAmt',
  110. label: ITP_MSG_LOCALE.label.colAmt, // 수거금액
  111. width: '14', fixed: false, align: 'right',
  112. minwidth: 80,
  113. sortable: false, hidden: false,
  114. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  115. },
  116. {
  117. index: 'WHS_DT', name: 'colDt',
  118. label: ITP_MSG_LOCALE.label.colDt, // 수거일
  119. width: '10', fixed: false, align: 'center',
  120. minwidth: 100,
  121. sortable: false, hidden: false
  122. },
  123. {
  124. index: 'WHS_CNFM_NM', name: 'colCnfmNm',
  125. label: ITP_MSG_LOCALE.label.colCnfmNm, // 수거확인자
  126. width: '10', fixed: false, align: 'center',
  127. minwidth: 100,
  128. sortable: false, hidden: false
  129. },
  130. {
  131. index: 'DLV_STTMT_UNQ_NO', name: 'colPickUnqNo',
  132. label: ITP_MSG_LOCALE.label.colPickUnqNo, // 수거서번호
  133. width: '10', fixed: false, align: 'center',
  134. sortable: false, hidden: true
  135. }
  136. ],
  137. view: [],
  138. detail: []
  139. }
  140. /*화면공통 Object*/
  141. let pageObj = {
  142. init: function() {
  143. this.ui.init();
  144. this.event.init();
  145. this.action();
  146. },
  147. ui: {
  148. init: function() {
  149. this.view();
  150. this.grid();
  151. this.ready();
  152. },
  153. view: function() {
  154. // 버튼 권한설정
  155. fn_proc_btn_auth('INOUTMNG04010');
  156. // 공통코드 표시
  157. $('select').each(function() {
  158. if($(this).data('select-code')) {
  159. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  160. }
  161. });
  162. // 조회일자 지정
  163. var now = new Date();
  164. var fromDate = new Date(now);
  165. fromDate.setDate(now.getDate() - 7);
  166. var toDate = new Date(now);
  167. $('#ITP_TAB_INOUTMNG04010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  168. $('#ITP_FORM_INOUTMNG04010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  169. $('#ITP_FORM_INOUTMNG04010_SEARCH_TO_DT').datepicker('setDate', toDate);
  170. },
  171. grid: function() {
  172. itp_fn_jqgrid_resize(INOUTMNG04010_GRID_ID, INOUTMNG04010_GRID_LIST, 'lg');
  173. listObj.empty.init();
  174. },
  175. ready: function() {
  176. listObj.init();
  177. }
  178. },
  179. event: {
  180. init: function() {
  181. this.button();
  182. },
  183. button: function() {
  184. // 버튼 클릭 이벤트
  185. $('button').each(function() {
  186. var id = $(this).attr('id');
  187. $(this).on('click', function() {
  188. switch (id) {
  189. case 'ITP_BTN_INOUTMNG04010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  190. case 'ITP_BTN_INOUTMNG04010_EXCEL' : listObj.excelDown(); break; // 엑셀다운로드
  191. }
  192. });
  193. });
  194. }
  195. },
  196. switchScreen: function(mode) {
  197. $('.itp_det_head').find('button[id^="ITP_BTN_INOUTMNG04010_"]').each(function(i) {
  198. $(this).hide();
  199. });
  200. $('#ITP_TAB_INOUTMNG04010').find('div[id$="_CONTAINER"]').each(function(i) {
  201. $(this).hide();
  202. });
  203. if(mode == 'LIST') { // 목록
  204. itp_fn_fire_window_resize();
  205. fn_show_btn_auth_array(['#ITP_BTN_INOUTMNG04010_PRINT', '#ITP_BTN_INOUTMNG04010_SRH']);
  206. $('#ITP_AJAX_INOUTMNG04010_LIST_CONTAINER').show();
  207. $('#ITP_BTN_INOUTMNG04010_DELETE_RTN_WHS_ID').show();
  208. $('#ITP_BTN_INOUTMNG04010_DELETE_WHS_ID').show();
  209. $('#ITP_FORM_INOUTMNG04010_SEARCH #ITP_FORM_INOUTMNG04010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  210. $('#ITP_BTN_INOUTMNG04010_EXCEL').show();
  211. }
  212. },
  213. action: function() {
  214. var _this = this;
  215. // 출하창고 조회 버튼 클릭
  216. $('#ITP_BTN_INOUTMNG04010_PRINT').on('click', function() {
  217. _this.popup();
  218. });
  219. },
  220. popup: function() {
  221. var selectedIds = $(INOUTMNG04010_GRID_ID).getGridParam('selarrrow');
  222. if(selectedIds.length > 1) { // 1이상 선택시
  223. alert("수거서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  224. return; //리턴
  225. }
  226. var selRowData ; //변수선언
  227. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  228. selRowData = $(INOUTMNG04010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  229. }
  230. const key = {brandId: fn_make_user_info.get('brandId'), colPickUnqNo: selRowData.colPickUnqNo}; // popup key 값 설정
  231. fn_call_popup('biz', 'BIZPOP_COL_STTMT_PRN', '#ITP_ASIDE', null, key, 'S');
  232. }
  233. };
  234. /*목록화면 Object*/
  235. let listObj = {
  236. init: function() {
  237. this.grid.init();
  238. this.action();
  239. },
  240. itp_INOUTMNG04010_param: {},
  241. itp_INOUTMNG04010_search: false,
  242. button: {
  243. search: function() {
  244. listObj.itp_INOUTMNG04010_search = true;
  245. let param = $('#ITP_FORM_INOUTMNG04010_SEARCH').serializeObject();
  246. param.gridSize = $.jgrid.defaults.rowNum;
  247. param.gridPage = $.jgrid.defaults.page;
  248. param.sidx = '0';
  249. console.log(JSON.stringify(param));
  250. $(INOUTMNG04010_GRID_ID).data('grid-param',param);
  251. $(INOUTMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  252. }
  253. },
  254. empty: {
  255. init: function() {
  256. var _this = this;
  257. this.push();
  258. $(INOUTMNG04010_GRID_EMPTY).on('click', function() {
  259. _this.back();
  260. listObj.itp_INOUTMNG04010_param.gridSize = $.jgrid.defaults.rowNum;
  261. $(INOUTMNG04010_GRID_ID).setGridParam({'postData': JSON.stringify(listObj.itp_INOUTMNG04010_param)}).trigger('reloadGrid');
  262. });
  263. },
  264. push: function() {
  265. let param = $('#ITP_FORM_INOUTMNG04010_SEARCH').serializeObject();
  266. listObj.itp_INOUTMNG04010_param = param;
  267. param.sidx = '0';
  268. },
  269. back: function() {
  270. $('#ITP_FORM_INOUTMNG04010_SERVICE_BRAND_TYPE').val(listObj.itp_INOUTMNG04010_param.brandType);
  271. $('#ITP_FORM_INOUTMNG04010_SERVICE_ST_CD').val(listObj.itp_INOUTMNG04010_param.stCd);
  272. $('#ITP_FORM_INOUTMNG04010_SEARCH_BRAND_NM').val(listObj.itp_INOUTMNG04010_param.brandNm);
  273. }
  274. },
  275. grid: {
  276. init: function() {
  277. // 데이터 없을때
  278. listObj.empty.push();
  279. this.search();
  280. },
  281. colModel: gridColModel.list,
  282. search: function() {
  283. pageObj.switchScreen('LIST');
  284. this.unload();
  285. this.load();
  286. },
  287. load: function() {
  288. let param = $('#ITP_FORM_INOUTMNG04010_SEARCH').serializeObject();
  289. param.gridSize = $.jgrid.defaults.rowNum;
  290. param.sidx = '0';
  291. console.log(JSON.stringify(param));
  292. var option = {
  293. gridId: INOUTMNG04010_GRID_ID,
  294. colModel: gridColModel.list,
  295. param: param,
  296. url: DOMAIN + API_RTNMNG_INOUTMNG_OUTSEARCH_GRID_LIST,
  297. pager: INOUTMNG04010_GRID_PAGER,
  298. multiselect: true,
  299. multiboxonly : false,
  300. rownumbers: false,
  301. loadComplete: function(data) {
  302. console.log(data);
  303. itp_fn_grid_load_complete(data, INOUTMNG04010_GRID_ID, true, 'number', 'INOUTMNG04010', listObj.itp_INOUTMNG04010_search, listObj.empty, true, data.gridRecords, true);
  304. },
  305. onPaging: function(action) {
  306. itp_fn_grid_paging(INOUTMNG04010_GRID_ID, action, param);
  307. }
  308. };
  309. itp_fn_grid_make_remote(option);
  310. },
  311. clearData: function() {
  312. $(INOUTMNG04010_GRID_ID).jqGrid('clearGridData', true);
  313. $(INOUTMNG04010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  314. $(INOUTMNG04010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  315. $(INOUTMNG04010_GRID_EMPTY).show();
  316. },
  317. unload: function() {
  318. $.jgrid.gridUnload(INOUTMNG04010_GRID_ID);
  319. }
  320. },
  321. action: function() {
  322. var _this = this;
  323. // 반품창고 조회 버튼 클릭
  324. $('#ITP_BTN_INOUTMNG04010_SEARCH_RTN_WHS_ID').on('click', function() {
  325. _this.popup('rtnWhs');
  326. });
  327. // 반품창고 텍스트 삭제 버튼 클릭
  328. $('#ITP_BTN_INOUTMNG04010_DELETE_RTN_WHS_ID').on('click', function() {
  329. $('#ITP_FORM_INOUTMNG04010_SEARCH_SRTN_WHS_ID').val('');
  330. $('#ITP_FORM_INOUTMNG04010_SEARCH_SRTN_WHS_NM').val('');
  331. });
  332. // 수거창고 조회 버튼 클릭
  333. $('#ITP_BTN_INOUTMNG04010_SEARCH_WHS_ID').on('click', function() {
  334. _this.popup('whs');
  335. });
  336. // 수거창고 텍스트 삭제 버튼 클릭
  337. $('#ITP_BTN_INOUTMNG04010_DELETE_WHS_ID').on('click', function() {
  338. $('#ITP_FORM_INOUTMNG04010_SEARCH_SWHS_NM').val('');
  339. $('#ITP_FORM_INOUTMNG04010_SEARCH_SWHS_ID').val('');
  340. });
  341. },
  342. popup: function(keyword) {
  343. var popFn ;
  344. if(keyword == 'rtnWhs') {
  345. popFn = this.callback.rtnWhs;
  346. } else if(keyword == 'whs'){
  347. popFn = this.callback.whs;
  348. }
  349. var whsDvsn = "";
  350. if(keyword == 'rtnWhs') {
  351. whsDvsn = "";
  352. } else if(keyword == 'whs'){
  353. whsDvsn = "W01";
  354. }
  355. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: whsDvsn};
  356. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  357. },
  358. callback: {
  359. rtnWhs: function(rowDataPop) {
  360. console.log(rowDataPop);
  361. $('#ITP_FORM_INOUTMNG04010_SEARCH_SRTN_WHS_ID').val(rowDataPop.whsId);
  362. $('#ITP_FORM_INOUTMNG04010_SEARCH_SRTN_WHS_NM').val(rowDataPop.whsNm);
  363. },
  364. whs: function(rowDataPop) {
  365. console.log(rowDataPop);
  366. $('#ITP_FORM_INOUTMNG04010_SEARCH_SWHS_ID').val(rowDataPop.whsId);
  367. $('#ITP_FORM_INOUTMNG04010_SEARCH_SWHS_NM').val(rowDataPop.whsNm);
  368. }
  369. },
  370. excelDown: function() {
  371. var param = {
  372. 'url': API_RTNMNG_INOUTMNG_OUTSEARCH_GRID_LIST,
  373. 'param': $('#ITP_FORM_INOUTMNG04010_SEARCH').serializeObject(),
  374. 'gridColumns': $(INOUTMNG04010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  375. 'fileName': '수거지시현황.xlsx',
  376. 'sheetName': '수거지시리스트'
  377. };
  378. itp_fn_remote_to_excel(param);
  379. }
  380. }