meeting-tpl-h5.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <template v-if="form.img">
  3. <div class="flex1" style="overflow: auto;">
  4. <TelViewTem @selectArea="selectArea" :enableDraw="enableDraw" bgColor="#f7f7f7" :bgSrc="form.img">
  5. <DragResizeRotate v-if="form.bgm" v-model="form.bgmRact" @deactivated="deactivated"></DragResizeRotate>
  6. <template v-for="(item, index) in form?.events" :key="index">
  7. <DragResizeRotate v-model="form.events[index]" @delete="deleteItemEvents($event, index, item)" @activated="activated($event, index)" @deactivated="deactivated"></DragResizeRotate>
  8. </template>
  9. </TelViewTem>
  10. </div>
  11. </template>
  12. <template v-else>
  13. <div @click="addImgBg" class="bg-#f7f7f7 flex1 w-750 mb-10 c-s-p d-flex a-c j-c">
  14. <div class="c-666 f-s-18 u-s-n">点击此处上传图片</div>
  15. </div>
  16. </template>
  17. </template>
  18. <script setup lang="ts">
  19. import { importFileGetUrls } from '@/utils/models';
  20. const emit = defineEmits<{
  21. (e: 'update:modelValue', value: any): void,
  22. (e: 'activated', value: any): void
  23. (e: 'deactivated'): void
  24. (e: 'deleteItemEvents', value: any): void
  25. }>();
  26. const props = defineProps<{
  27. modelValue: any
  28. }>();
  29. const eventDefault = {
  30. id: '',
  31. eventName: '',
  32. params: {
  33. phone: '',
  34. url: '',
  35. },
  36. x: 0,
  37. y: 0,
  38. w: 100,
  39. h: 100,
  40. };
  41. const form = ref<any>(props.modelValue || { img: '', events: [] });
  42. const enableDraw = ref(true);
  43. const selectArea = (area: any) => {
  44. if (area.rect.w < 20 || area.rect.h < 20) {
  45. return;
  46. }
  47. form.value.events.push({ ...eventDefault, id: new Date().getTime() + '_btn_drap', ...area.rect });
  48. }
  49. const activated = (event, index) => {
  50. enableDraw.value = false;
  51. emit('activated', form.value.events[index] || { id: '' });
  52. }
  53. const deactivated = () => {
  54. enableDraw.value = true;
  55. emit('deactivated');
  56. }
  57. const deleteItemEvents = (event: any, index: number, item: any) => {
  58. form.value.events.splice(index, 1);
  59. emit('deleteItemEvents', item);
  60. emit('update:modelValue', form.value);
  61. }
  62. const clickInfo = () => {
  63. console.log(form.value);
  64. }
  65. const addImgBg = async () => {
  66. const res: any[] = await importFileGetUrls(['png', 'jpg', 'jpeg'], false);
  67. if (res.length) {
  68. res.forEach(element => {
  69. if (element.data?.url) {
  70. form.value.img = element.data.url;
  71. }
  72. });
  73. }
  74. }
  75. watch(() => props.modelValue, (val) => {
  76. form.value = val || { img: '', events: [] };
  77. }, { deep: true });
  78. </script>
  79. <style scoped lang="scss"></style>