修改地图图层

pull/1/head
dearlin 2024-02-26 17:25:08 +08:00
parent 15e017eda5
commit 53175a7546
3 changed files with 35 additions and 31 deletions

View File

@ -32,3 +32,4 @@ export const setPathPlanningDelete = (params) =>
export const setPositioning = (params) =>
post("/videomanager/setPositioning", params); // 摆放摄像头
export const setLayAdd = (params) => post("/positAlarm/save", params); // 新建图层
export const setLayEdit = (params) => post("/positAlarm/edit", params); // 新建图层

View File

@ -4,27 +4,28 @@
:title="type === 'add' ? '新增' : '修改'"
:on-close="fnClose"
>
<el-form
ref="formRef"
:rules="rules"
:model="data.form"
label-width="150px"
>
<el-form ref="formRef" :rules="rules" :model="form" label-width="150px">
<el-form-item label="名称" prop="layName">
<el-input v-model="data.form.layName" />
<el-input v-model="form.layName" />
</el-form-item>
<el-form-item label="分组" prop="layGroup">
<el-input v-model="data.form.layGroup" />
<el-input v-model="form.layGroup" />
</el-form-item>
<el-form-item label="楼层" prop="floor">
<el-input v-model="data.form.floor" />
<el-input v-model="form.floor" />
</el-form-item>
<el-form-item label="list" prop="floor">
<el-input v-model="form.list" />
</el-form-item>
<el-form-item label="modUuid" prop="floor">
<el-input v-model="form.modUuid" />
</el-form-item>
</el-form>
<map-tools
v-if="visible"
ref="mapToolsRef"
v-model:positions="positions"
v-model:modUuid="modUuid"
v-model:positions="form.list"
v-model:modUuid="form.modUuid"
:type="1"
/>
<template #footer>
@ -39,8 +40,8 @@ import { useVModels } from "@vueuse/core";
import { debounce } from "throttle-debounce";
import { ElMessage } from "element-plus";
import MapTools from "@/components/map_tools";
import { reactive, ref } from "vue";
import { setLayAdd } from "@/request/map_settings.js";
import { ref } from "vue";
import { setLayAdd, setLayEdit } from "@/request/map_settings.js";
import useFormValidate from "@/assets/js/useFormValidate.js";
const props = defineProps({
@ -54,22 +55,20 @@ const props = defineProps({
required: true,
default: "",
},
});
const data = reactive({
form: {
layName: "",
layGroup: "",
floor: "",
type: Object,
required: true,
default: () => {},
},
});
const formRef = ref(null);
const emits = defineEmits(["update:visible", "get-data"]);
const emits = defineEmits(["update:visible", "update:form", "get-data"]);
const rules = {
layName: [{ required: true, message: "名称不能为空", trigger: "blur" }],
layGroup: [{ required: true, message: "分组不能为空", trigger: "blur" }],
floor: [{ required: true, message: "楼层不能为空", trigger: "blur" }],
};
const { visible } = useVModels(props, emits);
const { visible, form } = useVModels(props, emits);
const fnClose = () => {
positions.value = [];
modUuid.value = "";
@ -82,14 +81,18 @@ const fnSubmit = debounce(
1000,
async () => {
await useFormValidate(formRef);
if (positions.value.length === 0 || modUuid.value === "") {
if (props.form.list.length === 0 || props.form.modUuid === "") {
ElMessage.error("未选择建筑,或者未扎点");
return;
}
await setLayAdd({
...data.form,
list: JSON.stringify(positions.value),
modUuid: modUuid.value,
props.form.layId
? await setLayAdd({
...props.form,
list: JSON.stringify(props.form.list),
})
: await setLayEdit({
...props.form,
list: JSON.stringify(props.form.list),
});
ElMessage.success("保存成功");
fnClose();

View File

@ -53,7 +53,7 @@
type="primary"
text
link
@click="fnAddOrEdit(row.layId, 'edit')"
@click="fnAddOrEdit(row, 'edit')"
>
修改图层
</el-button>
@ -73,6 +73,7 @@
<add
v-model:visible="data.addOrEditDialog.visible"
:type="data.addOrEditDialog.type"
:form="data.addOrEditDialog.form"
@get-data="fnResetPagination"
/>
<edit-layer-info
@ -102,8 +103,7 @@ const { list, searchForm, tableRef, pagination, fnGetData, fnResetPagination } =
const data = reactive({
addOrEditDialog: {
visible: false,
layId: "",
type: "",
form: {},
},
editLayerInfoDialog: {
visible: false,
@ -140,8 +140,8 @@ const fnBatchDelete = debounce(
},
{ atBegin: true }
);
const fnAddOrEdit = (layId, type) => {
data.addOrEditDialog.layId = layId;
const fnAddOrEdit = (row, type) => {
data.addOrEditDialog.form = row;
data.addOrEditDialog.type = type;
data.addOrEditDialog.visible = true;
};