fix status display bug in detailframework

main
Dawn_Ocean 2024-03-22 15:58:53 +08:00
parent 97a8d0570a
commit 24f71ed997
2 changed files with 34 additions and 24 deletions

View File

@ -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<FixStatus, 0 | 1 | 2 | 3> = new Map([
[1, 0],
[2, 1],
[3, 2],
[4, 2],
[5, 3],
]);
interface DetailFrameworkState {
current: number;
items: Array<StepItemData>;
@ -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<DetailFrameworkProps> = {

View File

@ -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<FixStatus, 0 | 1 | 2 | 3> = 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,7 +48,15 @@ export function getTicketInfo(that: DetailFramework, id: number) {
},
};
const notes: Array<TicketNote> = [];
data.notes.map((item) => {
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,
@ -44,11 +65,14 @@ export function getTicketInfo(that: DetailFramework, id: number) {
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,
});
}
})