访客模块待完成

This commit is contained in:
Zy
2026-04-11 17:55:11 +08:00
parent 67a292b252
commit d957d1a039
35 changed files with 4564 additions and 95 deletions

View File

@@ -0,0 +1,208 @@
<template>
<div class="residentBox" @click="choiceResidentFun">
<div class="defaultbox" v-if="multipleSelection.length === 0">
<span>请选择</span>
<el-icon><Search /></el-icon>
</div>
<div v-else class="overflow-auto overflow-hidden w-full text-ellipsis text-nowrap">
<span>姓名{{ multipleSelection[0] && multipleSelection[0].name }}</span>
</div>
</div>
<el-dialog append-to-body v-model="dialog.dialogVisible" :title="dialog.dialogTitle" width="1050">
<nav class="flex flex-items-center mb-8">
<div class="flex flex-items-center mr-5 flex-1">
<div style="width: 120px">选择员工</div>
<el-select v-model="queryParams.ownerRelationship" placeholder="请选择" clearable>
<el-option v-for="dict in com_resident_relationship" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</div>
<div class="mr-5 flex-1">
<el-input clearable v-model.number="queryParams.name" placeholder="请输入员工姓名" />
</div>
<div>
<el-button type="primary" @click="getlist">查询</el-button>
<el-button>重置</el-button>
</div>
</nav>
<el-table ref="multipleTableRef" @selection-change="handleSelectionChange" :data="tableData" border>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" width="55" type="index" />
<el-table-column label="姓名" align="center" prop="name" />
<el-table-column label="角色" align="center" width="85" prop="type">
<template #default="{ row }">
<dict-tag :options="com_resident_type" :value="row.type" />
</template>
</el-table-column>
<el-table-column label="状态" align="center" width="85" prop="status">
<template #default="{ row }">
<dict-tag :options="com_certification_status" :value="row.status" />
</template>
</el-table-column>
<el-table-column label="手机号码" align="center" prop="phone" />
</el-table>
<template #footer>
<div class="dialog-footer flex flex-items-center flex-justify-between">
<pagination
style="margin-top: 0"
layout="total, prev, pager, next, jumper"
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getlist"
/>
<div>
<el-button @click="conback">退出</el-button>
<el-button type="primary" @click="confim"> 确定 </el-button>
</div>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { getCommunitylistAPI } from '@/api/system/community';
import { getVillageTree } from '@/api/system/house';
import { listResident } from '@/api/system/resident';
import { ResidentVO } from '@/api/system/resident/type';
import { convertBuildingToTree, getHousePathById } from '@/utils/house';
import { ref } from 'vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_resident_type } = toRefs<any>(proxy?.useDict('com_resident_type'));
const { com_certification_status } = toRefs<any>(proxy?.useDict('com_certification_status'));
const { com_resident_relationship } = toRefs<any>(proxy?.useDict('com_resident_relationship'));
interface tableType extends ResidentVO {
housePath?: string;
}
const props = defineProps<{
userid: string;
}>();
// 2. 转成 ref更安全可选但推荐
const { userid } = toRefs(props);
const emit = defineEmits<{
change: [value: string | number];
}>();
const dialog = ref({
dialogVisible: false,
dialogTitle: '选择住户'
});
const queryParams = ref({
pageNum: 1,
pageSize: 10,
date: null,
type: null,
status: null,
ownerRelationship: null,
name: null,
houseId: null,
villageId: null,
buildingId: null,
unitNo: null
});
const multipleTableRef = ref();
const tableData = ref<tableType[]>([]);
const multipleSelection = ref([]);
const total = ref(100);
const loading = ref(false);
getlist();
watch(
userid,
(newval) => {
if (newval !== null && newval !== undefined && newval.length > 0) {
const find = tableData.value.find((item) => item.id == newval);
if (find) {
multipleSelection.value = [find];
}
}
},
{
deep: true,
immediate: true
}
);
//
function choiceResidentFun() {
dialog.value.dialogVisible = true;
}
// 获取表格
function getlist() {
// 查询住户
loading.value = true;
listResident(queryParams.value).then((res) => {
tableData.value = res.rows;
total.value = res.total;
loading.value = false;
});
}
// 返回
function conback() {
dialog.value.dialogVisible = false;
queryParams.value = {
pageNum: 1,
pageSize: 10,
ownerRelationship: null,
name: null,
date: null,
type: null,
status: null,
houseId: null,
villageId: null,
buildingId: null,
unitNo: null
};
}
// 确定
function confim() {
dialog.value.dialogVisible = false;
if (multipleSelection.value.length > 0) {
const pop = multipleSelection.value.pop();
multipleSelection.value = [pop];
emit('change', pop.id);
}
}
// 单选
function handleSelectionChange(val) {
if (val && val.length > 0) {
const lastoptions = val.pop();
val.forEach((row) => {
multipleTableRef.value!.toggleRowSelection(row, false);
});
multipleTableRef.value!.toggleRowSelection(lastoptions, true);
multipleSelection.value = [lastoptions];
} else {
multipleTableRef.value!.clearSelection();
multipleSelection.value = [];
}
}
</script>
<style scoped lang="scss">
.residentBox {
width: 385px;
height: 35px;
line-height: 35px;
border: 1px solid #ccc;
border-radius: 5px;
padding: 0 10px;
.defaultbox {
display: flex;
align-items: center;
justify-content: space-between;
}
cursor: pointer;
&:hover {
background-color: #f4f8ff;
}
}
</style>