accounting.blade.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content container">
  4. <div class="card card-shadow">
  5. <div class="card-block p-30">
  6. <div class="row pb-20">
  7. <div class="col-md-8 col-sm-6">
  8. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.monthly_accounting') }}</div>
  9. </div>
  10. </div>
  11. <canvas id="days"></canvas>
  12. </div>
  13. </div>
  14. <div class="card card-shadow">
  15. <div class="card-block p-30">
  16. <div class="row pb-20">
  17. <div class="col-md-8 col-sm-6">
  18. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.annually_accounting') }}</div>
  19. </div>
  20. </div>
  21. <canvas id="months"></canvas>
  22. </div>
  23. </div>
  24. <div class="card card-shadow">
  25. <div class="card-block p-30">
  26. <div class="row pb-20">
  27. <div class="col-md-8 col-sm-6">
  28. <div class="blue-grey-700 font-size-26 font-weight-500">{{ trans('admin.report.historic_accounting') }}</div>
  29. </div>
  30. </div>
  31. <canvas id="years"></canvas>
  32. </div>
  33. </div>
  34. </div>
  35. @endsection
  36. @section('javascript')
  37. <script src="/assets/global/vendor/chart-js/chart.min.js"></script>
  38. <script type="text/javascript">
  39. function label_callbacks(tail) {
  40. return {
  41. mode: 'index',
  42. intersect: false,
  43. callbacks: {
  44. title: function(context) {
  45. return context[0].label + tail;
  46. },
  47. label: function(context) {
  48. let label = context.dataset.label || '';
  49. if (label) {
  50. label += ': ';
  51. }
  52. if (context.parsed.y !== null) {
  53. label += new Intl.NumberFormat('ch-CN', {
  54. style: 'currency',
  55. currency: '{{sysConfig('standard_currency')}}',
  56. }).format(context.parsed.y);
  57. }
  58. return label;
  59. },
  60. },
  61. };
  62. }
  63. function common_options(label) {
  64. return {
  65. responsive: true,
  66. scales: {
  67. x: {
  68. grid: {
  69. display: false,
  70. },
  71. },
  72. y: {
  73. grid: {
  74. display: false,
  75. },
  76. min: 0,
  77. },
  78. },
  79. plugins: {
  80. legend: {
  81. labels: {
  82. padding: 20,
  83. usePointStyle: true,
  84. pointStyle: 'circle',
  85. font: {size: 14},
  86. },
  87. },
  88. tooltip: label_callbacks(label),
  89. },
  90. };
  91. }
  92. function area_a(label, data) {
  93. return {
  94. label: label,
  95. backgroundColor: 'rgba(184, 215, 255)',
  96. borderColor: 'rgba(184, 215, 255)',
  97. data: data,
  98. fill: {
  99. target: 'origin',
  100. above: 'rgba(184, 215, 255, 0.5)',
  101. },
  102. tension: 0.4,
  103. };
  104. }
  105. function area_b(label, data) {
  106. return {
  107. label: label,
  108. backgroundColor: 'rgba(146, 240, 230)',
  109. borderColor: 'rgba(146, 240, 230)',
  110. data: data,
  111. fill: {
  112. target: 'origin',
  113. above: 'rgba(146, 240, 230, 0.5)',
  114. },
  115. tension: 0.4,
  116. };
  117. }
  118. new Chart(document.getElementById('days'), {
  119. type: 'line',
  120. data: {
  121. labels: @json($data['days']),
  122. datasets: [
  123. area_a('{{ trans('admin.report.current_month') }}',@json($data['currentMonth'])),
  124. area_b('{{ trans('admin.report.last_month') }} ',@json($data['lastMonth']))],
  125. },
  126. options: common_options(' {{ trans_choice('common.days.attribute', 1) }}'),
  127. });
  128. new Chart(document.getElementById('months'), {
  129. type: 'line',
  130. data: {
  131. labels: @json($data['years']),
  132. datasets: [
  133. area_a('{{ trans('admin.report.current_year') }}',@json($data['currentYear'])),
  134. area_b('{{ trans('admin.report.last_year') }}',@json($data['lastYear']))],
  135. },
  136. options: common_options(' {{ trans('validation.attributes.month') }}'),
  137. });
  138. new Chart(document.getElementById('years'), {
  139. type: 'line',
  140. data: {
  141. labels: @json(array_keys($data['ordersByYear'])),
  142. datasets: [
  143. {
  144. backgroundColor: 'rgba(184, 215, 255)',
  145. borderColor: 'rgba(184, 215, 255)',
  146. data: @json(array_values($data['ordersByYear'])),
  147. fill: {target: 'origin'},
  148. tension: 0.4,
  149. }],
  150. },
  151. options: {
  152. responsive: true,
  153. scales: {
  154. x: {
  155. grid: {
  156. display: false,
  157. },
  158. },
  159. y: {
  160. grid: {
  161. display: false,
  162. },
  163. min: 0,
  164. },
  165. },
  166. plugins: {
  167. legend: false,
  168. tooltip: label_callbacks(' {{ trans('validation.attributes.year') }}'),
  169. },
  170. },
  171. });
  172. </script>
  173. @endsection