This commit is contained in:
2026-04-24 14:17:10 +08:00
parent 0e4f09b5bd
commit 50e694ef4b

View File

@ -100,6 +100,7 @@
</template>
<script setup>
import { countByTaskStatus } from "@/api/traffic";
import ChooseList from "@/components/ChooseList.vue";
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
@ -123,10 +124,10 @@ const alarmVoiceEnabled = ref(true);
// 统计数据
const stats = ref({
violationCount: '12',
trafficCount: '5',
completedCount: '8',
completionRate: '66.7%'
violationCount: 0,
trafficCount: 0,
completedCount: 0,
completionRate: 0
});
// 执法点位点击
@ -154,7 +155,31 @@ function handleLogout() {
router.push("/");
}).catch(() => {});
}
function getCountByTaskStatus() {
let data = {
userId: userInfo.value.userId,
};
countByTaskStatus(data).then((res) => {
let arr = res || [];
let wzTotal = 0;
let lmTotal = 0;
let yclTotal = 0;
arr.forEach(item => {
item.statusList = item.statusList || [];
let total = item.statusList.reduce((sum, status) => sum + (status.count), 0);
item.statusList.find(status => {
if(status.taskStatus == 2) yclTotal += status.count;
});
// 1:路面事件 2:违章事件
item.eventCategory == 1 ? lmTotal = total : wzTotal = total;
});
stats.value.violationCount = wzTotal;
stats.value.trafficCount = lmTotal;
stats.value.completedCount = yclTotal;
stats.value.completionRate = yclTotal > 0 ? `${((yclTotal / total) * 100).toFixed(1)}%` : '0%';
});
}
onMounted(() => {
// 从 localStorage 获取用户信息
const storedUserInfo = localStorage.getItem("userInfo");
@ -166,6 +191,7 @@ onMounted(() => {
console.error("解析用户信息失败", e);
}
}
getCountByTaskStatus();
});
</script>