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

View File

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

View File

@@ -3,15 +3,19 @@ import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { costMeterWaterAdd, costMeterWaterInfo, costMeterWaterUpdate } from '#/api/property/costMeterWater'; import {
costMeterWaterAdd,
costMeterWaterInfo,
costMeterWaterUpdate,
} from '#/api/property/costMeterWater';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { cloneDeep,handleNode,getPopupContainer } from '@vben/utils'; import { cloneDeep, handleNode, getPopupContainer } from '@vben/utils';
import { communityTree } from '#/api/property/community'; import { communityTree } from '#/api/property/community';
import { costItemSettingList} from '#/api/property/costManagement/costItemSetting'; import { costItemSettingList } from '#/api/property/costManagement/costItemSetting';
import { meterReadingTypeList } from '#/api/property/costManagement/meterReadingType'; import { meterReadingTypeList } from '#/api/property/costManagement/meterReadingType';
import { getDictOptions } from '#/utils/dict'; import { getDictOptions } from '#/utils/dict';
import {ultimoWater} from '#/api/property/costMeterWater' import { ultimoWater } from '#/api/property/costMeterWater';
import {personList} from '#/api/property/resident/person' import { personList } from '#/api/property/resident/person';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
const costItemsOptions = ref<any>([]); const costItemsOptions = ref<any>([]);
const meterTypeOptions = ref<any>([]); const meterTypeOptions = ref<any>([]);
@@ -20,7 +24,7 @@ const isUpdate = ref(false);
const title = computed(() => { const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add'); return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
}); });
const schema =[ const schema = [
{ {
label: '主键ID', label: '主键ID',
fieldName: 'id', fieldName: 'id',
@@ -34,7 +38,7 @@ const schema =[
label: '房间号', label: '房间号',
fieldName: 'roomId', fieldName: 'roomId',
component: 'TreeSelect', component: 'TreeSelect',
rules: 'required' rules: 'required',
}, },
{ {
label: '业主', label: '业主',
@@ -43,13 +47,13 @@ const schema =[
rules: 'required', rules: 'required',
componentProps: { componentProps: {
api: async () => { api: async () => {
const res = await personList({pageSize:1000000000,pageNum:1}); const res = await personList({ pageSize: 1000000000, pageNum: 1 });
return res.rows.map((item: any) => ({ return res.rows.map((item: any) => ({
label: item.userName, label: item.userName,
value: item.id, value: item.id,
})); }));
}, },
} },
}, },
{ {
label: '费用类型', label: '费用类型',
@@ -58,21 +62,29 @@ const schema =[
rules: 'required', rules: 'required',
componentProps: { componentProps: {
options: getDictOptions('wy_cbfylx'), options: getDictOptions('wy_cbfylx'),
onChange: async (value:any) => { onChange: async (value: any) => {
// 请求并更新下拉 // 请求并更新下拉
if (!value) { if (!value) {
costItemsOptions.value = []; costItemsOptions.value = [];
meterTypeOptions.value = []; meterTypeOptions.value = [];
isMeterType.value = false isMeterType.value = false;
} else { } else {
isMeterType.value = true isMeterType.value = true;
const costItemsRes = await costItemSettingList({ pageSize: 1000000000, pageNum: 1, costType: value }); const costItemsRes = await costItemSettingList({
costItemsOptions.value = (costItemsRes?.rows || []).map(item => ({ pageSize: 1000000000,
pageNum: 1,
costType: value,
});
costItemsOptions.value = (costItemsRes?.rows || []).map((item) => ({
label: item.chargeItem, label: item.chargeItem,
value: item.id, value: item.id,
})); }));
const meterTypeRes = await meterReadingTypeList({ pageSize: 1000000000, pageNum: 1, costType: value == '5' ? 0 : 1 }); const meterTypeRes = await meterReadingTypeList({
meterTypeOptions.value = (meterTypeRes?.rows || []).map(item => ({ pageSize: 1000000000,
pageNum: 1,
costType: value == '5' ? 0 : 1,
});
meterTypeOptions.value = (meterTypeRes?.rows || []).map((item) => ({
label: item.name, label: item.name,
value: item.id, value: item.id,
})); }));
@@ -100,8 +112,8 @@ const schema =[
meterTypeId: '', meterTypeId: '',
}); });
console.log(await formApi.getValues()); console.log(await formApi.getValues());
} },
} },
}, },
{ {
label: '收费项目', label: '收费项目',
@@ -111,7 +123,7 @@ const schema =[
componentProps: { componentProps: {
options: costItemsOptions.value, options: costItemsOptions.value,
disabled: !isMeterType.value, disabled: !isMeterType.value,
} },
}, },
{ {
label: '抄表类型', label: '抄表类型',
@@ -121,7 +133,7 @@ const schema =[
componentProps: { componentProps: {
options: meterTypeOptions.value, options: meterTypeOptions.value,
disabled: !isMeterType.value, disabled: !isMeterType.value,
} },
}, },
{ {
label: '上期止度', label: '上期止度',
@@ -144,7 +156,7 @@ const schema =[
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss', valueFormat: 'YYYY-MM-DD HH:mm:ss',
}, },
disabled:true disabled: true,
}, },
{ {
label: '本期读表时间', label: '本期读表时间',
@@ -161,7 +173,7 @@ const schema =[
label: '说明', label: '说明',
fieldName: 'remark', fieldName: 'remark',
component: 'Input', component: 'Input',
} },
]; ];
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -172,7 +184,7 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: schema, schema: schema,
showDefaultActions: false, showDefaultActions: false,
@@ -197,22 +209,30 @@ const [BasicModal, modalApi] = useVbenModal({
if (!isOpen) { if (!isOpen) {
return null; return null;
} }
isMeterType.value = true isMeterType.value = true;
setupCommunitySelect() setupCommunitySelect();
modalApi.modalLoading(true); modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await costMeterWaterInfo(id); const record = await costMeterWaterInfo(id);
console.log(1,record); console.log(1, record);
const costItemsRes = await costItemSettingList({ pageSize: 1000000000, pageNum: 1, costType: record.costType }); const costItemsRes = await costItemSettingList({
costItemsOptions.value = (costItemsRes?.rows || []).map(item => ({ pageSize: 1000000000,
pageNum: 1,
costType: record.costType,
});
costItemsOptions.value = (costItemsRes?.rows || []).map((item) => ({
label: item.chargeItem, label: item.chargeItem,
value: item.id, value: item.id,
})); }));
const meterTypeRes = await meterReadingTypeList({ pageSize: 1000000000, pageNum: 1, costType: record.costType == '5' ? 0 : 1 }); const meterTypeRes = await meterReadingTypeList({
meterTypeOptions.value = (meterTypeRes?.rows || []).map(item => ({ pageSize: 1000000000,
pageNum: 1,
costType: record.costType == '5' ? 0 : 1,
});
meterTypeOptions.value = (meterTypeRes?.rows || []).map((item) => ({
label: item.name, label: item.name,
value: item.id, value: item.id,
})); }));
@@ -233,8 +253,7 @@ const [BasicModal, modalApi] = useVbenModal({
}, },
]); ]);
await formApi.setValues(record); await formApi.setValues(record);
console.log(2,await formApi.getValues()); console.log(2, await formApi.getValues());
} }
await markInitialized(); await markInitialized();
@@ -253,12 +272,14 @@ async function handleConfirm() {
const data = cloneDeep(await formApi.getValues()); const data = cloneDeep(await formApi.getValues());
console.log(data); console.log(data);
await (isUpdate.value ? costMeterWaterUpdate(data) : costMeterWaterAdd(data)); await (isUpdate.value
? costMeterWaterUpdate(data)
: costMeterWaterAdd(data));
resetInitialized(); resetInitialized();
//必须要手动清空不然ref会保留值 //必须要手动清空不然ref会保留值
costItemsOptions.value = []; costItemsOptions.value = [];
meterTypeOptions.value = []; meterTypeOptions.value = [];
isMeterType.value = false isMeterType.value = false;
// 更新表单下拉 // 更新表单下拉
formApi.updateSchema([ formApi.updateSchema([
{ {
@@ -287,10 +308,10 @@ async function handleConfirm() {
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
await formApi.setValues({}) await formApi.setValues({});
costItemsOptions.value = []; costItemsOptions.value = [];
meterTypeOptions.value = []; meterTypeOptions.value = [];
isMeterType.value = false isMeterType.value = false;
// 更新表单下拉 // 更新表单下拉
formApi.updateSchema([ formApi.updateSchema([
{ {
@@ -312,12 +333,12 @@ async function handleClosed() {
} }
// 获取服务地址 // 获取服务地址
async function setupCommunitySelect() { async function setupCommunitySelect() {
const areaList = await communityTree(5); const areaList = await communityTree(4);
// 选中后显示在输入框的值 即父节点 / 子节点 // 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / '); // addFullName(areaList, 'areaName', ' / ');
const splitStr = '/'; const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) { handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 5) { if (node.level != 4) {
node.disabled = true; node.disabled = true;
} }
}); });
@@ -342,14 +363,14 @@ async function setupCommunitySelect() {
// 选中后显示在输入框的值 // 选中后显示在输入框的值
treeNodeLabelProp: 'fullName', treeNodeLabelProp: 'fullName',
onChange: async (value: any) => { onChange: async (value: any) => {
if(!value){ if (!value) {
await formApi.setValues({preDegrees:''}) await formApi.setValues({ preDegrees: '' });
await formApi.setValues({preReadingTime:''}) await formApi.setValues({ preReadingTime: '' });
}else{ } else {
const data = await ultimoWater(value) const data = await ultimoWater(value);
if(data){ if (data) {
await formApi.setValues({preDegrees:data.curDegrees}) await formApi.setValues({ preDegrees: data.curDegrees });
await formApi.setValues({preReadingTime:data.curReadingTime}) await formApi.setValues({ preReadingTime: data.curReadingTime });
} }
} }
}, },

View File

@@ -1,25 +1,25 @@
<script setup lang="ts"> <script setup lang="ts">
import {computed, ref} from 'vue'; import { computed, ref } from 'vue';
import {useVbenModal} from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import {$t} from '@vben/locales'; import { $t } from '@vben/locales';
import {cloneDeep, handleNode} from '@vben/utils'; import { cloneDeep, handleNode } from '@vben/utils';
import {useVbenForm} from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { import {
houseChargeAdd, houseChargeAdd,
houseChargeInfo, houseChargeInfo,
houseChargeUpdate houseChargeUpdate,
} from '#/api/property/costManagement/houseCharge'; } from '#/api/property/costManagement/houseCharge';
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import {modalSchema} from './data'; import { modalSchema } from './data';
import {communityTree} from "#/api/property/community"; import { communityTree } from '#/api/property/community';
import {costItemSettingList} from "#/api/property/costManagement/costItemSetting"; import { costItemSettingList } from '#/api/property/costManagement/costItemSetting';
import type {CostItemSettingVO} from "#/api/property/costManagement/costItemSetting/model"; import type { CostItemSettingVO } from '#/api/property/costManagement/costItemSetting/model';
import {getDictOptions} from "#/utils/dict"; import { getDictOptions } from '#/utils/dict';
import {personList} from "#/api/property/resident/person"; import { personList } from '#/api/property/resident/person';
import {renderDictValue} from "#/utils/render"; import { renderDictValue } from '#/utils/render';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
@@ -38,14 +38,14 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
}); });
const {onBeforeClose, markInitialized, resetInitialized} = useBeforeCloseDiff( const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{ {
initializedGetter: defaultFormValueGetter(formApi), initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi), currentGetter: defaultFormValueGetter(formApi),
@@ -64,16 +64,16 @@ const [BasicModal, modalApi] = useVbenModal({
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
await initRoomOptions() await initRoomOptions();
await queryCostItemOptions() await queryCostItemOptions();
await initCostTypeOptions() await initCostTypeOptions();
await queryPersonData() await queryPersonData();
const {id} = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await houseChargeInfo(id); const record = await houseChargeInfo(id);
record.chargeTime = [record.startTime, record.endTime] record.chargeTime = [record.startTime, record.endTime];
await formApi.setValues(record); await formApi.setValues(record);
} }
await markInitialized(); await markInitialized();
@@ -85,15 +85,15 @@ const [BasicModal, modalApi] = useVbenModal({
async function handleConfirm() { async function handleConfirm() {
try { try {
modalApi.lock(true); modalApi.lock(true);
const {valid} = await formApi.validate(); const { valid } = await formApi.validate();
if (!valid) { if (!valid) {
return; return;
} }
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues()); const data = cloneDeep(await formApi.getValues());
if (data.chargeTime && data.chargeTime.length) { if (data.chargeTime && data.chargeTime.length) {
data.startTime = data.chargeTime[0] data.startTime = data.chargeTime[0];
data.endTime = data.chargeTime[1] data.endTime = data.chargeTime[1];
} }
await (isUpdate.value ? houseChargeUpdate(data) : houseChargeAdd(data)); await (isUpdate.value ? houseChargeUpdate(data) : houseChargeAdd(data));
resetInitialized(); resetInitialized();
@@ -115,10 +115,10 @@ async function handleClosed() {
* 房间数据 * 房间数据
*/ */
async function initRoomOptions() { async function initRoomOptions() {
const roomList = await communityTree(5); const roomList = await communityTree(4);
const splitStr = '/'; const splitStr = '/';
handleNode(roomList, 'label', splitStr, function (node: any) { handleNode(roomList, 'label', splitStr, function (node: any) {
if (node.level != 5) { if (node.level != 4) {
node.disabled = true; node.disabled = true;
} }
}); });
@@ -136,7 +136,7 @@ async function initRoomOptions() {
showSearch: true, showSearch: true,
treeData: roomList, treeData: roomList,
treeDefaultExpandAll: true, treeDefaultExpandAll: true,
treeLine: {showLeafIcon: false}, treeLine: { showLeafIcon: false },
// 筛选的字段 // 筛选的字段
treeNodeFilterProp: 'label', treeNodeFilterProp: 'label',
// 选中后显示在输入框的值 // 选中后显示在输入框的值
@@ -150,63 +150,79 @@ async function initRoomOptions() {
/** /**
* 查询费用项设置 * 查询费用项设置
*/ */
async function queryCostItemOptions(costType:string) { async function queryCostItemOptions(costType: string) {
let params = { let params = {
pageSize: 1000, pageSize: 1000,
pageNum: 1, pageNum: 1,
costType costType,
} };
const res = await costItemSettingList(params) const res = await costItemSettingList(params);
costItemOptions.value = res.rows costItemOptions.value = res.rows;
formApi.updateSchema([{ formApi.updateSchema([
{
componentProps: { componentProps: {
options: costItemOptions.value, options: costItemOptions.value,
fieldNames: {label: 'chargeItem', value: 'id'}, fieldNames: { label: 'chargeItem', value: 'id' },
showSearch: true, showSearch: true,
optionFilterProp: 'chargeItem', optionFilterProp: 'chargeItem',
onChange: async (value: string) => { onChange: async (value: string) => {
if (value) { if (value) {
const costItem = costItemOptions.value.find(item => item.id == value) const costItem = costItemOptions.value.find(
if(costItem){ (item) => item.id == value,
await formApi.setFieldValue('remark', `单价:${costItem.unitPrice} 附加费:${costItem.surcharge}`); );
} if (costItem) {
await formApi.setFieldValue(
'remark',
`单价:${costItem.unitPrice} 附加费:${costItem.surcharge}`,
);
} }
} }
}, },
fieldName: 'costItemsId' },
}]) fieldName: 'costItemsId',
},
]);
} }
/** /**
* 初始化费用类型 * 初始化费用类型
*/ */
async function initCostTypeOptions(){ async function initCostTypeOptions() {
formApi.updateSchema([{ formApi.updateSchema([
{
componentProps: { componentProps: {
options: getDictOptions('pro_expense_type'), options: getDictOptions('pro_expense_type'),
onChange: async (value: string) => { onChange: async (value: string) => {
if (value) { if (value) {
await queryCostItemOptions(value) await queryCostItemOptions(value);
await formApi.setFieldValue('costItemsId', null) await formApi.setFieldValue('costItemsId', null);
}
} }
}, },
fieldName: 'costType' },
}]) fieldName: 'costType',
},
]);
} }
async function queryPersonData() { async function queryPersonData() {
let params = { let params = {
pageSize: 1000, pageSize: 1000,
pageNum: 1, pageNum: 1,
} };
const res = await personList(params); const res = await personList(params);
const options = res.rows.map((user) => ({ const options = res.rows.map((user) => ({
label: user.userName + '-' + renderDictValue(user.gender, 'sys_user_sex') label:
+ '-' + user.phone + '-' + user.unitName, user.userName +
'-' +
renderDictValue(user.gender, 'sys_user_sex') +
'-' +
user.phone +
'-' +
user.unitName,
value: user.id, value: user.id,
})); }));
formApi.updateSchema([{ formApi.updateSchema([
{
componentProps: () => ({ componentProps: () => ({
options: options, options: options,
showSearch: true, showSearch: true,
@@ -214,13 +230,13 @@ async function queryPersonData() {
optionLabelProp: 'label', optionLabelProp: 'label',
}), }),
fieldName: 'personId', fieldName: 'personId',
}]) },
]);
} }
</script> </script>
<template> <template>
<BasicModal :title="title"> <BasicModal :title="title">
<BasicForm/> <BasicForm />
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -2,9 +2,13 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { cloneDeep,handleNode,getPopupContainer } from '@vben/utils'; import { cloneDeep, handleNode, getPopupContainer } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { orderMaintainAdd, orderMaintainInfo, orderMaintainUpdate } from '#/api/property/conservationManagement'; import {
orderMaintainAdd,
orderMaintainInfo,
orderMaintainUpdate,
} from '#/api/property/conservationManagement';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data'; import { modalSchema } from './data';
import { communityTree } from '#/api/property/community'; import { communityTree } from '#/api/property/community';
@@ -21,7 +25,7 @@ const [BasicForm, formApi] = useVbenForm({
labelWidth: 80, labelWidth: 80,
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
@@ -45,7 +49,7 @@ const [BasicModal, modalApi] = useVbenModal({
if (!isOpen) { if (!isOpen) {
return null; return null;
} }
setupCommunitySelect() setupCommunitySelect();
modalApi.modalLoading(true); modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
@@ -91,12 +95,12 @@ async function handleClosed() {
// 获取服务地址 // 获取服务地址
async function setupCommunitySelect() { async function setupCommunitySelect() {
const areaList = await communityTree(5); const areaList = await communityTree(4);
// 选中后显示在输入框的值 即父节点 / 子节点 // 选中后显示在输入框的值 即父节点 / 子节点
// addFullName(areaList, 'areaName', ' / '); // addFullName(areaList, 'areaName', ' / ');
const splitStr = '/'; const splitStr = '/';
handleNode(areaList, 'label', splitStr, function (node: any) { handleNode(areaList, 'label', splitStr, function (node: any) {
if (node.level != 5) { if (node.level != 4) {
node.disabled = true; node.disabled = true;
} }
}); });
@@ -132,4 +136,3 @@ async function setupCommunitySelect() {
<BasicForm /> <BasicForm />
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -1,23 +1,27 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue' import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui' import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales' import { $t } from '@vben/locales';
import { cloneDeep, handleNode } from '@vben/utils' import { cloneDeep, handleNode } from '@vben/utils';
import { useVbenForm } from '#/adapter/form' import { useVbenForm } from '#/adapter/form';
import { resident_unitAdd, resident_unitInfo, resident_unitUpdate } from '#/api/property/resident/unit' import {
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup' resident_unitAdd,
resident_unitInfo,
resident_unitUpdate,
} from '#/api/property/resident/unit';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data' import { modalSchema } from './data';
import { communityTree } from "#/api/property/community" import { communityTree } from '#/api/property/community';
const emit = defineEmits<{ reload: [] }>() const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false) const isUpdate = ref(false);
const title = computed(() => { const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add') return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
}) });
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
@@ -28,19 +32,19 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
}) });
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff( const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{ {
initializedGetter: defaultFormValueGetter(formApi), initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi), currentGetter: defaultFormValueGetter(formApi),
}, },
) );
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度 // 在这里更改宽度
@@ -51,57 +55,57 @@ const [BasicModal, modalApi] = useVbenModal({
onConfirm: handleConfirm, onConfirm: handleConfirm,
onOpenChange: async (isOpen) => { onOpenChange: async (isOpen) => {
if (!isOpen) { if (!isOpen) {
return null return null;
} }
modalApi.modalLoading(true) modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string } const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id isUpdate.value = !!id;
await initLocationOptions() await initLocationOptions();
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await resident_unitInfo(id) const record = await resident_unitInfo(id);
await formApi.setValues(record) await formApi.setValues(record);
} }
await markInitialized() await markInitialized();
modalApi.modalLoading(false) modalApi.modalLoading(false);
}, },
}) });
async function handleConfirm() { async function handleConfirm() {
try { try {
modalApi.lock(true) modalApi.lock(true);
const { valid } = await formApi.validate() const { valid } = await formApi.validate();
if (!valid) { if (!valid) {
return return;
} }
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues()) const data = cloneDeep(await formApi.getValues());
data.authBegDate = data.authTime[0] data.authBegDate = data.authTime[0];
data.authEndDate = data.authTime[1] data.authEndDate = data.authTime[1];
await (isUpdate.value ? resident_unitUpdate(data) : resident_unitAdd(data)) await (isUpdate.value ? resident_unitUpdate(data) : resident_unitAdd(data));
resetInitialized() resetInitialized();
emit('reload') emit('reload');
modalApi.close() modalApi.close();
} catch (error) { } catch (error) {
console.error(error) console.error(error);
} finally { } finally {
modalApi.lock(false) modalApi.lock(false);
} }
} }
/** /**
* 入驻位置数据 * 入驻位置数据
*/ */
async function initLocationOptions() { async function initLocationOptions() {
const locationList = await communityTree(5) const locationList = await communityTree(4);
const splitStr = '/' const splitStr = '/';
handleNode(locationList, 'label', splitStr, function (node: any) { handleNode(locationList, 'label', splitStr, function (node: any) {
if (node.level != 5) { if (node.level != 4) {
node.disabled = true node.disabled = true;
} }
}) });
formApi.updateSchema([ formApi.updateSchema([
{ {
componentProps: () => ({ componentProps: () => ({
@@ -124,19 +128,17 @@ async function initLocationOptions() {
}), }),
fieldName: 'location', fieldName: 'location',
}, },
]) ]);
} }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm() await formApi.resetForm();
resetInitialized() resetInitialized();
} }
</script> </script>
<template> <template>
<BasicModal :title="title"> <BasicModal :title="title">
<BasicForm> <BasicForm> </BasicForm>
</BasicForm>
</BasicModal> </BasicModal>
</template> </template>

View File

@@ -1,19 +1,23 @@
<script setup lang="ts"> <script setup lang="ts">
import {computed, ref} from 'vue'; import { computed, ref } from 'vue';
import {useVbenModal} from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import {$t} from '@vben/locales'; import { $t } from '@vben/locales';
import {cloneDeep, getPopupContainer, handleNode} from '@vben/utils'; import { cloneDeep, getPopupContainer, handleNode } from '@vben/utils';
import {useVbenForm} from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import {meetAdd, meetInfo, meetUpdate} from '#/api/property/roomBooking/conferenceSettings'; import {
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup'; meetAdd,
meetInfo,
meetUpdate,
} from '#/api/property/roomBooking/conferenceSettings';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import {modalSchema} from './data'; import { modalSchema } from './data';
import {TimeRangePicker} from 'ant-design-vue' import { TimeRangePicker } from 'ant-design-vue';
import {renderDictValue} from "#/utils/render"; import { renderDictValue } from '#/utils/render';
import {personList} from "#/api/property/resident/person"; import { personList } from '#/api/property/resident/person';
import {communityTree} from "#/api/property/community"; import { communityTree } from '#/api/property/community';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
@@ -31,14 +35,14 @@ const [BasicForm, formApi] = useVbenForm({
// 通用配置项 会影响到所有表单项 // 通用配置项 会影响到所有表单项
componentProps: { componentProps: {
class: 'w-full', class: 'w-full',
} },
}, },
schema: modalSchema(), schema: modalSchema(),
showDefaultActions: false, showDefaultActions: false,
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
}); });
const {onBeforeClose, markInitialized, resetInitialized} = useBeforeCloseDiff( const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{ {
initializedGetter: defaultFormValueGetter(formApi), initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi), currentGetter: defaultFormValueGetter(formApi),
@@ -58,20 +62,20 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
await formApi.setValues({ await formApi.setValues({
expenseType:'1', expenseType: '1',
isCheck:'0', isCheck: '0',
}) });
const {id} = modalApi.getData() as { id?: number | string }; const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id; isUpdate.value = !!id;
await queryPerson() await queryPerson();
await initLocationOptions() await initLocationOptions();
if (isUpdate.value && id) { if (isUpdate.value && id) {
const record = await meetInfo(id); const record = await meetInfo(id);
record.expenseType=record.expenseType.toString() record.expenseType = record.expenseType.toString();
record.isCheck=record.isCheck.toString() record.isCheck = record.isCheck.toString();
let hour = record.openHours.split('-'); let hour = record.openHours.split('-');
if(hour.length>1){ if (hour.length > 1) {
record.openHours=[dayjs(hour[0],'HH:mm'),dayjs(hour[1],'HH:mm')] record.openHours = [dayjs(hour[0], 'HH:mm'), dayjs(hour[1], 'HH:mm')];
} }
await formApi.setValues(record); await formApi.setValues(record);
} }
@@ -84,14 +88,17 @@ const [BasicModal, modalApi] = useVbenModal({
async function handleConfirm() { async function handleConfirm() {
try { try {
modalApi.lock(true); modalApi.lock(true);
const {valid} = await formApi.validate(); const { valid } = await formApi.validate();
if (!valid) { if (!valid) {
return; return;
} }
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次 // getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues()); const data = cloneDeep(await formApi.getValues());
if (data.openHours) { if (data.openHours) {
data.openHours = data.openHours[0]?.format("HH:mm") + '-' + data.openHours[1]?.format("HH:mm"); data.openHours =
data.openHours[0]?.format('HH:mm') +
'-' +
data.openHours[1]?.format('HH:mm');
} }
await (isUpdate.value ? meetUpdate(data) : meetAdd(data)); await (isUpdate.value ? meetUpdate(data) : meetAdd(data));
resetInitialized(); resetInitialized();
@@ -113,20 +120,27 @@ async function queryPerson() {
let params = { let params = {
pageSize: 1000, pageSize: 1000,
pageNum: 1, pageNum: 1,
} };
const res = await personList(params); const res = await personList(params);
const options = res.rows.map((user) => ({ const options = res.rows.map((user) => ({
label: user.userName + '-' + renderDictValue(user.gender, 'sys_user_sex') + '-' + user.phone, label:
user.userName +
'-' +
renderDictValue(user.gender, 'sys_user_sex') +
'-' +
user.phone,
value: user.id, value: user.id,
})); }));
formApi.updateSchema([{ formApi.updateSchema([
{
componentProps: () => ({ componentProps: () => ({
options: options, options: options,
filterOption: filterOption, filterOption: filterOption,
showSearch:true, showSearch: true,
}), }),
fieldName: 'principals', fieldName: 'principals',
}]) },
]);
} }
const filterOption = (input: string, option: any) => { const filterOption = (input: string, option: any) => {
@@ -137,10 +151,10 @@ const filterOption = (input: string, option: any) => {
* 地址数据 * 地址数据
*/ */
async function initLocationOptions() { async function initLocationOptions() {
const locationList = await communityTree(5); const locationList = await communityTree(4);
const splitStr = '/'; const splitStr = '/';
handleNode(locationList, 'label', splitStr, function (node: any) { handleNode(locationList, 'label', splitStr, function (node: any) {
if (node.level != 5) { if (node.level != 4) {
node.disabled = true; node.disabled = true;
} }
}); });
@@ -159,7 +173,7 @@ async function initLocationOptions() {
showSearch: true, showSearch: true,
treeData: locationList, treeData: locationList,
treeDefaultExpandAll: true, treeDefaultExpandAll: true,
treeLine: {showLeafIcon: false}, treeLine: { showLeafIcon: false },
// 筛选的字段 // 筛选的字段
treeNodeFilterProp: 'label', treeNodeFilterProp: 'label',
// 选中后显示在输入框的值 // 选中后显示在输入框的值
@@ -180,4 +194,3 @@ async function initLocationOptions() {
</BasicForm> </BasicForm>
</BasicModal> </BasicModal>
</template> </template>