|
@@ -3,7 +3,7 @@
|
|
|
<div class="flex1" style="overflow: auto;">
|
|
<div class="flex1" style="overflow: auto;">
|
|
|
<TelViewTem @selectArea="selectArea" :enableDraw="enableDraw" bgColor="#f7f7f7" :bgSrc="form.img">
|
|
<TelViewTem @selectArea="selectArea" :enableDraw="enableDraw" bgColor="#f7f7f7" :bgSrc="form.img">
|
|
|
<template v-for="(item, index) in form?.events" :key="index">
|
|
<template v-for="(item, index) in form?.events" :key="index">
|
|
|
- <DragResizeRotate v-model="form.events[index]" @delete="deleteItemEvents($event, index)" @activated="activated" @deactivated="deactivated"></DragResizeRotate>
|
|
|
|
|
|
|
+ <DragResizeRotate v-model="form.events[index]" @delete="deleteItemEvents($event, index, item)" @activated="activated($event, index)" @deactivated="deactivated"></DragResizeRotate>
|
|
|
</template>
|
|
</template>
|
|
|
</TelViewTem>
|
|
</TelViewTem>
|
|
|
</div>
|
|
</div>
|
|
@@ -16,42 +16,61 @@
|
|
|
</template>
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { importFileGetUrls } from '@/utils/models';
|
|
import { importFileGetUrls } from '@/utils/models';
|
|
|
-
|
|
|
|
|
|
|
+const emit = defineEmits<{
|
|
|
|
|
+ (e: 'update:modelValue', value: any): void,
|
|
|
|
|
+ (e: 'activated', value: any): void
|
|
|
|
|
+ (e: 'deactivated'): void
|
|
|
|
|
+ (e: 'deleteItemEvents', value: any): void
|
|
|
|
|
+}>();
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
modelValue: any
|
|
modelValue: any
|
|
|
}>();
|
|
}>();
|
|
|
-const form = ref<any>(props.modelValue || { img: '', events: []});
|
|
|
|
|
|
|
+const eventDefault = {
|
|
|
|
|
+ id: '',
|
|
|
|
|
+ eventName: '',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ phone: '',
|
|
|
|
|
+ url: '',
|
|
|
|
|
+ },
|
|
|
|
|
+ x: 0,
|
|
|
|
|
+ y: 0,
|
|
|
|
|
+ w: 100,
|
|
|
|
|
+ h: 100,
|
|
|
|
|
+};
|
|
|
|
|
+const form = ref<any>(props.modelValue || { img: '', events: [] });
|
|
|
const enableDraw = ref(true);
|
|
const enableDraw = ref(true);
|
|
|
-const addInfo = () => {
|
|
|
|
|
- form.value.events.push({ id: new Date().getTime() + '_btn_drap' });
|
|
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
const selectArea = (area: any) => {
|
|
const selectArea = (area: any) => {
|
|
|
if (area.rect.w < 20 || area.rect.h < 20) {
|
|
if (area.rect.w < 20 || area.rect.h < 20) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- form.value.events.push({ id: new Date().getTime() + '_btn_drap', ...area.rect });
|
|
|
|
|
|
|
+ form.value.events.push({ ...eventDefault, id: new Date().getTime() + '_btn_drap', ...area.rect });
|
|
|
}
|
|
}
|
|
|
-const activated = () => {
|
|
|
|
|
|
|
+const activated = (event, index) => {
|
|
|
enableDraw.value = false;
|
|
enableDraw.value = false;
|
|
|
|
|
+ emit('activated', form.value.events[index] || { id: '' });
|
|
|
}
|
|
}
|
|
|
const deactivated = () => {
|
|
const deactivated = () => {
|
|
|
enableDraw.value = true;
|
|
enableDraw.value = true;
|
|
|
|
|
+ emit('deactivated');
|
|
|
}
|
|
}
|
|
|
-const deleteItemEvents = (item: any, index: number) => {
|
|
|
|
|
|
|
+const deleteItemEvents = (event: any, index: number, item: any) => {
|
|
|
form.value.events.splice(index, 1);
|
|
form.value.events.splice(index, 1);
|
|
|
|
|
+ emit('deleteItemEvents', item);
|
|
|
|
|
+ emit('update:modelValue', form.value);
|
|
|
}
|
|
}
|
|
|
const clickInfo = () => {
|
|
const clickInfo = () => {
|
|
|
console.log(form.value);
|
|
console.log(form.value);
|
|
|
}
|
|
}
|
|
|
const addImgBg = async () => {
|
|
const addImgBg = async () => {
|
|
|
- const res: any[] = await importFileGetUrls(['png', 'jpg', 'jpeg'], false);
|
|
|
|
|
- if (res.length) {
|
|
|
|
|
- res.forEach(element => {
|
|
|
|
|
- if (element.data?.url) {
|
|
|
|
|
- form.value.img = element.data.url;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const res: any[] = await importFileGetUrls(['png', 'jpg', 'jpeg'], false);
|
|
|
|
|
+ if (res.length) {
|
|
|
|
|
+ res.forEach(element => {
|
|
|
|
|
+ if (element.data?.url) {
|
|
|
|
|
+ form.value.img = element.data.url;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
<style scoped lang="scss"></style>
|
|
<style scoped lang="scss"></style>
|