<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>
|