更新
This commit is contained in:
@ -100,6 +100,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { countByTaskStatus } from "@/api/traffic";
|
||||||
import ChooseList from "@/components/ChooseList.vue";
|
import ChooseList from "@/components/ChooseList.vue";
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
@ -123,10 +124,10 @@ const alarmVoiceEnabled = ref(true);
|
|||||||
|
|
||||||
// 统计数据
|
// 统计数据
|
||||||
const stats = ref({
|
const stats = ref({
|
||||||
violationCount: '12',
|
violationCount: 0,
|
||||||
trafficCount: '5',
|
trafficCount: 0,
|
||||||
completedCount: '8',
|
completedCount: 0,
|
||||||
completionRate: '66.7%'
|
completionRate: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// 执法点位点击
|
// 执法点位点击
|
||||||
@ -154,7 +155,31 @@ function handleLogout() {
|
|||||||
router.push("/");
|
router.push("/");
|
||||||
}).catch(() => {});
|
}).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(() => {
|
onMounted(() => {
|
||||||
// 从 localStorage 获取用户信息
|
// 从 localStorage 获取用户信息
|
||||||
const storedUserInfo = localStorage.getItem("userInfo");
|
const storedUserInfo = localStorage.getItem("userInfo");
|
||||||
@ -166,6 +191,7 @@ onMounted(() => {
|
|||||||
console.error("解析用户信息失败", e);
|
console.error("解析用户信息失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getCountByTaskStatus();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user