main.js 15 KB

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