Commit 84d29dc3 by Liu

feat:更换常见问题&&提质增效接口

parent 94e0db57
......@@ -185,7 +185,7 @@ export function fetchQueryRecommendQuestion(
}
/**
* 查询推荐问题
* 查询推荐问题 工单/提质增效
* @param conversationId
* @param recordId
* @param toolId 可选的工具ID
......
......@@ -25,8 +25,10 @@ export function fetchToolList(params?: { userRoles?: string[] }) {
/**
* 查询 提质增效 推荐问题列表
* @params
* toolId: 工具id
* conversationId: 会话id
* busiType: 业务类型,固定值 '01'
* recordType: 记录类型,固定值 'A14'
*/
export function fetchEfficiencyQuestionList(data: any) {
return http.post('/conversation/api/conversation/mobile/v1/generate_question', data)
return http.post('/conversation/api/conversation/mobile/v1/query_strategy_recommend_question', data)
}
......@@ -25,9 +25,15 @@ export const ChatAnswerRecommend: React.FC<ChatAnswerRecommendProps> = ({ answer
const place = searchParams.get('place')
const shouldAttachBusiParams = from === 'tactics'
const isOrderTactics = from === 'tactics' && place === 'order'
const busiType = shouldAttachBusiParams ? '02' : undefined
const isSpecialToolId = toolId === '6712395743241'
let busiType: string | undefined
let recordType: string | undefined
if (shouldAttachBusiParams) {
if (isSpecialToolId) {
busiType = '01'
recordType = 'A15'
}
else if (shouldAttachBusiParams) {
busiType = '02'
// from=tactics 且 place=order → recordType=A13 (使用 fetchOrderQueryRecommendQuestion)
if (isOrderTactics) {
recordType = 'A13'
......@@ -42,7 +48,7 @@ export const ChatAnswerRecommend: React.FC<ChatAnswerRecommendProps> = ({ answer
}
}
try {
const res = isOrderTactics
const res = (isOrderTactics || isSpecialToolId)
? await fetchOrderQueryRecommendQuestion(
answer.conversationId || '',
answer.recordId || '',
......
......@@ -122,16 +122,23 @@ export const Home: React.FC = () => {
setIsDataLoaded(false) // 重置加载状态
try {
// 获取当前的 toolId,只从 sessionStorage 获取
const sessionToolId = safeSessionStorageGetItem('currentToolId') || ''
console.log('[HomeNew] handleRefreshQuestions - 当前 toolId:', sessionToolId)
// 从路由中获取 conversationId
const conversationId = location.pathname.startsWith('/chat/')
? location.pathname.split('/')[2]
: null
console.log('[HomeNew] handleRefreshQuestions - 当前 conversationId:', conversationId)
if (!conversationId) {
console.warn('[HomeNew] handleRefreshQuestions - conversationId 不存在,跳过接口调用')
setIsDataLoaded(true)
return
}
// 调用接口重新获取问题列表
console.log('[HomeNew] handleRefreshQuestions - 开始调用 fetchEfficiencyQuestionList 接口')
const res = await fetchEfficiencyQuestionList({
toolId: sessionToolId,
conversationId,
busiType: '01',
recordType: 'A14',
})
console.log('[HomeNew] handleRefreshQuestions - fetchEfficiencyQuestionList 接口返回:', res)
if (res && res.data && res.data.questions) {
console.log('[HomeNew] handleRefreshQuestions - 获取到问题数量:', res.data.questions.length)
setOtherQuestions((prev: any) => ({
......@@ -181,10 +188,22 @@ export const Home: React.FC = () => {
finalToolId = storedToolId
}
// 调用真实 API 获取常见问题列表,优先使用 sessionStorage 中的 currentToolId
const sessionToolId = safeSessionStorageGetItem('currentToolId') || ''
// 从路由中获取 conversationId
const conversationId = location.pathname.startsWith('/chat/')
? location.pathname.split('/')[2]
: null
if (!conversationId) {
console.warn('[HomeNew] _handleToolClick - conversationId 不存在,跳过接口调用')
setIsDataLoaded(true)
return
}
// 调用真实 API 获取常见问题列表
const res = await fetchEfficiencyQuestionList({
toolId: sessionToolId || finalToolId,
conversationId,
busiType: '01',
recordType: 'A14',
})
if (res && res.data && res.data.questions) {
setOtherQuestions((prev: any) => ({
......@@ -199,7 +218,7 @@ export const Home: React.FC = () => {
finally {
setIsDataLoaded(true) // 无论成功失败都标记为已加载
}
}, [originalOtherQuestions, location.search])
}, [originalOtherQuestions, location.search, location.pathname])
// 监听工具按钮点击事件
useEffect(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment