Browse Source

标签编辑2.0

master
DIAMOND 2 years ago
parent
commit
b295ec08d7
  1. 24
      src/axios/cameraMark/markLabelApi.ts
  2. 58
      src/views/page/Model/LabelEditModel.vue

24
src/axios/cameraMark/markLabelApi.ts

@ -2,6 +2,8 @@ import {axios} from '@/utils/axios';
import { apiUrl } from "@/axios"; import { apiUrl } from "@/axios";
import qs from 'qs'; import qs from 'qs';
const CisApiUrl = apiUrl.CisApiUrl;
enum Api { enum Api {
Add = '/cmMarkLabel/add', Add = '/cmMarkLabel/add',
AddReturnId = '/cmMarkLabel/addReturnId', AddReturnId = '/cmMarkLabel/addReturnId',
@ -12,13 +14,31 @@ enum Api {
GetPageList = '/cmMarkLabel/getPageList', GetPageList = '/cmMarkLabel/getPageList',
} }
const CisApiUrl = apiUrl.CisApiUrl;
interface modelParams {
CbCameraId: number, //相机 Id
CmMarkGroupId?: number, //标记组 Id
Name: string, //名称
PanPosition?: number, //Pan 坐标
TiltPosition?: number, //Tilt 坐标
ZoomPosition?: number, //Zoom 坐标
VideoWidth: number, //视频宽度
VideoHeight: number, //视频高度
CanvasLeftRatio: number,//画布 left 距离比例
CanvasTopRatio: number, //画布 top 距离比例
Remark?: string, //备注
IsDelete?: boolean, //软删除
Id?: string,
CreateTime?: string
}
export const Add = (params?: any) => axios.post(CisApiUrl + Api.Add, qs.stringify(params)) export const Add = (params?: any) => axios.post(CisApiUrl + Api.Add, qs.stringify(params))
export const AddReturnId = (params?: any) => axios.post(CisApiUrl + Api.AddReturnId, qs.stringify(params)) export const AddReturnId = (params?: any) => axios.post(CisApiUrl + Api.AddReturnId, qs.stringify(params))
export const Update = (params?: any) => axios.post(CisApiUrl + Api.Update, qs.stringify(params)) export const Update = (params?: modelParams) => axios.post(CisApiUrl + Api.Update, qs.stringify(params))
export const Delete = (params?: any) => axios.post(CisApiUrl + Api.Delete, qs.stringify(params)) export const Delete = (params?: any) => axios.post(CisApiUrl + Api.Delete, qs.stringify(params))

58
src/views/page/Model/LabelEditModel.vue

@ -41,6 +41,7 @@ import { Input, Row, Col, InputNumber, Button, notification } from 'ant-design-v
import Draggable from '@/components/Draggable.vue' import Draggable from '@/components/Draggable.vue'
import { onMounted, reactive, ref, UnwrapRef, watch } from 'vue'; import { onMounted, reactive, ref, UnwrapRef, watch } from 'vue';
import * as markLabelApi from '@/axios/cameraMark/markLabelApi'; import * as markLabelApi from '@/axios/cameraMark/markLabelApi';
import Msg from '@/utils/message';
interface FormState { interface FormState {
id: string id: string
name: string; name: string;
@ -90,42 +91,46 @@ onMounted(() => {
} }
}) })
// X
function changeX(e: any) { function changeX(e: any) {
// console.log(e); // console.log(e);
//dom //dom
let d = document.getElementById(props.modelData.id); let dom = document.getElementById(props.modelData.id);
// console.log(d); // console.log(d);
// console.log(d?.style); // console.log(d?.style);
//css //css
d.style.left = e + 'px'; dom.style.left = e + 'px';
// x // x
x.value = e; x.value = e;
// console.log(d?.style.left); // console.log(d?.style.left);
} }
// Y
function changeY(e: any) { function changeY(e: any) {
// console.log(e); // console.log(e);
//dom //dom
let d = document.getElementById(props.modelData.id); let dom = document.getElementById(props.modelData.id);
// console.log(d); // console.log(d);
// console.log(d?.style); // console.log(d?.style);
//css //css
d.style.top = e + 'px'; dom.style.top = e + 'px';
// y // y
y.value = e; y.value = e;
// console.log(d?.style.left); // console.log(d?.style.left);
} }
// name
function changeName(e: any) { function changeName(e: any) {
// console.log(e); // console.log(e);
//dom //dom
let d = document.getElementById(props.modelData.id); let dom = document.getElementById(props.modelData.id);
// console.log(d); // console.log(d);
let dom = d?.querySelector(".label-content") let domHTML = dom?.querySelector(".label-content")
// console.log(dom); // console.log(dom);
//html //html
dom.innerHTML = e.target.value; domHTML.innerHTML = e.target.value;
name.value = e.target.value name.value = e.target.value
} }
@ -139,24 +144,47 @@ function cancel() {
// //
notification.close("editLabel"); notification.close("editLabel");
//dom //dom
let d = document.getElementById(props.modelData.id); let dom = document.getElementById(props.modelData.id);
//dom HTML //dom HTML
let dom = d?.querySelector(".label-content") let domHTML = dom?.querySelector(".label-content")
// //
dom.innerHTML = props.modelData.name domHTML.innerHTML = props.modelData.name
x.value = document.body.offsetWidth * canvasLeft.value x.value = document.body.offsetWidth * canvasLeft.value
y.value = document.body.offsetHeight * canvasTop.value y.value = document.body.offsetHeight * canvasTop.value
d.style.left = x.value + 'px'; dom.style.left = x.value + 'px';
d.style.top = y.value + 'px'; dom.style.top = y.value + 'px';
} }
// //
function confirm() { function confirm() {
markLabelApi.Update().then(res => { markLabelApi.Update({
CbCameraId: props.modelData.cbCameraId,
Name: name.value,
VideoWidth: props.modelData.videoWidth,
VideoHeight: props.modelData.videoHeight,
CanvasLeftRatio: x.value / document.body.offsetWidth,
CanvasTopRatio: y.value / document.body.offsetHeight,
CmMarkGroupId: props.modelData.cmMarkGroupId,// Id
PanPosition: props.modelData.panPosition, //Pan
TiltPosition: props.modelData.tiltPosition, //Tilt
ZoomPosition: props.modelData.zoomPosition, //Zoom
IsDelete: props.modelData.isDelete, //
Id: props.modelData.id,
CreateTime: props.modelData.createTime
}).then(res => {
console.log("res", res);
if (res.data.data == true) {
Msg.success("修改成功")
//
notification.close("editLabel");
}
else{
Msg.error("修改失败",res.data.message)
}
}) })
} }

Loading…
Cancel
Save