ITP_POMNG05010.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. $('#ITP_TAB_POMNG05010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  201. $('#ITP_FORM_POMNG05010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  202. $('#ITP_FORM_POMNG05010_SEARCH_TO_DT').datepicker('setDate', new Date());
  203. $('#ITP_BTN_POMNG05010_EXCEL').show();
  204. },
  205. },
  206. action: function () {
  207. var _this = this;
  208. // 검색 공급사
  209. $('#ITP_BTN_POMNG05010_SEARCH_SPPLY_NM').on('click', function() {
  210. _this.popup('SS');
  211. });
  212. // 검색 텍스트 삭제 버튼 클릭
  213. $('#ITP_BTN_POMNG05010_DELETE_SPPLY_NM').on('click', function() {
  214. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_NM').val('');
  215. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_ID').val('');
  216. });
  217. // 검색 납품장소
  218. $('#ITP_BTN_POMNG05010_SEARCH_SWHS_NM').on('click', function() {
  219. _this.popup('SW');
  220. });
  221. // 검색 납품장소 텍스트 삭제 버튼 클릭
  222. $('#ITP_BTN_POMNG05010_DELETE_SWHS_NM').on('click', function() {
  223. $('#ITP_FORM_POMNG05010_SEARCH_WHS_NM').val('');
  224. $('#ITP_FORM_POMNG05010_SEARCH_WHS_ID').val('');
  225. });
  226. },
  227. popup: function (arg) {
  228. var popFn ;
  229. // 팝업
  230. if (arg == "SW") {
  231. popFn = this.callback.searWhs;
  232. } else if (arg == "SS") {
  233. popFn = this.callback.searSpply;
  234. }
  235. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  236. if (arg == "SW" ) {
  237. const keya = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};
  238. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, keya, 'S');
  239. } else if (arg == "SS") {
  240. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  241. }
  242. },
  243. callback: {
  244. searSpply: function(rowDataPop) {
  245. if(rowDataPop) {
  246. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_NM').val(rowDataPop.spplyNm);
  247. $('#ITP_FORM_POMNG05010_SEARCH_SPPLY_ID').val(rowDataPop.spplyId);
  248. }
  249. },
  250. searWhs: function(rowDataPop) {
  251. if(rowDataPop) {
  252. $('#ITP_FORM_POMNG05010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  253. $('#ITP_FORM_POMNG05010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  254. }
  255. }
  256. },
  257. event: {
  258. init: function () {
  259. this.button();
  260. },
  261. button: function () {
  262. // 버튼 클릭 이벤트
  263. $('button').each(function() {
  264. var id = $(this).attr('id');
  265. $(this).on('click', function() {
  266. switch (id) {
  267. case 'ITP_BTN_POMNG05010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  268. case 'ITP_BTN_POMNG05010_PRT' : listObj.button.print(); break; // 납품서출력 버튼
  269. case 'ITP_BTN_POMNG05010_EXCEL' : listObj.excelDown(); break; // 엑셀
  270. }
  271. });
  272. });
  273. }
  274. },
  275. screen: function() {
  276. $('#ITP_FORM_POMNG05010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));//input hidden 값 넣기
  277. $('#ITP_FORM_POMNG05010_SEARCH_DTL_GUBUN').val('dtlGubun');
  278. $('#ITP_BTN_POMNG05010_DELETE_SPPLY_NM').show();
  279. $('#ITP_BTN_POMNG05010_DELETE_SWHS_NM').show();
  280. }
  281. };
  282. /*목록화면 Object*/
  283. let listObj = {
  284. init: function () {
  285. this.grid.init();
  286. },
  287. itp_POMNG05010_search: false,
  288. button: {
  289. search: function() {
  290. listObj.itp_POMNG05010_search = true;
  291. let param = $('#ITP_FORM_POMNG05010_SEARCH').serializeObject();
  292. param.gridSize = $.jgrid.defaults.rowNum;
  293. param.gridPage = $.jgrid.defaults.page;
  294. console.log(param);
  295. $(POMNG05010_GRID_ID).data('grid-param',param);
  296. $(POMNG05010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  297. },
  298. print: function() {
  299. if(!fn_make_user_info.isEmpty()) {
  300. const rowKey = $(POMNG05010_GRID_ID).getGridParam('selrow'); // 그리드 셀 선택
  301. if (!rowKey) {//선택 안했을시
  302. alert("납품서를 선택해주세요 (대표 납품서번호)") ; //출력
  303. return; //리턴
  304. }
  305. var selectedIds = $(POMNG05010_GRID_ID).getGridParam('selarrrow');
  306. if(selectedIds.length > 1) { // 1이상 선택시
  307. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  308. return; //리턴
  309. }
  310. var selRowData ; //변수선언
  311. for (var i=selectedIds.length-1; i>=0; i--) {//1개만 선택시
  312. selRowData = $(POMNG05010_GRID_ID).jqGrid('getRowData', selectedIds[i]);//cell 선택
  313. }
  314. const key = {brandId :fn_make_user_info.get('brandId'), dlvSttmtUnqNo : selRowData.dlvSttmtUnqNo}; //popup key 값 설정
  315. fn_call_popup('biz', 'BIZPOP_DLV_STTMT_PRN', '#ITP_ASIDE',null, key, 'S'); //config 참고 421줄 팝업 이름,키
  316. }
  317. }
  318. },
  319. empty: {
  320. init: function() {
  321. },
  322. itp_POMNG05010_param: {},
  323. push: function() {
  324. },
  325. },
  326. grid: {
  327. init: function () {
  328. itp_fn_jqgrid_resize(POMNG05010_GRID_ID, POMNG05010_GRID_LIST, 'lg');
  329. itp_fn_fire_window_resize();
  330. this.search();
  331. },
  332. colModel: gridColModel.list,
  333. search: function() {
  334. pageObj.screen();
  335. this.load();
  336. },
  337. load: function() {
  338. let param = $('#ITP_FORM_POMNG05010_SEARCH').serializeObject();
  339. param.gridSize = $.jgrid.defaults.rowNum;
  340. param.sbrandId = fn_make_user_info.get('brandId');
  341. var option = {
  342. gridId: POMNG05010_GRID_ID,
  343. colModel: gridColModel.list,
  344. param: param,
  345. url: DOMAIN + API_DETAIL_GRID_LIST,
  346. pager: POMNG05010_GRID_PAGER,
  347. multiselect: true,
  348. rownumbers: false,
  349. loadComplete: function(data) {
  350. itp_fn_grid_load_complete(data, POMNG05010_GRID_ID, true, 'number', 'POMNG05010', listObj.itp_POMNG05010_search, listObj.empty, true, data.gridRecords, true);
  351. },
  352. onPaging: function(action) {
  353. itp_fn_grid_paging(POMNG05010_GRID_ID, action, param);
  354. }
  355. };
  356. itp_fn_grid_make_remote(option);
  357. }
  358. },
  359. excelDown: function() {
  360. var param = {
  361. 'url': API_DETAIL_GRID_LIST,
  362. 'param': $('#ITP_FORM_POMNG05010_SEARCH').serializeObject(),
  363. 'gridColumns': $(POMNG05010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  364. 'fileName': '납품서현황.xlsx',
  365. 'sheetName': '납품서현황리스트'
  366. };
  367. itp_fn_remote_to_excel(param);
  368. }
  369. };