This commit is contained in:
刘旋 2023-04-24 17:29:34 +08:00
parent 454a10534c
commit ba83f4e478
2 changed files with 280 additions and 370 deletions

View File

@ -2,27 +2,25 @@
<div ref="map" <div ref="map"
class="container"></div> class="container"></div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import WKT from 'terraformer-wkt-parser' import WKT from 'terraformer-wkt-parser'
import * as turf from '@turf/turf'
import L from 'leaflet' import L from 'leaflet'
import 'leaflet/dist/leaflet.css' import 'leaflet/dist/leaflet.css'
import 'leaflet-draw/dist/leaflet.draw' import 'leaflet-draw/dist/leaflet.draw'
import 'leaflet-draw/dist/leaflet.draw.css' import 'leaflet-draw/dist/leaflet.draw.css'
import '@geoman-io/leaflet-geoman-free'; import '@geoman-io/leaflet-geoman-free';
import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'; import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css';
import 'Leaflet-ImageOverlay-Rotated' import 'Leaflet-ImageOverlay-Rotated'
import { useVariableStore } from '/@/stores/index.ts' import { useVariableStore } from '/@/stores/index.ts'
import * as omnivore from '@mapbox/leaflet-omnivore' import * as omnivore from '@mapbox/leaflet-omnivore'
const variableStore = useVariableStore() const variableStore = useVariableStore()
const map = ref() const map = ref()
let homeMap = null let homeMap = null
let text = null
let featureLayerG_area = null let featureLayerG_area = null
let featureLayerG_point = null let featureLayerG_point = null
let layerRectangle = null
onMounted(() => { onMounted(() => {
homeMap = L.map(map.value, { homeMap = L.map(map.value, {
@ -44,92 +42,8 @@ onMounted(() => {
tileSize: 256, tileSize: 256,
zoomOffset: 1, zoomOffset: 1,
}).addTo(homeMap) }).addTo(homeMap)
text = new L.Draw.Polygon(homeMap)
L.drawLocal = {
draw: {
handlers: {
circle: {
tooltip: {
start: '单击并拖动可绘制圆',
},
radius: '半径',
},
circlemarker: {
tooltip: {
start: '点击地图放置圆形标记',
},
},
marker: {
tooltip: {
start: '点击地图放置标记Esc取消',
},
},
polygon: {
tooltip: {
start: '点击开始绘制Esc取消',
cont: '单击以继续绘制Esc取消',
end: '单击第一个点完成绘制Esc取消',
},
},
polyline: {
error: '<strong>异常:</strong> 形状边缘不能交叉!',
tooltip: {
start: '点击开始绘制Esc取消',
cont: '单击以继续绘制Esc取消',
end: '双击完成绘制Esc取消',
},
},
rectangle: {
tooltip: {
start: '单击并拖动以绘制矩形',
end: '完成',
},
},
simpleshape: {
tooltip: {
end: '释放鼠标完成绘图',
},
},
},
},
edit: {
toolbar: {
actions: {
save: {
title: '保存改动',
text: '保存',
},
cancel: {
title: '取消编辑,丢弃所有更改',
text: '取消',
},
clearAll: {
title: '清除所有标记',
text: '清除所有',
},
},
buttons: {
edit: '编辑图层',
editDisabled: '不需要编辑图层',
remove: '删除图层',
removeDisabled: '没有要删除的图层',
},
},
handlers: {
edit: {
tooltip: {
text: '拖动节点或标记来编辑图形',
subtext: '单击“取消”撤消更改',
},
},
remove: {
tooltip: {
text: '单击某个标记进行删除',
},
},
},
},
}
featureLayerG_area = L.layerGroup().addTo(homeMap) featureLayerG_area = L.layerGroup().addTo(homeMap)
featureLayerG_point = L.layerGroup().addTo(homeMap) featureLayerG_point = L.layerGroup().addTo(homeMap)
}) })
@ -142,14 +56,34 @@ onMounted(() => {
*/ */
const mapOperations = { const mapOperations = {
wktParseToMap: (res) => { wktParseToMap: (res) => {
return omnivore.wkt.parse(res).addTo(featureLayerG_point) let layer = omnivore.wkt.parse(res)
// if(omnivore.wkt.parse(res) instanceof L.Marker){ layer.addTo(featureLayerG_point)
// } let attr=Object.values(layer._layers)
// else{
// return omnivore.wkt.parse(res).addTo(featureLayerG_area ) // flyTo
// } if(attr[0].feature.geometry.type.indexOf('Polygon')==-1){
homeMap.flyTo([attr[0].feature.geometry.coordinates[1],attr[0].feature.geometry.coordinates[0]],3)
}
// fly
else{
let polygons=[];
for(let i=0;i<attr[0].feature.geometry.coordinates.length;i++){
console.log(attr[0].feature.geometry.coordinates[i])
polygons.push(turf.polygon([attr[0].feature.geometry.coordinates[i]]));
}
let centers = polygons.map(polygon => turf.centroid(polygon));
// console.log(centers)
let features=[]
for(let i=0;i<centers.length;i++){
features.push(turf.point(centers[i].geometry.coordinates))
}
let final_center=turf.center(turf.featureCollection(features))
// console.log(final_center)
homeMap.flyTo([final_center.geometry.coordinates[1],final_center.geometry.coordinates[0]],3)
}
return layer
}, },
/** /**
* Object param 参数集合 * Object param 参数集合
@ -177,7 +111,7 @@ const mapOperations = {
addInteractMarker: (lat, lon) => { addInteractMarker: (lat, lon) => {
featureLayerG_point.clearLayers() featureLayerG_point.clearLayers()
variableStore.layerGroupPoint = null variableStore.layerGroupPoint = null
var marker = L.marker([lat, lon], { draggable: true }).addTo( var marker = L.marker([lat, lon]).addTo(
featureLayerG_point featureLayerG_point
) )
let features = featureLayerG_point.toGeoJSON().features let features = featureLayerG_point.toGeoJSON().features
@ -189,6 +123,7 @@ const mapOperations = {
// marker.on('click',function(){ // marker.on('click',function(){
// featureLayerG_point.removeLayer(marker) // featureLayerG_point.removeLayer(marker)
// }) // })
}, },
/** /**
* Object param 参数集合 * Object param 参数集合
@ -344,10 +279,7 @@ const mapOperations = {
featureLayerG_point.clearLayers() featureLayerG_point.clearLayers()
variableStore.layerGroupPoint = null variableStore.layerGroupPoint = null
variableStore.layerGroupPoly = null variableStore.layerGroupPoly = null
if (variableStore.polygoncontrol == 'option2') {
text = new L.Draw.Polygon(homeMap)
text.enable()
}
}, },
/** /**
* 清楚wkt添加的所有 * 清楚wkt添加的所有
@ -369,80 +301,86 @@ const mapOperations = {
// console.log('2-2') // console.log('2-2')
variableStore.layerGroupPoint = null variableStore.layerGroupPoint = null
featureLayerG_point.clearLayers() featureLayerG_point.clearLayers()
homeMap.pm.enableDraw('Polygon',{ snappable: false });
let polygon=null;
homeMap.on("pm:create",(e)=>{
featureLayerG_area.clearLayers()
e.layer.setStyle({
color: '#FF0080',
opacity: 1,
})
e.layer.addTo(featureLayerG_area)
polygon=e.layer
})
// featureLayerG_area.clearLayers() // featureLayerG_area.clearLayers()
// variableStore.layerGroupPoly=null; // variableStore.layerGroupPoly=null;
text = new L.Draw.Polygon(homeMap) return polygon
text.enable()
}, },
clearPolygon: () => { clearPolygon: () => {
// console.log('1-2') // console.log('1-2')
text.disable()
featureLayerG_area.clearLayers() featureLayerG_area.clearLayers()
variableStore.layerGroupPoly = null variableStore.layerGroupPoly = null
homeMap.pm.disableDraw();
// variableStore.layerGroupPoint=null // variableStore.layerGroupPoint=null
// featureLayerG_point.clearLayers() // featureLayerG_point.clearLayers()
}, },
drawCreated: () => { drawCreated: () => {
// console.log("2-3")
homeMap.on('draw:created', function (elll) { // homeMap.on('draw:created', function (elll) {
featureLayerG_area.clearLayers() // featureLayerG_area.clearLayers()
variableStore.layerGroupPoly = null // variableStore.layerGroupPoly = null
elll.layer.setStyle({ // elll.layer.setStyle({
color: '#FF0080', // color: '#FF0080',
opacity: 1, // opacity: 1,
}) // })
featureLayerG_area.addLayer(elll.layer) // featureLayerG_area.addLayer(elll.layer)
let features = featureLayerG_area.toGeoJSON().features // let features = featureLayerG_area.toGeoJSON().features
// console.log(features) // // console.log(features)
variableStore.layerGroupPoly = features.map(function (feature) { // variableStore.layerGroupPoly = features.map(function (feature) {
return WKT.convert(feature.geometry) // return WKT.convert(feature.geometry)
}) // })
variableStore.layerGroupPoly = // variableStore.layerGroupPoly =
variableStore.layerGroupPoly.join('\n') // variableStore.layerGroupPoly.join('\n')
text.enable()
}) // })
}, },
drawDestroyed: () => { Edit: () => {
homeMap.off('draw:created', function (elll) { homeMap.pm.enableGlobalEditMode({
elll.layer.setStyle({ allowSelfIntersection: false,
color: '#FF0080',
opacity: 1,
})
featureLayerG_area.addLayer(elll.layer)
let features = featureLayerG_area.toGeoJSON().features
// console.log(features)
variableStore.layerGroupPoly = features.map(function (feature) {
return WKT.convert(feature.geometry)
})
variableStore.layerGroupPoly =
variableStore.layerGroupPoly.join('\n')
text = new L.Draw.Polygon(homeMap)
text.enable()
}) })
}, if(featureLayerG_area.getLayers().length==1){
drawRectangle: () => { featureLayerG_area.eachLayer(function (layer) {
if (layerRectangle != null) { layer.on('pm:edit', (e) => {
homeMap.removeLayer(layerRectangle) let features = featureLayerG_area.toGeoJSON().features
layerRectangle = null variableStore.layerGroupPoly = features.map(function (feature) {
return WKT.convert(feature.geometry)
})
variableStore.layerGroupPoly = variableStore.layerGroupPoly.join('\n')
});
});
} }
homeMap.pm.enableDraw('Rectangle', { else if(featureLayerG_point.getLayers().length==1){
snappable: true, featureLayerG_point.eachLayer(function (layer) {
snapDistance: 20, layer.on('pm:edit', (e) => {
}); let features = featureLayerG_point.toGeoJSON().features
homeMap.on('pm:create', (e) => { variableStore.layerGroupPoint = features.map(function (feature) {
L.PM.reInitLayer(e.layer); return WKT.convert(feature.geometry)
layerRectangle = e.layer })
}); variableStore.layerGroupPoint = variableStore.layerGroupPoint.join('\n')
});
});
}
else{
console.log('error')
}
}, },
deleteRectangle: () => {
homeMap.removeLayer(layerRectangle)
}
} }
//omnivore.wkt.parse('POINT(-80 0)').addTo(homeMap); //omnivore.wkt.parse('POINT(-80 0)').addTo(homeMap);
defineExpose({ defineExpose({
mapOperations, mapOperations,
}) })
</script> </script>

View File

@ -1,46 +1,45 @@
<template> <template>
<div class="system-role-container layout-padding"> <div class="system-role-container layout-padding">
<el-config-provider :locale="en"> <el-config-provider :locale="en">
<div class="system-role-padding layout-padding-auto layout-padding-view"> <div class="system-role-padding layout-padding-auto layout-padding-view">
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" style="margin-left: 20px"> <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick" style="margin-left: 20px">
<el-tab-pane label="Unapproved" name="first"> <el-tab-pane label="Unapproved" name="first">
<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%"> <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
<el-table-column type="index" label="ID" width="50" /> <el-table-column type="index" label="ID" width="50" />
<el-table-column prop="username" label="User name" show-overflow-tooltip></el-table-column> <el-table-column prop="username" label="User name" show-overflow-tooltip></el-table-column>
<el-table-column prop="organization" label="Organization" show-overflow-tooltip></el-table-column> <el-table-column prop="organization" label="Organization" show-overflow-tooltip></el-table-column>
<el-table-column prop="disasterType" label="Disaster type" show-overflow-tooltip> <el-table-column prop="disasterType" label="Disaster type" show-overflow-tooltip>
<!-- 在disasterType中获取dictKey 对应的dictValue --> <!-- 在disasterType中获取dictKey 对应的dictValue -->
<template #default="scope"> <template #default="scope">
<el-tag type="info">{{ getValue(scope.row.disasterType) }}</el-tag> <el-tag type="info">{{ getValue(scope.row.disasterType) }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="disasterKeyword" label="Disaster keywords" show-overflow-tooltip></el-table-column> <el-table-column prop="disasterKeyword" label="Disaster keyword" show-overflow-tooltip></el-table-column>
<!-- <el-table-column prop="affectedCountry" label="Affected country" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="affectedCountry" label="Affected country" show-overflow-tooltip></el-table-column> -->
<!-- <el-table-column prop="Longitude" label="Longitude" show-overflow-tooltip></el-table-column> <!-- <el-table-column prop="Longitude" label="Longitude" show-overflow-tooltip></el-table-column>
<el-table-column prop="Latitude" label="Latitude" show-overflow-tooltip></el-table-column> --> <el-table-column prop="Latitude" label="Latitude" show-overflow-tooltip></el-table-column> -->
<el-table-column prop="disasterTime" label="Disaster time" show-overflow-tooltip> <el-table-column prop="disasterTime" label="Disaster time" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<!-- 格式化去除时分秒 --> <!-- 格式化去除时分秒 -->
{{ dateFormat(scope.row.disasterTime) }} {{ dateFormat(scope.row.disasterTime) }}
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column prop="responseTime" label="Response time" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="responseTime" label="Response time" show-overflow-tooltip></el-table-column> -->
<el-table-column prop="respondStatus" label="Response status" show-overflow-tooltip> <el-table-column prop="respondStatus" label="Response status" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-tag type="info" v-if="scope.row.respondStatus === 0">Awaiting approval</el-tag> <el-tag type="info" v-if="scope.row.respondStatus === 0">Awaiting approval</el-tag>
<el-tag type="info" v-if="scope.row.respondStatus === 1">Rejected</el-tag> <el-tag type="info" v-if="scope.row.respondStatus === 1">Rejected</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="Operate" label="Operate" show-overflow-tooltip> <el-table-column prop="Operate" label="Operate" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-button size="small" text type="primary" <el-button size="small" text type="primary" @click="onOpenEditRole('edit', scope.row)">Approve</el-button>
@click="onOpenEditRole('edit', scope.row)">Approve</el-button> </template>
</template> </el-table-column>
</el-table-column>
<!-- <el-table-column prop="describe" label="角色描述" show-overflow-tooltip></el-table-column> <!-- <el-table-column prop="describe" label="角色描述" show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column> --> <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column> -->
<!-- <el-table-column prop="status" label="角色状态" show-overflow-tooltip> <!-- <el-table-column prop="status" label="角色状态" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-tag type="success" v-if="scope.row.status">启用</el-tag> <el-tag type="success" v-if="scope.row.status">启用</el-tag>
<el-tag type="info" v-else>禁用</el-tag> <el-tag type="info" v-else>禁用</el-tag>
@ -56,29 +55,29 @@
> >
</template> </template>
</el-table-column> --> </el-table-column> -->
</el-table> </el-table>
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15" <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15"
:pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.current" background :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.current" background
v-model:page-size="state.tableData.param.size" layout="total, sizes, prev, pager, next, jumper" v-model:page-size="state.tableData.param.size" layout="total, sizes, prev, pager, next, jumper"
:total="state.tableData.total"> :total="state.tableData.total">
</el-pagination> </el-pagination>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="Approved" name="second"> <el-tab-pane label="Approved | Rejected" name="second">
<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%"> <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
<el-table-column type="index" label="ID" width="50" />
<el-table-column prop="username" label="User name" show-overflow-tooltip></el-table-column> <el-table-column prop="username" label="User name" show-overflow-tooltip></el-table-column>
<!-- <el-table-column prop="Administrator" label="Administrator" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="Administrator" label="Administrator" show-overflow-tooltip></el-table-column> -->
<el-table-column prop="organization" label="Organization" show-overflow-tooltip></el-table-column> <el-table-column prop="organization" label="Organization" show-overflow-tooltip></el-table-column>
<el-table-column prop="email" label="Email" show-overflow-tooltip></el-table-column> <el-table-column prop="email" label="Email" show-overflow-tooltip></el-table-column>
<el-table-column prop="disasterType" label="Disaster type" show-overflow-tooltip> <el-table-column prop="disasterType" label="Disaster type" show-overflow-tooltip>
<!-- 在disasterType中获取dictKey 对应的dictValue --> <!-- 在disasterType中获取dictKey 对应的dictValue -->
<template #default="scope"> <template #default="scope">
<el-tag type="info">{{ getValue(scope.row.disasterType) }}</el-tag> <el-tag type="info">{{ getValue(scope.row.disasterType) }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="disasterKeyword" label="Disaster keywords" show-overflow-tooltip></el-table-column> <el-table-column prop="disasterKeyword" label="Disaster keyword" show-overflow-tooltip></el-table-column>
<!-- <el-table-column prop="Affected country" label="Affected country" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="Affected country" label="Affected country" show-overflow-tooltip></el-table-column> -->
<!-- <el-table-column prop="Longitude" label="Longitude" show-overflow-tooltip></el-table-column> <!-- <el-table-column prop="Longitude" label="Longitude" show-overflow-tooltip></el-table-column>
<el-table-column prop="Latitude" label="Latitude" show-overflow-tooltip></el-table-column> --> <el-table-column prop="Latitude" label="Latitude" show-overflow-tooltip></el-table-column> -->
<el-table-column prop="disasterTime" label="Disaster time" show-overflow-tooltip> <el-table-column prop="disasterTime" label="Disaster time" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
@ -87,75 +86,72 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="chiefName" label="Answer" show-overflow-tooltip></el-table-column> <el-table-column prop="chiefName" label="Answer" show-overflow-tooltip></el-table-column>
<!-- <el-table-column prop="responseTime" label="Response time" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="responseTime" label="Response time" show-overflow-tooltip></el-table-column> -->
<!-- <el-table-column prop="Operate" label="Operate" show-overflow-tooltip></el-table-column> --> <!-- <el-table-column prop="Operate" label="Operate" show-overflow-tooltip></el-table-column> -->
<el-table-column width="170" prop="respondStatus" label="Response status" show-overflow-tooltip> <el-table-column prop="respondStatus" label="Response status" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-tag type="info" v-if="scope.row.respondStatus === 2">Approved</el-tag> <el-tag type="info" v-if="scope.row.respondStatus === 2">Approved</el-tag>
<el-tag type="info" v-if="scope.row.respondStatus === 1">Rejected</el-tag> <el-tag type="info" v-if="scope.row.respondStatus === 1">Rejected</el-tag>
<el-tag type="success" v-if="scope.row.respondStatus === 3">Complete response</el-tag> </template>
</template>
</el-table-column> </el-table-column>
<el-table-column width="200" prop="Operate" label="Operate" show-overflow-tooltip> <el-table-column prop="Operate" label="Operate" show-overflow-tooltip>
<template #default="scope"> <template #default="scope">
<el-button size="small" text type="primary" @click="onAllocation(scope.row)">Allocation</el-button> <el-button size="small" text type="primary" @click="onAllocation(scope.row)">Allocation</el-button>
<el-button size="small" text type="danger" @click="responseEnded(scope.row)">Response ended</el-button> </template>
</template> </el-table-column>
</el-table-column> </el-table>
</el-table> <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15"
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.current" background
:pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.current" background v-model:page-size="state.tableData.param.size" layout="total, sizes, prev, pager, next, jumper"
v-model:page-size="state.tableData.param.size" layout="total, sizes, prev, pager, next, jumper" :total="state.tableData.total">
:total="state.tableData.total"> </el-pagination>
</el-pagination> </el-tab-pane>
</el-tab-pane> </el-tabs>
</el-tabs> </div>
</div> <el-dialog v-model="state.dialogVisible" title="Review" width="30%">
<el-dialog v-model="state.dialogVisible" title="Approval" width="30%"> <el-container style="margin-top: -2%;margin-bottom: 2%;">
<el-container style="margin-top: -2%;margin-bottom: 2%;"> <el-radio v-model="state.radio" label='1' @click="mapEvents('1')">Point</el-radio>
<el-radio v-model="state.radio" label='1' @click="mapEvents('1')">Point</el-radio> <el-radio v-model="state.radio" label='2' @click="mapEvents('2')">Area</el-radio>
<el-radio v-model="state.radio" label='2' @click="mapEvents('2')">Area</el-radio> <el-radio v-model="state.radio" label='3' @click="mapEvents('3')">Edit</el-radio>
<el-radio v-model="state.radio" label='3' @click="mapEvents('3')">Edit</el-radio> <el-button type="primary" style="margin-left: 5%;" @click="ClearSubmit">Clear</el-button>
<el-button type="primary" style="margin-left: 5%;" @click="ClearSubmit">Clear</el-button> </el-container>
</el-container> <el-container style="margin-top: 2%;margin-bottom: 2%;" v-if="state.radio==='1'?true:false">
<el-container style="margin-top: 2%;margin-bottom: 2%;" v-if="state.radio === '1' ? true : false"> <span style="line-height: 35px;"> Latitude</span>
<span style="line-height: 35px;"> Latitude</span> <el-input placeholder="wait……" style="height:35px;margin-right: 1%;" v-model="state.dislat" readonly="readonly"> </el-input>
<el-input placeholder="wait……" style="height:35px;margin-right: 1%;" v-model="state.dislat" readonly="readonly"> <span style="line-height: 35px;">Longitude</span>
</el-input> <el-input placeholder="wait……" style="height:35px;" v-model="state.dislon" readonly="readonly"></el-input>
<span style="line-height: 35px;">Longitude</span> </el-container>
<el-input placeholder="wait……" style="height:35px;" v-model="state.dislon" readonly="readonly"></el-input> <MapPage style="height:350px ; width:100% ;margin-bottom: 10px;" ref="mapRef"></MapPage>
</el-container> <el-form-item label="Disaster Time">
<MapPage style="height:350px ; width:100% ;margin-bottom: 10px;" ref="mapRef"></MapPage> <el-date-picker v-model="state.edit.disasterTime" type="date" value-format="YYYY-MM-DD"
<el-form-item label="Disaster Time"> placeholder="Select date and time" />
<el-date-picker v-model="state.edit.disasterTime" type="date" value-format="YYYY-MM-DD" </el-form-item>
placeholder="Select date and time" />
</el-form-item>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="dialogVisible = false">Cancel</el-button> <el-button @click="dialogVisible = false">Cancel</el-button>
<el-button type="danger" @click="reviews(1)"> <el-button type="danger" @click="reviews(1)">
Reject Reject
</el-button> </el-button>
<el-button type="primary" @click="reviews(2)"> <el-button type="primary" @click="reviews(2)">
Approve Approve
</el-button> </el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
<selectUser ref="select" @callback="getTableData"></selectUser> <selectUser ref ="select" @callback="getTableData"></selectUser>
</el-config-provider> </el-config-provider>
</div> </div>
</template> </template>
<script setup name="userResponse"> <script setup name="userResponse">
import en from 'element-plus/dist/locale/en.mjs' import en from 'element-plus/dist/locale/en.mjs'
import { reactive, onMounted, ref, nextTick, watchEffect, defineAsyncComponent } from 'vue'; import { reactive, onMounted, ref, nextTick,watchEffect,defineAsyncComponent } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { getList, review, responseEndedDisasterInfo } from '/@/api/disasterInfo/index'; import { getList, review } from '/@/api/disasterInfo/index';
import { getDictionary } from '/@/api/system/dictbiz'; import { getDictionary } from '/@/api/system/dictbiz';
import { useVariableStore } from '/@/stores/index.ts' import { useVariableStore } from '/@/stores/index.ts'
// //
@ -163,8 +159,8 @@ import Map from '/@/components/Map.vue';
import { useDateFormat } from '@vueuse/shared'; import { useDateFormat } from '@vueuse/shared';
import selectUser from './component/selectUser.vue'; import selectUser from './component/selectUser.vue';
import L from "leaflet"; import L from "leaflet";
import '@geoman-io/leaflet-geoman-free'; import '@geoman-io/leaflet-geoman-free';
import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css'; import '@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css';
import "leaflet/dist/leaflet.css"; import "leaflet/dist/leaflet.css";
import 'leaflet-draw/dist/leaflet.draw' import 'leaflet-draw/dist/leaflet.draw'
import 'leaflet-draw/dist/leaflet.draw.css' import 'leaflet-draw/dist/leaflet.draw.css'
@ -179,29 +175,12 @@ const handleClick = (tab, event) => {
getTableData(); getTableData();
}; };
const MapPage = defineAsyncComponent({ const MapPage = defineAsyncComponent({
loader: () => import('/@/components/Map.vue'), loader:() =>import('/@/components/Map.vue'),
delay: 200, delay: 200,
}) })
const onAllocation = (row) => { const onAllocation = (row) => {
select.value.openDialog(row) select.value.openDialog(row)
}; };
const responseEnded = (row) => {
ElMessageBox.confirm(`Confirm completion of response?`, 'Prompt', {
confirmButtonText: 'Yes',
cancelButtonText: 'No',
type: 'warning',
})
.then(() => {
responseEndedDisasterInfo(row.id).then((da) => {
ElMessage.success('Operation successful');
})
})
.catch(() => { });
};
const dateFormat = (date) => { const dateFormat = (date) => {
return useDateFormat(date, 'YYYY-MM-DD').value; return useDateFormat(date, 'YYYY-MM-DD').value;
} }
@ -223,10 +202,10 @@ const state = reactive({
disasterTypeList: [], disasterTypeList: [],
selectName: 'first', selectName: 'first',
edit: {}, edit: {},
radio: null, radio:null,
dislat: '', dislat:'',
dislon: '', dislon:'',
wktPoint_Poly: undefined wktPoint_Poly:undefined
}); });
// //
const getTableData = () => { const getTableData = () => {
@ -235,7 +214,7 @@ const getTableData = () => {
if (state.selectName === 'first') { if (state.selectName === 'first') {
state.tableData.param.respondStatus = 0; state.tableData.param.respondStatus = 0;
} else { } else {
state.tableData.param.respondStatus = 3; state.tableData.param.respondStatus = 2;
} }
getList(state.tableData.param).then((res) => { getList(state.tableData.param).then((res) => {
state.tableData.data = res.records; state.tableData.data = res.records;
@ -248,41 +227,41 @@ const onHandleSizeChange = (val) => {
getTableData(); getTableData();
}; };
const onOpenEditRole = (type, row) => { const onOpenEditRole = (type, row) => {
// //
state.edit = JSON.parse(JSON.stringify(row)); state.edit = JSON.parse(JSON.stringify(row));
state.dialogVisible = true; state.dialogVisible = true;
setTimeout(() => { setTimeout(() => {
state.radio = "1" state.radio = "1"
// mapRef.value.mapOperations.removeAll() // mapRef.value.mapOperations.removeAll()
// //
if (state.wktPoint_Poly) { if(state.wktPoint_Poly){
mapRef.value.mapOperations.removeLayer(state.wktPoint_Poly) mapRef.value.mapOperations.removeLayer(state.wktPoint_Poly)
} }
state.wktPoint_Poly = mapRef.value.mapOperations.wktParseToMap(row.geometry) state.wktPoint_Poly= mapRef.value.mapOperations.wktParseToMap(row.geometry)
// mapRef.value.mapOperations.on("click", (res)=>{ // mapRef.value.mapOperations.on("click", (res)=>{
// mapRef.value.mapOperations.clearPolygon() // mapRef.value.mapOperations.clearPolygon()
// mapRef.value.mapOperations.removeLayer( state.wktPoint_Poly) // mapRef.value.mapOperations.removeLayer( state.wktPoint_Poly)
// mapRef.value.mapOperations.addInteractMarker(res.latlng.lat, res.latlng.lng) // mapRef.value.mapOperations.addInteractMarker(res.latlng.lat, res.latlng.lng)
// }) // })
mapEvents('1') mapEvents('1')
}, 100); },100);
}; };
const mapEvents = (ev) => { const mapEvents = (ev)=>{
if (ev == '1') { if(ev == '1'){
// mapRef.value.mapOperations.clearPolygon() // mapRef.value.mapOperations.clearPolygon()
mapRef.value.mapOperations.on("click", mapClick) mapRef.value.mapOperations.on("click", mapClick)
mapRef.value.mapOperations.on("mousemove", changelatlon) mapRef.value.mapOperations.on("mousemove", changelatlon)
mapRef.value.mapOperations.clearPolygon() mapRef.value.mapOperations.clearPolygon()
} else if (ev == '2') { }else if(ev == '2'){
mapRef.value.mapOperations.off("click", mapClick); mapRef.value.mapOperations.off("click",mapClick);
mapRef.value.mapOperations.drawPolygon() mapRef.value.mapOperations.drawPolygon()
// mapRef.value.mapOperations.drawPolygon() // mapRef.value.mapOperations.drawPolygon()
// mapRef.value.mapOperations.drawCreated() // mapRef.value.mapOperations.drawCreated()
} }
else { else{
mapRef.value.mapOperations.Edit() mapRef.value.mapOperations.Edit()
} }
}; };
@ -290,14 +269,14 @@ const ClearSubmit = () => {
setTimeout(() => { setTimeout(() => {
mapRef.value.mapOperations.removeAll() mapRef.value.mapOperations.removeAll()
variableStore.wktdata = null variableStore.wktdata = null
variableStore.layerGroupPoint = null; variableStore.layerGroupPoint=null;
layerGroupPoly = null; layerGroupPoly=null;
}, 100) }, 100)
} }
const mapClick = (res) => { const mapClick=(res)=>{
// mapRef.value.mapOperations.removeLayer( state.wktPoint_Poly ) mapRef.value.mapOperations.removeLayer( state.wktPoint_Poly )
changelatlon(res); changelatlon(res);
mapRef.value.mapOperations.addInteractMarker(res.latlng.lat.toFixed(3), res.latlng.lng.toFixed(3)) state.wktPoint_Poly=mapRef.value.mapOperations.addInteractMarker(res.latlng.lat.toFixed(3),res.latlng.lng.toFixed(3))
// console.log(state.wktPoint_Poly) // console.log(state.wktPoint_Poly)
} }
const reviews = (index) => { const reviews = (index) => {
@ -331,44 +310,44 @@ const onHandleCurrentChange = (val) => {
const changelatlon = (e) => { const changelatlon = (e) => {
//e //e
state.dislat = e.latlng.lat.toFixed(3); state.dislat = e.latlng.lat.toFixed(3);
state.dislon = e.latlng.lng.toFixed(3); state.dislon= e.latlng.lng.toFixed(3);
// if (state.lon < 0) { // if (state.lon < 0) {
// state.lon = state.lon + 360; // state.lon = state.lon + 360;
// } // }
// state.lon = state.lon.toFixed(3); // state.lon = state.lon.toFixed(3);
if (state.dislat < 0) { if (state.dislat < 0) {
state.dislat = String(Math.abs(state.dislat)) + "°S" state.dislat = String(Math.abs(state.dislat)) + "°S"
} }
else { else {
state.dislat = String(state.dislat) + "°N" state.dislat = String(state.dislat) + "°N"
} }
if (state.dislon <= 180 && state.dislon >= 0) {
state.dislon = String(Math.abs(state.dislon)) + "°E"
}
else if (state.dislon > 180 && state.dislon <= 360) {
state.dislon = String((360 - state.dislon).toFixed(3)) + "°W"
}
else if (state.dislon < 0) {
let n = Math.floor(state.dislon / 360)
state.dislon = (state.dislon - n * 360).toFixed(3)
if (state.dislon <= 180 && state.dislon >= 0) { if (state.dislon <= 180 && state.dislon >= 0) {
state.dislon = String(Math.abs(state.dislon)) + "°E" state.dislon = String(Math.abs(state.dislon)) + "°E"
} }
else if (state.dislon > 180 && state.dislon <= 360) { else if (state.dislon > 180 && state.dislon <= 360) {
state.dislon = String((360 - state.dislon).toFixed(3)) + "°W" state.dislon = String((360 - state.dislon).toFixed(3)) + "°W"
} }
else if (state.dislon < 0) { }
let n = Math.floor(state.dislon / 360) else if (state.dislon > 360) {
state.dislon = (state.dislon - n * 360).toFixed(3) let n = Math.floor(state.dislon / 360)
if (state.dislon <= 180 && state.dislon >= 0) { state.dislon = (state.dislon - n * 360).toFixed(3)
state.dislon = String(Math.abs(state.dislon)) + "°E" if (state.dislon <= 180 && state.dislon >= 0) {
} state.dislon = String(Math.abs(state.dislon)) + "°E"
else if (state.dislon > 180 && state.dislon <= 360) {
state.dislon = String((360 - state.dislon).toFixed(3)) + "°W"
}
} }
else if (state.dislon > 360) { else if (state.dislon > 180 && state.dislon <= 360) {
let n = Math.floor(state.dislon / 360) state.dislon = String((360 - state.dislon).toFixed(3)) + "°W"
state.dislon = (state.dislon - n * 360).toFixed(3)
if (state.dislon <= 180 && state.dislon >= 0) {
state.dislon = String(Math.abs(state.dislon)) + "°E"
}
else if (state.dislon > 180 && state.dislon <= 360) {
state.dislon = String((360 - state.dislon).toFixed(3)) + "°W"
}
} }
}
} }
// //
@ -377,14 +356,14 @@ onMounted(() => {
getDictionary({ code: 'disaster' }).then((res) => { getDictionary({ code: 'disaster' }).then((res) => {
state.disasterTypeList = res; state.disasterTypeList = res;
}); });
}); });
const getValue = (key) => { const getValue = (key) => {
//state.disasterTypeLis value //state.disasterTypeLis value
return state.disasterTypeList.find((item) => item.dictKey === key)?.dictValue; return state.disasterTypeList.find((item) => item.dictKey === key)?.dictValue;
}; };
</script> </script>
<style lang="scss"> <style>
.demo-tabs>.el-tabs__content { .demo-tabs>.el-tabs__content {
padding: 0px; padding: 0px;
color: #6b778c; color: #6b778c;
@ -401,11 +380,4 @@ const getValue = (key) => {
} }
} }
} }
.mt15 {
display: flex;
justify-content: end;
float: right;
margin-bottom: 15px;
}
</style> </style>