feat: 用户添加常用问题

main
许宏杰 2 months ago
parent 2e4379651e
commit c9e16424aa

@ -14,6 +14,24 @@ export const projectListApi = async (data?: object) => {
} }
} }
export const getDict = async(data: object)=>{
try{
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.DICT}`, data)
return res
}catch{
httpErrorHandle()
}
}
export const addIssue = async(data: object)=>{
try{
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.ISSUE}`, data)
return res
}catch{
httpErrorHandle()
}
}
// 新增聊天室历史记录 // 新增聊天室历史记录

@ -2,7 +2,9 @@
export enum ModuleTypeEnum { export enum ModuleTypeEnum {
SYSTEM = 'sys', SYSTEM = 'sys',
PROJECT = 'project', PROJECT = 'project',
MESSAGE = 'tHistoricalReply' MESSAGE = 'tHistoricalReply',
DICT = 'dictionary',
ISSUE= 'commonQuestion'
} }
// 请求结果集 // 请求结果集

@ -100,7 +100,8 @@ import {
NColorPicker, NColorPicker,
NWatermark, NWatermark,
NEmpty, NEmpty,
NCollapseTransition NCollapseTransition,
NPopconfirm
} from 'naive-ui' } from 'naive-ui'
const naive = create({ const naive = create({
@ -204,7 +205,8 @@ const naive = create({
NColorPicker, NColorPicker,
NWatermark, NWatermark,
NEmpty, NEmpty,
NCollapseTransition NCollapseTransition,
NPopconfirm
] ]
}) })

@ -18,8 +18,7 @@
<!-- 纯文本 --> <!-- 纯文本 -->
<div class="text-ros"> <div class="text-ros">
<span v-show="item.type == 'text'">{{ item.text }}</span> <span v-show="item.type == 'text'">{{ item.text }}</span>
<AddIssue v-show="item.add"></AddIssue> <AddIssue :issueText="item.text" :list="dictList" v-show="item.add"></AddIssue>
</div> </div>
<!-- 图表 --> <!-- 图表 -->
<section v-if="ehcatrsType.includes(item.type)"> <section v-if="ehcatrsType.includes(item.type)">
@ -40,7 +39,7 @@
</div> </div>
</section> </section>
<!-- 表格 --> <!-- 表格 -->
<AiTable v-if="!item.type" :obj="item"></AiTable> <AiTable v-if="item.type ==='table' " :obj="item"></AiTable>
<!-- 思考 --> <!-- 思考 -->
<div v-show="item.from === 'ai' && item.loading" class="ai-loading"> <div v-show="item.from === 'ai' && item.loading" class="ai-loading">
<span>思考中</span> <n-spin size="small" content-class="spin-class" /> <span>思考中</span> <n-spin size="small" content-class="spin-class" />
@ -101,7 +100,7 @@ import aiIcon from '@/assets/images/ai/ai-icon.png'
import { useMessage } from 'naive-ui' import { useMessage } from 'naive-ui'
import useMessageRoomStore from '@/store/modules/messageRoom' import useMessageRoomStore from '@/store/modules/messageRoom'
import { canvasCut } from '@/utils' import { canvasCut } from '@/utils'
import { historyMessageRoomById } from '@/api/path' import { historyMessageRoomById,getDict } from '@/api/path'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
@ -122,15 +121,25 @@ const echartsTheme = ['简约风', '商务风', '科技风']
let stopWatch = null let stopWatch = null
let isWatching = ref(false) let isWatching = ref(false)
const ehcatrsType = ['pie', 'line', 'bar'] const ehcatrsType = ['pie', 'line', 'bar']
let dictList = ref( [])
/** /**
* 页面初始完成 * 页面初始完成
*/ */
onMounted(() => { onMounted(() => {
getDictListist()
startWatching() startWatching()
getMessageInfo() getMessageInfo()
}) })
/**
* 字典
*/
const getDictListist =async ()=>{
const res =await getDict()
dictList.value = res.data.records
}
/** /**
* 获取聊天详情 * 获取聊天详情
*/ */
@ -185,7 +194,7 @@ const handleSend = async () => {
time: moment().format('YYYY/MM/DD HH:mm:ss'), time: moment().format('YYYY/MM/DD HH:mm:ss'),
add: true add: true
}) })
return
//AI //AI
setMessageItem( setMessageItem(
{ {

@ -1,20 +1,18 @@
<template> <template>
<div> <div>
<n-popconfirm v-model:show="showModal"> <n-popconfirm :show-icon="false" @positive-click="handlePositiveClick">
<!-- 按钮区 -->
<template #trigger> <template #trigger>
<n-button>引用</n-button> <n-tooltip trigger="hover">
</template>
譬如我或许可以就大象本身写一点什么但对象的驯化却不知从何写起
<template #action>
<n-button size="small" @click="showModal = false">
或许吧
</n-button>
</template>
</n-popconfirm>
<!-- <n-tooltip placement="bottom" trigger="hover">
<template #trigger> <template #trigger>
<n-icon size="14" style="cursor: pointer" @click="handleAdd()"> <n-button strong secondary size="tiny">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 12 12"> <template #icon>
<n-icon size="14" style="cursor: pointer">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 12 12"
>
<g fill="none"> <g fill="none">
<path <path
d="M6.5 1.75a.75.75 0 0 0-1.5 0V5H1.75a.75.75 0 0 0 0 1.5H5v3.25a.75.75 0 0 0 1.5 0V6.5h3.25a.75.75 0 0 0 0-1.5H6.5V1.75z" d="M6.5 1.75a.75.75 0 0 0-1.5 0V5H1.75a.75.75 0 0 0 0 1.5H5v3.25a.75.75 0 0 0 1.5 0V6.5h3.25a.75.75 0 0 0 0-1.5H6.5V1.75z"
@ -24,42 +22,91 @@
</svg> </svg>
</n-icon> </n-icon>
</template> </template>
<span> 添加为常用问题 </span> </n-button>
</n-tooltip> --> </template>
添加为常用问题
</n-tooltip>
</template>
<!-- 弹窗信息 --> <!-- 内容区 -->
<!-- <n-modal v-model:show="showModal">
<n-card style="width: 600px" title="添加常用问题" :bordered="false" size="huge" role="dialog" aria-modal="true">
<div class="issue-list"> <div class="issue-list">
<div
<div class="issue-item"></div> class="issue-item"
<div class="issue-item"></div> :class="currentIndex == index ? 'active-type' : ''"
<div class="issue-item"></div> @click="handlerClick(item.dictKey, index)"
v-for="(item, index) in list"
:key="item.id"
>
{{ item.dictValue }}
</div> </div>
<template #footer> 尾部 </template> </div>
</n-card> </n-popconfirm>
</n-modal> -->
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { addIssue } from '@/api/path'
let showModal = ref(true) import { useMessage } from 'naive-ui'
import { ref, reactive } from 'vue'
import { useSystemStore } from '@/store/modules/systemStore/systemStore'
const props = defineProps({
list: {
type: Array,
default: () => []
},
issueText: {
type: String,
default: ''
}
})
const systemStore = useSystemStore()
let currentIndex = ref(null)
const message = useMessage()
let form = {
questionType: undefined,
content: undefined,
userId: undefined
}
const handleAdd = () => { const handlePositiveClick = async () => {
showModal.value = true form.content = props.issueText
form.userId = systemStore.userInfo.userId || 1
try {
await addIssue(form)
currentIndex.value = null
} catch {
message.warning('保存出错!请联系管理员')
}
}
const handlerClick = (dictKey, index) => {
if (currentIndex.value != index) {
form.questionType = dictKey
currentIndex.value = index
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.issue-list { .issue-list {
width: 250px;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
gap: 20px; gap: 10px;
.issue-item{ .issue-item {
height: 100px; padding: 10px 0;
background-color: rgba(242, 242, 242, 1); color: '#fff';
text-align: center;
background-color: #3d424d;
border: 1px solid #474d59;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
font-weight: 400;
}
.active-type {
border-color: #507afc;
} }
} }
</style> </style>

@ -29,23 +29,24 @@ const props = defineProps({
<style lang="scss" scoped> <style lang="scss" scoped>
.ai-table { .ai-table {
width: fit-content; // width: fit-content;
} }
.table-title{ .table-title{
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;
margin-bottom: 8px; margin-bottom: 8px;
color: #fff; color: #fff;
} }
.table-list { .table-list {
min-width: 400px;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: rgba(195, 202, 217, 0.5); background-color: rgba(195, 202, 217, 0.5);
gap: 1px; gap: 1px;
.list-item{ .list-item{
flex: 1; flex: 1;
min-width: 150px;
max-width: 300px;
} }
.item-header { .item-header {
background-color: #507afc; background-color: #507afc;

Loading…
Cancel
Save