ITP_ORDMNG03010.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init(); //config 적용
  5. });
  6. });
  7. /********************************************************
  8. --------------------------------------------------------
  9. - Object 목록 -
  10. --------------------------------------------------------
  11. * const gridColModel = {} : 화면 Grid Object *
  12. * let pageObj = {} : 화면공통 Object *
  13. * let listObj = {} : 목록화면 Object *
  14. *******************************************************/
  15. /*화면 변수*/
  16. const ORDMNG03010_GRID_ID = '#ITP_ORDMNG03010_jqGrid'; //GRID_ID 선언
  17. const ORDMNG03010_GRID_LIST = '#ITP_ORDMNG03010_jqGrid_list'; //GRID_LIST 선언
  18. const ORDMNG03010_GRID_PAGER = '#ITP_ORDMNG03010_jqGridPager'; //GRID_PAGER 선언
  19. const ORDMNG03010_GRID_EMPTY = '#ITP_ORDMNG03010_jqGridEmpty'; //GRID_EMPTY 선언
  20. /*API URL*/
  21. let API_DELI_GRID_LIST = '/api/pomng/inoutmng/spply-deli-grid-list';// 목록
  22. let API_INFO_INV = '/api/pomng/inoutmng/init-spply-inv'; // 상세
  23. /*화면 Grid ColModel*/
  24. const gridColModel = {
  25. list: [
  26. {
  27. index: 'Brand_ID', name: 'brandId', //서버로 전송시 데이터 명 , 데이터명
  28. label: ITP_MSG_LOCALE.label.brandId, //브랜드아이디
  29. width: '18', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  30. sortable: false, hidden: true //정렬가능 여부,화면표시 여부
  31. },
  32. {
  33. index: 'Brand_Nm', name: 'brandNm', //정렬가능 여부,화면표시 여부
  34. label: ITP_MSG_LOCALE.label.brandNm, //브랜드이름
  35. width: '10', fixed: false, align: 'left', // cell가로넓이,고정 여부 ,text정렬
  36. minwidth: 120, //최소가로넓이 설정
  37. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  38. },
  39. {
  40. index: 'DLV_STTMT_NO', name: 'dlvSttmtUnqNo', //서버로 전송시 데이터 명 , 데이터명
  41. label: ITP_MSG_LOCALE.label.dlvSttmtUnqNo, //납품서번호
  42. width: '20', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  43. minwidth: 140,
  44. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  45. },
  46. {
  47. index: 'DLV_ST_NM', name: 'dlvStNm', //서버로 전송시 데이터 명 , 데이터명
  48. label: '납품상태', //납품서상태
  49. width: '12', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  50. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  51. },
  52. {
  53. index: 'PODR_REG_DT', name: 'podrRegDt', //서버로 전송시 데이터 명 , 데이터명
  54. label: '수주일자', //수주일자
  55. width: '14', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  56. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  57. },
  58. {
  59. index: 'PCH_ITEM_YN', name: 'dlvReqDt', //서버로 전송시 데이터 명 , 데이터명
  60. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  61. width: '14', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  62. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  63. },
  64. {
  65. index: 'PCH_ITEM_YN', name: 'dlvSchDt', //서버로 전송시 데이터 명 , 데이터명
  66. label: ITP_MSG_LOCALE.label.dlvSchDt, //납품예정일
  67. width: '14', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  68. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  69. },
  70. {
  71. index: 'PCH_ITEM_YN', name: 'dlvCmpltDt', //서버로 전송시 데이터 명 , 데이터명
  72. label: ITP_MSG_LOCALE.label.dlvCmpltDt, //납품완료일
  73. width: '14', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  74. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  75. },
  76. {
  77. index: 'ITEM_CLASS_NM', name: 'itemId', //서버로 전송시 데이터 명 , 데이터명
  78. label: ITP_MSG_LOCALE.label.itemId, //품목번호
  79. minwidth: 180,
  80. width: '11', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  81. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  82. },
  83. {
  84. index: 'PODR_PSSBLDVSN_NM', name: 'itemNm', //서버로 전송시 데이터 명 , 데이터명
  85. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  86. minwidth: 140,
  87. width: '10', fixed: false, align: 'left', // cell가로넓이,고정 여부 ,text정렬
  88. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  89. },
  90. {
  91. index: 'PODR_QTY', name: 'podrQty', //서버로 전송시 데이터 명 , 데이터명
  92. label: ITP_MSG_LOCALE.label.podrQty, //수주수량
  93. minwidth: 80,
  94. width: '6', fixed: false, align: 'right', // cell가로넓이,고정 여부 ,text정렬
  95. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  96. },
  97. {
  98. index: 'SALE_ITEM_YN', name: 'dlvQty', //서버로 전송시 데이터 명 , 데이터명
  99. label: ITP_MSG_LOCALE.label.dlvQty, //납품수량
  100. minwidth: 80,
  101. width: '6', fixed: false, align: 'right', // cell가로넓이,고정 여부 ,text정렬
  102. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  103. },
  104. {
  105. index: 'UNIT', name: 'unit', //서버로 전송시 데이터 명 , 데이터명
  106. label: ITP_MSG_LOCALE.label.unit, //단위
  107. minwidth: 80,
  108. width: '6', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  109. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  110. },
  111. {
  112. index: 'PCH_ITEM_YN', name: 'unitAmt', //서버로 전송시 데이터 명 , 데이터명
  113. label: ITP_MSG_LOCALE.label.unitAmt, //납품금액
  114. minwidth: 80,
  115. width: '6', fixed: false, align: 'right ', // cell가로넓이,고정 여부 ,text정렬
  116. sortable: false, hidden: false, //정렬가능 여부,화면표시 여부
  117. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  118. },
  119. {
  120. index: 'SALE_ITEM_YN', name: 'whsNm', //서버로 전송시 데이터 명 , 데이터명
  121. label: ITP_MSG_LOCALE.label.whsNm, //납품장소
  122. minwidth: 240,
  123. width: '6', fixed: false, align: 'left', // cell가로넓이,고정 여부 ,text정렬
  124. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  125. },
  126. {
  127. index: 'PCH_ITEM_YN', name: 'dlvMgrNm', //서버로 전송시 데이터 명 , 데이터명
  128. label: ITP_MSG_LOCALE.label.dlvMgrNm, //납품담당자
  129. minwidth: 100,
  130. width: '8', fixed: false, align: 'left', // cell가로넓이,고정 여부 ,text정렬
  131. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  132. },
  133. {
  134. index: 'PCH_ITEM_YN', name: 'dlvMgrTelNo', //서버로 전송시 데이터 명 , 데이터명
  135. label: ITP_MSG_LOCALE.label.dlvMgrTelNo, //납품담당연락처
  136. minwidth: 120,
  137. width: '10', fixed: false, align: 'center', // cell가로넓이,고정 여부 ,text정렬
  138. sortable: false, hidden: false //정렬가능 여부,화면표시 여부
  139. }
  140. ]
  141. };
  142. /*화면공통 Object*/
  143. let pageObj = {
  144. init: function () {
  145. this.ui.init(); //ul 안 init 불러옴
  146. this.event.init(); //event 안 init 불러옴
  147. this.action(); //action 불러옴
  148. },
  149. ui: {
  150. init: function () {
  151. this.view(); //view 불러오기
  152. listObj.init(); //listObj 에서 init 불러오기
  153. },
  154. view: function() {
  155. // 버튼 권한설정
  156. fn_proc_btn_auth('ORDMNG03010');
  157. // 조회일자 달력 팝업 불러오기
  158. var now = new Date();
  159. $('#ITP_TAB_ORDMNG03010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  160. $('#ITP_FORM_ORDMNG03010_SEARCH_DLV_REQ_DT').datepicker('setDate', new Date(now.setMonth(now.getMonth() - 1)));
  161. $('#ITP_FORM_ORDMNG03010_SEARCH_DLV_CMPLT_DT').datepicker('setDate', new Date());
  162. }
  163. },
  164. event: {
  165. init: function () {
  166. this.button(); //button 부르기
  167. },
  168. button: function () {
  169. // 버튼 클릭 이벤트
  170. $('button').each(function() {
  171. var id = $(this).attr('id');
  172. $(this).on('click', function() {
  173. switch (id) {
  174. case 'ITP_BTN_ORDMNG03010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  175. case 'ITP_BTN_ORDMNG03010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  176. }
  177. });
  178. });
  179. }
  180. },
  181. screen: function() {
  182. $('#ITP_FORM_ORDMNG03010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('userId')); //input hidden 값 넣기
  183. $('#ITP_FORM_ORDMNG03010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));//input hidden 값 넣기
  184. $('#ITP_FORM_ORDMNG03010_SDELETE_SWHS_NM').show(); //버튼 보이게 하기
  185. $('#ITP_BTN_ORDMNG03010_EXCEL').show(); //버튼 보이게 하기
  186. },
  187. action: function() {
  188. var _this = this;
  189. $('#ITP_BTN_ORDMNG03010_POPUP').on('click', function() {
  190. _this.popup();
  191. });
  192. },
  193. popup: function() {
  194. var selectedIds = $(ORDMNG03010_GRID_ID).getGridParam('selarrrow');
  195. if(selectedIds.length > 1) { // 1이상 선택시
  196. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  197. return; //리턴
  198. }
  199. var selRowData ; //변수선언
  200. for (var i=selectedIds.length-1; i>=0; i--) {//1개만 선택시
  201. selRowData = $(ORDMNG03010_GRID_ID).jqGrid('getRowData', selectedIds[i]);//cell 선택
  202. }
  203. if (selRowData == null) {
  204. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData)
  205. return;
  206. }
  207. const key = {brandId :fn_make_user_info.get('brandId'), dlvSttmtUnqNo : selRowData.dlvSttmtUnqNo}; //popup key 값 설정
  208. fn_call_popup('biz', 'BIZPOP_DLV_STTMT_PRN', '#ITP_ASIDE',null, key, 'S'); //config 참고 421줄 팝업 이름,키
  209. }
  210. };
  211. /*목록화면 Object*/
  212. let listObj = {
  213. init: function () {
  214. this.grid.init(); //grid 에 init 불러오기
  215. this.action();
  216. },
  217. itp_ORDMNG03010_search: false, //조회 안함
  218. button: {
  219. search: function() {
  220. listObj.itp_ORDMNG03010_search = true; //조회 시작
  221. let param = $('#ITP_FORM_ORDMNG03010_SEARCH').serializeObject();
  222. param.gridSize = $.jgrid.defaults.rowNum; // 그리드 사이즈 20
  223. param.gridPage = $.jgrid.defaults.page; // 페이지 1
  224. /*물어봐야할것들*/
  225. $(ORDMNG03010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  226. }
  227. },
  228. empty: {
  229. init: function() {
  230. },
  231. itp_ORDMNG03010_param: {},//현재 정보는 없음
  232. push: function() {
  233. }
  234. },
  235. grid: {
  236. init: function () {
  237. // 데이터 없을때
  238. this.search();//search 불러오기
  239. //itp_fn_jqgrid_resize(ORDMNG03010_GRID_ID, ORDMNG03010_GRID_LIST, 'lg');
  240. },
  241. colModel: gridColModel.list, //컬럼정보
  242. search: function() {
  243. pageObj.screen(); //공통 스크린 불러오기
  244. this.load(); //load 불러오기
  245. },
  246. load: function() {
  247. let param = $('#ITP_FORM_ORDMNG03010_SEARCH').serializeObject(); //param 값 선언
  248. param.gridSize = $.jgrid.defaults.rowNum; //그리드 사이즈 20
  249. param.sbrandId = fn_make_user_info.get('brandId'); //안쓰는 api 값 넣기
  250. var option = {
  251. gridId: ORDMNG03010_GRID_ID, //아이디 정보
  252. colModel: gridColModel.list, //컬럼 정보
  253. param: param, //파람 정보
  254. url: DOMAIN + API_DELI_GRID_LIST,//API 주소 정보
  255. pager: ORDMNG03010_GRID_PAGER, //페이지 정보
  256. multiselect: true, //동시선택 가능
  257. /*물어봐야할것들*/
  258. loadComplete: function(data) {
  259. itp_fn_grid_load_complete(data, ORDMNG03010_GRID_ID, true, 'number', 'ORDMNG03010', listObj.itp_ORDMNG03010_search, listObj.empty, true, data.gridRecords, true);
  260. },
  261. onPaging: function(action) {
  262. itp_fn_grid_paging(ORDMNG03010_GRID_ID, action, param);
  263. }
  264. };
  265. itp_fn_grid_make_remote(option);
  266. },
  267. },
  268. action: function () {
  269. var _this = this; //_this 는 this 와 같다
  270. // 검색 납품장소 클릭
  271. $('#ITP_FORM_ORDMNG03010_SSEARCH_SWHS_NM').on('click', function() {
  272. _this.popup(); //'whs 팝업생성'
  273. });
  274. // 검색 납품장소 텍스트 삭제 버튼 클릭
  275. $('#ITP_FORM_ORDMNG03010_SDELETE_SWHS_NM').on('click', function() {
  276. $('#ITP_FORM_ORDMNG03010_SEARCH_SWHS_NM').val(''); //납품장소 이름 값 제거
  277. $('#ITP_FORM_ORDMNG03010_SEARCH_SWHS_ID').val(''); //납품장소 아이디 값 제거
  278. });
  279. },
  280. popup: function () {
  281. var popFn = this.callback.searWhs; //popFn 선언
  282. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:""};//key 값 선언
  283. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S'); //popup 부르기 팝업 이름,popFn,key
  284. },
  285. callback: {
  286. searWhs: function(rowDataPop) {
  287. if(rowDataPop) {
  288. $('#ITP_FORM_ORDMNG03010_SEARCH_SWHS_NM').val(rowDataPop.whsNm); // popup 에서 고른 값 넣기
  289. $('#ITP_FORM_ORDMNG03010_SEARCH_SWHS_ID').val(rowDataPop.whsId); // popup 에서 고른 값 넣기
  290. }
  291. }
  292. },
  293. excelDown: function() {
  294. var param = {
  295. 'url': API_DELI_GRID_LIST,
  296. 'param': $('#ITP_FORM_ORDMNG03010_SEARCH').serializeObject(),
  297. 'gridColumns': $(ORDMNG03010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  298. 'fileName': '공급사 납품서현황.xlsx',
  299. 'sheetName': '공급사 납품서리스트'
  300. };
  301. itp_fn_remote_to_excel(param);
  302. }
  303. };