ITP_ORDMNG02010.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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. case 'ITP_BTN_ORDMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  165. }
  166. });
  167. });
  168. $('body').on('click', function(e) {
  169. var gridId = (ORDMNG02010_DETAIL_GRID_ID).replace('#', '');
  170. var rids = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  171. var last_row_id = rids[rids.length - 1];
  172. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'ORDMNG02010_DETAIL');
  173. modifyObj.button.recal();
  174. })
  175. }
  176. },
  177. switchScreen: function(mode) {
  178. $('.itp_det_head').find('button[id^="ITP_BTN_ORDMNG02010_"]').each(function(i) {
  179. $(this).hide();
  180. });
  181. $('#ITP_TAB_ORDMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  182. $(this).hide();
  183. });
  184. if(mode === 'LIST') { // 목록
  185. $('#ITP_AJAX_ORDMNG02010_LIST_CONTAINER').show();
  186. fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_SRH', '#ITP_BTN_ORDMNG02010_NEWREG']);
  187. $('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  188. $('#ITP_FORM_ORDMNG02010_SEARCH #ITP_FORM_ORDMNG02010_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  189. $('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').show();
  190. $('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').show();
  191. $('#ITP_BTN_ORDMNG02010_EXCEL').show();
  192. } else if(mode === 'MODIFY') { // 수정
  193. $('#ITP_AJAX_ORDMNG02010_DETAIL_CONTAINER').show();
  194. fn_show_btn_auth_array(['#ITP_BTN_ORDMNG02010_CANCELLIST', '#ITP_BTN_ORDMNG02010_SAVE', '#ITP_BTN_ORDMNG02010_RESET_PW']);
  195. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  196. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_SEARCH_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  197. $('#ITP_FORM_ORDMNG02010_DETAIL_USER_ID').attr('readonly', true);
  198. $('#ITP_FORM_ORDMNG02010_DETAIL_DUP').attr('disabled', true);
  199. $('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
  200. $('#ITP_FORM_ORDMNG02010_DETAIL_USER_NM').attr('readonly', true);
  201. $('#ITP_FORM_ORDMNG02010_DETAIL_SEARCH_AFFL_SHOP').hide();
  202. $('#ITP_FORM_ORDMNG02010_DETAIL_DELETE_AFFL_SHOP').hide();
  203. $('#ITP_BTN_ORDMNG02010_CANCELLIST').show();
  204. $('#ITP_BTN_ORDMNG02010_SAVE').show();
  205. }
  206. }
  207. };
  208. /*목록화면 Object*/
  209. let listObj = {
  210. init: function() {
  211. this.grid.init();
  212. this.action();
  213. },
  214. itp_ORDMNG02010_param: {},
  215. itp_ORDMNG02010_search: false,
  216. button: {
  217. search: function() {
  218. listObj.itp_ORDMNG02010_search = true;
  219. let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
  220. param.gridSize = $.jgrid.defaults.rowNum;
  221. param.gridPage = $.jgrid.defaults.page;
  222. $(ORDMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  223. },
  224. create: function() {
  225. var selectedIds = $(ORDMNG02010_GRID_ID).getGridParam('selarrrow');
  226. if(selectedIds.length > 1) { // 1이상 선택시
  227. alert("납품서 하나만 선택해주세요 (대표 납품서번호)") ;//출력
  228. return; //리턴
  229. }
  230. var selRowData ; //변수선언
  231. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  232. selRowData = $(ORDMNG02010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  233. }
  234. let param = {brandId: selRowData.brandId, pchPodrUnqNo: selRowData.pchPodrUnqNo};
  235. param.spplyId = fn_make_user_info.get('spplyId');
  236. pageObj.switchScreen('MODIFY');
  237. itp_fn_form_clear_validate(null, '#ITP_FORM_ORDMNG02010_DETAIL');
  238. modifyObj.init(param);
  239. }
  240. },
  241. empty: {
  242. init: function() {
  243. },
  244. push: function() {
  245. },
  246. back: function() {
  247. }
  248. },
  249. grid: {
  250. init: function() {
  251. // 데이터 없을때
  252. this.search();
  253. },
  254. colModel: gridColModel.list,
  255. search: function() {
  256. pageObj.switchScreen('LIST');
  257. this.unload();
  258. this.load();
  259. },
  260. load: function() {
  261. let param = $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject();
  262. param.gridSize = $.jgrid.defaults.rowNum;
  263. var option = {
  264. gridId: ORDMNG02010_GRID_ID,
  265. colModel: gridColModel.list,
  266. param: param,
  267. url: DOMAIN + API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST,
  268. pager: ORDMNG02010_GRID_PAGER,
  269. multiselect: true,
  270. multiboxonly : false,
  271. rownumbers: false,
  272. loadComplete: function(data) {
  273. itp_fn_grid_load_complete(data, ORDMNG02010_GRID_ID, true, 'number', 'ORDMNG02010', listObj.itp_ORDMNG02010_search, listObj.empty, true, data.gridRecords, true);
  274. },
  275. onPaging: function(action) {
  276. itp_fn_grid_paging(ORDMNG02010_GRID_ID, action, param);
  277. }
  278. };
  279. itp_fn_grid_make_remote(option);
  280. },
  281. clearData: function() {
  282. $(ORDMNG02010_GRID_ID).jqGrid('clearGridData', true);
  283. $(ORDMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  284. $(ORDMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  285. $(ORDMNG02010_GRID_EMPTY).show();
  286. },
  287. unload: function() {
  288. $.jgrid.gridUnload(ORDMNG02010_GRID_ID);
  289. }
  290. },
  291. action: function() {
  292. var _this = this;
  293. // 출하창고 조회 버튼 클릭
  294. $('#ITP_BTN_ORDMNG02010_SEARCH_WHS_ID').on('click', function() {
  295. _this.popup();
  296. });
  297. // 출하창고 텍스트 삭제 버튼 클릭
  298. $('#ITP_BTN_ORDMNG02010_DELETE_WHS_ID').on('click', function() {
  299. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val('');
  300. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val('');
  301. });
  302. },
  303. popup: function() {
  304. var popFn = this.callback.create;
  305. const key = {brandId:fn_make_user_info.get('brandId'),storeId:fn_make_user_info.get('storeId'),whsDvsn: ''};
  306. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  307. },
  308. callback: {
  309. create: function(rowDataPop) {
  310. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_ID').val(rowDataPop.whsId);
  311. $('#ITP_FORM_ORDMNG02010_SEARCH_WHS_NM').val(rowDataPop.whsNm);
  312. }
  313. },
  314. excelDown: function() {
  315. var param = {
  316. 'url': API_POMNG_INOUTMNG_SPPLY_TARGET_GRID_LIST,
  317. 'param': $('#ITP_FORM_ORDMNG02010_SEARCH').serializeObject(),
  318. 'gridColumns': $(ORDMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  319. 'fileName': '공급사 납품서생성.xlsx',
  320. 'sheetName': '공급사 납품서리스트'
  321. };
  322. itp_fn_remote_to_excel(param);
  323. }
  324. };
  325. /*수정화면 Object*/
  326. let modifyObj = {
  327. init: function(param) {
  328. this.load(param);
  329. },
  330. itp_ORDMNG02010_param: {},
  331. itp_ORDMNG02010_search: false,
  332. button: {
  333. cancel: function() {
  334. listObj.grid.search();
  335. },
  336. save: function() {
  337. const formId = '#ITP_FORM_ORDMNG02010_DETAIL';
  338. itp_fn_form_clear_validate(null, formId);
  339. itp_fn_grid_save_rows(ORDMNG02010_DETAIL_GRID_ID);
  340. let gridInsertData = [];
  341. for(var i=0; i<$(ORDMNG02010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
  342. $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
  343. }
  344. let param = $(formId).serializeObject();
  345. const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
  346. for (var i = 0; i < rowData.length; i++) {
  347. rowData[i].podrQty = Number(rowData[i].podrQty);
  348. rowData[i].shmtQty = Number(rowData[i].shmtQty);
  349. }
  350. var now = new Date();
  351. var today = now.getFullYear() +
  352. "." + (now.getMonth()+1 > 9 ? (now.getMonth()+1).toString() : "0" + (now.getMonth()+1).toString()) +
  353. "." + (now.getDate() > 9 ? now.getDate().toString() : "0" + now.getDate().toString());
  354. var dlvReqDt = $('#ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val();
  355. if (today > dlvReqDt) {
  356. alert("납품요청일은 오늘 이후이어야 합니다.");
  357. return;
  358. }
  359. var modalFn = {
  360. callBack: (args) => {
  361. param.gridInsertData = rowData;
  362. var searhFn = function () {
  363. ITP_FORM_OPER03010_DETAIL_IS_WRITING = false;
  364. listObj.grid.search();
  365. }
  366. fn_ajax_call(API_POMNG_INOUTMNG_SAVE_SPPLY_INV, JSON.stringify(param), searhFn, 'POST');
  367. }
  368. };
  369. itp_fn_modal_confirm('저장 하시겠습니까?', modalFn);
  370. },
  371. recal: function() {
  372. var ids = $(ORDMNG02010_DETAIL_GRID_ID).getDataIDs();
  373. $.each(ids, function(idx, rowId) {
  374. var unitAmt = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  375. var shmtQty = jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'shmtQty');
  376. if (!isNaN(unitAmt) && !isNaN(shmtQty)) {
  377. if (unitAmt != null && unitAmt != '' && shmtQty != null && shmtQty != '') {
  378. jQuery(ORDMNG02010_DETAIL_GRID_ID).jqGrid('setRowData', rowId, {podrAmt: parseInt(unitAmt) * parseInt(shmtQty)});
  379. }
  380. }
  381. });
  382. const rowData = $(ORDMNG02010_DETAIL_GRID_ID).getRowData();
  383. var podrTotalAmt = 0;
  384. $.each(rowData, function(key, value) {
  385. if(value.podrAmt != null && value.podrAmt != "") {
  386. podrTotalAmt = podrTotalAmt + parseInt(value.podrAmt);
  387. }
  388. });
  389. $('#ITP_FORM_ORDMNG02010_DETAIL .fnPodrTotalAmt').text(itp_fn_number_comma(podrTotalAmt));
  390. }
  391. },
  392. empty: {
  393. init: function() {
  394. /*
  395. var _this = this;
  396. this.push();
  397. $(ORDMNG02010_VIEW_GRID_EMPTY).on('click', function() {
  398. _this.back();
  399. modifyObj.itp_ORDMNG02010_param.gridSize = $.jgrid.defaults.rowNum;
  400. $(ORDMNG02010_DETAIL_GRID_ID).setGridParam({'postData': JSON.stringify(modifyObj.itp_ORDMNG02010_param)}).trigger('reloadGrid');
  401. });
  402. */
  403. },
  404. push: function() {
  405. /*
  406. let param = $('#ITP_FORM_ORDMNG02010_DETAIL').serializeObject();
  407. modifyObj.itp_ORDMNG02010_param = param;
  408. */
  409. },
  410. back: function() {
  411. /*
  412. $('#ITP_FORM_ORDMNG02010_SERVICE_BRAND_TYPE').val(modifyObj.itp_ORDMNG02010_param.brandType);
  413. $('#ITP_FORM_ORDMNG02010_SERVICE_ST_CD').val(modifyObj.itp_ORDMNG02010_param.stCd);
  414. $('#ITP_FORM_ORDMNG02010_SEARCH_BRAND_NM').val(modifyObj.itp_ORDMNG02010_param.brandNm);
  415. */
  416. }
  417. },
  418. load: function(param) {
  419. fn_ajax_call(API_POMNG_INOUTMNG_INIT_SPPLY_INV, param, this.callback, 'GET');
  420. },
  421. callback: function(result) {
  422. pageObj.switchScreen('MODIFY');
  423. $('#ITP_FORM_ORDMNG02010_DETAIL .fnBrandNm').text(result.brandNm); // 브랜드
  424. $('#ITP_FORM_ORDMNG02010_DETAIL .fnPchPodrUnqNo').text(result.invPoInfoList[0].pchPodrUnqNo); // 발주번호
  425. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt); // 납품서생성일자
  426. $('#ITP_FORM_ORDMNG02010_DETAIL .fnWhsNm').text(result.whsNm); // 발주총금액
  427. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDeliTelNo').text(result.deliTelNo); // 납품장소연락처
  428. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_SCH_DT').val(result.dlvSchDt); // 납품예정일
  429. $('#ITP_FORM_ORDMNG02010_DETAIL .fnDlvRegDt').text(result.dlvReqDt); // 납품요청일
  430. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_NM').val(result.dlvMgrNm); // 납품담당자
  431. $('#ITP_FORM_ORDMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_DLV_MGR_TEL_NO').val(result.dlvMgrTelNo); // 납품담당자연락처
  432. shmtQtyValue = function(value, colname) {
  433. var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
  434. var selRowData ; //변수선언
  435. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  436. selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  437. }
  438. let podrQty = selRowData.podrQty;
  439. if(Number(value) > Number(podrQty) || value == null || value == '') {
  440. return [false, '발주수량 이하 값 입력'];
  441. } else if (Number(value) < 0) {
  442. return [false, '음수 입력 불가'];
  443. } else {
  444. return [true, ''];
  445. }
  446. };
  447. isExpryDate = function(value, colname) {
  448. var selectedIds = $(ORDMNG02010_DETAIL_GRID_ID).getGridParam('selarrrow');
  449. var selRowData ; //변수선언
  450. for (var i=selectedIds.length-1; i>=0; i--) { //1개만 선택시
  451. selRowData = $(ORDMNG02010_DETAIL_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  452. }
  453. let expryYn = selRowData.expryYn;
  454. if (expryYn !== 'Y' && value.length > 0) {
  455. return [false, '유통기한여부 N'];
  456. } else {
  457. return [true, ''];
  458. }
  459. };
  460. modifyObj.grid.init('MODIFY', result.invPoInfoList);
  461. },
  462. grid: {
  463. init: function(mode, gridData) {
  464. this.mode = mode;
  465. this.gridId = ORDMNG02010_DETAIL_GRID_ID;
  466. this.gridList = ORDMNG02010_DETAIL_GRID_LIST;
  467. this.gridEmpty = ORDMNG02010_DETAIL_GRID_EMPTY;
  468. this.unload();
  469. this.load(gridData);
  470. },
  471. mode: '',
  472. colModel: gridColModel.detail,
  473. load: function(gridData) {
  474. var _this = this;
  475. var option = {
  476. gridId: _this.gridId,
  477. colModel: [
  478. {
  479. index: 'PCH_PODR_UNQ_NO', name: 'pchPodrUnqNo',
  480. label: ITP_MSG_LOCALE.label.pchPodrUnqNo,
  481. width: '8', fixed: false, align: 'center',
  482. sortable: false, hidden: true
  483. },
  484. {
  485. index: 'PCH_PODR_DTL_NO', name: 'pchPodrDtlNo',
  486. label: ITP_MSG_LOCALE.label.pchPodrDtlNo, //발주항번
  487. width: '8', fixed: false, align: 'center',
  488. sortable: false, hidden: false, edittype: 'text',
  489. editable: false
  490. },
  491. {
  492. index: 'ITEM_ID', name: 'itemId',
  493. label: ITP_MSG_LOCALE.label.itemId, //품목번호
  494. width: '10', fixed: false, align: 'center',
  495. minwidth: 100,
  496. sortable: false, hidden: false, edittype: 'text',
  497. editable: false
  498. },
  499. {
  500. index: 'ITEM_NM', name: 'itemNm',
  501. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  502. width: '10', fixed: false, align: 'left',
  503. sortable: false, hidden: false, edittype: 'text',
  504. editable: false
  505. },
  506. {
  507. index: 'UNIT', name: 'unit',
  508. label: ITP_MSG_LOCALE.label.unit, //기본단위
  509. width: '8', fixed: false, align: 'center',
  510. sortable: false, hidden: false, edittype: 'text',
  511. editable: false
  512. },
  513. {
  514. index: 'UNIT_AMT', name: 'unitAmt',
  515. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  516. width: '20', fixed: false, align: 'center',
  517. sortable: false, hidden: true, edittype: 'text',
  518. editable: false
  519. },
  520. {
  521. index: 'PODR_QTY', name: 'podrQty',
  522. label: ITP_MSG_LOCALE.label.podrQty, //발주수량
  523. width: '8', fixed: false, align: 'right',
  524. sortable: false, hidden: false, edittype: 'text',
  525. editable: false
  526. },
  527. {
  528. index: 'SHMT_QTY', name: 'shmtQty',
  529. label: ITP_MSG_LOCALE.label.shmtQty, //출하수량
  530. width: '8', fixed: false, align: 'right',
  531. sortable: false, hidden: false, edittype: 'text',
  532. classes: 'input_color',
  533. editable: true, editrules: {number: true, custom: true, custom_func: shmtQtyValue}
  534. },
  535. {
  536. index: 'EXPRY_YN', name: 'expryYn',
  537. label: ITP_MSG_LOCALE.label.expryYn, //유통기한여부
  538. width: '10', fixed: false, align: 'center',
  539. sortable: false, hidden: false, edittype: 'text',
  540. editable: false
  541. },
  542. {
  543. index: 'EXPRY_DATE', name: 'expryDate',
  544. label: ITP_MSG_LOCALE.label.expryDate, //유통기한일자
  545. width: '10', fixed: false, align: 'center',
  546. sortable: false, hidden: false,
  547. classes: 'input_color',
  548. editable: true, sorttype: 'date',
  549. editoptions: {dataInit: function(e) {$(e).datepicker(ITP_DATE_LANGUAGE);}},
  550. editrules: {custom: true, custom_func: isExpryDate}
  551. },
  552. {
  553. index: 'REMARK', name: 'deliDesc', //API 비고 키
  554. label: ITP_MSG_LOCALE.label.remark, //locale-ko 비고 값
  555. width: '10', fixed: false, align: 'center',
  556. classes: 'input_color',
  557. sortable: false, hidden: false, edittype: 'text',
  558. editable: true
  559. },
  560. {
  561. index: 'PODR_AMT', name: 'podrAmt',
  562. label: ITP_MSG_LOCALE.label.podrAmt, //발주금액
  563. width: '20', fixed: false, align: 'center',
  564. sortable: false, hidden: true, edittype: 'text',
  565. editable: false
  566. },
  567. ],
  568. data: gridData,
  569. multiselect: true,
  570. loadComplete: function(data) {
  571. itp_fn_grid_load_complete(data, ORDMNG02010_DETAIL_GRID_ID, true, 'number', 'ORDMNG02010', modifyObj.itp_ORDMNG02010_search, modifyObj.empty, true, data.gridRecords, true);
  572. },
  573. onCellSelect: function(rowId, cellIdx, cellValue) {
  574. ORDMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, ORDMNG02010_GRID_LAST_ROW_ID, ORDMNG02010_DETAIL_GRID_ID, ['actionId']);
  575. itp_fn_form_event.onKeyup(ORDMNG02010_DETAIL_GRID_ID);
  576. }
  577. };
  578. itp_fn_grid_make_local(option);
  579. },
  580. unload: function() {
  581. $.jgrid.gridUnload(this.gridId);
  582. }
  583. }
  584. };