莳松crm管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ss-crm-manage-web/src/views/Home/Comp/SignTotalCard.vue

195 lines
5.6 KiB

<template>
<ContentWrap>
<div class="flex items-center">
<span class="mr-20px">成交概况</span>
<el-dropdown>
<el-button size="small"
>{{ periodTypeOptions[periodType] }} <Icon icon="ep:arrow-down"
/></el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
v-for="(item, index) in periodTypeOptions"
:key="index"
@click="handleSearchTotalInfo(index)"
>
{{ item }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
<el-row :gutter="20" v-loading="infoLoading">
<el-col :span="8" :offset="0">
<div class="statistic-card">
<el-statistic :value="totalData.signNumber" title="成交数" />
<div
class="statistic-footer"
:class="periodType != 4 ? 'justify-between' : 'justify-center'"
>
<div class="footer-item">
<span>环比</span>
<span :class="getColor(totalData.signNumberSequentialGrowth)">
{{ totalData.signNumberSequentialGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.signNumberSequentialGrowth)" />
</span>
</div>
<div class="footer-item" v-if="periodType != 4">
<span>同比</span>
<span :class="getColor(totalData.signNumberPeriodCompareGrowth)">
{{ totalData.signNumberPeriodCompareGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.signNumberPeriodCompareGrowth)" />
</span>
</div>
</div>
</div>
</el-col>
<el-col :span="8" :offset="0">
<div class="statistic-card">
<el-statistic :value="totalData.signPrice" title="成交额" :precision="2" />
<div
class="statistic-footer"
:class="periodType != 4 ? 'justify-between' : 'justify-center'"
>
<div class="footer-item">
<span>环比</span>
<span :class="getColor(totalData.signPriceSequentialGrowth)">
{{ totalData.signPriceSequentialGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.signPriceSequentialGrowth)" />
</span>
</div>
<div class="footer-item" v-if="periodType != 4">
<span>同比</span>
<span :class="getColor(totalData.signPriceSamePeriodCompareGrowth)">
{{ totalData.signPriceSamePeriodCompareGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.signPriceSamePeriodCompareGrowth)" />
</span>
</div>
</div>
</div>
</el-col>
<el-col :span="8" :offset="0">
<div class="statistic-card">
<el-statistic :value="totalData.profit" title="利润" :precision="2" />
<div
class="statistic-footer"
:class="periodType != 4 ? 'justify-between' : 'justify-center'"
>
<div class="footer-item">
<span>环比</span>
<span :class="getColor(totalData.profitSequentialGrowth)">
{{ totalData.profitSequentialGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.profitSequentialGrowth)" />
</span>
</div>
<div class="footer-item" v-if="periodType != 4">
<span>同比</span>
<span :class="getColor(totalData.profitSamePeriodCompareGrowth)">
{{ totalData.profitSamePeriodCompareGrowth }}%
<Icon class="ml-2px" :icon="getIcon(totalData.profitSamePeriodCompareGrowth)" />
</span>
</div>
</div>
</div>
</el-col>
</el-row>
</ContentWrap>
</template>
<script setup name="SignTotalCard">
import { getInfo } from '@/api/home/reportSignDetail'
const periodTypeOptions = ['本日', '本周', '本月', '本季', '本年']
const periodType = ref(2)
const totalData = ref({})
onMounted(() => {
handleSearchTotalInfo(2)
})
const infoLoading = ref(false)
async function handleSearchTotalInfo(index) {
periodType.value = index
infoLoading.value = true
try {
const data = await getInfo({ periodType: periodType.value + 1 })
totalData.value = data
} finally {
infoLoading.value = false
}
}
function getIcon(val) {
if (val > 0) {
return 'ep:caret-top'
} else if (val < 0) {
return 'ep:caret-bottom'
} else {
return 'ep:minus'
}
}
function getColor(val) {
if (val > 0) {
return 'green'
} else if (val < 0) {
return 'red'
} else {
return 'gley'
}
}
</script>
<style lang="scss" scoped>
.el-col {
text-align: center;
}
:global(h2#card-usage ~ .example .example-showcase) {
background-color: var(--el-fill-color) !important;
}
.el-statistic {
--el-statistic-content-font-size: 28px;
}
.statistic-card {
height: 100%;
// padding: 20px;
border-radius: 4px;
background-color: var(--el-bg-color-overlay);
}
.statistic-footer {
margin: 16px auto 0;
display: flex;
// justify-content: space-between;
align-items: center;
flex-wrap: wrap;
font-size: 12px;
color: var(--el-text-color-regular);
width: 300px;
}
.statistic-footer .footer-item {
display: flex;
justify-content: space-between;
align-items: center;
}
.statistic-footer .footer-item span:last-child {
display: inline-flex;
align-items: center;
margin-left: 4px;
}
.green {
color: var(--el-color-success);
}
.gley {
color: var(--el-color-info);
}
.red {
color: var(--el-color-error);
}
</style>