on-site-robots-screen/src/views/home/components/right-two/index.vue

288 lines
7.0 KiB
Vue

<template>
<!-- 右二 ---- 智能对比 -->
<div class="right-two child-container">
<div class="title-container">
<TitleBackground :title="`智能对比`" />
<div class="more-btn" @click="onHandleMore">更多</div>
</div>
<!-- 内容区域 -->
<div class="content-container">
<div
class="content-item"
:key="item.title"
v-for="(item, index) in compareList"
:class="`item-${index + 1}`"
>
<div>
<span style="padding-left: 10px; font-size: 16px"> {{ item.title }} </span>
<span style="padding-left: 10px; font-size: 14px"> 总数: </span>
<span> {{ item.total }} </span>
</div>
<div>
<span style="padding-left: 10px; font-size: 18px; font-weight: bold">
{{ item.amount }}
</span>
<span style="font-size: 14px; margin-left: 4px"> {{ item.unit }} </span>
</div>
</div>
</div>
</div>
<!-- 弹框内容 -->
<n-modal v-model:show="morePanelVisible">
<n-card
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
class="more-panel-card"
>
<n-flex justify="space-between">
<n-gradient-text
style="font-size: 20px; font-weight: 600; letter-spacing: 2px"
gradient="linear-gradient(90deg, #CDF7FD 0%, #DAFAFE 20%, #CDF7FD 40%, #DAFAFE 60%, #CDF7FD 80%, #DAFAFE 100%)"
>
人员动态
</n-gradient-text>
<img
class="close-icon"
src="@/assets/home-imgs/close.png"
@click="morePanelVisible = false"
/>
</n-flex>
<div class="tabs-btns">
<div
class="tabs-btn"
:key="item.name"
v-for="(item, index) in tapsBtns"
:class="{ active: activeIndex === index }"
@click="onHandleTabs(item.component, index)"
>
{{ item.name }}
</div>
</div>
<div class="taps-content">
<component :is="componentMap[currentComponent]" />
</div>
</n-card>
</n-modal>
</template>
<script setup>
import { NTag } from 'naive-ui'
import { ref, onMounted, onUpdated, nextTick, h } from 'vue'
import { getTaskStatisticsApi } from '@/api/home'
import TapsOne from './taps-one.vue'
import TapsTwo from './taps-two.vue'
import TapsThree from './taps-three.vue'
const morePanelVisible = ref(false)
const contentContainer = ref(null)
const shouldScroll = ref(false)
const page = ref(1)
const pageSize = ref(10)
const activeIndex = ref(0)
const currentComponent = ref('comp-a')
const compareList = ref([
{ title: '巡检次数', total: 0, amount: 0, unit: '次' },
{ title: '巡检照片', total: 0, amount: 0, unit: '张' },
{ title: '比对次数', total: 0, amount: 0, unit: '次' },
{ title: '异常数量', total: 0, amount: 0, unit: '项' },
])
const componentMap = {
'comp-a': TapsOne,
'comp-b': TapsTwo,
'comp-c': TapsThree,
}
const tapsBtns = ref([
{
name: '巡检次数',
component: 'comp-a',
},
{
name: '巡检照片',
component: 'comp-b',
},
{
name: '比对结果',
component: 'comp-c',
},
])
const columns = ref([
{
title: '日期时间',
key: 'age',
align: 'center',
},
{
title: '图片',
key: 'tags',
align: 'center',
render(row) {
const tags = row.tags.map((tagKey) => {
return h(
NTag,
{
style: {
marginRight: '6px',
},
type: 'info',
bordered: false,
},
{
default: () => tagKey,
},
)
})
return tags
},
},
{
title: '姓名',
key: 'age',
align: 'center',
},
{
title: '年龄',
key: 'age',
align: 'center',
},
{
title: '工种',
key: 'age',
align: 'center',
},
])
const data = ref([
{
age: '2025-06-01 10:00:00',
tags: ['nice'],
},
])
// 获取智能对比数据
const getTaskStatisticsData = async () => {
const { data: res } = await getTaskStatisticsApi()
console.log(res, 'res智能对比数据')
const { allErr, allImage, allSimilarity, allTask, dayErr, dayImage, daySimilarity, todayTask } =
res?.data
compareList.value[0].total = allTask
compareList.value[1].total = allImage
compareList.value[2].total = allSimilarity
compareList.value[3].total = allErr
compareList.value[0].amount = todayTask
compareList.value[1].amount = dayImage
compareList.value[2].amount = daySimilarity
compareList.value[3].amount = dayErr
}
getTaskStatisticsData()
const onHandleMore = () => {
console.log('更多')
morePanelVisible.value = true
}
const onHandleTabs = (component, index) => {
activeIndex.value = index
currentComponent.value = component
}
</script>
<style lang="scss" scoped>
.right-two {
.title-container {
position: relative;
.more-btn {
position: absolute;
right: 0;
top: 0;
}
}
}
.content-container {
flex: 1;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(4, 1fr);
gap: 10px;
padding: 20px 2px;
.content-item {
display: flex;
flex-direction: column;
justify-content: space-around;
border: 1px solid #00deff;
color: #b9e8fe;
}
.item-1 {
grid-column: 1 / 3;
grid-row: 1 / 3;
}
.item-2 {
grid-column: 3 / 5;
grid-row: 1 / 3;
}
.item-3 {
grid-column: 1 / 3;
grid-row: 3 / 5;
}
.item-4 {
grid-column: 3 / 5;
grid-row: 3 / 5;
}
}
.more-panel-card {
width: 80%;
height: 100vh;
display: flex;
flex-direction: column;
background: url('@/assets/home-imgs/modal-bg.png') no-repeat center center;
background-size: 100% 100%;
}
.close-icon {
width: 20px;
height: 20px;
cursor: pointer;
}
.tabs-btns {
display: flex;
margin: 20px 0;
.tabs-btn {
width: 90px;
height: 32px;
background-color: #1b4589;
color: #fff;
text-align: center;
line-height: 32px;
cursor: pointer;
}
.active {
background-color: #1090f0;
border-radius: 8px;
}
}
.taps-content {
width: 100%;
height: 80%;
}
</style>