wujingjing
2025-02-26 08c6ecf506bfc7003894775fe57d98d9b11f3d9e
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
<template>
    <div class="flex flex-col gap-2">
        <span class="text-gray-600 font-normal">{{ `${order} ${item?.data?.title}` }}</span>
        <div  class="flex-items-center gap-5">
            <!-- <span
                @click="select(subItem)"
                v-for="(subItem, index) in item?.data?.options"
                :key="index"
                class="flex w-fit items-center cursor-pointer border-solid border px-3 border-gray-300 hover:text-blue-400 rounded-lg"
                :class="{ 'cursor-not-allowed': disabled, 'bg-blue-400': subItem === activeOption, 'text-white': subItem === activeOption }"
                >{{ subItem }}</span
            > -->
            <el-select v-if="isSelect" v-model="activeOption" placeholder="请选择" @change="selectChange">
                <el-option v-for="item in item?.data?.options" :key="item" :label="item" :value="item"></el-option>
            </el-select>
            <div v-else class="flex items-center gap-3">
                <el-input   v-model="inputValue" />
                <el-button type="primary" @click="submitInput">提交</el-button>
            </div>
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { computed, ref } from 'vue';
import { question_stream_reply } from '/@/api/ai/chat';
import { debounce } from '/@/utils/util';
const props = defineProps(['order', 'item', 'disabled']);
// :class="[...(subItem === activeOption ? ['bg-blue-400', 'text-white'] : []), disabled ? 'cursor-not-allowed' : '']"
// 'bg-blue-400': subItem === activeOption, 'text-white': subItem === activeOption.value
const isSelect = computed(() => props.item?.data?.options?.length > 0);
const inputValue = ref('');
const activeOption = ref();
const selectChange = async (option) => {
    if (props.disabled) return;
    const res = await question_stream_reply({
        select: option,
        reply_id: props.item?.data?.reply_id,
    });
    if (res.json_ok) {
        activeOption.value = option;
    }
};
const submitInput = () => {
    selectChange(inputValue.value);
};
</script>
<style scoped lang="scss"></style>