| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <template>
- <div class="question-input-bottom">
- <!-- 快捷标签 -->
- <transition name="tags-slide">
- <div v-if="showQuickTags && !loading" class="quick-tags-row">
- <el-space wrap :size="12" class="tags-center">
- <el-tag
- v-for="(tag, index) in quickTags"
- :key="index"
- type="info"
- effect="plain"
- size="large"
- class="quick-tag"
- @click="handleTagClick(tag)"
- >
- <el-icon class="tag-icon">
- <component :is="tag.icon" />
- </el-icon>
- <span>{{ tag.text }}</span>
- </el-tag>
- </el-space>
- </div>
- </transition>
-
- <!-- 输入框容器 -->
- <div class="input-row">
- <div class="input-wrapper">
- <div class="input-container">
- <el-button circle class="icon-button">
- <el-icon><Link /></el-icon>
- </el-button>
-
- <el-button circle class="icon-button">
- <el-icon><Paperclip /></el-icon>
- </el-button>
-
- <el-input
- v-model="form.question"
- type="textarea"
- :rows="1"
- :autosize="{ minRows: 1, maxRows: 4 }"
- placeholder="请在此处发送消息 (Enter键可立即发送)"
- :disabled="loading"
- @keydown.enter="handleEnterKey"
- class="message-input"
- />
-
- <el-button circle class="icon-button">
- <el-icon><Microphone /></el-icon>
- </el-button>
-
- <el-button
- type="primary"
- :loading="loading"
- :disabled="!form.question.trim()"
- @click="handleSubmit"
- class="send-button"
- size="large"
- >
- <span v-if="!loading">发送</span>
- <el-icon v-if="!loading"><Position /></el-icon>
- </el-button>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { reactive, ref } from 'vue'
- import { Position, Link, Paperclip, Microphone, Setting, Document, Files } from '@element-plus/icons-vue'
- import { handleChatInputEnterKey } from '@/utils/chatInputKeydown.js'
- const emit = defineEmits(['submit', 'cancel'])
- const props = defineProps({
- loading: {
- type: Boolean,
- default: false
- }
- })
- const form = reactive({
- question: '',
- windowSize: 3,
- nResults: 10
- })
- const showQuickTags = ref(true)
- const quickTags = [
- { text: '工程建设质量的要求', icon: Setting },
- { text: '施工安全生产责任的规定', icon: Document },
- { text: '公路桥梁加固设计规范', icon: Files }
- ]
- const handleTagClick = (tag) => {
- form.question = tag.text
- }
- const handleSubmit = () => {
- if (!form.question.trim()) {
- return
- }
-
- showQuickTags.value = false
-
- emit('submit', {
- question: form.question.trim(),
- windowSize: form.windowSize,
- nResults: form.nResults
- })
- }
- const handleEnterKey = (event) => {
- handleChatInputEnterKey(event, {
- submit: handleSubmit,
- updateValue: (value) => {
- form.question = value
- }
- })
- }
- const handleCancel = () => {
- emit('cancel')
- }
- </script>
- <style scoped>
- .question-input-bottom {
- width: 100%;
- }
- .quick-tags-row {
- margin-bottom: 16px;
- }
- .tags-center {
- display: flex;
- justify-content: center;
- width: 100%;
- }
- .quick-tag {
- cursor: pointer;
- transition: all 0.3s ease;
- padding: 8px 16px;
- border-radius: 16px;
- background: white;
- border: 1px solid #e0e6ed;
- }
- .quick-tag:hover {
- background: #f0f4ff;
- border-color: #5b8def;
- color: #5b8def;
- transform: translateY(-2px);
- box-shadow: 0 4px 8px rgba(91, 141, 239, 0.15);
- }
- .tag-icon {
- margin-right: 6px;
- font-size: 14px;
- }
- .input-row {
- display: flex;
- justify-content: center;
- width: 100%;
- }
- .input-wrapper {
- max-width: 900px;
- width: 100%;
- }
- .input-container {
- display: flex;
- align-items: center;
- gap: 12px;
- background: white;
- border-radius: 24px;
- padding: 8px 12px;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
- }
- .icon-button {
- flex-shrink: 0;
- border: none;
- background: transparent;
- color: #8b92a7;
- transition: all 0.3s ease;
- width: 36px;
- height: 36px;
- }
- .icon-button:hover {
- background: #f0f4ff;
- color: #5b8def;
- }
- .message-input {
- flex: 1;
- min-width: 0;
- }
- :deep(.message-input .el-textarea__inner) {
- border: none;
- box-shadow: none;
- padding: 8px 4px;
- font-size: 14px;
- line-height: 1.5;
- resize: none;
- background: transparent;
- color: #2d3748;
- min-height: 36px;
- }
- :deep(.message-input .el-textarea__inner::placeholder) {
- color: #a0aec0;
- }
- :deep(.message-input .el-textarea__inner:focus) {
- border: none;
- box-shadow: none;
- }
- .send-button {
- background: linear-gradient(135deg, #5b8def 0%, #0063f7 100%);
- border: none;
- border-radius: 20px;
- padding: 10px 24px;
- font-size: 14px;
- font-weight: 500;
- height: 40px;
- display: flex;
- align-items: center;
- gap: 6px;
- transition: all 0.3s ease;
- flex-shrink: 0;
- }
- .send-button:hover:not(:disabled) {
- background: linear-gradient(135deg, #4a7de8 0%, #0056e0 100%);
- transform: translateY(-2px);
- box-shadow: 0 4px 12px rgba(91, 141, 239, 0.4);
- }
- .send-button:disabled {
- background: #e2e8f0;
- color: #a0aec0;
- cursor: not-allowed;
- }
- .send-button .el-icon {
- font-size: 16px;
- }
- /* 动画 */
- .tags-slide-enter-active,
- .tags-slide-leave-active {
- transition: all 0.3s ease;
- }
- .tags-slide-enter-from {
- opacity: 0;
- transform: translateY(10px);
- }
- .tags-slide-leave-to {
- opacity: 0;
- transform: translateY(-10px);
- }
- @media (max-width: 768px) {
- .input-container {
- gap: 8px;
- padding: 6px 8px;
- }
-
- .icon-button {
- width: 32px;
- height: 32px;
- }
-
- .send-button {
- padding: 8px 20px;
- height: 36px;
- }
- }
- </style>
|