停车区修改

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