|
|
@ -191,7 +191,7 @@ |
|
|
|
</u-input> |
|
|
|
<button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button> |
|
|
|
</view> |
|
|
|
<view v-else-if="type=='map'" class="map plant-dingweixiao" :class="{noData:value.length<=0}" @click="openMap">{{value.length>0?value[0].join():"选择经纬度"}}</view> |
|
|
|
<view v-else-if="type=='map'" class="map plant-dingweixiao" :class="{noData:value.length<=0}" @click="openMap">{{value.length>0?Object.values(value[0]).join():"选择经纬度"}}</view> |
|
|
|
<view v-else-if="type=='select'" class="plant-youbian" :class="{noData: !value[0]}" @click="show=true">{{pickerContent}}</view> |
|
|
|
<u-upload v-else-if="type=='upImg'" :fileList="imgs" previewFullImage multiple :maxCount="num" @delete="delImg" @afterRead="afterRead"> |
|
|
|
<view class="album"> |
|
|
@ -258,6 +258,7 @@ |
|
|
|
<script> |
|
|
|
import request,{host} from '@/common/request' |
|
|
|
import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
import {computeArea} from '@/common/utils' |
|
|
|
|
|
|
|
function setPickerCol(columns, value, n){ |
|
|
|
if(columns.length<=0)return |
|
|
@ -339,8 +340,8 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
|
|
|
|
showMap:false, |
|
|
|
maps:null, |
|
|
|
markerList:[], |
|
|
|
temp_markerList:[], |
|
|
|
markerList: this.$defineArray([]), |
|
|
|
temp_markerList: this.$defineArray([]), |
|
|
|
areaPolygon:null, |
|
|
|
} |
|
|
|
}, |
|
|
@ -370,7 +371,7 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
}, |
|
|
|
pickerContent(){//下拉选择 表单显示数据 |
|
|
|
if(this.type=='select'){ |
|
|
|
return setPickerVal(this.columns[0], this.value).filter(v=>v).at(-1)?.label||this.placeholder||`请选择${this.label}` |
|
|
|
return this.$defineArray(setPickerVal(this.columns[0], this.value).filter(v=>v)).at(-1)?.label||this.placeholder||`请选择${this.label}` |
|
|
|
} |
|
|
|
return '' |
|
|
|
}, |
|
|
@ -387,6 +388,11 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
setPickerCol.bind(this.$refs.picker)(this.columns[0]||[],this.value,1) |
|
|
|
}) |
|
|
|
} |
|
|
|
this.$nextTick(()=>{ |
|
|
|
uni.$u.getRect(".amap").then(res=>{ |
|
|
|
console.log(res,'---res----') |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
async afterRead(e){ |
|
|
@ -443,7 +449,16 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
polyline.setLineWidth(8) |
|
|
|
polyline.setStrokeColor("#10C176") |
|
|
|
|
|
|
|
this.value.forEach(v=>this.addMarker(v,polyline)) |
|
|
|
if(this.value.length>0){ |
|
|
|
var bound=computeArea(this.value) |
|
|
|
for(var i=0;i<this.value.length;i++){ |
|
|
|
this.maps.addOverlay(this.addMarker(this.value[i],polyline)) |
|
|
|
} |
|
|
|
this.markerList[0].pre=this.markerList[this.markerList.length-1].value |
|
|
|
this.markerList[this.markerList.length-1].next=this.markerList[0].value |
|
|
|
this.maps.centerAndZoom(new plus.maps.Point(bound.center.longitude, bound.center.latitude),10) |
|
|
|
this.drawOver(true) |
|
|
|
} |
|
|
|
this.maps.onclick=(e)=>{ |
|
|
|
this.markerList.length<=0 && this.maps.addOverlay(polyline) |
|
|
|
|
|
|
@ -460,8 +475,9 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
} |
|
|
|
/* #endif */ |
|
|
|
}, |
|
|
|
drawOver(){ |
|
|
|
this.$emit("editorMap",this.markerList.map(({value})=>value.getPoint())) |
|
|
|
drawOver(init=false){ |
|
|
|
!init && this.$emit("editorMap",this.markerList.map(({value})=>value.getPoint())) |
|
|
|
|
|
|
|
this.areaPolygon=new plus.maps.Polygon( this.markerList.map(({value})=>new plus.maps.Point(...Object.values(value.getPoint()))) ) |
|
|
|
this.areaPolygon.setLineWidth(3) |
|
|
|
this.areaPolygon.setStrokeColor("#10C176") |
|
|
@ -476,7 +492,7 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
}, |
|
|
|
addMarker({longitude,latitude},polyline){ |
|
|
|
var marker=new plus.maps.Marker(new plus.maps.Point(longitude, latitude)); |
|
|
|
marker.setIcon("/static/map_point_1.png"); |
|
|
|
marker.setIcon("/static/map_point_3.png"); |
|
|
|
marker.bringToTop() |
|
|
|
marker.setDraggable(false) |
|
|
|
marker.onDrag= this.onDrag |
|
|
@ -516,19 +532,20 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
onClick(e){ |
|
|
|
if(this.markerList.length>3){ |
|
|
|
this.maps.removeOverlay(e) |
|
|
|
this.markerList = this.markerList.filter(v=>v.value!=e) |
|
|
|
var preMarker=this.markerList.find(v=>v.pre==e) |
|
|
|
var nextMarker=this.markerList.find(v=>v.next==e) |
|
|
|
preMarker.pre=nextMarker.value |
|
|
|
nextMarker.next=preMarker.value |
|
|
|
this.markerList.splice( this.markerList.Dfind(v=>v.value==e), 1) |
|
|
|
var preMarker=this.markerList.find(v=>v.next==e) |
|
|
|
var nextMarker=this.markerList.find(v=>v.pre==e) |
|
|
|
preMarker.next=nextMarker.value |
|
|
|
nextMarker.pre=preMarker.value |
|
|
|
|
|
|
|
// this.maps.removeOverlay(this.temp_markerList.find(v=>v.next==e).value) |
|
|
|
// this.maps.removeOverlay(this.temp_markerList.find(v=>v.pre==e).value) |
|
|
|
// this.temp_markerList=this.temp_markerList.filter(v=>v.pre!=e&&v.next!=e) |
|
|
|
// this.addTempMarker({value:preMarker.value, next:nextMarker.value}) |
|
|
|
this.temp_markerList.forEach(v=>this.maps.removeOverlay(v.value)) |
|
|
|
this.temp_markerList=[] |
|
|
|
this.markerList.forEach(v=>this.addTempMarker(v)) |
|
|
|
this.maps.removeOverlay(this.temp_markerList.find(v=>v.next==e).value) |
|
|
|
this.maps.removeOverlay(this.temp_markerList.find(v=>v.pre==e).value) |
|
|
|
this.temp_markerList.splice(this.temp_markerList.Dfind(v=>v.pre==e),1) |
|
|
|
this.temp_markerList.splice(this.temp_markerList.Dfind(v=>v.next==e),1) |
|
|
|
this.addTempMarker(preMarker) |
|
|
|
// this.temp_markerList.forEach(v=>this.maps.removeOverlay(v.value)) |
|
|
|
// this.temp_markerList.length=0 |
|
|
|
// this.markerList.forEach(v=>this.addTempMarker(v)) |
|
|
|
|
|
|
|
this.reComputArea() |
|
|
|
}else{ |
|
|
@ -546,7 +563,7 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
return new plus.maps.Point(point.longitude, point.latitude) |
|
|
|
})) |
|
|
|
}, |
|
|
|
addTempMarker({value,pre,next}){ |
|
|
|
addTempMarker({value,next}){ |
|
|
|
var point1=value.getPoint() |
|
|
|
var point2=next.getPoint() |
|
|
|
|
|
|
@ -554,7 +571,7 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
Math.min(point1.longitude,point2.longitude)+Math.abs(point1.longitude-point2.longitude)/2, |
|
|
|
Math.min(point1.latitude,point2.latitude)+Math.abs(point1.latitude-point2.latitude)/2 |
|
|
|
)); |
|
|
|
marker.setIcon("/static/map_point_2.png"); |
|
|
|
marker.setIcon("/static/map_point_4.png"); |
|
|
|
marker.bringToTop() |
|
|
|
marker.setDraggable(true) |
|
|
|
marker.onDrag= e=>{ |
|
|
@ -582,9 +599,9 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
this.temp_markerList=this.temp_markerList.filter(v=>v.value!=e) |
|
|
|
this.temp_markerList.splice(this.temp_markerList.Dfind(v=>v.value==e),1) |
|
|
|
this.reComputArea() |
|
|
|
e.setIcon('/static/map_point_1.png') |
|
|
|
e.setIcon('/static/map_point_3.png') |
|
|
|
e.onDrag= this.onDrag |
|
|
|
e.onclick= this.onClick |
|
|
|
|
|
|
@ -592,8 +609,8 @@ import {dataType} from 'black-knight/lib/config/tools' |
|
|
|
} |
|
|
|
this.maps.addOverlay(marker) |
|
|
|
this.temp_markerList.push({ |
|
|
|
value:marker, |
|
|
|
pre:value, |
|
|
|
value:marker, |
|
|
|
next:next |
|
|
|
}) |
|
|
|
}, |
|
|
|