Browse Source

标签编辑1.0

master
DIAMOND 2 years ago
parent
commit
3d6fea45c8
  1. 114
      src/views/page/Model/LabelEditModel.vue
  2. 2
      src/views/page/cameraCenter.vue

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

@ -1,19 +1,19 @@
<template> <template>
<div class="label-edit-model"> <div class="label-edit-model">
<Draggable></Draggable> <Draggable></Draggable>
<div class="model-head"><Button type="primary" danger @click="reset">重新调整</Button></div> <div class="model-head"><Button type="primary" danger @click="reset">重新调整</Button></div>
<Row> <Row>
<Col :span="24" class="label-attribute"> <Col :span="24" class="label-attribute">
<Row> <Row>
<Col :span="4">标签名称 :</Col> <Col :span="4">标签名称 :</Col>
<Col :span="8"><Input size="small" v-model:value="name"></Input></Col> <Col :span="8"><Input size="small" v-model:value="name" @change="changeName"></Input></Col>
</Row> </Row>
</Col> </Col>
<Col :span="24" class="label-attribute"> <Col :span="24" class="label-attribute">
<Row> <Row>
<Col :span="4">标签X轴 :</Col> <Col :span="4">标签X轴 :</Col>
<Col :span="8"> <Col :span="8">
<InputNumber size="small" :min="0" :max="10000" :step="0.001" v-model:value="x"/> <InputNumber size="small" :min="0" :max="10000" :step="1.0" v-model:value="x" @change="changeX" />
</Col> </Col>
</Row> </Row>
</Col> </Col>
@ -21,7 +21,7 @@
<Row> <Row>
<Col :span="4">标签Y轴 :</Col> <Col :span="4">标签Y轴 :</Col>
<Col :span="8"> <Col :span="8">
<InputNumber size="small" :min="0" :max="10000" :step="0.001" v-model:value="y"/> <InputNumber size="small" :min="0" :max="10000" :step="1.0" v-model:value="y" @change="changeY" />
</Col> </Col>
</Row> </Row>
</Col> </Col>
@ -42,21 +42,21 @@ 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';
interface FormState { interface FormState {
id: string id: string
name: string; name: string;
x: string; x: string;
y:string; y: string;
canvasLeftRatio: string; canvasLeftRatio: string;
canvasTopRatio: string; canvasTopRatio: string;
} }
const formState: UnwrapRef<FormState> = reactive({ const formState: UnwrapRef<FormState> = reactive({
// id: '', // id: '',
name: '', name: '',
x: null, x: null,
y:null, y: null,
canvasLeftRatio: null, canvasLeftRatio: null,
canvasTopRatio: null, canvasTopRatio: null,
}); });
@ -66,41 +66,95 @@ const y = ref();
const canvasLeft = ref(); const canvasLeft = ref();
const canvasTop = ref(); const canvasTop = ref();
watch(name, (nv, ov) => { // watch(name, (nv, ov) => {
// console.log("document.body.offsetWidth ",document.body.offsetWidth ); // // console.log("document.body.offsetWidth ",document.body.offsetWidth );
// console.log("document.body.clientHeight",document.body.offsetHeight); // // console.log("document.body.clientHeight",document.body.offsetHeight);
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
}) // })
const props = defineProps({ const props = defineProps({
modelData:Object modelData: Object
}) })
onMounted(()=>{ onMounted(() => {
console.log("收到了",props.modelData); console.log("收到了", props.modelData);
if(props.modelData){ if (props.modelData) {
name.value = props.modelData.name; name.value = props.modelData.name;
canvasLeft.value = props.modelData.canvasLeftRatio canvasLeft.value = props.modelData.canvasLeftRatio
canvasTop.value = props.modelData.canvasTopRatio canvasTop.value = props.modelData.canvasTopRatio
x.value = document.body.offsetWidth * canvasLeft.value
y.value = document.body.offsetHeight * canvasTop.value
} }
}) })
function changeX(e: any) {
// console.log(e);
//dom
let d = document.getElementById(props.modelData.id);
// console.log(d);
// console.log(d?.style);
//css
d.style.left = e + 'px';
// x
x.value = e;
// console.log(d?.style.left);
}
function changeY(e: any) {
// console.log(e);
//dom
let d = document.getElementById(props.modelData.id);
// console.log(d);
// console.log(d?.style);
//css
d.style.top = e + 'px';
// y
y.value = e;
// console.log(d?.style.left);
}
function changeName(e: any) {
// console.log(e);
//dom
let d = document.getElementById(props.modelData.id);
// console.log(d);
let dom = d?.querySelector(".label-content")
// console.log(dom);
//html
dom.innerHTML = e.target.value;
name.value = e.target.value
}
// //
function reset(){ function reset() {
} }
// //
function cancel(){ function cancel() {
//
notification.close("editLabel"); notification.close("editLabel");
//dom
let d = document.getElementById(props.modelData.id);
//dom HTML
let dom = d?.querySelector(".label-content")
//
dom.innerHTML = props.modelData.name
x.value = document.body.offsetWidth * canvasLeft.value
y.value = document.body.offsetHeight * canvasTop.value
d.style.left = x.value + 'px';
d.style.top = y.value + 'px';
} }
// //
function confirm(){ function confirm() {
markLabelApi.Update().then( res =>{ markLabelApi.Update().then(res => {
}) })

2
src/views/page/cameraCenter.vue

@ -9,7 +9,7 @@
</video> --> </video> -->
<div id="videoPlayer" @mousedown="mouseDownVideo"></div> <div id="videoPlayer" @mousedown="mouseDownVideo"></div>
<div v-for="item in labelList" :class="`labels ${item.groupName == '视频标签' ? 'lavels-video' : 'lavels-build'}`" <div v-for="item in labelList" :class="`labels ${item.groupName == '视频标签' ? 'lavels-video' : 'lavels-build'}`"
:key="item.id" :key="item.id" :id="item.id"
:style="`top:${canvasHeight * item.canvasTopRatio}px;left:${canvasWidth * item.canvasLeftRatio}px`"> :style="`top:${canvasHeight * item.canvasTopRatio}px;left:${canvasWidth * item.canvasLeftRatio}px`">
<a-dropdown :trigger="['contextmenu']"> <a-dropdown :trigger="['contextmenu']">
<div class="labels-item" v-if="item.groupName == '视频标签'"> <div class="labels-item" v-if="item.groupName == '视频标签'">

Loading…
Cancel
Save