main
chenshuichuan 2 years ago
parent 27a84369c7
commit 93ee24b7ce

@ -0,0 +1,35 @@
import request from '@/config/axios'
// date": "2024-06-25",
// "week": "2",
// "dayweather": "晴",
// "nightweather": "晴",
// "daytemp": "29",
// "nighttemp": "15",
// "daywind": "东南",
// "nightwind": "东南",
// "daypower": "1-3",
// "nightpower": "1-3"
// 天气 VO
export interface WeatherVO {
date: string
week: string,
dayweather: string,
nightweather: string,
daytemp: string,
nighttemp: string,
daywind: string,
nightwind: string,
daypower: string,
nightpower: string
}
// 生产计划 API
export const HomeApi = {
// 查询天气
getWeatherInfo: async () => {
return await request.get({ url: `/home/info/weatherInfo`})
},
}

@ -194,7 +194,7 @@ export default {
},
workplace: {
welcome: '你好',
happyDay: '祝你开心每一天!',
happyDay: '!',
toady: '今日晴',
notice: '通知公告',
project: '项目数',

@ -3,7 +3,7 @@
<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">
<el-col :xl="8" :lg="8" :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="" />
@ -12,43 +12,33 @@
<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 v-if="weatherData.isEnable" class="mt-10px text-14px text-gray-500">
{{ weatherData.city }}白天{{ todayWeather.dayweather }}晚上{{ todayWeather.nightweather }}
</div>
<div v-if="weatherData.isEnable" class="mt-10px text-14px text-gray-500">
气温{{ todayWeather.daytemp }}°C~{{ todayWeather.nighttemp }}°C {{ todayWeather.daywind }}{{ todayWeather.daypower }}
</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>
<el-col :xl="8" :lg="8" :md="12" :sm="24" :xs="24">
<div class="flex items-center">
<el-col v-for="item in weatherList.slice(1, 4)" :key="item.date" :xl="12" :lg="12" :md="12" :sm="12" :xs="12">
<div>
<div class="text-16px">
{{ item.date }}
</div>
<div class="mt-10px text-14px text-gray-500">
白天{{ item.dayweather }}晚上{{ item.nightweather }}气温{{ item.daytemp }}°C~{{ item.nighttemp }}°C
{{ item.daywind }}{{ item.daypower }}
</div>
</div>
</el-col>
</div>
</el-col>
<el-col :xl="8" :lg="8" :md="12" :sm="24" :xs="24">
<div>
</div>
</el-col>
</el-row>
@ -180,6 +170,8 @@ 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 {HomeApi} from "@/api/home/info";
import {WeatherVO} from "@/api/home/info";
defineOptions({ name: 'Home' })
@ -197,6 +189,18 @@ let totalSate = reactive<WorkplaceTotal>({
todo: 0
})
const weatherList = ref<WeatherVO[]>([])
let weatherData = null
let todayWeather = null
/** 初始化 **/
onMounted(async () => {
//
weatherData = await HomeApi.getWeatherInfo()
weatherList.value = weatherData.casts
if(weatherData.isEnable && weatherList)
todayWeather = weatherList.value[0];
})
const getCount = async () => {
const data = {
project: 40,

Loading…
Cancel
Save