Commit 74f59bc6 by 匡雅琴

省市组件优化

1 parent 842248aa
......@@ -235,7 +235,6 @@ export default {
// 打开地图弹框
hanleSelectMap() {
console.log(this.provinceForm)
this.dialogMapVisible = true
this.$nextTick(() => {
if (this.provinceForm.fullAddress && !this.$refs.mapForm.address) {
......@@ -259,12 +258,14 @@ export default {
var mapData = this.$refs.mapForm.geocoderAddress
// 赋值省市区名称和code
const { city, citycode, province, district, towncode } = mapData.addressComponent
this.provinceForm.provinceName = province
this.provinceForm.cityName = city
this.provinceForm.townName = district
this.provinceForm.provincecode = mapData.adcode
this.provinceForm.citycode = citycode
this.provinceForm.towncode = towncode
if (!this.provinceForm.provinceName) {
this.provinceForm.provinceName = province
this.provinceForm.cityName = city
this.provinceForm.townName = district
this.provinceForm.provinceCode = mapData.adcode
this.provinceForm.cityCode = citycode
this.provinceForm.townCode = towncode
}
var fullAddress = ''
var provincecode = ''
// 为防止打开地图弹框不选择地址点确定按钮无法正确判断地址选择是否正确产生的报错,设置this.addressData.fullAddress来保存上次选择的地址
......@@ -298,6 +299,7 @@ export default {
}
// 判断省市是否匹配
// 如果只展示省市
console.log(this.provinceForm.provinceName, provincename, '12121212')
if (this.provinceForm.provinceName && !this.provinceForm.townName) {
if (this.provinceForm.provinceName !== provincename || this.provinceForm.cityName !== cityname) {
this.$message.error('您选择的地址错误,请重新选择')
......@@ -312,8 +314,6 @@ export default {
}
}
this.dialogMapVisible = false
// this.subdistrict == 2 ? this.init(province, city) : this.init(province, city, town)
// console.log(this.provinceForm.lat, 'provinceForm')
// 通过地图选择省市区
this.$emit('selectAddressByMap', this.provinceForm)
}
......@@ -342,6 +342,10 @@ export default {
.el-form-item__content {
width: 474px;
display: flex;
margin-left: 0 !important;
}
.el-form-item {
display: flex;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!