add AskLeave page

mgy
Dawn_Ocean 2024-04-11 15:26:11 +08:00
parent 952a6caa24
commit 1702b5aa6a
10 changed files with 181 additions and 4 deletions

View File

@ -479,7 +479,7 @@ Request
```json ```json
{ {
"token": "token_test", "token": "token_test",
"week": 1, "week": "1",
"shift": "2", "shift": "2",
"reason": "家庭原因", "reason": "家庭原因",
"substitute": "晓洋" // 未找人代班则为空 "substitute": "晓洋" // 未找人代班则为空

View File

@ -123,6 +123,9 @@ export default {
place: '204', place: '204',
}, },
}, },
'POST /member/askleave': {
success: true,
},
'POST /login': { 'POST /login': {
success: true, success: true,
data: { data: {

View File

@ -10,6 +10,7 @@ export default defineAppConfig({
'pages/user/member/member', 'pages/user/member/member',
'pages/TicketDetail/TicketDetail', 'pages/TicketDetail/TicketDetail',
'pages/TicketList/TicketList', 'pages/TicketList/TicketList',
'pages/AskLeave/AskLeave',
'pages/404/404', 'pages/404/404',
], ],
window: { window: {

View File

@ -0,0 +1,3 @@
export default definePageConfig({
usingComponents: {},
});

View File

View File

@ -0,0 +1,128 @@
import {
AtTextarea,
AtButton,
AtForm,
AtMessage,
AtInput,
AtList,
AtListItem,
} from 'taro-ui';
import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import pt from '@/plain-text';
import { Picker, View } from '@tarojs/components';
import { askLeave } from '@/service/askleave';
import './AskLeave.scss';
const submitInterval = 5000;
export default class AskLeavePage extends Component {
state = {
isLoading: false,
isDisable: false,
range: [
['1', '2', '3', '4', '5', '6', '7'],
['1', '2', '3'],
],
shift: [],
reason: '',
substitute: '',
};
componentDidMount(): void {
Taro.setNavigationBarTitle({
title: pt.get().navBar.askLeave,
});
}
onShiftSelect(shift: []) {
this.setState({
shift,
});
}
handleReasonChange(reason: string) {
this.setState({
reason,
});
}
handleSubstituteChange(substitute: string) {
this.setState({
substitute,
});
}
onSubmit() {
this.setState({
isDisable: true,
});
if (this.state.reason == '') {
Taro.atMessage({
message: pt.get().button.submitText.blank,
type: 'error',
});
setTimeout(() => {
this.setState({
isDisable: false,
});
}, submitInterval);
return;
}
askLeave(this);
setTimeout(() => {
this.setState({
isDisable: false,
});
}, submitInterval);
}
render(): ReactNode {
return (
<View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}>
<AtForm onSubmit={this.onSubmit.bind(this)}>
<AtMessage />
<Picker
mode='multiSelector'
range={this.state.range}
onChange={this.onShiftSelect.bind(this)}
value={this.state.shift}
>
<AtList>
<AtListItem
title={pt.get().askLeave.shift.title}
extraText={
pt.get().askLeave.shift.week[this.state.shift[0]] +
pt.get().askLeave.shift.shift[this.state.shift[1]]
}
/>
</AtList>
</Picker>
<AtTextarea
value={this.state.reason}
onChange={this.handleReasonChange.bind(this)}
maxLength={200}
placeholder={pt.get().reportPage.placeHolderText}
/>
<AtInput
name='substitute'
title={pt.get().askLeave.substitute.title}
type='text'
placeholder={pt.get().askLeave.substitute.placeHolder}
value={this.state.substitute}
onChange={this.handleSubstituteChange.bind(this)}
/>
<View>
<AtButton
loading={this.state.isLoading}
formType='submit'
type='primary'
disabled={this.state.isDisable}
>
{pt.get().button.buttonText.submit}
</AtButton>
</View>
</AtForm>
</View>
);
}
}

View File

@ -0,0 +1,35 @@
export interface AskLeaveText {
shift: {
title: string;
week: string[];
shift: string[];
};
substitute: {
title: string;
placeHolder: string;
};
}
export const askLeaveZhCn: AskLeaveText = {
shift: {
title: '值班时间',
week: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
shift: ['第一班', '第二班', '第三班'],
},
substitute: {
title: '替班人员',
placeHolder: '人数少于 4 时必填!',
},
};
export const askLeaveEnUs: AskLeaveText = {
shift: {
title: 'Duty time',
week: ['Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.', 'Sun.'],
shift: ['1st Shift', '2nd Shift', '3rd Shift'],
},
substitute: {
title: 'Substitute',
placeHolder: 'Must have if members are less than 4!',
},
};

View File

@ -2,6 +2,7 @@ export interface NavBarTitle {
notFound: string; notFound: string;
ticketDetail: string; ticketDetail: string;
ticketList: string; ticketList: string;
askLeave: string;
user: { user: {
myTicket: string; myTicket: string;
report: string; report: string;
@ -16,6 +17,7 @@ export const navBarTitleZhCn: NavBarTitle = {
notFound: '连接失败', notFound: '连接失败',
ticketDetail: '工单详情', ticketDetail: '工单详情',
ticketList: '所有工单', ticketList: '所有工单',
askLeave: '请假单填写',
user: { user: {
myTicket: '我的工单', myTicket: '我的工单',
report: '意见反馈', report: '意见反馈',
@ -30,6 +32,7 @@ export const navBarTitleEnUs: NavBarTitle = {
notFound: 'Failed', notFound: 'Failed',
ticketDetail: 'Ticket Detail', ticketDetail: 'Ticket Detail',
ticketList: 'All Tickets', ticketList: 'All Tickets',
askLeave: 'Ask for leave',
user: { user: {
myTicket: 'My Tickets', myTicket: 'My Tickets',
report: 'Report', report: 'Report',

View File

@ -25,6 +25,7 @@ import {
actIndicatorZhCn, actIndicatorZhCn,
} from './ActIndicator'; } from './ActIndicator';
import { NotFoundText, notFound } from './404'; import { NotFoundText, notFound } from './404';
import { AskLeaveText, askLeaveEnUs, askLeaveZhCn } from './AskLeave';
interface TextRecord { interface TextRecord {
common: CommonText; common: CommonText;
@ -46,6 +47,7 @@ interface TextRecord {
toast: ToastText; toast: ToastText;
actIndicator: ActIndicatorText; actIndicator: ActIndicatorText;
notFound: NotFoundText; notFound: NotFoundText;
askLeave: AskLeaveText;
} }
const textZhCn: TextRecord = { const textZhCn: TextRecord = {
@ -68,6 +70,7 @@ const textZhCn: TextRecord = {
toast: toastZhCn, toast: toastZhCn,
actIndicator: actIndicatorZhCn, actIndicator: actIndicatorZhCn,
notFound: notFound, notFound: notFound,
askLeave: askLeaveZhCn,
}; };
const textEnUs: TextRecord = { const textEnUs: TextRecord = {
@ -90,6 +93,7 @@ const textEnUs: TextRecord = {
toast: toastEnUs, toast: toastEnUs,
actIndicator: actIndicatorEnUs, actIndicator: actIndicatorEnUs,
notFound: notFound, notFound: notFound,
askLeave: askLeaveEnUs,
}; };
// type Lang = 'zh_CN' | 'en_US' | ...; // type Lang = 'zh_CN' | 'en_US' | ...;

View File

@ -4,7 +4,7 @@ import pt from '@/plain-text';
import wechatUser from '@/wechat'; import wechatUser from '@/wechat';
import { getUrl } from '.'; import { getUrl } from '.';
export function reportMessage(that: AskLeavePage) { export function askLeave(that: AskLeavePage) {
that.setState({ that.setState({
isLoading: true, isLoading: true,
}); });
@ -13,8 +13,8 @@ export function reportMessage(that: AskLeavePage) {
method: 'POST', method: 'POST',
data: { data: {
token: wechatUser.getToken(), token: wechatUser.getToken(),
week: that.state.week, week: that.state.range[0][that.state.shift[0]],
shift: that.state.shift, shift: that.state.range[1][that.state.shift[1]],
reason: that.state.reason, reason: that.state.reason,
substitute: that.state.substitute, substitute: that.state.substitute,
}, },