作者 潘浩文
1 个管道 的构建 通过 耗费 6 秒

XIAOPAN

... ... @@ -30,8 +30,10 @@ class AdminStatisticsController extends AdminBaseController{
public function index(){
$param=$this->request->param();
$where='';
$where1=[];
if (!empty($param['hospital'])){
$where="hospital='".$param['hospital']."' AND";
$where1['hospital']=$param['hospital'];
}
//医院总体时长统计
$data=Db::name('order')
... ... @@ -77,13 +79,23 @@ class AdminStatisticsController extends AdminBaseController{
$month_interval[$i]=[$month[$i],$month[$i+1]];
}
$Month_statistics=array();
$Month_money=array();
$Month=array();
for ($i = 0; $i<24; $i++){
$Month[]=date('Y-m-d',$month_interval[$i][1]);
$Month_statistics[]=Db::name('order')->where('start_time','between',$month_interval[$i])->count();
$Month_money[]=Db::name('order')
->alias('o')
->join('equipment e','o.eq_name=e.name')
->where($where1)
->where('o.start_time','between',$month_interval[$i])
->where('o.state',3)
->sum('o.price');
}
$this->assign('month',json_encode($Month));
$this->assign('monthData',json_encode($Month_statistics));
$this->assign('monthMoney',json_encode($Month_money));
//时间段统计
$interval=array();
... ... @@ -99,6 +111,10 @@ class AdminStatisticsController extends AdminBaseController{
$interval[$k]=$interval[$k][0]['num'];
}
$this->assign('interval',json_encode($interval));
$this->assign('hospital', isset($param['hospital']) ? $param['hospital'] : '');
... ...
... ... @@ -49,6 +49,9 @@
<div>
<div id="main2" class="my_main" style="width: 380px;"></div>
</div>
<div>
<div id="main12" class="my_main" style="width: 380px;"></div>
</div>
</div>
</div>
... ... @@ -131,7 +134,7 @@
//月统计数据
var monthDataX = JSON.parse('{$month}');
var monthDataY = JSON.parse('{$monthData}');
var monthMoney = JSON.parse('{$monthMoney}');
// 路径配置
... ... @@ -156,6 +159,7 @@
var myChart4 = ec.init(document.getElementById('main4'),'macarons');
var myChart10 = ec.init(document.getElementById('main10'),'macarons');
var myChart11 = ec.init(document.getElementById('main11'),'macarons');
var myChart12 = ec.init(document.getElementById('main12'),'macarons');
//时间段统计(柱形图)
var option = {
... ... @@ -482,13 +486,65 @@
}
]
};
var option12 = {
backgroundColor : "white",
color : ["#c05050","#59678c"],
title:{
text : '时间段统计',
y: '15'
},
tooltip : {
trigger: 'axis',
showDelay: 0, // 显示延迟,添加显示延迟可以避免频繁切换,单位ms
formatter: "{b}</br>{a} : {c}元"
},
dataZoom : {
show : true,
realtime: true,
y : 220,
height: 20,
start : 75,
end : 100
},
calculable : true,
grid: {
x: 80,
y: 40,
x2:60,
},
xAxis : [
{
type : 'category',
boundaryGap : true,
data : monthDataX
}
],
yAxis : [
{
type : 'value',
scale:true,
}
],
series : [
{
name:'月统计',
type:'line',
//stack: '人数',
barWidth : 10,
data:monthMoney
}
]
};
// 为echarts对象加载数据
myChart.setOption(option);
myChart2.setOption(option4);
myChart4.setOption(option2);
myChart10.setOption(option10);
myChart11.setOption(option11);
myChart12.setOption(option12);
}
);
});
... ...