index修改
This commit is contained in:
@@ -413,26 +413,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 显示工单创建器
|
||||
function showCreator() {
|
||||
showWorkcaseCreator.value = true
|
||||
// 直接跳转到工单详情页的 create 模式(复用 workcaseDetail 页面)
|
||||
async function showCreator() {
|
||||
// 首页直接创建工单:为了让工单和聊天室绑定,这里先创建一个聊天室(workcase类型),再带 roomId 跳转
|
||||
// 如果你希望“无聊天室也能创建工单”,后端 WorkcaseServiceImpl 也支持 roomId 为空时自动创建聊天室
|
||||
uni.showLoading({ title: '正在创建工单...' })
|
||||
try {
|
||||
const res = await workcaseChatAPI.createChatRoom({
|
||||
guestId: userInfo.value.userId || userInfo.value.wechatId,
|
||||
guestName: userInfo.value.username || '访客',
|
||||
roomName: `${userInfo.value.username || '访客'}的工单`,
|
||||
roomType: 'workcase',
|
||||
status: 'active',
|
||||
aiSessionId: chatId.value || ''
|
||||
})
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.success && res.data?.roomId) {
|
||||
const roomId = res.data.roomId
|
||||
uni.navigateTo({
|
||||
url: `/pages/workcase/workcaseDetail/workcaseDetail?mode=create&roomId=${roomId}`
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showToast({ title: res.message || '创建工单失败', icon: 'none' })
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
console.error('首页创建工单失败:', e)
|
||||
uni.showToast({ title: '创建工单失败,请稍后重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
// 隐藏工单创建器
|
||||
// 兼容旧逻辑:不再使用页面内工单创建器
|
||||
function hideCreator() {
|
||||
showWorkcaseCreator.value = false
|
||||
}
|
||||
|
||||
// 工单创建成功
|
||||
// 兼容旧逻辑:不再使用页面内工单创建器
|
||||
function onWorkcaseCreated(workcaseData : TbWorkcaseDTO) {
|
||||
hideCreator()
|
||||
|
||||
uni.showToast({
|
||||
title: '工单创建成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
// 添加成功消息
|
||||
addMessage('bot', `工单创建成功!\n类型:${workcaseData.type || ''}\n设备:${workcaseData.device || ''}\n我们会尽快处理您的问题。`, ['查看工单', '创建新工单'])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user