停车区修改

This commit is contained in:
tx 2024-08-31 18:04:08 +08:00
parent ec4880f981
commit 24c0a1a060

View File

@ -1,276 +1,303 @@
<template>
<div class="container">
<div id="container"></div>
<div class="input-card-left">
<div style="color: red">tips双击区域可重新编辑</div>
<div style="color: red">
点击新建--左键开始建立停车区--右键完成建立--点击结束编辑才会最终生效
</div>
</div>
<div class="input-card">
<el-button @click="setFitView()">全局查看</el-button>
<el-button @click="changeMapStyle()">切换地图</el-button>
<el-button @click="showMarkers">显示/隐藏文字</el-button>
</div>
<div class="input-card-right">
<el-button @click="createPolygon()">新建</el-button>
<!-- <el-button @click="polyEditor.open()">开始编辑</el-button> -->
<el-button @click="editClose">结束编辑</el-button>
<el-button @click="changeMapStyle()">切换地图</el-button>
<el-button @click="clearPolygon()">清除多边形</el-button>
<el-button @click="sub()">保存</el-button>
</div>
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
style="margin-top: 20px"
>
<el-form-item label="停车区" label-width="100" prop="parkingName">
<el-input
v-model="queryParams.parkingName"
placeholder="请输入停车区"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="queryParams.type" clearable>
<el-option
v-for="dict in dict.type.et_parking_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:parking:add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:parking:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:parking:remove']"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:parking:export']"
>导出</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-if="showtable"
v-loading="loading"
:data="parkingList"
@selection-change="handleSelectionChange"
ref="tableRef"
:cell-style="columnbackgroundStyle"
@current-change="handleCurrentChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="parkingId" />
<el-table-column label="名称" align="center" prop="parkingName" />
<el-table-column
label="误差距离"
align="center"
prop="error"
:formatter="formatDistance"
/>
<el-table-column label="类型" align="center" prop="type">
<template slot-scope="scope">
<dict-tag
:options="dict.type.et_parking_type"
:value="scope.row.type"
/>
</template>
</el-table-column>
<el-table-column label="照片" align="center" prop="picture" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50" />
</template>
</el-table-column>
<el-table-column label="状态" align="center" key="status">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<!-- <el-table-column label="区域" align="center" prop="areaId" />-->
<el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
<div class="left">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
style="margin-top: 20px"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column>
<el-table-column label="id" align="center" prop="parkingId">
<template slot-scope="scope">
<div :ref="'row_' + scope.row.parkingId">
{{ scope.row.parkingId }}
</div>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-form-item label="停车区" label-width="100" prop="parkingName">
<el-input
v-model="queryParams.parkingName"
placeholder="请输入停车区"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="queryParams.type" clearable>
<el-option
v-for="dict in dict.type.et_parking_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
type="text"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:parking:add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:parking:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="changeRange(scope.row)"
v-hasPermi="['system:parking:remove']"
>修改范围</el-button
>
<el-button
size="mini"
type="text"
type="danger"
plain
icon="el-icon-delete"
@click="handleDelete(scope.row)"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:parking:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:parking:export']"
>导出</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="24">
<el-form-item label="停车区" label-width="90" prop="parkingName">
<el-input style="width: 90%" v-model="form.parkingName" placeholder="请输入停车区" />
</el-form-item>
</el-col>
<el-col>
<el-col :span="12">
<el-form-item label="类型">
<el-radio-group v-model="form.type">
<el-radio
v-for="dict in dict.type.et_parking_type"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
<el-table
v-if="showtable"
v-loading="loading"
:data="parkingList"
@selection-change="handleSelectionChange"
ref="tableRef"
:cell-style="columnbackgroundStyle"
@current-change="handleCurrentChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="parkingId" />
<el-table-column label="名称" align="center" prop="parkingName" />
<el-table-column
label="误差距离"
align="center"
prop="error"
:formatter="formatDistance"
/>
<el-table-column label="类型" align="center" prop="type">
<template slot-scope="scope">
<dict-tag
:options="dict.type.et_parking_type"
:value="scope.row.type"
/>
</template>
</el-table-column>
<!-- <el-table-column label="照片" align="center" prop="picture" width="100">
<template slot-scope="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50" />
</template>
</el-table-column> -->
<el-table-column label="状态" align="center" key="status">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<!-- <el-table-column label="区域" align="center" prop="areaId" />-->
<!-- <el-table-column
label="创建时间"
align="center"
prop="createTime"
width="180"
>
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
</template>
</el-table-column> -->
<!-- <el-table-column label="id" align="center" prop="parkingId">
<template slot-scope="scope">
<div :ref="'row_' + scope.row.parkingId">
{{ scope.row.parkingId }}
</div>
</template>
</el-table-column> -->
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:parking:edit']"
>修改</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="changeRange(scope.row)"
v-hasPermi="['system:parking:remove']"
>修改范围</el-button
>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:parking:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<el-dialog
:title="title"
:visible.sync="open"
width="1200px"
append-to-body
>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-col :span="24">
<el-form-item label="停车区" label-width="90" prop="parkingName">
<el-input
style="width: 90%"
v-model="form.parkingName"
placeholder="请输入停车区"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="还车误差(米)" label-width="100">
<el-input-number v-model="form.error" placeholder="还车误差"></el-input-number>
<el-col>
<el-col :span="12">
<el-form-item label="类型">
<el-radio-group v-model="form.type">
<el-radio
v-for="dict in dict.type.et_parking_type"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}</el-radio
>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="还车误差(米)" label-width="100">
<el-input-number
v-model="form.error"
placeholder="还车误差"
></el-input-number>
</el-form-item>
</el-col>
</el-col>
<el-col :span="24"> </el-col>
<el-col>
<el-col :span="12">
<el-form-item label="经度" prop="longitude">
<el-input
v-model="form.longitude"
placeholder="请新建边界"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="纬度" prop="latitude">
<el-input
v-model="form.latitude"
placeholder="请新建边界"
disabled
/>
</el-form-item>
</el-col>
</el-col>
<el-col :span="24" v-show="form.type == '1'">
<el-form-item label="周边环境图片" prop="picture">
<image-upload v-model="form.picture" />
</el-form-item>
</el-col>
</el-col>
<el-col :span="24">
</el-col>
<el-col >
<el-col :span="12">
<el-form-item label="经度" prop="longitude">
<el-input v-model="form.longitude" placeholder="请新建边界" disabled/>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="纬度" prop="latitude">
<el-input v-model="form.latitude" placeholder="请新建边界" disabled/>
</el-form-item>
</el-col>
</el-col>
<el-col :span="24" v-show="form.type =='1' ">
<el-form-item label="周边环境图片" prop="picture" >
<image-upload v-model="form.picture"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
</el-form-item>
</el-col>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
<div class="right">
<div id="container"></div>
<div class="input-card-left">
<div style="color: red">tips双击区域可重新编辑</div>
<div style="color: red">
点击新建--左键开始建立停车区--右键完成建立--点击结束编辑才会最终生效
</div>
</div>
</el-dialog>
<div class="input-card">
<el-button @click="setFitView()">全局查看</el-button>
<el-button @click="changeMapStyle()">切换地图</el-button>
<el-button @click="showMarkers">显示/隐藏文字</el-button>
</div>
<div class="input-card-right">
<el-button @click="createPolygon()">新建</el-button>
<!-- <el-button @click="polyEditor.open()">开始编辑</el-button> -->
<el-button @click="editClose">结束编辑</el-button>
<el-button @click="changeMapStyle()">切换地图</el-button>
<el-button @click="clearPolygon()">清除多边形</el-button>
<!-- <el-button @click="sub()">保存</el-button> -->
</div>
</div>
</div>
</template>
@ -380,6 +407,7 @@ export default {
highlightedId: null, //
showtable: true,
currentRow: null,
ischange: false,
//
rules: {
parkingName: [
@ -422,51 +450,51 @@ export default {
this.form = response.data;
this.areaLon = response.data.longitude;
this.areaLat = response.data.latitude;
});
this.getArea(this.areaId);
setTimeout(() => {
this.map.getAllOverlays("polygon").forEach((polygon) => {
// polygon id
if (
polygon.getExtData() &&
polygon.getExtData().parkingId === row.parkingId
) {
// polygon
this.map.remove(polygon);
}
});
this.initEditor(row.boundaryStr);
this.map.setCenter([row.longitude, row.latitude]);
this.map.setZoom(17); // 15
document.documentElement.scrollTop = 0
// polygon id
if (
polygon.getExtData() &&
polygon.getExtData().parkingId === row.parkingId
) {
// polygon
this.map.remove(polygon);
}
});
this.initEditor(row.boundaryStr);
this.map.setCenter([row.longitude, row.latitude]);
this.map.setZoom(17); // 15
document.documentElement.scrollTop = 0;
}, 300);
console.log(row, "changeRangechangeRangechangeRange");
},
sub(){
updateParking(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
// this.open = false;
this.getList();
});
sub() {
updateParking(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
// this.open = false;
this.getArea(this.areaId);
});
},
/** 提交按钮 */
submitForm() {
/** 提交按钮 */
submitForm() {
this.form.areaId = this.defaultAreaId;
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
if (this.form.parkingId != null) {
updateParking(this.form).then(response => {
updateParking(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
this.getArea(this.areaId);
});
} else {
addParking(this.form).then(response => {
this.form.latitude = this.lat;
this.form.longitude = this.lon;
addParking(this.form).then((response) => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
this.getArea(this.areaId);
});
}
}
@ -544,6 +572,7 @@ export default {
// this.initEditor();
},
initEditor(pathList) {
this.ischange = true;
var path1 = [];
path1 = JSON.parse(pathList) || [];
@ -605,6 +634,8 @@ export default {
},
getArea(areaId) {
this.markers = [];
this.labels = [];
getArea(areaId).then((response) => {
this.queryParams.areaId = response.data.areaId;
this.areaId = response.data.areaId;
@ -769,20 +800,15 @@ export default {
},
clearPolygon() {
this.status = false;
if (polyEditor) {
polyEditor.close(); //
}
//
this.map.getAllOverlays("polygon").forEach((polygon) => {
this.map.remove(polygon);
const polygons = polyEditor.getPolygons(); //
console.log(polygons, "polygonspolygons");
polygons.forEach((polygon) => {
this.map.remove(polygon); //
});
polyEditor.close(); //
//
//
this.coordList = "";
this.$emit("mapList", "");
this.$emit("center", "");
},
changeMapStyle() {
//
@ -930,12 +956,39 @@ export default {
this.map.add(polygon);
},
highlightRow(parkingId) {
this.$set(this, "highlightedId", parkingId);
// this.showtable = false;
// this.$refs.myTable.setCurrentRow(this.parkingList[6]);
this.$nextTick(() => {
this.scrollToRow(6);
});
if ((this.ischange = false)) {
this.$set(this, "highlightedId", parkingId);
this.$nextTick(() => {
this.scrollToRow(6);
});
this.$confirm("请选择要进行的操作", "提示", {
confirmButtonText: "修改范围",
cancelButtonText: "修改停车区内容",
closeOnClickModal: false,
closeOnPressEscape: false,
type: "warning",
distinguishCancelAndClose: true,
})
.then(() => {
//
this.changeRange(
this.parkingList.find((item) => item.parkingId === parkingId)
);
})
.catch((action) => {
if (action === "cancel") {
//
this.handleUpdate(
this.parkingList.find((item) => item.parkingId === parkingId)
);
} else {
//
//
}
});
}
},
handleCurrentChange(val) {
this.currentRow = val;
@ -1011,9 +1064,9 @@ export default {
addNoriding(data, title, lon, lat, parkingId) {
let polygon = new AMap.Polygon({
path: data,
fillColor: "#ccebc5",
strokeOpacity: 1,
fillOpacity: 0.5,
fillColor: "#fff9e6", //
strokeOpacity: 0.1,
fillOpacity: 0.1, //
strokeColor: "#ffcc00",
strokeWeight: 2,
strokeStyle: "solid",
@ -1046,7 +1099,7 @@ export default {
},
editClose: function () {
// console.log("this", this);
this.ischange = false;
let that = this;
polyEditor.on("end", function (event) {
// event.target
@ -1062,13 +1115,15 @@ export default {
console.log(mapList, "mapListmapList");
// this.newmapList=mapList
let mapListJson = JSON.stringify(mapList);
console.log("mapListJson:"+mapListJson);
this.form.boundaryStr = mapListJson;
let centerArr = center.toString().split(",");
this.form.longitude = centerArr[0];
this.form.latitude = centerArr[1];
console.log("mapListJson:" + mapListJson);
// console.log(this.form.boundaryStr,'this.form.boundaryStrthis.form.boundaryStr');
that.form.boundaryStr = mapListJson;
let centerArr = center.toString().split(",");
that.form.longitude = centerArr[0];
that.form.latitude = centerArr[1];
});
polyEditor.close();
this.sub();
},
},
beforeDestroy() {
@ -1078,30 +1133,32 @@ export default {
</script>
<style lang="scss" scoped>
#container {
width: 100%;
height: 30rem;
}
.el-table__body-wrapper {
overflow: auto; /* 或者 scroll */
}
.input-card {
position: absolute;
top: 15px;
right: 15px;
}
.highlight-row {
background-color: #f0f9eb; /* 浅绿色背景 */
}
.container {
display: flex;
height: 90vh;
}
.left {
width: 40%;
overflow-y: auto;
}
.right {
position: relative;
border: 1px solid rgb(204, 204, 204);
padding-bottom: 50px;
width: 60%;
height: 90vh;
#container {
width: 100%;
height: 100%;
}
.input-card-right {
position: absolute;
top: 28rem;
top: 90%;
right: 15px;
}
.input-card-left {
position: absolute;
top: 5px;
@ -1110,4 +1167,19 @@ export default {
line-height: 20px;
}
}
.input-card {
position: absolute;
top: 15px;
right: 15px;
}
.el-table__body-wrapper {
overflow: auto;
}
.highlight-row {
background-color: #f0f9eb;
/* 浅绿色背景 */
}
</style>