refactor api for dutyinfo

dev
Dawn1Ocean 2024-04-04 01:39:58 +08:00
parent d34564980f
commit 5ce1db7693
7 changed files with 74 additions and 54 deletions

View File

@ -44,9 +44,12 @@ data:
{
"isInDuty": true,
"inDutyCnt": 3,
"currentDuty": "2",
"place": "东三-204",
"otherDutyTime": ""
"currentDuty": "1",
"place": "", // 只有当 currentDuty 为 others 时place 和 值班时间 才不为空
"otherDutyStart": "",
"otherDutyEnd": "",
"offDutyReason": "",
"dutyRecoverTime": ""
}
```
@ -59,8 +62,11 @@ data:
"isInDuty": true,
"inDutyCnt": 3,
"currentDuty": "others",
"place": "蓝田",
"otherDutyTime": "9:30-11:30"
"place": "蓝田", // 只有当 currentDuty 为 others 时place 才不为空
"otherDutyStart": "2024-03-07T11:52:48.523303", // Timestamp
"otherDutyEnd": "2024-03-07T13:52:48.523303",
"offDutyReason": "",
"dutyRecoverTime": ""
}
```
@ -71,6 +77,11 @@ data:
```json
{
"isInDuty": false,
"inDutyCnt": 0,
"currentDuty": "0", // '0' 代表正常值班时间下班,'others' 代表其他值班时间下班
"place": "",
"otherDutyStart": "",
"otherDutyEnd": "",
"offDutyReason": "学园维修",
"dutyRecoverTime": "下周一"
}

View File

@ -14,18 +14,19 @@ export default {
'GET /duty/info': {
success: true,
data: {
token: 'token_test',
isInDuty: true,
inDutyCnt: 3,
currentDuty: 'others',
otherDutyTime: '9:30-11:30',
otherDutyStart: '2024-03-07T09:30:48.523303',
otherDutyEnd: '2024-03-07T13:30:48.523303',
place: '蓝田',
offDutyReason: '',
dutyRecoverTime: '',
},
},
'GET /user/info': {
success: true,
data: {
token: 'token_test',
name: '马保国',
phone: 13333333333,
},
@ -116,7 +117,6 @@ export default {
'GET /member/duty/info': {
success: true,
data: {
token: 'token_test',
isInDuty: true,
inDutyCnt: 6,
currentDuty: '3',

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

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 = '明天 1330';
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) },
]}

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

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':

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,
},
dutyData: data,
});
} else {
that.setState({
rs: former.trans(true),
dutyData: {
isInDuty: data.isInDuty,
offDutyReason: data.offDutyReason,
dutyRecoverTime: data.dutyRecoverTime,
place: data.place,
},
});
}
})
.catch((err) => {
console.log(err.errMsg);