ITP_COLLMNG02010.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. require(['config'], function() {
  2. require([], function($) {
  3. pageObj.init();
  4. });
  5. });
  6. /********************************************************
  7. --------------------------------------------------------
  8. - Object 목록 -
  9. --------------------------------------------------------
  10. * const gridColModel = {} : 화면 Grid Object *
  11. * let pageObj = {} : 화면공통 Object *
  12. * let listObj = {} : 목록화면 Object *
  13. * let modifyObj = {} : 수정화면 Object *
  14. *******************************************************/
  15. /*화면 변수*/
  16. const COLLMNG02010_GRID_ID = '#ITP_COLLMNG02010_jqGrid';
  17. const COLLMNG02010_GRID_LIST = '#ITP_COLLMNG02010_jqGrid_list';
  18. const COLLMNG02010_GRID_PAGER = '#ITP_COLLMNG02010_jqGridPager';
  19. const COLLMNG02010_GRID_EMPTY = '#ITP_COLLMNG02010_jqGridEmpty';
  20. const COLLMNG02010_DETAIL_GRID_ID = '#ITP_COLLMNG02010_DETAIL_jqGrid';
  21. const COLLMNG02010_DETAIL_GRID_LIST = '#ITP_COLLMNG02010_DETAIL_jqGrid_list';
  22. const COLLMNG02010_DETAIL_GRID_PAGER = '#ITP_COLLMNG02010_DETAIL_jqGridPager';
  23. const COLLMNG02010_DETAIL_GRID_EMPTY = '#ITP_COLLMNG02010_DETAIL_jqGridEmpty';
  24. //let ITP_FORM_COLLMNG02010_DETAIL_IS_WRITING = false;
  25. let COLLMNG02010_GRID_LAST_ROW_ID;
  26. /*API URL*/
  27. let API_DETAIL_GRID_LIST = '/api/rtnmng/inoutmng/spply-target-rtn-grid-list'; // 목록
  28. let API_DETAIL_INIT_INFO = '/api/rtnmng/inoutmng/init-spply-col'; // 정보
  29. let API_DETAIL_SAVE = '/api/rtnmng/inoutmng/save-spply-col'; // 수거서생성
  30. /*화면 Grid ColModel*/
  31. const gridColModel = {
  32. list: [
  33. {
  34. index: 'BRAND_ID', name: 'brandId',
  35. label: ITP_MSG_LOCALE.label.brandId, //브랜드아이디
  36. width: '13', fixed: false, align: 'center',
  37. sortable: false, hidden: true
  38. },
  39. {
  40. index: 'BRAND_NM', name: 'brandNm',
  41. label: ITP_MSG_LOCALE.label.brandNm, //브랜드명
  42. width: '10', fixed: false, align: 'left',
  43. sortable: false, hidden: false, classes: 'ui-ellipsis'
  44. },
  45. {
  46. index: 'RTN_PODR_UNQ_NO', name: 'rtnPodrUnqNo',
  47. label: ITP_MSG_LOCALE.label.rtnPodrUnqNo, //반품발주번호
  48. width: '10', fixed: false, align: 'center',
  49. sortable: false, hidden: false
  50. },
  51. {
  52. index: 'RTN_PODR_DTL_NO', name: 'rtnPodrDtlNo',
  53. label: ITP_MSG_LOCALE.label.rtnPodrDtlNo, //반품발주항번
  54. width: '10', fixed: false, align: 'center',
  55. sortable: false, hidden: false
  56. },
  57. {
  58. index: 'ITEM_ID', name: 'itemId',
  59. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  60. width: '10', fixed: false, align: 'center',
  61. minwidth: 150,
  62. sortable: false, hidden: false
  63. },
  64. {
  65. index: 'ITEM_NM', name: 'itemNm',
  66. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  67. width: '10', fixed: false, align: 'left',
  68. sortable: false, hidden: false, classes: 'ui-ellipsis'
  69. },
  70. {
  71. index: 'RTN_WHS_ID', name: 'rtnWhsId',
  72. label: ITP_MSG_LOCALE.label.rtnWhsId, //수거창고아이디
  73. width: '13', fixed: false, align: 'center',
  74. sortable: false, hidden: true
  75. },
  76. {
  77. index: 'RTN_WHS_NM', name: 'rtnWhsNm',
  78. label: ITP_MSG_LOCALE.label.rtnWhsNm, //수거창고명
  79. width: '15', fixed: false, align: 'left',
  80. minwidth: 220,
  81. sortable: false, hidden: false, classes: 'ui-ellipsis'
  82. },
  83. {
  84. index: 'RTN_LOCATION', name: 'rtnLocation',
  85. label: ITP_MSG_LOCALE.label.rtnLocation, //납품수거LOCATION
  86. width: '15', fixed: false, align: 'center',
  87. sortable: false, hidden: true
  88. },
  89. {
  90. index: 'UNIT_AMT', name: 'unitAmt',
  91. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  92. width: '6', fixed: false, align: 'right',
  93. sortable: false, hidden: false,
  94. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  95. },
  96. {
  97. index: 'RTN_ODR_QTY', name: 'rtnOdrQty',
  98. label: ITP_MSG_LOCALE.label.rtnOdrQty, //rtnOdrAmt
  99. width: '10', fixed: false, align: 'right',
  100. sortable: false, hidden: false,
  101. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  102. },
  103. {
  104. index: 'COL_REQ_DT', name: 'colReqDt',
  105. label: ITP_MSG_LOCALE.label.colReqDt, //수거요청일
  106. width: '20', fixed: false, align: 'center',
  107. sortable: false, hidden: true,
  108. editable: false, sorttype: "date"
  109. }
  110. ],
  111. detail: [
  112. {
  113. index: 'RTN_PODR_UNQ_NO', name: 'rtnPodrUnqNo',
  114. label: ITP_MSG_LOCALE.label.rtnPodrUnqNo, //반품발주번호
  115. width: '10', fixed: false, align: 'center',
  116. sortable: false, hidden: false
  117. },
  118. {
  119. index: 'RTN_PODR_DTL_NO', name: 'rtnPodrDtlNo',
  120. label: ITP_MSG_LOCALE.label.rtnPodrDtlNo, //반품발주항번
  121. width: '10', fixed: false, align: 'center',
  122. sortable: false, hidden: false
  123. },
  124. {
  125. index: 'ITEM_ID', name: 'itemId',
  126. label: ITP_MSG_LOCALE.label.itemId, //품목아이디
  127. width: '10', fixed: false, align: 'center',
  128. sortable: false, hidden: false
  129. },
  130. {
  131. index: 'ITEM_NM', name: 'itemNm',
  132. label: ITP_MSG_LOCALE.label.itemNm, //품목명
  133. width: '10', fixed: false, align: 'left',
  134. sortable: false, hidden: false, classes: 'ui-ellipsis'
  135. },
  136. {
  137. index: 'UNIT', name: 'unit',
  138. label: ITP_MSG_LOCALE.label.unit, //단위
  139. width: '6', fixed: false, align: 'center',
  140. sortable: false, hidden: false
  141. },
  142. {
  143. index: 'UNIT_AMT', name: 'unitAmt',
  144. label: ITP_MSG_LOCALE.label.unitAmt, //단가
  145. width: '6', fixed: false, align: 'right',
  146. sortable: false, hidden: false,
  147. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  148. },
  149. {
  150. index: 'RTN_ODR_QTY', name: 'rtnOdrQty',
  151. label: ITP_MSG_LOCALE.label.rtnOdrQty, //반품발주수량
  152. width: '10', fixed: false, align: 'right',
  153. sortable: false, hidden: false,
  154. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  155. },
  156. {
  157. index: 'COL_QTY', name: 'colQty',
  158. label: ITP_MSG_LOCALE.label.colQty, //수거수량
  159. width: '10', fixed: false, align: 'right',
  160. sortable: true, editable: true, edittype: 'text',
  161. editrules: { required: true, number: true },
  162. classes: 'input_color',
  163. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' },
  164. editoptions: {"onKeyup": "this.value=this.value.replace(/[^0-9]/g,'');"}
  165. },
  166. {
  167. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  168. label: ITP_MSG_LOCALE.label.rtnRsnDvsnNm, //반품사유
  169. width: '10', fixed: false, align: 'center',
  170. sortable: false, hidden: false, classes: 'ui-ellipsis'
  171. },
  172. {
  173. index: 'RTN_RSN_DVSN', name: 'rtnRsnDvsn',
  174. label: ITP_MSG_LOCALE.label.rtnRsnDvsn, //반품사유
  175. width: '10', fixed: false, align: 'center',
  176. sortable: false, hidden: true
  177. },
  178. {
  179. index: 'RTN_RSN', name: 'rtnRsn',
  180. label: ITP_MSG_LOCALE.label.rtnRsn, //비고
  181. width: '10', fixed: false, align: 'center',
  182. sortable: false, hidden: false, classes: 'ui-ellipsis'
  183. },
  184. {
  185. index: 'COL_AMT', name: 'colAmt',
  186. label: ITP_MSG_LOCALE.label.colAmt, //
  187. width: '10', fixed: false, align: 'right',
  188. sortable: false, hidden: false,
  189. formatter: 'integer', formatoptions: { defaultValue: '', thousandsSeparator: ',' }
  190. }
  191. ]
  192. };
  193. /*화면공통 Object*/
  194. let pageObj = {
  195. init: function () {
  196. this.ui.init();
  197. this.event.init();
  198. this.action();
  199. },
  200. ui: {
  201. init: function () {
  202. this.view();
  203. this.grid();
  204. this.ready();
  205. },
  206. view: function() {
  207. // 버튼 권한설정
  208. fn_proc_btn_auth('COLLMNG02010');
  209. // 공통코드 표시
  210. $('select').each(function() {
  211. if($(this).data('select-code')) {
  212. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  213. }
  214. });
  215. // 조회일자 지정
  216. var now = new Date();
  217. $('#ITP_TAB_COLLMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  218. $('#ITP_FORM_COLLMNG02010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setDate(now.getDate())));
  219. $('#ITP_FORM_COLLMNG02010_SEARCH_TO_DT').datepicker('setDate', new Date(now.setDate(now.getDate() + 30)));
  220. $('#ITP_FORM_COLLMNG02010_SEARCH #ITP_FORM_COLLMNG02010_SEARCH_SSPPLY_ID').val(fn_make_user_info.get('spplyId'));
  221. },
  222. grid: function() {
  223. //itp_fn_jqgrid_resize(COLLMNG02010_GRID_ID, COLLMNG02010_GRID_LIST, 'lg');
  224. itp_fn_fire_window_resize();
  225. },
  226. ready: function() {
  227. listObj.init();
  228. }
  229. },
  230. action: function () {
  231. var _this = this;
  232. // 수거창고 조회 버튼 클릭
  233. $('#ITP_BTN_COLLMNG02010_SEARCH_RTN_WHS_ID').on('click', function() {
  234. _this.popup();
  235. });
  236. // 출하창고 텍스트 삭제 버튼 클릭
  237. $('#ITP_BTN_COLLMNG02010_DELETE_RTN_WHS_ID').on('click', function() {
  238. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_NM').val('');
  239. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_ID').val('');
  240. });
  241. },
  242. popup: function (arg) {
  243. var popFn = this.callback.rtnwhs;
  244. var whsDvsn = "";
  245. const key = { brandId: fn_make_user_info.get('brandId'), storeId: fn_make_user_info.get('storeId'), whsDvsn: whsDvsn };
  246. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  247. },
  248. callback: {
  249. rtnwhs: function(rowDataPop) {
  250. if (rowDataPop) {
  251. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_NM').val(rowDataPop.whsNm);
  252. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_ID').val(rowDataPop.whsId);
  253. }
  254. }
  255. },
  256. event: {
  257. init: function () {
  258. this.button();
  259. },
  260. button: function () {
  261. // 버튼 클릭 이벤트
  262. $('button').each(function() {
  263. var id = $(this).attr('id');
  264. $(this).on('click', function() {
  265. switch (id) {
  266. case 'ITP_BTN_COLLMNG02010_SRH' : listObj.button.search(); break;
  267. case 'ITP_BTN_COLLMNG02010_CUDW' : listObj.button.colcreat(); break; // 수거서생성
  268. case 'ITP_BTN_COLLMNG02010_CRT' : modifyObj.button.save() ; break; // 생성
  269. case 'ITP_BTN_COLLMNG02010_CANCELLIST' : modifyObj.button.cancel(); break;
  270. case 'ITP_BTN_COLLMNG02010_EXCEL' : listObj.excelDown(); break; // 엑셀 다운로드
  271. }
  272. });
  273. });
  274. $('body').on('click', function(e) {
  275. var gridId = (COLLMNG02010_DETAIL_GRID_ID).replace('#', '');
  276. var rids = $(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  277. var last_row_id = rids[rids.length - 1];
  278. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'COLLMNG02010_DETAIL');
  279. modifyObj.button.recal();
  280. });
  281. }
  282. },
  283. switchScreen: function(mode) {
  284. $('.itp_det_head').find('button[id^="ITP_BTN_COLLMNG02010_"]').each(function(i) {
  285. $(this).hide();
  286. });
  287. $('#ITP_TAB_COLLMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  288. $(this).hide();
  289. });
  290. if(mode == 'LIST') { // 목록
  291. $('#ITP_AJAX_COLLMNG02010_LIST_CONTAINER').show();
  292. $('#ITP_BTN_COLLMNG02010_DELETE_RTN_WHS_ID').show();
  293. fn_show_btn_auth_array(['#ITP_BTN_COLLMNG02010_SRH', '#ITP_BTN_COLLMNG02010_CUDW']);
  294. $('#ITP_FORM_COLLMNG02010_SEARCH_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  295. $('#ITP_FORM_COLLMNG02010_SEARCH_SSPPLY_ID').val(fn_make_user_info.get('spplyId'));
  296. $('#ITP_BTN_COLLMNG02010_EXCEL').show();
  297. } else if(mode == 'DETAIL') { // 수거서 작성
  298. $('#ITP_AJAX_COLLMNG02010_DETAIL_CONTAINER').show();
  299. fn_show_btn_auth_array(['#ITP_BTN_COLLMNG02010_CRT', '#ITP_BTN_COLLMNG02010_CANCELLIST']);
  300. $('#ITP_FORM_COLLMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  301. //pageObj.grid.init(param);
  302. }
  303. },
  304. grid: {
  305. init: function(gridData) {
  306. this.gridId = COLLMNG02010_DETAIL_GRID_ID;
  307. this.gridList = COLLMNG02010_DETAIL_GRID_LIST;
  308. this.gridEmpty = COLLMNG02010_DETAIL_GRID_EMPTY;
  309. //var now = new Date();
  310. //$('#ITP_TAB_COLLMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  311. //$('#ITP_FORM_COLLMNG02010_DETAIL_DLV_SCH_DT').datepicker('setDate', new Date(param.dlvSchDt));
  312. //$('#ITP_FORM_COLLMNG02010_DETAIL .fnBrandNm').text(param.brandNm);
  313. //this.gridRows = param.recordData;
  314. this.unload();
  315. this.load(gridData);
  316. },
  317. gridId: '',
  318. button: {},
  319. gridList: '',
  320. gridEmpty: '',
  321. gridRows: '',
  322. load: function(gridRows) {
  323. var _this = this;
  324. var option = {
  325. gridId: _this.gridId,
  326. colModel: gridColModel.detail,
  327. data: gridRows,
  328. loadComplete: function(data) {
  329. itp_fn_grid_load_complete(data, COLLMNG02010_DETAIL_GRID_ID, true, 'number', 'COLLMNG02010', modifyObj.itp_COLLMNG02010_search, modifyObj.empty, true, data.gridRecords, true);
  330. },
  331. onCellSelect: function(rowid, cellIdx, cellValue) {
  332. COLLMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, COLLMNG02010_GRID_LAST_ROW_ID, _this.gridId, ['rtnReqDtlNo']);
  333. }
  334. };
  335. itp_fn_grid_make_local(option);
  336. },
  337. clearData : function(mode) {
  338. $(COLLMNG02010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  339. $(COLLMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  340. $(COLLMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  341. $(COLLMNG02010_DETAIL_GRID_EMPTY).show();
  342. },
  343. unload : function() {
  344. $.jgrid.gridUnload(this.gridId);
  345. }
  346. }
  347. };
  348. /*목록화면 Object*/
  349. let listObj = {
  350. init: function () {
  351. this.grid.init();
  352. },
  353. itp_COLLMNG02010_search: false,
  354. button: {
  355. search: function() {
  356. listObj.itp_COLLMNG02010_search = true;
  357. let param = $('#ITP_FORM_COLLMNG02010_SEARCH').serializeObject();
  358. param.gridSize = $.jgrid.defaults.rowNum;
  359. param.gridPage = $.jgrid.defaults.page;
  360. $(COLLMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  361. },
  362. colcreat: function() {
  363. var selectedIds = $(COLLMNG02010_GRID_ID).getGridParam('selarrrow');
  364. if(selectedIds.length > 1) { // 1이상 선택시
  365. alert("반품발주 한 건만 선택해주세요 (대표 반품발주)") ;//출력
  366. return; //리턴
  367. }
  368. var selRowData ; //변수선언
  369. for (var i=selectedIds.length-1; i>=0;i--) {
  370. selRowData = $(COLLMNG02010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  371. }
  372. if (selRowData == null) {
  373. itp_fn_modal_alert_ajax(ITP_MSG_LOCALE.message.ajax.noData)
  374. return;
  375. }
  376. let param = {brandId: selRowData.brandId, rtnPodrUnqNo: selRowData.rtnPodrUnqNo, spplyId: fn_make_user_info.get('spplyId')};
  377. pageObj.switchScreen('DETAIL');
  378. itp_fn_form_clear_validate(null, '#ITP_FORM_COLLMNG02010_DETAIL');
  379. modifyObj.init(param);
  380. }
  381. },
  382. empty: {
  383. init: function() {
  384. },
  385. itp_COLLMNG02010_param: {},
  386. push: function() {
  387. },
  388. back: function() {
  389. }
  390. },
  391. grid: {
  392. init: function () {
  393. // 데이터 없을때
  394. //itp_fn_jqgrid_resize(COLLMNG02010_GRID_ID, COLLMNG02010_GRID_LIST, 'lg');
  395. itp_fn_fire_window_resize();
  396. this.search();
  397. },
  398. colModel: gridColModel.list,
  399. search: function() {
  400. pageObj.switchScreen('LIST');
  401. this.unload();
  402. this.load();
  403. },
  404. load: function() {
  405. let param = $('#ITP_FORM_COLLMNG02010_SEARCH').serializeObject();
  406. param.gridSize = $.jgrid.defaults.rowNum;
  407. var option = {
  408. multiselect: true,
  409. rownumbers: false,
  410. autowidth: true,
  411. gridId: COLLMNG02010_GRID_ID,
  412. colModel: gridColModel.list,
  413. param: param,
  414. url: DOMAIN + API_DETAIL_GRID_LIST,
  415. pager: COLLMNG02010_GRID_PAGER,
  416. loadComplete: function(data) {
  417. itp_fn_grid_load_complete(data, COLLMNG02010_GRID_ID, true, 'number', 'COLLMNG02010', listObj.itp_COLLMNG02010_search, listObj.empty, true, data.gridRecords, true);
  418. },
  419. onPaging: function(action) {
  420. itp_fn_grid_paging(COLLMNG02010_GRID_ID, action, param);
  421. }
  422. };
  423. itp_fn_grid_make_remote(option);
  424. },
  425. button: {
  426. },
  427. unload : function() {
  428. $.jgrid.gridUnload(COLLMNG02010_GRID_ID);
  429. },
  430. clearData : function() {
  431. $(COLLMNG02010_GRID_ID).jqGrid('clearGridData', true);
  432. $(COLLMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  433. $(COLLMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  434. $(COLLMNG02010_GRID_EMPTY).show();
  435. }
  436. },
  437. excelDown: function() {
  438. var param = {
  439. 'url': API_DETAIL_GRID_LIST,
  440. 'param': $('#ITP_FORM_COLLMNG02010_SEARCH').serializeObject(),
  441. 'gridColumns': $(COLLMNG02010_GRID_ID).jqGrid('getGridParam', 'colModel'),
  442. 'fileName': '공급사 수거서작성.xlsx',
  443. 'sheetName': '공급사 수거서리스트'
  444. };
  445. itp_fn_remote_to_excel(param);
  446. }
  447. };
  448. /*수정화면 Object*/
  449. let modifyObj = {
  450. init: function (param) {
  451. this.load(param);
  452. },
  453. button: {
  454. modify: function (param) {
  455. itp_fn_form_clear_validate(null, '#ITP_FORM_COLLMNG02010_DETAIL');
  456. //const selectVal = $('#ITP_FORM_COLLMNG02010_VIEW_STORE_ID').val();
  457. //const key = {brandId:fn_make_user_info.get('brandId'), storeId: selectVal, viewCd: 'R'};
  458. //var param = $.param(key);
  459. //modifyObj.load(param);
  460. },
  461. cancel: function() {
  462. $('body').trigger('click');
  463. document.getElementById('ITP_FORM_COLLMNG02010_DETAIL').reset();
  464. listObj.grid.search();
  465. },
  466. recal: function() {
  467. var ids = $(COLLMNG02010_DETAIL_GRID_ID).getDataIDs();
  468. $.each(ids, function(idx, rowId) {
  469. var unitAmt = jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  470. var colQty = jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'colQty');
  471. if(unitAmt != null && unitAmt != '' && colQty != null && colQty != '') {
  472. jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{colAmt: parseInt(unitAmt)*parseInt(colQty)});
  473. }
  474. });
  475. const rowData = $(COLLMNG02010_DETAIL_GRID_ID).getRowData();
  476. var colAmt = 0 ;
  477. $.each(rowData, function(key, value) {
  478. if (value.colAmt != null && value.colAmt != "" ) {
  479. colAmt = colAmt + parseInt(value.colAmt) ;
  480. }
  481. });
  482. $('#ITP_FORM_COLLMNG02010_DETAIL .fnColAmt').text(itp_fn_number_comma(colAmt));
  483. },
  484. save: function() {
  485. $('body').trigger('click');
  486. const formId = ('#ITP_FORM_COLLMNG02010_DETAIL');
  487. itp_fn_form_clear_validate(null, formId);
  488. if (itp_fn_form_event.isValid(formId)) {
  489. var modalFn = {
  490. callBack: () => {
  491. itp_fn_form_event.removeChar('#ITP_FORM_COLLMNG02010_DETAIL');
  492. var chkQtyYn = "N";
  493. let gridInsertData = [];
  494. const rowData = $(COLLMNG02010_DETAIL_GRID_ID).getRowData();
  495. $.each(rowData, function(key, value) {
  496. if (value.coltQty == '' || value.coltQty < 1 ) {
  497. alert("수거수량을 입력해주세요!");
  498. chkQtyYn = "Y";
  499. return false;
  500. }
  501. if (value.rtnOdrQty > value.coltQty ) {
  502. alert("수거수량이 반품발주수량보다 클수 없습니다!");
  503. chkQtyYn = "Y";
  504. return false;
  505. }
  506. gridInsertData.push(value);
  507. });
  508. if (chkQtyYn == "Y") return;
  509. let param = $(formId).serializeObject();
  510. param.viewCd = "C";
  511. param.gridInsertData = gridInsertData;
  512. var searhFn = function () {
  513. //ITP_FORM_COLLMNG02010_DETAIL_IS_WRITING = false;
  514. pageObj.grid.clearData();
  515. modifyObj.button.cancel();
  516. }
  517. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  518. }
  519. };
  520. itp_fn_modal_confirm('수거서 생성 하시겠습니까?', modalFn);
  521. }
  522. }
  523. },
  524. load: function(param) {
  525. fn_ajax_call(API_DETAIL_INIT_INFO, param, this.callback, 'GET');
  526. },
  527. callback: function(result) {
  528. pageObj.switchScreen('DETAIL');
  529. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  530. $('#ITP_FORM_COLLMNG02010_DETAIL .fnBrandNm').text(result.brandNm); // 브랜드
  531. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_BRAND_ID').val(result.brandId); //
  532. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_COL_SCH_DT').val(result.colReqDt); //
  533. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId); //
  534. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_RTN_lOCATION').val(result.rtnLocation); //
  535. $('#ITP_FORM_COLLMNG02010_DETAIL .fnColAmt').text(result.rtnDodrTotalAmt); //
  536. $('#ITP_FORM_COLLMNG02010_DETAIL .fnRtnWhsNm').text(result.rtnWhsNm); //
  537. $('#ITP_FORM_COLLMNG02010_DETAIL .fnPickTelNo').text(result.pickTelNo); //
  538. $('#ITP_FORM_COLLMNG02010_DETAIL .fnRtnPodrUnqNo').text(result.rtnPodrUnqNo); //
  539. pageObj.grid.init( result.pickRtnDtlInfo);
  540. },
  541. };