2025-07-01 21:08:51 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<el-row :gutter="16" justify="space-between">
|
|
|
|
|
|
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
|
<el-avatar :src="avatar" :size="70" class="mr-16px">
|
|
|
|
|
|
<img src="@/assets/imgs/avatar.gif" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class="text-20px">
|
|
|
|
|
|
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="mt-10px text-14px text-gray-500">
|
|
|
|
|
|
{{ t('workplace.toady') }},20℃ - 32℃!
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<!-- <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
|
|
|
|
|
|
<div class="h-70px flex items-center justify-end lt-sm:mt-10px">
|
|
|
|
|
|
<div class="px-8px text-right">
|
|
|
|
|
|
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.project') }}</div>
|
|
|
|
|
|
<CountTo class="text-20px" :start-val="0" :end-val="totalSate.project" :duration="2600" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-divider direction="vertical" />
|
|
|
|
|
|
<div class="px-8px text-right">
|
|
|
|
|
|
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.toDo') }}</div>
|
|
|
|
|
|
<CountTo class="text-20px" :start-val="0" :end-val="totalSate.todo" :duration="2600" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-divider direction="vertical" border-style="dashed" />
|
|
|
|
|
|
<div class="px-8px text-right">
|
|
|
|
|
|
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.access') }}</div>
|
|
|
|
|
|
<CountTo class="text-20px" :start-val="0" :end-val="totalSate.access" :duration="2600" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-col> -->
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<el-row class="mt-8px" :gutter="8" justify="space-between">
|
|
|
|
|
|
<el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-8px">
|
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
<div class="h-3 flex justify-between">
|
|
|
|
|
|
<span>{{ t('workplace.project') }}</span>
|
|
|
|
|
|
<!-- <el-link type="primary" :underline="false" href="https://github.com/yudaocode" target="_blank">
|
|
|
|
|
|
{{ t('action.more') }}
|
|
|
|
|
|
</el-link> -->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-col v-for="(item, index) in projects" :key="`card-${index}`" :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
|
|
|
|
|
|
<el-card shadow="hover" class="mr-5px mt-5px cursor-pointer" @click="handleProjectClick(item.message)">
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
|
<Icon :icon="item.icon" :size="25" class="mr-8px" :style="{ color: item.color }" />
|
|
|
|
|
|
<span class="text-16px">{{ item.name }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="mt-12px text-12px text-gray-400">{{ t(item.message) }}</div>
|
|
|
|
|
|
<div class="mt-12px flex justify-between text-12px text-gray-400">
|
|
|
|
|
|
<span>{{ item.personal }}</span>
|
|
|
|
|
|
<span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
2025-08-08 14:38:06 +08:00
|
|
|
|
<el-card shadow="never" class="mt-8px">
|
|
|
|
|
|
|
2025-09-09 20:33:33 +08:00
|
|
|
|
<!-- <div style="display: flex; width: 50%;"
|
2025-08-08 14:38:06 +08:00
|
|
|
|
v-if="wsCache.get('roleRouters').find(item => item.id === 1)?.children.find(item => item.id === 100)">
|
|
|
|
|
|
|
|
|
|
|
|
<el-select v-model="allocationUser" :placeholder="t('newHosts.placeAllocationUser')" clearable
|
|
|
|
|
|
@change="getUserAccessSource(allocationUser)">
|
|
|
|
|
|
<el-option v-for="(user, index) in allocationUserList" :key="index" :label="user.label"
|
|
|
|
|
|
:value="user.value" />
|
|
|
|
|
|
</el-select>
|
2025-09-09 20:33:33 +08:00
|
|
|
|
</div> -->
|
2025-08-08 14:38:06 +08:00
|
|
|
|
|
2025-07-01 21:08:51 +08:00
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<el-row :gutter="20" justify="space-between">
|
2025-09-09 20:33:33 +08:00
|
|
|
|
<!-- <el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
|
2025-07-01 21:08:51 +08:00
|
|
|
|
<el-card shadow="hover" class="mb-8px">
|
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<Echart :options="pieOptionsData" :height="280" />
|
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card>
|
2025-09-09 20:33:33 +08:00
|
|
|
|
</el-col> -->
|
|
|
|
|
|
<el-col
|
|
|
|
|
|
v-if="wsCache.get('roleRouters').find(item => item.id === 1)?.children.find(item => item.id === 100)"
|
2025-10-17 15:37:42 +08:00
|
|
|
|
:xl="20" :lg="20" :md="24" :sm="24" :xs="24">
|
2025-07-01 21:08:51 +08:00
|
|
|
|
<el-card shadow="hover" class="mb-8px">
|
2025-10-17 15:37:42 +08:00
|
|
|
|
<el-select style="width: 200px;" v-model="days" @change="updataDays">
|
2025-10-17 15:53:12 +08:00
|
|
|
|
<el-option :value="1" label="当日">当日</el-option>
|
|
|
|
|
|
<el-option :value="7" label="近7日">近7日</el-option>
|
2025-10-17 15:37:42 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
|
2025-07-01 21:08:51 +08:00
|
|
|
|
<el-skeleton :loading="loading" animated>
|
2025-10-17 15:37:42 +08:00
|
|
|
|
<Echart style="width: 100%;" :options="barOptionsData" :height="280" />
|
2025-07-01 21:08:51 +08:00
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card>
|
2025-09-09 20:33:33 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col v-else :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
|
|
|
|
|
|
<el-card shadow="hover" class="mb-8px">
|
|
|
|
|
|
<div>当日建联数量</div>
|
|
|
|
|
|
{{ HostsOperationNum }}
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</el-col>
|
2025-07-01 21:08:51 +08:00
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-skeleton>
|
2025-08-08 14:38:06 +08:00
|
|
|
|
</el-card>
|
2025-07-01 21:08:51 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-8px">
|
|
|
|
|
|
<!-- 快捷入口 -->
|
|
|
|
|
|
<!-- <el-card shadow="never">
|
2025-09-09 20:33:33 +08:00
|
|
|
|
<template #header>
|
2025-07-01 21:08:51 +08:00
|
|
|
|
<div class="h-3 flex justify-between">
|
|
|
|
|
|
<span>{{ t('workplace.shortcutOperation') }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-8px">
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
|
<Icon :icon="item.icon" class="mr-8px" :style="{ color: item.color }" />
|
|
|
|
|
|
<el-link type="default" :underline="false" @click="handleShortcutClick(item.url)">
|
|
|
|
|
|
{{ item.name }}
|
|
|
|
|
|
</el-link>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card> -->
|
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
<div class="h-3 flex justify-between">
|
|
|
|
|
|
<span>{{ t('workplace.notice') }}</span>
|
|
|
|
|
|
<!-- <el-button @click="test">test</el-button> -->
|
|
|
|
|
|
<!-- <el-link type="primary" :underline="false">{{ t('action.more') }}</el-link> -->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
|
<div v-for="(item, index) in notice" :key="`dynamics-${index}`">
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
|
<el-avatar :src="avatar" :size="35" class="mr-16px">
|
|
|
|
|
|
<img src="@/assets/imgs/avatar.gif" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div class="text-14px">
|
|
|
|
|
|
<Highlight :keys="item.keys.map((v) => t(v))">
|
|
|
|
|
|
{{ item.type }} : {{ item.title }}
|
|
|
|
|
|
</Highlight>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="mt-16px text-12px text-gray-400">
|
|
|
|
|
|
{{ formatTime(item.date, 'yyyy-MM-dd') }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-divider />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import { set } from 'lodash-es'
|
|
|
|
|
|
import { EChartsOption } from 'echarts'
|
|
|
|
|
|
import { formatTime } from '@/utils'
|
|
|
|
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
|
|
|
// import { useWatermark } from '@/hooks/web/useWatermark'
|
|
|
|
|
|
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
|
|
|
|
|
|
import { pieOptions, barOptions } from './echarts-data'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
2025-08-08 14:38:06 +08:00
|
|
|
|
import { getComplete, getEmployeeComplete } from '@/api/system/user'
|
|
|
|
|
|
import { useCache } from '@/hooks/web/useCache'
|
|
|
|
|
|
import { getSimpleUserListPage, getSimpleUserList } from '@/api/system/user'
|
2025-09-09 20:33:33 +08:00
|
|
|
|
import { EmployeeHostsApi } from '@/api/server/employeehosts'
|
|
|
|
|
|
import { ref, reactive, onMounted, onActivated } from 'vue'
|
2025-10-17 15:37:42 +08:00
|
|
|
|
import WxMusic from '../mp/components/wx-music'
|
2025-09-09 20:33:33 +08:00
|
|
|
|
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)) {
|
2025-10-17 15:37:42 +08:00
|
|
|
|
await fetchAllHostsCount(1)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
await fetchDailyHostsCount()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
2025-10-17 15:53:12 +08:00
|
|
|
|
let days = ref(1)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
// 每次页面“再次显示”时都会触发(前提:该路由组件被 keep-alive 缓存)
|
|
|
|
|
|
onActivated(async () => {
|
|
|
|
|
|
await fetchDailyHostsCount()
|
2025-10-17 15:37:42 +08:00
|
|
|
|
await fetchAllHostsCount(1)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
})
|
2025-10-17 15:37:42 +08:00
|
|
|
|
|
|
|
|
|
|
async function updataDays(val) {
|
|
|
|
|
|
await fetchAllHostsCount(val)
|
|
|
|
|
|
}
|
2025-07-01 21:08:51 +08:00
|
|
|
|
// import { useGlobalWebSocket } from '@/components/useGlobalWebSocket'
|
|
|
|
|
|
// let messageList = useGlobalWebSocket().messageList
|
|
|
|
|
|
// console.log(messageList.value)
|
2025-08-08 14:38:06 +08:00
|
|
|
|
const { wsCache } = useCache()
|
|
|
|
|
|
let allocationUser = ref('') //选中的分配用户
|
|
|
|
|
|
let allocationUserList = ref([
|
|
|
|
|
|
{
|
|
|
|
|
|
label: '分配用户1',
|
|
|
|
|
|
value: 1
|
|
|
|
|
|
}
|
|
|
|
|
|
]) //选中的分配用户
|
2025-07-01 21:08:51 +08:00
|
|
|
|
|
|
|
|
|
|
// function test() {
|
|
|
|
|
|
// console.log(messageList.value)
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'Index' })
|
2025-09-09 20:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
// console.log(data)
|
2025-07-01 21:08:51 +08:00
|
|
|
|
// const { open } = useGlobalWebSocket()
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
// const { setWatermark } = useWatermark()
|
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
|
const avatar = userStore.getUser.avatar
|
|
|
|
|
|
const username = userStore.getUser.nickname
|
|
|
|
|
|
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
|
|
|
|
|
|
// 获取统计数
|
|
|
|
|
|
let totalSate = reactive<WorkplaceTotal>({
|
|
|
|
|
|
project: 0,
|
|
|
|
|
|
access: 0,
|
|
|
|
|
|
todo: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const getCount = async () => {
|
|
|
|
|
|
const data = {
|
|
|
|
|
|
project: 40,
|
|
|
|
|
|
access: 2340,
|
|
|
|
|
|
todo: 10
|
|
|
|
|
|
}
|
|
|
|
|
|
totalSate = Object.assign(totalSate, data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取项目数
|
|
|
|
|
|
let projects = reactive<Project[]>([])
|
|
|
|
|
|
const getProject = async () => {
|
|
|
|
|
|
const data = [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'YOLO助手',
|
|
|
|
|
|
icon: 'simple-icons:springboot',
|
|
|
|
|
|
message: 'www.yolozs.com/',
|
|
|
|
|
|
personal: '全球tiktok经纪人必备高效管理神器!',
|
|
|
|
|
|
time: new Date('2025-01-02'),
|
|
|
|
|
|
color: '#6DB33F'
|
|
|
|
|
|
},
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: '找大哥助手',
|
|
|
|
|
|
// icon: 'ep:element-plus',
|
|
|
|
|
|
// message: 'www.yolozs.com/',
|
|
|
|
|
|
// personal: '全球tiktok经纪人必备高效管理神器!',
|
|
|
|
|
|
// time: new Date('2025-02-03'),
|
|
|
|
|
|
// color: '#409EFF'
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: 'yudao-ui-mall-uniapp',
|
|
|
|
|
|
// icon: 'icon-park-outline:mall-bag',
|
|
|
|
|
|
// message: 'github.com/yudaocode/yudao-ui-mall-uniapp',
|
|
|
|
|
|
// personal: 'Vue3 + uniapp 商城手机端',
|
|
|
|
|
|
// time: new Date('2025-03-04'),
|
|
|
|
|
|
// color: '#ff4d4f'
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: 'yudao-cloud',
|
|
|
|
|
|
// icon: 'material-symbols:cloud-outline',
|
|
|
|
|
|
// message: 'github.com/YunaiV/yudao-cloud',
|
|
|
|
|
|
// personal: 'Spring Cloud 微服务架构',
|
|
|
|
|
|
// time: new Date('2025-04-05'),
|
|
|
|
|
|
// color: '#1890ff'
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: 'yudao-ui-admin-vben',
|
|
|
|
|
|
// icon: 'devicon:antdesign',
|
|
|
|
|
|
// message: 'github.com/yudaocode/yudao-ui-admin-vben',
|
|
|
|
|
|
// personal: 'Vue3 + vben5(antd) 管理后台',
|
|
|
|
|
|
// time: new Date('2025-05-06'),
|
|
|
|
|
|
// color: '#e18525'
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: 'yudao-ui-admin-uniapp',
|
|
|
|
|
|
// icon: 'ant-design:mobile',
|
|
|
|
|
|
// message: 'github.com/yudaocode/yudao-ui-admin-uniapp',
|
|
|
|
|
|
// personal: 'Vue3 + uniapp 管理手机端',
|
|
|
|
|
|
// time: new Date('2025-06-01'),
|
|
|
|
|
|
// color: '#2979ff'
|
|
|
|
|
|
// }
|
|
|
|
|
|
]
|
|
|
|
|
|
projects = Object.assign(projects, data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取通知公告
|
|
|
|
|
|
let notice = reactive<Notice[]>([])
|
|
|
|
|
|
const getNotice = async () => {
|
|
|
|
|
|
const data = [
|
|
|
|
|
|
// {
|
|
|
|
|
|
// title: '系统支持 JDK 8/17/21,Vue 2/3',
|
|
|
|
|
|
// type: '技术兼容性',
|
|
|
|
|
|
// keys: ['JDK', 'Vue'],
|
|
|
|
|
|
// date: new Date()
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// title: '后端提供 Spring Boot 2.7/3.2 + Cloud 双架构',
|
|
|
|
|
|
// type: '架构灵活性',
|
|
|
|
|
|
// keys: ['Boot', 'Cloud'],
|
|
|
|
|
|
// date: new Date()
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// title: '全部开源,个人与企业可 100% 直接使用,无需授权',
|
|
|
|
|
|
// type: '开源免授权',
|
|
|
|
|
|
// keys: ['无需授权'],
|
|
|
|
|
|
// date: new Date()
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// title: '国内使用最广泛的快速开发平台,远超 10w+ 企业使用',
|
|
|
|
|
|
// type: '广泛企业认可',
|
|
|
|
|
|
// keys: ['最广泛', '10w+'],
|
|
|
|
|
|
// date: new Date()
|
|
|
|
|
|
// }
|
|
|
|
|
|
]
|
|
|
|
|
|
notice = Object.assign(notice, data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取快捷入口
|
|
|
|
|
|
let shortcut = reactive<Shortcut[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
const getShortcut = async () => {
|
|
|
|
|
|
const data = [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '首页',
|
|
|
|
|
|
icon: 'ion:home-outline',
|
|
|
|
|
|
url: '/',
|
|
|
|
|
|
color: '#1fdaca'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '商城中心',
|
|
|
|
|
|
icon: 'ep:shop',
|
|
|
|
|
|
url: '/mall/home',
|
|
|
|
|
|
color: '#ff6b6b'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'AI 大模型',
|
|
|
|
|
|
icon: 'tabler:ai',
|
|
|
|
|
|
url: '/ai/chat',
|
|
|
|
|
|
color: '#7c3aed'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ERP 系统',
|
|
|
|
|
|
icon: 'simple-icons:erpnext',
|
|
|
|
|
|
url: '/erp/home',
|
|
|
|
|
|
color: '#3fb27f'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'CRM 系统',
|
|
|
|
|
|
icon: 'simple-icons:civicrm',
|
|
|
|
|
|
url: '/crm/backlog',
|
|
|
|
|
|
color: '#4daf1bc9'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'IoT 物联网',
|
|
|
|
|
|
icon: 'fa-solid:hdd',
|
|
|
|
|
|
url: '/iot/home',
|
|
|
|
|
|
color: '#1a73e8'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
shortcut = Object.assign(shortcut, data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 用户来源
|
2025-08-08 14:38:06 +08:00
|
|
|
|
const getUserAccessSource = async (id) => {
|
|
|
|
|
|
const res = id ? await getEmployeeComplete(id) : await getComplete()
|
|
|
|
|
|
const completeData = res ?? { unfinishedNum: 0, finishedNum: 0 }
|
|
|
|
|
|
console.log('completeData', completeData)
|
2025-07-01 21:08:51 +08:00
|
|
|
|
const data = [
|
2025-08-08 14:38:06 +08:00
|
|
|
|
{ value: completeData.unfinishedNum, name: 'analysis.noAlliance' },
|
|
|
|
|
|
{ value: completeData.finishedNum, name: 'analysis.alreadyJianlian' },
|
|
|
|
|
|
// { value: 234, name: 'analysis.allianceAdvertising' },
|
|
|
|
|
|
// { value: 135, name: 'analysis.videoAdvertising' },
|
|
|
|
|
|
// { value: 1548, name: 'analysis.searchEngines' }
|
2025-07-01 21:08:51 +08:00
|
|
|
|
]
|
|
|
|
|
|
set(
|
|
|
|
|
|
pieOptionsData,
|
|
|
|
|
|
'legend.data',
|
|
|
|
|
|
data.map((v) => t(v.name))
|
|
|
|
|
|
)
|
|
|
|
|
|
pieOptionsData!.series![0].data = data.map((v) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
name: t(v.name),
|
|
|
|
|
|
value: v.value
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
|
2025-09-09 20:33:33 +08:00
|
|
|
|
type EmpBarItem = {
|
|
|
|
|
|
userId: number
|
|
|
|
|
|
finishedNum: number | null
|
|
|
|
|
|
totalNum: number | null
|
|
|
|
|
|
unfinishedNum: number | null
|
|
|
|
|
|
}
|
|
|
|
|
|
// 传入希望展示的用户 id 列表 + 后端原始返回,补齐未返回的用户为 0
|
|
|
|
|
|
function mergeZeroUsers(ids: number[], resList: EmpBarItem[]): EmpBarItem[] {
|
|
|
|
|
|
const map = new Map<number, EmpBarItem>(resList.map(it => [it.userId, it]))
|
|
|
|
|
|
return ids.map(id => {
|
|
|
|
|
|
const it = map.get(id)
|
|
|
|
|
|
const finished = it?.finishedNum ?? 0
|
|
|
|
|
|
// 未建联:优先用后端给的 unfinishedNum;若没有且提供了 totalNum,则用 totalNum - finished;否则 0
|
|
|
|
|
|
const total = it?.totalNum ?? 0
|
|
|
|
|
|
const unfinished = it?.unfinishedNum ?? (it?.totalNum != null && it?.finishedNum != null
|
|
|
|
|
|
? Math.max(Number(total) - Number(finished), 0)
|
|
|
|
|
|
: 0)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
userId: id,
|
|
|
|
|
|
finishedNum: Number(finished),
|
|
|
|
|
|
totalNum: Number(total),
|
|
|
|
|
|
unfinishedNum: Number(unfinished)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// 把后端返回的数据渲染到柱状图
|
|
|
|
|
|
function updateEmployeeBarChart(list: EmpBarItem[]) {
|
|
|
|
|
|
// 建立 id -> 昵称 的映射
|
|
|
|
|
|
const id2label = new Map(allocationUserList.value.map(u => [u.value, u.label]))
|
|
|
|
|
|
const labels = list.map(it => id2label.get(it.userId) || String(it.userId))
|
|
|
|
|
|
|
|
|
|
|
|
const finished = list.map(it => it.finishedNum ?? 0)
|
|
|
|
|
|
const unfinished = list.map(it => it.unfinishedNum ?? 0)
|
2025-07-01 21:08:51 +08:00
|
|
|
|
|
2025-09-09 20:33:33 +08:00
|
|
|
|
// legend
|
|
|
|
|
|
const legendNames = []
|
|
|
|
|
|
|
|
|
|
|
|
set(barOptionsData, 'legend.data', legendNames)
|
|
|
|
|
|
set(barOptionsData, 'xAxis.data', labels)
|
|
|
|
|
|
|
2025-09-09 21:02:15 +08:00
|
|
|
|
// 1) 轴标签强制全部显示 + 不自动隐藏
|
|
|
|
|
|
set(barOptionsData, 'xAxis.axisLabel.interval', 0)
|
|
|
|
|
|
set(barOptionsData, 'xAxis.axisLabel.hideOverlap', false)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
|
2025-09-09 21:02:15 +08:00
|
|
|
|
// 2) 适当旋转,避免重叠(不想旋转可设为 0)
|
|
|
|
|
|
set(barOptionsData, 'xAxis.axisLabel.rotate', 30)
|
|
|
|
|
|
|
|
|
|
|
|
// 3) 防止被裁剪:让 grid 预留标签空间
|
|
|
|
|
|
set(barOptionsData, 'grid.containLabel', true)
|
|
|
|
|
|
set(barOptionsData, 'grid.bottom', 60) // 视情况调大/调小
|
|
|
|
|
|
set(barOptionsData, 'xAxis.axisTick.alignWithLabel', true)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set(barOptionsData, 'series', [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: t('analysis.alreadyJianlian'),
|
|
|
|
|
|
type: 'bar',
|
|
|
|
|
|
data: finished
|
|
|
|
|
|
},
|
|
|
|
|
|
// {
|
|
|
|
|
|
// name: t('analysis.noAlliance'),
|
|
|
|
|
|
// type: 'bar',
|
|
|
|
|
|
// data: unfinished
|
|
|
|
|
|
// }
|
|
|
|
|
|
])
|
|
|
|
|
|
}
|
|
|
|
|
|
// 周活跃量 图表数据
|
2025-07-01 21:08:51 +08:00
|
|
|
|
const getWeeklyUserActivity = async () => {
|
|
|
|
|
|
const data = [
|
2025-09-09 20:33:33 +08:00
|
|
|
|
{ value: HostsOperationNum.value, name: 'analysis.monday' },
|
|
|
|
|
|
|
2025-07-01 21:08:51 +08:00
|
|
|
|
]
|
|
|
|
|
|
set(
|
|
|
|
|
|
barOptionsData,
|
|
|
|
|
|
'xAxis.data',
|
|
|
|
|
|
data.map((v) => t(v.name))
|
|
|
|
|
|
)
|
|
|
|
|
|
set(barOptionsData, 'series', [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: t('analysis.activeQuantity'),
|
|
|
|
|
|
data: data.map((v) => v.value),
|
|
|
|
|
|
type: 'bar'
|
|
|
|
|
|
}
|
|
|
|
|
|
])
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getAllApi = async () => {
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
getCount(),
|
|
|
|
|
|
getProject(),
|
|
|
|
|
|
getNotice(),
|
|
|
|
|
|
getShortcut(),
|
2025-08-08 14:38:06 +08:00
|
|
|
|
getUserAccessSource(null),
|
2025-07-01 21:08:51 +08:00
|
|
|
|
getWeeklyUserActivity()
|
|
|
|
|
|
])
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleProjectClick = (message: string) => {
|
|
|
|
|
|
window.open(`https://${message}`, '_blank')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleShortcutClick = (url: string) => {
|
|
|
|
|
|
router.push(url)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-08 14:38:06 +08:00
|
|
|
|
/** 查询员工 */
|
|
|
|
|
|
const getAllocationList = async () => {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
allocationUserList.value = []
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = await getSimpleUserList()
|
|
|
|
|
|
console.log('data', data)
|
|
|
|
|
|
data.forEach((item) => {
|
|
|
|
|
|
if (wsCache.get('user').user.id == item.id) {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
allocationUserList.value.push({
|
|
|
|
|
|
label: item.nickname,
|
|
|
|
|
|
value: item.id
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
console.log(allocationUserList.value)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-09 20:33:33 +08:00
|
|
|
|
// 获取当前日期,格式为 YYYY-MM-DD
|
|
|
|
|
|
const getFormattedDate = () => {
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
return now.toISOString().split('T')[0] + ' 00:00:00'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ 抽成函数:每天数量
|
|
|
|
|
|
async function fetchDailyHostsCount() {
|
|
|
|
|
|
const res = await EmployeeHostsApi.getEmployeeHostsPage({
|
|
|
|
|
|
operationStatus: 1,
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
updateTime: getFormattedDate()
|
|
|
|
|
|
})
|
|
|
|
|
|
HostsOperationNum.value = res.total ?? 0
|
|
|
|
|
|
// 如果柱状图依赖这个值,顺便刷新一次图表数据
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ 抽成函数:每天所有员工数量(用于多人柱状图)
|
2025-10-17 15:37:42 +08:00
|
|
|
|
async function fetchAllHostsCount(val) {
|
2025-09-09 20:33:33 +08:00
|
|
|
|
// 以“传入的用户 id”为准展示(顺序也按这里来)
|
|
|
|
|
|
const ids = allocationUserList.value.map(item => item.value)
|
|
|
|
|
|
|
2025-10-17 15:37:42 +08:00
|
|
|
|
const res = await EmployeeHostsApi.employeeCompleteBarChart(ids, val)
|
2025-09-09 20:33:33 +08:00
|
|
|
|
const rawList: EmpBarItem[] = Array.isArray(res) ? res : (res?.data ?? [])
|
|
|
|
|
|
|
|
|
|
|
|
// 补齐后端未返回的用户为 0
|
|
|
|
|
|
const list = mergeZeroUsers(ids, rawList)
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染
|
|
|
|
|
|
updateEmployeeBarChart(list)
|
|
|
|
|
|
}
|
2025-07-01 21:08:51 +08:00
|
|
|
|
</script>
|