feat: 绿植租赁方案添加产品数量
This commit is contained in:
parent
f5d7d70cc2
commit
9ab72435c7
@ -80,7 +80,7 @@ export interface RentalPlanForm extends BaseEntity {
|
||||
/**
|
||||
* 方案下绿植产品
|
||||
*/
|
||||
productList:any[];
|
||||
productList?:any[];
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,64 +1,6 @@
|
||||
import type { statisticsByTimeQuery } from './model';
|
||||
|
||||
import type { ID, IDS } from '#/api/common';
|
||||
import type { PageResult } from '#/api/common';
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
// /**
|
||||
// * 查询绿植租赁-租赁方案列表
|
||||
// * @param params
|
||||
// * @returns 绿植租赁-租赁方案列表
|
||||
// */
|
||||
// export function rentalPlanList(params?: RentalPlanQuery) {
|
||||
// return requestClient.get<PageResult<RentalPlanVO>>('/property/rentalPlan/list', { params });
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 导出绿植租赁-租赁方案列表
|
||||
// * @param params
|
||||
// * @returns 绿植租赁-租赁方案列表
|
||||
// */
|
||||
// export function rentalPlanExport(params?: RentalPlanQuery) {
|
||||
// return commonExport('/property/rentalPlan/export', params ?? {});
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 查询绿植租赁-租赁方案详情
|
||||
// * @param id id
|
||||
// * @returns 绿植租赁-租赁方案详情
|
||||
// */
|
||||
// export function rentalPlanInfo(id: ID) {
|
||||
// return requestClient.get<RentalPlanVO>(`/property/rentalPlan/${id}`);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 新增绿植租赁-租赁方案
|
||||
// * @param data
|
||||
// * @returns void
|
||||
// */
|
||||
// export function rentalPlanAdd(data: RentalPlanForm) {
|
||||
// return requestClient.postWithMsg<void>('/property/rentalPlan', data);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 更新绿植租赁-租赁方案
|
||||
// * @param data
|
||||
// * @returns void
|
||||
// */
|
||||
// export function rentalPlanUpdate(data: RentalPlanForm) {
|
||||
// return requestClient.putWithMsg<void>('/property/rentalPlan', data);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 删除绿植租赁-租赁方案
|
||||
// * @param id id
|
||||
// * @returns void
|
||||
// */
|
||||
// export function rentalPlanRemove(id: ID | IDS) {
|
||||
// return requestClient.deleteWithMsg<void>(`/property/rentalPlan/${id}`);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询订单数量趋势
|
||||
@ -68,3 +10,61 @@ import { requestClient } from '#/api/request';
|
||||
export function statisticsByTime(params:statisticsByTimeQuery) {
|
||||
return requestClient.get<any>('/property/rentalOrder/statisticsByTime', { params });
|
||||
}
|
||||
/**
|
||||
* 用户类型统计订单数
|
||||
* @param timeUnit
|
||||
* @returns void
|
||||
*/
|
||||
export function countByCusType() {
|
||||
return requestClient.get<any>('/property/rentalOrder/countByCusType');
|
||||
}
|
||||
/**
|
||||
* 查询客户续租率统计
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countRenewRate() {
|
||||
return requestClient.get<any>('/property/rentalOrder/countRenewRate');
|
||||
}
|
||||
/**
|
||||
* 按租赁方式统计租赁金额
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countByRentalType() {
|
||||
return requestClient.get<any>('/property/rentalOrder/countByRentalType');
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计订单总数和租赁金额总数
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countOrderAndAmount( ) {
|
||||
return requestClient.get<any>('/property/rentalOrder/countOrderAndAmount', );
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算绿植养护完成率
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countAchievedRate() {
|
||||
return requestClient.get<any>('/property/orderMaintain/countAchievedRate');
|
||||
}
|
||||
/**
|
||||
* 统计养护完成情况
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countAchieved() {
|
||||
return requestClient.get<any>('/property/orderMaintain/countAchieved');
|
||||
}
|
||||
/**
|
||||
* 按用户评分统计养护
|
||||
* @param
|
||||
* @returns void
|
||||
*/
|
||||
export function countByCusScore() {
|
||||
return requestClient.get<any>('/property/orderMaintain/countByCusScore');
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
@ -25,6 +25,10 @@ const title = computed(() => {
|
||||
// 缓存清洁服务数据
|
||||
let plantListData: any[] = [];
|
||||
const detailIndex = ref<number>();//传index对应详情的某条数据,对该条数据进行编辑修改
|
||||
|
||||
// 添加数量最大值
|
||||
const productNumMax = ref<any>(0);
|
||||
|
||||
const detailSchema = [
|
||||
{
|
||||
label: '产品名称',
|
||||
@ -33,7 +37,7 @@ const detailSchema = [
|
||||
componentProps: {
|
||||
disabled: isView,
|
||||
api: async () => {
|
||||
const res = await plantsProductList({inventory:0});
|
||||
const res = await plantsProductList({state:1,inventory:0});
|
||||
plantListData = res.rows || [];
|
||||
return res;
|
||||
},
|
||||
@ -47,6 +51,7 @@ const detailSchema = [
|
||||
// 自动填充其他字段
|
||||
await formApi.setValues({
|
||||
plantCode: selectedService.plantCode,
|
||||
inventory: selectedService.inventory,
|
||||
plantType: selectedService.plantType,
|
||||
imgPath: selectedService.imgPath,
|
||||
specification: selectedService.specification,
|
||||
@ -54,11 +59,32 @@ const detailSchema = [
|
||||
state: selectedService.state,
|
||||
remark: selectedService.remark,
|
||||
});
|
||||
// 更新最大数量
|
||||
productNumMax.value = selectedService.inventory || 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '产品库存',
|
||||
fieldName: 'inventory',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '添加数量',
|
||||
fieldName: 'productNum',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
min: 1,
|
||||
max: productNumMax,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
label: '产品编号',
|
||||
fieldName: 'plantCode',
|
||||
@ -138,6 +164,22 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
// 监听inventory变化,更新productNumMax
|
||||
watch(async () => {
|
||||
const values = await formApi.getValues();
|
||||
return values.inventory;
|
||||
}, async (newInventory) => {
|
||||
if (newInventory) {
|
||||
productNumMax.value = newInventory;
|
||||
// 如果当前productNum大于新的库存,则设置为库存值
|
||||
const values = await formApi.getValues();
|
||||
const currentProductNum = values.productNum;
|
||||
if (currentProductNum && currentProductNum > newInventory) {
|
||||
formApi.setFieldValue('productNum', newInventory);
|
||||
}
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
@ -185,7 +227,7 @@ async function handleConfirm() {
|
||||
const selectedService = plantListData.find(item => item.id === data.plantName);
|
||||
if (selectedService) {
|
||||
data.plantName = selectedService.plantName;
|
||||
data.id = selectedService.id
|
||||
data.productId = selectedService.id
|
||||
}
|
||||
if (isUpdate.value) {
|
||||
data.index = detailIndex.value;
|
||||
|
@ -88,7 +88,8 @@ async function handleConfirm() {
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues());
|
||||
data.productIds = detailTable.value.map((item:any) => item.id);
|
||||
// data.productIds = detailTable.value.map((item:any) => item.productId);
|
||||
data.productList = detailTable.value;
|
||||
await (isUpdate.value ? rentalPlanUpdate({...data,id:editId.value}) : rentalPlanAdd(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
@ -114,6 +115,7 @@ const detailColumns = [
|
||||
{ title: '产品编号', dataIndex: 'plantCode', key: 'plantCode' },
|
||||
{ title: '产品名称', dataIndex: 'plantName', key: 'plantName' },
|
||||
{ title: '产品分类', dataIndex: 'plantType', key: 'plantType' },
|
||||
{ title: '产品数量', dataIndex: 'productNum', key: 'productNum' },
|
||||
{
|
||||
title: '图片',
|
||||
dataIndex: 'imgPath',
|
||||
@ -131,7 +133,7 @@ const detailColumns = [
|
||||
dataIndex: 'state',
|
||||
key: 'state',
|
||||
customRender: ({ value }: { value: number }) =>
|
||||
value === 1 ? '上架' : '下架',
|
||||
value == 1 ? '上架' : '下架',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
@ -7,7 +7,15 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { statisticsByTime } from '#/api/property/reportStatistics';
|
||||
import { statisticsByTime,
|
||||
countByRentalType,
|
||||
countByCusType,
|
||||
countRenewRate,
|
||||
countByCusScore,
|
||||
countOrderAndAmount,
|
||||
countAchievedRate,
|
||||
countAchieved
|
||||
} from '#/api/property/reportStatistics';
|
||||
|
||||
const orderLineRef = ref<EchartsUIType>();
|
||||
const leasePieRef = ref<EchartsUIType>();
|
||||
@ -31,11 +39,39 @@ const { renderEcharts: renderMaintenanceQualityScoresPei } = useEcharts(
|
||||
);
|
||||
const timeUnit = ref<number>(1)
|
||||
|
||||
const countOrderAndAmountDataAmount = ref<number>(0);
|
||||
const countOrderAndAmountDataOrder = ref<number>(0);
|
||||
const countAchievedRateData = ref<any>(null);
|
||||
onMounted(async () => {
|
||||
// 任务数
|
||||
const countOrderAndAmountData= await countOrderAndAmount();
|
||||
countOrderAndAmountDataAmount.value = countOrderAndAmountData.amount;
|
||||
countOrderAndAmountDataOrder.value = countOrderAndAmountData.num;
|
||||
const countAchievedRateDataRes: any = await countAchievedRate();
|
||||
countAchievedRateData.value = countAchievedRateDataRes.rate;
|
||||
// 查询订单数量趋势
|
||||
const res = await statisticsByTime({ timeUnit: timeUnit.value });
|
||||
const xAxisData = res?.time ?? [];
|
||||
const seriesData = 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: {
|
||||
@ -48,7 +84,7 @@ onMounted(async () => {
|
||||
{
|
||||
name: '订单数',
|
||||
type: 'line',
|
||||
data: seriesData,
|
||||
data: seriesData ||[],
|
||||
smooth: true,
|
||||
},
|
||||
],
|
||||
@ -59,17 +95,11 @@ onMounted(async () => {
|
||||
legend: { orient: 'vertical', left: 'left' },
|
||||
series: [
|
||||
{
|
||||
name: '金额',
|
||||
// name: '金额',
|
||||
type: 'pie',
|
||||
radius: '60%',
|
||||
center: ['50%', '50%'],
|
||||
data: [
|
||||
{ value: 1048, name: '办公楼' },
|
||||
{ value: 735, name: '商场' },
|
||||
{ value: 580, name: '酒店' },
|
||||
{ value: 484, name: '医院' },
|
||||
{ value: 300, name: '其他' },
|
||||
],
|
||||
data:convertedData || [],
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
@ -89,15 +119,15 @@ onMounted(async () => {
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['1月', '2月', '3月', '4月', '5月', '6月'],
|
||||
boundaryGap: false,
|
||||
data: countByCusTypeData.type || [],
|
||||
boundaryGap: true,
|
||||
},
|
||||
yAxis: { type: 'value' },
|
||||
series: [
|
||||
{
|
||||
name: '订单数',
|
||||
type: 'bar',
|
||||
data: [120, 132, 101, 134, 90, 230],
|
||||
data: countByCusTypeData.counts || [],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -106,7 +136,7 @@ onMounted(async () => {
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['1月', '2月', '3月', '4月', '5月', '6月'],
|
||||
data: countRenewRateData.month || [],
|
||||
boundaryGap: false,
|
||||
},
|
||||
yAxis: { type: 'value' },
|
||||
@ -114,7 +144,7 @@ onMounted(async () => {
|
||||
{
|
||||
name: '订单数',
|
||||
type: 'line',
|
||||
data: [120, 132, 101, 134, 90, 230],
|
||||
data: countRenewRateData.rate || [],
|
||||
smooth: true,
|
||||
},
|
||||
],
|
||||
@ -131,7 +161,7 @@ onMounted(async () => {
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: ['朝阳区', '海淀区', '西城区', '东城区'],
|
||||
data: countAchievedData.type || [],
|
||||
},
|
||||
],
|
||||
yAxis: [
|
||||
@ -157,18 +187,18 @@ onMounted(async () => {
|
||||
{
|
||||
name: '计划任务数',
|
||||
type: 'bar',
|
||||
data: [156, 140, 130, 120],
|
||||
data: countAchievedData.toral || [],
|
||||
},
|
||||
{
|
||||
name: '已完成数',
|
||||
type: 'bar',
|
||||
data: [152, 135, 125, 110],
|
||||
data: countAchievedData.finish || [],
|
||||
},
|
||||
{
|
||||
name: '完成率',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
data: [97.4, 96.4, 96.2, 91.7],
|
||||
data: countAchievedData.rate || [],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -190,13 +220,7 @@ onMounted(async () => {
|
||||
type: 'pie',
|
||||
radius: '60%',
|
||||
center: ['50%', '50%'],
|
||||
data: [
|
||||
{ value: 12.43, name: '一星' },
|
||||
{ value: 12.26, name: '两星' },
|
||||
{ value: 16.87, name: '三星' },
|
||||
{ value: 25.75, name: '四星' },
|
||||
{ value: 32.68, name: '五星' },
|
||||
],
|
||||
data: countByCusScoreDataList || [],
|
||||
label: {
|
||||
formatter: '{b} {d}%',
|
||||
show: true,
|
||||
@ -211,9 +235,23 @@ const nodeOptions = [
|
||||
{ label: '月', value: 3 },
|
||||
];
|
||||
function handleAssociationChange(e: any) {
|
||||
console.log(e);
|
||||
timeUnit.value = e.target.value;
|
||||
}
|
||||
function formatNumber(num: number | string) {
|
||||
if (!num && num !== 0) {
|
||||
return '';
|
||||
}
|
||||
num = num.toString();
|
||||
const parts = num.split('.');
|
||||
let integerPart: string = parts[0] || '0';
|
||||
const decimalPart = parts.length > 1 ? '.' + parts[1] : '';
|
||||
const rgx = /(\d+)(\d{3})/;//整体表示匹配一组由多个数字后跟三个数字组成的字符串
|
||||
while (rgx.test(integerPart)) {
|
||||
integerPart = integerPart.replace(rgx, `$1${','}$2`);
|
||||
}
|
||||
|
||||
return integerPart + decimalPart;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="main">
|
||||
@ -232,12 +270,17 @@ function handleAssociationChange(e: any) {
|
||||
<div class="row">
|
||||
<div class="box">
|
||||
<div class="title">总订单数</div>
|
||||
<div class="number">13,132</div>
|
||||
<div class="percent">8.9%</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">{{ countAchievedRateData }}</div>
|
||||
</div>
|
||||
<div class="box"></div>
|
||||
<div class="box"></div>
|
||||
<div class="box"></div>
|
||||
</div>
|
||||
<div class="row-first">
|
||||
<div class="item1">
|
||||
@ -251,7 +294,6 @@ function handleAssociationChange(e: any) {
|
||||
option-type="button"
|
||||
@change="handleAssociationChange"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<EchartsUI
|
||||
|
Loading…
Reference in New Issue
Block a user