hot-edit.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="pc-edit">
  3. <!-- 内容 -->
  4. <div class="content-wrap" v-show="diyStore.editTab == 'content'">
  5. <div class="edit-attr-item-wrap">
  6. <h3 class="mb-[10px]">标题内容</h3>
  7. <el-form label-width="90px" class="px-[10px]">
  8. <el-form-item label="热区背景">
  9. <upload-image v-model="diyStore.editComponent.imageUrl" :limit="1" @change="selectImg" />
  10. </el-form-item>
  11. <el-form-item label="热区设置">
  12. <heat-map v-model="diyStore.editComponent" />
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. </div>
  17. <!-- 样式 -->
  18. <div class="style-wrap" v-show="diyStore.editTab == 'style'">
  19. <!-- 组件样式 -->
  20. <slot name="style"></slot>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup name="Index" lang="ts">
  25. import usePcdiyStore from '@/store/modules/pcdiy';
  26. const diyStore = usePcdiyStore();
  27. console.log(diyStore.editComponent, '5555');
  28. // 组件验证
  29. diyStore.editComponent.verify = (index: number) => {
  30. const res = { code: true, message: '' };
  31. if (diyStore.value[index].imageUrl === '') {
  32. res.code = false;
  33. res.message = '请上传图片';
  34. return res;
  35. }
  36. return res;
  37. };
  38. const selectImg = (url: string) => {
  39. handleHeight();
  40. };
  41. // 处理高度
  42. const handleHeight = () => {
  43. const image = new Image();
  44. image.src = diyStore.editComponent.imageUrl;
  45. image.onload = async () => {
  46. diyStore.editComponent.imgWidth = image.width;
  47. diyStore.editComponent.imgHeight = image.height;
  48. };
  49. };
  50. defineExpose({});
  51. </script>
  52. <style lang="scss" scoped>
  53. .pc-edit {
  54. .edit-attr-item-wrap {
  55. border-top: 2px solid var(--el-color-info-light-8);
  56. padding-top: 20px;
  57. &:first-of-type {
  58. border-top: none;
  59. padding-top: 0;
  60. }
  61. }
  62. .data-bos {
  63. display: flex;
  64. flex-wrap: wrap;
  65. gap: 0 12px;
  66. .data-list {
  67. background-color: #f9fafb;
  68. border: 1px solid #e5e7eb;
  69. &.border-primary {
  70. border-color: var(--el-color-primary);
  71. }
  72. img {
  73. width: 100%;
  74. }
  75. }
  76. }
  77. :deep(.el-form-item__label) {
  78. font-weight: 400;
  79. }
  80. }
  81. </style>