Commit 278daa71 by lzzzzl

新增数据表盘

parent f99150a5
...@@ -143,6 +143,9 @@ class AccessApiController extends Controller ...@@ -143,6 +143,9 @@ class AccessApiController extends Controller
} }
/**
* 日志列表
*/
private function ApiLogsList($request) { private function ApiLogsList($request) {
$limit = $request['limit']; $limit = $request['limit'];
...@@ -156,4 +159,14 @@ class AccessApiController extends Controller ...@@ -156,4 +159,14 @@ class AccessApiController extends Controller
} }
private function ApiEffectSku($request) {
$start_time = empty($request['start_time']) ? strtotime("-1 day") : $request['start_time'];
$end_time = empty($request['end_time']) ? strtotime("0 day") : $request['end_time'];
$data = (new SpiderModel())->effectSku($start_time, $end_time);
$this->ExportLayui(0,'成功',$data,sizeof($data));
}
} }
...@@ -370,4 +370,16 @@ class AccessController extends Controller ...@@ -370,4 +370,16 @@ class AccessController extends Controller
return view('spider', $data); return view('spider', $data);
} }
/**
* 平台有效SKU
* @param $request
* @param $data
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function effectSku($request, $data, $id) {
$data['title'] = '平台有效SKU';
return view('spider_card', $data);
}
} }
...@@ -296,6 +296,25 @@ class SpiderModel extends Model ...@@ -296,6 +296,25 @@ class SpiderModel extends Model
} }
public function effectSku($start_time, $end_time) {
$map = [];
$map[] = ['update_time', '<=', $end_time];
$map[] = ['update_time', '>=', $start_time];
$data = DB::connection('dashboard')->table('effect_sku')->where($map)->get();
foreach ($data as $k => $v) {
$data[$k]['update_time'] = date("Y-m-d H:i:s", $v['update_time']);
}
return $data;
}
/**
* 补充人员数据
*/
public function saleMan($sale_id) { public function saleMan($sale_id) {
$sale_man = ''; $sale_man = '';
......
...@@ -6,7 +6,7 @@ return [ ...@@ -6,7 +6,7 @@ return [
'NotAuth' 'NotAuth'
), ),
//api不用验证方法 //api不用验证方法
'ApiNotAuth'=>array('ApiSpiderList','ApiUpdateStatus','ApiConfigContent','ApiAddConfig','ApiUpdateNode','ApiUpdateAllNode','ApiUpdateAllBoard', 'ApiLogsList' 'ApiNotAuth'=>array('ApiSpiderList','ApiUpdateStatus','ApiConfigContent','ApiAddConfig','ApiUpdateNode','ApiUpdateAllNode','ApiUpdateAllBoard', 'ApiLogsList', 'ApiEffectSku'
), ),
'MenuSign'=>'/web/',//菜单去除掉标记,生成菜单时用 'MenuSign'=>'/web/',//菜单去除掉标记,生成菜单时用
......
layui.use(['table', 'form', 'laydate', 'layer'], function() {
var laydate = layui.laydate;
var table = layui.table;
//日期范围
laydate.render({
elem: '#start_time'
,type:'date'
,format:'yyyy-MM-dd'
});
laydate.render({
elem: '#end_time'
,type:'date'
,format:'yyyy-MM-dd'
});
table.render({
elem:'#table',
loading:true,
cellMinWidth: 100,
page:false,
url: '/api/ApiEffectSku/',
request:{pageName:'p', limitName:'limit'},
cols: [[
{field:'effect_sku', title:'有效sku数', sort: true},
{field:'update_time', title:'更新时间', sort: true},
]],
id: 'idTest'
});
var $ = layui.$, active = {
reload: function(){
//执行重载
table.reload('idTest', {
where: {
start_time: $('#start_time').val(),
end_time: $('#end_time').val(),
}
});
},
};
$('.load').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
});
$('#search').click(function () {
var start_time = $('#start_time').val();
var end_time = $('#end_time').val();
if (start_time != '' && end_time != '') {
EffectSku(start_time, end_time);
} else {
layer.msg('请选择时间');
}
})
EffectSku('','');
function EffectSku(start_time, end_time) {
$.ajax({
url:'/api/ApiEffectSku',
type:'get',
dataType:'json',
data: {'start_time': start_time, 'end_time': end_time},
success:function (data) {
var myChart = echarts.init(document.getElementById('page'));
var time = [];
var count = [];
for (var i = 0; i < data['data'].length; i++) {
time.push(data['data'][i].update_time);
count.push(data['data'][i].effect_sku);
}
var option = {
title: {
text: '访问数',
left: '50%',
top: '1%',
textAlign: 'center'
},
tooltip: {
trigger: 'axis'
},
toolbox: {
feature: {
saveAsImage: {
show: true
}
}
},
grid: {
containLabel: true
},
xAxis: [{
type: 'category',
axisTick: {
alignWithLabel: true
},
data: time
}],
yAxis: [{
}],
series: [{
name: '入库数',
type: 'line',
label: {
normal: {
show: true,
position: 'top',
}
},
lineStyle: {
normal: {
width: 3,
shadowColor: 'rgba(0,0,0,0.4)',
shadowBlur: 10,
shadowOffsetY: 10
}
},
data: count
}]
};
myChart.setOption(option,true);
},
error:function () {
}
});
}
<div style="padding: 20px; background-color: #F2F2F2;">
<div class="layui-row layui-col-space10">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-input-inline">
<label class="layui-form-label">时间筛选:</label>
<div class="layui-input-inline">
<input type="text" name="start_time" id="start_time" autocomplete="off" class="layui-input" value="{{$_GET['start_time'] or ''}}">
</div>
-
<div class="layui-input-inline">
<input type="text" name="end_time" id="end_time" autocomplete="off" class="layui-input" value="{{$_GET['end_time'] or ''}}">
</div>
<div class="layui-inline">
<button class="btn btn btn-outline btn-primary load" lay-submit lay-filter="*" data-type="reload" id="search">搜索</button>
</div>
</div>
</div>
</div>
</div>
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-col-md12">
<span style="font-size:20px;font-weight:bold">数据概览</span>
<span class="layui-badge-dot layui-bg-orange"></span>
</div>
<div id="page" style="width: auto;height: 600px"></div>
</div>
</div>
</div>
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-col-md6">
<span style="font-size:20px;font-weight:bold">数据详情</span>
<span class="layui-badge-dot layui-bg-orange"></span>
</div>
<table class="layui-table" id="table" lay-filter="demo"></table>
</div>
</div>
</div>
</div>
<script src="/js/echarts.min.js"></script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment