feat: prefill ticket resolution from linked solutions
This commit is contained in:
@@ -13,6 +13,8 @@ import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { SolutionLinkPanel } from '@/features/solutions/SolutionLinkPanel'
|
||||
import { selectDefaultTicketSolution } from '@/features/solutions/solutionSelection'
|
||||
import type { TicketSolution } from '@/features/solutions/types'
|
||||
import { formatDateTime } from '@/lib/format'
|
||||
|
||||
import { getTicket, listTicketEvents, transitionTicket } from './api'
|
||||
@@ -64,6 +66,7 @@ export function TicketDetailPage({ ticketId }: { ticketId: number }) {
|
||||
const [targetActionLabel, setTargetActionLabel] = React.useState('')
|
||||
const [transitionDialogOpen, setTransitionDialogOpen] = React.useState(false)
|
||||
const [transitionError, setTransitionError] = React.useState('')
|
||||
const [linkedSolutions, setLinkedSolutions] = React.useState<TicketSolution[]>([])
|
||||
|
||||
React.useEffect(() => {
|
||||
refreshTicket()
|
||||
@@ -127,6 +130,15 @@ export function TicketDetailPage({ ticketId }: { ticketId: number }) {
|
||||
}
|
||||
|
||||
const nextStatuses = getTicketNextStatuses(ticket.category_code, ticket.status)
|
||||
const defaultLinkedSolution = selectDefaultTicketSolution(linkedSolutions)
|
||||
const transitionDefaultResolution =
|
||||
targetStatus === 'resolved' || targetStatus === 'closed'
|
||||
? ticket.resolution || defaultLinkedSolution?.solution.solution || ''
|
||||
: ''
|
||||
const transitionDefaultRemark =
|
||||
targetStatus === 'closed' && transitionDefaultResolution && !ticket.resolution
|
||||
? '根据关联解决方案关闭工单'
|
||||
: ''
|
||||
|
||||
return (
|
||||
<AppPage maxWidth="6xl">
|
||||
@@ -195,6 +207,7 @@ export function TicketDetailPage({ ticketId }: { ticketId: number }) {
|
||||
<TicketMetaPanel ticket={ticket} />
|
||||
<SolutionLinkPanel
|
||||
ticketId={ticket.id}
|
||||
onLinkedSolutionsChange={setLinkedSolutions}
|
||||
onTicketChanged={() => {
|
||||
refreshTicket()
|
||||
refreshEvents()
|
||||
@@ -254,6 +267,8 @@ export function TicketDetailPage({ ticketId }: { ticketId: number }) {
|
||||
open={transitionDialogOpen}
|
||||
status={targetStatus}
|
||||
actionLabel={targetActionLabel}
|
||||
defaultResolution={transitionDefaultResolution}
|
||||
defaultRemark={transitionDefaultRemark}
|
||||
onOpenChange={setTransitionDialogOpen}
|
||||
onSubmit={handleTransition}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user