feat 对接数据
This commit is contained in:
@@ -1,6 +1,32 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted } from 'vue'
|
||||||
|
import { useDbStore } from '@/store/modules/db'
|
||||||
|
|
||||||
|
const db = useDbStore()
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`
|
const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`
|
||||||
|
|
||||||
|
const workingCount = computed(() =>
|
||||||
|
(db.project || []).filter(item => item.status === 2).length,
|
||||||
|
)
|
||||||
|
|
||||||
|
const totalCompactionArea = computed(() =>
|
||||||
|
(db.project || []).reduce((sum, item) => sum + (item.total_compaction_area ?? 0), 0),
|
||||||
|
)
|
||||||
|
|
||||||
|
const totalDuration = computed(() =>
|
||||||
|
(db.project || []).reduce((sum, item) => sum + (item.total_duration ?? 0), 0),
|
||||||
|
)
|
||||||
|
|
||||||
|
function formatNumber(value: number) {
|
||||||
|
return Number.isInteger(value) ? String(value) : value.toFixed(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!db.project?.length)
|
||||||
|
await db.loadAll()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -19,7 +45,7 @@ const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}
|
|||||||
实时作业状态(台)
|
实时作业状态(台)
|
||||||
</text>
|
</text>
|
||||||
<text class="stat-value">
|
<text class="stat-value">
|
||||||
1
|
{{ workingCount }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="stat-item">
|
<view class="stat-item">
|
||||||
@@ -27,7 +53,7 @@ const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}
|
|||||||
累计作业面积(m²)
|
累计作业面积(m²)
|
||||||
</text>
|
</text>
|
||||||
<text class="stat-value">
|
<text class="stat-value">
|
||||||
1268
|
{{ formatNumber(totalCompactionArea) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="stat-item">
|
<view class="stat-item">
|
||||||
@@ -35,7 +61,7 @@ const dateStr = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}
|
|||||||
累计作业时长(小时)
|
累计作业时长(小时)
|
||||||
</text>
|
</text>
|
||||||
<text class="stat-value">
|
<text class="stat-value">
|
||||||
8.5
|
{{ formatNumber(totalDuration) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,7 +1,77 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { calcUncompactedArea } from '@/service/project'
|
||||||
|
import { useDbStore } from '@/store/modules/db'
|
||||||
|
import storage from '@/utils/storage'
|
||||||
|
|
||||||
const current = ref(25)
|
const db = useDbStore()
|
||||||
|
const currentProjectId = ref<number | null>(storage.get('current_project')?.id ?? null)
|
||||||
|
|
||||||
|
const currentProject = computed(() => {
|
||||||
|
const list = db.project || []
|
||||||
|
if (!list.length)
|
||||||
|
return null
|
||||||
|
|
||||||
|
const stored = currentProjectId.value != null
|
||||||
|
? list.find(item => item.id === currentProjectId.value)
|
||||||
|
: null
|
||||||
|
if (stored)
|
||||||
|
return stored
|
||||||
|
|
||||||
|
return list.find(item => item.status === 2) || list[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
const progressPercent = computed(() => {
|
||||||
|
const project = currentProject.value
|
||||||
|
if (!project)
|
||||||
|
return 0
|
||||||
|
if (project.progress)
|
||||||
|
return clampPercent(project.progress)
|
||||||
|
|
||||||
|
const total = project.total_area || 0
|
||||||
|
if (total <= 0)
|
||||||
|
return 0
|
||||||
|
return clampPercent(((project.total_compaction_area ?? 0) / total) * 100)
|
||||||
|
})
|
||||||
|
|
||||||
|
const qualifiedRate = computed(() => currentProject.value?.qualified_rate ?? 0)
|
||||||
|
|
||||||
|
const totalArea = computed(() => currentProject.value?.total_area ?? 0)
|
||||||
|
|
||||||
|
const compactedArea = computed(() => currentProject.value?.total_compaction_area ?? 0)
|
||||||
|
|
||||||
|
const uncompactedArea = computed(() => {
|
||||||
|
const project = currentProject.value
|
||||||
|
if (!project)
|
||||||
|
return 0
|
||||||
|
if (project.uncompacted_area != null)
|
||||||
|
return Math.max(0, project.uncompacted_area)
|
||||||
|
return calcUncompactedArea(project.total_area, project.total_compaction_area)
|
||||||
|
})
|
||||||
|
|
||||||
|
function clampPercent(value: number) {
|
||||||
|
return Math.min(100, Math.max(0, Number(value.toFixed(1))))
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatArea(value: number) {
|
||||||
|
const text = Number.isInteger(value) ? String(value) : String(value)
|
||||||
|
return `${text}m²`
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatRate(value: number) {
|
||||||
|
const text = Number.isInteger(value) ? String(value) : value.toFixed(2)
|
||||||
|
return `${text}%`
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!db.project?.length)
|
||||||
|
await db.loadAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
currentProjectId.value = storage.get('current_project')?.id ?? null
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -11,16 +81,19 @@ const current = ref(25)
|
|||||||
项目作业进度
|
项目作业进度
|
||||||
</text>
|
</text>
|
||||||
<text class="card-sub">
|
<text class="card-sub">
|
||||||
K1+200-K1+800
|
{{ currentProject?.stake_range || currentProject?.project_name || '暂无项目' }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="card-body">
|
<view class="card-body">
|
||||||
<view class="progress-content">
|
<view v-if="!currentProject" class="empty-tip">
|
||||||
|
暂无项目数据
|
||||||
|
</view>
|
||||||
|
<view v-else class="progress-content">
|
||||||
<view class="progress-circle">
|
<view class="progress-circle">
|
||||||
<wd-circle v-model="current" :size="120">
|
<wd-circle :model-value="progressPercent" :size="120">
|
||||||
<view class="progress-circle-text">
|
<view class="progress-circle-text">
|
||||||
<text class="progress-percent">
|
<text class="progress-percent">
|
||||||
{{ current }}%
|
{{ progressPercent }}%
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-label">
|
<text class="progress-label">
|
||||||
已完成
|
已完成
|
||||||
@@ -35,10 +108,10 @@ const current = ref(25)
|
|||||||
压实合格率
|
压实合格率
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-value">
|
<text class="progress-value">
|
||||||
95.65%
|
{{ formatRate(qualifiedRate) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<wd-progress :percentage="50" hide-text />
|
<wd-progress :percentage="clampPercent(qualifiedRate)" hide-text />
|
||||||
</view>
|
</view>
|
||||||
<view class="progress-item">
|
<view class="progress-item">
|
||||||
<view class="progress-row">
|
<view class="progress-row">
|
||||||
@@ -46,17 +119,17 @@ const current = ref(25)
|
|||||||
完成进度
|
完成进度
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-value">
|
<text class="progress-value">
|
||||||
66%
|
{{ progressPercent }}%
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<wd-progress :percentage="50" hide-text />
|
<wd-progress :percentage="progressPercent" hide-text />
|
||||||
</view>
|
</view>
|
||||||
<view class="progress-item progress-item-inline">
|
<view class="progress-item progress-item-inline">
|
||||||
<text class="progress-name">
|
<text class="progress-name">
|
||||||
总面积
|
总面积
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-value">
|
<text class="progress-value">
|
||||||
1164m²
|
{{ formatArea(totalArea) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="progress-item progress-item-inline">
|
<view class="progress-item progress-item-inline">
|
||||||
@@ -64,7 +137,7 @@ const current = ref(25)
|
|||||||
已压实面积
|
已压实面积
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-value">
|
<text class="progress-value">
|
||||||
664m²
|
{{ formatArea(compactedArea) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="progress-item progress-item-inline">
|
<view class="progress-item progress-item-inline">
|
||||||
@@ -72,7 +145,7 @@ const current = ref(25)
|
|||||||
未压实面积
|
未压实面积
|
||||||
</text>
|
</text>
|
||||||
<text class="progress-value">
|
<text class="progress-value">
|
||||||
500m²
|
{{ formatArea(uncompactedArea) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -114,6 +187,13 @@ const current = ref(25)
|
|||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-tip {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999999;
|
||||||
|
text-align: center;
|
||||||
|
padding: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.progress-content {
|
.progress-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user