江河点位修正
This commit is contained in:
@@ -36,6 +36,8 @@ const river = function (data) { // 江河水质数据查询
|
|||||||
return axios.post("/water/visualiz/river", data)
|
return axios.post("/water/visualiz/river", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const waterStation = function (data) { // 水站数据查询
|
const waterStation = function (data) { // 水站数据查询
|
||||||
return axios.post("/water/visualiz/waterStation", data)
|
return axios.post("/water/visualiz/waterStation", data)
|
||||||
}
|
}
|
||||||
@@ -52,6 +54,10 @@ const waterVillage = function (data) { // 农村
|
|||||||
return axios.post("/drinkingWaterVillage/drinkingWaterVillage/villageGis", data)
|
return axios.post("/drinkingWaterVillage/drinkingWaterVillage/villageGis", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const updateRiverCorrectLocation = function (data) { // 江河水质数据查询
|
||||||
|
return axios.post("/water/visualiz/updatePointLocation", data)
|
||||||
|
}
|
||||||
export {
|
export {
|
||||||
getLakePlace,
|
getLakePlace,
|
||||||
getAirGis,
|
getAirGis,
|
||||||
@@ -64,5 +70,6 @@ export {
|
|||||||
waterStation,
|
waterStation,
|
||||||
waterCity,
|
waterCity,
|
||||||
waterCounty,
|
waterCounty,
|
||||||
waterVillage
|
waterVillage,
|
||||||
|
updateRiverCorrectLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ export default {
|
|||||||
{title: "路宽", dataIndex: "roadWidth", sorter: true,},
|
{title: "路宽", dataIndex: "roadWidth", sorter: true,},
|
||||||
{title: "测点经度", dataIndex: "placeLng", sorter: true,},
|
{title: "测点经度", dataIndex: "placeLng", sorter: true,},
|
||||||
{title: "测点纬度", dataIndex: "placeLat", sorter: true,},
|
{title: "测点纬度", dataIndex: "placeLat", sorter: true,},
|
||||||
|
{title: "修正经度", dataIndex: "correctLng"},
|
||||||
|
{title: "修正纬度", dataIndex: "correctLat"},
|
||||||
{
|
{
|
||||||
title: "操作",
|
title: "操作",
|
||||||
key: "action",
|
key: "action",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<a-select style="width: 200px;" v-if="currentRequestCata == '1'" @change="changeText" name="waterCate"
|
<a-select style="width: 200px;" v-if="currentRequestCata == '1'" @change="changeText" name="waterCate"
|
||||||
:default-value="currentCate">
|
:default-value="currentCate">
|
||||||
<a-select-option v-for="(item,index) in waterCate" :key="index">
|
<a-select-option :value="item" v-for="(item,index) in waterCate" :key="index">
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
@@ -43,11 +43,17 @@
|
|||||||
<mapNominal :param="nominalList"></mapNominal>
|
<mapNominal :param="nominalList"></mapNominal>
|
||||||
<!-- <map-table-center :rowData="pointData"></map-table-center>-->
|
<!-- <map-table-center :rowData="pointData"></map-table-center>-->
|
||||||
<map-table :columns="columns" :rowData="pointData"></map-table>
|
<map-table :columns="columns" :rowData="pointData"></map-table>
|
||||||
|
|
||||||
|
<a-modal @ok="updateCorrectLocation" :closable="false" :destroy-on-close="true" :width="1000" :body-style="{height:'700px'}"
|
||||||
|
v-model:visible="visibleRoadMap" :title="roadMapTitle"
|
||||||
|
>
|
||||||
|
<div style="width: 100%;height: 100%;" ref="roadMap" id="roadMap"></div>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
river, national, waterStation, autonomous
|
river, national, waterStation, autonomous,updateRiverCorrectLocation
|
||||||
} from "@/api/gis/gisApi";
|
} from "@/api/gis/gisApi";
|
||||||
import {
|
import {
|
||||||
getColumnOptions,
|
getColumnOptions,
|
||||||
@@ -160,6 +166,10 @@ export default {
|
|||||||
"common": "劣Ⅴ",
|
"common": "劣Ⅴ",
|
||||||
"desc": "劣五类"
|
"desc": "劣五类"
|
||||||
}],
|
}],
|
||||||
|
// 字典表单
|
||||||
|
visibleRoadMap: false,
|
||||||
|
roadMapTitle: "选择坐标",
|
||||||
|
form: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -172,7 +182,7 @@ export default {
|
|||||||
that.requestFun()
|
that.requestFun()
|
||||||
},
|
},
|
||||||
changeText: function (e) {
|
changeText: function (e) {
|
||||||
that.currentCate = that.waterCate[e]
|
that.currentCate = e
|
||||||
that.requestFun()
|
that.requestFun()
|
||||||
},
|
},
|
||||||
changeCate: function (e) {
|
changeCate: function (e) {
|
||||||
@@ -317,6 +327,13 @@ export default {
|
|||||||
that.currentY = 0
|
that.currentY = 0
|
||||||
that.tipFlag = false
|
that.tipFlag = false
|
||||||
}, true)
|
}, true)
|
||||||
|
myCompOverlay.addEventListener('contextmenu',function (e){
|
||||||
|
console.log("右键")
|
||||||
|
let currentId = e.target.getAttribute("id")
|
||||||
|
const {longitude, latitude, correctLng, correctLat,pointDictId} = that.pointData[currentId.substring(2, currentId.length)]
|
||||||
|
that.form = {longitude, latitude, correctLng, correctLat,pointDictId}
|
||||||
|
that.showRoadMap(that.form);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
whereChange(e) {
|
whereChange(e) {
|
||||||
@@ -385,6 +402,87 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
showRoadMap(form) {
|
||||||
|
const {longitude, latitude, correctLng, correctLat} = form
|
||||||
|
this.visibleRoadMap = true
|
||||||
|
// this.roadMapTitle = "选择修正后的道路坐标"
|
||||||
|
this.$nextTick(() => {
|
||||||
|
console.log(this.$refs.roadMap)
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var map = new BMap.Map(this.$refs.roadMap); // 创建Map实例
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.NavigationControl()); //初始化地图控件
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.ScaleControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.OverviewMapControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var point = new BMap.Point(correctLng ? correctLng : longitude ? longitude : 108.33, correctLat ? correctLat : latitude ? latitude : 22.84);
|
||||||
|
// var point = new BBMap.Point(form.longitude ? form.longitude : 108.33, form.latitude ? form.latitude : 22.84);
|
||||||
|
map.centerAndZoom(point, 13);//初始化地图中心点
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var marker = new BMap.Marker(point); //初始化地图标记
|
||||||
|
marker.enableDragging(); //标记开启拖拽
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var gc = new BMap.Geocoder();//地址解析类
|
||||||
|
//添加标记拖拽监听
|
||||||
|
marker.addEventListener("dragend", (e) => {
|
||||||
|
//获取地址信息
|
||||||
|
this.form['correctLng'] = e.point.lng
|
||||||
|
this.form['correctLat'] = e.point.lat
|
||||||
|
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//添加标记点击监听
|
||||||
|
marker.addEventListener("click", function (e) {
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
map.centerAndZoom(point, 15); //设置中心点坐标和地图级别
|
||||||
|
map.addOverlay(marker); //将标记添加到地图中
|
||||||
|
//显示地址信息窗口
|
||||||
|
function showLocationInfo(pt, rs) {
|
||||||
|
var opts = {
|
||||||
|
width: 250, //信息窗口宽度
|
||||||
|
height: 100, //信息窗口高度
|
||||||
|
title: "" //信息窗口标题
|
||||||
|
}
|
||||||
|
var addComp = rs.addressComponents;
|
||||||
|
var addr = "当前位置:" + addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber + "<br/>";
|
||||||
|
addr += "纬度: " + pt.lat + ", " + "经度:" + pt.lng;
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var infoWindow = new BMap.InfoWindow(addr, opts); //创建信息窗口对象
|
||||||
|
marker.openInfoWindow(infoWindow);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
updateCorrectLocation(){
|
||||||
|
const {correctLng, correctLat,pointDictId} = that.form;
|
||||||
|
const reqData = {correctLng, correctLat,id:pointDictId};
|
||||||
|
if(this.currentRequestCata == "0"){
|
||||||
|
reqData.type = "river"
|
||||||
|
}else if(this.currentRequestCata == "1"){
|
||||||
|
if(this.currentCate == "国家水功能区"){
|
||||||
|
reqData.type = "national"
|
||||||
|
}else{
|
||||||
|
reqData.type = "auto"
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
reqData.type = "water"
|
||||||
|
}
|
||||||
|
updateRiverCorrectLocation(reqData).then(res=>{
|
||||||
|
if(res.data.code == 0){
|
||||||
|
this.requestFun()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -104,6 +104,23 @@
|
|||||||
<a-form-item label="纬度" name="latitude">
|
<a-form-item label="纬度" name="latitude">
|
||||||
<a-input v-model:value="form.latitude" placeholder="请输入纬度" allow-clear />
|
<a-input v-model:value="form.latitude" placeholder="请输入纬度" allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="修正位置" name="correctLocation">
|
||||||
|
<a-input-search @search="showRoadMap(form)"
|
||||||
|
:value="`[${form.correctLng},${form.correctLat}]`" placeholder="`[${form.longitude},${form.latitude}]`" allow-clear>
|
||||||
|
<template #enterButton>
|
||||||
|
<a-button>选择位置</a-button>
|
||||||
|
</template>
|
||||||
|
</a-input-search>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-modal :closable="false" :destroy-on-close="true" :width="1000" :body-style="{height:'700px'}"
|
||||||
|
v-model:visible="visibleRoadMap" :title="roadMapTitle"
|
||||||
|
>
|
||||||
|
<div style="width: 100%;height: 100%;" ref="roadMap" id="roadMap"></div>
|
||||||
|
<template #footer>
|
||||||
|
<a-button key="submit" type="primary" @click="visibleRoadMap = false">确定</a-button>
|
||||||
|
</template>
|
||||||
|
</a-modal>
|
||||||
<a-form-item label="序号" name="seq">
|
<a-form-item label="序号" name="seq">
|
||||||
<a-input v-model:value="form.seq" placeholder="请输入序号" allow-clear />
|
<a-input v-model:value="form.seq" placeholder="请输入序号" allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -263,6 +280,8 @@
|
|||||||
title: "纬度",
|
title: "纬度",
|
||||||
dataIndex: "latitude",
|
dataIndex: "latitude",
|
||||||
},
|
},
|
||||||
|
{title: "修正经度", dataIndex: "correctLng"},
|
||||||
|
{title: "修正纬度", dataIndex: "correctLat"},
|
||||||
{
|
{
|
||||||
title: "序号",
|
title: "序号",
|
||||||
dataIndex: "seq",
|
dataIndex: "seq",
|
||||||
@@ -310,6 +329,8 @@
|
|||||||
showNYear: false,
|
showNYear: false,
|
||||||
cYear: undefined,
|
cYear: undefined,
|
||||||
nYear: undefined,
|
nYear: undefined,
|
||||||
|
visibleRoadMap: false,
|
||||||
|
roadMapTitle: "选择坐标",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -462,7 +483,67 @@
|
|||||||
|
|
||||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||||
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
||||||
}
|
},
|
||||||
|
showRoadMap(form) {
|
||||||
|
const {longitude,latitude,correctLng,correctLat} = form
|
||||||
|
this.visibleRoadMap = true
|
||||||
|
this.roadMapTitle = "选择修正后的道路坐标"
|
||||||
|
this.$nextTick(() => {
|
||||||
|
console.log(this.$refs.roadMap)
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var map = new BMap.Map(this.$refs.roadMap); // 创建Map实例
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.NavigationControl()); //初始化地图控件
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.ScaleControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.OverviewMapControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var point = new BMap.Point(correctLng?correctLng:longitude?longitude:108.33,correctLat?correctLat:latitude?latitude:22.84);
|
||||||
|
// var point = new BBMap.Point(form.longitude ? form.longitude : 108.33, form.latitude ? form.latitude : 22.84);
|
||||||
|
map.centerAndZoom(point, 13);//初始化地图中心点
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var marker = new BMap.Marker(point); //初始化地图标记
|
||||||
|
marker.enableDragging(); //标记开启拖拽
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var gc = new BMap.Geocoder();//地址解析类
|
||||||
|
//添加标记拖拽监听
|
||||||
|
marker.addEventListener("dragend", (e) => {
|
||||||
|
//获取地址信息
|
||||||
|
this.form['correctLng'] = e.point.lng
|
||||||
|
this.form['correctLat'] = e.point.lat
|
||||||
|
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//添加标记点击监听
|
||||||
|
marker.addEventListener("click", function (e) {
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
map.centerAndZoom(point, 15); //设置中心点坐标和地图级别
|
||||||
|
map.addOverlay(marker); //将标记添加到地图中
|
||||||
|
//显示地址信息窗口
|
||||||
|
function showLocationInfo(pt, rs) {
|
||||||
|
var opts = {
|
||||||
|
width: 250, //信息窗口宽度
|
||||||
|
height: 100, //信息窗口高度
|
||||||
|
title: "" //信息窗口标题
|
||||||
|
}
|
||||||
|
var addComp = rs.addressComponents;
|
||||||
|
var addr = "当前位置:" + addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber + "<br/>";
|
||||||
|
addr += "纬度: " + pt.lat + ", " + "经度:" + pt.lng;
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var infoWindow = new BMap.InfoWindow(addr, opts); //创建信息窗口对象
|
||||||
|
marker.openInfoWindow(infoWindow);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,389 +1,475 @@
|
|||||||
<!--水站点位信息-->
|
<!--水站点位信息-->
|
||||||
<template>
|
<template>
|
||||||
<div class="ele-body">
|
<div class="ele-body">
|
||||||
<a-card :bordered="false">
|
<a-card :bordered="false">
|
||||||
<a-form
|
<a-form
|
||||||
:model="where"
|
:model="where"
|
||||||
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
||||||
>
|
>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
||||||
<a-form-item label="年份:">
|
<a-form-item label="年份:">
|
||||||
<a-select v-model:value="where.year" allow-clear show-search>
|
<a-select v-model:value="where.year" allow-clear show-search>
|
||||||
<a-select-option
|
<a-select-option
|
||||||
v-for="(item) in yearOptions"
|
v-for="(item) in yearOptions"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
>{{ item.label }}
|
>{{ item.label }}
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
|
||||||
<a-space>
|
|
||||||
<a-button type="primary" @click="reload">查询</a-button>
|
|
||||||
<a-button @click="reset" style="background: #FFA200FF; border-color: #FFA200FF;color: #FFFFFF">重置</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
<a-row>
|
|
||||||
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
<a-modal
|
|
||||||
v-model:visible="showNYear"
|
|
||||||
:title="'批量复制'"
|
|
||||||
:confirm-loading="loading"
|
|
||||||
:body-style="{ paddingBottom: '8px' }"
|
|
||||||
@ok="copyBatch"
|
|
||||||
>
|
|
||||||
<a-form
|
|
||||||
ref="form"
|
|
||||||
:model="form"
|
|
||||||
:rules="rules"
|
|
||||||
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
|
|
||||||
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
|
||||||
>
|
|
||||||
<a-form-item label="新年份" name="nYear">
|
|
||||||
<a-input-number id="inputNumber" v-model:value="nYear" :min="1970" :max="2050" />
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
<a-modal
|
|
||||||
v-model:visible="showEdit"
|
|
||||||
:title="form.waterStationPointId !== undefined ? '修改' : '添加'"
|
|
||||||
:confirm-loading="loading"
|
|
||||||
:width="800"
|
|
||||||
:body-style="{ paddingBottom: '8px' }"
|
|
||||||
@ok="save"
|
|
||||||
>
|
|
||||||
<a-form
|
|
||||||
ref="form"
|
|
||||||
:model="form"
|
|
||||||
:rules="rules"
|
|
||||||
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
|
|
||||||
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
|
||||||
>
|
|
||||||
<a-form-item label="年份" name="year">
|
|
||||||
<a-input-number v-model:value="form.year" :min="1970" :max="2050" />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="所在河流名称" name="riverName">
|
|
||||||
<a-input v-model:value="form.riverName" placeholder="请输入所在河流名称" allow-clear />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="自动站名称" name="stationName">
|
|
||||||
<a-input v-model:value="form.stationName" placeholder="请输入自动站名称" allow-clear />
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="所属系统" name="system">
|
|
||||||
<a-select v-model:value="form.system" allowClear placeholder="未选择">
|
|
||||||
<a-select-option :value="'1'">国家水站</a-select-option>
|
|
||||||
<a-select-option :value="'2'">广西水系统</a-select-option>
|
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="水质目标" name="waterTarget">
|
</a-col>
|
||||||
<a-input v-model:value="form.waterTarget" placeholder="请输入水质目标" allow-clear />
|
<a-col :lg="6" :md="12" :sm="24" :xs="24">
|
||||||
</a-form-item>
|
<a-space>
|
||||||
<a-form-item label="经度" name="longitude">
|
<a-button type="primary" @click="reload">查询</a-button>
|
||||||
<a-input v-model:value="form.longitude" placeholder="请输入经度" allow-clear />
|
<a-button @click="reset" style="background: #FFA200FF; border-color: #FFA200FF;color: #FFFFFF">重置
|
||||||
</a-form-item>
|
</a-button>
|
||||||
<a-form-item label="纬度" name="latitude">
|
</a-space>
|
||||||
<a-input v-model:value="form.latitude" placeholder="请输入纬度" allow-clear />
|
</a-col>
|
||||||
</a-form-item>
|
</a-row>
|
||||||
</a-form>
|
<a-row>
|
||||||
</a-modal>
|
|
||||||
<!-- 表格 -->
|
</a-row>
|
||||||
<ele-pro-table
|
</a-form>
|
||||||
v-model:selection="selectionList"
|
<a-modal
|
||||||
ref="table"
|
v-model:visible="showNYear"
|
||||||
row-key="waterStationPointId"
|
:title="'批量复制'"
|
||||||
:datasource="url"
|
:confirm-loading="loading"
|
||||||
:columns="columns"
|
:body-style="{ paddingBottom: '8px' }"
|
||||||
:where="where"
|
@ok="copyBatch"
|
||||||
:scroll="{ x: 'max-content' }"
|
>
|
||||||
@done="(d) => (data = d.data)"
|
<a-form
|
||||||
|
ref="form"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
|
||||||
|
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
||||||
|
>
|
||||||
|
<a-form-item label="新年份" name="nYear">
|
||||||
|
<a-input-number id="inputNumber" v-model:value="nYear" :min="1970" :max="2050"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="showEdit"
|
||||||
|
:title="form.waterStationPointId !== undefined ? '修改' : '添加'"
|
||||||
|
:confirm-loading="loading"
|
||||||
|
:width="800"
|
||||||
|
:body-style="{ paddingBottom: '8px' }"
|
||||||
|
@ok="save"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
ref="form"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
|
||||||
|
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
|
||||||
|
>
|
||||||
|
<a-form-item label="年份" name="year">
|
||||||
|
<a-input-number v-model:value="form.year" :min="1970" :max="2050"/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="所在河流名称" name="riverName">
|
||||||
|
<a-input v-model:value="form.riverName" placeholder="请输入所在河流名称" allow-clear/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="自动站名称" name="stationName">
|
||||||
|
<a-input v-model:value="form.stationName" placeholder="请输入自动站名称" allow-clear/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="所属系统" name="system">
|
||||||
|
<a-select v-model:value="form.system" allowClear placeholder="未选择">
|
||||||
|
<a-select-option :value="'1'">国家水站</a-select-option>
|
||||||
|
<a-select-option :value="'2'">广西水系统</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="水质目标" name="waterTarget">
|
||||||
|
<a-input v-model:value="form.waterTarget" placeholder="请输入水质目标" allow-clear/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="经度" name="longitude">
|
||||||
|
<a-input v-model:value="form.longitude" placeholder="请输入经度" allow-clear/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="纬度" name="latitude">
|
||||||
|
<a-input v-model:value="form.latitude" placeholder="请输入纬度" allow-clear/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="修正位置" name="correctLocation">
|
||||||
|
<a-input-search @search="showRoadMap(form)"
|
||||||
|
:value="`[${form.correctLng},${form.correctLat}]`"
|
||||||
|
placeholder="`[${form.longitude},${form.latitude}]`" allow-clear>
|
||||||
|
<template #enterButton>
|
||||||
|
<a-button>选择位置</a-button>
|
||||||
|
</template>
|
||||||
|
</a-input-search>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-modal :closable="false" :destroy-on-close="true" :width="1000" :body-style="{height:'700px'}"
|
||||||
|
v-model:visible="visibleRoadMap" :title="roadMapTitle"
|
||||||
|
>
|
||||||
|
<div style="width: 100%;height: 100%;" ref="roadMap" id="roadMap"></div>
|
||||||
|
<template #footer>
|
||||||
|
<a-button key="submit" type="primary" @click="visibleRoadMap = false">确定</a-button>
|
||||||
|
</template>
|
||||||
|
</a-modal>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ele-pro-table
|
||||||
|
v-model:selection="selectionList"
|
||||||
|
ref="table"
|
||||||
|
row-key="waterStationPointId"
|
||||||
|
:datasource="url"
|
||||||
|
:columns="columns"
|
||||||
|
:where="where"
|
||||||
|
:scroll="{ x: 'max-content' }"
|
||||||
|
@done="(d) => (data = d.data)"
|
||||||
|
>
|
||||||
|
<template #toolbar>
|
||||||
|
<a-space>
|
||||||
|
<a-button @click="openEdit" type="primary">新增</a-button>
|
||||||
|
<a-dropdown>
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu @click="setCYear">
|
||||||
|
<a-menu-item v-for="item in yearOptions" :key="item.value">
|
||||||
|
{{ item.label }}
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button>
|
||||||
|
批量复制
|
||||||
|
<DownOutlined/>
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
<a-popconfirm
|
||||||
|
:disabled="selectionList.length == 0"
|
||||||
|
:title="`确认删除${selectionList.length}条数据吗?`"
|
||||||
|
ok-text="Yes"
|
||||||
|
cancel-text="No"
|
||||||
|
@confirm="removeBatch"
|
||||||
>
|
>
|
||||||
<template #toolbar>
|
<a-button
|
||||||
<a-space>
|
:disabled="selectionList.length == 0"
|
||||||
<a-button @click="openEdit" type="primary">新增</a-button>
|
type="primary"
|
||||||
<a-dropdown>
|
ghost
|
||||||
<template #overlay>
|
danger
|
||||||
<a-menu @click="setCYear">
|
>删除
|
||||||
<a-menu-item v-for="item in yearOptions" :key="item.value">
|
</a-button>
|
||||||
{{ item.label }}
|
</a-popconfirm>
|
||||||
</a-menu-item>
|
<a-button @click="exportData" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">导出
|
||||||
</a-menu>
|
</a-button>
|
||||||
</template>
|
</a-space>
|
||||||
<a-button>
|
</template>
|
||||||
批量复制
|
<template #action="{ record }">
|
||||||
<DownOutlined/>
|
<a-space>
|
||||||
</a-button>
|
<a-button
|
||||||
</a-dropdown>
|
@click="openEdit(record)"
|
||||||
<a-popconfirm
|
type="primary"
|
||||||
:disabled="selectionList.length == 0"
|
shape="round"
|
||||||
:title="`确认删除${selectionList.length}条数据吗?`"
|
size="small"
|
||||||
ok-text="Yes"
|
>修改
|
||||||
cancel-text="No"
|
</a-button
|
||||||
@confirm="removeBatch"
|
>
|
||||||
>
|
<a-popconfirm
|
||||||
<a-button
|
:title="`确认删除这条数据吗?`"
|
||||||
:disabled="selectionList.length == 0"
|
ok-text="Yes"
|
||||||
type="primary"
|
cancel-text="No"
|
||||||
ghost
|
@confirm="remove(record)"
|
||||||
danger
|
>
|
||||||
>删除
|
<a-button type="primary" danger shape="round" size="small"
|
||||||
</a-button>
|
>删除
|
||||||
</a-popconfirm>
|
</a-button
|
||||||
<a-button @click="exportData" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">导出</a-button>
|
>
|
||||||
</a-space>
|
</a-popconfirm>
|
||||||
</template>
|
</a-space>
|
||||||
<template #action="{ record }">
|
</template>
|
||||||
<a-space>
|
</ele-pro-table>
|
||||||
<a-button
|
</a-card>
|
||||||
@click="openEdit(record)"
|
</div>
|
||||||
type="primary"
|
<!-- 编辑弹窗 -->
|
||||||
shape="round"
|
|
||||||
size="small"
|
|
||||||
>修改</a-button
|
|
||||||
>
|
|
||||||
<a-popconfirm
|
|
||||||
:title="`确认删除这条数据吗?`"
|
|
||||||
ok-text="Yes"
|
|
||||||
cancel-text="No"
|
|
||||||
@confirm="remove(record)"
|
|
||||||
>
|
|
||||||
<a-button type="primary" danger shape="round" size="small"
|
|
||||||
>删除</a-button
|
|
||||||
>
|
|
||||||
</a-popconfirm>
|
|
||||||
</a-space>
|
|
||||||
</template>
|
|
||||||
</ele-pro-table>
|
|
||||||
</a-card>
|
|
||||||
</div>
|
|
||||||
<!-- 编辑弹窗 -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import _ from "lodash";
|
// import _ from "lodash";
|
||||||
import {
|
import {
|
||||||
listAllUrl,
|
listAllUrl,
|
||||||
savePlace,
|
savePlace,
|
||||||
updatePlace,
|
updatePlace,
|
||||||
removePlace,
|
removePlace,
|
||||||
removeBatchPlace,
|
removeBatchPlace,
|
||||||
copyBatchPlace,
|
copyBatchPlace,
|
||||||
getColumnOptions
|
getColumnOptions
|
||||||
} from "@/api/ecology/water/river-water";
|
} from "@/api/ecology/water/river-water";
|
||||||
import XLSX from "xlsx";
|
import XLSX from "xlsx";
|
||||||
import {DownOutlined} from '@ant-design/icons-vue';
|
import {DownOutlined} from '@ant-design/icons-vue';
|
||||||
// import moment from "moment";
|
// import moment from "moment";
|
||||||
export default {
|
export default {
|
||||||
name: "water",
|
name: "water",
|
||||||
components: {DownOutlined},
|
components: {DownOutlined},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
data: [],
|
data: [],
|
||||||
// 表格数据接口
|
// 表格数据接口
|
||||||
url: listAllUrl,
|
url: listAllUrl,
|
||||||
selection: [],
|
selection: [],
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
columns: [
|
columns: [
|
||||||
{title: "年份", dataIndex: "year",sorter: true,},
|
{title: "年份", dataIndex: "year", sorter: true,},
|
||||||
{title: "所在河流名称",dataIndex: "riverName",sorter: true,},
|
{title: "所在河流名称", dataIndex: "riverName", sorter: true,},
|
||||||
{title: "自动站名称",dataIndex: "stationName",sorter: true,},
|
{title: "自动站名称", dataIndex: "stationName", sorter: true,},
|
||||||
{title: "所属系统",dataIndex: "system",sorter: true,customRender:({text})=> text == "1"?"国家水站":"广西水系统"},
|
{title: "所属系统", dataIndex: "system", sorter: true, customRender: ({text}) => text == "1" ? "国家水站" : "广西水系统"},
|
||||||
{
|
{
|
||||||
title: "水质目标",
|
title: "水质目标",
|
||||||
dataIndex: "waterTarget",
|
dataIndex: "waterTarget",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "经度",
|
title: "经度",
|
||||||
dataIndex: "longitude",
|
dataIndex: "longitude",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "纬度",
|
title: "纬度",
|
||||||
dataIndex: "latitude",
|
dataIndex: "latitude",
|
||||||
},
|
},
|
||||||
{
|
{title: "修正经度", dataIndex: "correctLng"},
|
||||||
title: "操作",
|
{title: "修正纬度", dataIndex: "correctLat"},
|
||||||
key: "action",
|
{
|
||||||
width: 150,
|
title: "操作",
|
||||||
align: "center",
|
key: "action",
|
||||||
fixed: "right",
|
width: 150,
|
||||||
slots: {
|
align: "center",
|
||||||
customRender: "action",
|
fixed: "right",
|
||||||
},
|
slots: {
|
||||||
},
|
customRender: "action",
|
||||||
],
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
// 表格搜索条件
|
// 表格搜索条件
|
||||||
where: {},
|
where: {},
|
||||||
// 表格选中数据
|
// 表格选中数据
|
||||||
selectionList: [],
|
selectionList: [],
|
||||||
// 是否显示编辑弹窗
|
// 是否显示编辑弹窗
|
||||||
showEdit: false,
|
showEdit: false,
|
||||||
// 表单数据
|
// 表单数据
|
||||||
form: {},
|
form: {},
|
||||||
loading: false,
|
loading: false,
|
||||||
rules: {
|
rules: {
|
||||||
year: [{required: true, message: '请输入年份'}],
|
year: [{required: true, message: '请输入年份'}],
|
||||||
stationName:[{required: true,message: '请输入自动站名称'}],
|
stationName: [{required: true, message: '请输入自动站名称'}],
|
||||||
system: [{required: true,message: '请输入所属系统',},],
|
system: [{required: true, message: '请输入所属系统',},],
|
||||||
},
|
},
|
||||||
yearOptions: [],
|
yearOptions: [],
|
||||||
showNYear:false,
|
showNYear: false,
|
||||||
cYear: undefined,
|
cYear: undefined,
|
||||||
nYear:undefined,
|
nYear: undefined,
|
||||||
};
|
visibleRoadMap: false,
|
||||||
},
|
roadMapTitle: "选择坐标",
|
||||||
mounted() {
|
};
|
||||||
this.getOptions();
|
},
|
||||||
},
|
mounted() {
|
||||||
methods: {
|
this.getOptions();
|
||||||
/* 刷新表格 */
|
},
|
||||||
reload() {
|
methods: {
|
||||||
|
/* 刷新表格 */
|
||||||
|
reload() {
|
||||||
|
|
||||||
this.$refs.table.reload({
|
this.$refs.table.reload({
|
||||||
where: this.where,
|
where: this.where,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/* 重置搜索 */
|
/* 重置搜索 */
|
||||||
reset() {
|
reset() {
|
||||||
this.where = {};
|
this.where = {};
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
/* 打开编辑弹窗 */
|
/* 打开编辑弹窗 */
|
||||||
openEdit(row) {
|
openEdit(row) {
|
||||||
// cloneRecord.mi
|
// cloneRecord.mi
|
||||||
this.form = Object.assign({}, row);
|
this.form = Object.assign({}, row);
|
||||||
this.showEdit = true;
|
this.showEdit = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.form.clearValidate(); // 清除表单验证信息
|
this.$refs.form.clearValidate(); // 清除表单验证信息
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async save() {
|
async save() {
|
||||||
await this.$refs.form.validate();
|
await this.$refs.form.validate();
|
||||||
const hide = this.$message.loading('请求中..', 0);
|
const hide = this.$message.loading('请求中..', 0);
|
||||||
const form = this.form;
|
const form = this.form;
|
||||||
console.log(form,'form');
|
console.log(form, 'form');
|
||||||
if (form.waterStationPointId) {
|
if (form.waterStationPointId) {
|
||||||
updatePlace(form)
|
updatePlace(form)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
this.showEdit = false;
|
this.showEdit = false;
|
||||||
this.$message.success(res.data.msg);
|
this.$message.success(res.data.msg);
|
||||||
this.reload();
|
this.reload();
|
||||||
this.getOptions();
|
this.getOptions();
|
||||||
} else {
|
|
||||||
this.$message.error(res.data.msg);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.$message.error(error.message);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hide();
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
savePlace(form)
|
this.$message.error(res.data.msg);
|
||||||
.then((res) => {
|
|
||||||
if (res.data.code == 0) {
|
|
||||||
this.showEdit = false;
|
|
||||||
this.$message.success(res.data.msg);
|
|
||||||
this.reload();
|
|
||||||
this.getOptions();
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.data.msg);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.$message.error(error.message);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hide();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
/* 删除单个 */
|
.catch((error) => {
|
||||||
remove(row) {
|
this.$message.error(error.message);
|
||||||
const hide = this.$message.loading('请求中..', 0);
|
})
|
||||||
removePlace(row.waterStationPointId).then((res) => {
|
.finally(() => {
|
||||||
hide();
|
hide();
|
||||||
if (res.data.code === 0) {
|
});
|
||||||
this.$message.success(res.data.msg);
|
} else {
|
||||||
this.reload();
|
savePlace(form)
|
||||||
} else {
|
.then((res) => {
|
||||||
this.$message.error(res.data.msg);
|
if (res.data.code == 0) {
|
||||||
}
|
this.showEdit = false;
|
||||||
}).catch(e => {
|
this.$message.success(res.data.msg);
|
||||||
hide();
|
this.reload();
|
||||||
this.$message.error(e.message);
|
this.getOptions();
|
||||||
})
|
} else {
|
||||||
},
|
this.$message.error(res.data.msg);
|
||||||
/* 批量删除 */
|
}
|
||||||
removeBatch() {
|
})
|
||||||
const hide = this.$message.loading('请求中..', 0);
|
.catch((error) => {
|
||||||
const ids = this.selectionList.map((item) => item.waterStationPointId);
|
this.$message.error(error.message);
|
||||||
removeBatchPlace(ids).then((res) => {
|
})
|
||||||
if (res.data.code === 0) {
|
.finally(() => {
|
||||||
this.$message.success(res.data.msg);
|
hide();
|
||||||
this.reload();
|
});
|
||||||
} else {
|
}
|
||||||
this.$message.error(res.data.msg);
|
},
|
||||||
}
|
/* 删除单个 */
|
||||||
}).catch(e => {
|
remove(row) {
|
||||||
this.$message.error(e.message);
|
const hide = this.$message.loading('请求中..', 0);
|
||||||
}).finally(() => {
|
removePlace(row.waterStationPointId).then((res) => {
|
||||||
hide();
|
hide();
|
||||||
})
|
if (res.data.code === 0) {
|
||||||
},
|
this.$message.success(res.data.msg);
|
||||||
getOptions(){
|
this.reload();
|
||||||
getColumnOptions("year").then(res => {
|
} else {
|
||||||
console.log(res)
|
this.$message.error(res.data.msg);
|
||||||
if (res.data.code == 0) {
|
|
||||||
this.yearOptions = res.data.data.map(item => {
|
|
||||||
return {
|
|
||||||
label: item,
|
|
||||||
value: item
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
setCYear(e){
|
|
||||||
this.cYear = e.key;
|
|
||||||
this.showNYear = true;
|
|
||||||
},
|
|
||||||
copyBatch(){
|
|
||||||
const hide = this.$message.loading('请求中..', 0);
|
|
||||||
copyBatchPlace({cyear:Number(this.cYear),nyear:this.nYear}).then(res=>{
|
|
||||||
if (res.data.code === 0) {
|
|
||||||
this.$message.success(res.data.msg);
|
|
||||||
this.reload();
|
|
||||||
this.getOptions();
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.data.msg);
|
|
||||||
}
|
|
||||||
this.showNYear = false;
|
|
||||||
}).catch(e => {
|
|
||||||
this.$message.error(e.message);
|
|
||||||
}).finally(() => {
|
|
||||||
hide();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
exportData(){
|
|
||||||
const columns = this.columns.filter(item=>item.dataIndex);
|
|
||||||
const arr = [];
|
|
||||||
const th = columns.map((item) => item.title);
|
|
||||||
arr.push(th);
|
|
||||||
this.data.forEach((d) => {
|
|
||||||
const td = columns.map((item) => d[item.dataIndex]);
|
|
||||||
arr.push(td);
|
|
||||||
});
|
|
||||||
|
|
||||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
|
||||||
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
|
||||||
}
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
hide();
|
||||||
|
this.$message.error(e.message);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/* 批量删除 */
|
||||||
|
removeBatch() {
|
||||||
|
const hide = this.$message.loading('请求中..', 0);
|
||||||
|
const ids = this.selectionList.map((item) => item.waterStationPointId);
|
||||||
|
removeBatchPlace(ids).then((res) => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
this.$message.success(res.data.msg);
|
||||||
|
this.reload();
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.data.msg);
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
this.$message.error(e.message);
|
||||||
|
}).finally(() => {
|
||||||
|
hide();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getOptions() {
|
||||||
|
getColumnOptions("year").then(res => {
|
||||||
|
console.log(res)
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
this.yearOptions = res.data.data.map(item => {
|
||||||
|
return {
|
||||||
|
label: item,
|
||||||
|
value: item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setCYear(e) {
|
||||||
|
this.cYear = e.key;
|
||||||
|
this.showNYear = true;
|
||||||
|
},
|
||||||
|
copyBatch() {
|
||||||
|
const hide = this.$message.loading('请求中..', 0);
|
||||||
|
copyBatchPlace({cyear: Number(this.cYear), nyear: this.nYear}).then(res => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
this.$message.success(res.data.msg);
|
||||||
|
this.reload();
|
||||||
|
this.getOptions();
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.data.msg);
|
||||||
|
}
|
||||||
|
this.showNYear = false;
|
||||||
|
}).catch(e => {
|
||||||
|
this.$message.error(e.message);
|
||||||
|
}).finally(() => {
|
||||||
|
hide();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
exportData() {
|
||||||
|
const columns = this.columns.filter(item => item.dataIndex);
|
||||||
|
const arr = [];
|
||||||
|
const th = columns.map((item) => item.title);
|
||||||
|
arr.push(th);
|
||||||
|
this.data.forEach((d) => {
|
||||||
|
const td = columns.map((item) => d[item.dataIndex]);
|
||||||
|
arr.push(td);
|
||||||
|
});
|
||||||
|
|
||||||
|
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||||
|
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
||||||
|
},
|
||||||
|
showRoadMap(form) {
|
||||||
|
const {longitude, latitude, correctLng, correctLat} = form
|
||||||
|
this.visibleRoadMap = true
|
||||||
|
this.roadMapTitle = "选择修正后的道路坐标"
|
||||||
|
this.$nextTick(() => {
|
||||||
|
console.log(this.$refs.roadMap)
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var map = new BMap.Map(this.$refs.roadMap); // 创建Map实例
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.NavigationControl()); //初始化地图控件
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.ScaleControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
map.addControl(new BMap.OverviewMapControl());
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var point = new BMap.Point(correctLng ? correctLng : longitude ? longitude : 108.33, correctLat ? correctLat : latitude ? latitude : 22.84);
|
||||||
|
// var point = new BBMap.Point(form.longitude ? form.longitude : 108.33, form.latitude ? form.latitude : 22.84);
|
||||||
|
map.centerAndZoom(point, 13);//初始化地图中心点
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var marker = new BMap.Marker(point); //初始化地图标记
|
||||||
|
marker.enableDragging(); //标记开启拖拽
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var gc = new BMap.Geocoder();//地址解析类
|
||||||
|
//添加标记拖拽监听
|
||||||
|
marker.addEventListener("dragend", (e) => {
|
||||||
|
//获取地址信息
|
||||||
|
this.form['correctLng'] = e.point.lng
|
||||||
|
this.form['correctLat'] = e.point.lat
|
||||||
|
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//添加标记点击监听
|
||||||
|
marker.addEventListener("click", function (e) {
|
||||||
|
gc.getLocation(e.point, function (rs) {
|
||||||
|
showLocationInfo(e.point, rs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
map.centerAndZoom(point, 15); //设置中心点坐标和地图级别
|
||||||
|
map.addOverlay(marker); //将标记添加到地图中
|
||||||
|
//显示地址信息窗口
|
||||||
|
function showLocationInfo(pt, rs) {
|
||||||
|
var opts = {
|
||||||
|
width: 250, //信息窗口宽度
|
||||||
|
height: 100, //信息窗口高度
|
||||||
|
title: "" //信息窗口标题
|
||||||
|
}
|
||||||
|
var addComp = rs.addressComponents;
|
||||||
|
var addr = "当前位置:" + addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber + "<br/>";
|
||||||
|
addr += "纬度: " + pt.lat + ", " + "经度:" + pt.lng;
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
var infoWindow = new BMap.InfoWindow(addr, opts); //创建信息窗口对象
|
||||||
|
marker.openInfoWindow(infoWindow);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user