ITP_POMNG06010.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. require(['config'], function() {
  2. require([], function($) {
  3. listObj.init();
  4. });
  5. });
  6. /********************************************************
  7. --------------------------------------------------------
  8. - Object 목록 -
  9. --------------------------------------------------------
  10. * const gridColModel = {} : 화면 Grid Object *
  11. * let pageObj = {} : 화면공통 Object *
  12. * let listObj = {} : 목록화면 Object *
  13. * let viewObj = {} : 상세화면 Object *
  14. * let modifyObj = {} : 수정화면 Object *
  15. * let createObj = {} : 신규화면 Object *
  16. *******************************************************/
  17. /*화면 변수*/
  18. const POMNG06010_GRID_ID = '#ITP_POMNG06010_jqGrid';
  19. const POMNG06010_GRID_LIST = '#ITP_POMNG06010_jqGrid_list';
  20. const POMNG06010_GRID_PAGER = '#ITP_POMNG06010_jqGridPager';
  21. const POMNG06010_GRID_EMPTY = '#ITP_POMNG06010_jqGridEmpty';
  22. let ITP_FORM_POMNG06010_DETAIL_IS_WRITING = false;
  23. let POMNG06010_LAST_ROW_ID;
  24. /*API URL*/
  25. let API_DETAIL_GRID_LIST = '/api/pomng/inoutmng/warehouse-target-grid-list'; // 목록
  26. let API_DETAIL_SAVE = '/api/pomng/inoutmng/save-warehouse'; // 입고처리
  27. /*화면 Grid ColModel*/
  28. const gridColModel = {
  29. list: [
  30. {
  31. index: 'BRAND_ID', name: 'brandId',
  32. label: ITP_MSG_LOCALE.label.brandId, //브랜드아이디
  33. width: '13', fixed: false, align: 'center',
  34. sortable: false, hidden: true
  35. },
  36. {
  37. index: 'BRAND_NM', name: 'brandNm',
  38. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  39. width: '10', fixed: false, align: 'left',
  40. minwidth: 180,
  41. sortable: false, hidden: false, classes: 'ui-ellipsis'
  42. },
  43. {
  44. index: 'DLV_STTMT_UNQ_NO', name: 'dlvSttmtUnqNo',
  45. label: ITP_MSG_LOCALE.label.dlvSttmtUnqNo, //납품서번호
  46. width: '10', fixed: false, align: 'center',
  47. minwidth: 140,
  48. sortable: false, hidden: false
  49. },
  50. {
  51. index: 'DLV_STTMT_DTL_NO', name: 'dlvSttmtDtlNo',
  52. label: ITP_MSG_LOCALE.label.dlvSttmtDtlNo, //납품서항번
  53. width: '10', fixed: false, align: 'center',
  54. sortable: false, hidden: false
  55. },
  56. {
  57. index: 'ITEM_ID', name: 'itemId',
  58. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  59. width: '10', fixed: false, align: 'center',
  60. minwidth: 140,
  61. sortable: false, hidden: false
  62. },
  63. {
  64. index: 'ITEM_NM', name: 'itemNm',
  65. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  66. width: '10', fixed: false, align: 'left',
  67. minwidth: 180,
  68. sortable: false, hidden: false, classes: 'ui-ellipsis'
  69. },
  70. {
  71. index: 'PODR_QTY', name: 'podrQty',
  72. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  73. width: '18', fixed: false, align: 'right',
  74. sortable: false, hidden: false,
  75. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  76. },
  77. {
  78. index: 'DLV_QTY', name: 'dlvQty',
  79. label: ITP_MSG_LOCALE.label.dlvQty, //납품/수주 수량
  80. width: '18', fixed: false, align: 'right',
  81. sortable: false, hidden: false,
  82. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  83. },
  84. {
  85. index: 'WHS_QTY', name: 'whsQty',
  86. label: ITP_MSG_LOCALE.label.whsQty, //입고수량
  87. width: '18', fixed: false, align: 'right',
  88. sortable: true, editable: true, edittype: 'text',
  89. editrules: { required: false, number: true },
  90. classes: 'input_color',
  91. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  92. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');", maxlength: 10}
  93. },
  94. {
  95. index: 'WHS_AMT', name: 'whsAmt',
  96. label: ITP_MSG_LOCALE.label.whsAmt, //입고금액
  97. width: '13', fixed: false, align: 'right',
  98. sortable: false, hidden: true
  99. },
  100. {
  101. index: 'UNIT_AMT', name: 'unitAmt',
  102. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  103. width: '18', fixed: false, align: 'right',
  104. sortable: false, hidden: false,
  105. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  106. },
  107. {
  108. index: 'WHS_ID', name: 'whsId',
  109. label: ITP_MSG_LOCALE.label.whsId, //납품창고아이디
  110. width: '15', fixed: false, align: 'left',
  111. minwidth: 150,
  112. sortable: false, hidden: true
  113. },
  114. {
  115. index: 'LOCATION', name: 'location',
  116. label: ITP_MSG_LOCALE.label.location, //납품납품LOCATION
  117. width: '15', fixed: false, align: 'center',
  118. sortable: false, hidden: true
  119. },
  120. {
  121. index: 'WHS_NM', name: 'whsNm',
  122. label: ITP_MSG_LOCALE.label.whsNm, //납품창고명
  123. width: '15', fixed: false, align: 'left',
  124. minwidth: 170,
  125. sortable: false, hidden: false, classes: 'ui-ellipsis'
  126. },
  127. {
  128. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  129. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  130. width: '14', fixed: false, align: 'center',
  131. sortable: false, hidden: false
  132. },
  133. {
  134. index: 'DLV_SCH_DT', name: 'dlvSchDt',
  135. label: ITP_MSG_LOCALE.label.dlvSchDt, //납품예정일
  136. width: '14', fixed: false, align: 'center',
  137. sortable: false, hidden: false
  138. },
  139. {
  140. index: 'DLV_MGR_NM', name: 'dlvMgrNm',
  141. label: ITP_MSG_LOCALE.label.dlvMgrNm, //납품담당자명
  142. width: '12', fixed: false, align: 'center',
  143. sortable: false, hidden: false, classes: 'ui-ellipsis'
  144. },
  145. {
  146. index: 'DLV_MGR_TEL_NO', name: 'dlvMgrTelNo',
  147. label: '납품자연락처',
  148. width: '15', fixed: false, align: 'center',
  149. minwidth: 110,
  150. sortable: false, hidden: false
  151. },
  152. {
  153. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  154. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, //구매발주번호
  155. width: '15', fixed: false, align: 'center',
  156. sortable: false, hidden: true
  157. },
  158. {
  159. index: 'PCH_REQ_UNQ_NO', name: 'pchReqUnqNo',
  160. label: ITP_MSG_LOCALE.label.pchReqUnqNo, //구매요청번호
  161. width: '15', fixed: false, align: 'center',
  162. sortable: false, hidden: true
  163. },
  164. {
  165. index: 'PCH_REQ_DTL_NO', name: 'pchReqDltNo',
  166. label: ITP_MSG_LOCALE.label.pchReqDltNo, //구매요청항번
  167. width: '15', fixed: false, align: 'center',
  168. sortable: false, hidden: true
  169. },
  170. {
  171. index: 'UNIT', name: 'unit',
  172. label: ITP_MSG_LOCALE.label.unit, //단위
  173. width: '15', fixed: false, align: 'center',
  174. sortable: false, hidden: true
  175. },
  176. {
  177. index: 'SPPLY_ID', name: 'spplyId',
  178. label: ITP_MSG_LOCALE.label.spplyId, //공급사아이디
  179. width: '15', fixed: false, align: 'center',
  180. sortable: false, hidden: true
  181. },
  182. {
  183. index: 'SPPLY_NM', name: 'spplyNm',
  184. label: ITP_MSG_LOCALE.label.spplyNm, //공급사명
  185. width: '15', fixed: false, align: 'center',
  186. sortable: false, hidden: true
  187. }
  188. ]
  189. };
  190. /*목록화면 Object*/
  191. let listObj = {
  192. init: function() {
  193. this.view();
  194. this.action();
  195. this.event.init();
  196. this.grid.init();
  197. this.screen();
  198. },
  199. view: function() {
  200. // 버튼 권한설정
  201. fn_proc_btn_auth('POMNG06010');
  202. // 공통코드 표시
  203. $('select').each(function() {
  204. if ($(this).data('select-code')) {
  205. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  206. }
  207. });
  208. // 조회일자 지정
  209. var now = new Date();
  210. var fromDate = new Date(now);
  211. fromDate.setDate(now.getDate() - 7);
  212. var toDate = new Date(now);
  213. toDate.setDate(now.getDate() + 7);
  214. $('#ITP_TAB_POMNG06010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  215. $('#ITP_FORM_POMNG06010_SEARCH_FROM_DT').datepicker('setDate', fromDate);
  216. $('#ITP_FORM_POMNG06010_SEARCH_TO_DT').datepicker('setDate', toDate);
  217. $('#ITP_BTN_POMNG06010_EXCEL').show();
  218. },
  219. itp_POMNG06010_search: false,
  220. button: {
  221. search: function() {
  222. console.log("search event");
  223. listObj.itp_POMNG06010_search = true;
  224. let param = $('#ITP_FORM_POMNG06010_SEARCH').serializeObject();
  225. param.gridSize = $.jgrid.defaults.rowNum;
  226. param.gridPage = $.jgrid.defaults.page;
  227. param.sbrandId = fn_make_user_info.get('brandId');
  228. param.sstoreId = fn_make_user_info.get('storeId');
  229. if (param.swhsId == "") {
  230. alert("입고창고를 지정해주세요!");
  231. return;
  232. }
  233. if (param.fromDt == '' || param.toDt == '') {
  234. alert("납품예정일 기간을 지정해주세요!");
  235. return;
  236. }
  237. $(POMNG06010_GRID_ID).setGridParam({ 'postData': JSON.stringify(param) }).trigger('reloadGrid');
  238. },
  239. save: function() {
  240. $('body').trigger('click');
  241. var modalFn = {
  242. callBack: () => {
  243. //itp_fn_form_event.removeChar('#ITP_FORM_OPER03010_DETAIL');
  244. var chkQtyYn = "N";
  245. let gridInsertData = [];
  246. const rowData = $(POMNG06010_GRID_ID).getRowData();
  247. var cwhsId = "";
  248. $.each(rowData, function(key, value) {
  249. if (value.whsQty != '') {
  250. if (parseInt(value.whsQty) > parseInt(value.dlvQty)) {
  251. alert("납품수량보다 입고수량이 더 많습니다.");
  252. chkQtyYn = "Y";
  253. return false;
  254. }
  255. if (cwhsId != "" && cwhsId != value.whsId) {
  256. alert("서로 다른 입고창고 품목은 처리할 수 없습니다.");
  257. chkQtyYn = "Y";
  258. return false;
  259. }
  260. cwhsId = value.whsId;
  261. gridInsertData.push(value);
  262. }
  263. });
  264. if (chkQtyYn == "Y") return;
  265. if (gridInsertData.length == 0) {
  266. alert("입고처리할 품목에 입고수량을 입력해주세요!");
  267. return ;
  268. }
  269. let param = {};
  270. param.viewCd = "C";
  271. param.whsId = cwhsId;
  272. param.brandId = fn_make_user_info.get('brandId');
  273. param.storeId = fn_make_user_info.get('storeId');
  274. param.dlvCnfmDocFileNo = "";
  275. param.gridInsertData = gridInsertData;
  276. console.log(JSON.stringify(param));
  277. var searhFn = function () {
  278. //ITP_FORM_INOUTMNG01010_DETAIL_IS_WRITING = false;
  279. listObj.button.search();
  280. }
  281. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  282. }
  283. };
  284. itp_fn_modal_confirm('입고처리 하시겠습니까?', modalFn);
  285. }
  286. },
  287. action: function() {
  288. var _this = this;
  289. // 공급업체 조회 버튼 클릭
  290. $('#ITP_BTN_POMNG06010_SEARCH_SPPLY_ID').on('click', function() {
  291. _this.popup('spply');
  292. });
  293. // 공급업체 텍스트 삭제 버튼 클릭
  294. $('#ITP_BTN_POMNG06010_DELETE_SPPLY_ID').on('click', function() {
  295. $('#ITP_FORM_POMNG06010_SEARCH_SPPLY_NM').val('');
  296. $('#ITP_FORM_POMNG06010_SEARCH_SPPLY_ID').val('');
  297. });
  298. // 매장/창고 조회 버튼 클릭
  299. $('#ITP_BTN_POMNG06010_SEARCH_WHS_ID').on('click', function() {
  300. _this.popup('whs');
  301. });
  302. // 매장/창고 텍스트 삭제 버튼 클릭
  303. $('#ITP_BTN_POMNG06010_DELETE_WHS_ID').on('click', function() {
  304. $('#ITP_FORM_POMNG06010_SEARCH_WHS_NM').val('');
  305. $('#ITP_FORM_POMNG06010_SEARCH_WHS_ID').val('');
  306. });
  307. },
  308. popup: function(arg) {
  309. var popFn = this.callback.create;
  310. var whsDvsn = "";
  311. if (fn_make_user_info.get('storeId') == "") {
  312. whsDvsn = "W01";
  313. } else {
  314. whsDvsn = "W02";
  315. }
  316. //param.sstoreId = fn_make_user_info.get('storeId');
  317. if(arg === 'spply'){
  318. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId')};
  319. fn_call_popup('biz', 'BIZPOP_STORE_SPPLY', '#ITP_ASIDE', popFn, key, 'S');
  320. } else if(arg === 'whs'){
  321. const key1 = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'), whsDvsn:whsDvsn};
  322. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key1, 'S');
  323. }
  324. },
  325. callback: {
  326. create: function(rowDataPop) {
  327. console.log(rowDataPop);
  328. if(rowDataPop.hasOwnProperty('whsId') == false) {
  329. $('#ITP_FORM_POMNG06010_SEARCH_SPPLY_NM').val(rowDataPop.spplyNm);
  330. $('#ITP_FORM_POMNG06010_SEARCH_SPPLY_ID').val(rowDataPop.spplyId);
  331. } else {
  332. $('#ITP_FORM_POMNG06010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  333. $('#ITP_FORM_POMNG06010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  334. }
  335. }
  336. },
  337. event: {
  338. init: function() {
  339. this.button();
  340. },
  341. button: function() {
  342. // 버튼 클릭 이벤트
  343. $('button').each(function() {
  344. var id = $(this).attr('id');
  345. $(this).on('click', function() {
  346. switch (id) {
  347. case 'ITP_BTN_POMNG06010_SRH': listObj.button.search(); break; // 조회 버튼 클릭
  348. case 'ITP_BTN_POMNG06010_MODIFY': listObj.button.save(); break; // 입고처리 버튼
  349. case 'ITP_BTN_POMNG06010_EXCEL': listObj.excelDown(); break; // excel 버튼
  350. }
  351. });
  352. });
  353. $('body').on('click', function(e) {
  354. var gridId = POMNG06010_GRID_ID.replace('#', '');
  355. var rids = $(POMNG06010_GRID_ID).jqGrid('getDataIDs');
  356. var last_row_id = rids[rids.length - 1];
  357. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'POMNG06010');
  358. });
  359. }
  360. },
  361. empty: {
  362. init: function() {
  363. /*
  364. var _this = this;
  365. this.push();
  366. $(POMNG06010_GRID_EMPTY).on('click', function() {
  367. _this.back();
  368. _this.itp_POMNG06010_param.gridSize = $.jgrid.defaults.rowNum;
  369. $(POMNG06010_GRID_ID).setGridParam({ 'postData': JSON.stringify(_this.itp_POMNG06010_param) }).trigger('reloadGrid');
  370. });
  371. */
  372. },
  373. itp_POMNG06010_param: {},
  374. push: function() {
  375. /*
  376. let param = $('#ITP_FORM_POMNG06010_SEARCH').serializeObject();
  377. listObj.itp_POMNG06010_param = param;
  378. */
  379. },
  380. back: function() {
  381. /*
  382. $('#ITP_FORM_POMNG06010_SEARCH_FROM_DT').val(this.itp_POMNG06010_param.fromDt);
  383. $('#ITP_FORM_POMNG06010_SEARCH_TO_DT').val(this.itp_POMNG06010_param.toDt);
  384. $('#ITP_FORM_POMNG06010_SEARCH_DLV_STTMT_UNQ_NO').val(this.itp_POMNG06010_param.sDlvSttmtUnqNo);
  385. $('#ITP_FORM_POMNG06010_SEARCH_SPPLY_ID').val(this.itp_POMNG06010_param.sSpplyId);
  386. $('#ITP_FORM_POMNG06010_SEARCH_WHS_ID').val(this.itp_POMNG06010_param.sWhsId);
  387. $('#ITP_FORM_POMNG06010_SEARCH_ITEM_NM').val(this.itp_POMNG06010_param.sItemNm);
  388. */
  389. }
  390. },
  391. grid: {
  392. init: function() {
  393. // 데이터 없을때
  394. listObj.empty.push();
  395. itp_fn_jqgrid_resize(POMNG06010_GRID_ID, POMNG06010_GRID_LIST, 'lg');
  396. this.search();
  397. },
  398. colModel: gridColModel.list,
  399. search: function() {
  400. this.unload();
  401. this.load();
  402. },
  403. load: function() {
  404. let param = $('#ITP_FORM_POMNG06010_SEARCH').serializeObject();
  405. param.gridSize = $.jgrid.defaults.rowNum;
  406. param.sbrandId = fn_make_user_info.get('brandId');
  407. param.sstoreId = fn_make_user_info.get('storeId');
  408. param.swhsId = "Order";
  409. $(POMNG06010_GRID_ID).data('grid-param',param);
  410. var option = {
  411. //multiselect: true,
  412. autowidth: true,
  413. gridId: POMNG06010_GRID_ID,
  414. colModel: gridColModel.list,
  415. param: param,
  416. url: DOMAIN + API_DETAIL_GRID_LIST,
  417. pager: POMNG06010_GRID_PAGER,
  418. onCellSelect: function(rowid, cellIdx, cellValue) {
  419. POMNG06010_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, POMNG06010_LAST_ROW_ID, POMNG06010_GRID_ID, ['pchPodrUnqNo']);
  420. },
  421. loadComplete: function(data) {
  422. itp_fn_grid_load_complete(data, POMNG06010_GRID_ID, true, 'number', 'POMNG06010', listObj.itp_POMNG06010_search, listObj.empty, true, data.gridRecords, true);
  423. },
  424. onPaging: function(action) {
  425. itp_fn_grid_paging(POMNG06010_GRID_ID, action, param);
  426. }
  427. };
  428. itp_fn_grid_make_remote(option);
  429. },
  430. button: {
  431. },
  432. unload: function() {
  433. $.jgrid.gridUnload(POMNG06010_GRID_ID);
  434. },
  435. clearData: function() {
  436. $(POMNG06010_GRID_ID).jqGrid('clearGridData', true);
  437. $(POMNG06010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  438. $(POMNG06010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  439. $(POMNG06010_GRID_EMPTY).show();
  440. }
  441. },
  442. screen: function() {
  443. $('#ITP_BTN_POMNG06010_DELETE_WHS_ID').show();
  444. $('#ITP_BTN_POMNG06010_DELETE_SPPLY_ID').show();
  445. },
  446. excelDown: function() {
  447. var excelParam = $('#ITP_FORM_POMNG06010_SEARCH').serializeObject();
  448. excelParam.sbrandId = fn_make_user_info.get('brandId');
  449. excelParam.sstoreId = fn_make_user_info.get('storeId');
  450. var param = {
  451. 'url': API_DETAIL_GRID_LIST,
  452. 'param': excelParam,
  453. 'gridColumns': $(POMNG06010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  454. 'fileName': '입고처리대상정보.xlsx',
  455. 'sheetName': '입고처리대상리스트'
  456. };
  457. itp_fn_remote_to_excel(param);
  458. }
  459. };