|
|
|
|
@ -6,10 +6,21 @@
|
|
|
|
|
<div slot="content"></div>
|
|
|
|
|
|
|
|
|
|
<slot>
|
|
|
|
|
<el-select v-model="selectArea" size="small" placeholder="请选择区域" @change="areaClick">
|
|
|
|
|
<el-option v-for="item in areas" :key="item.id" value-key="id" :value="item" :label="item.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-cascader
|
|
|
|
|
:value="selector.area_id"
|
|
|
|
|
style="width: 200px;"
|
|
|
|
|
placeholder="区域选择"
|
|
|
|
|
:options="areas"
|
|
|
|
|
:props="{
|
|
|
|
|
label:'value',
|
|
|
|
|
value:'id',
|
|
|
|
|
emitPath:false
|
|
|
|
|
}"
|
|
|
|
|
@change="areaClick"
|
|
|
|
|
>
|
|
|
|
|
</el-cascader>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- <Input placeholder="关键字搜索" v-model="selector.keyword" style="width: 200px; margin-right: 10px" />-->
|
|
|
|
|
|
|
|
|
|
<!-- <Button style="margin-left: 10px" type="primary" @click="selector.page = 1,getCustomers()">查询</Button>-->
|
|
|
|
|
@ -57,7 +68,7 @@ const amapManager = new AMapManager()
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
selectArea:{},
|
|
|
|
|
areaMap:new Map(),
|
|
|
|
|
selector: {
|
|
|
|
|
page: 1,
|
|
|
|
|
page_size: 9999,
|
|
|
|
|
@ -79,18 +90,31 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async getAreas(){
|
|
|
|
|
let res = await getparameter({number:'serveArea'})
|
|
|
|
|
this.areas = res.detail
|
|
|
|
|
console.log(this.areas)
|
|
|
|
|
let city = await getparameter({
|
|
|
|
|
number: 'city'
|
|
|
|
|
}, false)
|
|
|
|
|
for (let i = 0; i < city.detail.length; i++) {
|
|
|
|
|
let area = await getparameter({
|
|
|
|
|
pid: city.detail[i].id
|
|
|
|
|
}, false)
|
|
|
|
|
city.detail[i].children = area.detail
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.areas = city.detail
|
|
|
|
|
|
|
|
|
|
this.areas.forEach(item1 => {
|
|
|
|
|
this.areaMap.set(item1.id,item1.remark)
|
|
|
|
|
|
|
|
|
|
if(item1.children && item1.children.length > 0){
|
|
|
|
|
item1.children.forEach(item2 => {
|
|
|
|
|
this.areaMap.set(item2.id,item2.remark)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async areaClick(e){
|
|
|
|
|
console.log(e)
|
|
|
|
|
if(e.value == '市本级'){
|
|
|
|
|
this.selector.area_id = ''
|
|
|
|
|
}else{
|
|
|
|
|
this.selector.area_id = e.id
|
|
|
|
|
}
|
|
|
|
|
this.selector.area_id = e
|
|
|
|
|
await this.getCustomers()
|
|
|
|
|
this.draw()
|
|
|
|
|
},
|
|
|
|
|
@ -106,25 +130,47 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
drawPolygon(district = '常州市'){
|
|
|
|
|
this.district.search(district,(status,res) => {
|
|
|
|
|
console.log(res,status)
|
|
|
|
|
if(res.districtList){
|
|
|
|
|
this.polygons = []
|
|
|
|
|
let bounds = res.districtList[0].boundaries
|
|
|
|
|
for(let i = 0,l = bounds.length; i < l; i++){
|
|
|
|
|
let polygon = new AMap.Polygon({
|
|
|
|
|
strokeWeight: 1,
|
|
|
|
|
path: bounds[i],
|
|
|
|
|
fillOpacity: 0.4,
|
|
|
|
|
fillColor: "rgba(225,121,110,0.92)",
|
|
|
|
|
strokeColor: "#a53227",
|
|
|
|
|
})
|
|
|
|
|
this.polygons.push(polygon)
|
|
|
|
|
let cityArr = district.split(',')
|
|
|
|
|
cityArr.forEach(item => {
|
|
|
|
|
this.district.search(item,(status,res) => {
|
|
|
|
|
console.log(res,status)
|
|
|
|
|
if(res.districtList){
|
|
|
|
|
this.polygons = []
|
|
|
|
|
let bounds = res.districtList[0].boundaries
|
|
|
|
|
for(let i = 0,l = bounds.length; i < l; i++){
|
|
|
|
|
let polygon = new AMap.Polygon({
|
|
|
|
|
strokeWeight: 1,
|
|
|
|
|
path: bounds[i],
|
|
|
|
|
fillOpacity: 0.4,
|
|
|
|
|
fillColor: "rgba(225,121,110,0.92)",
|
|
|
|
|
strokeColor: "#a53227",
|
|
|
|
|
})
|
|
|
|
|
this.polygons.push(polygon)
|
|
|
|
|
}
|
|
|
|
|
this.map.add(this.polygons)
|
|
|
|
|
this.map.setFitView(this.polygons)
|
|
|
|
|
}
|
|
|
|
|
this.map.add(this.polygons)
|
|
|
|
|
this.map.setFitView(this.polygons)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
// this.district.search(district,(status,res) => {
|
|
|
|
|
// console.log(res,status)
|
|
|
|
|
// if(res.districtList){
|
|
|
|
|
// this.polygons = []
|
|
|
|
|
// let bounds = res.districtList[0].boundaries
|
|
|
|
|
// for(let i = 0,l = bounds.length; i < l; i++){
|
|
|
|
|
// let polygon = new AMap.Polygon({
|
|
|
|
|
// strokeWeight: 1,
|
|
|
|
|
// path: bounds[i],
|
|
|
|
|
// fillOpacity: 0.4,
|
|
|
|
|
// fillColor: "rgba(225,121,110,0.92)",
|
|
|
|
|
// strokeColor: "#a53227",
|
|
|
|
|
// })
|
|
|
|
|
// this.polygons.push(polygon)
|
|
|
|
|
// }
|
|
|
|
|
// this.map.add(this.polygons)
|
|
|
|
|
// this.map.setFitView(this.polygons)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initLoad() {
|
|
|
|
|
@ -180,7 +226,7 @@ export default {
|
|
|
|
|
this.map.remove(this.polygons)
|
|
|
|
|
this.map.remove(this.markers)
|
|
|
|
|
this.drawMarkers()
|
|
|
|
|
this.drawPolygon(this.selectArea.remark || '常州市')
|
|
|
|
|
this.drawPolygon(this.areaMap.get(this.selector.area_id) || '常州市')
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|