ITP_COLLMNG02010.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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
  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
  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
  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
  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. },
  165. {
  166. index: 'RTN_RSN_DVSN_NM', name: 'rtnRsnDvsnNm',
  167. label: ITP_MSG_LOCALE.label.rtnRsnDvsnNm, //반품사유
  168. width: '10', fixed: false, align: 'center',
  169. sortable: false, hidden: false
  170. },
  171. {
  172. index: 'RTN_RSN_DVSN', name: 'rtnRsnDvsn',
  173. label: ITP_MSG_LOCALE.label.rtnRsnDvsn, //반품사유
  174. width: '10', fixed: false, align: 'center',
  175. sortable: false, hidden: true
  176. },
  177. {
  178. index: 'RTN_RSN', name: 'rtnRsn',
  179. label: ITP_MSG_LOCALE.label.rtnRsn, //비고
  180. width: '10', fixed: false, align: 'center',
  181. sortable: false, hidden: false
  182. },
  183. {
  184. index: 'COL_AMT', name: 'colAmt',
  185. label: ITP_MSG_LOCALE.label.colAmt, //
  186. width: '10', fixed: false, align: 'right',
  187. sortable: false, hidden: false
  188. }
  189. ]
  190. };
  191. /*화면공통 Object*/
  192. let pageObj = {
  193. init: function () {
  194. this.ui.init();
  195. this.event.init();
  196. this.action();
  197. },
  198. ui: {
  199. init: function () {
  200. this.view();
  201. this.grid();
  202. this.ready();
  203. },
  204. view: function() {
  205. // 버튼 권한설정
  206. fn_proc_btn_auth('COLLMNG02010');
  207. // 공통코드 표시
  208. $('select').each(function() {
  209. if($(this).data('select-code')) {
  210. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  211. }
  212. });
  213. // 조회일자 지정
  214. var now = new Date();
  215. $('#ITP_TAB_COLLMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  216. $('#ITP_FORM_COLLMNG02010_SEARCH_FROM_DT').datepicker('setDate', new Date(now.setDate(now.getDate())));
  217. $('#ITP_FORM_COLLMNG02010_SEARCH_TO_DT').datepicker('setDate', new Date(now.setDate(now.getDate() + 30)));
  218. $('#ITP_FORM_COLLMNG02010_SEARCH #ITP_FORM_COLLMNG02010_SEARCH_SSPPLY_ID').val(fn_make_user_info.get('spplyId'));
  219. },
  220. grid: function() {
  221. itp_fn_jqgrid_resize(COLLMNG02010_GRID_ID, COLLMNG02010_GRID_LIST, 'lg');
  222. itp_fn_fire_window_resize();
  223. },
  224. ready: function() {
  225. listObj.init();
  226. }
  227. },
  228. action: function () {
  229. var _this = this;
  230. // 수거창고 조회 버튼 클릭
  231. $('#ITP_BTN_COLLMNG02010_SEARCH_RTN_WHS_ID').on('click', function() {
  232. _this.popup();
  233. });
  234. // 출하창고 텍스트 삭제 버튼 클릭
  235. $('#ITP_BTN_COLLMNG02010_DELETE_RTN_WHS_ID').on('click', function() {
  236. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_NM').val('');
  237. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_ID').val('');
  238. });
  239. },
  240. popup: function (arg) {
  241. var popFn = this.callback.rtnwhs;
  242. var whsDvsn = "";
  243. const key = { brandId: fn_make_user_info.get('brandId'), storeId: fn_make_user_info.get('storeId'), whsDvsn: whsDvsn };
  244. fn_call_popup('biz', 'BIZPOP_WHS_LOCATION', '#ITP_ASIDE', popFn, key, 'S');
  245. },
  246. callback: {
  247. rtnwhs: function(rowDataPop) {
  248. if (rowDataPop) {
  249. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_NM').val(rowDataPop.whsNm);
  250. $('#ITP_FORM_COLLMNG02010_SEARCH_SRTN_WHS_ID').val(rowDataPop.whsId);
  251. }
  252. }
  253. },
  254. event: {
  255. init: function () {
  256. this.button();
  257. },
  258. button: function () {
  259. // 버튼 클릭 이벤트
  260. $('button').each(function() {
  261. var id = $(this).attr('id');
  262. $(this).on('click', function() {
  263. switch (id) {
  264. case 'ITP_BTN_COLLMNG02010_SRH' : listObj.button.search(); break;
  265. case 'ITP_BTN_COLLMNG02010_CUDW' : listObj.button.colcreat(); break; // 수거서생성
  266. case 'ITP_BTN_COLLMNG02010_CRT' : modifyObj.button.save() ; break; // 생성
  267. case 'ITP_BTN_COLLMNG02010_CANCELLIST' : modifyObj.button.cancel(); break;
  268. }
  269. });
  270. });
  271. $('body').on('click', function(e) {
  272. var gridId = (COLLMNG02010_DETAIL_GRID_ID).replace('#', '');
  273. var rids = $(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getDataIDs');
  274. var last_row_id = rids[rids.length - 1];
  275. itp_fn_grid_reset_selection(e, last_row_id, gridId, 'COLLMNG02010_DETAIL');
  276. modifyObj.button.recal();
  277. });
  278. }
  279. },
  280. switchScreen: function(mode) {
  281. $('.itp_det_head').find('button[id^="ITP_BTN_COLLMNG02010_"]').each(function(i) {
  282. $(this).hide();
  283. });
  284. $('#ITP_TAB_COLLMNG02010').find('div[id$="_CONTAINER"]').each(function(i) {
  285. $(this).hide();
  286. });
  287. if(mode == 'LIST') { // 목록
  288. $('#ITP_AJAX_COLLMNG02010_LIST_CONTAINER').show();
  289. $('#ITP_BTN_COLLMNG02010_DELETE_RTN_WHS_ID').show();
  290. fn_show_btn_auth_array(['#ITP_BTN_COLLMNG02010_SRH', '#ITP_BTN_COLLMNG02010_CUDW']);
  291. $('#ITP_FORM_COLLMNG02010_SEARCH_SBRAND_ID').val(fn_make_user_info.get('brandId'));
  292. $('#ITP_FORM_COLLMNG02010_SEARCH_SSPPLY_ID').val(fn_make_user_info.get('spplyId'));
  293. } else if(mode == 'DETAIL') { // 수거서 작성
  294. $('#ITP_AJAX_COLLMNG02010_DETAIL_CONTAINER').show();
  295. fn_show_btn_auth_array(['#ITP_BTN_COLLMNG02010_CRT', '#ITP_BTN_COLLMNG02010_CANCELLIST']);
  296. $('#ITP_FORM_COLLMNG02010_SEARCH_BRAND_ID').val(fn_make_user_info.get('brandId'));
  297. //pageObj.grid.init(param);
  298. }
  299. },
  300. grid: {
  301. init: function(gridData) {
  302. this.gridId = COLLMNG02010_DETAIL_GRID_ID;
  303. this.gridList = COLLMNG02010_DETAIL_GRID_LIST;
  304. this.gridEmpty = COLLMNG02010_DETAIL_GRID_EMPTY;
  305. //var now = new Date();
  306. //$('#ITP_TAB_COLLMNG02010 .input-group.date').datepicker(ITP_DATE_LANGUAGE);
  307. //$('#ITP_FORM_COLLMNG02010_DETAIL_DLV_SCH_DT').datepicker('setDate', new Date(param.dlvSchDt));
  308. //$('#ITP_FORM_COLLMNG02010_DETAIL .fnBrandNm').text(param.brandNm);
  309. //this.gridRows = param.recordData;
  310. this.unload();
  311. this.load(gridData);
  312. },
  313. gridId: '',
  314. button: {},
  315. gridList: '',
  316. gridEmpty: '',
  317. gridRows: '',
  318. load: function(gridRows) {
  319. var _this = this;
  320. var option = {
  321. gridId: _this.gridId,
  322. colModel: gridColModel.detail,
  323. data: gridRows,
  324. loadComplete: function(data) {
  325. itp_fn_grid_load_complete(data, COLLMNG02010_DETAIL_GRID_ID, true, 'number', 'COLLMNG02010', modifyObj.itp_COLLMNG02010_search, modifyObj.empty, true, data.gridRecords, true);
  326. },
  327. onCellSelect: function(rowid, cellIdx, cellValue) {
  328. COLLMNG02010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowid, cellIdx, COLLMNG02010_GRID_LAST_ROW_ID, _this.gridId, ['rtnReqDtlNo']);
  329. }
  330. };
  331. itp_fn_grid_make_local(option);
  332. },
  333. clearData : function(mode) {
  334. $(COLLMNG02010_DETAIL_GRID_ID).jqGrid('clearGridData', true);
  335. $(COLLMNG02010_DETAIL_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  336. $(COLLMNG02010_DETAIL_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  337. $(COLLMNG02010_DETAIL_GRID_EMPTY).show();
  338. },
  339. unload : function() {
  340. $.jgrid.gridUnload(this.gridId);
  341. }
  342. }
  343. };
  344. /*목록화면 Object*/
  345. let listObj = {
  346. init: function () {
  347. this.grid.init();
  348. },
  349. itp_COLLMNG02010_search: false,
  350. button: {
  351. search: function() {
  352. listObj.itp_COLLMNG02010_search = true;
  353. let param = $('#ITP_FORM_COLLMNG02010_SEARCH').serializeObject();
  354. param.gridSize = $.jgrid.defaults.rowNum;
  355. param.gridPage = $.jgrid.defaults.page;
  356. $(COLLMNG02010_GRID_ID).setGridParam({'postData': JSON.stringify(param)}).trigger('reloadGrid');
  357. },
  358. colcreat: function() {
  359. var selectedIds = $(COLLMNG02010_GRID_ID).getGridParam('selarrrow');
  360. if(selectedIds.length > 1) { // 1이상 선택시
  361. alert("반품발주 한 건만 선택해주세요 (대표 반품발주)") ;//출력
  362. return; //리턴
  363. }
  364. var selRowData ; //변수선언
  365. for (var i=selectedIds.length-1; i>=0;i--) {
  366. selRowData = $(COLLMNG02010_GRID_ID).jqGrid('getRowData', selectedIds[i]); //cell 선택
  367. }
  368. let param = {brandId: selRowData.brandId, rtnPodrUnqNo: selRowData.rtnPodrUnqNo, spplyId: fn_make_user_info.get('spplyId')};
  369. pageObj.switchScreen('DETAIL');
  370. itp_fn_form_clear_validate(null, '#ITP_FORM_COLLMNG02010_DETAIL');
  371. modifyObj.init(param);
  372. }
  373. },
  374. empty: {
  375. init: function() {
  376. },
  377. itp_COLLMNG02010_param: {},
  378. push: function() {
  379. },
  380. back: function() {
  381. }
  382. },
  383. grid: {
  384. init: function () {
  385. // 데이터 없을때
  386. itp_fn_jqgrid_resize(COLLMNG02010_GRID_ID, COLLMNG02010_GRID_LIST, 'lg');
  387. itp_fn_fire_window_resize();
  388. this.search();
  389. },
  390. colModel: gridColModel.list,
  391. search: function() {
  392. pageObj.switchScreen('LIST');
  393. this.unload();
  394. this.load();
  395. },
  396. load: function() {
  397. let param = $('#ITP_FORM_COLLMNG02010_SEARCH').serializeObject();
  398. param.gridSize = $.jgrid.defaults.rowNum;
  399. var option = {
  400. multiselect: true,
  401. autowidth: true,
  402. gridId: COLLMNG02010_GRID_ID,
  403. colModel: gridColModel.list,
  404. param: param,
  405. url: DOMAIN + API_DETAIL_GRID_LIST,
  406. pager: COLLMNG02010_GRID_PAGER,
  407. loadComplete: function(data) {
  408. itp_fn_grid_load_complete(data, COLLMNG02010_GRID_ID, true, 'number', 'COLLMNG02010', listObj.itp_COLLMNG02010_search, listObj.empty, true, data.gridRecords, true);
  409. },
  410. onPaging: function(action) {
  411. itp_fn_grid_paging(COLLMNG02010_GRID_ID, action, param);
  412. }
  413. };
  414. itp_fn_grid_make_remote(option);
  415. },
  416. button: {
  417. },
  418. unload : function() {
  419. $.jgrid.gridUnload(COLLMNG02010_GRID_ID);
  420. },
  421. clearData : function() {
  422. $(COLLMNG02010_GRID_ID).jqGrid('clearGridData', true);
  423. $(COLLMNG02010_GRID_LIST).find('.ui-jqgrid-bdiv').css('min-height', '100px');
  424. $(COLLMNG02010_GRID_EMPTY).html(ITP_MSG_LOCALE.message.grid.noData);
  425. $(COLLMNG02010_GRID_EMPTY).show();
  426. }
  427. }
  428. };
  429. /*수정화면 Object*/
  430. let modifyObj = {
  431. init: function (param) {
  432. this.load(param);
  433. },
  434. button: {
  435. modify: function (param) {
  436. itp_fn_form_clear_validate(null, '#ITP_FORM_COLLMNG02010_DETAIL');
  437. //const selectVal = $('#ITP_FORM_COLLMNG02010_VIEW_STORE_ID').val();
  438. //const key = {brandId:fn_make_user_info.get('brandId'), storeId: selectVal, viewCd: 'R'};
  439. //var param = $.param(key);
  440. //modifyObj.load(param);
  441. },
  442. cancel: function() {
  443. $('body').trigger('click');
  444. document.getElementById('ITP_FORM_COLLMNG02010_DETAIL').reset();
  445. listObj.grid.search();
  446. },
  447. recal: function() {
  448. var ids = $(COLLMNG02010_DETAIL_GRID_ID).getDataIDs();
  449. $.each(ids, function(idx, rowId) {
  450. var unitAmt = jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'unitAmt');
  451. var colQty = jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('getCell', rowId, 'colQty');
  452. if(unitAmt != null && unitAmt != '' && colQty != null && colQty != '') {
  453. jQuery(COLLMNG02010_DETAIL_GRID_ID).jqGrid('setRowData',rowId,{colAmt: parseInt(unitAmt)*parseInt(colQty)});
  454. }
  455. });
  456. const rowData = $(COLLMNG02010_DETAIL_GRID_ID).getRowData();
  457. var colAmt = 0 ;
  458. $.each(rowData, function(key, value) {
  459. if (value.colAmt != null && value.colAmt != "" ) {
  460. colAmt = colAmt + parseInt(value.colAmt) ;
  461. }
  462. });
  463. $('#ITP_FORM_COLLMNG02010_DETAIL .fnColAmt').text(itp_fn_number_comma(colAmt));
  464. },
  465. save: function() {
  466. $('body').trigger('click');
  467. const formId = ('#ITP_FORM_COLLMNG02010_DETAIL');
  468. itp_fn_form_clear_validate(null, formId);
  469. if (itp_fn_form_event.isValid(formId)) {
  470. var modalFn = {
  471. callBack: () => {
  472. itp_fn_form_event.removeChar('#ITP_FORM_COLLMNG02010_DETAIL');
  473. var chkQtyYn = "N";
  474. let gridInsertData = [];
  475. const rowData = $(COLLMNG02010_DETAIL_GRID_ID).getRowData();
  476. $.each(rowData, function(key, value) {
  477. if (value.coltQty == '' || value.coltQty < 1 ) {
  478. alert("수거수량을 입력해주세요!");
  479. chkQtyYn = "Y";
  480. return false;
  481. }
  482. if (value.rtnOdrQty > value.coltQty ) {
  483. alert("수거수량이 반품발주수량보다 클수 없습니다!");
  484. chkQtyYn = "Y";
  485. return false;
  486. }
  487. gridInsertData.push(value);
  488. });
  489. if (chkQtyYn == "Y") return;
  490. let param = $(formId).serializeObject();
  491. param.viewCd = "C";
  492. param.gridInsertData = gridInsertData;
  493. var searhFn = function () {
  494. //ITP_FORM_COLLMNG02010_DETAIL_IS_WRITING = false;
  495. pageObj.grid.clearData();
  496. modifyObj.button.cancel();
  497. }
  498. fn_ajax_call(API_DETAIL_SAVE, JSON.stringify(param), searhFn, 'POST');
  499. }
  500. };
  501. itp_fn_modal_confirm('수거서 생성 하시겠습니까?', modalFn);
  502. }
  503. }
  504. },
  505. load: function(param) {
  506. fn_ajax_call(API_DETAIL_INIT_INFO, param, this.callback, 'GET');
  507. },
  508. callback: function(result) {
  509. pageObj.switchScreen('DETAIL');
  510. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_SPPLY_ID').val(fn_make_user_info.get('spplyId'));
  511. $('#ITP_FORM_COLLMNG02010_DETAIL .fnBrandNm').text(result.brandNm); // 브랜드
  512. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_BRAND_ID').val(result.brandId); //
  513. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_ORDMNG02010_DETAIL_COL_SCH_DT').val(result.colReqDt); //
  514. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_RTN_WHS_ID').val(result.rtnWhsId); //
  515. $('#ITP_FORM_COLLMNG02010_DETAIL #ITP_FORM_COLLMNG02010_DETAIL_RTN_lOCATION').val(result.rtnLocation); //
  516. $('#ITP_FORM_COLLMNG02010_DETAIL .fnColAmt').text(result.rtnDodrTotalAmt); //
  517. $('#ITP_FORM_COLLMNG02010_DETAIL .fnRtnWhsNm').text(result.rtnWhsNm); //
  518. $('#ITP_FORM_COLLMNG02010_DETAIL .fnPickTelNo').text(result.pickTelNo); //
  519. $('#ITP_FORM_COLLMNG02010_DETAIL .fnRtnPodrUnqNo').text(result.rtnPodrUnqNo); //
  520. pageObj.grid.init( result.pickRtnDtlInfo);
  521. },
  522. };