ITP_POMNG05010.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. /********************************************************
  8. --------------------------------------------------------
  9. - Object 목록 -
  10. --------------------------------------------------------
  11. * const gridColModel = {} : 화면 Grid Object *
  12. * let pageObj = {} : 화면공통 Object *
  13. * let listObj = {} : 목록화면 Object *
  14. * let viewObj = {} : 상세화면 Object *
  15. * let modifyObj = {} : 수정화면 Object *
  16. * let createObj = {} : 신규화면 Object *
  17. *******************************************************/
  18. /*화면 변수*/
  19. const POMNG05010_GRID_ID = '#ITP_POMNG05010_jqGrid';
  20. const POMNG05010_GRID_LIST = '#ITP_POMNG05010_jqGrid_list';
  21. const POMNG05010_GRID_PAGER = '#ITP_POMNG05010_jqGridPager';
  22. const POMNG05010_GRID_EMPTY = '#ITP_POMNG05010_jqGridEmpty';
  23. /*API URL*/
  24. let API_DETAIL_GRID_LIST = '/api/pomng/inoutmng/deli-grid-list';// 목록
  25. let API_DETAIL_INFO = '/api/pomng/inoutmng/info-inv'; // 상세
  26. /*화면 Grid ColModel*/
  27. const gridColModel = {
  28. list: [ //DLV1 뭔지 물어보기
  29. {
  30. index: 'Brand_ID', name: 'brandId',
  31. label: ITP_MSG_LOCALE.label.brandId,
  32. width: '18', fixed: false, align: 'center',
  33. sortable: false, hidden: true
  34. },
  35. {
  36. index: 'Brand_Nm', name: 'brandNm',
  37. label: ITP_MSG_LOCALE.label.brandNm, //브랜드이름
  38. width: '20', fixed: false, align: 'left',
  39. minwidth:150,
  40. sortable: false, hidden: false, classes: 'ui-ellipsis'
  41. },
  42. {
  43. index: 'DLV_STTMT_NO', name: 'dlvSttmtUnqNo',
  44. label: ITP_MSG_LOCALE.label.dlvSttmtUnqNo, //납품서번호
  45. width: '20', fixed: false, align: 'center',
  46. minwidth:140,
  47. sortable: false, hidden: false
  48. },
  49. {
  50. index: 'PODR_REG_DT', name: 'pchPodrUnqNo',
  51. label: '발주번호', //발주번호
  52. width: '14', fixed: false, align: 'center',
  53. minwidth:140,
  54. sortable: false, hidden: false
  55. },
  56. {
  57. index: 'PODR_REG_DT', name: 'spplyNm',
  58. label: '공급업체', //공급업체
  59. width: '14', fixed: false, align: 'left',
  60. minwidth:140,
  61. sortable: false, hidden: false, classes: 'ui-ellipsis'
  62. },
  63. {
  64. index: 'DLV_ST_CD', name: 'dlvStNm',
  65. label: '납품상태', //납품서상태
  66. width: '12', fixed: false, align: 'center',
  67. minwidth:70,
  68. sortable: false, hidden: false
  69. },
  70. {
  71. index: 'WHS_NM', name: 'whsNm',
  72. label: '입고처', //납품장소
  73. width: '20', fixed: false, align: 'left',
  74. minwidth:220,
  75. sortable: false, hidden: false, classes: 'ui-ellipsis'
  76. },
  77. {
  78. index: 'PODR_REG_DT', name: 'podrRegDt',
  79. label: '발주생성일', //발주생성일
  80. width: '14', fixed: false, align: 'center',
  81. minwidth:90,
  82. sortable: false, hidden: false
  83. },
  84. {
  85. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  86. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  87. width: '14', fixed: false, align: 'center',
  88. minwidth:90,
  89. sortable: false, hidden: false
  90. },
  91. {
  92. index: 'DLV_REG_DT', name: 'dlvRegDt',
  93. label: '납품생성일', //발주생성일
  94. width: '14', fixed: false, align: 'center',
  95. minwidth:90,
  96. sortable: false, hidden: false
  97. },
  98. {
  99. index: 'DLV_SCH_DT', name: 'dlvSchDt',
  100. label: ITP_MSG_LOCALE.label.dlvDt, //납품일
  101. width: '14', fixed: false, align: 'center',
  102. minwidth:90,
  103. sortable: false, hidden: false
  104. },
  105. {
  106. index: 'DLV_CMPLT_DT', name: 'dlvCmpltDt',
  107. label: '납품완료일', //납품완료일
  108. width: '10', fixed: false, align: 'center',
  109. minwidth:90,
  110. sortable: false, hidden: false
  111. },
  112. {
  113. index: 'ITEM_ID', name: 'itemId',
  114. label: ITP_MSG_LOCALE.label.itemId, //품목번호
  115. width: '11', fixed: false, align: 'center',
  116. minwidth:150,
  117. sortable: false, hidden: false
  118. },
  119. {
  120. index: 'ITEM_NM', name: 'itemNm',
  121. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  122. width: '10', fixed: false, align: 'left',
  123. minwidth:180,
  124. sortable: false, hidden: false, classes: 'ui-ellipsis'
  125. },
  126. {
  127. index: 'PODR_QTY', name: 'podrQty',
  128. label: ITP_MSG_LOCALE.label.podrQty, //수주수량
  129. width: '6', fixed: false, align: 'right',
  130. minwidth:80,
  131. sortable: false, hidden: false
  132. },
  133. {
  134. index: 'DLV_QTY', name: 'dlvQty',
  135. label: ITP_MSG_LOCALE.label.dlvQty, //납품수량
  136. width: '6', fixed: false, align: 'right',
  137. minwidth:80,
  138. sortable: false, hidden: false
  139. },
  140. {
  141. index: 'UNIT', name: 'unit',
  142. label: ITP_MSG_LOCALE.label.unit, //단가
  143. width: '6', fixed: false, align: 'right',
  144. sortable: false, hidden: true
  145. },
  146. {
  147. index: 'UNIT_AMT', name: 'unitAmt',
  148. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  149. width: '6', fixed: false, align: 'right',
  150. minwidth:80,
  151. sortable: false, hidden: false,
  152. formatter:'integer',formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  153. },
  154. {
  155. index: 'DLV_MGR_NM', name: 'dlvMgrNm',
  156. label: ITP_MSG_LOCALE.label.dlvMgrNm, //납품담당자
  157. width: '8', fixed: false, align: 'left',
  158. minwidth:100,
  159. sortable: false, hidden: false, classes: 'ui-ellipsis'
  160. },
  161. {
  162. index: 'DLV_MGR_TEL_NO', name: 'dlvMgrTelNo',
  163. label: ITP_MSG_LOCALE.label.dlvMgrTelNo, //납품담당연락처
  164. width: '10', fixed: false, align: 'center',
  165. minwidth:120,
  166. sortable: false, hidden: false
  167. },
  168. {
  169. index: 'WHS_DVSN_NM', name: 'whsDvsnNm',
  170. label: ITP_MSG_LOCALE.label.whsDvsnNm, //창고구분
  171. width: '10', fixed: false, align: 'center',
  172. minwidth:100,
  173. sortable: false, hidden: false
  174. }
  175. ]
  176. };
  177. /*화면공통 Object*/
  178. let pageObj = {
  179. init: function () {
  180. this.ui.init();
  181. this.event.init();
  182. this.action();
  183. },
  184. ui: {
  185. init: function () {
  186. this.view();
  187. listObj.init();
  188. },
  189. view: function() {
  190. // 버튼 권한설정
  191. fn_proc_btn_auth('POMNG05010');
  192. // 공통코드 표시
  193. $('select').each(function() {
  194. if($(this).data('select-code')) {
  195. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  196. }
  197. });
  198. // 조회일자 지정
  199. var now = new Date();
  200. var fromDate = new Date(now);
  201. fromDate.setDate(now.getDate() - 7);
  202. var toDate = new Date(now);
  203. $('#ITP_TAB_POMNG05010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  204. $('#ITP_FORM_POMNG05010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  205. $('#ITP_FORM_POMNG05010_SEARCH_TO_DT').datepicker('setDate', toDate);
  206. $('#ITP_BTN_POMNG05010_EXCEL').show();
  207. },
  208. },
  209. action: function () {
  210. var _this = this;
  211. // 검색 공급사
  212. $('#ITP_BTN_POMNG05010_SEARCH_SPPLY_NM').on('click', function() {
  213. _this.popup('SS');
  214. });
  215. // 검색 텍스트 삭제 버튼 클릭
  216. $('#ITP_BTN_POMNG05010_DELETE_SPPLY_NM').on('click', function() {
  217. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_NM').val('');
  218. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_ID').val('');
  219. });
  220. // 검색 납품장소
  221. $('#ITP_BTN_POMNG05010_SEARCH_SWHS_NM').on('click', function() {
  222. _this.popup('SW');
  223. });
  224. // 검색 납품장소 텍스트 삭제 버튼 클릭
  225. $('#ITP_BTN_POMNG05010_DELETE_SWHS_NM').on('click', function() {
  226. $('#ITP_FORM_POMNG05010_SEARCH_WHS_NM').val('');
  227. $('#ITP_FORM_POMNG05010_SEARCH_WHS_ID').val('');
  228. });
  229. },
  230. popup: function (arg) {
  231. var popFn ;
  232. // 팝업
  233. if (arg == "SW") {
  234. popFn = this.callback.searWhs;
  235. } else if (arg == "SS") {
  236. popFn = this.callback.searSpply;
  237. }
  238. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  239. if (arg == "SW" ) {
  240. const keya = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  241. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keya, 'S');
  242. } else if (arg == "SS") {
  243. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  244. }
  245. },
  246. callback: {
  247. searSpply: function(rowDataPop) {
  248. if(rowDataPop) {
  249. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_NM').val(rowDataPop.spplyNm);
  250. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_ID').val(rowDataPop.spplyId);
  251. }
  252. },
  253. searWhs: function(rowDataPop) {
  254. if(rowDataPop) {
  255. $('#ITP_FORM_POMNG05010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  256. $('#ITP_FORM_POMNG05010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  257. }
  258. }
  259. },
  260. event: {
  261. init: function () {
  262. this.button();
  263. },
  264. button: function () {
  265. // 버튼 클릭 이벤트
  266. $('button').each(function() {
  267. var id = $(this).attr('id');
  268. $(this).on('click', function() {
  269. switch (id) {
  270. case 'ITP_BTN_POMNG05010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  271. case 'ITP_BTN_POMNG05010_PRT' : listObj.button.print(); break; // 납품서출력 버튼
  272. case 'ITP_BTN_POMNG05010_EXCEL' : listObj.excelDown(); break; // 엑셀
  273. }
  274. });
  275. });
  276. }
  277. },
  278. screen: function() {
  279. $('#ITP_FORM_POMNG05010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));//input hidden 값 넣기
  280. $('#ITP_FORM_POMNG05010_SEARCH_DTL_GUBUN').val('dtlGubun');
  281. $('#ITP_BTN_POMNG05010_DELETE_SPPLY_NM').show();
  282. $('#ITP_BTN_POMNG05010_DELETE_SWHS_NM').show();
  283. }
  284. };
  285. /*목록화면 Object*/
  286. let listObj = {
  287. init: function () {
  288. this.grid.init();
  289. },
  290. itp_POMNG05010_search: false,
  291. button: {
  292. search: function() {
  293. listObj.itp_POMNG05010_search = true;
  294. let param = $('#ITP_FORM_POMNG05010_SEARCH').serializeObject();
  295. param.gridSize = $.jgrid.defaults.rowNum;
  296. param.gridPage = $.jgrid.defaults.page;
  297. console.log(param);
  298. $(POMNG05010_GRID_ID).data('grid-param',param);
  299. $(POMNG05010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  300. },
  301. print: function() {
  302. if(!fn_make_user_info.isEmpty()) {
  303. const rowKey = $(POMNG05010_GRID_ID).getGridParam('selrow'); // 그리드 셀 선택
  304. if (!rowKey) {//선택 안했을시
  305. alert("납품서를 선택해주세요 (대표 납품서번호)") ; //출력
  306. return; //리턴
  307. }
  308. var selectedIds = $(POMNG05010_GRID_ID).getGridParam('selarrrow');
  309. if(selectedIds.length > 1) { // 1이상 선택시
  310. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  311. return; //리턴
  312. }
  313. var selRowData ; //변수선언
  314. for (var i=selectedIds.length-1; i>=0; i--) {//1개만 선택시
  315. selRowData = $(POMNG05010_GRID_ID).jqGrid('getRowData', selectedIds[i]);//cell 선택
  316. }
  317. const key = {brandId :fn_make_user_info.get('brandId'), dlvSttmtUnqNo : selRowData.dlvSttmtUnqNo}; //popup key 값 설정
  318. fn_call_popup('biz', 'BIZPOP_DLV_STTMT_PRN', '#ITP_ASIDE',null, key, 'S'); //config 참고 421줄 팝업 이름,키
  319. }
  320. }
  321. },
  322. empty: {
  323. init: function() {
  324. },
  325. itp_POMNG05010_param: {},
  326. push: function() {
  327. },
  328. },
  329. grid: {
  330. init: function () {
  331. itp_fn_jqgrid_resize(POMNG05010_GRID_ID, POMNG05010_GRID_LIST, 'lg');
  332. itp_fn_fire_window_resize();
  333. this.search();
  334. },
  335. colModel: gridColModel.list,
  336. search: function() {
  337. pageObj.screen();
  338. this.load();
  339. },
  340. load: function() {
  341. let param = $('#ITP_FORM_POMNG05010_SEARCH').serializeObject();
  342. param.gridSize = $.jgrid.defaults.rowNum;
  343. param.sbrandId = fn_make_user_info.get('brandId');
  344. var option = {
  345. gridId: POMNG05010_GRID_ID,
  346. colModel: gridColModel.list,
  347. param: param,
  348. url: DOMAIN + API_DETAIL_GRID_LIST,
  349. pager: POMNG05010_GRID_PAGER,
  350. multiselect: true,
  351. rownumbers: false,
  352. loadComplete: function(data) {
  353. itp_fn_grid_load_complete(data, POMNG05010_GRID_ID, true, 'number', 'POMNG05010', listObj.itp_POMNG05010_search, listObj.empty, true, data.gridRecords, true);
  354. },
  355. onPaging: function(action) {
  356. itp_fn_grid_paging(POMNG05010_GRID_ID, action, param);
  357. }
  358. };
  359. itp_fn_grid_make_remote(option);
  360. }
  361. },
  362. excelDown: function() {
  363. var param = {
  364. 'url': API_DETAIL_GRID_LIST,
  365. 'param': $('#ITP_FORM_POMNG05010_SEARCH').serializeObject(),
  366. 'gridColumns': $(POMNG05010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  367. 'fileName': '납품서현황.xlsx',
  368. 'sheetName': '납품서현황리스트'
  369. };
  370. itp_fn_remote_to_excel(param);
  371. }
  372. };