add confirm modal in AskLeave

mgy
Dawn1Ocean 2024-04-11 17:01:08 +08:00
parent a12c69cdc0
commit 0351819fa2
3 changed files with 110 additions and 23 deletions

View File

@ -135,7 +135,7 @@ export default {
'GET /checklogin': { 'GET /checklogin': {
success: true, success: true,
data: { data: {
islogin: false, islogin: true,
}, },
}, },
}; };

View File

@ -6,6 +6,7 @@ import {
AtInput, AtInput,
AtList, AtList,
AtListItem, AtListItem,
AtModal,
} from 'taro-ui'; } from 'taro-ui';
import { Component, ReactNode } from 'react'; import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro'; import Taro from '@tarojs/taro';
@ -20,11 +21,12 @@ export default class AskLeavePage extends Component {
state = { state = {
isLoading: false, isLoading: false,
isDisable: false, isDisable: false,
showModal: false,
range: [ range: [
['1', '2', '3', '4', '5', '6', '7'], ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
['1', '2', '3'], ['第一班', '第二班', '第三班'],
], ],
shift: [], shift: [0, 0],
reason: '', reason: '',
substitute: '', substitute: '',
}; };
@ -35,10 +37,45 @@ export default class AskLeavePage extends Component {
}); });
} }
onShiftSelect(shift: []) { onShiftSelect(event) {
this.setState({ this.setState({
shift, shift: event.detail.value,
}); });
console.log(event);
}
onModalClose() {
this.setState({
showModal: false,
});
setTimeout(() => {
this.setState({
isDisable: false,
});
}, submitInterval);
}
onModalCancel() {
this.setState({
showModal: false,
});
setTimeout(() => {
this.setState({
isDisable: false,
});
}, submitInterval);
}
onModalConfirm() {
this.setState({
showModal: false,
});
askLeave(this);
setTimeout(() => {
this.setState({
isDisable: false,
});
}, submitInterval);
} }
handleReasonChange(reason: string) { handleReasonChange(reason: string) {
@ -69,6 +106,12 @@ export default class AskLeavePage extends Component {
}, submitInterval); }, submitInterval);
return; return;
} }
if (this.state.substitute == '') {
this.setState({
showModal: true,
});
return;
}
askLeave(this); askLeave(this);
setTimeout(() => { setTimeout(() => {
this.setState({ this.setState({
@ -79,8 +122,19 @@ export default class AskLeavePage extends Component {
render(): ReactNode { render(): ReactNode {
return ( return (
<View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}> <View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}>
<AtForm onSubmit={this.onSubmit.bind(this)}>
<AtMessage /> <AtMessage />
<AtModal
isOpened={this.state.showModal}
title={pt.get().askLeave.modal.title}
cancelText={pt.get().modal.cancel}
confirmText={pt.get().modal.confirm}
onClose={this.onModalClose.bind(this)}
onCancel={this.onModalCancel.bind(this)}
onConfirm={this.onModalConfirm.bind(this)}
content={pt.get().askLeave.modal.content}
/>
<AtForm onSubmit={this.onSubmit.bind(this)}>
<View style={{ width: '98%', marginLeft: '1%' }}>
<Picker <Picker
mode='multiSelector' mode='multiSelector'
range={this.state.range} range={this.state.range}
@ -97,12 +151,20 @@ export default class AskLeavePage extends Component {
/> />
</AtList> </AtList>
</Picker> </Picker>
</View>
<View
className='at-article__h3'
style={{ marginTop: '20rpx', marginBottom: '20rpx' }}
>
{pt.get().askLeave.reason.title}
</View>
<AtTextarea <AtTextarea
value={this.state.reason} value={this.state.reason}
onChange={this.handleReasonChange.bind(this)} onChange={this.handleReasonChange.bind(this)}
maxLength={200} maxLength={200}
placeholder={pt.get().reportPage.placeHolderText} placeholder={pt.get().askLeave.reason.placeHolder}
/> />
<AtInput <AtInput
name='substitute' name='substitute'
title={pt.get().askLeave.substitute.title} title={pt.get().askLeave.substitute.title}

View File

@ -1,9 +1,17 @@
export interface AskLeaveText { export interface AskLeaveText {
modal: {
title: string;
content: string;
};
shift: { shift: {
title: string; title: string;
week: string[]; week: string[];
shift: string[]; shift: string[];
}; };
reason: {
title: string;
placeHolder: string;
};
substitute: { substitute: {
title: string; title: string;
placeHolder: string; placeHolder: string;
@ -11,11 +19,19 @@ export interface AskLeaveText {
} }
export const askLeaveZhCn: AskLeaveText = { export const askLeaveZhCn: AskLeaveText = {
modal: {
title: '确认无代班?',
content: '值班人数少于 4 时须填写代班人员。请假记录将会被上传保存!',
},
shift: { shift: {
title: '值班时间', title: '值班时间',
week: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], week: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
shift: ['第一班', '第二班', '第三班'], shift: ['第一班', '第二班', '第三班'],
}, },
reason: {
title: '请假原因',
placeHolder: '请在此说明请假原因',
},
substitute: { substitute: {
title: '替班人员', title: '替班人员',
placeHolder: '人数少于 4 时必填!', placeHolder: '人数少于 4 时必填!',
@ -23,11 +39,20 @@ export const askLeaveZhCn: AskLeaveText = {
}; };
export const askLeaveEnUs: AskLeaveText = { export const askLeaveEnUs: AskLeaveText = {
modal: {
title: 'Confirm no substitute?',
content:
'Must have substitute if members are less than 4! The ticket will be uploaded and saved!',
},
shift: { shift: {
title: 'Duty time', title: 'Duty time',
week: ['Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.', 'Sun.'], week: ['Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.', 'Sun.'],
shift: ['1st Shift', '2nd Shift', '3rd Shift'], shift: ['1st Shift', '2nd Shift', '3rd Shift'],
}, },
reason: {
title: 'Reason',
placeHolder: 'Leave your reason for leaving here',
},
substitute: { substitute: {
title: 'Substitute', title: 'Substitute',
placeHolder: 'Must have if members are less than 4!', placeHolder: 'Must have if members are less than 4!',