wave.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?php
  2. use app\assets\CoreAsset;
  3. use app\assets\PluginsAsset;
  4. $asset = CoreAsset::register($this);
  5. $assetsUrl = $asset->baseUrl;
  6. $pluginsAsset = PluginsAsset::register($this);
  7. $pluginsUrl = $pluginsAsset->baseUrl;
  8. use yii\widgets\ActiveForm;
  9. ?>
  10. <style>
  11. table tbody {
  12. display:block;
  13. }
  14. table thead, tbody tr {
  15. display:table;
  16. width:100%;
  17. table-layout:fixed;
  18. border:none;
  19. }
  20. table thead {
  21. width: calc( 100% - 20px )//core code
  22. }</style>
  23. <?php $this->beginContent('@app/modules/admin/views/layouts/_datatable_start.php'); ?><?php $this->endContent(); ?>
  24. <script src="<?php echo $assetsUrl;?>/libs/tableExport.jquery.plugin/libs/js-xlsx/xlsx.core.min.js"></script>
  25. <script src="<?php echo $assetsUrl;?>/libs/tableExport.jquery.plugin/libs/FileSaver/FileSaver.min.js"></script>
  26. <script src="<?php echo $assetsUrl;?>/libs/tableExport.jquery.plugin/tableExport.min.js"></script>
  27. <div class="row ">
  28. <div class="col-12">
  29. <div class="card">
  30. <div class="card-body" style="padding:0 1.25rem;">
  31. <!-- 搜索表单 -->
  32. <div class="searchbox" style="margin-bottom: 0px;padding: 10px 0px 10px;border-bottom:none;" >
  33. <?php $form = ActiveForm::begin(['options' => ['id'=>'searchform','class' => 'row gy-2 gx-3 align-items-center'], 'enableClientValidation' => false]); ?>
  34. <div class="col-sm-auto"><label class="col-form-label">年份</label></div>
  35. <div class="col-sm-auto" >
  36. <input type="text" name="year" id="year" class="form-control" value="<?php echo get_date(TIMESTAMP,'Y');?>">
  37. </div>
  38. <div class="col-sm-auto"><label class="col-form-label">月份</label></div>
  39. <div class="col-sm-auto">
  40. <select class="form-select" data-dselect-clearable="true" name="end_month" id="end_month">
  41. <option value="">月份</option>
  42. <?php for($i=1;$i<=12;$i++){ ?>
  43. <option value="<?php echo $i;?>" <?php if(date('m')==$i){?> selected <?php }?>><?php echo $i;?>月</option>
  44. <?php }?>
  45. </select>
  46. </div>
  47. <div class="col-sm-auto"><label class="col-form-label">地市</label></div>
  48. <div class="col-sm-auto">
  49. <?php echo \app\common\widget\LinkmenuWidget::widget(['key_id'=>1,'name'=>'city','level'=>1,'emptyTxts'=>['地市'],'value'=>0,'selectClass'=>'form-select original ','blockClass'=>'','unitStyle'=>'min-width:120px;display:inline-block;margin-right:10px;']);?>
  50. </div>
  51. <div class="col-sm-auto">
  52. <div class="form-check">
  53. <input class="form-check-input" type="radio" name="datatype" value="1" checked>
  54. <label class="form-check-label">月度</label>
  55. </div>
  56. </div>
  57. <div class="col-sm-auto">
  58. <div class="form-check">
  59. <input class="form-check-input" type="radio" name="datatype" value="2" >
  60. <label class="form-check-label">累计</label>
  61. </div>
  62. </div>
  63. <div class="col-sm-auto">
  64. <button type="button" class="btn btn-light carbtn" onclick="doQuery()">查询</button>
  65. <button type="button" class="btn btn-light carbtn" onclick="doExport()">导出</button>
  66. <button type="button" class="btn btn-light carbtn" data-bs-toggle="modal" data-bs-target="#koujing" onclick="doKoujing()">口径描述</button>
  67. </div>
  68. <?php ActiveForm::end(); ?>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="row">
  75. <div class="card">
  76. <div class="card-body">
  77. <div class="row">
  78. <div id="chartbox" class="apex-charts" dir="ltr"></div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="row">
  84. <div class="card">
  85. <div class="card-body">
  86. <div class="row" id="tablebox">
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <script src="<?php echo $assetsUrl;?>/libs/apexcharts/apexcharts.min.js"></script>
  92. <script src="<?php echo $assetsUrl;?>/libs/datepicker/datepicker.js"></script>
  93. <script src="<?php echo $assetsUrl;?>/libs/datepicker/i18n/datepicker.zh-CN.js"></script>
  94. <link href="<?php echo $assetsUrl;?>/libs/datepicker/datepicker.css" rel="stylesheet">
  95. <script>
  96. $(function(){
  97. //年份选择
  98. $('#year').datepicker({
  99. format: 'yyyy',
  100. autoclose: true,
  101. yearSuffix: '年'
  102. })
  103. //类型变化
  104. $("input[name='datatype']").change(function(){
  105. doQuery();
  106. })
  107. /*//年份变化
  108. $('#year').change(function(){
  109. doQuery();
  110. })
  111. //城市变化
  112. $('#city_1').change(function(){
  113. doQuery();
  114. })*/
  115. })
  116. </script>
  117. <?php $this->beginContent('@app/modules/admin/views/layouts/_datatable_end.php'); ?><?php $this->endContent(); ?>
  118. <script>
  119. var chart = null;
  120. var data_url = '<?php echo Yii::$app->controller->createRealUrl(['car/wave/index','type'=>$type]);?>';
  121. function doQuery()
  122. {
  123. var datatype = $("input[name='datatype']:checked").val();
  124. var year = $('#year').val();
  125. var city = $('#city').val();
  126. var end_month = $('#end_month').val();
  127. layer.msg('请求中,请稍候...', { icon: 16 ,shade: 0.5,time:100000 });
  128. var data = {year:year,datatype:datatype,city:city,end_month:end_month};
  129. $.get(data_url,data,function(result) {
  130. layer.closeAll();
  131. if(datatype==1)
  132. {
  133. var options = {
  134. chart: {
  135. height: 200,
  136. type: "line",
  137. zoom: {
  138. enabled: !1
  139. },
  140. toolbar: {
  141. show: !1
  142. }
  143. },
  144. colors: ["#556ee6", "#34c38f"],
  145. dataLabels: {
  146. enabled: !1
  147. },
  148. stroke: {
  149. width: [2, 2],
  150. curve: "straight"
  151. },
  152. series: [{
  153. name: result.year,
  154. data: result.line1
  155. }, {
  156. name: result.lastyear,
  157. data: result.line2
  158. }],
  159. grid: {
  160. row: {
  161. colors: ["transparent", "transparent"],
  162. opacity: .2
  163. },
  164. borderColor: "#f1f1f1"
  165. },
  166. markers: {
  167. style: "inverted",
  168. size: 3
  169. },
  170. xaxis: {
  171. categories: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
  172. },
  173. yaxis: {
  174. title: {
  175. text: "单位("+result.unit+")"
  176. },
  177. }
  178. }
  179. }
  180. if(datatype==2)
  181. {
  182. var options = {
  183. chart: {
  184. height: 200,
  185. type: "line",
  186. stacked: !1,
  187. toolbar: {
  188. show: !1
  189. }
  190. },
  191. stroke: {
  192. width: [2,2,2],
  193. curve: "straight"
  194. },
  195. plotOptions: {
  196. bar: {
  197. columnWidth: "40%"
  198. }
  199. },
  200. colors:["#34c38f", "#cf5a5a", "#50a5f1"],
  201. series: [{
  202. name: "本年累计",
  203. type: "column",
  204. data: result.line1
  205. },{
  206. name: "去年同期",
  207. type: "column",
  208. data: result.line2
  209. }, {
  210. name: "同比增幅",
  211. type: "line",
  212. data: result.line3
  213. }],
  214. fill: {
  215. opacity: [0.8, 0.8, 0.8],
  216. gradient: {
  217. inverseColors: !1,
  218. shade: "light",
  219. type: "vertical",
  220. opacityFrom: .85,
  221. opacityTo: .55
  222. }
  223. },
  224. labels: result.cityOptions,
  225. markers: {
  226. size: 3
  227. },
  228. /*xaxis: {
  229. type: "datetime"
  230. },
  231. yaxis: {
  232. title: {
  233. text: "Points"
  234. }
  235. },*/
  236. yaxis: {
  237. axisBorder: {
  238. show: !1
  239. },
  240. axisTicks: {
  241. show: !1
  242. },
  243. labels: {
  244. show: !1,
  245. },
  246. },
  247. tooltip: {
  248. shared: !0,
  249. intersect: !1,
  250. y: [{
  251. title: {
  252. formatter: function(e) {
  253. return e+ '('+result.unit+')'
  254. }
  255. },
  256. }, {
  257. title: {
  258. formatter: function(e) {
  259. return e+ '('+result.unit+')'
  260. }
  261. }
  262. }, {
  263. title: {
  264. formatter: function(e) {
  265. return e+ '(%)'
  266. }
  267. }
  268. }]
  269. },
  270. grid: {
  271. borderColor: "#f1f1f1"
  272. }
  273. };
  274. }
  275. $('#tablebox').html(result.table);
  276. $(document).on("click", ".treegrid-expanded", function(){
  277. var id = $(this).data('id');
  278. $(".treegrid-parent-"+id).hide();
  279. $(this).removeClass('treegrid-expanded').addClass('treegrid-collapsed');
  280. $(this).find(".treegrid-expander-expanded").removeClass('treegrid-expander-expanded').addClass('treegrid-expander-collapsed');
  281. //二级信息控制
  282. $(".treegrid-parent-"+id).each(function(){
  283. var tempId = $(this).data('id');
  284. $(".treegrid-parent-"+tempId).hide();
  285. $(this).removeClass('treegrid-expanded').addClass('treegrid-collapsed');
  286. })
  287. })
  288. $(document).on("click", ".treegrid-collapsed", function(){
  289. var id = $(this).data('id');
  290. $(".treegrid-parent-"+id).show();
  291. $(this).removeClass('treegrid-collapsed').addClass('treegrid-expanded');
  292. $(this).find(".treegrid-expander-collapsed").removeClass('treegrid-expander-collapsed').addClass('treegrid-expander-expanded');
  293. })
  294. $("body").css("overflow-y","hidden");
  295. if(chart!=null)
  296. {
  297. chart.updateOptions(options);
  298. }
  299. else
  300. {
  301. chart = new ApexCharts(document.querySelector("#chartbox"), options);
  302. chart.render();
  303. }
  304. })
  305. }
  306. doQuery();
  307. function doKoujing()
  308. {
  309. $('#koujing_content').html('<?php echo $koujing;?>');
  310. }
  311. </script>