江河点位修正

This commit is contained in:
weicw
2022-02-07 11:58:36 +08:00
parent 53db46f90a
commit 98511f212a
7 changed files with 1745 additions and 1298 deletions

View File

@@ -235,6 +235,8 @@ export default {
{title: "路宽", dataIndex: "roadWidth", sorter: true,},
{title: "测点经度", dataIndex: "placeLng", sorter: true,},
{title: "测点纬度", dataIndex: "placeLat", sorter: true,},
{title: "修正经度", dataIndex: "correctLng"},
{title: "修正纬度", dataIndex: "correctLat"},
{
title: "操作",
key: "action",

View File

@@ -30,7 +30,7 @@
<a-select style="width: 200px;" v-if="currentRequestCata == '1'" @change="changeText" name="waterCate"
: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 }}
</a-select-option>
</a-select>
@@ -43,11 +43,17 @@
<mapNominal :param="nominalList"></mapNominal>
<!-- <map-table-center :rowData="pointData"></map-table-center>-->
<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>
</template>
<script>
import {
river, national, waterStation, autonomous
river, national, waterStation, autonomous,updateRiverCorrectLocation
} from "@/api/gis/gisApi";
import {
getColumnOptions,
@@ -160,6 +166,10 @@ export default {
"common": "劣Ⅴ",
"desc": "劣五类"
}],
// 字典表单
visibleRoadMap: false,
roadMapTitle: "选择坐标",
form: {},
};
},
mounted() {
@@ -172,7 +182,7 @@ export default {
that.requestFun()
},
changeText: function (e) {
that.currentCate = that.waterCate[e]
that.currentCate = e
that.requestFun()
},
changeCate: function (e) {
@@ -317,6 +327,13 @@ export default {
that.currentY = 0
that.tipFlag = false
}, 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) {
@@ -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

View File

@@ -104,6 +104,23 @@
<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-item label="序号" name="seq">
<a-input v-model:value="form.seq" placeholder="请输入序号" allow-clear />
</a-form-item>
@@ -263,6 +280,8 @@
title: "纬度",
dataIndex: "latitude",
},
{title: "修正经度", dataIndex: "correctLng"},
{title: "修正纬度", dataIndex: "correctLat"},
{
title: "序号",
dataIndex: "seq",
@@ -310,6 +329,8 @@
showNYear: false,
cYear: undefined,
nYear: undefined,
visibleRoadMap: false,
roadMapTitle: "选择坐标",
};
},
mounted() {
@@ -462,7 +483,67 @@
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);
}
})
},
},
};

View File

@@ -1,389 +1,475 @@
<!--水站点位信息-->
<template>
<div class="ele-body">
<a-card :bordered="false">
<a-form
:model="where"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
>
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="年份:">
<a-select v-model:value="where.year" allow-clear show-search>
<a-select-option
v-for="(item) in yearOptions"
:key="item.value"
>{{ item.label }}
</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>
<div class="ele-body">
<a-card :bordered="false">
<a-form
:model="where"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
>
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="年份:">
<a-select v-model:value="where.year" allow-clear show-search>
<a-select-option
v-for="(item) in yearOptions"
:key="item.value"
>{{ item.label }}
</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>
</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)"
</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-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-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"
>
<a-button
:disabled="selectionList.length == 0"
type="primary"
ghost
danger
>删除
</a-button>
</a-popconfirm>
<a-button @click="exportData" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">导出</a-button>
</a-space>
</template>
<template #action="{ record }">
<a-space>
<a-button
@click="openEdit(record)"
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>
<!-- 编辑弹窗 -->
<a-button
:disabled="selectionList.length == 0"
type="primary"
ghost
danger
>删除
</a-button>
</a-popconfirm>
<a-button @click="exportData" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">导出
</a-button>
</a-space>
</template>
<template #action="{ record }">
<a-space>
<a-button
@click="openEdit(record)"
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>
<script>
// import _ from "lodash";
import {
listAllUrl,
savePlace,
updatePlace,
removePlace,
removeBatchPlace,
copyBatchPlace,
getColumnOptions
listAllUrl,
savePlace,
updatePlace,
removePlace,
removeBatchPlace,
copyBatchPlace,
getColumnOptions
} from "@/api/ecology/water/river-water";
import XLSX from "xlsx";
import {DownOutlined} from '@ant-design/icons-vue';
// import moment from "moment";
export default {
name: "water",
components: {DownOutlined},
data() {
return {
data: [],
// 表格数据接口
url: listAllUrl,
selection: [],
// 表格列配置
columns: [
{title: "年份", dataIndex: "year",sorter: true,},
{title: "所在河流名称",dataIndex: "riverName",sorter: true,},
{title: "自动站名称",dataIndex: "stationName",sorter: true,},
{title: "所属系统",dataIndex: "system",sorter: true,customRender:({text})=> text == "1"?"国家水站":"广西水系统"},
{
title: "水质目标",
dataIndex: "waterTarget",
},
{
title: "经度",
dataIndex: "longitude",
},
{
title: "纬度",
dataIndex: "latitude",
},
{
title: "操作",
key: "action",
width: 150,
align: "center",
fixed: "right",
slots: {
customRender: "action",
},
},
],
name: "water",
components: {DownOutlined},
data() {
return {
data: [],
// 表格数据接口
url: listAllUrl,
selection: [],
// 表格列配置
columns: [
{title: "年份", dataIndex: "year", sorter: true,},
{title: "所在河流名称", dataIndex: "riverName", sorter: true,},
{title: "自动站名称", dataIndex: "stationName", sorter: true,},
{title: "所属系统", dataIndex: "system", sorter: true, customRender: ({text}) => text == "1" ? "国家水站" : "广西水系统"},
{
title: "水质目标",
dataIndex: "waterTarget",
},
{
title: "经度",
dataIndex: "longitude",
},
{
title: "纬度",
dataIndex: "latitude",
},
{title: "修正经度", dataIndex: "correctLng"},
{title: "修正纬度", dataIndex: "correctLat"},
{
title: "操作",
key: "action",
width: 150,
align: "center",
fixed: "right",
slots: {
customRender: "action",
},
},
],
// 表格搜索条件
where: {},
// 表格选中数据
selectionList: [],
// 是否显示编辑弹窗
showEdit: false,
// 表单数据
form: {},
loading: false,
rules: {
year: [{required: true, message: '请输入年份'}],
stationName:[{required: true,message: '请输入自动站名称'}],
system: [{required: true,message: '请输入所属系统',},],
},
yearOptions: [],
showNYear:false,
cYear: undefined,
nYear:undefined,
};
},
mounted() {
this.getOptions();
},
methods: {
/* 刷新表格 */
reload() {
// 表格搜索条件
where: {},
// 表格选中数据
selectionList: [],
// 是否显示编辑弹窗
showEdit: false,
// 表单数据
form: {},
loading: false,
rules: {
year: [{required: true, message: '请输入年份'}],
stationName: [{required: true, message: '请输入自动站名称'}],
system: [{required: true, message: '请输入所属系统',},],
},
yearOptions: [],
showNYear: false,
cYear: undefined,
nYear: undefined,
visibleRoadMap: false,
roadMapTitle: "选择坐标",
};
},
mounted() {
this.getOptions();
},
methods: {
/* 刷新表格 */
reload() {
this.$refs.table.reload({
where: this.where,
});
},
/* 重置搜索 */
reset() {
this.where = {};
this.reload();
},
/* 打开编辑弹窗 */
openEdit(row) {
// cloneRecord.mi
this.form = Object.assign({}, row);
this.showEdit = true;
this.$nextTick(() => {
this.$refs.form.clearValidate(); // 清除表单验证信息
});
},
async save() {
await this.$refs.form.validate();
const hide = this.$message.loading('请求中..', 0);
const form = this.form;
console.log(form,'form');
if (form.waterStationPointId) {
updatePlace(form)
.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();
});
this.$refs.table.reload({
where: this.where,
});
},
/* 重置搜索 */
reset() {
this.where = {};
this.reload();
},
/* 打开编辑弹窗 */
openEdit(row) {
// cloneRecord.mi
this.form = Object.assign({}, row);
this.showEdit = true;
this.$nextTick(() => {
this.$refs.form.clearValidate(); // 清除表单验证信息
});
},
async save() {
await this.$refs.form.validate();
const hide = this.$message.loading('请求中..', 0);
const form = this.form;
console.log(form, 'form');
if (form.waterStationPointId) {
updatePlace(form)
.then((res) => {
if (res.data.code == 0) {
this.showEdit = false;
this.$message.success(res.data.msg);
this.reload();
this.getOptions();
} else {
savePlace(form)
.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();
});
this.$message.error(res.data.msg);
}
},
/* 删除单个 */
remove(row) {
const hide = this.$message.loading('请求中..', 0);
removePlace(row.waterStationPointId).then((res) => {
hide();
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).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());
})
.catch((error) => {
this.$message.error(error.message);
})
.finally(() => {
hide();
});
} else {
savePlace(form)
.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();
});
}
},
/* 删除单个 */
remove(row) {
const hide = this.$message.loading('请求中..', 0);
removePlace(row.waterStationPointId).then((res) => {
hide();
if (res.data.code === 0) {
this.$message.success(res.data.msg);
this.reload();
} else {
this.$message.error(res.data.msg);
}
}).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>