refactor api for dutyinfo

This commit is contained in:
Dawn1Ocean
2024-04-04 01:39:58 +08:00
parent d34564980f
commit 5ce1db7693
7 changed files with 74 additions and 54 deletions
+8 -8
View File
@@ -410,28 +410,28 @@ export default class TicketDetail extends Component<{}, TicketDetailState> {
onClose={this.handleStatusCancel.bind(this)}
>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 0)}>
{pt.get().ticketDetail.statusModifyMessage['0']}
{pt.get().ticketDetail.statusModifyMessage.get('0')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 1)}>
{pt.get().ticketDetail.statusModifyMessage['1']}
{pt.get().ticketDetail.statusModifyMessage.get('1')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 2)}>
{pt.get().ticketDetail.statusModifyMessage['2']}
{pt.get().ticketDetail.statusModifyMessage.get('2')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 3)}>
{pt.get().ticketDetail.statusModifyMessage['3']}
{pt.get().ticketDetail.statusModifyMessage.get('3')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 4)}>
{pt.get().ticketDetail.statusModifyMessage['4']}
{pt.get().ticketDetail.statusModifyMessage.get('4')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 5)}>
{pt.get().ticketDetail.statusModifyMessage['5']}
{pt.get().ticketDetail.statusModifyMessage.get('5')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 6)}>
{pt.get().ticketDetail.statusModifyMessage['6']}
{pt.get().ticketDetail.statusModifyMessage.get('6')}
</AtActionSheetItem>
<AtActionSheetItem onClick={this.handleStatusChange.bind(this, 7)}>
{pt.get().ticketDetail.statusModifyMessage['7']}
{pt.get().ticketDetail.statusModifyMessage.get('7')}
</AtActionSheetItem>
</AtActionSheet>
<DetailFramework
+25 -10
View File
@@ -6,22 +6,24 @@ import tick from '@/assets/icons/MainPage/tick.svg';
import cross from '@/assets/icons/MainPage/cross.svg';
import clock from '@/assets/icons/MainPage/offduty.svg';
import wechatUser from '@/wechat';
import moment from 'moment';
export class DutyData {
constructor() {
this.isInDuty = false;
this.inDutyCnt = 3;
this.currentDuty = '2';
this.otherDutyTime = '9:30-11:30';
this.offDutyReason = '学园维修';
this.dutyRecoverTime = '下周一';
this.currentDuty = '1';
this.otherDutyStart = '2024-03-07T13:30:48.523303';
this.otherDutyEnd = '2024-03-07T16:00:48.523303';
this.dutyRecoverTime = '明天 13:30';
this.place = '东三-204';
}
isInDuty: boolean;
inDutyCnt?: number;
currentDuty?: 'off' | '1' | '2' | '3' | 'others';
otherDutyTime?: string;
currentDuty?: '0' | '1' | '2' | '3' | 'others';
otherDutyStart?: string;
otherDutyEnd?: string;
offDutyReason?: string;
dutyRecoverTime?: string;
place: string;
@@ -87,8 +89,18 @@ export class DutyInfo extends Component {
<Card isInDuty={data.isInDuty} place={data.place} />
<AtTimeline
items={[
{ title: od.reason(data.offDutyReason as string) },
{ title: od.recoverTime(data.dutyRecoverTime as string) },
{
title:
data.currentDuty == '0'
? pt.get().mainPage.normal.reason
: od.reason(data.offDutyReason as string),
},
{
title:
data.currentDuty == '0'
? pt.get().mainPage.normal.recoverTime
: od.recoverTime(data.dutyRecoverTime as string),
},
]}
/>
</View>
@@ -106,8 +118,11 @@ export class DutyInfo extends Component {
{
title:
data.currentDuty == 'others'
? id.currentDutyText('others') + data.otherDutyTime
: id.currentDutyText(data.currentDuty || 'off'),
? id.currentDutyText('others') +
moment(data.otherDutyStart).format('H:mm') +
' - ' +
moment(data.otherDutyEnd).format('H:mm')
: id.currentDutyText(data.currentDuty || '0'),
},
{ title: id.inDutyCnt(data.inDutyCnt as number) },
]}
+1 -1
View File
@@ -123,7 +123,7 @@ export default class UserPage extends Component {
className='at-row at-row__justify--center at-row__align--center'
style='height:120rpx;color:#696969;'
>
<Text style={{ fontSize: '32rpx' }}> EVA Eta v1.0.0</Text>
<Text style={{ fontSize: '32rpx' }}> EVA Eta v1.0.1</Text>
</View>
<AtList>
<AtListItem
+16 -4
View File
@@ -1,4 +1,8 @@
export interface MainPageText {
normal: {
recoverTime: string;
reason: string;
};
titleLine: {
main: string;
sub: string;
@@ -33,13 +37,17 @@ export interface MainPageText {
};
inDuty: {
title: string;
currentDutyText: (c: 'off' | '1' | '2' | '3' | 'others') => string;
currentDutyText: (c: '0' | '1' | '2' | '3' | 'others') => string;
inDutyCnt: (n: number) => string;
};
};
}
export const mainPageZhCn: MainPageText = {
normal: {
recoverTime: '明天 13:30',
reason: '正常下班',
},
titleLine: {
main: '您好,这里是E志者协会',
sub: '维修请至【东三-204】实验室',
@@ -85,7 +93,7 @@ export const mainPageZhCn: MainPageText = {
title: '值班中',
currentDutyText: (c) => {
switch (c) {
case 'off':
case '0':
return '当前未值班';
case '1':
return '第一班 13:30-16:00';
@@ -103,6 +111,10 @@ export const mainPageZhCn: MainPageText = {
};
export const mainPageEnUs: MainPageText = {
normal: {
recoverTime: 'Tomorrow 13:30',
reason: 'Normal shift',
},
titleLine: {
main: 'Hi! This is EVA.',
sub: 'For maintenance, please go to [204 Lab, E3 building]',
@@ -148,8 +160,8 @@ export const mainPageEnUs: MainPageText = {
title: 'On Duty',
currentDutyText: (c) => {
switch (c) {
case 'off':
return 'Currently not on duty';
case '0':
return 'Normal Shift';
case '1':
return '1st Shift 13:30-16:00';
case '2':
+4 -22
View File
@@ -20,28 +20,10 @@ export function getDutyInfo(that: MainPage) {
return;
}
const data = res.data.data;
if (data.isInDuty) {
that.setState({
rs: former.trans(true),
dutyData: {
isInDuty: data.isInDuty,
inDutyCnt: data.inDutyCnt,
currentDuty: data.currentDuty,
otherDutyTime: data.otherDutyTime,
place: data.place,
},
});
} else {
that.setState({
rs: former.trans(true),
dutyData: {
isInDuty: data.isInDuty,
offDutyReason: data.offDutyReason,
dutyRecoverTime: data.dutyRecoverTime,
place: data.place,
},
});
}
that.setState({
rs: former.trans(true),
dutyData: data,
});
})
.catch((err) => {
console.log(err.errMsg);