169169 v-else
170170 ref =" quickInputRef"
171171 v-model =" inputValue"
172+ :autosize =" { minRows: 1, maxRows: isMobile ? 4 : 10 }"
173+ type =" textarea"
172174 :placeholder ="
173175 recorderStatus === 'START'
174176 ? `${$t('chat.inputPlaceholder.speaking')}...`
175177 : recorderStatus === 'TRANSCRIBING'
176178 ? `${$t('chat.inputPlaceholder.recorderLoading')}...`
177179 : $t('chat.inputPlaceholder.default')
178180 "
179- :autosize =" { minRows: 1, maxRows: isMobile ? 4 : 10 }"
180- type =" textarea"
181181 :maxlength =" 100000"
182182 @keydown.enter =" sendChatHandle($event)"
183183 @paste =" handlePaste"
184184 @drop =" handleDrop"
185+ class =" chat-operate-textarea"
185186 />
186187
187188 <div class =" operate flex-between" >
188189 <div >
189- <!-- <el-button
190- v-if="isUserInput || isAPIInput"
191- class="user-input-button mb-8"
192- type="primary"
193- text
194- @click="toggleUserInput"
195- >
196- <AppIcon iconName="app-user-input"></AppIcon>
197- </el-button> -->
190+ <slot name =" userInput" />
198191 </div >
199-
200192 <div >
201193 <template v-if =" props .applicationDetails .stt_model_enable " >
202194 <span v-if =" mode === 'mobile'" >
@@ -305,6 +297,7 @@ import { ref, computed, onMounted, nextTick, watch, type Ref } from 'vue'
305297import Recorder from ' recorder-core'
306298import TouchChat from ' ./TouchChat.vue'
307299import applicationApi from ' @/api/application/application'
300+ import UserForm from ' @/components/ai-chat/component/user-form/index.vue'
308301import { MsgAlert } from ' @/utils/message'
309302import { type chatType } from ' @/api/type/application'
310303import { useRoute , useRouter } from ' vue-router'
@@ -329,7 +322,6 @@ const props = withDefaults(
329322 isMobile: boolean
330323 appId? : string
331324 chatId: string
332- showUserInput? : boolean
333325 sendMessage: (question : string , other_params_data ? : any , chat ? : chatType ) => void
334326 openChatId: () => Promise <string >
335327 validate: () => Promise <any >
@@ -362,6 +354,31 @@ const localLoading = computed({
362354 },
363355})
364356
357+ const showUserInput = ref (true )
358+ const form_data = ref <any >({})
359+ const api_form_data = ref <any >({})
360+
361+ const toggleUserInput = () => {
362+ showUserInput .value = ! showUserInput .value
363+ if (showUserInput .value ) {
364+ // 保存当前数据作为初始数据(用于可能的恢复)
365+ initialFormData .value = JSON .parse (JSON .stringify (form_data .value ))
366+ initialApiFormData .value = JSON .parse (JSON .stringify (api_form_data .value ))
367+ }
368+ }
369+
370+ function UserFormConfirm() {
371+ showUserInput .value = false
372+ }
373+
374+ function UserFormCancel() {
375+ // 恢复初始数据
376+ form_data .value = JSON .parse (JSON .stringify (initialFormData .value ))
377+ api_form_data .value = JSON .parse (JSON .stringify (initialApiFormData .value ))
378+ userFormRef .value ?.render (form_data .value )
379+ showUserInput .value = false
380+ }
381+
365382const upload = ref ()
366383
367384const imageExtensions = [' JPG' , ' JPEG' , ' PNG' , ' GIF' , ' BMP' ]
@@ -807,7 +824,7 @@ function autoSendMessage() {
807824 uploadVideoList .value = []
808825 uploadOtherList .value = []
809826 if (quickInputRef .value ) {
810- quickInputRef .value .textareaStyle .height = ' 45px'
827+ quickInputRef .value .textarea . style .height = ' 45px'
811828 }
812829 })
813830 .catch (() => {
@@ -901,10 +918,10 @@ onMounted(() => {
901918 }, 100 )
902919 }
903920 setTimeout (() => {
904- if ( quickInputRef . value && mode === ' embed ' ) {
921+ nextTick (() => {
905922 quickInputRef .value .textarea .style .height = ' 0'
906- }
907- }, 1800 )
923+ })
924+ }, 800 )
908925})
909926 </script >
910927<style lang="scss" scoped>
@@ -914,6 +931,7 @@ onMounted(() => {
914931 width : 100% ;
915932 box-sizing : border-box ;
916933 z-index : 10 ;
934+
917935 :deep (.operate-textarea ) {
918936 box-shadow : 0px 6px 24px 0px rgba (31 , 35 , 41 , 0.08 );
919937 background-color : #ffffff ;
@@ -931,6 +949,8 @@ onMounted(() => {
931949 resize : none ;
932950 padding : 13px 16px ;
933951 box-sizing : border-box ;
952+ min-height : 47px !important ;
953+ height : 0 ;
934954 }
935955
936956 .operate {
@@ -986,4 +1006,12 @@ onMounted(() => {
9861006 }
9871007 }
9881008}
1009+ .popperUserInput {
1010+ position : absolute ;
1011+ z-index : 999 ;
1012+ left : 0 ;
1013+ bottom : 50px ;
1014+ width : calc (100% - 50px );
1015+ max-width : 400px ;
1016+ }
9891017 </style >
0 commit comments