vars-select.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="vars-select">
  3. <varsPopover
  4. :node="node"
  5. @setVars="(val) => ((state.vars = val), $emit('setVars', val))"
  6. >
  7. <div
  8. class="vars-display __hover"
  9. @mouseenter="state.hovering = true"
  10. @mouseleave="state.hovering = false"
  11. >
  12. <varsValue :vars="state.vars" />
  13. <div class="del" v-if="state.hovering && state.vars && clearable">
  14. <SvgIcon
  15. name="czr_close_1"
  16. size="10"
  17. color="rgba(0, 0, 0, 0.5)"
  18. class="__hover"
  19. @click.stop="((state.vars = null), $emit('setVars', null))"
  20. />
  21. </div>
  22. </div>
  23. </varsPopover>
  24. </div>
  25. </template>
  26. <script setup lang="ts">
  27. import { computed, getCurrentInstance, reactive, ref, watch } from 'vue'
  28. import varsValue from './vars-value.vue'
  29. import varsPopover from './vars-popover.vue'
  30. const emit = defineEmits(['setVars'])
  31. const props = defineProps({
  32. node: {},
  33. vars: { default: null },
  34. clearable: { default: true },
  35. })
  36. const { proxy }: any = getCurrentInstance()
  37. const state: any = reactive({
  38. vars: props.vars,
  39. hovering: false,
  40. })
  41. </script>
  42. <style lang="scss" scoped>
  43. @use '@/views/workflow/instance/component/style';
  44. .vars-display {
  45. border: style.$borderStyle;
  46. width: 100%;
  47. padding: 4px 4px;
  48. border-radius: 4px;
  49. font-size: 12px;
  50. display: flex;
  51. align-items: center;
  52. position: relative;
  53. background-color: style.$inputBg;
  54. .del {
  55. position: absolute;
  56. right: 0;
  57. width: 30px;
  58. display: flex;
  59. align-items: center;
  60. justify-content: center;
  61. }
  62. }
  63. </style>