<template> <div class="cardList"> <el-row :gutter="20"> <el-col :span="12"> <div class="cardItem"> <el-radio-group v-model="tabActive" style="margin-bottom: 10px"> <el-radio-button label="current">本年</el-radio-button> <el-radio-button label="total">累计</el-radio-button> </el-radio-group> <div class="grand item"> <div class="v v1"> <div class="icon"> <img src="@/assets/images/preassess/projectCont.png" alt="" style="width: 45px; height: 45px" /> </div> <div class="v1_info"> <h2> <span class="total_text">项目总数</span> <span>{{ statisticsData[tabActive].projectCount || 0 }}</span> </h2> <div class="v1_num"> <div class="start"> <div class="start_text text">已开工</div> <div class="start_num num"> <span>{{ statisticsData[tabActive].startCount || 0 }}个</span> </div> </div> <div class="complete"> <div class="complete_text text">已完工</div> <div class="scomplete_num num"> <span>{{ statisticsData[tabActive].endCount || 0 }}个</span> </div> </div> </div> </div> </div> <div class="v v2"> <div class="icon"> <img src="@/assets/images/preassess/projectMongy.png" alt="" style="width: 45px; height: 45px" /> </div> <div class="v1_info"> <h2>完成项目总投资</h2> <div class="v1_num v1_num_w"> <span v-if="statisticsData[tabActive].accomplishTotalInvest"> <i>{{ (statisticsData[tabActive].accomplishTotalInvest * 1).toFixed(2) }}</i> 万元 </span> <span v-else> <i>0</i> 万元 </span> </div> </div> </div> <div class="v v3"> <div class="icon"> <img src="@/assets/images/preassess/projectMongy.png" alt="" style="width: 45px; height: 45px" /> </div> <div class="v1_info"> <h2> <span>完成海绵相关投资</span> </h2> <div class="v1_num v1_num_w"> <span v-if="statisticsData[tabActive].accomplishSpongeInvest"> <i>{{ (statisticsData[tabActive].accomplishSpongeInvest * 1).toFixed(2) }}</i >万元</span > <span v-else> <i>0</i> 万元 </span> </div> </div> </div> </div> </div> </el-col> <el-col :span="12"> <div class="years cardItem"> <div class="year" v-for="(year, index) in statisticsData.yaerCount"> <div class="value">{{ year.typeName }}年</div> <div class="count">{{ year.typeCount }}个</div> <span class="title" v-show="index === statisticsData.yaerCount.length - 1 && curYear == year.typeName">本年</span> </div> </div> </el-col> </el-row> <div class="typeList cardItem"> <div class="type" v-for="item in statisticsData.projectTypeCount"> <p class="ellipsis" :title="item.typeName">{{ item.typeName }}</p> <div class="count_box"> <div class="icon"> <img v-if="iconMap.get(item.typeName.slice(item.typeName.length - 2, item.typeName.length))" :src="iconMap.get(item.typeName.slice(item.typeName.length - 2, item.typeName.length)) || ''" alt="" /> <img v-else :src="iconMap.get('其他') || ''" alt="" /> </div> <div class="count">{{ item.typeCount }}个</div> </div> </div> </div> </div> </template> <script setup> import { getProjectStatistics } from '@/api/project/projectInformationNew'; import { iconMap } from '../map'; const { proxy } = getCurrentInstance(); const curYear = proxy.moment().format('YYYY'); const statisticsData = reactive({ current: {}, total: {}, yaerCount: [], projectTypeCount: [], }); const tabActive = ref('total'); const getData = async () => { const res = await getProjectStatistics(); if (res?.code !== 200) return; // console.log(res); const { current, total, yaerCount, projectTypeCount } = res.data; statisticsData.current = current; statisticsData.total = total; statisticsData.yaerCount = yaerCount; statisticsData.projectTypeCount = projectTypeCount; }; onMounted(() => { getData(); }); defineExpose({ getData, }); </script> <style lang="scss" scoped> @import '@/assets/styles/variables.module.scss'; .cardList { // height: 254px; .cardItem { background: $mainColor1; border-radius: 6px; padding: 10px; } .item { display: flex; justify-content: space-around; align-items: center; position: relative; color: #c6c6c6; .title { position: absolute; top: 0; right: 0; padding: 2px; background-color: #409eff; color: #fff; } .v { display: flex; align-items: center; &:first-of-type { .v1_info { width: 180px; h2 { > span:nth-of-type(1) { margin-right: 40px; } } } } .icon { width: 60px; height: 60px; // background-color: green; margin-right: 10px; img { width: 24px; height: 24px; } } .v1_info { h2 { display: flex; align-items: baseline; font-size: 18px; margin-top: 0; .total_text { margin-left: 14px; } span:nth-of-type(2) { font-size: 24px; font-weight: 700; } } .v1_num { display: flex; align-items: center; &.v1_num_w { font-size: 20px; font-weight: 700; i { font-size: 24px; font-style: normal; vertical-align: bottom; } } > div { flex: 1; font-size: 14px; &:last-of-type { margin-left: 20px; } .text { text-align: center; margin-bottom: 5px; } .num { display: flex; justify-content: center; align-items: baseline; } } } } } } .years { display: flex; align-items: center; .year { flex: 1; margin-right: 10px; box-shadow: 0px 2px 6px 0px $mainColor2; padding: 26px 20px; font-size: 20px; text-align: center; position: relative; &:last-of-type { margin-right: 0; } .count { font-size: 22px; font-weight: 700; margin-top: 5px; } .title { position: absolute; top: 0; right: 0; padding: 2px; background-color: #409eff; color: #fff; font-size: 12px; } } } .typeList { display: flex; margin-top: 10px; .type { max-width: 240px; flex: 1; padding: 10px 15px; box-shadow: 0px 2px 6px 0px rgba(28, 52, 92, 0.1); font-size: 18px; margin-right: 10px; &:last-of-type { margin-right: 0; } p { margin-top: 0; margin-bottom: 10px; text-align: center; } .count_box { display: flex; width: 100%; align-items: center; justify-content: space-around; padding: 0 20px; .icon { width: 32px; height: 32px; img { width: 100%; height: 100%; } } } } } } </style>