更新7日建联数

This commit is contained in:
2025-10-17 15:37:42 +08:00
parent b59fcedcde
commit 734437b001
5 changed files with 33 additions and 9 deletions

View File

@@ -94,10 +94,15 @@
</el-col> -->
<el-col
v-if="wsCache.get('roleRouters').find(item => item.id === 1)?.children.find(item => item.id === 100)"
:xl="14" :lg="20" :md="24" :sm="24" :xs="24">
:xl="20" :lg="20" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-8px">
<el-select style="width: 200px;" v-model="days" @change="updataDays">
<el-option :value="1" label="近1天">近1天</el-option>
<el-option :value="7" label="近7天">近7天</el-option>
</el-select>
<el-skeleton :loading="loading" animated>
<Echart :options="barOptionsData" :height="280" />
<Echart style="width: 100%;" :options="barOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
@@ -179,12 +184,13 @@ import { useCache } from '@/hooks/web/useCache'
import { getSimpleUserListPage, getSimpleUserList } from '@/api/system/user'
import { EmployeeHostsApi } from '@/api/server/employeehosts'
import { ref, reactive, onMounted, onActivated } from 'vue'
import WxMusic from '../mp/components/wx-music'
let HostsOperationNum = ref(0)
onMounted(async () => {
await getAllApi()
await getAllocationList()
if (wsCache.get('roleRouters').find(item => item.id === 1)?.children.find(item => item.id === 100)) {
await fetchAllHostsCount()
await fetchAllHostsCount(1)
} else {
await fetchDailyHostsCount()
}
@@ -193,12 +199,16 @@ onMounted(async () => {
})
let days = ref()
// 每次页面“再次显示”时都会触发(前提:该路由组件被 keep-alive 缓存)
onActivated(async () => {
await fetchDailyHostsCount()
await fetchAllHostsCount()
await fetchAllHostsCount(1)
})
async function updataDays(val) {
await fetchAllHostsCount(val)
}
// import { useGlobalWebSocket } from '@/components/useGlobalWebSocket'
// let messageList = useGlobalWebSocket().messageList
// console.log(messageList.value)
@@ -552,11 +562,11 @@ async function fetchDailyHostsCount() {
}
// ✅ 抽成函数:每天所有员工数量(用于多人柱状图)
async function fetchAllHostsCount() {
async function fetchAllHostsCount(val) {
// 以“传入的用户 id”为准展示顺序也按这里来
const ids = allocationUserList.value.map(item => item.value)
const res = await EmployeeHostsApi.employeeCompleteBarChart(ids)
const res = await EmployeeHostsApi.employeeCompleteBarChart(ids, val)
const rawList: EmpBarItem[] = Array.isArray(res) ? res : (res?.data ?? [])
// 补齐后端未返回的用户为 0