2
schangxiang@126.com
2025-05-12 6177ed5cb88df34f2a67d9d0610e3e0dc7030e70
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<template>
  <div class="variable">
    <div class="variable--title" :style="{ width: width }" v-show="title">
      {{ title }}
    </div>
    <el-input :model-value="modelValue" v-bind="combineAttrs($attrs, $props)">
      <template #append>
        <div class="variable__icon" @click="handleButtonClick">
          <img
            src="@/assets/images/variable.png"
            style="width: 25px; height: 15px"
            alt=""
          />
        </div>
      </template>
    </el-input>
  </div>
</template>
 
<script lang="ts">
import { defineComponent } from 'vue'
import { omit } from 'lodash'
import sdk from 'sdk'
const { utils } = sdk
const { openVariableDialog } = utils
 
export default defineComponent({
  name: 'VariableInput',
  props: {
    title: {
      type: String,
      default: '',
    },
    UUID: {
      type: String,
      default: '',
    },
    modelValue: {
      type: String,
      default: '',
    },
    config: {
      type: Object,
      default: () => ({}),
    },
    width: {
      type: String,
      default: '80px',
    },
  },
  setup(props) {
    // const { variableList } = createInjector()
 
    const handleButtonClick = async () => {
      // 处理按钮点击事件
      const data = await openVariableDialog({
        isMultiple: false,
      })
      const params = {
        ...data,
        value: data.name,
      }
    }
 
    const combineAttrs = (
      attrs: Record<string, unknown>,
      props: Record<string, unknown>,
      omitPropNames: Array<string> = []
    ) => {
      const newObject = { ...attrs, ...props }
      return omit(newObject, omitPropNames)
    }
 
    return {
      combineAttrs,
      handleButtonClick,
    }
  },
})
</script>
<style lang="scss" scoped>
.variable {
  display: inline-flex;
  align-items: center;
 
  &--title {
    font-size: 14px;
    font-weight: bold;
    width: 80px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
 
  &__icon {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    margin-right: 8px;
  }
 
  :deep .cs-input__inner {
    height: 30px;
  }
 
  :deep(.cs-input__wrapper) {
    border: 1px solid var(--el-border-color);
    border-right: none;
    box-shadow: none;
  }
 
  :deep(.cs-input-group__append) {
    box-shadow: none;
    border: 1px solid var(--el-border-color);
    border-left: none;
    background-color: #fff;
  }
}
</style>