|
@ -7,7 +7,7 @@ |
|
|
<template #dropdown> |
|
|
<template #dropdown> |
|
|
<el-dropdown-menu> |
|
|
<el-dropdown-menu> |
|
|
<el-dropdown-item |
|
|
<el-dropdown-item |
|
|
@click="handleCity(item.deptId, item.deptName)" |
|
|
@click="handleCity(item.deptId, true)" |
|
|
v-for="(item, index) in cityList" |
|
|
v-for="(item, index) in cityList" |
|
|
:label="item.deptName" |
|
|
:label="item.deptName" |
|
|
:value="item.deptId" |
|
|
:value="item.deptId" |
|
@ -29,7 +29,7 @@ |
|
|
:label="item.deptName" |
|
|
:label="item.deptName" |
|
|
:value="item.deptId" |
|
|
:value="item.deptId" |
|
|
:key="index" |
|
|
:key="index" |
|
|
@click="handleApartment(item.deptId, item.deptName)" |
|
|
@click="handleApartment(item.deptId, true)" |
|
|
>{{ item.deptName }}</el-dropdown-item |
|
|
>{{ item.deptName }}</el-dropdown-item |
|
|
> |
|
|
> |
|
|
</el-dropdown-menu> |
|
|
</el-dropdown-menu> |
|
@ -47,7 +47,7 @@ |
|
|
:label="item.typeName" |
|
|
:label="item.typeName" |
|
|
:value="item.id" |
|
|
:value="item.id" |
|
|
:key="index" |
|
|
:key="index" |
|
|
@click="handleHouseType(item.id, item.typeName)" |
|
|
@click="handleHouseType(item.id, true)" |
|
|
>{{ item.typeName }}</el-dropdown-item |
|
|
>{{ item.typeName }}</el-dropdown-item |
|
|
> |
|
|
> |
|
|
</el-dropdown-menu> |
|
|
</el-dropdown-menu> |
|
@ -56,14 +56,14 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<script setup> |
|
|
<script setup> |
|
|
import { ref, reactive, onMounted, onUnmounted } from "vue"; |
|
|
import { ref, reactive, onMounted, onUnmounted ,watch} from "vue"; |
|
|
import { getAgencyList, getHouseTypeList } from "@/api/index"; |
|
|
import { getAgencyList, getHouseTypeList } from "@/api/index"; |
|
|
const emit = defineEmits(["changeAngecy"]); |
|
|
const emit = defineEmits(["changeAngecy"]); |
|
|
const props = defineProps({ |
|
|
const props = defineProps({ |
|
|
deptName: { |
|
|
selfMarkers: { |
|
|
// 部门名称 |
|
|
// 部门名称 |
|
|
type: String, // 类型为字符串 |
|
|
type: Object, |
|
|
default: "", |
|
|
default:()=>{}, |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
const list = ref([]); // 定义列表数据 |
|
|
const list = ref([]); // 定义列表数据 |
|
@ -103,28 +103,35 @@ const getDropdownList = async (type) => { |
|
|
console.error("获取数据失败:", err); // 处理错误 |
|
|
console.error("获取数据失败:", err); // 处理错误 |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
const handleCity = (id, name) => { |
|
|
const handleCity = async (id, refresh) => { |
|
|
deptId.value = id; |
|
|
deptId.value = id; |
|
|
cityName.value = name; |
|
|
cityName.value = cityList.value.find((item) => item.deptId === id)?.deptName; |
|
|
apartmentList.value = []; // 清空 apartmentList |
|
|
apartmentList.value = []; // 清空 apartmentList |
|
|
roomTypeList.value = []; // 清空 roomTypeList |
|
|
roomTypeList.value = []; // 清空 roomTypeList |
|
|
apartmentName.value = "请选择"; // 清空 apartmentName |
|
|
apartmentName.value = "请选择"; // 清空 apartmentName |
|
|
houseTypeName.value = "请选择"; // 清空 apartmentName |
|
|
houseTypeName.value = "请选择"; // 清空 apartmentName |
|
|
emit("changeAngecy", { id, type: "city" }); |
|
|
if(refresh){ |
|
|
getDropdownList("apartment"); |
|
|
emit("changeAngecy", { id, type: "city" }); |
|
|
|
|
|
} |
|
|
|
|
|
await getDropdownList("apartment"); |
|
|
}; |
|
|
}; |
|
|
const handleApartment = (id, name) => { |
|
|
const handleApartment = async (id, refresh) => { |
|
|
roomTypeList.value = []; // 清空 roomTypeList |
|
|
roomTypeList.value = []; // 清空 roomTypeList |
|
|
apartmentName.value = name; |
|
|
const item = apartmentList.value.find((item) => item.deptId === id) |
|
|
|
|
|
apartmentName.value = item.deptName; |
|
|
deptId.value = id; |
|
|
deptId.value = id; |
|
|
houseTypeName.value = "请选择"; // 清空 apartmentName |
|
|
houseTypeName.value = "请选择"; // 清空 apartmentName |
|
|
emit("changeAngecy", { id, type: "apartment" }); |
|
|
if(refresh){ |
|
|
getHouseType(id); |
|
|
emit("changeAngecy", { id, type: "apartment",item }); |
|
|
|
|
|
} |
|
|
|
|
|
await getHouseType(id); |
|
|
}; |
|
|
}; |
|
|
const handleHouseType = (id, name) => { |
|
|
const handleHouseType = (id, refresh) => { |
|
|
houseTypeName.value = name; |
|
|
houseTypeName.value = roomTypeList.value.find((item) => item.id === id)?.typeName;; |
|
|
deptId.value = id; |
|
|
deptId.value = id; |
|
|
emit("changeAngecy", { id, type: "houseType" }); |
|
|
if(refresh){ |
|
|
|
|
|
emit("changeAngecy", { id, type: "houseType" }); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
const getHouseType = async (id) => { |
|
|
const getHouseType = async (id) => { |
|
|
try { |
|
|
try { |
|
@ -137,5 +144,13 @@ const getHouseType = async (id) => { |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
// 组件挂载时获取数据 |
|
|
// 组件挂载时获取数据 |
|
|
getQIngDaoId(); // 调用获取数据函数 |
|
|
getQIngDaoId(); // 调用获取数据函数 |
|
|
|
|
|
watch( |
|
|
|
|
|
() => props.selfMarkers, |
|
|
|
|
|
async (newVal,oldVal) => { |
|
|
|
|
|
await handleCity(newVal.deptId); |
|
|
|
|
|
await handleApartment(newVal.apartmentId) |
|
|
|
|
|
}, |
|
|
|
|
|
{ deep: true } |
|
|
|
|
|
); |
|
|
}); |
|
|
}); |
|
|
</script> |
|
|
</script> |