from.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div style="position: relative" class="formbg">
  3. <van-form class="pragraph">
  4. <van-cell-group inset>
  5. <div class="text" v-text="item.title" @click.stop="select" :style="item.title_style"></div>
  6. <slot></slot>
  7. </van-cell-group>
  8. </van-form>
  9. <br />
  10. <div class="com addTop" @click.stop="addTop">
  11. <el-icon><Upload /></el-icon>
  12. </div>
  13. <div class="com addBottom" @click.stop="addBottom">
  14. <el-icon><Download /></el-icon>
  15. </div>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { defineProps, inject, defineEmits } from 'vue';
  20. import 'vant/lib/index.css';
  21. const starEditorFormwork = inject('starEditorFormwork');
  22. const emit = defineEmits(['addComponent']);
  23. const props = defineProps({
  24. item: Object,
  25. index: String,
  26. });
  27. const select = () => {
  28. const newItem = JSON.parse(JSON.stringify(props.item || {}));
  29. newItem.leftEle = true;
  30. newItem.nodetail = true;
  31. starEditorFormwork(newItem, props.index);
  32. };
  33. const addTop = () => {
  34. emit('addComponent', 'top', props.item.type, props.index);
  35. };
  36. const addBottom = () => {
  37. emit('addComponent', 'bottom', props.item.type, props.index);
  38. };
  39. </script>
  40. <style scoped>
  41. .pragraph {
  42. font-weight: 400;
  43. }
  44. .text {
  45. outline: none;
  46. border: 1px solid #fff;
  47. cursor: pointer;
  48. }
  49. .com {
  50. position: absolute;
  51. display: none;
  52. right: 0;
  53. color: #fff;
  54. background: #409eff;
  55. border-radius: 3px;
  56. padding: 3px;
  57. text-align: center;
  58. cursor: pointer;
  59. }
  60. .formbg:hover .com{
  61. display: block;
  62. }
  63. .addTop {
  64. top: 0;
  65. border-bottom-right-radius: 0;
  66. border-bottom-left-radius: 0;
  67. }
  68. .addBottom {
  69. bottom: 0;
  70. border-top-right-radius: 0;
  71. border-top-left-radius: 0;
  72. }
  73. .van_field_item:hover .addTop,
  74. .van_field_item:hover .addBottom {
  75. display: block;
  76. }
  77. </style>