ITP_MRTNMNG06010.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. require(['config'], function() {
  2. require([
  3. ], function($) {
  4. mobPageObj.init();
  5. });
  6. });
  7. /*API URL*/
  8. const API_MOBILE_GRID_LIST = 'api/rtnmng/inoutmng/retstock-result-grid-list'; // 목록
  9. const API_MOBILE_INFO = '/api/rtnmng/po/info-pchOdr'; // 상세
  10. const API_POP_SEARCH_LIST = '/api/whs/mng/pop-whs-search';
  11. const API_POP_SPPLY_LIST = '/api/spply/pop-grid-list';
  12. const PAGE_MODE_LIST = "LIST";
  13. const PAGE_MODE_VIEW = "VIEW";
  14. let mobPageObj = {
  15. viewMode: PAGE_MODE_LIST,
  16. init: function () {
  17. this.ui.init();
  18. this.event.init();
  19. this.ready();
  20. },
  21. ui: {
  22. init: function () {
  23. this.view();
  24. this.info();
  25. },
  26. view: function() {
  27. // 공통코드 표시
  28. $('select').each(function() {
  29. if($(this).data('select-code')) {
  30. fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
  31. }
  32. });
  33. // 조회일자 지정
  34. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH_FROM_DT').val(itp_fn_date_add('M', -1));
  35. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH_TO_DT').val(itp_fn_date_add('M', 0));
  36. },
  37. info: function() {
  38. $('input:hidden[id$="_BRAND_ID"]').val(fn_make_user_info.get('brandId'));
  39. $('input:hidden[id$="_STORE_ID"]').val(fn_make_user_info.get('storeId'));
  40. }
  41. },
  42. event: {
  43. init: function() {
  44. this.button();
  45. },
  46. button: function() {
  47. $('button[id^="ITP_BTN_MRTNMNG06010_LIST"]').on('click', function() {
  48. var id = $(this).attr('id');
  49. switch (id) {
  50. case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH_WHS_NM' : mobPopObj.popWhsNm.init('WHS'); break;
  51. case 'ITP_BTN_MRTNMNG06010_LIST_DELETE_WHS_NM' : mobPopObj.popWhsNm.delete('WHS'); break;
  52. case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM' : mobPopObj.popWhsNm.init('RTN_WHS'); break;
  53. case 'ITP_BTN_MRTNMNG06010_LIST_DELETE_RTN_WHS_NM' : mobPopObj.popWhsNm.delete('RTN_WHS'); break;
  54. case 'ITP_BTN_MRTNMNG06010_LIST_SEARCH' : mobContentObj.list.search(); break;
  55. }
  56. return false;
  57. });
  58. $(document).on('click', '#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWS li', function() {
  59. var item = mobContentObj.list.rows[$(this).index()];
  60. mobContentObj.view.init(item);
  61. });
  62. $(document).on('click', '#ITP_POP_MRTNMNG06010_LIST_SPPLY_ROWS li button', function() {
  63. mobPopObj.popSpply.choice($(this));
  64. });
  65. $(document).on('click', '#ITP_LIST_MRTNMNG06010_POP_WHS_ROWS li button', function() {
  66. mobPopObj.popWhsNm.choice($(this));
  67. });
  68. }
  69. },
  70. switchScreen: function(mode) {
  71. $('#ITP_MOBILE_MRTNMNG06010').find('div[id$="_CONTAINER"]').each(function(i) {
  72. $(this).hide();
  73. });
  74. if(mode === PAGE_MODE_LIST) {
  75. $('#ITP_AJAX_MRTNMNG06010_LIST_CONTAINER').show();
  76. this.moreView(true);
  77. }
  78. this.viewMode = mode;
  79. },
  80. moreView: function(isScroll) {
  81. var _this = this;
  82. if(isScroll) {
  83. $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA').on('scroll', function () {
  84. if($(this).scrollTop() + $(this).innerHeight() + 1 >= $(this)[0].scrollHeight) {
  85. if(mobContentObj.list.totPage > mobContentObj.list.listPage) {
  86. if(!mobContentObj.list.isSearch) {
  87. mobContentObj.list.load();
  88. }
  89. }
  90. }
  91. });
  92. } else {
  93. $('#ITP_LIST_MRTNMNG06010_LIST_AREA').off('scroll');
  94. }
  95. },
  96. ready: function() {
  97. mobContentObj.list.init();
  98. }
  99. };
  100. let mobContentObj = {
  101. list: {
  102. listSize: 10,
  103. listPage: 0,
  104. totPage: 0,
  105. isSearch: false,
  106. rows: [],
  107. init: function() {
  108. mobPageObj.switchScreen(PAGE_MODE_LIST);
  109. // this.search();
  110. },
  111. search: function() {
  112. if($('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val().length < 1) {
  113. alert('수거창고를 지정해주세요!');
  114. return;
  115. }
  116. var formId = '#ITP_FORM_MRTNMNG05010_LIST_SEARCH';
  117. itp_fn_form_clear_validate(null, formId);
  118. if (itp_fn_form_event.isValid(formId)) {
  119. this.listPage = 0;
  120. this.totPage = 0;
  121. this.rows.length = 0;
  122. $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWS').empty();
  123. this.load();
  124. }
  125. },
  126. load: function() {
  127. var _this = this;
  128. this.isSearch = true;
  129. var callbackFn = function(result) {
  130. console.log(result);
  131. _this.isSearch = false;
  132. _this.totPage = result.gridTotal;
  133. $.each(result.gridRows, function (i, item) {
  134. $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA .panel-group').append($('#ITP_LIST_MRTNMNG06010_LIST_ITEM_ROWCOPY').html());
  135. var $li = $('#ITP_LIST_MRTNMNG06010_LIST_ITEM_AREA .panel-group > .list-row:last');
  136. $li.find('.fnPchPodrUnqNo').text(item.pchPodrUnqNo);
  137. $li.find('.fnDlvCmpltDt').text(item.dlvCmpltDt);
  138. $li.find('.fnDlvSchDt').text(item.dlvSchDt);
  139. $li.find('.fnSpplyNm').text(item.spplyNm);
  140. $li.find('.fnWhsNm').text(item.whsNm);
  141. $li.find('.fnItemNm').text(item.itemNm);
  142. $li.find('.fnPodrQty').text(CommonObj.comma.set(item.podrQty));
  143. $li.find('.fnDlvQty').text(CommonObj.comma.set(item.dlvQty));
  144. _this.rows.push(item);
  145. });
  146. };
  147. var errFn = function() { _this.isSearch = false;};
  148. const param = $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH').serializeObject();
  149. param.gridPage = ++this.listPage;
  150. param.gridSize = this.listSize;
  151. param.fromDt = CommonObj.onlyNumber(param.fromDt);
  152. param.toDt = CommonObj.onlyNumber(param.toDt);
  153. console.log(JSON.stringify(param));
  154. fn_ajax_call(API_MOBILE_GRID_LIST, JSON.stringify(param), callbackFn, 'POST', errFn);
  155. }
  156. }
  157. };
  158. let mobPopObj = {
  159. popSpply: {
  160. popId: 'ITP_POP_MRTNMNG06010_SPPLY_AREA',
  161. rows: [],
  162. init: function() {
  163. this.rows.length = 0;
  164. mobPopObj.show(this.popId);
  165. this.search();
  166. this.action();
  167. },
  168. search: function() {
  169. var _this = this;
  170. $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').empty();
  171. var callbackFn = function(result) {
  172. console.log(result);
  173. _this.view(result.gridRows);
  174. };
  175. let param = $('#ITP_FORM_MRTNMNG06010_POP_SPPLY_SEARCH').serializeObject();
  176. fn_ajax_call(API_POP_SPPLY_LIST, JSON.stringify(param), callbackFn, 'POST');
  177. },
  178. view: function(gridRows) {
  179. this.rows = gridRows;
  180. $.each(gridRows, function (i, item) {
  181. $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').append($('#ITP_POP_MRTNMNG06010_LIST_SPPLY_ROWCOPY').html());
  182. var $li = $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group > .list-row:last');
  183. $li.find('.fnSpplyNm').text(item.spplyNm);
  184. $li.find('.fnStNm').text($li.find('.fnStNm').text().replace('$', item.stNm));
  185. $li.find('.fnSpplyId').data('item-key', item.spplyId);
  186. });
  187. },
  188. choice: function(elem) {
  189. var _this = this;
  190. var spplyId = $(elem).data('item-key');
  191. $.each(this.rows, function (i, item) {
  192. if(spplyId === item.spplyId) {
  193. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_ID').val(item.spplyId);
  194. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_NM').val(item.spplyNm);
  195. _this.close();
  196. return false;
  197. }
  198. });
  199. },
  200. action: function() {
  201. var _this = this;
  202. $('button[id^="ITP_BTN_MRTNMNG06010_POP_SPPLY"]').off('click').on('click', function() {
  203. var id = $(this).attr('id');
  204. switch (id) {
  205. case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_SEARCH' : _this.search(); break;
  206. case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_CHOICE' : _this.choice($(this)); break;
  207. case 'ITP_BTN_MRTNMNG06010_POP_SPPLY_CLOSE' : _this.close(); break;
  208. }
  209. return false;
  210. });
  211. },
  212. delete: function() {
  213. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_ID').val('');
  214. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_SPPLY_NM').val('');
  215. },
  216. close: function() {
  217. this.rows.length = 0;
  218. $('#ITP_POP_MRTNMNG06010_LIST_SPPLY_AREA .panel-group').empty();
  219. $('#ITP_FORM_MRTNMNG06010_POP_SPPLY_SEARCH #ITP_FORM_MRTNMNG06010_POP_SPPLY_KEYWORD').val('');
  220. mobPopObj.hide(this.popId);
  221. }
  222. },
  223. popWhsNm: {
  224. popId: 'ITP_POP_MRTNMNG06010_WHS_AREA',
  225. rows: [],
  226. init: function (mode) {
  227. this.popMode = mode;
  228. this.rows.length = 0;
  229. mobPopObj.show(this.popId);
  230. this.search();
  231. this.action();
  232. },
  233. search: function () {
  234. var _this = this;
  235. $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group').empty();
  236. var callbackFn = function(result) {
  237. console.log(result);
  238. _this.view(result.gridRows);
  239. };
  240. const param = $('#ITP_FORM_MRTNMNG06010_POP_WHS').serializeObject();
  241. fn_ajax_call(API_POP_SEARCH_LIST, JSON.stringify(param), callbackFn, 'POST');
  242. },
  243. view: function(gridRows) {
  244. this.rows = gridRows;
  245. $.each(gridRows, function (i, item) {
  246. $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group').append($('#ITP_LIST_MRTNMNG06010_POP_WHS_ROWCOPY').html());
  247. var $li = $('#ITP_LIST_MRTNMNG06010_POP_WHS_AREA .panel-group > .list-row:last');
  248. $li.find('.fnWhsNm').text(item.whsNm);
  249. $li.find('.fnLocationNm').text(item.locationNm);
  250. $li.find('.fnWhsId').data('whs-id', item.whsId);
  251. });
  252. },
  253. choice: function(elem) {
  254. var _this = this;
  255. var whsId = $(elem).data('whs-id');
  256. $.each(this.rows, function (i, item) {
  257. if(whsId === item.whsId) {
  258. if(_this.popMode === 'RTN_WHS') {
  259. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_ID').val(item.whsId);
  260. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val(item.whsNm);
  261. } else {
  262. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_ID').val(item.whsId);
  263. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_NM').val(item.whsNm);
  264. }
  265. _this.close();
  266. return false;
  267. }
  268. });
  269. },
  270. action: function() {
  271. var _this = this;
  272. $('button[id^="ITP_BTN_MRTNMNG06010_POP_WHS"]').off('click').on('click', function() {
  273. var id = $(this).attr('id');
  274. switch (id) {
  275. case 'ITP_BTN_MRTNMNG06010_POP_WHS_SEARCH' : _this.search(); break;
  276. case 'ITP_BTN_MRTNMNG06010_POP_WHS_CHOICE' : _this.choice($(this)); break;
  277. case 'ITP_BTN_MRTNMNG06010_POP_WHS_CLOSE' : _this.close(); break;
  278. }
  279. return false;
  280. });
  281. },
  282. delete: function() {
  283. if(this.popMode === 'RTN_WHS') {
  284. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_ID').val('');
  285. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_RTN_WHS_NM').val('');
  286. } else {
  287. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_ID').val('');
  288. $('#ITP_FORM_MRTNMNG06010_LIST_SEARCH #ITP_FORM_MRTNMNG06010_LIST_SEARCH_WHS_NM').val('');
  289. }
  290. },
  291. close: function() {
  292. this.rows.length = 0;
  293. $('#ITP_POP_MRTNMNG06010_LIST_WHS_AREA .panel-group').empty();
  294. $('#ITP_FORM_MRTNMNG06010_POP_WHS #ITP_FORM_MRTNMNG06010_POP_WHS_KEYWORD').val('');
  295. mobPopObj.hide(this.popId);
  296. }
  297. },
  298. show: function(popId) {
  299. $('button[id$="_CLOSE"]').off('click').on('click', function() {
  300. console.log($(this).attr('id'));
  301. if($(this).hasClass('btn-pop-close')) {
  302. mobPopObj.hide(popId);
  303. }
  304. });
  305. $('#' + popId).show();
  306. },
  307. hide: function(popId) {
  308. $('#' + popId).closest('.mobile-pop-close').hide();
  309. }
  310. };