更新细节
This commit is contained in:
parent
0b85a8062f
commit
0c780d19c6
|
@ -2,8 +2,8 @@ const config = {
|
||||||
terminal: 1, //终端
|
terminal: 1, //终端
|
||||||
title: '后台管理系统', //网站默认标题
|
title: '后台管理系统', //网站默认标题
|
||||||
version: '1.6.0', //版本号
|
version: '1.6.0', //版本号
|
||||||
baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
|
// baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
|
||||||
// baseUrl: 'http://127.0.0.1:30005/',
|
baseUrl: 'http://127.0.0.1:30005/',
|
||||||
urlPrefix: 'adminapi', //请求默认前缀
|
urlPrefix: 'adminapi', //请求默认前缀
|
||||||
timeout: 10 * 1000 //请求超时时长
|
timeout: 10 * 1000 //请求超时时长
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<div>
|
<div>
|
||||||
<v-charts
|
<v-charts
|
||||||
style="height: 350px"
|
style="height: 350px"
|
||||||
:option="workbenchData.visitorOption"
|
:option="workbenchData.dataOption"
|
||||||
:autoresize="true"
|
:autoresize="true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,9 +83,9 @@ import vCharts from 'vue-echarts'
|
||||||
const workbenchData: any = reactive({
|
const workbenchData: any = reactive({
|
||||||
today: {}, // 今日数据
|
today: {}, // 今日数据
|
||||||
menu: [], // 常用功能
|
menu: [], // 常用功能
|
||||||
visitor: [], // 图表数据
|
chart_data: [], // 图表数据
|
||||||
|
|
||||||
visitorOption: {
|
dataOption: {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: [0],
|
data: [0],
|
||||||
|
@ -138,29 +138,29 @@ const getData = () => {
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
workbenchData.today = res.today
|
workbenchData.today = res.today
|
||||||
workbenchData.menu = res.menu
|
workbenchData.menu = res.menu
|
||||||
workbenchData.visitor = res.visitor
|
workbenchData.chart_data = res.chart_data
|
||||||
// 清空echarts 数据
|
// 清空echarts 数据
|
||||||
workbenchData.visitorOption.xAxis.data = []
|
workbenchData.dataOption.xAxis.data = []
|
||||||
workbenchData.visitorOption.series[0].data = []
|
workbenchData.dataOption.series[0].data = []
|
||||||
workbenchData.visitorOption.series[1].data = []
|
workbenchData.dataOption.series[1].data = []
|
||||||
workbenchData.visitorOption.series[2].data = []
|
workbenchData.dataOption.series[2].data = []
|
||||||
workbenchData.visitorOption.series[3].data = []
|
workbenchData.dataOption.series[3].data = []
|
||||||
|
|
||||||
// 写入从后台拿来的数据
|
// 写入从后台拿来的数据
|
||||||
res.visitor.date.reverse().forEach((item: any) => {
|
res.chart_data.date.reverse().forEach((item: any) => {
|
||||||
workbenchData.visitorOption.xAxis.data.push(item)
|
workbenchData.dataOption.xAxis.data.push(item)
|
||||||
})
|
})
|
||||||
res.visitor.list[0].data.forEach((item: any) => {
|
res.chart_data.list[0].data.forEach((item: any) => {
|
||||||
workbenchData.visitorOption.series[0].data.push(item)
|
workbenchData.dataOption.series[0].data.push(item)
|
||||||
})
|
})
|
||||||
res.visitor.list[1].data.forEach((item: any) => {
|
res.chart_data.list[1].data.forEach((item: any) => {
|
||||||
workbenchData.visitorOption.series[1].data.push(item)
|
workbenchData.dataOption.series[1].data.push(item)
|
||||||
})
|
})
|
||||||
res.visitor.list[2].data.forEach((item: any) => {
|
res.chart_data.list[2].data.forEach((item: any) => {
|
||||||
workbenchData.visitorOption.series[2].data.push(item)
|
workbenchData.dataOption.series[2].data.push(item)
|
||||||
})
|
})
|
||||||
res.visitor.list[3].data.forEach((item: any) => {
|
res.chart_data.list[3].data.forEach((item: any) => {
|
||||||
workbenchData.visitorOption.series[3].data.push(item)
|
workbenchData.dataOption.series[3].data.push(item)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace app\adminapi\logic;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\service\ConfigService;
|
use app\common\service\ConfigService;
|
||||||
use app\common\service\FileService;
|
use app\common\service\FileService;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作台
|
* 工作台
|
||||||
|
@ -42,7 +42,7 @@ class WorkbenchLogic extends BaseLogic
|
||||||
// 快捷入口
|
// 快捷入口
|
||||||
'menu' => self::menu(),
|
'menu' => self::menu(),
|
||||||
// 图表数据
|
// 图表数据
|
||||||
'visitor' => self::visitor(),
|
'chart_data' => self::chartData(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,59 +87,77 @@ class WorkbenchLogic extends BaseLogic
|
||||||
*/
|
*/
|
||||||
public static function today(): array
|
public static function today(): array
|
||||||
{
|
{
|
||||||
|
$todayStart = strtotime(date('Y-m-d 00:00:00'));
|
||||||
|
$todayEnd = strtotime(date('Y-m-d 23:59:59'));
|
||||||
|
$userWhere['user_id'] = 0;
|
||||||
|
// 超级管理员数据
|
||||||
|
if ((request()->adminInfo)['root'] && !(request()->adminInfo)['user_id']) {
|
||||||
|
unset($userWhere['user_id']);
|
||||||
|
}
|
||||||
|
// 普通用户数据
|
||||||
|
if (!(request()->adminInfo)['root'] && (request()->adminInfo)['user_id']) {
|
||||||
|
$userWhere['user_id'] = (request()->adminInfo)['user_id'];
|
||||||
|
}
|
||||||
|
$totalLand = Db::name('land')->where($userWhere)->count();
|
||||||
|
$todayLand = Db::name('land')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$totalProduct = Db::name('product')->where($userWhere)->count();
|
||||||
|
$todayProduct = Db::name('product')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$totalDevice = Db::name('device')->where($userWhere)->count();
|
||||||
|
$todayDevice = Db::name('device')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$totalAlarm = Db::name('monitor_alarm')->where($userWhere)->count();
|
||||||
|
$todayAlarm = Db::name('monitor_alarm')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
return [
|
return [
|
||||||
'time' => date('Y-m-d H:i:s'),
|
'time' => date('Y-m-d H:i:s'),
|
||||||
// 土地数
|
'today_land' => $todayLand,
|
||||||
'today_land' => 3,
|
'total_land' => $totalLand,
|
||||||
// 今日新增
|
'today_product' => $todayProduct,
|
||||||
'total_land' => 10,
|
'total_product' => $totalProduct,
|
||||||
|
'today_device' => $todayDevice,
|
||||||
// 产品数
|
'total_device' => $totalDevice,
|
||||||
'today_product' => 2,
|
'today_alarm' => $todayAlarm,
|
||||||
// 今日新增
|
'total_alarm' => $totalAlarm
|
||||||
'total_product' => 100,
|
|
||||||
|
|
||||||
// 设备数
|
|
||||||
'today_device' => 2,
|
|
||||||
// 今日新增
|
|
||||||
'total_device' => 12,
|
|
||||||
|
|
||||||
// 报警数
|
|
||||||
'today_alarm' => 5,
|
|
||||||
// 今日新增
|
|
||||||
'total_alarm' => 35,
|
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 访问数
|
* @notes 图表数据
|
||||||
* @return array
|
* @return array
|
||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/29 16:57
|
* @date 2021/12/29 16:57
|
||||||
*/
|
*/
|
||||||
public static function visitor(): array
|
public static function chartData(): array
|
||||||
{
|
{
|
||||||
$land = $device = $product = $alarm = [];
|
$land = $device = $product = $alarm = [];
|
||||||
$date = [];
|
$date = [];
|
||||||
for ($i = 0; $i < 15; $i++) {
|
$userWhere['user_id'] = 0;
|
||||||
$where_start = strtotime("- " . $i . "day");
|
if ((request()->adminInfo)['root'] && !(request()->adminInfo)['user_id']) {
|
||||||
$date[] = date('Y/m/d', $where_start);
|
unset($userWhere['user_id']);
|
||||||
$land[$i] = rand(0, 100);
|
}
|
||||||
$product[$i] = rand(0, 100);
|
if (!(request()->adminInfo)['root'] && (request()->adminInfo)['user_id']) {
|
||||||
$device[$i] = rand(0, 100);
|
$userWhere['user_id'] = (request()->adminInfo)['user_id'];
|
||||||
$alarm[$i] = rand(0, 100);
|
}
|
||||||
|
for ($i = 0; $i < 7; $i++) {
|
||||||
|
$where_start = strtotime(date('Y-m-d 00:00:00', strtotime('-' . $i . ' day')));
|
||||||
|
$date[] = date('Y-m-d', $where_start);
|
||||||
|
$todayStart = $where_start;
|
||||||
|
$todayEnd = $where_start + 86400 -1;
|
||||||
|
$todayLand = Db::name('land')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$land[$i] = $todayLand;
|
||||||
|
$todayProduct = Db::name('product')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$product[$i] = $todayProduct;
|
||||||
|
$todayDevice = Db::name('device')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$device[$i] = $todayDevice;
|
||||||
|
$todayAlarm = Db::name('monitor_alarm')->where($userWhere)->where('create_time', 'between', [$todayStart, $todayEnd])->count();
|
||||||
|
$alarm[$i] = $todayAlarm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'list' => [
|
'list' => [
|
||||||
['name' => '土地数', 'data' => $land],
|
['name' => '土地数', 'data' => $land],
|
||||||
['name' => '产品数', 'data' => $product],
|
['name' => '产品数', 'data' => $product],
|
||||||
['name' => '设备数', 'data' => $device],
|
['name' => '设备数', 'data' => $device],
|
||||||
['name' => '报警数', 'data' => $alarm],
|
['name' => '报警数', 'data' => $alarm]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue