index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="go-shape-box">
  3. <slot></slot>
  4. <!-- 选中 -->
  5. <div class="shape-modal" :style="useSizeStyle(item.attr)">
  6. <div class="shape-modal-select" :class="{ active: select }" />
  7. <div class="shape-modal-change" :class="{ active: select || hover }" />
  8. </div>
  9. </div>
  10. </template>
  11. <script setup lang="ts">
  12. import { ref, computed, PropType, h } from 'vue';
  13. import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
  14. import { useDesignStore } from '@/store/modules/designStore/designStore'
  15. import { CreateComponentType } from '@/packages/index.d'
  16. import { useSizeStyle } from '../../hooks/useStyle.hook'
  17. const props = defineProps({
  18. item: {
  19. type: Object as PropType<CreateComponentType>,
  20. required: true
  21. }
  22. })
  23. // 全局颜色
  24. const designStore = useDesignStore()
  25. const themeColor = ref(designStore.getAppTheme)
  26. const chartEditStore = useChartEditStoreStore()
  27. // 计算当前选中目标
  28. const hover = computed(() => {
  29. return props.item.id === chartEditStore.getTargetChart.hoverId
  30. })
  31. const select = computed(() => {
  32. return props.item.id === chartEditStore.getTargetChart.selectId
  33. })
  34. </script>
  35. <style lang="scss" scoped>
  36. @include go(shape-box) {
  37. position: absolute;
  38. cursor: move;
  39. .shape-modal {
  40. position: absolute;
  41. top: 0;
  42. left: 0;
  43. .shape-modal-select,
  44. .shape-modal-change {
  45. position: absolute;
  46. width: 100%;
  47. height: 100%;
  48. border-radius: 10px;
  49. @extend .go-transition-quick;
  50. }
  51. .shape-modal-select {
  52. opacity: 0.1;
  53. top: 2px;
  54. left: 2px;
  55. &.active {
  56. background-color: v-bind('themeColor');
  57. }
  58. }
  59. .shape-modal-change {
  60. border: 2px solid rgba(0, 0, 0, 0);
  61. &.active {
  62. border: 2px solid v-bind('themeColor');
  63. }
  64. }
  65. }
  66. }
  67. </style>