245 lines
7.4 KiB
Vue
Raw Normal View History

2024-06-01 09:08:19 +08:00
<template>
<el-card>
{{ formData.order_amount }}
<el-form class="mb-[-16px]" :model="queryParams" label-width="80px">
<el-col :span="6">
<el-form-item label="时间筛选">
2024-06-08 10:20:37 +08:00
<el-date-picker v-model="date" type="daterange" value-format="YYYY-MM-DD" range-separator="-"
start-placeholder="开始时间" end-placeholder="结束时间" @change="deteToQuery" />
</el-form-item>
</el-col>
</el-form>
</el-card>
2024-06-08 10:20:37 +08:00
<el-card :key="date">
<el-row>
<el-col :span="6" class='flex mb-7' v-for="(item, index) in statisticLists" :key="index">
<img class="w-[50px] h-[50px] mr-2" :src="item.src" />
<el-statistic :title="item.title" :value="item.value()" />
</el-col>
</el-row>
</el-card>
2024-06-08 10:20:37 +08:00
<el-card :key="date">
<template #header>
营业趋势
</template>
<v-charts style="height: 350px" :option="visitorOption" :autoresize="true" />
</el-card>
2024-06-08 10:20:37 +08:00
<el-row :key="date">
<el-col :span="14">
<el-card class="h-[100%]">
<template #header>
交易数据
</template>
<!-- <tradData></tradData> -->
<el-table :data="[{}]">
<el-table-column label="头像" prop="build_area_text" show-overflow-tooltip>
<template #default="{ row }">
<!-- <el-image style="width: 50px; height: 50px" :src="url" /> -->
</template>
</el-table-column>
<el-table-column label="用户名称" prop="project_level_text" show-overflow-tooltip />
<el-table-column label="订单号" prop="total_investment" show-overflow-tooltip />
<el-table-column label="交易金额" prop="total_investment" show-overflow-tooltip />
<el-table-column label="成交时间" prop="total_investment" show-overflow-tooltip />
</el-table>
</el-card>
</el-col>
<el-col :span="10">
<el-card>
<template #header>
交易类型
</template>
<v-charts style="height: 350px" :option="tradTypeOption" :autoresize="true" />
</el-card>
</el-col>
</el-row>
2024-06-01 09:08:19 +08:00
</template>
<script lang="ts" setup name="manageProjectLists">
import { ref, reactive } from "vue"
2024-06-08 10:20:37 +08:00
import { apiTradStatisApi } from '@/api/statistics'
2024-06-01 09:08:19 +08:00
import vCharts from 'vue-echarts'
import tradData from "./components/tradData.vue"
2024-06-08 10:20:37 +08:00
const date = ref([])
const queryParams = reactive({
start_time: "",
end_time: "",
})
const deteToQuery = () => {
queryParams.start_time = date.value[0]
queryParams.end_time = date.value[1]
initPage()
}
function getFirstAndLastDayOfCurrentMonth() {
var today = new Date();
var firstDay = new Date(today.getFullYear(), today.getMonth(), 1);
var lastDay = new Date(today.getFullYear(), today.getMonth() + 1, 0);
var firstDayFormatted = formatDate(firstDay);
var lastDayFormatted = formatDate(lastDay);
return { firstDay: firstDayFormatted, lastDay: lastDayFormatted };
}
function formatDate(date) {
var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, '0');
var day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
}
2024-06-08 10:20:37 +08:00
date.value[0] = getFirstAndLastDayOfCurrentMonth().firstDay;
date.value[1] = getFirstAndLastDayOfCurrentMonth().lastDay;
const formData = ref({
order_amount: 0
})
const statisticLists = reactive([
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/20240604171701552002039.png',
title: "核销订单金额",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: "https://ceshi-engineering.lihaink.cn/uploads/files/20240604/2024060417170150a511510.png",
title: "余额消费金额",
value: () => {
return String(formData.value.order_amount)
}
2024-06-01 09:08:19 +08:00
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/20240604171701594ff8897.png',
title: "门店收益金额",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/202406041717018a22e1161.png',
title: "线下收银订单金额",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/202406041717013a08c6793.png',
title: "现金收银订单金额",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/2024060417170103b0a9686.png',
title: "门店新增用户数",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/20240604171701469b91377.png',
title: "门店成交用户数",
value: () => {
return String(formData.value.order_amount)
}
},
{
src: 'https://ceshi-engineering.lihaink.cn/uploads/files/20240604/20240604171701fbb680115.png',
title: "门店营业额",
value: () => {
return String(formData.value.order_amount)
}
},
])
const visitorOption = reactive({
2024-06-08 10:20:37 +08:00
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
2024-06-08 10:20:37 +08:00
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
2024-06-08 10:20:37 +08:00
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
2024-06-08 10:20:37 +08:00
smooth: true,
name: "门店收款"
},
{
data: [15, 12, 14, 78, 96, 54, 85],
type: 'line',
smooth: true,
name: '新增用户'
}
]
})
const tradTypeOption = reactive(
{
title: {
text: '交易类型',
left: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
left: 'left'
},
series: [
{
type: 'pie',
radius: '50%',
data: [
{ value: 1048, name: '线上收银订单' },
{ value: 735, name: '现金收银订单' },
{ value: 580, name: '核销订单' },
{ value: 484, name: '充值订单' },
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
}
)
2024-06-08 10:20:37 +08:00
const getData = async () => {
let res = await apiTradStatisApi(queryParams)
formData.value = res
visitorOption.xAxis.data = res.statistics.range
visitorOption.series[0].data = res.statistics.data.order_amount
visitorOption.series[1].data = res.statistics.data.user_number
2024-06-08 10:20:37 +08:00
}
2024-06-08 10:20:37 +08:00
const initPage = () => {
getData()
2024-06-01 09:08:19 +08:00
}
2024-06-08 10:20:37 +08:00
2024-06-01 09:08:19 +08:00
onMounted(() => {
2024-06-08 10:20:37 +08:00
deteToQuery()
2024-06-01 09:08:19 +08:00
})
</script>