feat: 修复保洁、绿植、园区、系统用户相关bug

This commit is contained in:
fyy 2025-07-14 11:53:18 +08:00
parent 9279f2246a
commit c8b6d2faba
11 changed files with 254 additions and 243 deletions

View File

@ -65,7 +65,9 @@ const [BasicModal, modalApi] = useVbenModal({
if (isUpdate.value && id) {
const record = await communityInfo(id);
await formApi.setValues(record);
}
setupDeptSelect();
await markInitialized();
modalApi.modalLoading(false);
@ -83,7 +85,10 @@ async function handleConfirm() {
}
// getValuesreadonly
const data: CommunityForm = cloneDeep(await formApi.getValues());
data.cityFullName = currentSelectNode.fullName;
// data.cityFullName = currentSelectNode? currentSelectNode.fullName : data.cityFullName;
if (currentSelectNode?.fullName) {
data.cityFullName = currentSelectNode.fullName;
}
await (isUpdate.value ? communityUpdate(data) : communityAdd(data));
resetInitialized();
emit('reload');

View File

@ -42,14 +42,14 @@ export const columns: VxeGridProps['columns'] = [
title: '地址',
field: 'addr',
},
{
title: '经度',
field: 'lon',
},
{
title: '维度',
field: 'lat',
},
// {
// title: '经度',
// field: 'lon',
// },
// {
// title: '维度',
// field: 'lat',
// },
{
title: '占地面积',
field: 'area',
@ -136,16 +136,16 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input',
rules: 'required',
},
{
label: '经度',
fieldName: 'lon',
component: 'Input',
},
{
label: '维度',
fieldName: 'lat',
component: 'Input',
},
// {
// label: '经度',
// fieldName: 'lon',
// component: 'Input',
// },
// {
// label: '维度',
// fieldName: 'lat',
// component: 'Input',
// },
{
label: '占地面积',
fieldName: 'area',

View File

@ -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',

View File

@ -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();
}
//

View File

@ -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: ""
// valuename
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>

View File

@ -175,20 +175,5 @@ export const modalSchema: FormSchemaGetter = () => [
label: '备注',
fieldName: 'remark',
component: 'Input',
},
{
label: '创建人id',
fieldName: 'createById',
component: 'Input',
},
{
label: '更新人id',
fieldName: 'updateById',
component: 'Input',
},
{
label: '搜索值',
fieldName: 'searchValue',
component: 'Input',
},
}
];

View File

@ -155,12 +155,12 @@ function handleDownloadExcel() {
</template>
<template #action="{ row }">
<Space>
<ghost-button
<!-- <ghost-button
v-access:code="['property:inspectionTask:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
</ghost-button> -->
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"

View File

@ -3,7 +3,7 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
import { getPopupContainer } from '@vben/utils';
import { getDictOptions } from '#/utils/dict';
import { DictEnum } from '@vben/constants';
import { renderDict } from '#/utils/render';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
@ -57,10 +57,16 @@ export const columns: VxeGridProps['columns'] = [
{
title: '是否可售',
field: 'isForSale',
slots: {
default: ({ row }) => {
return renderDict(row.isForSale, DictEnum.wy_sf);
},
},
},
{
title: '状态',
field: 'statusName',
},
{
field: 'action',
@ -125,7 +131,11 @@ export const modalSchema: FormSchemaGetter = () => [
{
label: '是否可售',
fieldName: 'isForSale',
component: 'Input',
component: 'Select',
componentProps: {
getPopupContainer,
options: getDictOptions(DictEnum.wy_sf),
},
},
{
label: '状态',

View File

@ -134,8 +134,7 @@ export const drawerSchema: FormSchemaGetter = () => [
rules: z
.string()
.regex(/^1[3-9]\d{9}$/, '请输入正确的手机号码')
.optional()
.or(z.literal('')),
.min(1, '手机号码不能为空'),
},
{
component: 'Input',

View File

@ -73,15 +73,9 @@ async function viteExtraAppConfigPlugin({
async function getConfigSource() {
const config = await loadEnv();
const windowVariable = `window.${VBEN_ADMIN_PRO_APP_CONF}`;
// 确保变量不会被修改
// 只使用 Object.freeze 来防止配置被修改,不设置 window 对象属性为只读
let source = `${windowVariable}=${JSON.stringify(config)};`;
source += `
Object.freeze(${windowVariable});
Object.defineProperty(window, "${VBEN_ADMIN_PRO_APP_CONF}", {
configurable: false,
writable: false,
});
`.replaceAll(/\s/g, '');
source += `Object.freeze(${windowVariable});`;
return source;
}

View File

@ -21,7 +21,7 @@ export const DictEnum = {
wy_fjzt: 'wy_fjzt', // 房间状态
wy_direction_towards: 'direction_towards', // 房间朝向
sis_device_status: 'sis_device_status', //设备在线状态
wy_sf:'wy_sf',//是否可售
SIS_ACCESS_CONTROL_DEVICE_TYPE: 'sis_access_control_device_type',
SIS_LIB_TYPE: 'sis_lib_type',
WY_ZCSHZT: 'wy_zcshzt',