add ticket detail data
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import TicketDetail, {
|
||||
TicketInfo,
|
||||
TicketNote,
|
||||
} from '@/pages/TicketDetail/TicketDetail';
|
||||
import Taro from '@tarojs/taro';
|
||||
import moment from 'moment';
|
||||
import { getUrl } from '.';
|
||||
|
||||
export function getTicketInfo(that: TicketDetail) {
|
||||
Taro.request({
|
||||
url: getUrl('/tickets/info'),
|
||||
method: 'GET',
|
||||
data: {
|
||||
id: that.state.id,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.data.success) {
|
||||
that.setState({
|
||||
rs: {
|
||||
loading: false,
|
||||
success: false,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = res.data.data;
|
||||
const ticketDetail: TicketInfo = {
|
||||
id: data.id,
|
||||
type: data.type,
|
||||
device: data.device,
|
||||
deviceModel: data.deviceModel,
|
||||
description: data.description,
|
||||
createdTime: moment(),
|
||||
status: data.status,
|
||||
};
|
||||
const notes: Array<TicketNote> = [];
|
||||
data.notes.map(item => {
|
||||
notes.push({
|
||||
id: item.id,
|
||||
op: item.op,
|
||||
type: item.type,
|
||||
content: item.content,
|
||||
createdTime: moment(),
|
||||
});
|
||||
});
|
||||
that.setState({
|
||||
ticketInfo: ticketDetail,
|
||||
notes: notes,
|
||||
rs: {
|
||||
loading: false,
|
||||
success: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(reason => {
|
||||
that.setState({
|
||||
rs: {
|
||||
loading: false,
|
||||
success: false,
|
||||
},
|
||||
});
|
||||
console.log(reason);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user