| | |
| | | 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 |
| | |
| | | type: String, |
| | | default: '', |
| | | }, |
| | | LanguageScopeKey: { |
| | | type: String, |
| | | default: '', |
| | | }, |
| | | }, |
| | | emits: ['update:modelValue', 'update:dataSource', 'change'], |
| | | setup(props, { attrs, slots, emit }) { |
| | |
| | | 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) |
| | | } |
| | | } |
| | | }) |
| | |
| | | |
| | | 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, |
| | |
| | | configData: {}, |
| | | }) |
| | | if (!props.isMultiple) { |
| | | variable.value = varData.name |
| | | emit('change', varData.name) |
| | | variable.value = varData?.name |
| | | emit('change', varData?.name) |
| | | } else { |
| | | onMultipleSelectVariable(varData) |
| | | } |
| | |
| | | clearable={props.clearable || props.isClose} |
| | | readonly={props.isClose || props.clearable} |
| | | class={styles.selectVariable} |
| | | placeholder="请输入" |
| | | placeholder={_t('请选择')} |
| | | suffix-icon={ |
| | | <el-button |
| | | link |
| | |
| | | style="margin-right: 10px;" |
| | | onClick={onSelectVariable} |
| | | > |
| | | 选择 |
| | | {_t('选择')} |
| | | </el-button> |
| | | } |
| | | ></el-input> |
| | |
| | | </div> |
| | | ) : ( |
| | | <span onClick={onSelectVariable} class={styles.select}> |
| | | 请选择 |
| | | {_t('请选择')} |
| | | </span> |
| | | )} |
| | | </div> |