wujingjing
2025-01-07 e6c7c42894cadcfbab107a253ad88171b928207e
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
<template>
    <div class="flex-items-center">
        <span class="flex-0 mr-2" v-if="data?.title">{{ data?.title }}</span>
        <el-input v-if="!isSelect" :disabled="disabled" v-model="modelValue" @input="stringInputInput" clearable></el-input>
        <el-select  v-else :disabled="disabled" v-model="modelValue" @change="stringInputInput" filterable multiple clearable collapse-tags collapse-tags-tooltip>
            <el-option v-for="item in data?.origin?.value_list" :key="item" :value="item" :label="item"></el-option>
        </el-select>
    </div>
</template>
 
<script setup lang="ts">
import { computed } from 'vue';
defineOptions({
    inheritAttrs: true,
});
 
const emit = defineEmits(['change']);
const props = defineProps(['data', 'disabled']);
const isSelect = computed(() => {
    return props.data?.origin?.value_list?.length > 0;
});
const modelValue = defineModel({
    type: Array,
    default: () => [],
});
const stringInputInput = (val) => {
    let finalValue;
    if (!val) {
        finalValue = '';
    } else {
        finalValue = val.join(',');
    }
    emit('change', finalValue);
};
</script>
<style scoped lang="scss"></style>