更新细节

This commit is contained in:
yaooo 2023-11-27 16:41:48 +08:00
parent 03eec6bb0d
commit f5a232a2eb
2 changed files with 134 additions and 98 deletions

View File

@ -1,7 +1,6 @@
<template> <template>
<div class="workbench"> <div class="workbench">
<div class="lg:flex"> <div class="lg:flex">
<el-card class="!border-none mb-4 flex-1" shadow="never"> <el-card class="!border-none mb-4 flex-1" shadow="never">
<template #header> <template #header>
<div> <div>
@ -12,7 +11,66 @@
</div> </div>
</template> </template>
<div class="flex flex-wrap">
<div class="w-1/2 md:w-1/4">
<div class="leading-10">土地数</div>
<div class="text-6xl">{{ workbenchData.today.total_land }}</div>
<div class="text-tx-secondary">
今日新增{{ workbenchData.today.today_land }}
</div>
</div>
<div class="w-1/2 md:w-1/4">
<div class="leading-10">产品数</div>
<div class="text-6xl">{{ workbenchData.today.total_product }}</div>
<div class="text-tx-secondary">
今日新增{{ workbenchData.today.today_product }}
</div>
</div>
<div class="w-1/2 md:w-1/4">
<div class="leading-10">设备数</div>
<div class="text-6xl">{{ workbenchData.today.total_device }}</div>
<div class="text-tx-secondary">
今日新增{{ workbenchData.today.today_device }}
</div>
</div>
<div class="w-1/2 md:w-1/4">
<div class="leading-10">报警数</div>
<div class="text-6xl">{{ workbenchData.today.total_alarm }}</div>
<div class="text-tx-secondary">
今日新增{{ workbenchData.today.today_alarm }}
</div>
</div>
</div>
</el-card>
</div>
<div class="function mb-4">
<el-card class="flex-1 !border-none" shadow="never">
<template #header>
<span>快捷入口</span>
</template>
<div class="flex flex-wrap">
<div
v-for="item in workbenchData.menu"
class="md:w-[12.5%] w-1/4 flex flex-col items-center"
:key="item"
>
<router-link :to="item.url" class="mb-3 flex flex-col items-center">
<image-contain width="40px" height="40px" :src="item?.image" />
<div class="mt-2">{{ item.name }}</div>
</router-link>
</div>
</div>
</el-card>
</div>
<div class="md:flex">
<el-card class="flex-1 !border-none md:mr-4 mb-4" shadow="never">
<div>
<v-charts
style="height: 350px"
:option="workbenchData.visitorOption"
:autoresize="true"
/>
</div>
</el-card> </el-card>
</div> </div>
</div> </div>
@ -23,31 +81,20 @@ import { getWorkbench } from '@/api/app'
import vCharts from 'vue-echarts' import vCharts from 'vue-echarts'
// //
const workbenchData: any = reactive({ const workbenchData: any = reactive({
version: {
version: '', //
website: '', //
based: '',
channel: {
gitee: '',
website: ''
}
},
support: [],
today: {}, // today: {}, //
menu: [], // menu: [], //
visitor: [], // 访 visitor: [], //
article: [], //
visitorOption: { visitorOption: {
xAxis: { xAxis: {
type: 'category', type: 'category',
data: [0] data: [0],
}, },
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
legend: { legend: {
data: ['访问量'] data: ['土地数', '产品数', '设备数', '报警数']
}, },
itemStyle: { itemStyle: {
// //
@ -58,10 +105,28 @@ const workbenchData: any = reactive({
}, },
series: [ series: [
{ {
name: '访问量', name: '土地数',
data: [0], data: [0],
type: 'line', type: 'line',
smooth: true smooth: true
},
{
name: '产品数',
data: [1],
type: 'line',
smooth: true
},
{
name: '设备数',
data: [2],
type: 'line',
smooth: true
},
{
name: '报警数',
data: [3],
type: 'line',
smooth: true
} }
] ]
} }
@ -71,15 +136,15 @@ const workbenchData: any = reactive({
const getData = () => { const getData = () => {
getWorkbench() getWorkbench()
.then((res: any) => { .then((res: any) => {
workbenchData.version = res.version
workbenchData.today = res.today workbenchData.today = res.today
workbenchData.menu = res.menu workbenchData.menu = res.menu
workbenchData.visitor = res.visitor workbenchData.visitor = res.visitor
workbenchData.support = res.support
// echarts // echarts
workbenchData.visitorOption.xAxis.data = [] workbenchData.visitorOption.xAxis.data = []
workbenchData.visitorOption.series[0].data = [] workbenchData.visitorOption.series[0].data = []
workbenchData.visitorOption.series[1].data = []
workbenchData.visitorOption.series[2].data = []
workbenchData.visitorOption.series[3].data = []
// //
res.visitor.date.reverse().forEach((item: any) => { res.visitor.date.reverse().forEach((item: any) => {
@ -88,6 +153,15 @@ const getData = () => {
res.visitor.list[0].data.forEach((item: any) => { res.visitor.list[0].data.forEach((item: any) => {
workbenchData.visitorOption.series[0].data.push(item) workbenchData.visitorOption.series[0].data.push(item)
}) })
res.visitor.list[1].data.forEach((item: any) => {
workbenchData.visitorOption.series[1].data.push(item)
})
res.visitor.list[2].data.forEach((item: any) => {
workbenchData.visitorOption.series[2].data.push(item)
})
res.visitor.list[3].data.forEach((item: any) => {
workbenchData.visitorOption.series[3].data.push(item)
})
}) })
.catch((err: any) => { .catch((err: any) => {
console.log('err', err) console.log('err', err)

View File

@ -37,22 +37,18 @@ class WorkbenchLogic extends BaseLogic
public static function index() public static function index()
{ {
return [ return [
// 版本信息
'version' => self::versionInfo(),
// 今日数据 // 今日数据
'today' => self::today(), 'today' => self::today(),
// 常用功能 // 快捷入口
'menu' => self::menu(), 'menu' => self::menu(),
// 近15日访客数 // 图表数据
'visitor' => self::visitor(), 'visitor' => self::visitor(),
// 服务支持
'support' => self::support()
]; ];
} }
/** /**
* @notes 常用功能 * @notes 快捷入口
* @return array[] * @return array[]
* @author 段誉 * @author 段誉
* @date 2021/12/29 16:40 * @date 2021/12/29 16:40
@ -61,70 +57,28 @@ class WorkbenchLogic extends BaseLogic
{ {
return [ return [
[ [
'name' => '管理员', 'name' => '土地列表',
'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
'url' => '/permission/admin'
],
[
'name' => '角色管理',
'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
'url' => '/permission/role'
],
[
'name' => '部门管理',
'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
'url' => '/organization/department'
],
[
'name' => '字典管理',
'image' => FileService::getFileUrl(config('project.default_image.menu_dict')), 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
'url' => '/dev_tools/dict' 'url' => '/land/land'
], ],
[ [
'name' => '代码生成器', 'name' => '产品列表',
'image' => FileService::getFileUrl(config('project.default_image.menu_generator')),
'url' => '/dev_tools/code'
],
[
'name' => '素材中心',
'image' => FileService::getFileUrl(config('project.default_image.menu_file')), 'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
'url' => '/material/index' 'url' => '/land/product'
], ],
[ [
'name' => '菜单权限', 'name' => '设备列表',
'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
'url' => '/permission/menu'
],
[
'name' => '网站信息',
'image' => FileService::getFileUrl(config('project.default_image.menu_web')), 'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
'url' => '/setting/website/information' 'url' => '/device/device'
], ],
]; [
} 'name' => '监控报警',
'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
'url' => '/device/monitor_alarm'
/**
* @notes 版本信息
* @return array
* @author 段誉
* @date 2021/12/29 16:08
*/
public static function versionInfo(): array
{
return [
'version' => config('project.version'),
'website' => config('project.website.url'),
'name' => ConfigService::get('website', 'name'),
'based' => 'vue3.x、ElementUI、MySQL',
'channel' => [
'website' => 'https://www.likeadmin.cn',
'gitee' => 'https://gitee.com/likeadmin/likeadmin_php',
] ]
]; ];
} }
/** /**
* @notes 今日数据 * @notes 今日数据
* @return int[] * @return int[]
@ -135,25 +89,27 @@ class WorkbenchLogic extends BaseLogic
{ {
return [ return [
'time' => date('Y-m-d H:i:s'), 'time' => date('Y-m-d H:i:s'),
// 今日销售额 // 土地数
'today_sales' => 100, 'today_land' => 3,
// 总销售额 // 今日新增
'total_sales' => 1000, 'total_land' => 10,
// 今日访问量 // 产品数
'today_visitor' => 10, 'today_product' => 2,
// 总访问量 // 今日新增
'total_visitor' => 100, 'total_product' => 100,
// 今日新增用户量 // 设备数
'today_new_user' => 30, 'today_device' => 2,
// 总用户量 // 今日新增
'total_new_user' => 3000, 'total_device' => 12,
// 订单量 (笔) // 报警数
'order_num' => 12, 'today_alarm' => 5,
// 总订单量 // 今日新增
'order_sum' => 255 'total_alarm' => 35,
]; ];
} }
@ -166,18 +122,24 @@ class WorkbenchLogic extends BaseLogic
*/ */
public static function visitor(): array public static function visitor(): array
{ {
$num = []; $land = $device = $product = $alarm = [];
$date = []; $date = [];
for ($i = 0; $i < 15; $i++) { for ($i = 0; $i < 15; $i++) {
$where_start = strtotime("- " . $i . "day"); $where_start = strtotime("- " . $i . "day");
$date[] = date('Y/m/d', $where_start); $date[] = date('Y/m/d', $where_start);
$num[$i] = rand(0, 100); $land[$i] = rand(0, 100);
$product[$i] = rand(0, 100);
$device[$i] = rand(0, 100);
$alarm[$i] = rand(0, 100);
} }
return [ return [
'date' => $date, 'date' => $date,
'list' => [ 'list' => [
['name' => '访客数', 'data' => $num] ['name' => '土地数', 'data' => $land],
['name' => '产品数', 'data' => $product],
['name' => '设备数', 'data' => $device],
['name' => '报警数', 'data' => $alarm],
] ]
]; ];
} }