UnisKB/ui/src/components/ai-chat/OperationButton.vue

103 lines
2.7 KiB
Vue
Raw Normal View History

2023-12-01 03:36:04 +00:00
<template>
2024-05-21 10:32:48 +00:00
<div>
<el-text type="info">
<span class="ml-4">{{ datetimeFormat(data.create_time) }}</span>
</el-text>
</div>
2023-12-01 03:36:04 +00:00
<div>
2024-05-28 02:41:36 +00:00
<el-tooltip effect="dark" content="换个答案" placement="top">
2023-12-01 11:17:58 +00:00
<el-button text @click="regeneration">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="VideoPlay"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
<el-tooltip effect="dark" content="复制" placement="top">
2023-12-01 10:21:49 +00:00
<el-button text @click="copyClick(data?.answer_text)">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</el-tooltip>
<el-divider direction="vertical" />
2023-12-01 10:21:49 +00:00
<el-tooltip
effect="dark"
content="赞同"
placement="top"
v-if="buttonData?.vote_status === '-1'"
>
2023-12-04 07:23:09 +00:00
<el-button text @click="voteHandle('0')" :disabled="loading">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-like"></AppIcon>
</el-button>
</el-tooltip>
2023-12-01 10:21:49 +00:00
<el-tooltip
effect="dark"
content="取消赞同"
placement="top"
2023-12-04 07:23:09 +00:00
v-if="buttonData?.vote_status === '0'"
2023-12-01 10:21:49 +00:00
>
<el-button text @click="voteHandle('-1')" :disabled="loading">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-like-color"></AppIcon>
</el-button>
</el-tooltip>
2023-12-01 10:21:49 +00:00
<el-divider direction="vertical" v-if="buttonData?.vote_status === '-1'" />
<el-tooltip
effect="dark"
content="反对"
placement="top"
v-if="buttonData?.vote_status === '-1'"
>
2023-12-04 07:23:09 +00:00
<el-button text @click="voteHandle('1')" :disabled="loading">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-oppose"></AppIcon>
</el-button>
</el-tooltip>
2023-12-01 10:21:49 +00:00
<el-tooltip
effect="dark"
content="取消反对"
placement="top"
2023-12-04 07:23:09 +00:00
v-if="buttonData?.vote_status === '1'"
2023-12-01 10:21:49 +00:00
>
<el-button text @click="voteHandle('-1')" :disabled="loading">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-oppose-color"></AppIcon>
</el-button>
</el-tooltip>
</div>
</template>
<script setup lang="ts">
2024-05-20 09:50:14 +00:00
import { ref } from 'vue'
2023-12-01 03:36:04 +00:00
import { copyClick } from '@/utils/clipboard'
2023-12-01 10:21:49 +00:00
import applicationApi from '@/api/application'
2024-05-21 10:32:48 +00:00
import { datetimeFormat } from '@/utils/time'
2023-12-01 10:21:49 +00:00
const props = defineProps({
2023-12-01 03:36:04 +00:00
data: {
type: Object,
default: () => {}
2023-12-01 10:21:49 +00:00
},
applicationId: {
type: String,
default: ''
},
2024-05-20 09:50:14 +00:00
chatId: {
2023-12-01 10:21:49 +00:00
type: String,
default: ''
2023-12-07 11:28:38 +00:00
},
log: Boolean
2023-12-01 03:36:04 +00:00
})
2023-12-01 11:17:58 +00:00
const emit = defineEmits(['update:data', 'regeneration'])
2023-12-01 03:36:04 +00:00
2023-12-01 10:21:49 +00:00
const buttonData = ref(props.data)
const loading = ref(false)
2023-12-07 11:28:38 +00:00
function regeneration() {
2023-12-01 11:17:58 +00:00
emit('regeneration')
}
2023-12-01 10:21:49 +00:00
function voteHandle(val: string) {
applicationApi
2024-05-20 09:50:14 +00:00
.putChatVote(props.applicationId, props.chatId, props.data.record_id, val, loading)
.then(() => {
2023-12-01 10:21:49 +00:00
buttonData.value['vote_status'] = val
emit('update:data', buttonData.value)
})
}
2023-12-01 03:36:04 +00:00
</script>
<style lang="scss" scoped></style>