main.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. require(['config'], function() {
  2. require([
  3. 'jquery'
  4. ], function($) {
  5. setTimeout(function() {
  6. // mobMainObj.init();
  7. }, 100);
  8. });
  9. });
  10. let MOBILE_APP_VERSION = '';
  11. let NTICE_DETAIL_GRID_LIST = '/api/ntice/main-detail-grid-list';
  12. let MAIN_CHART_COUNT = '/api/main/chart/count';
  13. let MAIN_CHART_PCH_REQ_CHART = '/api/main/chart/pch-req-chart';
  14. let MAIN_CHART_PCH_ODR_CHART = '/api/main/chart/pch-odr-chart';
  15. let MAIN_CHART_PR_RANK_CHART = '/api/main/chart/pr-rank-chart';
  16. let MAIN_CHART_STL_CHART = '/api/main/chart/stl-chart';
  17. let MAIN_CHART_SFT_STCK_CHART = '/api/main/chart/sft-stck-chart';
  18. let MAIN_CHART_DELI_CHART = '/api/main/chart/deli-chart';
  19. var chartCnt=0;
  20. var chartWidth=window.offsetWidth-16;
  21. function clickNotify(nticeNo) {
  22. mobPopObj.popNotice.open(nticeNo);
  23. }
  24. var mobMainObj = {
  25. init: function () {
  26. this.ui();
  27. this.action();
  28. this.notice.init();
  29. // this.count.init();
  30. // this.chart.init();
  31. },
  32. ui: function() {
  33. var authTpCd = fn_make_user_info.get('authTpCd');
  34. if(authTpCd === '40' ) {
  35. $('#ITP_BRAND_ICON_BAR').show();
  36. if(fn_make_user_info.get('authTpCd') === '40') {
  37. if(fn_make_user_info.get('shmtColProcType') === '10') {
  38. $('#ITP_BRAND_ICON_BAR .itp_icon_bar').each(function(i) {
  39. if(i < 2) {
  40. $(this).find('.md').remove();
  41. $(this).find('.itp_icon').addClass('w50');
  42. }
  43. });
  44. }
  45. }
  46. } else if(authTpCd === '50') {
  47. $('#ITP_STR_ICON_BAR').show();
  48. } else if(authTpCd === '60') {
  49. $('#ITP_SPY_ICON_BAR').show();
  50. }
  51. },
  52. action: function() {
  53. var _this = this;
  54. var getURL = function(id) {
  55. var rtnURL = '';
  56. $.each(AUTH_MENU_LIST, function(key, value) {
  57. if(value.menuId === id) {
  58. rtnURL = value.connUrl;
  59. return false;
  60. }
  61. });
  62. return rtnURL;
  63. };
  64. $('#ITP_MAIN_CONTAINER button').on('click', function() {
  65. const id = $(this).data('menu-id');
  66. const connURL = getURL(id);
  67. if(connURL !== '') {
  68. const href = MOBILE_CONTEXTPATH + connURL;
  69. fn_make_slide_menu.loadPage(id, href);
  70. }
  71. });
  72. },
  73. notice: {
  74. init: function () {
  75. this.load();
  76. },
  77. load: function () {
  78. var searhFn = function(result) {
  79. if(Array.isArray(result.gridRows) && result.gridRows.length ) {
  80. var s='', idx=1;
  81. for(var c of result.gridRows ) {
  82. let title=c.nticeTitl;
  83. if(title.length>62) {
  84. title=title.substr(0,62)+'...';
  85. }
  86. s+=`<li>
  87. <div class="itp_note_info">
  88. <div class="under fnNoteTitle"><a href="javascript:clickNotify('${c.nticeNo}')">${title}</a></div>
  89. <div style="width:75px;" class="fnNoteDt">${c.addDt}</div>
  90. </div>
  91. </li>`;
  92. }
  93. $('#ITP_NOTE_ROW').html(s);
  94. } else {
  95. $('#ITP_NOTE_ROW').html('<div class="itp_note_bar" style="display: block;"> <h1>등록된 게시물이 없습니다.</h1> </div>')
  96. }
  97. };
  98. fn_ajax_call(NTICE_DETAIL_GRID_LIST, "{}", searhFn, 'POST');
  99. }
  100. },
  101. count: {
  102. init: function () {
  103. this.load();
  104. },
  105. load: function () {
  106. var brandId = fn_make_user_info.get('brandId');
  107. var storeId = fn_make_user_info.get('storeId');
  108. var spplyId = fn_make_user_info.get('spplyId');
  109. if(brandId == '' && storeId == '' && spplyId == '') {
  110. return;
  111. }
  112. const key = { brandId:brandId, storeId:storeId, spplyId:spplyId };
  113. var param = $.param(key);
  114. fn_ajax_call(MAIN_CHART_COUNT, param, function(result) {
  115. console.log(result);
  116. $('#ITP_MAIN_CONTAINER .fnPr20Count').text( CommonObj.currency.add( result.pr20Count, '건' ));
  117. $('#ITP_MAIN_CONTAINER .fnDp02Amt').text( CommonObj.currency.add( result.dp02Amt ));
  118. $('#ITP_MAIN_CONTAINER .fnUnpaidAmt').text( CommonObj.currency.add( result.unpaidAmt ));
  119. $('#ITP_MAIN_CONTAINER .fnPo30Count').text( CommonObj.currency.add( result.po30Count, '건' ));
  120. $('#ITP_MAIN_CONTAINER .fnPoEndCount').text( CommonObj.currency.add( result.poEndCount, '건' ));
  121. $('#ITP_MAIN_CONTAINER .fnPoPsblAmt').text( CommonObj.currency.add( result.poPsblAmt ));
  122. $('#ITP_MAIN_CONTAINER .fnOrdersCount').text( CommonObj.currency.add( result.ordersCount, '건' ) );
  123. $('#ITP_MAIN_CONTAINER .fnOrdersAmt').text( CommonObj.currency.add( result.ordersAmt ));
  124. $('#ITP_MAIN_CONTAINER .fnSttlReqAmt').text( CommonObj.currency.add( result.sttlReqAmt ));
  125. }, 'GET');
  126. }
  127. },
  128. chart: {
  129. init: function () {
  130. //그래프
  131. google.charts.load('current', {'packages':['corechart']});
  132. google.charts.load('current', {'packages':['bar']});
  133. this.view();
  134. },
  135. view:function() {
  136. $('div[id^="ITP_MAIN_DRAW"]').hide();
  137. var authTpCd = fn_make_user_info.get('authTpCd');
  138. console.log("chart init authTpCd=="+authTpCd)
  139. if(authTpCd === '40' ) {
  140. this.brand.init();
  141. } else if(authTpCd === '50') {
  142. this.store.init();
  143. } else if(authTpCd === '60') {
  144. this.spply.init();
  145. }
  146. const me=this;
  147. $('#ITP_FORM_MAIN_SEARCH_PR_TYPE').on('change', function() {
  148. me.drawChartReq();
  149. });
  150. $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').on('change', function() {
  151. me.drawChartPodr();
  152. });
  153. $('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').on('change', function() {
  154. me.drawChartReqUp();
  155. });
  156. $('#ITP_FORM_MAIN_SEARCH_DELI_TYPE').on('change', function() {
  157. me.drawChartDeli();
  158. });
  159. $('#ITP_FORM_MAIN_SEARCH_RELEASE_TYPE').on('change', function() {
  160. me.drawChartRelease();
  161. });
  162. $('#ITP_FORM_MAIN_SEARCH_ORDERS_TYPE').on('change', function() {
  163. me.drawChartOrders();
  164. });
  165. },
  166. store: {
  167. init: function() {
  168. const chart=mobMainObj.chart;
  169. $('#ITP_MAIN_HEADER_STORE').show();
  170. $('#ITP_MAIN_DRAW_CHART_REQ').show();
  171. google.charts.setOnLoadCallback(chart.drawChartReq); // 구매요청
  172. $('#ITP_MAIN_DRAW_DELI_CHART').show();
  173. google.charts.setOnLoadCallback(chart.drawChartDeli); // 입고
  174. $('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
  175. $('#ITP_MAIN_DRAW_CHART_REQ_UP .itp_graph_header > label').html("요청순위");
  176. google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
  177. $('#ITP_MAIN_DRAW_CHART_CORE').show();
  178. google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
  179. chartCnt=4;
  180. }
  181. },
  182. spply: {
  183. init: function() {
  184. const chart=mobMainObj.chart;
  185. $('#ITP_MAIN_HEADER_SPPLY').show();
  186. $('#ITP_MAIN_DRAW_ORDERS_CHART').show();
  187. google.charts.setOnLoadCallback(chart.drawChartOrders); // 수주내역
  188. $('#ITP_MAIN_DRAW_RELEASE_CHART').show();
  189. google.charts.setOnLoadCallback(chart.drawChartRelease); // 출고
  190. $('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
  191. $('#ITP_MAIN_DRAW_CHART_REQ_UP .itp_graph_header > label').html("수주순위");
  192. google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
  193. $('#ITP_MAIN_DRAW_CHART_CORE').show();
  194. google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
  195. chartCnt=4;
  196. }
  197. },
  198. brand: {
  199. init: function() {
  200. const chart=mobMainObj.chart;
  201. $('#ITP_MAIN_DRAW_CHART_REQ').show();
  202. google.charts.setOnLoadCallback(chart.drawChartReq); // 구매요청
  203. $('#ITP_MAIN_DRAW_CHART_PODR').show();
  204. google.charts.setOnLoadCallback(chart.drawChartPodr); // 구매발주
  205. $('#ITP_MAIN_DRAW_CHART_REQ_UP').show();
  206. $('#ITP_MAIN_DRAW_CHART_REQ_UP .itp_graph_header > label').html("요청순위");
  207. google.charts.setOnLoadCallback(chart.drawChartReqUp); // 매출순위
  208. if(fn_make_user_info.get('brandId')) {
  209. $('#ITP_MAIN_DRAW_CHART_CORE').show();
  210. google.charts.setOnLoadCallback(chart.drawChartcore); // 정산
  211. }
  212. $('#ITP_MAIN_DRAW_LINE').show();
  213. $('#ITP_MAIN_DRAW_LINE .itp_main_draw_line').show();
  214. google.charts.setOnLoadCallback(chart.drawLine); // 안전재고
  215. },
  216. },
  217. drawChartReq: function() {
  218. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), prType: $('#ITP_FORM_MAIN_SEARCH_PR_TYPE').val() };
  219. var param = $.param(key);
  220. fn_ajax_call(MAIN_CHART_PCH_REQ_CHART, param, function(result) {
  221. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  222. var options = {
  223. legend: { position: 'left' },
  224. bar: { groupWidth: "50%" },
  225. width: chartWidth,
  226. };
  227. const el=document.getElementById('ITP_PCH_REQ_GRAPH');
  228. $(el).css('margin-top','16px');
  229. var chart = new google.charts.Bar(el);
  230. // chart.draw(data, options);
  231. console.log("xx draw char req xx", param, data, chart)
  232. chart.draw(data, google.charts.Bar.convertOptions(options));
  233. }, 'GET');
  234. },
  235. drawChartPodr: function() {
  236. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), poType: $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').val() };
  237. var param = $.param(key);
  238. fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
  239. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  240. var options = {
  241. legend: { position: 'left' },
  242. bar: { groupWidth: "50%" },
  243. width: chartWidth,
  244. };
  245. const el=document.getElementById('ITP_PCH_PODR_GRAPH');
  246. $(el).css('margin-top','16px');
  247. var chart = new google.charts.Bar(el);
  248. // chart.draw(data, options);
  249. chart.draw(data, google.charts.Bar.convertOptions(options));
  250. }, 'GET');
  251. },
  252. drawChartReqUp: function() {
  253. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId'), prType: $('#ITP_FORM_MAIN_SEARCH_ITEM_CNT_TYPE').val() };
  254. var param = $.param(key);
  255. fn_ajax_call(MAIN_CHART_PR_RANK_CHART, param, function(result) {
  256. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  257. var options = {
  258. title: '구매요청 상위 품목',
  259. legend: { position: 'left' },
  260. bars: 'horizontal',
  261. width: chartWidth,
  262. };
  263. const el=document.getElementById('ITP_PCH_REQ_UP_ITEM_GRAPH');
  264. $(el).css('margin-top','40px');
  265. var chart = new google.charts.Bar(el);
  266. chart.draw(data, options);
  267. }, 'GET');
  268. },
  269. drawChartcore: function() {
  270. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), spplyId:fn_make_user_info.get('spplyId') };
  271. var param = $.param(key);
  272. fn_ajax_call(MAIN_CHART_STL_CHART, param, function(result) {
  273. // var data = google.visualization.arrayToDataTable([ [' ', ' '], ['요청', 25], ['확인', 65], ['반려', 10] ]);
  274. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  275. var options = {
  276. title: '',
  277. legend: { position: 'left' },
  278. width: chartWidth,
  279. };
  280. const el=document.getElementById('ITP_STTL_GRAPH');
  281. var chart = new google.visualization.PieChart(el);
  282. $(el).css('margin-top','40px');
  283. chart.draw(data, options);
  284. }, 'GET');
  285. },
  286. drawLine: function() {
  287. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId') };
  288. var param = $.param(key);
  289. fn_ajax_call(MAIN_CHART_SFT_STCK_CHART, param, function(result) {
  290. var list=[], idx=0, res=eval(result.chartData);
  291. for(var c of res) {
  292. if(idx>5) break;
  293. list.push(res[idx++]);
  294. }
  295. var data = google.visualization.arrayToDataTable( list );
  296. var options = {
  297. title: '',
  298. pointSize: 4,
  299. width: chartWidth + 100,
  300. legend: { position: 'top' }
  301. };
  302. const el=document.getElementById('ITP_SAFE_STCK_GRAPH');
  303. $(el).css('margin-top','40px');
  304. var chart = new google.visualization.LineChart(el);
  305. chart.draw(data, options);
  306. }, 'GET');
  307. },
  308. //수주내역 그래프
  309. drawChartOrders() {
  310. const key = { brandId:fn_make_user_info.get('brandId'),
  311. spplyId:fn_make_user_info.get('spplyId'),
  312. poType: $('#ITP_FORM_MAIN_SEARCH_ORDERS_TYPE').val() };
  313. var param = $.param(key);
  314. fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
  315. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  316. var options = {
  317. legend: { position: 'left' },
  318. width: chartWidth,
  319. };
  320. const el=document.getElementById('ITP_ORDERS_GRAPH');
  321. $(el).css('margin-top','16px');
  322. var chart = new google.charts.Bar(el);
  323. chart.draw(data, options);
  324. }, 'GET');
  325. },
  326. //입고 그래프
  327. drawChartDeli() {
  328. const key = { brandId:fn_make_user_info.get('brandId'),
  329. storeId:fn_make_user_info.get('storeId'),
  330. deliType: $('#ITP_FORM_MAIN_SEARCH_DELI_TYPE').val() };
  331. var param = $.param(key);
  332. fn_ajax_call(MAIN_CHART_DELI_CHART, param, function(result) {
  333. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  334. var options = {
  335. legend: { position: 'left' },
  336. width: chartWidth,
  337. };
  338. const el=document.getElementById('ITP_DELI_GRAPH');
  339. $(el).css('margin-top','16px');
  340. var chart = new google.charts.Bar(el);
  341. chart.draw(data, options);
  342. }, 'GET');
  343. },
  344. //출고 그래프
  345. drawChartRelease() {
  346. const key = { brandId:fn_make_user_info.get('brandId'),
  347. spplyId:fn_make_user_info.get('spplyId'),
  348. deliType: $('#ITP_FORM_MAIN_SEARCH_RELEASE_TYPE').val() };
  349. var param = $.param(key);
  350. fn_ajax_call(MAIN_CHART_DELI_CHART, param, function(result) {
  351. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  352. var options = {
  353. legend: { position: 'left' },
  354. width: chartWidth,
  355. };
  356. const el=document.getElementById('ITP_RELEASE_GRAPH');
  357. $(el).css('margin-top','16px');
  358. var chart = new google.charts.Bar(el);
  359. chart.draw(data, options);
  360. }, 'GET');
  361. },
  362. //구매발주 그래프
  363. drawChartPodr() {
  364. const key = { brandId:fn_make_user_info.get('brandId'), storeId:fn_make_user_info.get('storeId'), poType: $('#ITP_FORM_MAIN_SEARCH_PO_TYPE').val() };
  365. var param = $.param(key);
  366. fn_ajax_call(MAIN_CHART_PCH_ODR_CHART, param, function(result) {
  367. var data = google.visualization.arrayToDataTable( eval(result.chartData) );
  368. var options = {
  369. legend: { position: 'left' },
  370. bar: { groupWidth: "50%" },
  371. width: chartWidth,
  372. };
  373. const el=document.getElementById('ITP_PCH_PODR_GRAPH');
  374. $(el).css('margin-top','16px');
  375. var chart = new google.charts.Bar(el);
  376. // chart.draw(data, options);
  377. chart.draw(data, google.charts.Bar.convertOptions(options));
  378. }, 'GET');
  379. }
  380. }
  381. };
  382. function appCallFnVersion(version) {
  383. MOBILE_APP_VERSION = version;
  384. console.log(MOBILE_APP_VERSION);
  385. }
  386. let mobPopObj = {
  387. popNotice: {
  388. popId: 'ITP_POP_NOTICE',
  389. open: function (nticeNo) {
  390. mobPopObj.show(this.popId);
  391. this.search(nticeNo);
  392. },
  393. close: function() {
  394. mobPopObj.hide(this.popId);
  395. },
  396. search: function (nticeNo) {
  397. const me=this;
  398. fn_ajax_call('/api/ntice/info-ntice', {nticeNo}, function(result) {
  399. // 브랜드그룹 셋팅
  400. $('#ITP_POP_NOTICE_AREA .fnNoteNm').html(result.nticeTitl);
  401. $('#ITP_POP_NOTICE_AREA .fnNote').html(result.nticeDesc);
  402. $('#ITP_POP_NOTICE_AREA .fnNoteFromTo').html(result.notiStDay+' ~ '+result.notiEdDay);
  403. me.makeFileDownloadTable($('#ITP_POP_NOTICE_AREA .fnNoteFile'),result.fileNo);
  404. /*
  405. $('#ITP_FORM_NOTICE_INFO_POPUP_AFFL_SHOP_NM').html(result.afflShopNm);
  406. $('#ITP_FORM_NOTICE_INFO_POPUP_BRAND_NM').html(result.brandNm);
  407. */
  408. }, 'GET');
  409. },
  410. makeFileDownloadTable: function (el, fileNo) {
  411. var searhFn = function(result) {
  412. var html = '';
  413. html += '<table class="table fileupload-download">';
  414. html += '<tbody>';
  415. $.each(result, function (key, value) {
  416. html += '<tr class="fileupload-downloadrow no-thumb row">';
  417. html += '<td class="col-xs-9 itp_file_info" data-file-no="' + value.fileNo + '" data-file-seq="' + value.fileSeq + '">';
  418. html += '<a href="' + DOMAIN + '/api/file/download/' + value.fileNo + '/' + value.fileSeq + '">';
  419. html += value.fileOrgNm + '</a></td>';
  420. html += '<td class="col-xs-3">' + value.fileSize + '</td>';
  421. html += '</tr>';
  422. });
  423. html += '</tbody>';
  424. html += '</table>';
  425. el.html(html);
  426. }
  427. fn_ajax_call('/api/file/list', {fileNo}, searhFn, 'GET');
  428. }
  429. },
  430. show: function(popId) {
  431. $('#' + popId+' .btn-pop-close').on('click', function() {
  432. mobPopObj.hide(popId);
  433. });
  434. $('#' + popId).show();
  435. },
  436. hide: function(popId) {
  437. $('#' + popId).closest('.mobile-pop-close').hide();
  438. }
  439. };
  440. function appCallFnConnKey(connKey) {
  441. if(connKey) {
  442. sessionStorage.setItem('itp_login_info', JSON.stringify({
  443. timestamp: new Date(),
  444. connKey: connKey
  445. }));
  446. itp_fn_session_data(connKey);
  447. } else {
  448. location.replace('app:logout');
  449. }
  450. }