代码提交
This commit is contained in:
@ -133,7 +133,6 @@ const emit = defineEmits(['callback'])
|
||||
|
||||
const items = ref(props.items || [])
|
||||
// const defaultValue = ref(props.defaultValue)
|
||||
// console.log("--> % defaultValue:\n", defaultValue)
|
||||
|
||||
const value = ref(props.value || '请选择')
|
||||
const province = ref(props.items)
|
||||
@ -151,7 +150,6 @@ watch(() => props.items, (next) => {
|
||||
})
|
||||
|
||||
watch(() => props.defaultValue, (next) => {
|
||||
console.log("--> % defaultValue % next:\n", next)
|
||||
value.value = `${next.province.name} ${next.city.name} ${next.district.name}`
|
||||
setDefaultValue(items.value, next)
|
||||
})
|
||||
@ -179,7 +177,6 @@ const setDefaultValue = (items, value) => {
|
||||
}
|
||||
province.value = items
|
||||
items.map(prov => {
|
||||
console.log("--> % setDefaultValue % prov:\n", prov)
|
||||
if (prov.name == value.province.name) {
|
||||
city.value = prov.id
|
||||
provinceActive.value = {
|
||||
@ -205,7 +202,6 @@ const setDefaultValue = (items, value) => {
|
||||
})
|
||||
}
|
||||
})
|
||||
console.log(provinceActive.value, cityActive.value, districtActive.value)
|
||||
}
|
||||
|
||||
const open = () => {
|
||||
@ -248,23 +244,8 @@ const selectCity = (selectItem, index) => {
|
||||
}
|
||||
|
||||
const selectDistrict = (selectItem, index) => {
|
||||
console.log("--> % selectDistrict % selectItem:\n", selectItem)
|
||||
districtActive.value = selectItem
|
||||
value.value = `${provinceActive.value?.name} ${cityActive.value?.name} ${districtActive.value?.name}`
|
||||
console.log({
|
||||
province: {
|
||||
id: provinceActive.value?.id,
|
||||
name: provinceActive.value?.name,
|
||||
},
|
||||
city: {
|
||||
id: cityActive.value?.id,
|
||||
name: cityActive.value?.name,
|
||||
},
|
||||
district: {
|
||||
id: districtActive.value?.id,
|
||||
name: districtActive.value?.name,
|
||||
},
|
||||
})
|
||||
emit('callback', {
|
||||
province: {
|
||||
id: provinceActive.value?.id,
|
||||
@ -283,7 +264,7 @@ const selectDistrict = (selectItem, index) => {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
<style lang="scss">
|
||||
.cityselect {
|
||||
width: 100%;
|
||||
height: 75%;
|
||||
|
Reference in New Issue
Block a user