From 24f71ed997f0ef1c1fceef75bde8c32c4cffa6e2 Mon Sep 17 00:00:00 2001 From: Dawn_Ocean <1785590531@qq.com> Date: Fri, 22 Mar 2024 15:58:53 +0800 Subject: [PATCH] fix status display bug in detailframework --- .../DetailFramework/DetailFramework.tsx | 14 ------ src/service/ticketsInfo.ts | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/components/DetailFramework/DetailFramework.tsx b/src/components/DetailFramework/DetailFramework.tsx index ef67323..31a9470 100644 --- a/src/components/DetailFramework/DetailFramework.tsx +++ b/src/components/DetailFramework/DetailFramework.tsx @@ -9,7 +9,6 @@ import { import pt from '@/plain-text'; import { RequestState } from '@/service'; import { getTicketInfo } from '@/service/ticketsInfo'; -import { FixStatus } from '@/common'; import { AtCard, AtSteps } from 'taro-ui'; import NoteList from '../NoteList/NoteList'; @@ -17,14 +16,6 @@ interface StepItemData { title: string; } -const mapStatusStep: Map = new Map([ - [1, 0], - [2, 1], - [3, 2], - [4, 2], - [5, 3], -]); - interface DetailFrameworkState { current: number; items: Array; @@ -57,11 +48,6 @@ export default class DetailFramework extends Component< title: navBar.ticketDetail, }); getTicketInfo(this, this.props.id); - const status = this.state.ticketInfo.status; - this.setState({ - current: mapStatusStep.get(status) || 0, - items: pt.get().ticketDetail.stepItems, - }); } props: Readonly = { diff --git a/src/service/ticketsInfo.ts b/src/service/ticketsInfo.ts index 1f8a8b9..2e103b1 100644 --- a/src/service/ticketsInfo.ts +++ b/src/service/ticketsInfo.ts @@ -2,8 +2,21 @@ import { TicketInfo, TicketNote } from '@/pages/TicketDetail/TicketNote'; import DetailFramework from '@/components/DetailFramework/DetailFramework'; import Taro from '@tarojs/taro'; import moment from 'moment'; +import { FixStatus } from '@/common'; +import pt from '@/plain-text'; import { getUrl } from '.'; +const mapStatusStep: Map = new Map([ + [0, 0], + [1, 1], + [2, 2], + [3, 3], + [4, 2], + [5, 3], + [6, 2], + [7, 3], +]); + export function getTicketInfo(that: DetailFramework, id: number) { Taro.request({ url: getUrl('/tickets/info'), @@ -35,20 +48,31 @@ export function getTicketInfo(that: DetailFramework, id: number) { }, }; const notes: Array = []; - data.notes.map((item) => { - notes.push({ - avatar: item.avatar, - id: item.id, - op: item.op, - type: item.type, - content: item.content, - createdTime: moment(item.createdTime as string), - }); - }); + data.notes.map( + (item: { + avatar: string; + id: number; + op: string; + type: 0 | 1 | 2; + content: string; + createdTime: string; + }) => { + notes.push({ + avatar: item.avatar, + id: item.id, + op: item.op, + type: item.type, + content: item.content, + createdTime: moment(item.createdTime as string), + }); + }, + ); that.setState({ ticketInfo: ticketDetail, notes: notes, rs: former.trans(true), + current: mapStatusStep.get(data.status) || 0, + items: pt.get().ticketDetail.stepItems, }); } })