222
schangxiang@126.com
2025-04-30 9bec4dcae002f36aa23231da11cb03a156b40110
PipeLineLems/web/src/components/Variable/Variable.tsx
@@ -4,7 +4,11 @@
import Icon from '../Icon/Icon'
import { Base } from '@/libs/Base/Base'
import { useVModels } from '@vueuse/core'
import get from 'lodash/get'
import { set } from 'lodash'
import { text } from 'stream/consumers'
const { openVariableDialog } = sdk.utils
import { _t, getScopeT, Language } from '@/libs/Language/Language'
interface CurrentVariableType {
  id?: string
@@ -47,6 +51,10 @@
      type: String,
      default: '',
    },
    LanguageScopeKey: {
      type: String,
      default: '',
    },
  },
  emits: ['update:modelValue', 'update:dataSource', 'change'],
  setup(props, { attrs, slots, emit }) {
@@ -69,14 +77,14 @@
    const onMultipleSelectVariable = (varData: any[]) => {
      if (props.field) {
        const index = props.index
        varData.forEach((variable, i: number) => {
          const row: any = dataSource.value[index + i]
          if (row) {
            if (
              typeof row[props.field] !== 'object' ||
              row[props.field] === null
            ) {
              row[props.field] = variable.name
            const v = get(row, props.field)
            if (typeof v !== 'object' || v === null) {
              set(row, props.field, variable.name)
            }
          }
        })
@@ -85,10 +93,10 @@
    const onSelectVariable = async () => {
      const currentVariable: CurrentVariableType = {}
      if (variable.value) {
        currentVariable.id = Base.getVariableIdByName(variable.value)
        currentVariable.name = variable.value
      }
      // if (variable.value) {
      //   currentVariable.id = Base.getVariableIdByName(variable.value)
      //   currentVariable.name = variable.value
      // }
      try {
        const varData = await openVariableDialog({
          currentVariable,
@@ -98,8 +106,8 @@
          configData: {},
        })
        if (!props.isMultiple) {
          variable.value = varData.name
          emit('change', varData.name)
          variable.value = varData?.name
          emit('change', varData?.name)
        } else {
          onMultipleSelectVariable(varData)
        }
@@ -120,7 +128,7 @@
            clearable={props.clearable || props.isClose}
            readonly={props.isClose || props.clearable}
            class={styles.selectVariable}
            placeholder="请输入"
            placeholder={_t('请选择')}
            suffix-icon={
              <el-button
                link
@@ -129,7 +137,7 @@
                style="margin-right: 10px;"
                onClick={onSelectVariable}
              >
                选择
                {_t('选择')}
              </el-button>
            }
          ></el-input>
@@ -173,7 +181,7 @@
            </div>
          ) : (
            <span onClick={onSelectVariable} class={styles.select}>
              请选择
              {_t('请选择')}
            </span>
          )}
        </div>