index.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. use backend\widgets\TabWidget;
  3. echo TabWidget::widget(['list' => $this->context->menuList, 'currentMenu' => $this->context->id]);
  4. ?>
  5. <div class="panel panel-default">
  6. <?php
  7. use backend\widgets\SubTabWidget;
  8. echo SubTabWidget::widget(['list' => $this->context->subMenuList, 'currentMenu' => $this->context->action->id]);
  9. ?>
  10. <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  11. <div class="row">
  12. <form action="" method="GET">
  13. <div class="col-xs-6">
  14. <div class="dataTables_length" style="margin:15px 0 15px 0;">
  15. <button class="btn btn-info btn-single">最近7天</button>
  16. <button class="btn btn-secondary btn-single">最近30天</button>
  17. <button class="btn btn-info btn-single">本月</button>
  18. <button class="btn btn-info btn-single">上个月</button>
  19. <button class="btn btn-info btn-single">最近3个月</button>
  20. &nbsp;&nbsp;
  21. <label>自定义时间:<input type="text" name="date" class="form-control" autocomplete="off" id="getDate"></label>
  22. <input class="btn btn-secondary btn-single" type="submit" name="" value="搜索">
  23. </div>
  24. </div>
  25. </form>
  26. </div>
  27. </div>
  28. <div class="panel-heading" style="margin-top:30px;margin-bottom:10px;">
  29. <span>总收入:<?= $source['totalAmount'] ?>&nbsp;</span>
  30. <?php foreach ($source['data'] as $thisIncome) { ?>
  31. <span><?= $thisIncome['name'] ?>:<?= $thisIncome['value'] ?>&nbsp;</span>
  32. <?php } ?>
  33. </div>
  34. <div class="panel-heading" style="margin-top:30px;margin-bottom:10px;">
  35. <h5 class="panel-title" style="font-size:14px">变化趋势</h5>
  36. </div>
  37. <div id="myTrend" style="height:300px;"></div>
  38. <div class="panel-heading" style="margin-top:30px;margin-bottom:10px;">
  39. <h5 class="panel-title" style="font-size:14px">占比情况</h5>
  40. </div>
  41. <div style="padding:0 0 0 60px;margin-top:50px;">
  42. <div id="source_category" style="height:300px;width:28%;display:inline-block;margin-left:80px;"></div>
  43. <div id="product_category" style="height:300px;width:28%;display:inline-block;"></div>
  44. <div id="usage_category" style="height:300px;width:28%;display:inline-block;margin-left:80px;"></div>
  45. </div>
  46. <div class="panel-heading" style="margin-top:30px;margin-bottom:10px;">
  47. <h5 class="panel-title" style="font-size:14px">用途明细</h5>
  48. </div>
  49. <div id="latestDay" style="height:300px;"></div>
  50. </div>
  51. <!-- footer -->
  52. <?php
  53. use backend\widgets\FooterWidget;
  54. ?>
  55. <?= FooterWidget::widget() ?>
  56. <!-- footer -->
  57. <script src="/js/layDate-v5.0.9/laydate.js"></script>
  58. <script>
  59. //执行一个laydate实例
  60. laydate.render({
  61. elem: '#getDate',
  62. range: true,
  63. value: '<?= $_GET['date'] ?>',
  64. });
  65. </script>
  66. <script src="/js/echarts/build/dist/echarts.js"></script>
  67. <script type="text/javascript">
  68. // 路径配置
  69. require.config({
  70. paths: {
  71. echarts: '/js/echarts/build/dist'
  72. }
  73. });
  74. // 使用
  75. require(
  76. [
  77. 'echarts',
  78. 'echarts/chart/bar', // 使用柱状图就加载bar模块,按需加载
  79. 'echarts/chart/pie',
  80. 'echarts/chart/line'
  81. ],
  82. function (ec) {
  83. // 基于准备好的dom,初始化echarts图表
  84. var myChart = ec.init(document.getElementById('product_category'));
  85. var option = option = {
  86. title: {
  87. text: '主要用途',
  88. subtext: '',
  89. x: 'center'
  90. },
  91. tooltip: {
  92. trigger: 'item',
  93. formatter: "{a} <br/>{b} : {c} ({d}%)"
  94. },
  95. legend: {
  96. orient: 'vertical',
  97. x: 'left',
  98. data: <?= json_encode($usage['usageName']) ?>
  99. },
  100. calculable: true,
  101. series: [
  102. {
  103. name: '访问来源',
  104. type: 'pie',
  105. radius: '55%',
  106. center: ['50%', '60%'],
  107. data: <?= json_encode($usage['data']) ?>
  108. }
  109. ]
  110. };
  111. // 为echarts对象加载数据
  112. myChart.setOption(option);
  113. // 基于准备好的dom,初始化echarts图表
  114. var myChart = ec.init(document.getElementById('usage_category'));
  115. var option = option = {
  116. title: {
  117. text: '收入来源',
  118. subtext: '',
  119. x: 'center'
  120. },
  121. tooltip: {
  122. trigger: 'item',
  123. formatter: "{a} <br/>{b} : {c} ({d}%)"
  124. },
  125. legend: {
  126. orient: 'vertical',
  127. x: 'left',
  128. data: <?= json_encode($source['sourceTypeName']) ?>
  129. },
  130. calculable: true,
  131. series: [
  132. {
  133. name: '访问来源',
  134. type: 'pie',
  135. radius: '55%',
  136. center: ['50%', '60%'],
  137. data: <?= json_encode($source['data']) ?>
  138. }
  139. ]
  140. };
  141. // 为echarts对象加载数据
  142. myChart.setOption(option);
  143. // 基于准备好的dom,初始化echarts图表
  144. var myChart = ec.init(document.getElementById('source_category'));
  145. var option = option = {
  146. title: {
  147. text: '分类占比',
  148. subtext: '',
  149. x: 'center'
  150. },
  151. tooltip: {
  152. trigger: 'item',
  153. formatter: "{a} <br/>{b} : {c} ({d}%)"
  154. },
  155. legend: {
  156. orient: 'vertical',
  157. x: 'left',
  158. data: <?= json_encode($category['categoryName']) ?>
  159. },
  160. calculable: true,
  161. series: [
  162. {
  163. name: '访问来源',
  164. type: 'pie',
  165. radius: '55%',
  166. center: ['50%', '60%'],
  167. data: <?= json_encode($category['data']) ?>
  168. }
  169. ]
  170. };
  171. // 为echarts对象加载数据
  172. myChart.setOption(option);
  173. var myTrend = ec.init(document.getElementById('myTrend'));
  174. option = {
  175. title: {
  176. text: '',
  177. x: 'left'
  178. },
  179. tooltip: {
  180. trigger: 'axis'
  181. },
  182. legend: {
  183. data: ['金额']
  184. },
  185. calculable: true,
  186. xAxis: [
  187. {
  188. type: 'category',
  189. boundaryGap: false,
  190. data: <?= $latestIncomeDate ?>
  191. }
  192. ],
  193. yAxis: [
  194. {
  195. type: 'value',
  196. axisLabel: {
  197. formatter: '{value}'
  198. }
  199. }
  200. ],
  201. series: [
  202. {
  203. name: '金额',
  204. type: 'line',
  205. data: <?= $latestIncomeAmount ?>
  206. }
  207. ]
  208. };
  209. myTrend.setOption(option);
  210. // 基于准备好的dom,初始化echarts图表。
  211. var myChart = ec.init(document.getElementById('latestDay'));
  212. var option = {
  213. tooltip: {
  214. show: true
  215. },
  216. legend: {
  217. data: ['收入']
  218. },
  219. xAxis: [
  220. {
  221. type: 'category',
  222. data: ["年销花", "婚礼布置", "培训", "花束", "开业花篮", "绿植"]
  223. }
  224. ],
  225. yAxis: [
  226. {
  227. type: 'value'
  228. }
  229. ],
  230. series: [
  231. {
  232. "name": "收入",
  233. "type": "bar",
  234. "data": [5, 20, 40, 10, 10, 20]
  235. }
  236. ]
  237. };
  238. // 为echarts对象加载数据
  239. myChart.setOption(option);
  240. }
  241. );
  242. </script>