fix: memberDutyInfo api; dutyInfo card in MainPage
parent
0dc87d06d6
commit
7e3ad80121
3
.env.dev
3
.env.dev
|
|
@ -1,3 +1,4 @@
|
||||||
# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config
|
# 配置文档参考 https://taro-docs.jd.com/docs/next/env-mode-config
|
||||||
TARO_APP_ID="wx636eb7cf2b84f305"
|
TARO_APP_ID="wx636eb7cf2b84f305"
|
||||||
TARO_APP_API="https://ate.zjueva.net"
|
TARO_APP_API="https://ate.zjueva.net"
|
||||||
|
# TARO_APP_API="http://127.0.0.1:9527"
|
||||||
18
doc/api.md
18
doc/api.md
|
|
@ -461,9 +461,14 @@ data:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"isInDuty": true,
|
"isInDuty": true, // 指示成员其当前是否在值班
|
||||||
"inDutyCnt": 3,
|
"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
|
```json
|
||||||
{
|
{
|
||||||
"isInDuty": false,
|
"isInDuty": false,
|
||||||
"offDutyReason": "学园维修",
|
"inDutyCnt": 0,
|
||||||
|
"currentDuty": "off", // "0" => 正常值班下班,"others" => 其他值班下班,"off" => 值班暂停
|
||||||
|
"place": "", // 只有当 currentDuty 为 others 时,place 才不为空
|
||||||
|
"otherDutyStart": "",
|
||||||
|
"otherDutyEnd": "",
|
||||||
|
"offDutyReason": "期中考试周",
|
||||||
"dutyRecoverTime": "下周一"
|
"dutyRecoverTime": "下周一"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -500,6 +510,8 @@ Request
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"token": "token_test",
|
"token": "token_test",
|
||||||
|
"week": "2",
|
||||||
|
"shift": "3",
|
||||||
"conclusion": "周四第三班,一人请假,共收两台电脑,均劝退已取回。由上一班交接两台电脑,其中一台维修成功已取回,一台仍在维修。"
|
"conclusion": "周四第三班,一人请假,共收两台电脑,均劝退已取回。由上一班交接两台电脑,其中一台维修成功已取回,一台仍在维修。"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
10
mock/api.ts
10
mock/api.ts
|
|
@ -120,9 +120,13 @@ export default {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
isInDuty: true,
|
isInDuty: true,
|
||||||
inDutyCnt: 6,
|
inDutyCnt: 3,
|
||||||
currentDuty: '3',
|
currentDuty: 'others',
|
||||||
place: '204',
|
otherDutyStart: '2024-03-07T09:30:48.523303',
|
||||||
|
otherDutyEnd: '2024-03-07T13:30:48.523303',
|
||||||
|
place: '蓝田',
|
||||||
|
offDutyReason: '',
|
||||||
|
dutyRecoverTime: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'POST /member/askleave': {
|
'POST /member/askleave': {
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,19 @@ export class DutyData {
|
||||||
}
|
}
|
||||||
|
|
||||||
isInDuty: boolean;
|
isInDuty: boolean;
|
||||||
inDutyCnt?: number;
|
inDutyCnt: number;
|
||||||
currentDuty?: 'off' | '0' | '1' | '2' | '3' | 'others';
|
currentDuty: 'off' | '0' | '1' | '2' | '3' | 'others';
|
||||||
otherDutyStart?: string;
|
otherDutyStart: string;
|
||||||
otherDutyEnd?: string;
|
otherDutyEnd: string;
|
||||||
offDutyReason?: string;
|
offDutyReason: string;
|
||||||
dutyRecoverTime?: string;
|
dutyRecoverTime: string;
|
||||||
place: string;
|
place: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Card extends Component {
|
class Card extends Component {
|
||||||
props = {
|
props = {
|
||||||
isInDuty: false,
|
isInDuty: false,
|
||||||
place: '东三-204',
|
place: pt.get().common.place,
|
||||||
};
|
};
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
const inDuty = this.props.isInDuty;
|
const inDuty = this.props.isInDuty;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ interface MainPageState {
|
||||||
fixList: Array<TicketListItem>;
|
fixList: Array<TicketListItem>;
|
||||||
rs: RequestState;
|
rs: RequestState;
|
||||||
dutyData: DutyData;
|
dutyData: DutyData;
|
||||||
inDutyCnt: number;
|
|
||||||
dutyInfoCard: CardContent;
|
dutyInfoCard: CardContent;
|
||||||
stepInfoCard: CardContent;
|
stepInfoCard: CardContent;
|
||||||
tipsInfoCard: CardContent;
|
tipsInfoCard: CardContent;
|
||||||
|
|
@ -62,7 +61,6 @@ interface MainPageState {
|
||||||
export default class MainPage extends Component<{}, MainPageState> {
|
export default class MainPage extends Component<{}, MainPageState> {
|
||||||
state = {
|
state = {
|
||||||
dutyData: new DutyData(),
|
dutyData: new DutyData(),
|
||||||
inDutyCnt: 0,
|
|
||||||
dutyInfoCard: {
|
dutyInfoCard: {
|
||||||
title: '',
|
title: '',
|
||||||
note: '',
|
note: '',
|
||||||
|
|
@ -91,7 +89,6 @@ export default class MainPage extends Component<{}, MainPageState> {
|
||||||
const ptPage = wechatUser.getAccess() ? 'memberPage' : 'mainPage';
|
const ptPage = wechatUser.getAccess() ? 'memberPage' : 'mainPage';
|
||||||
this.setState({
|
this.setState({
|
||||||
dutyData: new DutyData(),
|
dutyData: new DutyData(),
|
||||||
inDutyCnt: 0,
|
|
||||||
dutyInfoCard: {
|
dutyInfoCard: {
|
||||||
title: pt.get()[ptPage].cardTitle.dutyInfo,
|
title: pt.get()[ptPage].cardTitle.dutyInfo,
|
||||||
note: pt.get()[ptPage].cardTips.dutyInfo,
|
note: pt.get()[ptPage].cardTips.dutyInfo,
|
||||||
|
|
@ -130,7 +127,10 @@ export default class MainPage extends Component<{}, MainPageState> {
|
||||||
|
|
||||||
handleCnt(inDutyCnt: number) {
|
handleCnt(inDutyCnt: number) {
|
||||||
this.setState({
|
this.setState({
|
||||||
inDutyCnt: inDutyCnt,
|
dutyData: {
|
||||||
|
...this.state.dutyData,
|
||||||
|
inDutyCnt: inDutyCnt,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return inDutyCnt;
|
return inDutyCnt;
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ export default class MainPage extends Component<{}, MainPageState> {
|
||||||
min={0}
|
min={0}
|
||||||
max={10}
|
max={10}
|
||||||
step={1}
|
step={1}
|
||||||
value={this.state.inDutyCnt}
|
value={this.state.dutyData.inDutyCnt}
|
||||||
onChange={this.handleCnt.bind(this)}
|
onChange={this.handleCnt.bind(this)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ export interface CommonText {
|
||||||
createdAtText(time: Moment): string;
|
createdAtText(time: Moment): string;
|
||||||
offDutyReason: string;
|
offDutyReason: string;
|
||||||
place: string;
|
place: string;
|
||||||
|
dutyRecoverTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const commonTextZhCn: CommonText = {
|
export const commonTextZhCn: CommonText = {
|
||||||
|
|
@ -11,7 +12,8 @@ export const commonTextZhCn: CommonText = {
|
||||||
return '创建于 ' + time.format('YYYY-MM-DD HH:mm');
|
return '创建于 ' + time.format('YYYY-MM-DD HH:mm');
|
||||||
},
|
},
|
||||||
offDutyReason: '正常值班下班',
|
offDutyReason: '正常值班下班',
|
||||||
place: '东三-204',
|
place: '204',
|
||||||
|
dutyRecoverTime: '明天 13:30',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const commonTextEnUs: CommonText = {
|
export const commonTextEnUs: CommonText = {
|
||||||
|
|
@ -20,4 +22,5 @@ export const commonTextEnUs: CommonText = {
|
||||||
},
|
},
|
||||||
offDutyReason: 'Normal Shift',
|
offDutyReason: 'Normal Shift',
|
||||||
place: 'E3-204',
|
place: 'E3-204',
|
||||||
|
dutyRecoverTime: 'Tomorrow 13:30',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export function changeDutyCnt(that: MainPage) {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
token: wechatUser.getToken(),
|
token: wechatUser.getToken(),
|
||||||
dutyCnt: that.state.inDutyCnt,
|
dutyCnt: that.state.dutyData.inDutyCnt,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ export function conclude(that: ConclusionPage) {
|
||||||
data: {
|
data: {
|
||||||
token: wechatUser.getToken(),
|
token: wechatUser.getToken(),
|
||||||
conclusion: that.state.conclusion,
|
conclusion: that.state.conclusion,
|
||||||
|
week: (that.state.shift[0] + 1).toString(),
|
||||||
|
shift: (that.state.shift[1] + 1).toString(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,23 @@ export function getDutyInfo(that: MainPage) {
|
||||||
rs: former.trans(true),
|
rs: former.trans(true),
|
||||||
dutyData: data,
|
dutyData: data,
|
||||||
});
|
});
|
||||||
if (data.currentDuty === '0') {
|
if (!data.isInDuty) {
|
||||||
that.setState({
|
that.setState({
|
||||||
dutyData: {
|
dutyData: {
|
||||||
...that.state.dutyData,
|
...that.state.dutyData,
|
||||||
place: pt.get().common.place,
|
|
||||||
offDutyReason: pt.get().common.offDutyReason,
|
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) => {
|
.catch((err) => {
|
||||||
|
|
@ -42,6 +51,10 @@ export function getDutyInfo(that: MainPage) {
|
||||||
rs: former.trans(false),
|
rs: former.trans(false),
|
||||||
dutyData: {
|
dutyData: {
|
||||||
isInDuty: false,
|
isInDuty: false,
|
||||||
|
inDutyCnt: 0,
|
||||||
|
currentDuty: '0',
|
||||||
|
otherDutyStart: '',
|
||||||
|
otherDutyEnd: '',
|
||||||
offDutyReason: '获取失败!Network Error!',
|
offDutyReason: '获取失败!Network Error!',
|
||||||
dutyRecoverTime: '获取失败!Network Error!',
|
dutyRecoverTime: '获取失败!Network Error!',
|
||||||
place: '204',
|
place: '204',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import MainPage from '@/pages/index';
|
import MainPage from '@/pages/index';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import wechatUser from '@/wechat';
|
import wechatUser from '@/wechat';
|
||||||
|
import pt from '@/plain-text';
|
||||||
import { getUrl } from '.';
|
import { getUrl } from '.';
|
||||||
|
|
||||||
export function getMemberDutyInfo(that: MainPage) {
|
export function getMemberDutyInfo(that: MainPage) {
|
||||||
|
|
@ -13,25 +14,24 @@ export function getMemberDutyInfo(that: MainPage) {
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
if (data.isInDuty) {
|
that.setState({
|
||||||
|
dutyData: data,
|
||||||
|
});
|
||||||
|
if (!data.isInDuty) {
|
||||||
that.setState({
|
that.setState({
|
||||||
dutyData: {
|
dutyData: {
|
||||||
isInDuty: data.isInDuty,
|
...that.state.dutyData,
|
||||||
inDutyCnt: data.inDutyCnt,
|
offDutyReason: pt.get().common.offDutyReason,
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (data.currentDuty === '0') {
|
||||||
|
that.setState({
|
||||||
|
dutyData: {
|
||||||
|
...that.state.dutyData,
|
||||||
|
place: pt.get().common.place,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
@ -39,6 +39,10 @@ export function getMemberDutyInfo(that: MainPage) {
|
||||||
that.setState({
|
that.setState({
|
||||||
dutyData: {
|
dutyData: {
|
||||||
isInDuty: false,
|
isInDuty: false,
|
||||||
|
inDutyCnt: 0,
|
||||||
|
currentDuty: '0',
|
||||||
|
otherDutyStart: '',
|
||||||
|
otherDutyEnd: '',
|
||||||
offDutyReason: '获取失败!Network Error!',
|
offDutyReason: '获取失败!Network Error!',
|
||||||
dutyRecoverTime: '获取失败!Network Error!',
|
dutyRecoverTime: '获取失败!Network Error!',
|
||||||
place: '204',
|
place: '204',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue