|
1 | 1 | <template> |
2 | 2 | <!-- 问题内容 --> |
3 | | - <div class="question-content item-content mb-16 lighter"> |
4 | | - <div class="content p-12-16 border-r-8" :class="getClassName"> |
| 3 | + <div class="question-content item-content mb-4 lighter"> |
| 4 | + <div v-if="!isReQuestion" class="content p-12-16 border-r-8" :class="getClassName"> |
5 | 5 | <div class="text break-all pre-wrap"> |
6 | 6 | <div class="mb-8" v-if="document_list.length"> |
7 | 7 | <el-space wrap class="w-full media-file-width"> |
8 | 8 | <template v-for="(item, index) in document_list" :key="index"> |
9 | 9 | <el-card shadow="never" style="--el-card-padding: 8px" class="download-file cursor"> |
10 | 10 | <div class="download-button flex align-center" @click="downloadFile(item)"> |
11 | 11 | <el-icon class="mr-4"> |
12 | | - <Download/> |
| 12 | + <Download /> |
13 | 13 | </el-icon> |
14 | 14 | {{ $t('chat.download') }} |
15 | 15 | </div> |
16 | 16 | <div class="show flex align-center"> |
17 | | - <img :src="getImgUrl(item && item?.name)" alt="" width="24"/> |
| 17 | + <img :src="getImgUrl(item && item?.name)" alt="" width="24" /> |
18 | 18 | <div class="ml-4 ellipsis-1" :title="item && item?.name"> |
19 | 19 | {{ item && item?.name }} |
20 | 20 | </div> |
|
78 | 78 | <el-card shadow="never" style="--el-card-padding: 8px" class="download-file cursor"> |
79 | 79 | <div class="download-button flex align-center" @click="downloadFile(item)"> |
80 | 80 | <el-icon class="mr-4"> |
81 | | - <Download/> |
| 81 | + <Download /> |
82 | 82 | </el-icon> |
83 | 83 | {{ $t('chat.download') }} |
84 | 84 | </div> |
85 | 85 | <div class="show flex align-center"> |
86 | | - <img :src="getImgUrl(item && item?.name)" alt="" width="24"/> |
| 86 | + <img :src="getImgUrl(item && item?.name)" alt="" width="24" /> |
87 | 87 | <div class="ml-4 ellipsis-1" :title="item && item?.name"> |
88 | 88 | {{ item && item?.name }} |
89 | 89 | </div> |
|
95 | 95 | <span> {{ chatRecord.problem_text }}</span> |
96 | 96 | </div> |
97 | 97 | </div> |
| 98 | + <el-input v-else v-model="editText"> |
| 99 | + <template #append> |
| 100 | + <div class="flex" style="gap: 8px"> |
| 101 | + <el-button-group class="flex ml-8 mr-8"> |
| 102 | + <el-button class="flex mr-8" text @click="cancelReQuestion" |
| 103 | + ><el-icon><Close /></el-icon |
| 104 | + ></el-button> |
| 105 | + <el-button :disabled="!editText.trim()" text @click="sendReQuestionMessage(chatRecord)"> |
| 106 | + <el-icon><Comment /></el-icon> |
| 107 | + </el-button> |
| 108 | + </el-button-group> |
| 109 | + </div> |
| 110 | + </template> |
| 111 | + </el-input> |
98 | 112 | <div class="avatar ml-8" v-if="showAvatar"> |
99 | 113 | <el-image |
100 | 114 | v-if="application.user_avatar" |
|
104 | 118 | style="width: 28px; height: 28px; display: block" |
105 | 119 | /> |
106 | 120 | <el-avatar v-else :size="28"> |
107 | | - <img src="@/assets/user-icon.svg" style="width: 50%" alt=""/> |
| 121 | + <img src="@/assets/user-icon.svg" style="width: 50%" alt="" /> |
108 | 122 | </el-avatar> |
109 | 123 | </div> |
110 | 124 | </div> |
| 125 | + <div |
| 126 | + class="text-right mb-8" |
| 127 | + :style="{ |
| 128 | + 'padding-right': showAvatar ? '36px' : '0', |
| 129 | + }" |
| 130 | + v-if="!isReQuestion" |
| 131 | + > |
| 132 | + <div class="text-right"> |
| 133 | + <el-tooltip effect="dark" :content="$t('common.edit')" placement="top" v-if="props.isLast"> |
| 134 | + <el-button text @click="handleEdit(chatRecord)"> |
| 135 | + <AppIcon iconName="app-edit"></AppIcon> |
| 136 | + </el-button> |
| 137 | + </el-tooltip> |
| 138 | + <el-tooltip effect="dark" :content="$t('common.copy')" placement="top"> |
| 139 | + <el-button text @click="copyClick(chatRecord?.problem_text)"> |
| 140 | + <AppIcon iconName="app-copy"></AppIcon> |
| 141 | + </el-button> |
| 142 | + </el-tooltip> |
| 143 | + </div> |
| 144 | + </div> |
111 | 145 | </template> |
112 | 146 | <script setup lang="ts"> |
113 | | -import {type chatType} from '@/api/type/application' |
114 | | -import {getImgUrl, downloadByURL} from '@/utils/common' |
115 | | -import {getAttrsArray} from '@/utils/array' |
116 | | -import {onMounted, computed} from 'vue' |
| 147 | +import { type chatType } from '@/api/type/application' |
| 148 | +import { getImgUrl, downloadByURL } from '@/utils/common' |
| 149 | +import { getAttrsArray } from '@/utils/array' |
| 150 | +import { onMounted, computed, ref } from 'vue' |
| 151 | +import { copyClick } from '@/utils/clipboard' |
117 | 152 |
|
118 | 153 | const props = defineProps<{ |
119 | 154 | application: any |
120 | 155 | chatRecord: chatType |
| 156 | + chatManagement: any |
| 157 | + sendMessage: (question: string, other_params_data?: any, chat?: chatType) => Promise<boolean> |
121 | 158 | type: 'log' | 'ai-chat' | 'debug-ai-chat' |
| 159 | + isLast: boolean |
122 | 160 | }>() |
123 | 161 |
|
| 162 | +const isReQuestion = ref<boolean>(false) |
| 163 | +const editText = ref<string>('') |
| 164 | +const direction = ref<'horizontal' | 'vertical'>('horizontal') |
| 165 | +
|
124 | 166 | const showAvatar = computed(() => { |
125 | 167 | return props.application.show_user_avatar == undefined ? true : props.application.show_user_avatar |
126 | 168 | }) |
@@ -184,8 +226,48 @@ function downloadFile(item: any) { |
184 | 226 | downloadByURL(item.url, item.name) |
185 | 227 | } |
186 | 228 |
|
187 | | -onMounted(() => { |
188 | | -}) |
| 229 | +function handleEdit(chatRecord: any) { |
| 230 | + isReQuestion.value = true |
| 231 | + editText.value = chatRecord.problem_text |
| 232 | +} |
| 233 | +
|
| 234 | +const cancelReQuestion = () => { |
| 235 | + isReQuestion.value = false |
| 236 | +} |
| 237 | +
|
| 238 | +const emit = defineEmits(['reQuestion']) |
| 239 | +
|
| 240 | +function sendReQuestionMessage(chat: chatType) { |
| 241 | + const container = props.chatRecord?.upload_meta |
| 242 | + ? props.chatRecord.upload_meta |
| 243 | + : props.chatRecord.execution_details?.find((detail) => detail.type === 'start-node') |
| 244 | +
|
| 245 | + props.chatRecord.problem_text = editText.value |
| 246 | + reset_answer_text_list(props.chatRecord.answer_text_list) |
| 247 | + props.chatRecord.write_ed = false |
| 248 | +
|
| 249 | + isReQuestion.value = false |
| 250 | + props.sendMessage( |
| 251 | + editText.value, |
| 252 | + { |
| 253 | + re_chat: true, |
| 254 | + image_list: container?.image_list || [], |
| 255 | + document_list: container?.document_list || [], |
| 256 | + audio_list: container?.audio_list || [], |
| 257 | + video_list: container?.video_list || [], |
| 258 | + other_list: container?.other_list || [], |
| 259 | + chat_record_id: props.chatRecord.record_id ? props.chatRecord.record_id : props.chatRecord.id, |
| 260 | + }, |
| 261 | + { ...props.chatRecord, problem_text: editText.value }, |
| 262 | + ) |
| 263 | +} |
| 264 | +
|
| 265 | +const reset_answer_text_list = (answer_text_list: any) => { |
| 266 | + answer_text_list.splice(0, answer_text_list.length) |
| 267 | + answer_text_list.push([]) |
| 268 | +} |
| 269 | +
|
| 270 | +onMounted(() => {}) |
189 | 271 | </script> |
190 | 272 | <style lang="scss" scoped> |
191 | 273 | .question-content { |
|
0 commit comments