fix: memberDutyInfo api; dutyInfo card in MainPage

mgy
Dawn_Ocean 2024-04-23 17:10:22 +08:00
parent 0dc87d06d6
commit 7e3ad80121
10 changed files with 77 additions and 38 deletions

View File

@ -1,3 +1,4 @@
# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config
TARO_APP_ID="wx636eb7cf2b84f305"
TARO_APP_API="https://ate.zjueva.net"
# TARO_APP_API="http://127.0.0.1:9527"

View File

@ -461,9 +461,14 @@ data:
```json
{
"isInDuty": true,
"isInDuty": true, // 指示成员其当前是否在值班
"inDutyCnt": 3,
"currentDuty": "2"
"currentDuty": "others",
"place": "蓝田", // 只有当 currentDuty 为 others 时place 才不为空
"otherDutyStart": "2024-03-07T11:52:48.523303", // Timestamp
"otherDutyEnd": "2024-03-07T13:52:48.523303",
"offDutyReason": "",
"dutyRecoverTime": ""
}
```
@ -474,7 +479,12 @@ data:
```json
{
"isInDuty": false,
"offDutyReason": "学园维修",
"inDutyCnt": 0,
"currentDuty": "off", // "0" => 正常值班下班,"others" => 其他值班下班,"off" => 值班暂停
"place": "", // 只有当 currentDuty 为 others 时place 才不为空
"otherDutyStart": "",
"otherDutyEnd": "",
"offDutyReason": "期中考试周",
"dutyRecoverTime": "下周一"
}
```
@ -500,6 +510,8 @@ Request
```json
{
"token": "token_test",
"week": "2",
"shift": "3",
"conclusion": "周四第三班,一人请假,共收两台电脑,均劝退已取回。由上一班交接两台电脑,其中一台维修成功已取回,一台仍在维修。"
}
```

View File

@ -120,9 +120,13 @@ export default {
success: true,
data: {
isInDuty: true,
inDutyCnt: 6,
currentDuty: '3',
place: '204',
inDutyCnt: 3,
currentDuty: 'others',
otherDutyStart: '2024-03-07T09:30:48.523303',
otherDutyEnd: '2024-03-07T13:30:48.523303',
place: '蓝田',
offDutyReason: '',
dutyRecoverTime: '',
},
},
'POST /member/askleave': {

View File

@ -20,19 +20,19 @@ export class DutyData {
}
isInDuty: boolean;
inDutyCnt?: number;
currentDuty?: 'off' | '0' | '1' | '2' | '3' | 'others';
otherDutyStart?: string;
otherDutyEnd?: string;
offDutyReason?: string;
dutyRecoverTime?: string;
inDutyCnt: number;
currentDuty: 'off' | '0' | '1' | '2' | '3' | 'others';
otherDutyStart: string;
otherDutyEnd: string;
offDutyReason: string;
dutyRecoverTime: string;
place: string;
}
class Card extends Component {
props = {
isInDuty: false,
place: '东三-204',
place: pt.get().common.place,
};
render(): ReactNode {
const inDuty = this.props.isInDuty;

View File

@ -51,7 +51,6 @@ interface MainPageState {
fixList: Array<TicketListItem>;
rs: RequestState;
dutyData: DutyData;
inDutyCnt: number;
dutyInfoCard: CardContent;
stepInfoCard: CardContent;
tipsInfoCard: CardContent;
@ -62,7 +61,6 @@ interface MainPageState {
export default class MainPage extends Component<{}, MainPageState> {
state = {
dutyData: new DutyData(),
inDutyCnt: 0,
dutyInfoCard: {
title: '',
note: '',
@ -91,7 +89,6 @@ export default class MainPage extends Component<{}, MainPageState> {
const ptPage = wechatUser.getAccess() ? 'memberPage' : 'mainPage';
this.setState({
dutyData: new DutyData(),
inDutyCnt: 0,
dutyInfoCard: {
title: pt.get()[ptPage].cardTitle.dutyInfo,
note: pt.get()[ptPage].cardTips.dutyInfo,
@ -130,7 +127,10 @@ export default class MainPage extends Component<{}, MainPageState> {
handleCnt(inDutyCnt: number) {
this.setState({
inDutyCnt: inDutyCnt,
dutyData: {
...this.state.dutyData,
inDutyCnt: inDutyCnt,
},
});
return inDutyCnt;
}
@ -217,7 +217,7 @@ export default class MainPage extends Component<{}, MainPageState> {
min={0}
max={10}
step={1}
value={this.state.inDutyCnt}
value={this.state.dutyData.inDutyCnt}
onChange={this.handleCnt.bind(this)}
/>
</View>

View File

@ -4,6 +4,7 @@ export interface CommonText {
createdAtText(time: Moment): string;
offDutyReason: string;
place: string;
dutyRecoverTime: string;
}
export const commonTextZhCn: CommonText = {
@ -11,7 +12,8 @@ export const commonTextZhCn: CommonText = {
return '创建于 ' + time.format('YYYY-MM-DD HH:mm');
},
offDutyReason: '正常值班下班',
place: '东三-204',
place: '204',
dutyRecoverTime: '明天 13:30',
};
export const commonTextEnUs: CommonText = {
@ -20,4 +22,5 @@ export const commonTextEnUs: CommonText = {
},
offDutyReason: 'Normal Shift',
place: 'E3-204',
dutyRecoverTime: 'Tomorrow 13:30',
};

View File

@ -15,7 +15,7 @@ export function changeDutyCnt(that: MainPage) {
method: 'POST',
data: {
token: wechatUser.getToken(),
dutyCnt: that.state.inDutyCnt,
dutyCnt: that.state.dutyData.inDutyCnt,
},
})
.then((res) => {

View File

@ -14,6 +14,8 @@ export function conclude(that: ConclusionPage) {
data: {
token: wechatUser.getToken(),
conclusion: that.state.conclusion,
week: (that.state.shift[0] + 1).toString(),
shift: (that.state.shift[1] + 1).toString(),
},
})
.then((res) => {

View File

@ -25,14 +25,23 @@ export function getDutyInfo(that: MainPage) {
rs: former.trans(true),
dutyData: data,
});
if (data.currentDuty === '0') {
if (!data.isInDuty) {
that.setState({
dutyData: {
...that.state.dutyData,
place: pt.get().common.place,
offDutyReason: pt.get().common.offDutyReason,
},
});
if (data.currentDuty === '0') {
that.setState({
dutyData: {
...that.state.dutyData,
place: pt.get().common.place,
offDutyReason: pt.get().common.offDutyReason,
dutyRecoverTime: pt.get().common.dutyRecoverTime,
},
});
}
}
})
.catch((err) => {
@ -42,6 +51,10 @@ export function getDutyInfo(that: MainPage) {
rs: former.trans(false),
dutyData: {
isInDuty: false,
inDutyCnt: 0,
currentDuty: '0',
otherDutyStart: '',
otherDutyEnd: '',
offDutyReason: '获取失败Network Error!',
dutyRecoverTime: '获取失败Network Error!',
place: '204',

View File

@ -1,6 +1,7 @@
import MainPage from '@/pages/index';
import Taro from '@tarojs/taro';
import wechatUser from '@/wechat';
import pt from '@/plain-text';
import { getUrl } from '.';
export function getMemberDutyInfo(that: MainPage) {
@ -13,25 +14,24 @@ export function getMemberDutyInfo(that: MainPage) {
})
.then((res) => {
const data = res.data.data;
if (data.isInDuty) {
that.setState({
dutyData: data,
});
if (!data.isInDuty) {
that.setState({
dutyData: {
isInDuty: data.isInDuty,
inDutyCnt: data.inDutyCnt,
currentDuty: data.currentDuty,
place: data.place,
},
inDutyCnt: data.inDutyCnt,
});
} else {
that.setState({
dutyData: {
isInDuty: data.isInDuty,
offDutyReason: data.offDutyReason,
dutyRecoverTime: data.dutyRecoverTime,
place: data.place,
...that.state.dutyData,
offDutyReason: pt.get().common.offDutyReason,
},
});
if (data.currentDuty === '0') {
that.setState({
dutyData: {
...that.state.dutyData,
place: pt.get().common.place,
},
});
}
}
})
.catch((err) => {
@ -39,6 +39,10 @@ export function getMemberDutyInfo(that: MainPage) {
that.setState({
dutyData: {
isInDuty: false,
inDutyCnt: 0,
currentDuty: '0',
otherDutyStart: '',
otherDutyEnd: '',
offDutyReason: '获取失败Network Error!',
dutyRecoverTime: '获取失败Network Error!',
place: '204',