fix: add conditional rendering for vote reason content and optimize user input field availability checks

This commit is contained in:
zhangzhanwei 2025-12-26 15:27:49 +08:00 committed by zhanweizhang7
parent f551ae214b
commit 5dcb615360
6 changed files with 98 additions and 85 deletions

View File

@ -68,6 +68,7 @@
</span>
</template>
<VoteReasonContent
v-if="props.data.record_id"
vote-type="0"
:chat-id="props.chatId"
:record-id="props.data.record_id"
@ -104,6 +105,7 @@
</span>
</template>
<VoteReasonContent
v-if="props.data.record_id"
vote-type="1"
:chat-id="props.chatId"
:record-id="props.data.record_id"

View File

@ -1,91 +1,94 @@
<template>
<div class="flex-between mt-8">
<div>
<el-text type="info">
<span class="ml-4">{{ datetimeFormat(data.create_time) }}</span>
</el-text>
</div>
<div>
<!-- 语音播放 -->
<span v-if="tts">
<el-tooltip
effect="dark"
:content="$t('chat.operation.play')"
placement="top"
v-if="!audioPlayerStatus"
>
<el-button text @click="playAnswerText(data?.answer_text)">
<AppIcon iconName="app-video-play"></AppIcon>
</el-button>
</el-tooltip>
<el-tooltip v-else effect="dark" :content="$t('chat.operation.pause')" placement="top">
<el-button type="primary" text @click="pausePlayAnswerText()">
<AppIcon iconName="app-video-pause"></AppIcon>
<div>
<div class="flex-between mt-8">
<div>
<el-text type="info">
<span class="ml-4">{{ datetimeFormat(data.create_time) }}</span>
</el-text>
</div>
<div>
<!-- 语音播放 -->
<span v-if="tts">
<el-tooltip
effect="dark"
:content="$t('chat.operation.play')"
placement="top"
v-if="!audioPlayerStatus"
>
<el-button text @click="playAnswerText(data?.answer_text)">
<AppIcon iconName="app-video-play"></AppIcon>
</el-button>
</el-tooltip>
<el-tooltip v-else effect="dark" :content="$t('chat.operation.pause')" placement="top">
<el-button type="primary" text @click="pausePlayAnswerText()">
<AppIcon iconName="app-video-pause"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
</span>
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
<el-button text @click="copyClick(data?.answer_text)">
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
</span>
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
<el-button text @click="copyClick(data?.answer_text)">
<AppIcon iconName="app-copy"></AppIcon>
<template v-if="permissionPrecise.chat_log_add_knowledge(id)">
<el-tooltip
v-if="buttonData.improve_paragraph_id_list.length === 0"
effect="dark"
:content="$t('views.chatLog.editContent')"
placement="top"
>
<el-button text @click="editContent(data)">
<AppIcon iconName="app-edit"></AppIcon>
</el-button>
</el-tooltip>
<el-tooltip v-else effect="dark" :content="$t('views.chatLog.editMark')" placement="top">
<el-button text @click="editMark(data)">
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
</el-button>
</el-tooltip>
</template>
<el-divider direction="vertical" v-if="buttonData?.vote_status !== '-1'" />
<el-button text disabled v-if="buttonData?.vote_status === '0'">
<AppIcon iconName="app-like-color"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
<template v-if="permissionPrecise.chat_log_add_knowledge(id)">
<el-tooltip
v-if="buttonData.improve_paragraph_id_list.length === 0"
effect="dark"
:content="$t('views.chatLog.editContent')"
placement="top"
>
<el-button text @click="editContent(data)">
<AppIcon iconName="app-edit"></AppIcon>
</el-button>
</el-tooltip>
<el-tooltip v-else effect="dark" :content="$t('views.chatLog.editMark')" placement="top">
<el-button text @click="editMark(data)">
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
</el-button>
</el-tooltip>
</template>
<el-divider direction="vertical" v-if="buttonData?.vote_status !== '-1'" />
<el-button text disabled v-if="buttonData?.vote_status === '0'">
<AppIcon iconName="app-like-color"></AppIcon>
</el-button>
<el-button text disabled v-if="buttonData?.vote_status === '1'">
<AppIcon iconName="app-oppose-color"></AppIcon>
</el-button>
<EditContentDialog ref="EditContentDialogRef" @refresh="refreshContent" />
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refreshMark" />
<!-- 先渲染不然不能播放 -->
<audio
ref="audioPlayer"
v-for="item in audioList"
:key="item"
controls
hidden="hidden"
></audio>
<el-button text disabled v-if="buttonData?.vote_status === '1'">
<AppIcon iconName="app-oppose-color"></AppIcon>
</el-button>
<EditContentDialog ref="EditContentDialogRef" @refresh="refreshContent" />
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refreshMark" />
<!-- 先渲染不然不能播放 -->
<audio
ref="audioPlayer"
v-for="item in audioList"
:key="item"
controls
hidden="hidden"
></audio>
</div>
</div>
</div>
<div>
<el-card
class="mt-16"
shadow="always"
v-if="buttonData?.vote_status !== '-1' && data.vote_reason"
>
<VoteReasonContent
:vote-type="buttonData?.vote_status"
:chat-id="buttonData?.chat_id"
:record-id="buttonData?.id"
readonly
:default-reason="data.vote_reason"
:default-other-content="data.vote_other_content"
<div>
<el-card
class="mt-16"
shadow="always"
v-if="buttonData?.vote_status !== '-1' && data.vote_reason"
>
</VoteReasonContent>
</el-card>
<VoteReasonContent
v-if="buttonData?.id"
:vote-type="buttonData?.vote_status"
:chat-id="buttonData?.chat_id"
:record-id="buttonData?.id"
readonly
:default-reason="data.vote_reason"
:default-other-content="data.vote_other_content"
>
</VoteReasonContent>
</el-card>
</div>
</div>
</template>
<script setup lang="ts">

View File

@ -102,7 +102,11 @@
<el-button class="flex mr-8" text @click="cancelReQuestion"
><el-icon><Close /></el-icon
></el-button>
<el-button :disabled="!editText.trim()" text @click="sendReQuestionMessage(chatRecord)">
<el-button
:disabled="!editText.trim() || editText.trim() === chatRecord.problem_text.trim()"
text
@click="sendReQuestionMessage(chatRecord)"
>
<el-icon><Comment /></el-icon>
</el-button>
</el-button-group>
@ -130,7 +134,12 @@
v-if="!isReQuestion"
>
<div class="text-right">
<el-tooltip effect="dark" :content="$t('common.edit')" placement="top" v-if="props.isLast">
<el-tooltip
effect="dark"
:content="$t('common.edit')"
placement="top"
v-if="props.isLast && props.type !== 'log'"
>
<el-button text @click="handleEdit(chatRecord)">
<AppIcon iconName="app-edit"></AppIcon>
</el-button>

View File

@ -107,7 +107,7 @@ watch(
function handleInputFieldList() {
dynamicsFormRefresh.value++
const default_value: any = {}
props.application.work_flow?.nodes
props.application?.work_flow?.nodes
?.filter((v: any) => v.id === 'base-node')
.map((v: any) => {
inputFieldList.value = v.properties.user_input_field_list

View File

@ -197,7 +197,7 @@ const initialApiFormData = ref({})
const isUserInput = computed(
() =>
props.applicationDetails.work_flow?.nodes?.filter((v: any) => v.id === 'base-node')[0]
props.applicationDetails?.work_flow?.nodes?.filter((v: any) => v.id === 'base-node')[0]
?.properties.user_input_field_list.length > 0,
)

View File

@ -45,7 +45,6 @@ const useChatUserStore = defineStore('chat-user', {
},
applicationProfile() {
return ChatAPI.applicationProfile().then((ok) => {
console.log('applicationProfile', ok.data)
this.application = ok.data
localStorage.setItem(`${this.accessToken}-locale`, ok.data?.language || this.getLanguage())
})