feat: 修改地址查询层级

This commit is contained in:
fyy
2025-07-30 14:57:42 +08:00
parent 64a01a3d6f
commit e0d55b6ab4
7 changed files with 440 additions and 346 deletions

View File

@@ -6,7 +6,7 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep,handleNode,getPopupContainer } from '@vben/utils';
import { cloneDeep, handleNode, getPopupContainer } from '@vben/utils';
import { Button, Table } from 'ant-design-vue';
import dayjs from 'dayjs';
@@ -43,7 +43,11 @@ const isAudit = ref(false);
const isRefund = ref(false);
const rowData = ref<any>({});
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : isReadonly.value ? '详情' : $t('pages.common.add');
return isUpdate.value
? $t('pages.common.edit')
: isReadonly.value
? '详情'
: $t('pages.common.add');
});
// 用来缓存 cleanList 的完整数据
@@ -123,9 +127,9 @@ const [BasicModal, modalApi] = useVbenModal({
return null;
}
// 查询服务地址树形结构
setupCommunitySelect()
setupCommunitySelect();
modalApi.modalLoading(true);
const { id, readonly,audit,refund,row } = modalApi.getData() as {
const { id, readonly, audit, refund, row } = modalApi.getData() as {
id?: string;
readonly?: boolean;
audit?: boolean;
@@ -138,9 +142,9 @@ const [BasicModal, modalApi] = useVbenModal({
isRefund.value = !!refund;
rowData.value = row;
//判断是否是编辑状态需要先判断是否是只读状态
if(isReadonly.value){
if (isReadonly.value) {
isUpdate.value = false;
}else{
} else {
isUpdate.value = !!id;
}
if ((isUpdate.value || isReadonly.value) && id) {
@@ -149,9 +153,9 @@ const [BasicModal, modalApi] = useVbenModal({
if (record.endTime) record.endTime = dayjs(record.endTime);
editUnitId.value = record.unitId || '';
detailTable.value = record.cleanList || [];
for(const item of record.relationList){
for(let i = 0; i < detailTable.value.length; i++){
if(item.cleanId === detailTable.value[i].id){
for (const item of record.relationList) {
for (let i = 0; i < detailTable.value.length; i++) {
if (item.cleanId === detailTable.value[i].id) {
detailTable.value[i].area = item.areas;
detailTable.value[i].sumPeices = item.sumPrice;
}
@@ -271,11 +275,11 @@ const detailColumns = [
dataIndex: 'sumPeices',
key: 'sumPeices',
},
{
title: '操作',
key: 'action',
fixed: 'right' as const,
},
{
title: '操作',
key: 'action',
fixed: 'right' as const,
},
];
const [DetailTable, detailTableApi] = useVbenVxeGrid({
@@ -298,7 +302,6 @@ function handleDetailReload(data: any) {
// 编辑订单服务详情
function handleEditDetailReload(data: any) {
detailTable.value[data.index] = data;
}
// 删除订单服务详情
function handleDeleteDetail(record: any, index: number) {
@@ -342,11 +345,15 @@ async function handleConfirm() {
data.unit = unitObj ? unitObj.name : data.unit || '';
data.name = cleanObj ? cleanObj.name : data.name || '';
data.unitId = unitObj ? unitObj.id : isUpdate.value ? editUnitId.value : '';
data.sumPeices = Number(totalSumPeices.value)
data.sumPeices = Number(totalSumPeices.value);
data.cleanList = detailTable.value;
if (data.starTime) data.starTime = dayjs(data.starTime).format('YYYY-MM-DD HH:mm:ss');
if (data.endTime) data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss');
isUpdate.value ? await clean_orderUpdate({...data,id:editCleanOrderId.value}) : await clean_orderAdd(data);
if (data.starTime)
data.starTime = dayjs(data.starTime).format('YYYY-MM-DD HH:mm:ss');
if (data.endTime)
data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss');
isUpdate.value
? await clean_orderUpdate({ ...data, id: editCleanOrderId.value })
: await clean_orderAdd(data);
resetInitialized();
emit('reload');
modalApi.close();
@@ -359,17 +366,17 @@ async function handleConfirm() {
async function handleClosed() {
await formApi.resetForm();
detailTable.value = [];//清空详情表格
detailTable.value = []; //清空详情表格
resetInitialized();
}
// 获取服务地址
async function setupCommunitySelect() {
const areaList = await communityTree(5);
const areaList = await communityTree(4);
// 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / ');
const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 5) {
if (node.level != 4) {
node.disabled = true;
}
});
@@ -399,58 +406,65 @@ async function setupCommunitySelect() {
]);
}
async function handleAudit(params: any) {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
const data = cloneDeep(await formApi.getValues());
if(rowData.value){
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
const data = cloneDeep(await formApi.getValues());
if (rowData.value) {
data.state = rowData.value.state;
data.isUnbooking = rowData.value?.isUnbooking;
}
// 单位数据缓存
if (unitListData.length === 0) {
const res = await resident_unitList();
unitListData = res.rows || [];
}
// 劳务数据缓存 cleanListData 已有
// 查找label
const unitObj = unitListData.find((item) => item.id === data.unitId);
const cleanObj = cleanListData.find((item) => item.id === data.name);
data.unit = unitObj ? unitObj.name : data.unit || '';
data.name = cleanObj ? cleanObj.name : data.name || '';
data.unitId = unitObj ? unitObj.id : isUpdate.value ? editUnitId.value : '';
data.sumPeices = Number(totalSumPeices.value)
data.starTime = dayjs(data.starTime).format('YYYY-MM-DD HH:mm:ss');
data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss');
// data.sumPeices = parseInt(totalSumPeices.value, 10);
// 组装 cleanIds
// data.cleanIds = detailTable.value.map((item: any) => item.id);
data.cleanList = detailTable.value;
if(params.isRefund){
data.isUnbooking = 1;
} else if(params.isAudit){
data.state = 1;
}else{
data.state = 2;
}
// 0未审核 1审核通过 2审核不通过
await clean_orderUpdate({...data,id:editCleanOrderId.value})
resetInitialized();
emit('reload');
modalApi.close();
}
// 单位数据缓存
if (unitListData.length === 0) {
const res = await resident_unitList();
unitListData = res.rows || [];
}
// 劳务数据缓存 cleanListData 已有
// 查找label
const unitObj = unitListData.find((item) => item.id === data.unitId);
const cleanObj = cleanListData.find((item) => item.id === data.name);
data.unit = unitObj ? unitObj.name : data.unit || '';
data.name = cleanObj ? cleanObj.name : data.name || '';
data.unitId = unitObj ? unitObj.id : isUpdate.value ? editUnitId.value : '';
data.sumPeices = Number(totalSumPeices.value);
data.starTime = dayjs(data.starTime).format('YYYY-MM-DD HH:mm:ss');
data.endTime = dayjs(data.endTime).format('YYYY-MM-DD HH:mm:ss');
// data.sumPeices = parseInt(totalSumPeices.value, 10);
// 组装 cleanIds
// data.cleanIds = detailTable.value.map((item: any) => item.id);
data.cleanList = detailTable.value;
if (params.isRefund) {
data.isUnbooking = 1;
} else if (params.isAudit) {
data.state = 1;
} else {
data.state = 2;
}
// 0未审核 1审核通过 2审核不通过
await clean_orderUpdate({ ...data, id: editCleanOrderId.value });
resetInitialized();
emit('reload');
modalApi.close();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm>
</BasicForm>
<BasicForm> </BasicForm>
<!-- 添加订单详情部分 -->
<div class="mt-4">
<div class="mb-2 flex items-center justify-between">
<h3 class="text-lg font-medium">{{ isUpdate ? '编辑保洁订单详情' : isReadonly ? '查看保洁订单详情' : '添加保洁订单详情' }} </h3>
<h3 class="text-lg font-medium">
{{
isUpdate
? '编辑保洁订单详情'
: isReadonly
? '查看保洁订单详情'
: '添加保洁订单详情'
}}
</h3>
<a-button v-if="!isReadonly" type="primary" @click="handleAddDetail">
{{ $t('pages.common.add') }}
</a-button>
@@ -468,10 +482,26 @@ async function handleAudit(params: any) {
<template v-if="isReadonly">
<Button @click="handleViewDetail(record)">查看</Button>
</template>
<template v-else >
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleViewDetail(record)">查看</Button>
<Button type="primary" size="small" style="margin-right: 5px;" @click="handleEditDetail(record, index)">编辑</Button>
<Button danger size="small" @click="handleDeleteDetail(record, index)">
<template v-else>
<Button
type="primary"
size="small"
style="margin-right: 5px"
@click="handleViewDetail(record)"
>查看</Button
>
<Button
type="primary"
size="small"
style="margin-right: 5px"
@click="handleEditDetail(record, index)"
>编辑</Button
>
<Button
danger
size="small"
@click="handleDeleteDetail(record, index)"
>
删除
</Button>
</template>
@@ -480,17 +510,26 @@ async function handleAudit(params: any) {
</Table>
<div>费用合计{{ totalSumPeices }}</div>
</div>
<CleanDetailModal @reload="handleDetailReload" @editReload="handleEditDetailReload"/>
<CleanDetailModal
@reload="handleDetailReload"
@editReload="handleEditDetailReload"
/>
<template #footer v-if="isAudit">
<a-button @click="modalApi.close()">取消</a-button>
<a-button type="primary" @click="handleAudit({isAudit:true})">审核通过</a-button>
<a-button danger @click="handleAudit({isAudit:false})">审核通过</a-button>
<a-button type="primary" @click="handleAudit({ isAudit: true })"
>审核通过</a-button
>
<a-button danger @click="handleAudit({ isAudit: false })"
>审核不通过</a-button
>
</template>
<template #footer v-if="isRefund">
<a-button @click="modalApi.close()">取消</a-button>
<a-button type="primary" @click="handleAudit({isRefund:true})">退定</a-button>
<a-button type="primary" @click="handleAudit({ isRefund: true })"
>退定</a-button
>
</template>
</BasicModal>
</BasicModal>
</template>
<style scoped>

View File

@@ -23,7 +23,7 @@ import { onMounted, ref } from 'vue';
import { communityTree } from '#/api/property/community';
const areaList = ref<any>(null);
onMounted(async () => {
areaList.value = await communityTree(5);
areaList.value = await communityTree(4);
});
const formOptions: VbenFormProps = {
commonConfig: {