oa-ui/src/views/Home/Index.vue
2024-09-19 13:34:43 +08:00

716 lines
24 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<el-card shadow="never" style="margin-bottom: 10px;height: 300px">
<el-carousel :interval="4000" type="card" height="300px">
<el-carousel-item v-for="item in filteredList" :key="item.imgId">
<el-image style="width: 100%; height: 100%" :src="imgUrl+item.imgImg" alt="无图片" :title="item.imgName"/>
</el-carousel-item>
</el-carousel>
</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" style="margin-bottom: 10px; margin-top: 10px">
<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>
<!-- <el-card shadow="never" style="margin-bottom: 10px; margin-top: 8px">-->
<!-- <el-carousel :interval="4000" type="card" height="200px">-->
<!-- <el-carousel-item v-for="item in image" :key="item.id">-->
<!-- <el-image style="width: 100%; height: 100%" :src="item.src" alt="无图片" :title="item.name"/>-->
<!-- </el-carousel-item>-->
<!-- </el-carousel>-->
<!-- </el-card>-->
<el-card shadow="never">
<template #header>
<div class="h-3 flex justify-between">
<!-- <span>{{ t('workplace.project') }}</span>-->
<span>数据统计</span>
<!-- <el-link-->
<!-- type="primary"-->
<!-- :underline="false"-->
<!-- href="http://localhost/index"-->
<!-- target="_blank"-->
<!-- >-->
<!-- {{ t('action.more') }}-->
<!-- </el-link>-->
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col
v-for="(item, index) in dataList"
:key="`card-${index}`"
:xl="8"
:lg="8"
:md="8"
:sm="24"
:xs="24"
>
<el-card shadow="hover" :style="{backgroundColor: item.color}" class="mr-5px mt-5px">
<!-- <div class="flex items-center">-->
<!-- <Icon :icon="item.icon" :size="25" class="mr-8px" />-->
<!-- <span class="text-16px">{{ item.name }}</span>-->
<!-- </div>-->
<!-- <div class="mt-12px text-9px 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>-->
<div class="flex items-center">
<span class="text-20px">{{ item.name }}</span>
</div>
<div class="mt-12px text-16px text-gray-400">{{ item.infoCo2e }}</div>
<div class="mt-12px flex justify-between text-12px text-gray-400">
<span>{{ item.dAn }}</span>
<span>{{ item.time }}</span>
</div>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
<el-card shadow="never" class="mt-8px">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-8px">
<el-skeleton :loading="loading" animated>
<Echart :options="pieOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-8px">
<el-skeleton :loading="loading" animated>
<Echart :options="barOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
<el-card shadow="never">
<template #header>
<div class="h-3 flex justify-between">
<!-- <span>{{ t('workplace.shortcutOperation') }}</span>-->
<span>未完成项目</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">-->
<el-col>
<div class="flex items-center">
<!-- <Icon :icon="item.icon" class="mr-8px" />-->
<!-- <el-link type="default" :underline="false" @click="setWatermark(item.name)">-->
<!--&lt;!&ndash; {{ item.name }}&ndash;&gt;-->
<!-- Test-->
<!-- </el-link>-->
<el-table
:data="list2"
:row-class-name="tableRowClassName"
stripe
style="width:100%"
height="300"
>
<el-table-column
fixed
prop="pjEtime"
label="预计日期"
align="center"
:formatter="dateFormatter2"
style="width: 20%"
/>
<el-table-column
prop="pjName"
label="标题"
style="width: 30%"
/>
<el-table-column
prop="pjType"
label="类别"
style="width: 20%"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.HOME_PJ_TYPE" :value="scope.row.pjType" />
</template>
</el-table-column>
<el-table-column
prop="pjDept"
label="部门"
style="width: 20%">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HOME_PJ_DEPT" :value="scope.row.pjDept" />
</template>
</el-table-column>
<el-table-column
prop="pjNumber"
label="人数"
style="width: 10%"
/>
</el-table>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-8px">
<el-card shadow="never" class="mt-8px" style="margin-bottom: 10px">
<template #header>
<div class="h-3 flex justify-between">
<span>{{ t('workplace.notice') }}</span>
<!-- <el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>-->
</div>
</template>
<el-skeleton :loading="loading" animated>
<div v-for="(item, index) in filteredList2" :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" @click="openDialog(item.contentType,item.imgId)">
<dict-tag :type="DICT_TYPE.HOME_CONTENT_STATUS" :value="item.contentType" /> :
{{ item.imgName }}
</div>
<div class="mt-16px text-12px text-gray-400">
{{ formatTime(item.imgCreatetime, 'yyyy-MM-dd') }}
</div>
</div>
</div>
<el-divider />
</div>
</el-skeleton>
</el-card>
<el-card shadow="never" style="margin-bottom: 10px">
<template #header>
<div class="h-3 flex justify-between">
<!-- <span>{{ t('workplace.shortcutOperation') }}</span>-->
<span>完成项目</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">-->
<el-col>
<div class="flex items-center">
<!-- <Icon :icon="item.icon" class="mr-8px" />-->
<!-- <el-link type="default" :underline="false" @click="setWatermark(item.name)">-->
<!--&lt;!&ndash; {{ item.name }}&ndash;&gt;-->
<!-- Test-->
<!-- </el-link>-->
<el-table
:data="list2"
:row-class-name="tableRowClassName2"
stripe
style="width:100%"
height="300"
><el-table-column
fixed
prop="pjEtime"
label="完成日期"
align="center"
:formatter="dateFormatter2"
style="width: 20%"
/>
<el-table-column
prop="pjName"
label="标题"
style="width: 30%"
/>
<el-table-column
prop="pjType"
label="类别"
style="width: 20%"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.HOME_PJ_TYPE" :value="scope.row.pjType" />
</template>
</el-table-column>
<el-table-column
prop="pjDept"
label="部门"
style="width: 20%">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HOME_PJ_DEPT" :value="scope.row.pjDept" />
</template>
</el-table-column>
<el-table-column
prop="pjNumber"
label="人数"
style="width: 10%"
/>
</el-table>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</el-col>
</el-row>
<Dialog :title="dialogTitle" v-model="dialogVisible" style="width: 85%">
<el-form >
<el-form-item >
<span style="font-size: 20px; font-weight: bold;">{{formData.imgName}}</span>
<el-divider style="border-top: none; margin: 0;"/>
<span style="font-size: 12px">发布时间: {{formatTime(formData.imgCreatetime,'yyyy-MM-dd')}}</span>
<el-divider style="margin-top: 10px"/>
<span style="line-height: 1.2" v-html="formData.imgContent"></span>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogVisible = false">确 定</el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import { set } from 'lodash-es'
import { EChartsOption } from 'echarts'
import { formatTime } from '@/utils'
// import mn2 from '@/assets/imgs/Home-image/02.png'
// import mn3 from '@/assets/imgs/Home-image/03.png'
// import mn4 from '@/assets/imgs/Home-image/04.png'
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 {DataInfoApi, DataInfoVO} from "@/api/home/datainfo";
import {pjApi, pjVO} from "@/api/home/homepj";
import {dateFormatter, dateFormatter2} from "@/utils/formatTime";
import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
import {imgApi, imgVO} from "@/api/home/homeimg";
import a from "../../../dist/assets/a-Bqc4tEO8";
defineOptions({ name: 'Home' })
const { t } = useI18n()
const userStore = useUserStore()
// const { setWatermark } = useWatermark()
const loading = ref(false)
const list = ref<DataInfoVO[]>([]) // 列表的数据
const list2 = ref<pjVO[]>([]) // 列表的数据
const list3 = ref<imgVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const avatar = userStore.getUser.avatar
const username = userStore.getUser.nickname
const allData = ref({});
const allData2 = ref({});
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
// 获取统计数
let totalSate = reactive<WorkplaceTotal>({
project: 0,
access: 0,
todo: 0
})
const formData = ref({
imgId: undefined,
imgName: undefined,
imgCreatetime: undefined,
imgImg: [],
imgContent: undefined,
contentType: undefined,
imgStatus: undefined,
contentStatus: undefined,
})
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const openDialog = async (type:number,id?:number) => {
dialogVisible.value = true
dialogTitle.value = type===1?'公告':'通知'
resetForm()
if (id) {
formData.value = await imgApi.getimg(id)
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
imgId: undefined,
imgName: undefined,
imgCreatetime: undefined,
imgImg: undefined,
imgContent: undefined,
contentType: undefined,
imgStatus: undefined,
contentStatus: undefined,
}
}
const filteredList = computed(() => {
return list3.value.filter(item => item.imgStatus !== 0 && item.contentStatus!==0);
});
const filteredList2 = computed(() => {
return list3.value.filter(item => item.contentStatus !== 0 );
});
const queryParams2 = reactive({
pageNo: 1,
pageSize: 50,
pjName: undefined,
pjDone: undefined,
pjDescribe: undefined,
pjContent: undefined,
pjType: undefined,
pjEtime: [],
pjVtime: [],
pjDept: undefined,
pjNumber: undefined,
createTime: [],
})
const queryParams3 = reactive({
pageNo: 1,
pageSize: 20,
imgId: undefined,
imgName: undefined,
imgCreatetime: [],
imgImg: undefined,
imgContent: undefined,
contentType: undefined,
imgStatus: undefined,
contentStatus: undefined,
createTime: [],
})
const tableRowClassName = ({ row }) => {
return row.pjDone === 1 ? 'warning-row' : '';
};
const tableRowClassName2 = ({ row }) => {
return row.pjDone === 0 ? 'warning-row' : '';
};
const imgUrl = "//images.weserv.nl/?url="
// const image = [
// {id: 1, src: mn2, name: '02'},
// {id: 2, src: mn3, name: '03'},
// {id: 3, src: mn4, name: '04'},
// ]
const dataList = computed(() => [
{ name: '碳排放', infoCo2e: allData.value.infoCo2e, dAn: '吨', time: '2024-07-05', color: '#e6eae3' },
{ name: '用水量', infoCo2e: allData.value.infoWater, dAn: '吨', time: '2024-07-05', color: '#ecf5ff' },
{ name: '环保投入', infoCo2e: allData.value.infoEcom, dAn: '万元', time: '2024-07-05', color: '#f0f9eb' },
{ name: '技能培训', infoCo2e: allData.value.infoTraining, dAn: '人', time: '2024-07-05', color: '#fef0f0' },
{ name: '污染物质', infoCo2e: allData.value.infoPollution, dAn: '吨', time: '2024-07-05', color: '#c0c4cc' },
{ name: '研发费用', infoCo2e: allData.value.infoRd, dAn: '万元', time: '2024-07-05', color: '#fdf6ec' }
]);
const dataList2 = computed(() => [
{E: allData2.value[0].infoEnvironment, S: allData2.value[0].infoSociety, G: allData2.value[0].infoGovern},
{E: allData2.value[1].infoEnvironment, S: allData2.value[1].infoSociety, G: allData2.value[1].infoGovern},
{E: allData2.value[2].infoEnvironment, S: allData2.value[2].infoSociety, G: allData2.value[2].infoGovern},
]);
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await DataInfoApi.getDataInfoPage(queryParams)
const data2 = await pjApi.getpjPage(queryParams2)
const data3 = await imgApi.getimgPage(queryParams3)
allData.value=data.list[0]
allData2.value=data.list
list.value = data.list
list2.value = data2.list
list3.value = data3.list
total.value = data.total
await getWeeklyUserActivity()
} finally {
loading.value = false
}
}
const queryParams = reactive({
pageNo: 1,
pageSize: 3,
infoYear: undefined,
infoCo2e: undefined,
infoWater: undefined,
infoPollution: undefined,
infoEcom: undefined,
infoTraining: undefined,
infoRd: undefined,
infoEnvironment: undefined,
infoSociety: undefined,
infoGovern: undefined,
createTime: [],
})
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: 'ruoyi-vue-pro',
icon: 'akar-icons:github-fill',
message: 'https://github.com/YunaiV/ruoyi-vue-pro',
personal: 'Spring Boot 单体架构',
time: new Date()
},
{
name: 'yudao-ui-admin-vue3',
icon: 'logos:vue',
message: 'https://github.com/yudaocode/yudao-ui-admin-vue3',
personal: 'Vue3 + element-plus',
time: new Date()
},
{
name: 'yudao-ui-admin-vben',
icon: 'logos:vue',
message: 'https://github.com/yudaocode/yudao-ui-admin-vben',
personal: 'Vue3 + vben(antd)',
time: new Date()
},
{
name: 'yudao-cloud',
icon: 'akar-icons:github',
message: 'https://github.com/YunaiV/yudao-cloud',
personal: 'Spring Cloud 微服务架构',
time: new Date()
},
{
name: 'yudao-ui-mall-uniapp',
icon: 'logos:vue',
message: 'https://github.com/yudaocode/yudao-ui-admin-uniapp',
personal: 'Vue3 + uniapp',
time: new Date()
},
{
name: 'yudao-ui-admin-vue2',
icon: 'logos:vue',
message: 'https://github.com/yudaocode/yudao-ui-admin-vue2',
personal: 'Vue2 + element-ui',
time: new Date()
}
]
projects = Object.assign(projects, data)
}
// 获取通知公告
let notice = reactive<Notice[]>([])
const getNotice = async () => {
const data = [
{
title: '2024年4月7日罗平县生态环境保护综合行政执法大队对你单位进行了调查发现你单位实施了以下生态环境违法行为',
// title: '系统支持 JDK 8/17/21Vue 2/3',
type: '通知',
keys: ['通知'],
date: new Date()
},
{
title: '2024年4月7日罗平县生态环境保护综合行政执法大队对你单位进行了调查发现你单位实施了以下生态环境违法行为',
// title: '后端提供 Spring Boot 2.7/3.2 + Cloud 双架构',
type: '公告',
keys: ['公告'],
date: new Date()
},
{
title: '2024年4月7日罗平县生态环境保护综合行政执法大队对你单位进行了调查发现你单位实施了以下生态环境违法行为',
// title: '全部开源,个人与企业可 100% 直接使用,无需授权',
type: '通知',
keys: ['通知'],
date: new Date()
},
{
title: '2024年4月7日罗平县生态环境保护综合行政执法大队对你单位进行了调查发现你单位实施了以下生态环境违法行为',
// title: '国内使用最广泛的快速开发平台,超 300+ 人贡献',
type: '公告',
keys: ['公告', '最广泛'],
date: new Date()
}
]
notice = Object.assign(notice, data)
}
// 获取快捷入口
let shortcut = reactive<Shortcut[]>([])
const getShortcut = async () => {
const data = [
{
name: 'Github',
icon: 'akar-icons:github-fill',
url: 'github.io'
},
{
name: 'Vue',
icon: 'logos:vue',
url: 'vuejs.org'
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
url: 'https://vitejs.dev/'
},
{
name: 'Angular',
icon: 'logos:angular-icon',
url: 'github.io'
},
{
name: 'React',
icon: 'logos:react',
url: 'github.io'
},
{
name: 'Webpack',
icon: 'logos:webpack',
url: 'github.io'
}
]
shortcut = Object.assign(shortcut, data)
}
// 用户来源
const getUserAccessSource = async () => {
// const data = [
// { value: 335, name: 'analysis.directAccess' },
// ]
const data = [
{ value: 335, name: '社会' },
{ value: 310, name: '环境' },
{ value: 234, name: '治理' },
]
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
// 周活跃量
const getWeeklyUserActivity = async () => {
// const data = [
// { value: 13253, name: 'analysis.monday' },
// ]
const data = [
{ name: '环境评分' },
{ name: '社会评分' },
{ name: '治理评分' },
]
set(
barOptionsData,
'xAxis.data',
data.map((v) => t(v.name))
)
set(barOptionsData, 'series', [
{
name: '2022',
data: [dataList2.value[0].E, dataList2.value[0].E, dataList2.value[0].E],
type: 'bar'
},
{
name: '2023',
data: [dataList2.value[1].S, dataList2.value[1].S, dataList2.value[1].S],
type: 'bar'
},
{
name: '2024',
data: [dataList2.value[2].G, dataList2.value[2].G, dataList2.value[2].G],
type: 'bar'
}
])
}
const getAllApi = async () => {
await Promise.all([
getCount(),
getProject(),
getNotice(),
getShortcut(),
getUserAccessSource(),
getWeeklyUserActivity()
])
loading.value = false
}
getAllApi()
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style scoped>
.el-carousel__item h3 {
opacity: 0.75;
line-height: 200px;
margin: 0;
text-align: center;
}
</style>
<style lang="scss">
.el-table .warning-row {
display: none;
}
</style>