Commit 16889dcc by 匡雅琴

省市组件更换

1 parent 7a6632c6
<template> <template>
<div v-if="provinceView"> <div v-if="provinceView">
<el-form ref="provinceForm" :model="provinceForm" inline="true" class="province"> <el-form ref="provinceForm" :model="provinceForm" :inline="inline" class="province" label-width="154px">
<el-select size="small" v-model="provinceForm.provinceName" clearable placeholder="选择省份" :style="{ width: defaultWidth }" @change="selectProvince" class="select-padding"> <el-form-item :label="provinceLabel">
<el-option v-for="item in AllData" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectProvince(item)"></el-option> <el-select size="small" v-model="provinceForm.provinceName" clearable placeholder="选择省份" @clear="selectProvince" class="select-padding" :style="{ width: subdistrict == 2 ? '52%' : '33.33%' }">
</el-select> <el-option v-for="(item, index) in AllData" :key="'province' + index" :label="item.name" :value="item.name" @click.native="selectProvince(item)"></el-option>
<el-select size="small" v-model="provinceForm.cityName" clearable placeholder="选择市" :style="{ width: defaultWidth }" @change="selectCity" class="select-padding"> </el-select>
<el-option v-for="item in cityList" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectCity(item)"></el-option> <el-select size="small" v-model="provinceForm.cityName" clearable placeholder="选择市" @clear="selectCity" class="select-padding" :style="{ width: subdistrict == 2 ? '52%' : '33.33%' }">
</el-select> <el-option v-for="(item, index) in cityList" :key="'city' + index" :label="item.name" :value="item.name" @click.native="selectCity(item)"></el-option>
<el-select v-if="subdistrict == 3" size="small" v-model="provinceForm.townName" clearable placeholder="选择区" :style="{ width: defaultWidth }" @change="selectTown" class="select-padding"> </el-select>
<el-option v-for="item in townList" :key="item.adcode" :label="item.name" :value="item.name" @click.native="selectTown(item)"></el-option> <el-select v-if="subdistrict == 3" size="small" v-model="provinceForm.townName" clearable placeholder="选择区" @clear="selectTown" class="select-padding" :style="{ width: subdistrict == 2 ? '52%' : '33.33%' }">
</el-select> <el-option v-for="(item, index) in townList" :key="'town' + index" :label="item.name" :value="item.name" @click.native="selectTown(item)"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="detailAddressLabel">
<el-input size="small" v-if="mapView" readonly placeholder="请选择详细地址" v-model="provinceForm.fullAddress">
<el-button size="small" slot="append" @click="hanleSelectMap">
<img src="@/assets/map.png" alt="" class="map-icon" />
</el-button>
</el-input>
</el-form-item>
</el-form> </el-form>
<GLDialog :visible.sync="dialogMapVisible" :mode="'big'" bigTitle="选择地址">
<map-view ref="mapForm" :mapHeight="mapHeight"></map-view>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogMapVisible = false">取 消</el-button>
<el-button size="small" type="primary" @click="getAddress">确 定</el-button>
</span>
</GLDialog>
</div> </div>
</template> </template>
<script> <script>
import mapView from './mapView.vue'
// import GLDialog from '@/packages/GLDialog/src/GLDialog'
export default { export default {
name: 'GLProvince', name: 'GLProvince',
components: {
mapView
// GLDialog
},
props: { props: {
// 省市级别,2--只显示省市,3--显示省市区,默认只显示省市 // 是否一行展示
inline: {
type: Boolean,
default: false
},
// 省市级别,2--只显示省市,3--显示省市区
subdistrict: { subdistrict: {
type: Number, type: Number,
// `2-只显示省市`
default: 2 default: 2
}, },
// 省市下拉组件宽度
defaultWidth: {
type: String,
default: '150px'
},
// 组件是否展示,默认展示 // 组件是否展示,默认展示
provinceView: { provinceView: {
type: Boolean, type: Boolean,
default: true default: true
},
// 地图组件是否展示,默认展示
// 如果需要展示地图组件,需要下载vue-amap包,并且在main.js中引入
// import VueAMap from "vue-amap"
// Vue.use(VueAMap)
// 初始化vue-amap
// VueAMap.initAMapApiLoader({
// key: "bd290dc27d0945959280753215ddda71", // 这里写你申请的高德地图的key
// plugin: ["AMap.PlaceSearch", "AMap.Geocoder", "AMap.Geolocation"],
// v: "1.4.15"
// });
mapView: {
type: Boolean,
default: true
},
// 省份标签值
provinceLabel: {
type: String,
default: '省市地址:'
},
// 详细地址标签值
detailAddressLabel: {
type: String,
default: '详细地址:'
} }
}, },
data() { data() {
...@@ -54,11 +101,23 @@ export default { ...@@ -54,11 +101,23 @@ export default {
// 城市代码 // 城市代码
cityCode: '', cityCode: '',
// 地区代码 // 地区代码
townCode: '' townCode: '',
} lat: '',
lng: '',
// 全部地址
fullAddress: ''
},
mapHeight: 380,
dialogMapVisible: false,
// 暂存地址表单
addressData: {}
}
},
mounted() {
if (this.provinceView) {
this.provinceList()
} }
}, },
mounted() {},
methods: { methods: {
/* /*
* @params:传入的为一个key-value的对象 * @params:传入的为一个key-value的对象
...@@ -85,8 +144,9 @@ export default { ...@@ -85,8 +144,9 @@ export default {
}) })
**/ **/
// 获取省市信息 // 获取省市信息
provinceList(params = {}) { provinceList() {
params ? (params.subdistrict ? '' : (params.subdistrict = this.subdistrict)) : (params.subdistrict = this.subdistrict) var params = {}
params.subdistrict = this.subdistrict
let data = '' let data = ''
for (let key in params) { for (let key in params) {
data += '&' + key + '=' + params[key] data += '&' + key + '=' + params[key]
...@@ -104,12 +164,14 @@ export default { ...@@ -104,12 +164,14 @@ export default {
return pro return pro
}, },
// 省市回显 // 省市回显
init(province, city, town) { init(provinceData) {
this.provinceForm = { const { province, city, townName, fullAddress, lng, lat } = provinceData
provinceName: province, this.provinceForm.provinceName = province
cityName: city, this.provinceForm.cityName = city
townName: town this.provinceForm.townName = townName
} this.provinceForm.fullAddress = fullAddress
this.provinceForm.lng = lng
this.provinceForm.lat = lat
if (province) { if (province) {
this.AllData.map(item => { this.AllData.map(item => {
if (item.name.indexOf(province) != -1) { if (item.name.indexOf(province) != -1) {
...@@ -122,9 +184,9 @@ export default { ...@@ -122,9 +184,9 @@ export default {
this.provinceForm.cityCode = itm.adcode this.provinceForm.cityCode = itm.adcode
this.provinceForm.cityName = itm.name this.provinceForm.cityName = itm.name
this.townList = itm.districts this.townList = itm.districts
if (town) { if (townName) {
this.townList.map(itmx => { this.townList.map(itmx => {
if (itmx.name.indexOf(town) != -1) { if (itmx.name.indexOf(townName) != -1) {
this.provinceForm.townCode = itmx.adcode this.provinceForm.townCode = itmx.adcode
this.provinceForm.townName = itmx.name this.provinceForm.townName = itmx.name
} }
...@@ -137,32 +199,161 @@ export default { ...@@ -137,32 +199,161 @@ export default {
}) })
} }
}, },
// 选择省
selectProvince(val) { selectProvince(val) {
console.log(val)
this.provinceForm.provinceName = val ? val.name : ''
this.provinceForm.fullAddress = ''
this.provinceForm.cityName = '' this.provinceForm.cityName = ''
this.provinceForm.townName = '' this.provinceForm.townName = ''
this.cityList = val.districts if (val) {
this.$emit('selectProvince', val.name, val.adcode) this.cityList = val.districts
} else {
val = ''
}
// 选择省
this.$emit('selectProvince', val)
}, },
// 选择市
selectCity(val) { selectCity(val) {
this.provinceForm.cityName = val ? val.name : ''
this.provinceForm.fullAddress = ''
this.provinceForm.townName = '' this.provinceForm.townName = ''
this.townList = val.districts if (val) {
this.$emit('selectCity', val.name, val.adcode) this.townList = val.districts
} else {
val = ''
}
// 选择市
this.$emit('selectCity', val)
}, },
// 选择区
selectTown(val) { selectTown(val) {
this.$emit('selectTown', val.name, val.adcode) this.provinceForm.townName = val ? val.name : ''
this.provinceForm.fullAddress = ''
// 选择区
this.$emit('selectTown', val)
},
// 打开地图弹框
hanleSelectMap() {
console.log(this.provinceForm)
this.dialogMapVisible = true
this.$nextTick(() => {
if (this.provinceForm.fullAddress && !this.$refs.mapForm.address) {
this.$refs.mapForm.address = this.provinceForm.fullAddress
this.$refs.mapForm.addMarker([this.provinceForm.lng, this.provinceForm.lat])
}
})
},
// 选择地图地址
getAddress() {
if (!this.$refs.mapForm.address) {
this.$message.success('请选择地址')
return
}
this.provinceForm.fullAddress = this.$refs.mapForm.address
// 获取选择经纬度
let lnglat = this.$refs.mapForm.lnglat
this.provinceForm.lat = lnglat.lat
this.provinceForm.lng = lnglat.lng
var mapData = this.$refs.mapForm.geocoderAddress
// 赋值省市区名称和code
console.log(this.$refs.mapForm, '\\\\\\')
const { city, citycode, province, district, towncode } = mapData.addressComponent
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来保存上次选择的地址
if (mapData.addressComponent) {
fullAddress = mapData.addressComponent
provincecode = mapData.adcode
this.addressData.fullAddress = fullAddress
this.addressData.provincecode = provincecode
} else {
fullAddress = this.addressData.fullAddress
provincecode = this.addressData.provincecode
}
// 获取省市
var provincename = ''
var cityname = ''
var town = ''
provincename = fullAddress.province
cityname = fullAddress.city ? fullAddress.city : fullAddress.district
town = fullAddress.district
// 直辖市需额外判断
const municipalities = ['北京市', '天津市', '上海市', '重庆市']
var municipality = municipalities.find(item => item == provincename)
if (municipality) {
cityname = cityname.slice(0, 2) + '城区'
if (municipality === '重庆市') {
provincecode = provincecode.slice(0, 4)
provincecode == 5001 ? (cityname = cityname.slice(0, 2) + '城区') : (cityname = cityname.slice(0, 2) + '郊县')
// 重新赋值城市名
this.provinceForm.cityName = cityname
}
}
// 判断省市是否匹配
// 如果只展示省市
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('您选择的地址错误,请重新选择')
return
}
}
// 如果展示省市区
if (this.provinceForm.provinceName && this.provinceForm.townName) {
if (this.provinceForm.provinceName !== provincename || this.provinceForm.cityName !== cityname || this.provinceForm.townName !== town) {
this.$message.error('您选择的地址错误,请重新选择')
return
}
}
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)
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.province { // .province {
display: inline-flex; // display: inline-flex;
} // }
.select-padding { .select-padding {
margin-right: 10px; &:nth-child(1) {
margin-left: 0;
}
margin-left: 10px;
}
.map-icon {
vertical-align: middle;
}
/deep/ {
.el-input-group__append {
background-color: #fff;
padding: 0 11px;
}
.el-form-item__content {
width: 474px;
display: flex;
margin-left: 0 !important;
}
.el-form-item {
display: flex;
}
.el-dialog__body {
padding: 20px 10px 30px !important;
}
} }
</style> </style>
<template>
<div class="map-box" :style="{ height: mapHeight + 'px' }">
<div id="container" style="width: 100%; height: 100%"></div>
<div class="map-address">{{ address }}</div>
<div id="myPageTop" style="position: absolute; top: 10px; width: 50%; left: 25%">
<el-input placeholder="请输入关键字" v-model="input" class="input-with-select">
<el-button slot="append" icon="el-icon-search" @click="searchAddress"></el-button>
</el-input>
</div>
</div>
</template>
<script>
let map, marker, placeSearch
export default {
name: 'map',
props: {
mapHeight: {
type: Number,
default: 300
}
},
data() {
return {
input: '',
address: '',
lnglat: [],
geocoderAddress: {}
}
},
methods: {
mapInit() {
map = new AMap.Map('container', {
resizeEnable: true,
zoom: 20
})
AMap.plugin(['AMap.PlaceSearch'], function() {
//构造地点查询类
placeSearch = new AMap.PlaceSearch({
pageSize: 8, // 单页显示结果条数
pageIndex: 1, // 页码
citylimit: false, //是否强制限制在设置的城市内搜索
// panel: "panel", // 结果列表将在此容器中进行展示。
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
renderStyle: 'default'
})
})
// 添加列表点选监听事件
map.on('click', this.getAddress)
},
searchAddress() {
let _this = this
placeSearch.search(this.input, function(status, result) {
if (status === 'complete' && result.poiList.pois.length) {
let lnglat = result.poiList.pois[0].location
_this.getAddress(lnglat)
}
})
},
addMarker(lnglat) {
let position
if (lnglat.lng) {
position = [lnglat.lng, lnglat.lat]
} else {
position = lnglat
}
marker = new AMap.Marker({
icon: new AMap.Icon({
image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
size: new AMap.Size(27, 34), //图标大小
imageSize: new AMap.Size(27, 34)
}),
position: position,
offset: new AMap.Pixel(-10, -10)
})
map.add(marker)
map.setFitView()
},
getAddress(e) {
let self = this
let lnglat
if (e.type == 'click') {
lnglat = e.lnglat
} else {
let { lng, lat } = e
lnglat = [lng, lat]
}
if (marker) {
marker.setMap(null)
marker = null
}
self.addMarker(lnglat)
AMap.plugin('AMap.Geocoder', () => {
const geocoder = new AMap.Geocoder()
geocoder.getAddress(lnglat, (status, result) => {
self.lnglat = lnglat
self.address = result.regeocode.formattedAddress
geocoder.getLocation(self.address, (status, result) => {
if (status === 'complete' && result.info === 'OK') {
this.geocoderAddress = result.geocodes[0]
}
})
})
})
},
selectAddress(e) {
//这里获得点选地点的经纬度
this.getAddress()
}
},
mounted() {
this.mapInit()
}
}
</script>
<style scoped lang="scss">
.map-box {
position: relative;
width: 100%;
}
#container {
position: absolute;
height: 100%;
}
#panel {
position: absolute;
max-height: 90%;
overflow-y: auto;
top: 80px;
right: 10px;
width: 280px;
}
.map-address {
position: absolute;
line-height: 20px;
bottom: -30px;
}
</style>
...@@ -46,12 +46,12 @@ ...@@ -46,12 +46,12 @@
</el-row> --> </el-row> -->
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item size="small" label="商户地址" class="form-row"> <ProvinceCity ref="provinceForm" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" :detailAddressLabel="detailAddressLabel" @selectAddressByMap="selectAddressByMap"></ProvinceCity>
<!-- 省市 --> <!-- <el-form-item size="small" label="商户地址" class="form-row">
<ProvinceCity ref="provinceForm" @selectProvince="selectProvince" @selectCity="selectCity"></ProvinceCity> <ProvinceCity ref="provinceForm" @selectProvince="selectProvince" @selectCity="selectCity"></ProvinceCity>
<el-input readonly style="flex:1" v-model="accountAddForm.merchantAddress" placeholder="请选择商户地址"></el-input> <el-input readonly style="flex:1" v-model="accountAddForm.merchantAddress" placeholder="请选择商户地址"></el-input>
<el-button type="primary" class="form-btn" @click="hanleSelectMap">选择地址</el-button> <el-button type="primary" class="form-btn" @click="hanleSelectMap">选择地址</el-button>
</el-form-item> </el-form-item> -->
</el-col> </el-col>
</el-row> </el-row>
<!-- <el-row> <!-- <el-row>
...@@ -131,26 +131,26 @@ ...@@ -131,26 +131,26 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<GLDialog :visible.sync="dialogMapVisible" title="选择地图"> <!-- <GLDialog :visible.sync="dialogMapVisible" title="选择地图">
<map-view ref="mapForm" :mapHeight="450"></map-view> <map-view ref="mapForm" :mapHeight="450"></map-view>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogMapVisible = false">取 消</el-button> <el-button @click="dialogMapVisible = false">取 消</el-button>
<el-button type="primary" @click="getAddress">确 定</el-button> <el-button type="primary" @click="getAddress">确 定</el-button>
</span> </span>
</GLDialog> </GLDialog> -->
</div> </div>
</template> </template>
<script> <script>
import util from '@/utils/util' import util from '@/utils/util'
import mapView from '@/components/mapView/index' // import mapView from '@/components/mapView/index'
import SelectBrand from '../../baseInfo/selectBrand.vue' import SelectBrand from '../../baseInfo/selectBrand.vue'
import ProvinceCity from '@/components/province-city/index.vue' import ProvinceCity from '@/components/province-city/index.vue'
export default { export default {
name: 'base', name: 'base',
components: { components: {
ProvinceCity, ProvinceCity,
mapView, // mapView,
SelectBrand SelectBrand
}, },
props: { props: {
...@@ -192,6 +192,8 @@ export default { ...@@ -192,6 +192,8 @@ export default {
} }
} }
return { return {
subdistrict: 2,
detailAddressLabel: ' ',
imgIndex: '', imgIndex: '',
filterText: '', filterText: '',
defaultProps: { defaultProps: {
...@@ -287,80 +289,82 @@ export default { ...@@ -287,80 +289,82 @@ export default {
if (!value) return true if (!value) return true
return data.label.indexOf(value) !== -1 return data.label.indexOf(value) !== -1
}, },
getAddress() { // getAddress() {
if (!this.$refs.mapForm.address) { // if (!this.$refs.mapForm.address) {
this.$message.error('请选择地址') // this.$message.error('请选择地址')
return // return
} // }
this.accountAddForm.merchantAddress = this.$refs.mapForm.address // this.accountAddForm.merchantAddress = this.$refs.mapForm.address
let lnglat = this.$refs.mapForm.lnglat // let lnglat = this.$refs.mapForm.lnglat
this.accountAddForm.lat = lnglat.lat // this.accountAddForm.lat = lnglat.lat
this.accountAddForm.lng = lnglat.lng // this.accountAddForm.lng = lnglat.lng
var fullAddress = '' // var fullAddress = ''
var provincecode = '' // var provincecode = ''
if (this.$refs.mapForm.geocoderAddress.addressComponent) { // if (this.$refs.mapForm.geocoderAddress.addressComponent) {
fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent // fullAddress = this.$refs.mapForm.geocoderAddress.addressComponent
provincecode = this.$refs.mapForm.geocoderAddress.adcode // provincecode = this.$refs.mapForm.geocoderAddress.adcode
this.addressData.fullAddress = fullAddress // this.addressData.fullAddress = fullAddress
this.addressData.provincecode = provincecode // this.addressData.provincecode = provincecode
} else { // } else {
fullAddress = this.addressData.fullAddress // fullAddress = this.addressData.fullAddress
provincecode = this.addressData.provincecode // provincecode = this.addressData.provincecode
} // }
// 获取省市 // // 获取省市
var province = '' // var province = ''
var city = '' // var city = ''
if (fullAddress) { // if (fullAddress) {
province = fullAddress.province // province = fullAddress.province
city = fullAddress.city ? fullAddress.city : fullAddress.district // city = fullAddress.city ? fullAddress.city : fullAddress.district
} else { // } else {
province = this.accountAddForm.provinceName // province = this.accountAddForm.provinceName
city = this.accountAddForm.cityName // city = this.accountAddForm.cityName
provincecode = this.accountAddForm.cityCode // provincecode = this.accountAddForm.cityCode
} // }
const municipalities = ['北京市', '天津市', '上海市', '重庆市'] // const municipalities = ['北京市', '天津市', '上海市', '重庆市']
var municipality = municipalities.find(item => item == province) // var municipality = municipalities.find(item => item == province)
if (municipality) { // if (municipality) {
city = city.slice(0, 2) + '城区' // city = city.slice(0, 2) + '城区'
if (municipality === '重庆市') { // if (municipality === '重庆市') {
provincecode = provincecode.slice(0, 4) // provincecode = provincecode.slice(0, 4)
provincecode == 5001 ? (city = city.slice(0, 2) + '城区') : (city = city.slice(0, 2) + '郊县') // provincecode == 5001 ? (city = city.slice(0, 2) + '城区') : (city = city.slice(0, 2) + '郊县')
} // }
} // }
// 判断省市是否匹配 // // 判断省市是否匹配
if (this.accountAddForm.provinceName) { // if (this.accountAddForm.provinceName) {
if (this.accountAddForm.provinceName !== province && this.accountAddForm.cityName !== city) { // if (this.accountAddForm.provinceName !== province && this.accountAddForm.cityName !== city) {
this.$message.error('您选择的地址错误,请重新选择') // this.$message.error('您选择的地址错误,请重新选择')
this.accountAddForm.merchantAddress = '' // this.accountAddForm.merchantAddress = ''
return // return
} // }
} // }
this.dialogMapVisible = false // this.dialogMapVisible = false
this.accountAddForm.provinceName = province // this.accountAddForm.provinceName = province
this.accountAddForm.cityName = city // this.accountAddForm.cityName = city
this.$refs.provinceForm.init(province, city) // this.$refs.provinceForm.init(province, city)
const { provinceCode, cityCode } = this.$refs.provinceForm.provinceForm // const { provinceCode, cityCode } = this.$refs.provinceForm.provinceForm
this.accountAddForm.provinceCode = provinceCode // this.accountAddForm.provinceCode = provinceCode
this.accountAddForm.cityCode = cityCode // this.accountAddForm.cityCode = cityCode
}, // },
// 当直接点击选择地址时,获取省市ID // 当直接点击选择地址时,获取省市ID
init(province, city) { init(province, city) {
this.$refs.provinceForm.init(province, city) this.$refs.provinceForm.init(province, city)
}, },
// 获取省 // 获取省
selectProvince(provinceName, provinceCode) { selectProvince(val) {
console.log(val)
this.$set(this.accountAddForm, 'merchantAddress', '') this.$set(this.accountAddForm, 'merchantAddress', '')
// 强制更新 merchantAddress // 强制更新 merchantAddress
this.$forceUpdate() this.$forceUpdate()
this.accountAddForm.cityName = '' this.accountAddForm.cityName = ''
this.accountAddForm.provinceName = provinceName this.accountAddForm.provinceName = val.name
this.accountAddForm.provinceCode = provinceCode this.accountAddForm.provinceCode = val.adcode
}, },
// 获取市 // 获取市
selectCity(cityName, cityCode) { selectCity(val) {
if (cityName) { console.log(val)
this.accountAddForm.cityName = cityName if (val.name) {
this.accountAddForm.cityCode = cityCode this.accountAddForm.cityName = val.name
this.accountAddForm.cityCode = val.adcode
} else { } else {
this.accountAddForm.cityName = '' this.accountAddForm.cityName = ''
this.accountAddForm.cityCode = '' this.accountAddForm.cityCode = ''
...@@ -368,6 +372,16 @@ export default { ...@@ -368,6 +372,16 @@ export default {
this.$set(this.accountAddForm, 'merchantAddress', '') this.$set(this.accountAddForm, 'merchantAddress', '')
this.$forceUpdate() this.$forceUpdate()
}, },
// 通过地图选择省市和详细地址
selectAddressByMap(val) {
console.log(val)
const { provinceName, cityName, fullAddress, lat, lng } = val
this.accountAddForm.merchantAddress = fullAddress
this.accountAddForm.provinceName = provinceName
this.accountAddForm.cityName = cityName
this.accountAddForm.lat = lat
this.accountAddForm.lng = lng
},
delImg(index) { delImg(index) {
this.accountAddForm.merchantFiles.splice(index, 1) this.accountAddForm.merchantFiles.splice(index, 1)
}, },
......
...@@ -434,7 +434,14 @@ export default { ...@@ -434,7 +434,14 @@ export default {
merchantBrandMain merchantBrandMain
}) })
// 省市回显 // 省市回显
this.$refs.baseInfoForm.init(this.accountAddForm.provinceName, this.accountAddForm.cityName) var provinceData = {
province: this.accountAddForm.provinceName,
city: this.accountAddForm.cityName,
fullAddress: this.accountAddForm.merchantAddress,
lng: this.accountAddForm.lng,
lat: this.accountAddForm.lat
}
this.$refs.baseInfoForm.init(provinceData)
if (!this.accountAddForm.merchantBrandMain) { if (!this.accountAddForm.merchantBrandMain) {
this.accountAddForm.merchantBrandMain = [] this.accountAddForm.merchantBrandMain = []
} else { } else {
......
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
<div class="main-information"> <div class="main-information">
<div class="information-title">修改企业信息</div> <div class="information-title">修改企业信息</div>
<div class="information-form-box"> <div class="information-form-box">
<el-form ref="baseForm" :model="infoForm" class="account-body-form" label-width="120px" :rules="baseFormRules"> <el-form ref="baseForm" :model="infoForm" class="account-body-form" label-width="154px" :rules="baseFormRules">
<el-form-item size="small" label="商户地址:" class="map-row"> <Province ref="provinceForm" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity" :detailAddressLabel="detailAddressLabel"></Province>
<!-- <el-form-item size="small" label="商户地址:" class="map-row">
<Province ref="provinceForm" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity"></Province> <Province ref="provinceForm" :subdistrict="subdistrict" @selectProvince="selectProvince" @selectCity="selectCity"></Province>
<el-input class="input-width" v-model="infoForm.merchantAddress" placeholder="请选择商户地址" readonly="readonly"></el-input> <el-input class="input-width" v-model="infoForm.merchantAddress" placeholder="请选择商户地址" readonly="readonly"></el-input>
<el-button @click="hanleSelectMap" type="primary">选择地址</el-button> <el-button @click="hanleSelectMap" type="primary">选择地址</el-button>
</el-form-item> </el-form-item> -->
<el-form-item size="small" label="经营业务类型:"> <el-form-item size="small" label="经营业务类型:">
<el-checkbox-group v-model="infoForm.businessType"> <el-checkbox-group v-model="infoForm.businessType">
<el-checkbox :label="item.dictValue" v-for="item in businessType" :key="item.dictValue" :disabled="item.dictValue <= 6">{{ item.dictLabel }}</el-checkbox> <el-checkbox :label="item.dictValue" v-for="item in businessType" :key="item.dictValue" :disabled="item.dictValue <= 6">{{ item.dictLabel }}</el-checkbox>
...@@ -83,6 +84,7 @@ export default { ...@@ -83,6 +84,7 @@ export default {
} }
return { return {
subdistrict: 2, subdistrict: 2,
detailAddressLabel: ' ',
checkedAll: false, checkedAll: false,
filterText: '', filterText: '',
dialogMapVisible: false, dialogMapVisible: false,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!