feat: 常用问题快速查询

main
许宏杰 1 month ago
parent c9e16424aa
commit 0d9b242419

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

@ -80,7 +80,7 @@
>
<template #suffix>
<div class="chat-suffix">
<span>常用问题</span>
<IssueQuey :list="dictList" v-model="keyWord"></IssueQuey>
<n-button :loading="loading" size="small" :class="['chat-send']" :bordered="false" @click="handleSend">
</n-button>
</div>
@ -94,7 +94,7 @@ import { ref, reactive, onMounted, onUnmounted, watch, nextTick } from 'vue'
import { getAiMsg } from '@/api/ai.js'
import moment from 'moment'
import { LineChart, BarChart, PieChart } from './class/index'
import { AiHint, AiTable,AddIssue } from '../components'
import { AiHint, AiTable,AddIssue,IssueQuey } from '../components'
import userIcon from '@/assets/images/ai/user-icon.png'
import aiIcon from '@/assets/images/ai/ai-icon.png'
import { useMessage } from 'naive-ui'

@ -3,4 +3,6 @@ export { default as AiHistory } from './history/index.vue'
export { default as AiLogo } from './logo/index.vue'
export { default as AiTable } from './aiTable/index.vue'
export { default as AddIssue } from './addIssue/index.vue'
export { default as AddIssue } from './addIssue/index.vue'
export { default as IssueQuey } from './issueQuey/index.vue'

@ -0,0 +1,154 @@
<template>
<n-popconfirm
ref="popconfirm"
:show-icon="false"
@positive-click="handlePositiveClick"
:positive-text="null"
:negative-text="null"
>
<!-- 按钮区 -->
<template #trigger>
<n-button quaternary size="small">
<slot></slot>
</n-button>
</template>
<div class="issue-list" v-if="!currentKey">
<div
class="issue-item"
@click="handlerClick(item.dictKey, item.dictValue)"
v-for="(item, index) in list"
:key="item.id"
>
{{ item.dictValue }}
</div>
</div>
<div v-else class="list-query">
<div class="list-title">
<div class="title-text">{{ currentValue }}</div>
<n-button size="small" @click="handlerBack()"></n-button>
</div>
<div
@click="handlerQuerParmas(item.content)"
class="list-item"
v-for="item in queryList"
:key="item.id"
v-show="queryList.length > 0"
>
{{ item.content }}
</div>
<n-empty description="你什么也找不到" v-show="queryList.length === 0"> </n-empty>
</div>
</n-popconfirm>
</template>
<script setup>
import { ref } from 'vue'
import { getIssue } from '@/api/path'
import { useMessage } from 'naive-ui'
import { useSystemStore } from '@/store/modules/systemStore/systemStore'
const message = useMessage()
const props = defineProps({
modelValue: {
type: String, // modelValue
default: ''
},
list: {
type: Array,
default: () => []
}
})
const emit = defineEmits(['update:modelValue'])
const systemStore = useSystemStore()
let popconfirm = ref(null)
let currentKey = ref(null)
let currentValue = ref('')
let queryList = ref([])
const handlerQuerParmas = content => {
emit('update:modelValue', content)
popconfirm.value.setShow(false)
setTimeout(() => {
handlerBack()
}, 1000)
}
const handlerBack = () => {
currentKey.value = null
currentValue.value = ''
}
const handlerClick = (dictKey, dictValue) => {
if (currentKey.value != dictKey) {
currentKey.value = dictKey
currentValue.value = dictValue
getList()
}
}
const getList = async () => {
try {
const res = await getIssue({
questionType: currentKey.value,
userId:systemStore.userInfo.userId
})
if (res && res.data) {
queryList.value = res.data.records
}
} catch {
message.warning('查询出错!请联系管理员')
}
}
</script>
<style lang="scss" scoped>
.list-query {
width: 300px;
height: 150px;
display: flex;
flex-direction: column;
overflow-y: auto;
gap: 6px;
.list-title {
display: flex;
justify-content: space-between;
align-items: center;
.title-text {
font-size: 13px;
font-weight: bold;
color: #fff;
}
}
.list-item {
box-sizing: border-box;
padding: 3px 10px;
background-color: #3d424d;
font-size: 14px;
font-weight: 400;
border-radius: 4px;
cursor: pointer;
}
}
.issue-list {
width: 250px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
.issue-item {
padding: 10px 0;
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>
Loading…
Cancel
Save