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