render basic data in ticket detail
parent
a1aa63635f
commit
cd076cd5a4
|
|
@ -0,0 +1 @@
|
||||||
|
export type FixStatus = 1 | 2 | 3 | 4 | 5;
|
||||||
|
|
@ -7,6 +7,17 @@ import { AtSteps } from 'taro-ui';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { RequestState } from '@/service';
|
import { RequestState } from '@/service';
|
||||||
import { getTicketInfo } from '@/service/ticketsInfo';
|
import { getTicketInfo } from '@/service/ticketsInfo';
|
||||||
|
import { FixStatus } from '@/common';
|
||||||
|
import { timeFormat } from '@/utils';
|
||||||
|
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||||
|
|
||||||
|
const mapStatusStep: Map<FixStatus, 0 | 1 | 2 | 3> = new Map([
|
||||||
|
[1, 0],
|
||||||
|
[2, 1],
|
||||||
|
[3, 2],
|
||||||
|
[4, 2],
|
||||||
|
[5, 3],
|
||||||
|
]);
|
||||||
|
|
||||||
interface StepItemData {
|
interface StepItemData {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -19,7 +30,7 @@ export class TicketInfo {
|
||||||
deviceModel: string;
|
deviceModel: string;
|
||||||
description: string;
|
description: string;
|
||||||
createdTime: moment.Moment;
|
createdTime: moment.Moment;
|
||||||
status: 1 | 2 | 3 | 4 | 5;
|
status: FixStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TicketNote {
|
export class TicketNote {
|
||||||
|
|
@ -30,12 +41,44 @@ export class TicketNote {
|
||||||
createdTime: moment.Moment;
|
createdTime: moment.Moment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StatusStr = '1' | '2' | '3' | '4' | '5';
|
||||||
|
|
||||||
|
const statusModifyMessage = new Map<StatusStr, string>([
|
||||||
|
['1', '维修中'],
|
||||||
|
['2', '2(?)'],
|
||||||
|
['3', '3(?)'],
|
||||||
|
['4', '维修成功待取回'],
|
||||||
|
['5', '维修成功已取回'],
|
||||||
|
]);
|
||||||
|
|
||||||
function renderNote(n: TicketNote): JSX.Element {
|
function renderNote(n: TicketNote): JSX.Element {
|
||||||
return <View>{n.id}</View>;
|
var message = '';
|
||||||
|
|
||||||
|
switch (n.type) {
|
||||||
|
case 0:
|
||||||
|
message = '创建了维修';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
message = n.content;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
message =
|
||||||
|
'将维修状态更改为:' +
|
||||||
|
statusModifyMessage.get(n.content as StatusStr) || '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View>
|
||||||
|
{n.op} {n.createdTime.format(timeFormat)}
|
||||||
|
</View>
|
||||||
|
<View>{message}</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TicketDetailState {
|
interface TicketDetailState {
|
||||||
id: number;
|
|
||||||
current: number;
|
current: number;
|
||||||
items: Array<StepItemData>;
|
items: Array<StepItemData>;
|
||||||
ticketInfo: TicketInfo;
|
ticketInfo: TicketInfo;
|
||||||
|
|
@ -45,7 +88,6 @@ interface TicketDetailState {
|
||||||
|
|
||||||
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
state = {
|
state = {
|
||||||
id: 0,
|
|
||||||
current: 0,
|
current: 0,
|
||||||
items: [],
|
items: [],
|
||||||
ticketInfo: new TicketInfo(),
|
ticketInfo: new TicketInfo(),
|
||||||
|
|
@ -62,11 +104,10 @@ export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
const id = router?.params.id as number;
|
const id = router?.params.id as number;
|
||||||
const items = pt.get().ticketDetail.stepItems;
|
const items = pt.get().ticketDetail.stepItems;
|
||||||
this.setState({
|
this.setState({
|
||||||
id: id,
|
|
||||||
items: items,
|
items: items,
|
||||||
});
|
});
|
||||||
|
|
||||||
getTicketInfo(this);
|
getTicketInfo(this, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
|
|
@ -76,16 +117,32 @@ export default class TicketDetail extends Component<{}, TicketDetailState> {
|
||||||
return <View>Request failed</View>;
|
return <View>Request failed</View>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const status = this.state.ticketInfo.status;
|
||||||
|
this.setState({
|
||||||
|
current: mapStatusStep.get(status) || 0,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<View>{this.state.ticketInfo.deviceModel}</View>
|
<View className='at-article__h1'>
|
||||||
|
{this.state.ticketInfo.device +
|
||||||
|
' ' +
|
||||||
|
this.state.ticketInfo.deviceModel}
|
||||||
|
</View>
|
||||||
|
<View className='at-article__h3'>
|
||||||
|
{'创建于 '}
|
||||||
|
{this.state.ticketInfo.createdTime.format(timeFormat)}
|
||||||
|
</View>
|
||||||
|
<View className='at-article__h3'>
|
||||||
|
{this.state.ticketInfo.description}
|
||||||
|
</View>
|
||||||
<AtSteps
|
<AtSteps
|
||||||
items={this.state.items}
|
items={this.state.items}
|
||||||
current={this.state.current}
|
current={this.state.current}
|
||||||
onChange={() => {}}
|
onChange={() => {}}
|
||||||
/>
|
/>
|
||||||
<View>TicketDetail: {this.state.id}</View>
|
|
||||||
<View>{this.state.notes.map(item => renderNote(item))}</View>
|
<View>{this.state.notes.map(item => renderNote(item))}</View>
|
||||||
|
<PageFooter />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,12 @@ export interface TicketDetailText {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ticketDetailZhCn: TicketDetailText = {
|
export const ticketDetailZhCn: TicketDetailText = {
|
||||||
stepItems: [{ title: '创建成功' }, { title: '维修中' }, { title: '待取回' }],
|
stepItems: [
|
||||||
|
{ title: '创建成功' },
|
||||||
|
{ title: '维修中' },
|
||||||
|
{ title: '待取回' },
|
||||||
|
{ title: '工单完成' },
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ticketDetailEnUs: TicketDetailText = {
|
export const ticketDetailEnUs: TicketDetailText = {
|
||||||
|
|
@ -15,5 +20,6 @@ export const ticketDetailEnUs: TicketDetailText = {
|
||||||
{ title: 'Ticket created' },
|
{ title: 'Ticket created' },
|
||||||
{ title: 'Repairing' },
|
{ title: 'Repairing' },
|
||||||
{ title: 'Take home' },
|
{ title: 'Take home' },
|
||||||
|
{ title: 'Finished' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ import Taro from '@tarojs/taro';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { getUrl } from '.';
|
import { getUrl } from '.';
|
||||||
|
|
||||||
export function getTicketInfo(that: TicketDetail) {
|
export function getTicketInfo(that: TicketDetail, id: number) {
|
||||||
Taro.request({
|
Taro.request({
|
||||||
url: getUrl('/tickets/info'),
|
url: getUrl('/tickets/info'),
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: {
|
||||||
id: that.state.id,
|
id: id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
@ -30,7 +30,7 @@ export function getTicketInfo(that: TicketDetail) {
|
||||||
device: data.device,
|
device: data.device,
|
||||||
deviceModel: data.deviceModel,
|
deviceModel: data.deviceModel,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
createdTime: moment(),
|
createdTime: moment(data.createdTime as string),
|
||||||
status: data.status,
|
status: data.status,
|
||||||
};
|
};
|
||||||
const notes: Array<TicketNote> = [];
|
const notes: Array<TicketNote> = [];
|
||||||
|
|
@ -40,7 +40,7 @@ export function getTicketInfo(that: TicketDetail) {
|
||||||
op: item.op,
|
op: item.op,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
content: item.content,
|
content: item.content,
|
||||||
createdTime: moment(),
|
createdTime: moment(item.createdTime as string),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
that.setState({
|
that.setState({
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import * as Time from './time';
|
||||||
|
|
||||||
|
export const timeFormat = Time.timeFormat;
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export const timeFormat = 'YYYY-MM-DD HH:mm';
|
||||||
Loading…
Reference in New Issue