feat: 修复保洁、绿植、园区、系统用户相关bug
This commit is contained in:
@@ -39,7 +39,29 @@ const detailSchema = [
|
||||
api: async () => {
|
||||
const res = await plantsProductList({state:1,inventory:0});
|
||||
plantListData = res.rows || [];
|
||||
return res;
|
||||
|
||||
// 获取当前模态框的数据,包含已添加的产品列表
|
||||
const modalData = modalApi.getData();
|
||||
const existingProducts = modalData?.existingProducts || [];
|
||||
const currentProductId = modalData?.currentProductId;
|
||||
|
||||
// 过滤掉已经添加到产品列表中的产品
|
||||
// 如果是编辑模式,需要排除当前正在编辑的产品
|
||||
const filteredRows = res.rows.filter((item: any) => {
|
||||
// 如果是编辑模式且是当前正在编辑的产品,则保留
|
||||
if (currentProductId && item.id === currentProductId) {
|
||||
return true;
|
||||
}
|
||||
// 过滤掉已添加的产品
|
||||
return !existingProducts.some((existing: any) =>
|
||||
existing.productId === item.id || existing.id === item.id
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
...res,
|
||||
rows: filteredRows
|
||||
};
|
||||
},
|
||||
resultField: 'rows',
|
||||
labelField: 'plantName',
|
||||
|
@@ -29,10 +29,10 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
// 默认label宽度 px
|
||||
labelWidth: 120,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: computed(() => ({
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
disabled: isReadonly.value,
|
||||
})),
|
||||
disabled: isReadonly,
|
||||
},
|
||||
},
|
||||
schema: modalSchema(),
|
||||
showDefaultActions: false,
|
||||
@@ -143,10 +143,13 @@ const detailColumns = [
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right' as const,
|
||||
width: 200,
|
||||
},
|
||||
];
|
||||
function handleAddDetail() {
|
||||
detailModalApi.setData({});
|
||||
detailModalApi.setData({
|
||||
existingProducts: detailTable.value
|
||||
});
|
||||
detailModalApi.open();
|
||||
}
|
||||
//添加植物组合包产品
|
||||
@@ -169,7 +172,13 @@ function handleViewDetail(record: any) {
|
||||
}
|
||||
// 编辑产品详情
|
||||
function handleEditDetail(record: any, index: number) {
|
||||
detailModalApi.setData({ ...record, index, readonly: false });
|
||||
detailModalApi.setData({
|
||||
...record,
|
||||
index,
|
||||
readonly: false,
|
||||
existingProducts: detailTable.value.filter((item: any, i: number) => i !== index),
|
||||
currentProductId: record.productId || record.id
|
||||
});
|
||||
detailModalApi.open();
|
||||
}
|
||||
//分类字典
|
||||
|
@@ -5,7 +5,7 @@ import { onMounted, ref } from 'vue';
|
||||
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Button,Radio } from 'ant-design-vue';
|
||||
import { Button,Radio,Spin } from 'ant-design-vue';
|
||||
import type { RadioChangeEvent } from 'ant-design-vue';
|
||||
|
||||
import { statisticsByTime,
|
||||
@@ -44,42 +44,30 @@ const timeUnit = ref<number>(1)
|
||||
const countOrderAndAmountDataAmount = ref<number>(0);
|
||||
const countOrderAndAmountDataOrder = ref<number>(0);
|
||||
const countAchievedRateData = ref<any>(null);
|
||||
const countCustomersData = ref<any>(null);
|
||||
const countCustomersData = ref<any>(0);
|
||||
const xAxisData = ref<any[]>([]);
|
||||
const seriesData = ref<any[]>([]);
|
||||
onMounted(async () => {
|
||||
// 任务数
|
||||
const countOrderAndAmountData= await countOrderAndAmount();
|
||||
const loading = ref(false);
|
||||
async function fetchOrderAndAmount() {
|
||||
const countOrderAndAmountData = await countOrderAndAmount();
|
||||
countOrderAndAmountDataAmount.value = countOrderAndAmountData.amount;
|
||||
countOrderAndAmountDataOrder.value = countOrderAndAmountData.num;
|
||||
//活跃用户
|
||||
}
|
||||
|
||||
async function fetchCustomers() {
|
||||
const countCustomersDataRes: any = await countCustomers();
|
||||
countCustomersData.value = countCustomersDataRes.count;
|
||||
}
|
||||
|
||||
async function fetchAchievedRate() {
|
||||
const countAchievedRateDataRes: any = await countAchievedRate();
|
||||
countAchievedRateData.value = countAchievedRateDataRes.rate;
|
||||
// 查询订单数量趋势
|
||||
}
|
||||
|
||||
async function fetchOrderTrend() {
|
||||
const res = await statisticsByTime({ timeUnit: timeUnit.value });
|
||||
xAxisData.value = res?.time ?? [];
|
||||
seriesData.value = res?.counts ?? [];
|
||||
// 租赁金额分布
|
||||
const data = await countByRentalType();//返回的内容是amount: 1, type: "单点"
|
||||
// 转换字段名为value和name
|
||||
const convertedData = data.map((item: { amount: number; type: string }) => ({
|
||||
value: item.amount,
|
||||
name: item.type
|
||||
}));
|
||||
// 客户类型分配
|
||||
const countByCusTypeData:any = await countByCusType();
|
||||
//客户续租率趋势
|
||||
const countRenewRateData:any = await countRenewRate();
|
||||
// 养护任务完成情况
|
||||
const countAchievedData:any = await countAchieved();
|
||||
// 养护质量评分分布
|
||||
const countByCusScoreData:any = await countByCusScore();
|
||||
const countByCusScoreDataList = countByCusScoreData.map((item: { score: string; count: number }) => ({
|
||||
value: item.count,
|
||||
name: item.score
|
||||
}));
|
||||
renderEcharts({
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: {
|
||||
@@ -87,31 +75,34 @@ onMounted(async () => {
|
||||
data: xAxisData.value,
|
||||
boundaryGap: false,
|
||||
},
|
||||
yAxis: { type: 'value',
|
||||
axisLabel: {
|
||||
formatter: (value) => `${value * 100}%`
|
||||
},
|
||||
},
|
||||
yAxis: { type: 'value', axisLabel: { formatter: (value) => `${value * 100}%` } },
|
||||
series: [
|
||||
{
|
||||
name: '订单趋势',
|
||||
type: 'line',
|
||||
data: seriesData.value ||[],
|
||||
data: seriesData.value || [],
|
||||
smooth: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchLeasePie() {
|
||||
const data = await countByRentalType();
|
||||
const convertedData = data.map((item: { amount: number; type: string }) => ({
|
||||
value: item.amount,
|
||||
name: item.type,
|
||||
}));
|
||||
renderLeasePie({
|
||||
title: { text: '租赁金额分布', left: 'center' },
|
||||
tooltip: { trigger: 'item' },
|
||||
legend: { orient: 'vertical', left: 'left' },
|
||||
series: [
|
||||
{
|
||||
// name: '金额',
|
||||
type: 'pie',
|
||||
radius: '60%',
|
||||
center: ['50%', '50%'],
|
||||
data:convertedData || [],
|
||||
data: convertedData || [],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
@@ -126,20 +117,19 @@ onMounted(async () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchCustomerTypesBar() {
|
||||
const countByCusTypeData: any = await countByCusType();
|
||||
renderCustomerTypesBar({
|
||||
title: { text: '客户类型分布' },
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['企业客户','个人客户','政府机构','商业地产','其他'],
|
||||
data: ['企业客户', '个人客户', '政府机构', '商业地产', '其他'],
|
||||
boundaryGap: true,
|
||||
},
|
||||
yAxis: { type: 'value',
|
||||
axisLabel: {
|
||||
// formatter: (value: number) => `${parseInt(value.toString())}`
|
||||
},
|
||||
// interval: 0,
|
||||
},
|
||||
yAxis: { type: 'value' },
|
||||
series: [
|
||||
{
|
||||
name: '客户数',
|
||||
@@ -148,16 +138,21 @@ onMounted(async () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchCustomerRenewalLine() {
|
||||
const countRenewRateData: any = await countRenewRate();
|
||||
renderCustomerRenewalLine({
|
||||
title: { text: '客户续租率趋势' },
|
||||
tooltip: { trigger: 'axis',
|
||||
formatter: function(params:any) {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: function (params: any) {
|
||||
let result = params[0].axisValue + '<br/>';
|
||||
params.forEach((item:any) => {
|
||||
params.forEach((item: any) => {
|
||||
result += item.marker + item.seriesName + ':' + item.data + '%<br/>';
|
||||
});
|
||||
return result;
|
||||
}
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
@@ -165,10 +160,9 @@ onMounted(async () => {
|
||||
boundaryGap: false,
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
formatter: '{value}%',
|
||||
}, },
|
||||
type: 'value',
|
||||
axisLabel: { formatter: '{value}%' },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '续租率',
|
||||
@@ -178,78 +172,55 @@ onMounted(async () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchConservationTasksBar() {
|
||||
const countAchievedData: any = await countAchieved();
|
||||
renderConservationTasksBar({
|
||||
title: { text: '养护任务完成情况' },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: function(params:any) {
|
||||
// params 是一个数组,包含每个系列的当前项
|
||||
let result = params[0].axisValue + '<br/>';
|
||||
params.forEach((item:any) => {
|
||||
if (item.seriesName === '完成率') {
|
||||
// 假设原始数据是 80,显示为 80%
|
||||
result += item.marker + item.seriesName + ':' + item.data + '%<br/>';
|
||||
} else {
|
||||
result += item.marker + item.seriesName + ':' + item.data + '<br/>';
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
data: ['计划任务数', '已完成数', '完成率'],
|
||||
formatter: function (params: any) {
|
||||
let result = params[0].axisValue + '<br/>';
|
||||
params.forEach((item: any) => {
|
||||
if (item.seriesName === '完成率') {
|
||||
result += item.marker + item.seriesName + ':' + item.data + '%<br/>';
|
||||
} else {
|
||||
result += item.marker + item.seriesName + ':' + item.data + '<br/>';
|
||||
}
|
||||
});
|
||||
return result;
|
||||
},
|
||||
},
|
||||
legend: { data: ['计划任务数', '已完成数', '完成率'] },
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: ['修剪整形','肥水管理','中耕除草','病虫害防治','越冬防寒'],
|
||||
data: ['修剪整形', '肥水管理', '中耕除草', '病虫害防治', '越冬防寒'],
|
||||
},
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '任务数',
|
||||
min: 0,
|
||||
max: 200,
|
||||
position: 'left',
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '完成率',
|
||||
min: 0,
|
||||
max: 100,
|
||||
position: 'right',
|
||||
axisLabel: {
|
||||
formatter: '{value}%',
|
||||
},
|
||||
},
|
||||
{ type: 'value', name: '任务数', min: 0, max: 200, position: 'left' },
|
||||
{ type: 'value', name: '完成率', min: 0, max: 100, position: 'right', axisLabel: { formatter: '{value}%' } },
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '计划任务数',
|
||||
type: 'bar',
|
||||
data: countAchievedData.total || [],
|
||||
},
|
||||
{
|
||||
name: '已完成数',
|
||||
type: 'bar',
|
||||
data: countAchievedData.finish || [],
|
||||
},
|
||||
{
|
||||
name: '完成率',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
data: countAchievedData.rate || [],
|
||||
},
|
||||
{ name: '计划任务数', type: 'bar', data: countAchievedData.total || [] },
|
||||
{ name: '已完成数', type: 'bar', data: countAchievedData.finish || [] },
|
||||
{ name: '完成率', type: 'line', yAxisIndex: 1, data: countAchievedData.rate || [] },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchMaintenanceQualityScoresPei() {
|
||||
const countByCusScoreData: any = await countByCusScore();
|
||||
const countByCusScoreDataList = countByCusScoreData.map((item: { score: string; count: number }) => ({
|
||||
value: item.count,
|
||||
name: item.score,
|
||||
}));
|
||||
renderMaintenanceQualityScoresPei({
|
||||
title: { text: '养护质量评分分布', left: 'center' },
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{b} : {d}%',
|
||||
},
|
||||
tooltip: { trigger: 'item', formatter: '{b} : {d}%' },
|
||||
legend: {
|
||||
orient: 'horizontal',
|
||||
left: 'center',
|
||||
@@ -263,13 +234,27 @@ onMounted(async () => {
|
||||
radius: '60%',
|
||||
center: ['50%', '50%'],
|
||||
data: countByCusScoreDataList || [],
|
||||
label: {
|
||||
formatter: '{b} {d}%',
|
||||
show: true,
|
||||
},
|
||||
label: { formatter: '{b} {d}%', show: true },
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
await fetchOrderAndAmount();
|
||||
await fetchCustomers();
|
||||
await fetchAchievedRate();
|
||||
await fetchOrderTrend();
|
||||
await fetchLeasePie();
|
||||
await fetchCustomerTypesBar();
|
||||
await fetchCustomerRenewalLine();
|
||||
await fetchConservationTasksBar();
|
||||
await fetchMaintenanceQualityScoresPei();
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
// 切换视图模式
|
||||
async function handleViewModeChange(e: RadioChangeEvent): Promise<void> {
|
||||
@@ -313,101 +298,103 @@ function formatNumber(num: number | string) {
|
||||
</script>
|
||||
<template>
|
||||
<div class="main">
|
||||
<div class="box">
|
||||
<div class="title">
|
||||
<div class="title-text">绿植租赁业务统计报表:</div>
|
||||
<div class="title-operate">
|
||||
<div class="export" style="display: none;">
|
||||
<Button size="large" style="color: #fff; background-color: #22c55e">
|
||||
导出数据
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="box">
|
||||
<div class="title">总订单数</div>
|
||||
<div class="number">{{formatNumber(countOrderAndAmountDataAmount)}}</div>
|
||||
<!-- <div class="percent">8.9%</div> -->
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">累计租赁金额</div>
|
||||
<div class="number">{{ formatNumber(countOrderAndAmountDataOrder) }}</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">当前活跃客户数</div>
|
||||
<div class="number">{{ formatNumber(countCustomersData) }}</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">绿植养护完成率</div>
|
||||
<div class="number">{{ countAchievedRateData }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-first">
|
||||
<div class="item1">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;">
|
||||
<span style="font-size: 18px; font-weight: bold;">订单数量趋势</span>
|
||||
<div>
|
||||
<Radio.Group v-model:value="timeUnit" @change="handleViewModeChange">
|
||||
<Radio.Button value=1>日</Radio.Button>
|
||||
<Radio.Button value=2>周</Radio.Button>
|
||||
<Radio.Button value=3>月</Radio.Button>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
<Spin :spinning="loading" size="large">
|
||||
<div class="box">
|
||||
<div class="title">
|
||||
<div class="title-text">绿植租赁业务统计报表:</div>
|
||||
<div class="title-operate">
|
||||
<div class="export" style="display: none;">
|
||||
<Button size="large" style="color: #fff; background-color: #22c55e">
|
||||
导出数据
|
||||
</Button>
|
||||
</div>
|
||||
<EchartsUI
|
||||
ref="orderLineRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
<div class="item2">
|
||||
<EchartsUI
|
||||
ref="leasePieRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-second">
|
||||
<div class="item1">
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="box">
|
||||
<div class="title">总订单数</div>
|
||||
<div class="number">{{formatNumber(countOrderAndAmountDataAmount)}}</div>
|
||||
<!-- <div class="percent">8.9%</div> -->
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">累计租赁金额</div>
|
||||
<div class="number">{{ formatNumber(countOrderAndAmountDataOrder) }}</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">当前活跃客户数</div>
|
||||
<div class="number">{{ formatNumber(countCustomersData) }}</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="title">绿植养护完成率</div>
|
||||
<div class="number">{{ countAchievedRateData || '0.00%' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-first">
|
||||
<div class="item1">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;">
|
||||
<span style="font-size: 18px; font-weight: bold;">订单数量趋势</span>
|
||||
<div>
|
||||
<Radio.Group v-model:value="timeUnit" @change="handleViewModeChange">
|
||||
<Radio.Button value=1>日</Radio.Button>
|
||||
<Radio.Button value=2>周</Radio.Button>
|
||||
<Radio.Button value=3>月</Radio.Button>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
</div>
|
||||
<EchartsUI
|
||||
ref="orderLineRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
<div class="item2">
|
||||
<EchartsUI
|
||||
ref="leasePieRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-second">
|
||||
<div class="item1">
|
||||
<EchartsUI
|
||||
ref="customerTypesBarRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
<div class="item2">
|
||||
<EchartsUI
|
||||
ref="customerRenewalLineRef"
|
||||
height="350px"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-third">
|
||||
<EchartsUI
|
||||
ref="customerTypesBarRef"
|
||||
height="350px"
|
||||
ref="conservationTasksBarRef"
|
||||
height="100%"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
<div class="item2">
|
||||
<div class="row-fouth">
|
||||
<EchartsUI
|
||||
ref="customerRenewalLineRef"
|
||||
height="350px"
|
||||
ref="maintenanceQualityScoresPeiRef"
|
||||
height="100%"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-third">
|
||||
<EchartsUI
|
||||
ref="conservationTasksBarRef"
|
||||
height="100%"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
<div class="row-fouth">
|
||||
<EchartsUI
|
||||
ref="maintenanceQualityScoresPeiRef"
|
||||
height="100%"
|
||||
width="100%"
|
||||
style="background: #fff; border-radius: 8px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
|
Reference in New Issue
Block a user