|
@@ -1,47 +1,21 @@
|
|
|
<template>
|
|
|
<div class="vars-select">
|
|
|
- <el-popover
|
|
|
- placement="bottom"
|
|
|
- trigger="click"
|
|
|
- :width="400"
|
|
|
- :popper-style="{
|
|
|
- padding: 0
|
|
|
- }"
|
|
|
- >
|
|
|
- <template #reference>
|
|
|
- <div class="vars-display __hover">
|
|
|
- <varsValue :vars="state.vars"/>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="vars-select-block">
|
|
|
- <div class="filter">
|
|
|
- <el-input v-model="state.text" :prefix-icon="Search" placeholder="搜索变量" clearable/>
|
|
|
- </div>
|
|
|
- <div class="list">
|
|
|
- <template v-for="item in optionsCpt">
|
|
|
- <div class="list-group">
|
|
|
- <div class="px-2 text-sm mb-1 text-gray-400">{{item.label}}</div>
|
|
|
- <template v-for="son in item.options">
|
|
|
- <div class="__hover-bg px-2 py-1" @click="state.vars = son">
|
|
|
- <varsItem :item="son"/>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <varsPopover :node="node" @setVars="val => state.vars = val">
|
|
|
+ <div class="vars-display __hover" @mouseenter="state.hovering = true" @mouseleave="state.hovering = false">
|
|
|
+ <varsValue :vars="state.vars"/>
|
|
|
+ <div class="del" v-if="state.hovering && state.vars">
|
|
|
+ <SvgIcon name="czr_close_1" size="10" color="rgba(0, 0, 0, 0.5)" class="__hover" @click.stop="state.vars = null"/>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </el-popover>
|
|
|
+ </varsPopover>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import {computed, getCurrentInstance, reactive, ref, watch} from "vue";
|
|
|
-import {useWorkflowStore} from "@/stores";
|
|
|
-import { Search } from '@element-plus/icons-vue'
|
|
|
-import varsItem from './vars-item.vue'
|
|
|
import varsValue from './vars-value.vue'
|
|
|
+import varsPopover from './vars-popover.vue'
|
|
|
|
|
|
-const WorkflowStore = useWorkflowStore()
|
|
|
const emits = defineEmits([])
|
|
|
const props = defineProps({
|
|
|
node: {}
|
|
@@ -49,24 +23,9 @@ const props = defineProps({
|
|
|
const {proxy}: any = getCurrentInstance()
|
|
|
const state: any = reactive({
|
|
|
vars: null,
|
|
|
- options: [],
|
|
|
- text: ''
|
|
|
-})
|
|
|
-watch(() => props.node, (n) => {
|
|
|
- if (n) {
|
|
|
- state.options = WorkflowStore.getInVars(n)
|
|
|
- }
|
|
|
-}, {immediate: true})
|
|
|
-const optionsCpt = computed(() => {
|
|
|
- if (!state.text) {
|
|
|
- return state.options
|
|
|
- }
|
|
|
- return state.options.map(v => {
|
|
|
- const obj = {...v}
|
|
|
- obj.options = obj.options.filter(s => s.label.includes(state.text) || s.key.includes(state.text))
|
|
|
- return obj
|
|
|
- }).filter(v => v.options.length > 0)
|
|
|
+ hovering: false
|
|
|
})
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -75,27 +34,21 @@ const optionsCpt = computed(() => {
|
|
|
.vars-display {
|
|
|
border: $borderStyle;
|
|
|
width: 100%;
|
|
|
- padding: 0 10px;
|
|
|
+ padding: 0 8px;
|
|
|
border-radius: 4px;
|
|
|
font-size: 12px;
|
|
|
- height: 32px;
|
|
|
+ height: 28px;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
-}
|
|
|
-.vars-select-block {
|
|
|
- .filter {
|
|
|
- padding: 10px;
|
|
|
- border-bottom: $borderStyle;
|
|
|
- }
|
|
|
- .list {
|
|
|
- padding: 4px;
|
|
|
+ position: relative;
|
|
|
+ .del {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ width: 30px;
|
|
|
+ background-color: #ffffff;
|
|
|
display: flex;
|
|
|
- flex-direction: column;
|
|
|
- gap: 6px;
|
|
|
- .list-group {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- }
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
}
|
|
|
}
|
|
|
</style>
|