wujingjing
2025-01-15 575429031e6d2b90394e047b4ff38b541935c1b5
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
<template>
    <div class="flex flex-col gap-1">
        <span class="text-gray-600 font-normal">{{ `${order} ${item?.data?.title}` }}</span>
        <div v-if="item?.data?.options?.length > 0" 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
            >
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { ref, watch } from 'vue';
import { question_stream_reply } from '/@/api/ai/chat';
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 activeOption = ref();
const select = 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;
    }
};
 
 
</script>
<style scoped lang="scss"></style>