ITP_ORDMNG02010.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. pageObj.init();
  5. });
  6. });
  7. /*화면 변수*/
  8. const ORDMNG02010_GRID_ID = '#ITP_ORDMNG02010_jqGrid';
  9. const ORDMNG02010_GRID_LIST = '#ITP_ORDMNG02010_jqGrid_list';
  10. const ORDMNG02010_GRID_PAGER = '#ITP_ORDMNG02010_jqGridPager';
  11. const ORDMNG02010_GRID_EMPTY = '#ITP_ORDMNG02010_jqGridEmpty';
  12. const ORDMNG02010_DETAIL_GRID_ID = '#ITP_ORDMNG02010_DETAIL_jqGrid';
  13. const ORDMNG02010_DETAIL_GRID_LIST = '#ITP_ORDMNG02010_DETAIL_jqGrid_list';
  14. const ORDMNG02010_DETAIL_GRID_PAGER = '#ITP_ORDMNG02010_DETAIL_jqGridPager';
  15. const ORDMNG02010_DETAIL_GRID_EMPTY = '#ITP_ORDMNG02010_DETAIL_jqGridEmpty';
  16. let ITP_FORM_OPER03010_DETAIL_IS_WRITING = false;
  17. let ORDMNG02010_GRID_LAST_ROW_ID;
  18. // editrules
  19. let shmtQtyValue;
  20. let isExpryDate;
  21. /*API URL*/
  22. let API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST = '/api/pomng/inoutmng/spply-target-grid-list'; // 공급사 납품 대상리스트 그리 리스트
  23. let API_POMNG_INOUTMNG_INIT_SPPLY_INV = '/api/pomng/inoutmng/init-spply-inv'; // 공급사 발주데이타 납품서 생성 초기데이타
  24. let API_POMNG_INOUTMNG_SAVE_SPPLY_INV = '/api/pomng/inoutmng/save-spply-inv' //공급사 납품서 생성 저장 저장
  25. /*화면 Grid ColModel*/
  26. const gridColModel = {
  27. list: [
  28. {
  29. index: 'VIEW_CD', name: 'viewCd',
  30. label: ITP_MSG_LOCALE.label.viewCd,
  31. width: '10', fixed: false, align: 'center',
  32. sortable: false, hidden: true
  33. },
  34. {
  35. index: 'BRAND_ID', name: 'brandId',
  36. label: ITP_MSG_LOCALE.label.brandId, //브랜드ID
  37. width: '10', fixed: false, align: 'center',
  38. sortable: false, hidden: true
  39. },
  40. {
  41. index: 'BRAND_NM', name: 'brandNm',
  42. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  43. width: '6', fixed: false, align: 'left',
  44. sortable: false, hidden: false
  45. },
  46. {
  47. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  48. label: ITP_MSG_LOCALE.label.pchPodrUnqNo, //발주번호
  49. width: '8', fixed: false, align: 'center',
  50. sortable: false, hidden: false
  51. },
  52. {
  53. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  54. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, //발주항번
  55. width: '4', fixed: false, align: 'center',
  56. sortable: false, hidden: false
  57. },
  58. {
  59. index: 'DLV_REQ_DT', name: 'dlvReqDt',
  60. label: ITP_MSG_LOCALE.label.dlvReqDt, //납품요청일
  61. width: '6', fixed: false, align: 'center',
  62. sortable: false, hidden: false
  63. },
  64. {
  65. index: 'WHS_NM', name: 'whsNm',
  66. label: ITP_MSG_LOCALE.label.whsNm, //납품장소
  67. width: '11', fixed: false, align: 'left',
  68. minwidht: 100,
  69. sortable: false, hidden: false
  70. },
  71. {
  72. index: 'ITEM_ID', name: 'itemId',
  73. label: ITP_MSG_LOCALE.label.itemId, //품목번호
  74. width: '8', fixed: false, align: 'center',
  75. sortable: false, hidden: false
  76. },
  77. {
  78. index: 'ITEM_NM', name: 'itemNm',
  79. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  80. width: '6', fixed: false, align: 'left',
  81. sortable: false, hidden: false
  82. },
  83. {
  84. index: 'PODR_QTY', name: 'podrQty',
  85. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  86. width: '4', fixed: false, align: 'right',
  87. sortable: false, hidden: false
  88. },
  89. {
  90. index: 'UNIT_AMT', name: 'unitAmt',
  91. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  92. width: '3', fixed: false, align: 'right',
  93. sortable: false, hidden: false,
  94. minwidth:80,
  95. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  96. },
  97. {
  98. index: 'PODR_AMT', name: 'podrAmt',
  99. label: ITP_MSG_LOCALE.label.podrAmt, //발주금액
  100. width: '4', fixed: false, align: 'right',
  101. minwidth:80,
  102. sortable: false, hidden: false,
  103. formatter: 'integer', formatoptions: {thousandsSeparator: ','}
  104. }
  105. ],
  106. view: [],
  107. detail: []
  108. };
  109. /*화면공통 Object*/
  110. let pageObj = {
  111. init: function() {
  112. this.ui.init();
  113. this.event.init();
  114. },
  115. ui: {
  116. init: function() {
  117. this.view();
  118. this.grid();
  119. this.form();
  120. this.ready();
  121. },
  122. view: function() {
  123. // 버튼 권한설정
  124. fn_proc_btn_auth('ORDMNG02010');
  125. // 공통코드 표시
  126. $('select').each(function() {
  127. if($(this).data('select-code')) {
  128. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  129. }
  130. });
  131. // 조회일자 지정
  132. var now = new Date();
  133. var defaultToDate = new Date(now);
  134. defaultToDate.setDate(now.getDate() + 7);
  135. $('#ITP_TAB_ORDMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  136. $('#ITP_FORM_ORDMNG02010_SEARCH_FROM_DT').datepicker('setDate', now);
  137. $('#ITP_FORM_ORDMNG02010_SEARCH_TO_DT').datepicker('setDate', defaultToDate);
  138. },
  139. form: function() {
  140. itp_fn_form_event.onKeyup('#ITP_FORM_ORDMNG02010_DETAIL');
  141. },
  142. grid: function() {
  143. itp_fn_jqgrid_resize(ORDMNG02010_GRID_ID, ORDMNG02010_GRID_LIST, 'lg');
  144. itp_fn_fire_window_resize();
  145. },
  146. ready: function() {
  147. listObj.init();
  148. }
  149. },
  150. event: {
  151. init: function() {
  152. this.button();
  153. },
  154. button: function() {
  155. // 버튼 클릭 이벤트
  156. $('button').each(function() {
  157. var id = $(this).attr('id');
  158. $(this).on('click', function() {
  159. switch (id) {
  160. case 'ITP_BTN_ORDMNG02010_SRH' : listObj.button.search(); break; // 조회 버튼 클릭
  161. case 'ITP_BTN_ORDMNG02010_NEWREG' : listObj.button.create(); break; // 신규등록 버튼
  162. case 'ITP_BTN_ORDMNG02010_CANCELLIST' : modifyObj.button.cancel(); break; // 취소/목록 버튼
  163. case 'ITP_BTN_ORDMNG02010_SAVE' : modifyObj.button.save(); break; // 생성버튼
  164. }
  165. });
  166. });
  167. $('body').on('click', function(e) {
  168. var gridId = (ORDMNG02010_DETAIL_GRID_ID).replace('#', '');
  169. var rids = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  170. var last_row_id = rids[rids.length - 1];
  171. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'ORDMNG02010_DETAIL');
  172. modifyObj.button.recal();
  173. })
  174. }
  175. },
  176. switchScreen: function(mode) {
  177. $('.itp_det_head').find('button[id^="ITP_BTN_ORDMNG02010_"]').each(function(i) {
  178. $(this).hide();
  179. });
  180. $('#ITP_TAB_ORDMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  181. $(this).hide();
  182. });
  183. if(mode === 'LIST') { // 목록
  184. $('#ITP_AJAX_ORDMNG02010_LIST_CONTAINER').show();
  185. fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_SRH', '#ITP_BTN_ORDMNG02010_NEWREG']);
  186. $('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  187. $('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  188. $('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').show();
  189. $('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').show();
  190. } else if(mode === 'MODIFY') { // 수정
  191. $('#ITP_AJAX_ORDMNG02010_DETAIL_CONTAINER').show();
  192. fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_CANCELLIST', '#ITP_BTN_ORDMNG02010_SAVE', '#ITP_BTN_ORDMNG02010_RESET_PW']);
  193. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  194. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  195. $('#ITP_FORM_ORDMNG02010_DETAIL_USER_ID').attr('readonly', true);
  196. $('#ITP_FORM_ORDMNG02010_DETAIL_DUP').attr('disabled', true);
  197. $('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
  198. $('#ITP_FORM_ORDMNG02010_DETAIL_USER_NM').attr('readonly', true);
  199. $('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP').hide();
  200. $('#ITP_FORM_ORDMNG02010_DETAIL_DELETE_AFFL_SHOP').hide();
  201. $('#ITP_BTN_ORDMNG02010_CANCELLIST').show();
  202. $('#ITP_BTN_ORDMNG02010_SAVE').show();
  203. }
  204. }
  205. };
  206. /*목록화면 Object*/
  207. let listObj = {
  208. init: function() {
  209. this.grid.init();
  210. this.action();
  211. },
  212. itp_ORDMNG02010_param: {},
  213. itp_ORDMNG02010_search: false,
  214. button: {
  215. search: function() {
  216. listObj.itp_ORDMNG02010_search = true;
  217. let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
  218. param.gridSize = $.jgrid.defaults.rowNum;
  219. param.gridPage = $.jgrid.defaults.page;
  220. $(ORDMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  221. },
  222. create: function() {
  223. var selectedIds = $(ORDMNG02010_GRID_ID).getGridParam('selarrrow');
  224. if(selectedIds.length > 1) { // 1이상 선택시
  225. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  226. return; //리턴
  227. }
  228. var selRowData ; //변수선언
  229. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  230. selRowData = $(ORDMNG02010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  231. }
  232. let param = {brandId: selRowData.brandId, pchPodrUnqNo: selRowData.pchPodrUnqNo};
  233. param.spplyId = fn_make_user_info.get('spplyId');
  234. pageObj.switchScreen('MODIFY');
  235. itp_fn_form_clear_validate(null, '#ITP_FORM_ORDMNG02010_DETAIL');
  236. modifyObj.init(param);
  237. }
  238. },
  239. empty: {
  240. init: function() {
  241. },
  242. push: function() {
  243. },
  244. back: function() {
  245. }
  246. },
  247. grid: {
  248. init: function() {
  249. // 데이터 없을때
  250. this.search();
  251. },
  252. colModel: gridColModel.list,
  253. search: function() {
  254. pageObj.switchScreen('LIST');
  255. this.unload();
  256. this.load();
  257. },
  258. load: function() {
  259. let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
  260. param.gridSize = $.jgrid.defaults.rowNum;
  261. var option = {
  262. gridId: ORDMNG02010_GRID_ID,
  263. colModel: gridColModel.list,
  264. param: param,
  265. url: DOMAIN + API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST,
  266. pager: ORDMNG02010_GRID_PAGER,
  267. multiselect: true,
  268. multiboxonly : false,
  269. rownumbers: false,
  270. loadComplete: function(data) {
  271. itp_fn_grid_load_complete(data, ORDMNG02010_GRID_ID, true, 'number', 'ORDMNG02010', listObj.itp_ORDMNG02010_search, listObj.empty, true, data.gridRecords, true);
  272. },
  273. onPaging: function(action) {
  274. itp_fn_grid_paging(ORDMNG02010_GRID_ID, action, param);
  275. }
  276. };
  277. itp_fn_grid_make_remote(option);
  278. },
  279. clearData: function() {
  280. $(ORDMNG02010_GRID_ID).jqGrid('clearGridData', true);
  281. $(ORDMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  282. $(ORDMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  283. $(ORDMNG02010_GRID_EMPTY).show();
  284. },
  285. unload: function() {
  286. $.jgrid.gridUnload(ORDMNG02010_GRID_ID);
  287. }
  288. },
  289. action: function() {
  290. var _this = this;
  291. // 출하창고 조회 버튼 클릭
  292. $('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').on('click', function() {
  293. _this.popup();
  294. });
  295. // 출하창고 텍스트 삭제 버튼 클릭
  296. $('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').on('click', function() {
  297. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val('');
  298. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val('');
  299. });
  300. },
  301. popup: function() {
  302. var popFn = this.callback.create;
  303. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: ''};
  304. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  305. },
  306. callback: {
  307. create: function(rowDataPop) {
  308. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  309. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  310. }
  311. }
  312. };
  313. /*수정화면 Object*/
  314. let modifyObj = {
  315. init: function(param) {
  316. this.load(param);
  317. },
  318. itp_ORDMNG02010_param: {},
  319. itp_ORDMNG02010_search: false,
  320. button: {
  321. cancel: function() {
  322. listObj.grid.search();
  323. },
  324. save: function() {
  325. const formId = '#ITP_FORM_ORDMNG02010_DETAIL';
  326. itp_fn_form_clear_validate(null, formId);
  327. itp_fn_grid_save_rows(ORDMNG02010_DETAIL_GRID_ID);
  328. let gridInsertData = [];
  329. for(var i=0; i<$(ORDMNG02010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
  330. $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
  331. }
  332. let param = $(formId).serializeObject();
  333. const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
  334. for (var i = 0; i < rowData.length; i++) {
  335. rowData[i].podrQty = Number(rowData[i].podrQty);
  336. rowData[i].shmtQty = Number(rowData[i].shmtQty);
  337. }
  338. var now = new Date();
  339. var today = now.getFullYear() +
  340. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  341. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  342. var dlvReqDt = $('#ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val();
  343. if (today > dlvReqDt) {
  344. alert("납품요청일은 오늘 이후이어야 합니다.");
  345. return;
  346. }
  347. var modalFn = {
  348. callBack: (args) => {
  349. param.gridInsertData = rowData;
  350. var searhFn = function () {
  351. ITP_FORM_OPER03010_DETAIL_IS_WRITING = false;
  352. listObj.grid.search();
  353. }
  354. fn_ajax_call(API_POMNG_INOUTMNG_SAVE_SPPLY_INV, JSON.stringify(param), searhFn, 'POST');
  355. }
  356. };
  357. itp_fn_modal_confirm('저장 하시겠습니까?', modalFn);
  358. },
  359. recal: function() {
  360. var ids = $(ORDMNG02010_DETAIL_GRID_ID).getDataIDs();
  361. $.each(ids, function(idx, rowId) {
  362. var unitAmt = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  363. var shmtQty = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'shmtQty');
  364. if (!isNaN(unitAmt) && !isNaN(shmtQty)) {
  365. if (unitAmt != null && unitAmt != '' && shmtQty != null && shmtQty != '') {
  366. jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('setRowData', rowId, {podrAmt: parseInt(unitAmt) * parseInt(shmtQty)});
  367. }
  368. }
  369. });
  370. const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
  371. var podrTotalAmt = 0;
  372. $.each(rowData, function(key, value) {
  373. if(value.podrAmt != null && value.podrAmt != "") {
  374. podrTotalAmt = podrTotalAmt + parseInt(value.podrAmt);
  375. }
  376. });
  377. $('#ITP_FORM_ORDMNG02010_DETAIL .fnPodrTotalAmt').text(itp_fn_number_comma(podrTotalAmt));
  378. }
  379. },
  380. empty: {
  381. init: function() {
  382. /*
  383. var _this = this;
  384. this.push();
  385. $(ORDMNG02010_VIEW_GRID_EMPTY).on('click', function() {
  386. _this.back();
  387. modifyObj.itp_ORDMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
  388. $(ORDMNG02010_DETAIL_GRID_ID).setGridParam({'postData': JSON.stringify(modifyObj.itp_ORDMNG02010_param)}).trigger('reloadGrid');
  389. });
  390. */
  391. },
  392. push: function() {
  393. /*
  394. let param = $('#ITP_FORM_ORDMNG02010_DETAIL').serializeObject();
  395. modifyObj.itp_ORDMNG02010_param = param;
  396. */
  397. },
  398. back: function() {
  399. /*
  400. $('#ITP_FORM_ORDMNG02010_SERVICE_BRAND_TYPE').val(modifyObj.itp_ORDMNG02010_param.brandType);
  401. $('#ITP_FORM_ORDMNG02010_SERVICE_ST_CD').val(modifyObj.itp_ORDMNG02010_param.stCd);
  402. $('#ITP_FORM_ORDMNG02010_SEARCH_BRAND_NM').val(modifyObj.itp_ORDMNG02010_param.brandNm);
  403. */
  404. }
  405. },
  406. load: function(param) {
  407. fn_ajax_call(API_POMNG_INOUTMNG_INIT_SPPLY_INV, param, this.callback, 'GET');
  408. },
  409. callback: function(result) {
  410. pageObj.switchScreen('MODIFY');
  411. $('#ITP_FORM_ORDMNG02010_DETAIL .fnBrandNm').text(result.brandNm); // 브랜드
  412. $('#ITP_FORM_ORDMNG02010_DETAIL .fnPchPodrUnqNo').text(result.invPoInfoList[0].pchPodrUnqNo); // 발주번호
  413. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt); // 납품서생성일자
  414. $('#ITP_FORM_ORDMNG02010_DETAIL .fnWhsNm').text(result.whsNm); // 발주총금액
  415. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDeliTelNo').text(result.deliTelNo); // 납품장소연락처
  416. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val(result.dlvSchDt); // 납품예정일
  417. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt); // 납품요청일
  418. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_NM').val(result.dlvMgrNm); // 납품담당자
  419. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_TEL_NO').val(result.dlvMgrTelNo); // 납품담당자연락처
  420. shmtQtyValue = function(value, colname) {
  421. var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
  422. var selRowData ; //변수선언
  423. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  424. selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  425. }
  426. let podrQty = selRowData.podrQty;
  427. if(Number(value) > Number(podrQty) || value == null || value == '') {
  428. return [false, '발주수량 이하 값 입력'];
  429. } else if (Number(value) < 0) {
  430. return [false, '음수 입력 불가'];
  431. } else {
  432. return [true, ''];
  433. }
  434. };
  435. isExpryDate = function(value, colname) {
  436. var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
  437. var selRowData ; //변수선언
  438. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  439. selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  440. }
  441. let expryYn = selRowData.expryYn;
  442. if (expryYn !== 'Y' && value.length > 0) {
  443. return [false, '유통기한여부 N'];
  444. } else {
  445. return [true, ''];
  446. }
  447. };
  448. modifyObj.grid.init('MODIFY', result.invPoInfoList);
  449. },
  450. grid: {
  451. init: function(mode, gridData) {
  452. this.mode = mode;
  453. this.gridId = ORDMNG02010_DETAIL_GRID_ID;
  454. this.gridList = ORDMNG02010_DETAIL_GRID_LIST;
  455. this.gridEmpty = ORDMNG02010_DETAIL_GRID_EMPTY;
  456. this.unload();
  457. this.load(gridData);
  458. },
  459. mode: '',
  460. colModel: gridColModel.detail,
  461. load: function(gridData) {
  462. var _this = this;
  463. var option = {
  464. gridId: _this.gridId,
  465. colModel: [
  466. {
  467. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  468. label: ITP_MSG_LOCALE.label.pchPodrUnqNo,
  469. width: '8', fixed: false, align: 'center',
  470. sortable: false, hidden: true
  471. },
  472. {
  473. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  474. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, //발주항번
  475. width: '8', fixed: false, align: 'center',
  476. sortable: false, hidden: false, edittype: 'text',
  477. editable: false
  478. },
  479. {
  480. index: 'ITEM_ID', name: 'itemId',
  481. label: ITP_MSG_LOCALE.label.itemId, //품목번호
  482. width: '10', fixed: false, align: 'center',
  483. minwidth: 100,
  484. sortable: false, hidden: false, edittype: 'text',
  485. editable: false
  486. },
  487. {
  488. index: 'ITEM_NM', name: 'itemNm',
  489. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  490. width: '10', fixed: false, align: 'left',
  491. sortable: false, hidden: false, edittype: 'text',
  492. editable: false
  493. },
  494. {
  495. index: 'UNIT', name: 'unit',
  496. label: ITP_MSG_LOCALE.label.unit, //기본단위
  497. width: '8', fixed: false, align: 'center',
  498. sortable: false, hidden: false, edittype: 'text',
  499. editable: false
  500. },
  501. {
  502. index: 'UNIT_AMT', name: 'unitAmt',
  503. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  504. width: '20', fixed: false, align: 'center',
  505. sortable: false, hidden: true, edittype: 'text',
  506. editable: false
  507. },
  508. {
  509. index: 'PODR_QTY', name: 'podrQty',
  510. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  511. width: '8', fixed: false, align: 'right',
  512. sortable: false, hidden: false, edittype: 'text',
  513. editable: false
  514. },
  515. {
  516. index: 'SHMT_QTY', name: 'shmtQty',
  517. label: ITP_MSG_LOCALE.label.shmtQty, //출하수량
  518. width: '8', fixed: false, align: 'right',
  519. sortable: false, hidden: false, edittype: 'text',
  520. classes: 'input_color',
  521. editable: true, editrules: {number: true, custom: true, custom_func: shmtQtyValue}
  522. },
  523. {
  524. index: 'EXPRY_YN', name: 'expryYn',
  525. label: ITP_MSG_LOCALE.label.expryYn, //유통기한여부
  526. width: '10', fixed: false, align: 'center',
  527. sortable: false, hidden: false, edittype: 'text',
  528. editable: false
  529. },
  530. {
  531. index: 'EXPRY_DATE', name: 'expryDate',
  532. label: ITP_MSG_LOCALE.label.expryDate, //유통기한일자
  533. width: '10', fixed: false, align: 'center',
  534. sortable: false, hidden: false,
  535. classes: 'input_color',
  536. editable: true, sorttype: 'date',
  537. editoptions: {dataInit: function(e) {$(e).datepicker(ITP_DATE_LANGUAGE);}},
  538. editrules: {custom: true, custom_func: isExpryDate}
  539. },
  540. {
  541. index: 'REMARK', name: 'deliDesc', //API 비고 키
  542. label: ITP_MSG_LOCALE.label.remark, //locale-ko 비고 값
  543. width: '10', fixed: false, align: 'center',
  544. classes: 'input_color',
  545. sortable: false, hidden: false, edittype: 'text',
  546. editable: true
  547. },
  548. {
  549. index: 'PODR_AMT', name: 'podrAmt',
  550. label: ITP_MSG_LOCALE.label.podrAmt, //발주금액
  551. width: '20', fixed: false, align: 'center',
  552. sortable: false, hidden: true, edittype: 'text',
  553. editable: false
  554. },
  555. ],
  556. data: gridData,
  557. multiselect: true,
  558. loadComplete: function(data) {
  559. itp_fn_grid_load_complete(data, ORDMNG02010_DETAIL_GRID_ID, true, 'number', 'ORDMNG02010', modifyObj.itp_ORDMNG02010_search, modifyObj.empty, true, data.gridRecords, true);
  560. },
  561. onCellSelect: function(rowId, cellIdx, cellValue) {
  562. ORDMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, ORDMNG02010_GRID_LAST_ROW_ID, ORDMNG02010_DETAIL_GRID_ID, ['actionId']);
  563. itp_fn_form_event.onKeyup(ORDMNG02010_DETAIL_GRID_ID);
  564. }
  565. };
  566. itp_fn_grid_make_local(option);
  567. },
  568. unload: function() {
  569. $.jgrid.gridUnload(this.gridId);
  570. }
  571. }
  572. };