meeting-tpl-h5.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. <template v-for="(item, index) in form?.events" :key="index">
  6. <DragResizeRotate v-model="form.events[index]" @activated="activated" @deactivated="deactivated"></DragResizeRotate>
  7. </template>
  8. </TelViewTem>
  9. </div>
  10. </template>
  11. <template v-else>
  12. <div @click="addImgBg" class="bg-#f7f7f7 flex1 w-750 mb-10 c-s-p d-flex a-c j-c">
  13. <div class="c-666 f-s-18 u-s-n">点击此处上传图片</div>
  14. </div>
  15. </template>
  16. </template>
  17. <script setup lang="ts">
  18. import { importFileGetUrls } from '@/utils/models';
  19. const props = defineProps<{
  20. modelValue: any
  21. }>();
  22. const form = ref<any>(props.modelValue || { img: '', events: []});
  23. const enableDraw = ref(true);
  24. const addInfo = () => {
  25. form.value.events.push({ id: new Date().getTime() + '_btn_drap' });
  26. }
  27. const selectArea = (area: any) => {
  28. if (area.rect.w < 20 || area.rect.h < 20) {
  29. return;
  30. }
  31. form.value.events.push({ id: new Date().getTime() + '_btn_drap', ...area.rect });
  32. }
  33. const activated = () => {
  34. enableDraw.value = false;
  35. }
  36. const deactivated = () => {
  37. enableDraw.value = true;
  38. }
  39. const clickInfo = () => {
  40. console.log(form.value);
  41. }
  42. const addImgBg = async () => {
  43. const res: any[] = await importFileGetUrls(['png', 'jpg', 'jpeg'], false);
  44. if (res.length) {
  45. res.forEach(element => {
  46. if (element.data?.url) {
  47. form.value.img = element.data.url;
  48. }
  49. });
  50. }
  51. }
  52. </script>
  53. <style scoped lang="scss"></style>