main.js 16 KB

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