Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JINRUN-DP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
JINRUN-DP
Commits
47dfce11
Commit
47dfce11
authored
Dec 19, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
卡掉预警 样式修改
parent
6af0cd91
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
51 deletions
+37
-51
RightAiWarning.vue
src/components/MineMonitor/RightAiWarning.vue
+37
-51
No files found.
src/components/MineMonitor/RightAiWarning.vue
View file @
47dfce11
...
@@ -23,20 +23,12 @@
...
@@ -23,20 +23,12 @@
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
,
onBeforeUnmount
,
nextTick
,
reactive
}
from
'
vue
'
import
{
ref
,
onMounted
,
onBeforeUnmount
,
nextTick
}
from
'
vue
'
import
{
getCarLogList
}
from
'
@/api/index-dp
'
;
import
{
getCarLogList
}
from
'
@/api/index-dp
'
;
import
{
useMessage
}
from
'
naive-ui
'
;
import
{
useMessage
}
from
'
naive-ui
'
;
const
message
=
useMessage
();
const
message
=
useMessage
();
// 1. 定义 TS 类型接口
// 1. 定义 TS 类型接口
interface
ChartDataItem
{
interface
ChartDataItem
{
name
:
string
;
name
:
string
;
...
@@ -50,13 +42,8 @@ interface RingLayer {
...
@@ -50,13 +42,8 @@ interface RingLayer {
}
}
// 2. 核心配置与数据(5个类别)
// 2. 核心配置与数据(5个类别)
var
chartData
:
ChartDataItem
[]
=
[
// 使用 ref 创建响应式数据
// { name: '疲劳驾驶', value: 10, color: '#409EFF' },
const
chartData
=
ref
<
ChartDataItem
[]
>
([]);
// { name: '违规打电话', value: 15, color: '#52C41A' },
// { name: '违规抽烟', value: 0, color: '#FAAD14' },
// { name: '左顾右盼', value: 2, color: '#FA8C16' },
// { name: '人脸丢失', value: 0, color: '#F5222D' },
];
// 调整环形图层尺寸以适应新的 canvas 尺寸,增大环间距离
// 调整环形图层尺寸以适应新的 canvas 尺寸,增大环间距离
const
ringLayers
:
RingLayer
[]
=
[
const
ringLayers
:
RingLayer
[]
=
[
...
@@ -106,7 +93,7 @@ const drawChart = () => {
...
@@ -106,7 +93,7 @@ const drawChart = () => {
// 步骤2:按比例绘制数值扇区
// 步骤2:按比例绘制数值扇区
const
drawSectors
=
()
=>
{
const
drawSectors
=
()
=>
{
const
validData
=
chartData
.
filter
((
item
)
=>
item
.
value
>
0
);
const
validData
=
chartData
.
value
.
filter
((
item
)
=>
item
.
value
>
0
);
const
total
=
validData
.
reduce
((
sum
,
item
)
=>
sum
+
item
.
value
,
0
);
const
total
=
validData
.
reduce
((
sum
,
item
)
=>
sum
+
item
.
value
,
0
);
if
(
total
===
0
)
{
if
(
total
===
0
)
{
console
.
warn
(
'
No valid data to draw
'
);
console
.
warn
(
'
No valid data to draw
'
);
...
@@ -118,7 +105,7 @@ const drawChart = () => {
...
@@ -118,7 +105,7 @@ const drawChart = () => {
// 先绘制背景
// 先绘制背景
drawBackground
();
drawBackground
();
chartData
.
forEach
((
item
,
index
)
=>
{
chartData
.
value
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
value
<=
0
)
return
;
if
(
item
.
value
<=
0
)
return
;
const
layer
=
ringLayers
[
index
];
const
layer
=
ringLayers
[
index
];
if
(
!
layer
)
return
;
if
(
!
layer
)
return
;
...
@@ -149,33 +136,36 @@ const drawChart = () => {
...
@@ -149,33 +136,36 @@ const drawChart = () => {
// 5. 挂载后初始化图表(DOM 渲染完成后执行)
// 5. 挂载后初始化图表(DOM 渲染完成后执行)
onMounted
(()
=>
{
onMounted
(()
=>
{
getCarLogList
().
then
((
response
)
=>
{
getCarLogList
().
then
((
response
)
=>
{
if
(
response
.
data
.
code
==
200
)
{
if
(
response
.
data
.
code
==
200
)
{
chartData
=
response
.
data
.
data
.
map
((
item
)
=>
({
// 使用 ref 的 value 属性更新数据,确保是响应式的
chartData
.
value
=
response
.
data
.
data
.
map
((
item
:
any
)
=>
({
name
:
item
.
name
,
name
:
item
.
name
,
value
:
item
.
count
*
1
,
value
:
item
.
count
*
1
,
color
:
item
.
color
color
:
item
.
color
}))
}));
console
.
log
(
'
*****************************
'
,
chartData
)
console
.
log
(
'
*****************************
'
,
chartData
.
value
);
console
.
log
(
'
Component mounted, attempting to draw chart
'
);
console
.
log
(
'
Component mounted, attempting to draw chart
'
);
// 使用 nextTick 确保 DOM 已完全渲染
// 使用 nextTick 确保 DOM 已完全渲染
nextTick
(()
=>
{
nextTick
(()
=>
{
drawChart
();
drawChart
();
});
});
}
else
{
}
else
{
message
.
error
(
response
.
data
.
msg
)
message
.
error
(
response
.
data
.
msg
)
;
}
}
})
}).
catch
((
error
)
=>
{
console
.
error
(
'
获取数据失败:
'
,
error
);
message
.
error
(
'
获取数据失败
'
);
});
});
});
// // 可选:监听数据变化重新绘制(如需动态更新数据可启用)
// // 可选:监听数据变化重新绘制(如需动态更新数据可启用)
// watch([() => chartData], () => {
// import { watch } from 'vue';
// watch(chartData, () => {
// drawChart();
// drawChart();
// }, { deep: true });
// }, { deep: true });
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
...
@@ -183,7 +173,7 @@ onMounted(() => {
...
@@ -183,7 +173,7 @@ onMounted(() => {
width
:
100%
;
width
:
100%
;
overflow
:
auto
;
overflow
:
auto
;
background-image
:
url("@/assets/jinrun/module-bg.png")
;
background-image
:
url("@/assets/jinrun/module-bg.png")
;
background-size
:
cover
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-repeat
:
no-repeat
;
}
}
...
@@ -212,10 +202,10 @@ background-size: cover;
...
@@ -212,10 +202,10 @@ background-size: cover;
align-items
:
center
;
align-items
:
center
;
margin-bottom
:
15px
;
margin-bottom
:
15px
;
width
:
2
.3rem
;
width
:
2
.3rem
;
height
:
0
.28rem
;
height
:
0
.28rem
;
background
:
#144f80
25
;
background
:
#144f80
25
;
border-radius
:
0
.14rem
;
border-radius
:
0
.14rem
;
padding-left
:
0
.3rem
;
padding-left
:
0
.3rem
;
}
}
.color-block
{
.color-block
{
...
@@ -232,19 +222,15 @@ padding-left: 0.3rem;
...
@@ -232,19 +222,15 @@ padding-left: 0.3rem;
width
:
1
.3rem
;
width
:
1
.3rem
;
padding-left
:
.12rem
;
padding-left
:
.12rem
;
}
}
// .legend-text:first-child{
// display: inline-block;
// text-align: left;
// }
.legend-name
{
.legend-name
{
font-size
:
12px
;
font-size
:
.16rem
;
color
:
#fff
;
color
:
#fff
;
margin-bottom
:
2px
;
margin-bottom
:
2px
;
}
}
.legend-value
{
.legend-value
{
font-size
:
12px
;
font-size
:
.16rem
;
color
:
#666
;
color
:
#666
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment