feat:房间查询

This commit is contained in:
2025-09-05 15:13:22 +08:00
parent a180aa1e42
commit 7848ae4acd
2 changed files with 43 additions and 15 deletions

View File

@@ -21,8 +21,8 @@ const emit = defineEmits<{
select: []; select: [];
}>(); }>();
const selectDeptId = defineModel('selectDeptId', { const selectFloorId = defineModel('selectFloorId', {
required: true, default: '',
type: Array as PropType<string[]>, type: Array as PropType<string[]>,
}); });
@@ -40,7 +40,7 @@ const showTreeSkeleton = ref<boolean>(true);
async function loadTree() { async function loadTree() {
showTreeSkeleton.value = true; showTreeSkeleton.value = true;
searchValue.value = ''; searchValue.value = '';
selectDeptId.value = []; selectFloorId.value = [];
const ret = await communityTree(3); const ret = await communityTree(3);
deptTreeArray.value = ret; deptTreeArray.value = ret;
showTreeSkeleton.value = false; showTreeSkeleton.value = false;
@@ -50,6 +50,9 @@ async function handleReload() {
await loadTree(); await loadTree();
emit('reload'); emit('reload');
} }
function selectNode(selectedKeys, e) {
emit('select',e.node.level);
}
onMounted(loadTree); onMounted(loadTree);
</script> </script>
@@ -86,14 +89,14 @@ onMounted(loadTree);
<Tree <Tree
v-bind="$attrs" v-bind="$attrs"
v-if="deptTreeArray.length > 0" v-if="deptTreeArray.length > 0"
v-model:selected-keys="selectDeptId" v-model:selected-keys="selectFloorId"
:class="$attrs.class" :class="$attrs.class"
:field-names="{ title: 'label', key: 'id' }" :field-names="{ title: 'label', key: 'id' }"
:show-line="{ showLeafIcon: false }" :show-line="{ showLeafIcon: false }"
:tree-data="deptTreeArray" :tree-data="deptTreeArray"
:virtual="false" :virtual="false"
default-expand-all default-expand-all
@select="$emit('select')" @select="selectNode"
> >
<template #title="{ label }"> <template #title="{ label }">
<span v-if="label.indexOf(searchValue) > -1"> <span v-if="label.indexOf(searchValue) > -1">

View File

@@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui'; import {Page, useVbenModal, type VbenFormProps} from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import {getVxePopupContainer} from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue'; import {Modal, Popconfirm, Space} from 'ant-design-vue';
import FloorTree from "./floor-tree.vue" import FloorTree from "./floor-tree.vue"
import { import {
@@ -15,11 +15,13 @@ import {
roomList, roomList,
roomRemove, roomRemove,
} from '#/api/property/room'; } from '#/api/property/room';
import type { RoomForm } from '#/api/property/room/model'; import type {RoomForm} from '#/api/property/room/model';
import { commonDownloadExcel } from '#/utils/file/download'; import {commonDownloadExcel} from '#/utils/file/download';
import roomModal from './room-modal.vue'; import roomModal from './room-modal.vue';
import { columns, querySchema } from './data'; import {columns, querySchema} from './data';
import DeptTree from "#/views/system/user/dept-tree.vue";
import {ref} from "vue";
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
commonConfig: { commonConfig: {
@@ -58,7 +60,19 @@ const gridOptions: VxeGridProps = {
pagerConfig: {}, pagerConfig: {},
proxyConfig: { proxyConfig: {
ajax: { ajax: {
query: async ({ page }, formValues = {}) => { query: async ({page}, formValues = {}) => {
Reflect.deleteProperty(formValues, 'communityId');
Reflect.deleteProperty(formValues, 'buildingId');
Reflect.deleteProperty(formValues, 'floorId');
if (selectFloorId.value.length === 1) {
if (level.value == 1) {
formValues.communityId = selectFloorId.value[0];
} else if (level.value == 2) {
formValues.buildingId = selectFloorId.value[0];
} else {
formValues.floorId = selectFloorId.value[0];
}
}
return await roomList({ return await roomList({
pageNum: page.currentPage, pageNum: page.currentPage,
pageSize: page.pageSize, pageSize: page.pageSize,
@@ -89,7 +103,7 @@ function handleAdd() {
} }
async function handleEdit(row: Required<RoomForm>) { async function handleEdit(row: Required<RoomForm>) {
modalApi.setData({ id: row.id }); modalApi.setData({id: row.id});
modalApi.open(); modalApi.open();
} }
@@ -117,12 +131,23 @@ function handleDownloadExcel() {
fieldMappingTime: formOptions.fieldMappingTime, fieldMappingTime: formOptions.fieldMappingTime,
}); });
} }
const selectFloorId = ref<string[]>([]);
const level = ref<number>();
function handleSelectFloor(nodeLevel: number) {
level.value = nodeLevel;
tableApi.reload()
}
</script> </script>
<template> <template>
<Page :auto-content-height="true" style="width: 100%"> <Page :auto-content-height="true" style="width: 100%">
<div class="flex h-full gap-[15px]"> <div class="flex h-full gap-[15px]">
<FloorTree></FloorTree> <FloorTree v-model:select-floor-id="selectFloorId"
class="w-[260px]"
@reload="() => tableApi.reload()"
@select="handleSelectFloor"></FloorTree>
<BasicTable class="flex-1 overflow-hidden" table-title="房间信息列表"> <BasicTable class="flex-1 overflow-hidden" table-title="房间信息列表">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
@@ -175,6 +200,6 @@ function handleDownloadExcel() {
</template> </template>
</BasicTable> </BasicTable>
</div> </div>
<RoomModal @reload="tableApi.query()" /> <RoomModal @reload="tableApi.query()"/>
</Page> </Page>
</template> </template>